Skip to content

Refactored the default constructor of the Grid Class and Other Enhancements

Damar Wicaksono requested to merge dev-71 into dev

This merge request is primarily about the default constructor of the Grid class now with optional arguments generating_function and generating_points.

The list of modifications include:

  • Refactored the default constructor to optionally accept generating_function and generating_points. If both of them are not specified, it uses default generating function which is, as before, the Leja-ordered Chebyshev-Lobatto nodes.
  • Introduced several internal methods for Grid class to verify and assign the arguments passed to the constructor.
  • Added expand_dim() method to the Grid class instances to encapsulate the procedure of expanding the dimension.
  • Made several properties of the Grid instances, i.e., multi_index, generating_function, generating_points, poly_degree, and spatial_dimension as read-only.
  • Improved exception handling - Handle LinAlgError in polynomial transformations tests especially for non-downward closed sets.
  • Refactor check_type_n_values() in minterpy.utils.verification to ensure better clarity and singularity of functionality.
  • Reorganized the minterpy.core.grid module.
  • Updated the documentation to match with implemented changes.

Furthermore, tests have been added to ensure the features work as expected and if bad inputs are handled with appropriate errors.

The changes introduced in this MR are ensured such that the typical call to construct an instance of Grid (i.e., without any arguments) stays the same and produces an instance with equivalent behavior.

This MR should resolve Issue #71 (closed) and part of the refactoring of the Grid class (see Issue #135).

Additional Information

The decision to include the generating function as a parameter to the default constructor and to store it as a read-only parameter is due to the importance of such function that was not emphasized before. Many internal procedures in Minterpy associated with polynomial manipulations (addition, multiplication, etc.) implicitly modify the underlying grids which then require a call to generating function to construct new generating points (and subsequently, unisolvent nodes). Before, it is always implied that the generating function is the built-in Leja-ordered Chebyshev-Lobatto nodes and there is no straightforward way to change this; it is always called internally.

Furthermore, even if a Grid is created with a different generating function (or generating values from another function), the updated Grid will always revert to the default generating function silently. This may cause problems later on.

After these merge request, the call to the default constructor of the Grid class may follow one of the following paths:

generating_function specified? \ generating_points specified? no yes
no generating_function is set to the default LCL, generating_points is created accordingly generating_function set to None, generating_points is set according to the specified value
yes generating_function set to the specified value, generating_points is created accordingly generating_function and generating_points must be consistent

LCL: Leja-ordered Chebyshev-Lobatto nodes

If the generating function is None, then the instance of Grid may be limited in terms of how it can be updated. With limited generating points, two instances of Grid without consistent generating functions may not be able to construct unisolvent nodes to support polynomials of a higher degree.

Edited by Damar Wicaksono

Merge request reports

Loading