pipda.operator
Provide operators
Classes
OperatorCall— The operator call</>Operator— Defines the operators</>
Functions
register_operator(opclass)— Register a operator class</>
class
pipda.operator.OperatorCall(op_func, op_name, *operands)
The operator call
Parameters
op_func— The function to handle the callop_name(str) — The name of the operator
Methods
__array_ufunc__(ufunc,method,*inputs,**kwargs)(FunctionCall) — Allow numpy ufunc to work on Expression objects</>__getattr__(name)(ReferenceAttr) — Wheneverexpr.attris encountered,return a ReferenceAttr object </>__getitem__(item)(ReferenceItem) — Wheneverexpr[item]is encountered,return a ReferenceAttr object </>__hash__()(int) — Make it hashable</>__index__()— Allow Expression object to work as index or part of slice</>__iter__()— Forbiden iterating on Expression objects</>__str__()— String representation of the operator call</>
method
__array_ufunc__(ufunc, method, *inputs, **kwargs) → FunctionCall
Allow numpy ufunc to work on Expression objects
method
__getattr__(name) → ReferenceAttr
Whenever expr.attr is encountered,return a ReferenceAttr object
method
__getitem__(item) → ReferenceItem
Whenever expr[item] is encountered,return a ReferenceAttr object
method
__str__()
String representation of the operator call
class
pipda.operator.Operator()
Defines the operators
By default, it inherits the operator from the builtin operator library
You can define you own operators by subclass this class and decorated it
using register_operator.
Examples
>>> @register_operator>>> class MyOperator(Operator):
>>> def add(self, x, y):
>>> return x * y
function
pipda.operator.register_operator(opclass)
Register a operator class
Can be worked as a decorator
>>> @register_operator
>>> class MyOperator(Operator):
>>> ...
Parameters
opclass— A subclass
Returns
The opclass