Skip to content

Commit

Permalink
Stop using np.float (#598)
Browse files Browse the repository at this point in the history
np.float has been a deprecated alias for float and is removed as of v1.24:
https://numpy.org/doc/stable/release/1.24.0-notes.html#expired-deprecations

Same for np.bool. Change all np.float->float and np.bool->bool
  • Loading branch information
dwpaley authored and rjgildea committed Jan 3, 2023
1 parent 001f0cf commit f424706
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions newsfragments/598.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stop using deprecated np.float
2 changes: 1 addition & 1 deletion src/dxtbx/format/FormatCBFFull.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def get_raw_data(self):
array_size = mid, fast
elif dtype == b"signed 64-bit real IEEE":
array_string = cbf.get_realarray_as_string()
self._raw_data = flex.double(np.fromstring(array_string, np.float))
self._raw_data = flex.double(np.fromstring(array_string, float))
parameters = cbf.get_realarrayparameters_wdims_fs()
slow, mid, fast = (parameters[7], parameters[6], parameters[5])
assert slow == 1 # sections not supported
Expand Down
3 changes: 1 addition & 2 deletions src/dxtbx/format/FormatHDF5PAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import sys

import h5py
import numpy as np

from scitbx.array_family import flex

Expand Down Expand Up @@ -54,7 +53,7 @@ def get_raw_data(self, index=None):
data = self._h5_handle[self._run]["scan_dat/raymx_data"][index]
# return flex.int(int) # this crashes!
# return flex.int(data.astype(np.int)) # this doesn't work! (data is read incorrectly)
return flex.double(data.astype(np.float))
return flex.double(data.astype(float))

def get_num_images(self):
return len(self._h5_handle[self._run]["scan_dat/N"][()])
Expand Down
2 changes: 1 addition & 1 deletion tests/nexus/test_build_dxtbx_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,6 @@ def test_dataset_as_flex_unsupported():
slices = ()
with h5py.File(" ", "w", **pytest.h5_in_memory) as f:
g = f.create_group("/foo")
d = g.create_dataset("bool", data=np.array([0, 1], dtype=np.bool))
d = g.create_dataset("bool", data=np.array([0, 1], dtype=bool))
with pytest.raises(TypeError, match="Unsupported dtype .*"):
dxtbx.nexus._dataset_as_flex(d, slices)

0 comments on commit f424706

Please sign in to comment.