MCPcopy
hub / github.com/numpy/numpy / test_priority

Method test_priority

numpy/_core/tests/test_umath.py:3336–3377  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3334 assert_array_equal(x, np.array(1))
3335
3336 def test_priority(self):
3337
3338 class A:
3339 def __array__(self, dtype=None, copy=None):
3340 return np.zeros(1)
3341
3342 def __array_wrap__(self, arr, context, return_scalar):
3343 r = type(self)()
3344 r.arr = arr
3345 r.context = context
3346 return r
3347
3348 class B(A):
3349 __array_priority__ = 20.
3350
3351 class C(A):
3352 __array_priority__ = 40.
3353
3354 x = np.zeros(1)
3355 a = A()
3356 b = B()
3357 c = C()
3358 f = ncu.minimum
3359 assert_(type(f(x, x)) is np.ndarray)
3360 assert_(type(f(x, a)) is A)
3361 assert_(type(f(x, b)) is B)
3362 assert_(type(f(x, c)) is C)
3363 assert_(type(f(a, x)) is A)
3364 assert_(type(f(b, x)) is B)
3365 assert_(type(f(c, x)) is C)
3366
3367 assert_(type(f(a, a)) is A)
3368 assert_(type(f(a, b)) is B)
3369 assert_(type(f(b, a)) is B)
3370 assert_(type(f(b, b)) is B)
3371 assert_(type(f(b, c)) is C)
3372 assert_(type(f(c, b)) is C)
3373 assert_(type(f(c, c)) is C)
3374
3375 assert_(type(ncu.exp(a) is A))
3376 assert_(type(ncu.exp(b) is B))
3377 assert_(type(ncu.exp(c) is C))
3378
3379 def test_failing_wrap(self):
3380

Callers

nothing calls this directly

Calls 5

assert_Function · 0.90
AClass · 0.70
BClass · 0.70
CClass · 0.70
fFunction · 0.70

Tested by

no test coverage detected