Skip to content

Commit 84d776a

Browse files
committed
test_serialize_numba: Workaround issue with np.empty_like in NP 1.23
In NumPy 1.23, the strides of empty arrays are 0 instead of the item size, due to numpy/numpy#21477 - however, `np.empty_like` seems to create non-zero-strided arrays from a zero-strided empty array, and copying to the host from a device array with zero strides fails a compatibility check in Numba. This commit works around the issue by calling `copy_to_host()` with no arguments, allowing Numba to create an array on the host that is compatible with the device array - the resulting implementation is functionally equivalent and slightly simpler, so I believe this change could remain permanant rather than requiring a revert later.
1 parent ee43309 commit 84d776a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

distributed/protocol/tests/test_numba.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ def test_serialize_numba(shape, dtype, order, serializers):
3131
elif serializers[0] == "dask":
3232
assert all(isinstance(f, memoryview) for f in frames)
3333

34-
hx = np.empty_like(ary)
35-
hy = np.empty_like(ary)
36-
x.copy_to_host(hx)
37-
y.copy_to_host(hy)
34+
hx = x.copy_to_host()
35+
hy = y.copy_to_host()
3836
assert (hx == hy).all()
3937

4038

0 commit comments

Comments
 (0)