Spatial dimension check in `MultiIndexSet.from_degree()` is now more forgiving.
Spatial dimension check in MultiIndexSet.from_degree()
is now more forgiving.
The type and value check for spatial dimension in the constructor MultiIndexSet.from_degree()
is now more forgiving as long as the provided value:
- is strictly positive
- is a whole number
- can be compared (
<= 0
) in anif
statement without ambiguity - can be converted to an
int
without ambiguity
This means values like 4.
(a float but a whole number) or np.array([4])[0]
(i.e., type numpy.int64
is not int
) are now a valid spatial_dimension value. They all will, however, be converted to int
as the attribute value of the resulting MultiIndexSet
instance.
This commit should resolve Issue #77 (closed).
Additional changes:
- A new verification function
verify_spatial_dimension()
is added to the moduleminterpy.core.verification
. The function checks for correctness of spatial dimension and forces the verified value to be ofint
type. -
lp_degree
inMultiIndexSet.from_degree()
may now throw a custom error message when aValueError
is raised. - A new test suite for the functions in
minterpy.core.verification
is added. - The test suite on
MultiIndexSet.from_degree
is extended to include testing the behavior of passing different types and values (both valid and invalid) for spatial dimension and lp-degree.
PS: NumPy throws a DeprecationWarning
for converting an array with ndim > 0
to a scalar via float
or int
. This means that, in the future, the NumPy development team deems converting a NumPy array with dimension larger than 0
is ambiguous. We will follow this decision. Currently, passing np.array([0])
is still acceptable as a spatial dimension because NumPy still allows it; we, however, don't include such a spatial dimension in the test.