(self)
| 278 | assert_array_equal(xe, array([0., 0.25, 0.5, 0.75, 1])) |
| 279 | |
| 280 | def test_dispatch(self): |
| 281 | class ShouldDispatch: |
| 282 | def __array_function__(self, function, types, args, kwargs): |
| 283 | return types, args, kwargs |
| 284 | |
| 285 | xy = [1, 2] |
| 286 | s_d = ShouldDispatch() |
| 287 | r = histogram2d(s_d, xy) |
| 288 | # Cannot use assert_equal since that dispatches... |
| 289 | assert_(r == ((ShouldDispatch,), (s_d, xy), {})) |
| 290 | r = histogram2d(xy, s_d) |
| 291 | assert_(r == ((ShouldDispatch,), (xy, s_d), {})) |
| 292 | r = histogram2d(xy, xy, bins=s_d) |
| 293 | assert_(r, ((ShouldDispatch,), (xy, xy), dict(bins=s_d))) |
| 294 | r = histogram2d(xy, xy, bins=[s_d, 5]) |
| 295 | assert_(r, ((ShouldDispatch,), (xy, xy), dict(bins=[s_d, 5]))) |
| 296 | assert_raises(Exception, histogram2d, xy, xy, bins=[s_d]) |
| 297 | r = histogram2d(xy, xy, weights=s_d) |
| 298 | assert_(r, ((ShouldDispatch,), (xy, xy), dict(weights=s_d))) |
| 299 | |
| 300 | @pytest.mark.parametrize(("x_len", "y_len"), [(10, 11), (20, 19)]) |
| 301 | def test_bad_length(self, x_len, y_len): |
no test coverage detected