Clarify the interface of non-default constructors of the Grid class
Currently, the Grid
class supports two class methods to construct an instance of the class (i.e., factory methods).
-
from_generator()
: Construct an instance withgenerating_values
generated from the passedgenerating_function
. -
from_value_set()
: Construct an instance with "generating values", i.e., one-dimensional generating points which will be expanded to the required dimension.
The method from_generator()
generates the required "generating values" and calls from_value_set()
under the hood.
The method from_value_set()
calls the default constructor with the passed "generating values" (which is expanded to generating_points
) and sets the generating_function
to None
.
Acccording to the internal TODOs, the name "generator" is a problematic one in Python because it has already a specific meaning. I would rename it to generating function as it was done in the refactoring of the default constructor (Issue #71 (closed); MR !125 (merged)).
Furthermore, I also would like to have another method call from_points()
as an explicit method to create an instance of the Grid
class only with generating_points
(and generating_function
is set to None
).
In summary, four factory methods will be available:
-
from_degree(m, n, p, generating_function, generating_points)
: Create an instance with a complete multi-index set, the given generating function (default to Chebyshev) and generating points (default toNone
). -
from_function(multi_index, generating_function)
: Create an instance withgenerating_function
as the generating function of theGrid
instance. The required generating points will be created on the fly. This method replacesfrom_generator()
. -
from_points(multi_index, generating_points)
: Create an instance withgenerating_points
as the generating points of theGrid
instance. The generating function of the instance is set toNone
. More points may be passed than what are required by the multi-index set, however, because the generating function is not available there is a limit to upgrading the grid to a higher degree. -
from_value_set(multi_index, generating_values)
: This methods remains in place; however, it is understood that "generating values" are interpolation points in one-dimension. So it must be given either as a one-dimensional array or a two-dimensional array of a single column/row.
What are the requirements of the arguments passed to these constructors?
-
m
,n
,p
follow the requirements of multi-index set constructor. -
generating_function
: it must have the following (type) signature (Callable[[int, int], np.ndarray
). The first parameter is the polynomial degree and the second is the spatial dimension; it returns an array of generating points of shape(poly_degree + 1, spatial_dimension)
. Each column of arrays produced by the function must contain unique values (no repeats). -
generating_points
: it must be a two-dimensional array of the shape(poly_degree + 1, spatial_dimension)
wherepoly_degree
is the degree of the grid and must be larger than or equal to the maximum degree of the multi-index set across all dimensions.spatial_dimension
must be equal to the spatial dimension of the multi-index set. All values in each column must be unique. -
generating_values
: must either be a one-dimensional array or two-dimensional array with a single column or row. The length of the array must bepoly_degree + 1
wherepoly_degree
must be larger than or equal to the maximum degree of the multi-index set across all dimensions. The values must be unique (no repeats).
This issue is part of the refactoring of the Grid
class (Issue #135).