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

Method test_structured_equal

numpy/core/tests/test_ufunc.py:2327–2339  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2325 out=None, invalid=0)
2326
2327 def test_structured_equal(self):
2328 # https://github.com/numpy/numpy/issues/4855
2329
2330 class MyA(np.ndarray):
2331 def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
2332 return getattr(ufunc, method)(*(input.view(np.ndarray)
2333 for input in inputs), **kwargs)
2334 a = np.arange(12.).reshape(4,3)
2335 ra = a.view(dtype=('f8,f8,f8')).squeeze()
2336 mra = ra.view(MyA)
2337
2338 target = np.array([ True, False, False, False], dtype=bool)
2339 assert_equal(np.all(target == (mra == ra[0])), True)
2340
2341 def test_scalar_equal(self):
2342 # Scalar comparisons should always work, without deprecation warnings.

Callers

nothing calls this directly

Calls 5

assert_equalFunction · 0.90
reshapeMethod · 0.80
squeezeMethod · 0.45
viewMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected