Skip to content

Commit a35dc6c

Browse files
committed
Fix NumPy 2.0 compatibility in numpy_parser
The `ndarray.newbyteorder()` method was removed in NumPy 2.0. Use `arr.view(arr.dtype.newbyteorder())` instead, which is compatible with both NumPy 1.x and 2.x. This fixes the failing numpy protocol handler integration tests that started running after numpy was added to dev dependencies.
1 parent 4331c5b commit a35dc6c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

cassandra/numpy_parser.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,6 @@ def make_native_byteorder(arr):
181181
# accordingly (e.g. from '>i8' to '<i8')
182182
#
183183
# Ignore any object arrays of dtype('O')
184-
return arr.byteswap().newbyteorder()
184+
# Note: arr.newbyteorder() was removed in NumPy 2.0, use view() instead
185+
return arr.byteswap().view(arr.dtype.newbyteorder())
185186
return arr

0 commit comments

Comments
 (0)