Skip to content

Commit

Permalink
Merge pull request #530 from European-XFEL/dependabot/pip/dot-github/…
Browse files Browse the repository at this point in the history
…dependabot/numpy-lt-2.1.0

Update numpy requirement from <1.27.0 to <2.1.0 in /.github/dependabot
  • Loading branch information
takluyver authored Jun 20, 2024
2 parents 3373d13 + 1508441 commit beb346d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ h5py<3.12.0
karabo-bridge==0.7.0
msgpack<=1.0.8
msgpack-numpy==0.4.8
numpy<1.27.0
numpy<2.1.0
pandas<2.3.0
Pillow<10.4.0
psutil==5.9.8
Expand Down
2 changes: 1 addition & 1 deletion extra_data/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ def _select_pulse_ids(self, pulse_ids):
else:
desired = val

return np.nonzero(np.isin(pulse_ids, desired))[0]
return np.nonzero(np.isin(pulse_ids, desired))[0].astype(np.uint64)

def _select_pulse_indices(self, count):
"""Select pulses by index
Expand Down
2 changes: 1 addition & 1 deletion extra_data/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ def info(self, details_for_sources=()):
last_train = self.train_ids[-1]
seconds, deciseconds = divmod((last_train - first_train + 1), 10)
try:
td = datetime.timedelta(seconds=seconds)
td = datetime.timedelta(seconds=int(seconds))
except OverflowError: # Can occur if a train ID is corrupted
span_txt = "OverflowError (one or more train IDs are probably wrong)"
else:
Expand Down
9 changes: 8 additions & 1 deletion extra_data/stacking.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import numpy as np
import re

# numpy.exceptions exists from 1.25 onwards, but for Python 3.8 we still support
# numpy 1.24. We can clean this up once we require Python >= 3.9.
try:
from numpy.exceptions import AxisError
except ImportError:
from numpy import AxisError

__all__ = [
'stack_data',
'stack_detector_data',
Expand Down Expand Up @@ -238,7 +245,7 @@ def squeeze(self, axis=None):
try:
slices[ax] = 0
except IndexError:
raise np.AxisError(
raise AxisError(
"axis {} is out of bounds for array of dimension {}"
.format(ax, self.ndim)
)
Expand Down
9 changes: 8 additions & 1 deletion extra_data/tests/test_stacking.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import numpy as np
import pytest

# numpy.exceptions exists from 1.25 onwards, but for Python 3.8 we still support
# numpy 1.24. We can clean this up once we require Python >= 3.9.
try:
from numpy.exceptions import AxisError
except ImportError:
from numpy import AxisError

from extra_data import RunDirectory, stack_data, stack_detector_data
from extra_data.stacking import StackView

Expand Down Expand Up @@ -174,5 +181,5 @@ def test_stackview_squeeze():
assert sv.squeeze(axis=0).shape == (1, 4)
assert sv.squeeze(axis=-2).shape == (1, 4)

with pytest.raises(np.AxisError):
with pytest.raises(AxisError):
sv.squeeze(axis=4)
2 changes: 1 addition & 1 deletion extra_data/write_cxi.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def write(self, filename, fillvalues=None):
- mask: 0xffffffff (uint32)
"""
pulse_ids = self.collect_pulse_ids()
experiment_ids = np.core.defchararray.add(np.core.defchararray.add(
experiment_ids = np.char.add(np.char.add(
self.train_ids_perframe.astype(str), ':'), pulse_ids.astype(str))

layouts = self.collect_data()
Expand Down

0 comments on commit beb346d

Please sign in to comment.