From cce486ab32b5b2690a6bb7a92d621fb4636bdfe3 Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Fri, 26 Apr 2024 17:02:53 +0200 Subject: [PATCH 1/3] update regression test --- src/pyFAI/test/test_bug_regression.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pyFAI/test/test_bug_regression.py b/src/pyFAI/test/test_bug_regression.py index 6c7af339f..e6637c45b 100644 --- a/src/pyFAI/test/test_bug_regression.py +++ b/src/pyFAI/test/test_bug_regression.py @@ -36,7 +36,7 @@ __contact__ = "Jerome.Kieffer@esrf.fr" __license__ = "MIT" __copyright__ = "2015-2024 European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "02/02/2024" +__date__ = "26/04/2024" import sys import os @@ -591,6 +591,15 @@ def test_bug_2072(self): d.use_gpu # used to raise AttributeError d.use_gpu = True # used to raise AttributeError + def test_bug_2151(self): + """Some detector fail to integrate in 2D, the CSC matrix produced by cython has wrong shape. + Faulty detectors: S10 + """ + ai = load({"detector": "imxpad_s10"}) + img=numpy.ones(ai.detector.shape); + ai.integrate2d(img, 10, method=("full","csc","python"), unit="r_mm") + #used to raise AssertionError assert self.size == len(indptr) - 1 + class TestBug1703(unittest.TestCase): """ Check the normalization affect propely the propagated errors/intensity From d02f4c7ffde0b9991c303d5b616562d0d9ab96fc Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Fri, 26 Apr 2024 18:09:31 +0200 Subject: [PATCH 2/3] close #2151 --- src/pyFAI/ext/splitPixelFullCSC.pyx | 10 ++++++---- src/pyFAI/ext/splitpixel_common.pyx | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pyFAI/ext/splitPixelFullCSC.pyx b/src/pyFAI/ext/splitPixelFullCSC.pyx index a54d982d4..8a15ae795 100644 --- a/src/pyFAI/ext/splitPixelFullCSC.pyx +++ b/src/pyFAI/ext/splitPixelFullCSC.pyx @@ -7,7 +7,7 @@ # Project: Fast Azimuthal Integration # https://github.com/silx-kit/pyFAI # -# Copyright (C) 2022-2023 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2022-2024 European Synchrotron Radiation Facility, Grenoble, France # # Principal author: Jérôme Kieffer (Jerome.Kieffer@ESRF.eu) # @@ -35,7 +35,7 @@ Sparse matrix represented using the CompressedSparseColumn. __author__ = "Jérôme Kieffer" __contact__ = "Jerome.kieffer@esrf.fr" -__date__ = "04/10/2023" +__date__ = "26/04/2024" __status__ = "stable" __license__ = "MIT" @@ -98,7 +98,8 @@ class FullSplitCSC_1d(CscIntegrator, FullSplitIntegrator): self.pos0_max - 0.5 * self.delta, self.bins) - csc = sparse.csr_matrix(self.calc_lut_1d().to_csr()).tocsc() + csc = sparse.csr_array(self.calc_lut_1d().to_csr(), + shape=(bins, self.size)).tocsc() #Call the constructor of the parent class CscIntegrator.__init__(self, (csc.data, csc.indices, csc.indptr), self.pos.shape[0], bins, empty or 0.0) @@ -171,7 +172,8 @@ class FullSplitCSC_2d(CscIntegrator, FullSplitIntegrator): self.pos1_max - 0.5 * self.delta1, self.bins[1]) - csc = sparse.csr_matrix(self.calc_lut_2d().to_csr()).tocsc() + csc = sparse.csr_matrix(self.calc_lut_2d().to_csr(), + shape=(numpy.prod(self.bins), self.size)).tocsc() #Call the constructor of the parent class CscIntegrator.__init__(self, (csc.data, csc.indices, csc.indptr), self.pos.shape[0], numpy.prod(bins), empty or 0.0) diff --git a/src/pyFAI/ext/splitpixel_common.pyx b/src/pyFAI/ext/splitpixel_common.pyx index e1c4f87f6..559bbe5f0 100644 --- a/src/pyFAI/ext/splitpixel_common.pyx +++ b/src/pyFAI/ext/splitpixel_common.pyx @@ -7,7 +7,7 @@ # Project: Fast Azimuthal integration # https://github.com/silx-kit/pyFAI # -# Copyright (C) 2021-2023 European Synchrotron Radiation Facility, France +# Copyright (C) 2021-2024 European Synchrotron Radiation Facility, France # # Principal author: Jérôme Kieffer (Jerome.Kieffer@ESRF.eu) # @@ -35,7 +35,7 @@ __author__ = "Jérôme Kieffer" __contact__ = "Jerome.kieffer@esrf.fr" -__date__ = "29/09/2023" +__date__ = "26/04/2024" __status__ = "stable" __license__ = "MIT" From 9c34ae09740423f87aaec6ab17dce556950282b6 Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Sat, 27 Apr 2024 17:50:29 +0200 Subject: [PATCH 3/3] compatibility with python3.7 --- src/pyFAI/ext/splitPixelFullCSC.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyFAI/ext/splitPixelFullCSC.pyx b/src/pyFAI/ext/splitPixelFullCSC.pyx index 8a15ae795..9e80222ab 100644 --- a/src/pyFAI/ext/splitPixelFullCSC.pyx +++ b/src/pyFAI/ext/splitPixelFullCSC.pyx @@ -98,7 +98,7 @@ class FullSplitCSC_1d(CscIntegrator, FullSplitIntegrator): self.pos0_max - 0.5 * self.delta, self.bins) - csc = sparse.csr_array(self.calc_lut_1d().to_csr(), + csc = sparse.csr_matrix(self.calc_lut_1d().to_csr(), shape=(bins, self.size)).tocsc() #Call the constructor of the parent class CscIntegrator.__init__(self, (csc.data, csc.indices, csc.indptr), self.pos.shape[0], bins, empty or 0.0)