MCPcopy Create free account
hub / github.com/dask/dask / _bind_operator

Method _bind_operator

dask/utils.py:1421–1442  ·  view source on GitHub ↗

bind operator to this class

(cls, op)

Source from the content-addressed store, hash-verified

1419
1420 @classmethod
1421 def _bind_operator(cls, op):
1422 """bind operator to this class"""
1423 name = op.__name__
1424
1425 if name.endswith("_"):
1426 # for and_ and or_
1427 name = name[:-1]
1428 elif name == "inv":
1429 name = "invert"
1430
1431 meth = f"__{name}__"
1432
1433 if name in ("abs", "invert", "neg", "pos"):
1434 setattr(cls, meth, cls._get_unary_operator(op))
1435 else:
1436 setattr(cls, meth, cls._get_binary_operator(op))
1437
1438 if name in ("eq", "gt", "ge", "lt", "le", "ne", "getitem"):
1439 return
1440
1441 rmeth = f"__r{name}__"
1442 setattr(cls, rmeth, cls._get_binary_operator(op, inv=True))
1443
1444 @classmethod
1445 def _get_unary_operator(cls, op):

Callers 1

delayed.pyFile · 0.80

Calls 2

_get_unary_operatorMethod · 0.80
_get_binary_operatorMethod · 0.45

Tested by

no test coverage detected