Expanding and/or reconsidering functionality of `zero`
The Zero
class overrides several operators that make it act like 0. However, there are several other operators that could be useful. Next to that, some operators are not strictly necessary or error-prone.
In my opinion, we should either reduce OR expand it to its minimum/maximum.
Possible expansions to consider:
-
__matmul__
.- (-) Not directly used in pymablock
- (+) No side effects
-
__bool__
:- (-) Not directly used in pymablock, limited use case
- (+) No side effects
-
__array_ufunc__ = None
: correctly multiply with numpy arrays, does not convert todtype=object
.- (-) numpy specific
- (+) robustness, reduces likelihood for mistakes
-
_op_priority = np.inf
: support right multiplication with sympy matrices- (-) sympy specific
- (+) robustness, reduces likelihood for mistakes
Possible existing operators to reconsider:
-
__eq__
:- (-)
0 == zero
returnsFalse
- (-) using
obj is zero
does a better job
- (-)
-
__rsub__
,__rmul__
,__radd__
,__rmatmul__
:- (-) Not guaranteed to work with any object, also see (3) and (4) for a partial remedy
- (-) Not directly used in pymablock
Edited by Hugo Kerstens