Skip to content

Commit a6b48ca

Browse files
committed
provide non regression test
1 parent d3016f1 commit a6b48ca

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

src/pyFAI/test/test_bug_regression.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
__contact__ = "Jerome.Kieffer@esrf.fr"
3737
__license__ = "MIT"
3838
__copyright__ = "2015-2025 European Synchrotron Radiation Facility, Grenoble, France"
39-
__date__ = "20/11/2025"
39+
__date__ = "17/12/2025"
4040

4141
import sys
4242
import os
@@ -45,15 +45,16 @@
4545
import subprocess
4646
import copy
4747
import logging
48+
from math import pi
4849
from .utilstest import UtilsTest
4950
from ..utils import mathutil
5051
import fabio
5152
from .. import load
5253
from ..integrator.azimuthal import AzimuthalIntegrator
5354
from .. import detectors
5455
from .. import units
55-
from math import pi
5656
from ..opencl import ocl
57+
from ..ext import splitPixel
5758
logger = logging.getLogger(__name__)
5859

5960
try:
@@ -691,6 +692,42 @@ def test_bug_2697(self):
691692
res = numpy.isnan(ai.integrate1d(fimg.data, 300, method=("no","csr", "cython"), error_model="azimuth").sum_variance).sum()
692693
self.assertEqual(res, 0, "No NaNs found in Cython")
693694

695+
def test_bug_2736(self):
696+
"""Checks the pixel splitting with boundaries, see tutorial entitled PixelSplitting"""
697+
ai = load({"dist":1,
698+
"poni1":2.2e-3,
699+
"poni2":2.8e-3,
700+
"rot3":-0.3,
701+
"detector":"Detector",
702+
"detector_config":{"pixel1":1e-3,
703+
"pixel2":1e-3,
704+
"max_shape":(5,5)}
705+
})
706+
ai.setChiDiscAtPi()
707+
pos = numpy.array(ai.array_from_unit(typ="corner", unit="r_mm", scale=True), dtype="float64")
708+
self.assertEqual((pos[..., 1]< -pi).sum(), 0, "No pixels below pi azim angle")
709+
self.assertEqual((pos[..., 1]> +pi).sum(), 0, "No pixels above pi azim angle")
710+
for i0 in range(pos.shape[0]):
711+
for i1 in range(pos.shape[1]):
712+
p = pos[i0, i1]
713+
splitPixel.recenter(p, chiDiscAtPi=True)
714+
self.assertEqual((pos[..., 1]< -pi).sum(), 5, "5 pixels below pi azim angle")
715+
self.assertEqual((pos[..., 1]> +pi).sum(), 1, "1 pixels above pi azim angle")
716+
717+
# Change origin to zero
718+
ai.setChiDiscAtZero()
719+
pos = numpy.array(ai.array_from_unit(typ="corner", unit="r_mm", scale=True), dtype="float64")
720+
self.assertEqual((pos[..., 1]< 0).sum(), 0, "No pixels below 0 azim angle")
721+
self.assertEqual((pos[..., 1]> 2*pi).sum(), 0, "No pixels above 2pi azim angle")
722+
for i0 in range(pos.shape[0]):
723+
for i1 in range(pos.shape[1]):
724+
p = pos[i0, i1]
725+
splitPixel.recenter(p, chiDiscAtPi=False)
726+
self.assertEqual((pos[..., 1]< 0).sum(), 1, "1 pixels below pi azim angle")
727+
self.assertEqual((pos[..., 1]> 2*pi).sum(), 3, "3 pixels above pi azim angle")
728+
729+
730+
694731
class TestBug1703(unittest.TestCase):
695732
"""
696733
Check the normalization affect properly the propagated errors/intensity

0 commit comments

Comments
 (0)