Skip to content

full-split CSC matrix has wrong size when last line of detector is masked out #2153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/pyFAI/ext/splitPixelFullCSC.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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_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)

Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions src/pyFAI/ext/splitpixel_common.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#
Expand Down Expand Up @@ -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"

Expand Down
11 changes: 10 additions & 1 deletion src/pyFAI/test/test_bug_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading