()
| 3250 | assert_equal(vals['d'], 0.5) |
| 3251 | |
| 3252 | def test_object_iter_cleanup(): |
| 3253 | # see gh-18450 |
| 3254 | # object arrays can raise a python exception in ufunc inner loops using |
| 3255 | # nditer, which should cause iteration to stop & cleanup. There were bugs |
| 3256 | # in the nditer cleanup when decref'ing object arrays. |
| 3257 | # This test would trigger valgrind "uninitialized read" before the bugfix. |
| 3258 | assert_raises(TypeError, lambda: np.zeros((17000, 2), dtype='f4') * None) |
| 3259 | |
| 3260 | # this more explicit code also triggers the invalid access |
| 3261 | arr = np.arange(ncu.BUFSIZE * 10).reshape(10, -1).astype(str) |
| 3262 | oarr = arr.astype(object) |
| 3263 | oarr[:, -1] = None |
| 3264 | assert_raises(TypeError, lambda: np.add(oarr[:, ::-1], arr[:, ::-1])) |
| 3265 | |
| 3266 | # followup: this tests for a bug introduced in the first pass of gh-18450, |
| 3267 | # caused by an incorrect fallthrough of the TypeError |
| 3268 | class T: |
| 3269 | def __bool__(self): |
| 3270 | raise TypeError("Ambiguous") |
| 3271 | assert_raises(TypeError, np.logical_or.reduce, |
| 3272 | np.array([T(), T()], dtype='O')) |
| 3273 | |
| 3274 | def test_object_iter_cleanup_reduce(): |
| 3275 | # Similar as above, but a complex reduction case that was previously |
nothing calls this directly
no test coverage detected
searching dependent graphs…