Skip to content

Commit 29783db

Browse files
authored
Merge pull request #2711 from kif/2710_numpy_2.4_compatibility
Ensure compatibility with numpy 2.4
2 parents caea122 + 8d16fc5 commit 29783db

File tree

18 files changed

+649
-642
lines changed

18 files changed

+649
-642
lines changed

doc/source/usage/tutorial/Goniometer/Rotation-Pilatus100k/Multi120_Pilatus100k.ipynb

Lines changed: 441 additions & 438 deletions
Large diffs are not rendered by default.

doc/source/usage/tutorial/Goniometer/Rotation-Pilatus100k/ROBL_v1.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
},
99
"wavelength": 7.7490120575e-11,
1010
"param": [
11-
0.8000839765720902,
12-
-0.03622366935257193,
13-
0.10321742056906069,
14-
0.07425314200070052,
15-
0.0630293870086395,
16-
0.017456686122063372
11+
0.7962627056799623,
12+
-0.0049159070708722375,
13+
0.16173982201327142,
14+
0.1467223695409547,
15+
0.024037314223167905,
16+
0.0174564204732632
1717
],
1818
"param_names": [
1919
"dist",

doc/source/usage/tutorial/Goniometer/Rotation-Pilatus100k/ROBL_v2.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
},
99
"wavelength": 7.7490120575e-11,
1010
"param": [
11-
0.800377661083084,
12-
-0.04622310182279707,
13-
0.07507822615541171,
14-
0.0397185984812323,
15-
-5.3923464865334315e-05,
16-
0.07554776101239513,
17-
0.017456754277306065
11+
0.794646251128909,
12+
-0.07363470214404985,
13+
0.08507222455014007,
14+
0.05213274215875943,
15+
2.0690405345504903e-05,
16+
0.11017698636732509,
17+
0.017456980094156
1818
],
1919
"param_names": [
2020
"dist",

doc/source/usage/tutorial/Goniometer/Rotation-XPADS540/D2AM-15.ipynb

Lines changed: 53 additions & 51 deletions
Large diffs are not rendered by default.

doc/source/usage/tutorial/Goniometer/Translation-Pilatus6M/ID29.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
},
99
"wavelength": 9.72386e-11,
1010
"param": [
11-
-0.001187934615261645,
12-
1.0019047069064837,
13-
0.21548513632227703,
14-
0.21309905129676254,
15-
0.006612408553125347,
16-
0.002803288489340183
11+
-0.001187934613853624,
12+
1.0019047068967826,
13+
0.2154851363242808,
14+
0.213099051297216,
15+
0.00661240855438098,
16+
0.0028032884832108686
1717
],
1818
"param_names": [
1919
"dist_offset",

doc/source/usage/tutorial/Goniometer/Translation-Pilatus6M/TTcalibration.ipynb

Lines changed: 65 additions & 72 deletions
Large diffs are not rendered by default.

src/pyFAI/average.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
__contact__ = "Jerome.Kieffer@ESRF.eu"
3030
__license__ = "MIT"
3131
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
32-
__date__ = "07/10/2025"
32+
__date__ = "04/12/2025"
3333
__status__ = "production"
3434

3535
import logging
@@ -441,11 +441,10 @@ def average_dark(lstimg, center_method="mean", cutoff=None, quantiles=(0.5, 0.5)
441441
output = center
442442
else:
443443
std = stack.std(axis=0)
444-
strides = 0, std.strides[0], std.strides[1]
445-
std.shape = 1, shape[0], shape[1]
446-
std.strides = strides
447-
center.shape = 1, shape[0], shape[1]
448-
center.strides = strides
444+
std.shape = shape
445+
std = std[numpy.newaxis, ...]
446+
center.shape = shape
447+
center = center[numpy.newaxis, ...]
449448
mask = ((abs(stack - center) / std) > cutoff)
450449
stack[numpy.where(mask)] = 0.0
451450
summed = stack.sum(axis=0)

src/pyFAI/crystallography/calibrant.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
__contact__ = "Jerome.Kieffer@ESRF.eu"
3939
__license__ = "MIT"
4040
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
41-
__date__ = "12/09/2025"
41+
__date__ = "04/12/2025"
4242
__status__ = "production"
4343

4444
import os
@@ -54,6 +54,8 @@
5454
from .resolution import _ResolutionFunction, Caglioti, Constant
5555
from ..containers import Integrate1dResult, Reflection
5656
from ..io.calibrant_config import CalibrantConfig
57+
from ..units import CONST_hc
58+
5759
logger = logging.getLogger(__name__)
5860
try:
5961
import numexpr
@@ -398,6 +400,17 @@ def wavelength(self, value: Optional[float] = None):
398400
reason="use property",
399401
since_version="2025.07")
400402

403+
@property
404+
def energy(self):
405+
if self.wavelength: # Use property instead of private variable
406+
return 1e-10 * CONST_hc / self.wavelength
407+
408+
@energy.setter
409+
def energy(self, value):
410+
"Set the energy in keV"
411+
wavelength = 1e-10 * CONST_hc / value
412+
self.wavelength = wavelength #Use property instead of private variable
413+
401414
def _calc_2th(self):
402415
"""Calculate the 2theta positions for all peaks"""
403416
self._initialize()

src/pyFAI/detectors/_imxpad.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
__contact__ = "Jerome.Kieffer@ESRF.eu"
3535
__license__ = "MIT"
3636
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
37-
__date__ = "04/11/2025"
37+
__date__ = "04/12/2025"
3838
__status__ = "production"
3939

4040
import functools
@@ -98,7 +98,7 @@ def __init__(self, pixel1=130e-6, pixel2=130e-6, max_shape=None, module_size=Non
9898
super().__init__(pixel1=pixel1, pixel2=pixel2, max_shape=max_shape,
9999
module_size=module_size, orientation=orientation, sensor=sensor)
100100
self._pixel_edges = None # array of size max_shape+1: pixels are contiguous
101-
101+
102102
def calc_pixels_edges(self):
103103
"""
104104
Calculate the position of the pixel edges
@@ -411,17 +411,10 @@ def get_pixel_corners(self, correct_binning=False):
411411
pixel_center2[i * self.module_size[1]:
412412
(i + 1) * self.module_size[1]] += i * self.MODULE_GAP[1]
413413

414-
pixel_center1.shape = -1, 1
415-
pixel_center1.strides = pixel_center1.strides[0], 0
416-
417-
pixel_center2.shape = 1, -1
418-
pixel_center2.strides = 0, pixel_center2.strides[1]
419-
420-
pixel_size1.shape = -1, 1
421-
pixel_size1.strides = pixel_size1.strides[0], 0
422-
423-
pixel_size2.shape = 1, -1
424-
pixel_size2.strides = 0, pixel_size2.strides[1]
414+
pixel_center1 = pixel_center1[:, numpy.newaxis]
415+
pixel_center2 = pixel_center2[numpy.newaxis, :]
416+
pixel_size1 = pixel_size1[:, numpy.newaxis]
417+
pixel_size2 = pixel_size2[numpy.newaxis, :]
425418

426419
corners = numpy.zeros((self.shape[0], self.shape[1], 4, 3), dtype=numpy.float32)
427420
corners[:,:, 0, 1] = pixel_center1 - pixel_size1 / 2.0
@@ -526,17 +519,10 @@ def _get_pixel_corners(self):
526519
pixel_center1[1:] += numpy.cumsum(pixel_size1[:-1])
527520
pixel_center2[1:] += numpy.cumsum(pixel_size2[:-1])
528521

529-
pixel_center1.shape = -1, 1
530-
pixel_center1.strides = pixel_center1.strides[0], 0
531-
532-
pixel_center2.shape = 1, -1
533-
pixel_center2.strides = 0, pixel_center2.strides[1]
534-
535-
pixel_size1.shape = -1, 1
536-
pixel_size1.strides = pixel_size1.strides[0], 0
537-
538-
pixel_size2.shape = 1, -1
539-
pixel_size2.strides = 0, pixel_size2.strides[1]
522+
pixel_center1 = pixel_center1[:, numpy.newaxis]
523+
pixel_center2 = pixel_center2[numpy.newaxis, :]
524+
pixel_size1 = pixel_size1[:, numpy.newaxis]
525+
pixel_size2 = pixel_size2[numpy.newaxis, :]
540526

541527
# Position of the first module
542528
corners = numpy.zeros((self.MEDIUM_MODULE_SIZE[0], self.MEDIUM_MODULE_SIZE[1], 4, 3), dtype=numpy.float32)

src/pyFAI/detectors/_non_flat.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
__contact__ = "Jerome.Kieffer@ESRF.eu"
3737
__license__ = "MIT"
3838
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
39-
__date__ = "04/11/2025"
39+
__date__ = "04/12/2025"
4040
__status__ = "production"
4141

4242

@@ -65,11 +65,11 @@ def __init__(self, pixel1=24.893e-6, pixel2=24.893e-6, radius=0.29989, orientati
6565

6666
def get_config(self):
6767
"""Return the configuration with arguments to the constructor
68-
68+
6969
:return: dict with param for serialization
7070
"""
71-
dico = super().get_config()
72-
dico["radius"] = self.radius
71+
dico = super().get_config()
72+
dico["radius"] = self.radius
7373
return dico
7474

7575
def set_config(self, config):
@@ -118,12 +118,9 @@ def get_pixel_corners(self, correct_binning=False, use_cython=True):
118118
d3 = mathutil.expand2d(p3, self.shape[0] + 1, True)
119119
corners = bilinear.convert_corner_2D_to_4D(3, d1, d2, d3)
120120
else:
121-
p1.shape = -1, 1
122-
p1.strides = p1.strides[0], 0
123-
p2.shape = 1, -1
124-
p2.strides = 0, p2.strides[1]
125-
p3.shape = 1, -1
126-
p3.strides = 0, p3.strides[1]
121+
p1 = p1.ravel()[:, numpy.newaxis]
122+
p2 = p2.ravel()[numpy.newaxis, :]
123+
p3 = p3.ravel()[numpy.newaxis, :]
127124
corners = numpy.zeros((self.shape[0], self.shape[1], 4, 3), dtype=numpy.float32)
128125
corners[:, :, 0, 0] = p3[:, :-1]
129126
corners[:, :, 0, 1] = p1[:-1, :]

0 commit comments

Comments
 (0)