From 68f8a7b4dc1b25dd60f0f33540d2fad3841a89f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:16:12 +0000 Subject: [PATCH 1/5] Update numpy requirement from <1.27.0 to <2.1.0 in /.github/dependabot Updates the requirements on [numpy](https://github.com/numpy/numpy) to permit the latest version. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](https://github.com/numpy/numpy/compare/v0.2.0...v2.0.0) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/dependabot/constraints.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot/constraints.txt b/.github/dependabot/constraints.txt index 8ccbb95f..a6fa2590 100644 --- a/.github/dependabot/constraints.txt +++ b/.github/dependabot/constraints.txt @@ -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 From ea6aa0c175fef97450affac7751ec7b0d843b992 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Tue, 18 Jun 2024 08:49:15 +0100 Subject: [PATCH 2/5] Use np.char namespace instead of np.core.defchararray --- extra_data/write_cxi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra_data/write_cxi.py b/extra_data/write_cxi.py index 004e2a65..5d583113 100644 --- a/extra_data/write_cxi.py +++ b/extra_data/write_cxi.py @@ -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() From 50f1361525676edbf4f761da9067b716deabe9c5 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Tue, 18 Jun 2024 09:07:45 +0100 Subject: [PATCH 3/5] Fix dtype for selecting pulses in xtdf train iterator --- extra_data/components.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra_data/components.py b/extra_data/components.py index ccc31bf6..84995c53 100644 --- a/extra_data/components.py +++ b/extra_data/components.py @@ -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 From 2a1bfc4015dc9d092f6ad48e993add77a52b3045 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Tue, 18 Jun 2024 09:23:25 +0100 Subject: [PATCH 4/5] Fix location of AxisError --- extra_data/stacking.py | 9 ++++++++- extra_data/tests/test_stacking.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/extra_data/stacking.py b/extra_data/stacking.py index 151934e0..9322eefb 100644 --- a/extra_data/stacking.py +++ b/extra_data/stacking.py @@ -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', @@ -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) ) diff --git a/extra_data/tests/test_stacking.py b/extra_data/tests/test_stacking.py index 6f0cf213..fa63bc36 100644 --- a/extra_data/tests/test_stacking.py +++ b/extra_data/tests/test_stacking.py @@ -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 @@ -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) From 1508441b4d2cede4150c7c2ce9707c5ace265066 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Tue, 18 Jun 2024 09:24:32 +0100 Subject: [PATCH 5/5] Ensure seconds for timedelta are a Python int --- extra_data/reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra_data/reader.py b/extra_data/reader.py index 05fdb5d0..ad09f23a 100644 --- a/extra_data/reader.py +++ b/extra_data/reader.py @@ -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: