Skip to content

Commit 39a937e

Browse files
committed
Fix for numpy>=1.24.0
Minimal `example.py`: ```python from cassandra.cluster import Cluster from cassandra.query import tuple_factory from cassandra.protocol import NumpyProtocolHandler import pandas as pd cluster = Cluster() session = cluster.connect() session.row_factory = tuple_factory session.client_protocol_handler = NumpyProtocolHandler print(pd.DataFrame(session.execute("SELECT broadcast_port FROM system.local").one())) ``` Result with numpy<1.24.0: ``` $ python3 example.py broadcast_port 0 7000 ``` Result with numpy>=1.24.0: ``` $ python3 example.py /usr/lib/python3/dist-packages/cassandra/io/libevreactor.py:370: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar. (This may have returned Python scalars in past versions. self.process_io_buffer() Empty DataFrame Columns: [] Index: [] ```
1 parent 8c41066 commit 39a937e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cassandra/numpy_parser.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def make_array(coltype, array_size):
134134
"""
135135
try:
136136
a = np.ma.empty((array_size,), dtype=_cqltype_to_numpy[coltype])
137-
a.mask = np.zeros((array_size,), dtype=np.bool)
137+
a.mask = np.zeros((array_size,), dtype=bool)
138138
except KeyError:
139139
a = np.empty((array_size,), dtype=obj_dtype)
140140
return a

0 commit comments

Comments
 (0)