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

Method test_priority

numpy/core/tests/test_umath.py:3056–3097  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3054 assert_equal(x.arr, np.zeros(1))
3055
3056 def test_priority(self):
3057
3058 class A:
3059 def __array__(self):
3060 return np.zeros(1)
3061
3062 def __array_wrap__(self, arr, context):
3063 r = type(self)()
3064 r.arr = arr
3065 r.context = context
3066 return r
3067
3068 class B(A):
3069 __array_priority__ = 20.
3070
3071 class C(A):
3072 __array_priority__ = 40.
3073
3074 x = np.zeros(1)
3075 a = A()
3076 b = B()
3077 c = C()
3078 f = ncu.minimum
3079 assert_(type(f(x, x)) is np.ndarray)
3080 assert_(type(f(x, a)) is A)
3081 assert_(type(f(x, b)) is B)
3082 assert_(type(f(x, c)) is C)
3083 assert_(type(f(a, x)) is A)
3084 assert_(type(f(b, x)) is B)
3085 assert_(type(f(c, x)) is C)
3086
3087 assert_(type(f(a, a)) is A)
3088 assert_(type(f(a, b)) is B)
3089 assert_(type(f(b, a)) is B)
3090 assert_(type(f(b, b)) is B)
3091 assert_(type(f(b, c)) is C)
3092 assert_(type(f(c, b)) is C)
3093 assert_(type(f(c, c)) is C)
3094
3095 assert_(type(ncu.exp(a) is A))
3096 assert_(type(ncu.exp(b) is B))
3097 assert_(type(ncu.exp(c) is C))
3098
3099 def test_failing_wrap(self):
3100

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected