Skip to content

Commit

Permalink
disable ufunc dispatch for now
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Paine <[email protected]>
  • Loading branch information
timkpaine committed Feb 21, 2024
1 parent 448e0e3 commit 7c74506
Showing 1 changed file with 0 additions and 74 deletions.
74 changes: 0 additions & 74 deletions csp/impl/wiring/edge.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
from types import MappingProxyType

_UFUNC_MAP = MappingProxyType(
{
"add": lambda x, y: x.__add__(y) if isinstance(x, Edge) else y.__add__(x),
"subtract": lambda x, y: x.__sub__(y) if isinstance(x, Edge) else y.__sub__(x),
"multiply": lambda x, y: x.__mul__(y) if isinstance(x, Edge) else y.__mul__(x),
"divide": lambda x, y: x.__truediv__(y) if isinstance(x, Edge) else y.__truediv__(x),
"floor_divide": lambda x, y: x.__floordiv__(y) if isinstance(x, Edge) else y.__floordiv__(x),
"power": lambda x, y: x.pow(y),
"pos": lambda x: x.pos(),
"neg": lambda x: x.neg(),
"abs": lambda x: x.abs(),
"log": lambda x: x.ln(),
"log2": lambda x: x.log2(),
"log10": lambda x: x.log10(),
"exp": lambda x: x.exp(),
"exp2": lambda x: x.exp2(),
"sin": lambda x: x.sin(),
"cos": lambda x: x.cos(),
"tan": lambda x: x.tan(),
"arcsin": lambda x: x.asin(),
"arccos": lambda x: x.acos(),
"arctan": lambda x: x.atan(),
"sqrt": lambda x: x.sqrt(),
"erf": lambda x: x.erf(),
}
)


class Edge:
__slots__ = ["tstype", "nodedef", "output_idx", "basket_idx"]
Expand Down Expand Up @@ -209,36 +180,6 @@ def exp(self):

return csp.exp(self)

def sin(self):
import csp

return csp.sin(self)

def cos(self):
import csp

return csp.cos(self)

def tan(self):
import csp

return csp.tan(self)

def arcsin(self):
import csp

return csp.arcsin(self)

def arccos(self):
import csp

return csp.arccos(self)

def arctan(self):
import csp

return csp.arctan(self)

def sqrt(self):
import csp

Expand All @@ -249,21 +190,6 @@ def erf(self):

return csp.erf(self)

def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
ufunc_func = _UFUNC_MAP.get(ufunc.__name__, None)
if ufunc_func:
if ufunc.__name__ in (
"add",
"subtract",
"multiply",
"divide",
"floor_divide",
"power",
):
return ufunc_func(inputs[0], inputs[1])
return ufunc_func(self)
raise NotImplementedError("Not Implemented for type csp.Edge: {}".format(ufunc))

def __getattr__(self, key):
from csp.impl.struct import Struct

Expand Down

0 comments on commit 7c74506

Please sign in to comment.