Clean up Polynomial Coefficients as a Property of MultivariatePolynomialSingleABC
Polynomial coefficients are stored in the property coeffs
which also includes a setter that will verify any given values before they are assigned.
The coefficients of a polynomial themselves may first be None
, in which case the polynomial is termed "uninitialized" in the codebase.
Accessing the coefficients of an uninitialized polynomial raises an exception which I find rather unintuitive.
It does, however, provide a single error point for attempting operations that require initialized polynomials (__add__
, __mul__
, __neg__
, etc.) on uninitialized polynomials as long as the (public) property is accessed (i.e., coeffs
instead of _coeffs
).
Refactor and clean up the docstrings of coeffs
property; in particular perhaps introduce a better encapsulation of the verification procedure for polynomial coefficients. For instance, while currently the coefficients may be assigned integer values, most of the underlying Numba JIT-compiled implementations require specifically numpy.float64
type for the coefficients and will raise TypeError
if another type is supplied (most prominently, perhaps, int types).
There might be a case to "normalize" the stored coefficient values to strictly numpy.float64
type because that's the type that the Numba functions can operate with anyway.