()
| 2999 | assert_equal(vals['d'], 0.5) |
| 3000 | |
| 3001 | def test_object_iter_cleanup(): |
| 3002 | # see gh-18450 |
| 3003 | # object arrays can raise a python exception in ufunc inner loops using |
| 3004 | # nditer, which should cause iteration to stop & cleanup. There were bugs |
| 3005 | # in the nditer cleanup when decref'ing object arrays. |
| 3006 | # This test would trigger valgrind "uninitialized read" before the bugfix. |
| 3007 | assert_raises(TypeError, lambda: np.zeros((17000, 2), dtype='f4') * None) |
| 3008 | |
| 3009 | # this more explicit code also triggers the invalid access |
| 3010 | arr = np.arange(np.BUFSIZE * 10).reshape(10, -1).astype(str) |
| 3011 | oarr = arr.astype(object) |
| 3012 | oarr[:, -1] = None |
| 3013 | assert_raises(TypeError, lambda: np.add(oarr[:, ::-1], arr[:, ::-1])) |
| 3014 | |
| 3015 | # followup: this tests for a bug introduced in the first pass of gh-18450, |
| 3016 | # caused by an incorrect fallthrough of the TypeError |
| 3017 | class T: |
| 3018 | def __bool__(self): |
| 3019 | raise TypeError("Ambiguous") |
| 3020 | assert_raises(TypeError, np.logical_or.reduce, |
| 3021 | np.array([T(), T()], dtype='O')) |
| 3022 | |
| 3023 | def test_object_iter_cleanup_reduce(): |
| 3024 | # Similar as above, but a complex reduction case that was previously |
nothing calls this directly
no test coverage detected