MCPcopy Index your code
hub / github.com/numpy/numpy / test_dispatch

Method test_dispatch

numpy/lib/tests/test_twodim_base.py:298–316  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

296 assert_array_equal(xe, array([0., 0.25, 0.5, 0.75, 1]))
297
298 def test_dispatch(self):
299 class ShouldDispatch:
300 def __array_function__(self, function, types, args, kwargs):
301 return types, args, kwargs
302
303 xy = [1, 2]
304 s_d = ShouldDispatch()
305 r = histogram2d(s_d, xy)
306 # Cannot use assert_equal since that dispatches...
307 assert_(r == ((ShouldDispatch,), (s_d, xy), {}))
308 r = histogram2d(xy, s_d)
309 assert_(r == ((ShouldDispatch,), (xy, s_d), {}))
310 r = histogram2d(xy, xy, bins=s_d)
311 assert_(r, ((ShouldDispatch,), (xy, xy), {'bins': s_d}))
312 r = histogram2d(xy, xy, bins=[s_d, 5])
313 assert_(r, ((ShouldDispatch,), (xy, xy), {'bins': [s_d, 5]}))
314 assert_raises(Exception, histogram2d, xy, xy, bins=[s_d])
315 r = histogram2d(xy, xy, weights=s_d)
316 assert_(r, ((ShouldDispatch,), (xy, xy), {'weights': s_d}))
317
318 @pytest.mark.parametrize(("x_len", "y_len"), [(10, 11), (20, 19)])
319 def test_bad_length(self, x_len, y_len):

Callers 1

test_dispatcherFunction · 0.80

Calls 4

histogram2dFunction · 0.90
assert_Function · 0.90
assert_raisesFunction · 0.90
ShouldDispatchClass · 0.85

Tested by

no test coverage detected