MCPcopy Create free account
hub / github.com/numpy/numpy / __array_ufunc__

Method __array_ufunc__

numpy/core/tests/test_multiarray.py:4028–4031  ·  view source on GitHub ↗
(self, ufunc, method, *inputs, **kw)

Source from the content-addressed store, hash-verified

4026 # regression test for gh-9112
4027 class PowerOnly(np.ndarray):
4028 def __array_ufunc__(self, ufunc, method, *inputs, **kw):
4029 if ufunc is not np.power:
4030 raise NotImplementedError
4031 return "POWER!"
4032 # explicit cast to float, to ensure the fast power path is taken.
4033 a = np.array(5., dtype=np.float64).view(PowerOnly)
4034 assert_equal(a ** 2.5, "POWER!")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected