Skip to content
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

Fix improper reset 2d integrator #1965

Merged
merged 5 commits into from
Oct 4, 2023
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
18 changes: 9 additions & 9 deletions pyFAI/azimuthalIntegrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "03/10/2023"
__date__ = "04/10/2023"
__status__ = "stable"
__docformat__ = 'restructuredtext'

Expand Down Expand Up @@ -719,7 +719,7 @@ def integrate1d_legacy(self, data, npt, filename=None,
integr = engine.engine
reset = None
if integr is None:
reset = "init"
reset = "of first initialization"
if (not reset) and safe:
if integr.unit != unit:
reset = "unit changed"
Expand Down Expand Up @@ -843,7 +843,7 @@ def integrate1d_legacy(self, data, npt, filename=None,
reset = None

if integr is None:
reset = "init"
reset = "of first initialization"
if (not reset) and safe:
if integr.unit != unit:
reset = "unit changed"
Expand Down Expand Up @@ -1822,7 +1822,7 @@ def integrate2d_legacy(self, data, npt_rad, npt_azim=360,
integr = engine.engine
reset = None
if integr is None:
reset = "init"
reset = "of first initialization"
if (not reset) and safe:
if integr.unit != unit:
reset = "unit changed"
Expand Down Expand Up @@ -1907,7 +1907,7 @@ def integrate2d_legacy(self, data, npt_rad, npt_azim=360,
integr = engine.engine
reset = None
if integr is None:
reset = "init"
reset = "of first initialization"
if (not reset) and safe:
if integr.unit != unit:
reset = "unit changed"
Expand Down Expand Up @@ -2273,7 +2273,7 @@ def integrate2d_ng(self, data, npt_rad, npt_azim=360,
if (radial_range is None) and (cython_integr.pos0_range is not None):
cython_reset = f"radial_range was defined in { method.algo_lower.upper()}"
elif (radial_range is not None) and (cython_integr.pos0_range != radial_range):
cython_reset = f"radial_range is defined but differs in %s" % method.algo_lower.upper()
cython_reset = f"radial_range is defined but differs in {method.algo_lower.upper()}"
if (azimuth_range is None) and (cython_integr.pos1_range is not None):
cython_reset = f"azimuth_range not defined and {method.algo_lower.upper()} had azimuth_range defined"
elif (azimuth_range is not None) and (cython_integr.pos1_range != azimuth_range):
Expand Down Expand Up @@ -2309,11 +2309,11 @@ def integrate2d_ng(self, data, npt_rad, npt_azim=360,
integr = engine.engine
reset = None
if integr is None:
reset = "init"
reset = "of first initialization"
if (not reset) and safe:
if integr.space != space:
reset = f"unit {integr.unit} incompatible with requested {unit}"
if integr.bins != npt:
if numpy.prod(integr.bins) != numpy.prod(npt):
reset = f"number of points {integr.bins} incompatible with requested {npt}"
if integr.size != data.size:
reset = f"input image size {integr.size} incompatible with requested {data.size}"
Expand Down Expand Up @@ -2477,7 +2477,7 @@ def integrate2d_ng(self, data, npt_rad, npt_azim=360,
integr = engine.engine
reset = None
if integr is None:
reset = "init"
reset = "of first initialization"
if (not reset) and safe:
if integr.space != space:
reset = f"unit {integr.unit} incompatible with requested {unit}"
Expand Down
6 changes: 3 additions & 3 deletions pyFAI/engines/CSC_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "26/09/2023"
__date__ = "04/10/2023"
__status__ = "development"

import logging
Expand Down Expand Up @@ -191,7 +191,7 @@ def __init__(self,
CSCIntegrator.__init__(self, image_size, len(bin_centers), lut, empty)
self.pos0_range = self.pos1_range = None
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.mask_checksum = mask_checksum

def set_matrix(self, data, indices, indptr):
Expand Down Expand Up @@ -428,7 +428,7 @@ def __init__(self,
self.bin_centers1 = bin_centers1
bins = (len(bin_centers0), len(bin_centers1))
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.mask_checksum = mask_checksum

if not checksum:
Expand Down
6 changes: 3 additions & 3 deletions pyFAI/engines/CSR_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "26/09/2023"
__date__ = "04/10/2023"
__status__ = "development"

import logging
Expand Down Expand Up @@ -182,7 +182,7 @@ def __init__(self,
CSRIntegrator.__init__(self, image_size, lut, empty)
self.pos0_range = self.pos1_range = None
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.mask_checksum = mask_checksum

def set_matrix(self, data, indices, indptr):
Expand Down Expand Up @@ -417,7 +417,7 @@ def __init__(self,
self.bin_centers0 = bin_centers0
self.bin_centers1 = bin_centers1
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.mask_checksum = mask_checksum

if not checksum:
Expand Down
6 changes: 3 additions & 3 deletions pyFAI/ext/splitBBoxCSC.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Serial implementation based on a sparse CSC matrix multiplication

__author__ = "Jérôme Kieffer"
__contact__ = "[email protected]"
__date__ = "26/09/2023"
__date__ = "04/10/2023"
__status__ = "stable"
__license__ = "MIT"

Expand Down Expand Up @@ -96,7 +96,7 @@ class HistoBBox1d(CscIntegrator, SplitBBoxIntegrator):
:param clip_pos1: clip the azimuthal range to [-π π] (or [0 2π] depending on chiDiscAtPi), set to False to deactivate behavior
"""
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (tuple, list)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (tuple, list)) else str(unit).split("_")[0]
SplitBBoxIntegrator.__init__(self, pos0, delta_pos0, pos1, delta_pos1,
bins, pos0_range, pos1_range,
mask, mask_checksum,
Expand Down Expand Up @@ -175,7 +175,7 @@ class HistoBBox2d(CscIntegrator, SplitBBoxIntegrator):
bins, pos0_range, pos1_range, mask, mask_checksum, allow_pos0_neg, chiDiscAtPi,
clip_pos1)
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (tuple, list)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (tuple, list)) else str(unit).split("_")[0]
self.bin_centers = None
self.delta0 = (self.pos0_max - self.pos0_min) / (<position_t> (self.bins[0]))
self.delta1 = (self.pos1_max - self.pos1_min) / (<position_t> (self.bins[1]))
Expand Down
6 changes: 3 additions & 3 deletions pyFAI/ext/splitBBoxCSR.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ reverse implementation based on a sparse matrix multiplication

__author__ = "Jérôme Kieffer"
__contact__ = "[email protected]"
__date__ = "28/09/2023"
__date__ = "04/10/2023"
__status__ = "stable"
__license__ = "MIT"

Expand Down Expand Up @@ -96,7 +96,7 @@ class HistoBBox1d(CsrIntegrator, SplitBBoxIntegrator):
:param clip_pos1: clip the azimuthal range to [-π π] (or [0 2π] depending on chiDiscAtPi), set to False to deactivate behavior
"""
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
SplitBBoxIntegrator.__init__(self, pos0, delta_pos0, pos1, delta_pos1,
bins, pos0_range, pos1_range,
mask, mask_checksum,
Expand Down Expand Up @@ -173,7 +173,7 @@ class HistoBBox2d(CsrIntegrator, SplitBBoxIntegrator):
bins, pos0_range, pos1_range, mask, mask_checksum, allow_pos0_neg, chiDiscAtPi,
clip_pos1)
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, tuple) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, tuple) else str(unit).split("_")[0]
self.bin_centers = None
self.delta0 = (self.pos0_max - self.pos0_min) / (<position_t> (self.bins[0]))
self.delta1 = (self.pos1_max - self.pos1_min) / (<position_t> (self.bins[1]))
Expand Down
6 changes: 3 additions & 3 deletions pyFAI/ext/splitBBoxLUT.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ reverse implementation based on a sparse matrix multiplication

__author__ = "Jérôme Kieffer"
__contact__ = "[email protected]"
__date__ = "26/09/2023"
__date__ = "04/10/2023"
__status__ = "stable"
__license__ = "MIT"

Expand Down Expand Up @@ -97,7 +97,7 @@ class HistoBBox1d(LutIntegrator, SplitBBoxIntegrator):
:param clip_pos1: clip the azimuthal range to [-π π] (or [0 2π] depending on chiDiscAtPi), set to False to deactivate behavior
"""
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (tuple, list)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (tuple, list)) else str(unit).split("_")[0]
SplitBBoxIntegrator.__init__(self, pos0, delta_pos0, pos1, delta_pos1,
bins, pos0_range, pos1_range,
mask, mask_checksum,
Expand Down Expand Up @@ -173,7 +173,7 @@ class HistoBBox2d(LutIntegrator, SplitBBoxIntegrator):
bins, pos0_range, pos1_range, mask, mask_checksum, allow_pos0_neg, chiDiscAtPi,
clip_pos1)
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.bin_centers = None
self.delta0 = (self.pos0_max - self.pos0_min) / (<position_t> (self.bins[0]))
self.delta1 = (self.pos1_max - self.pos1_min) / (<position_t> (self.bins[1]))
Expand Down
6 changes: 3 additions & 3 deletions pyFAI/ext/splitPixelFullCSC.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Sparse matrix represented using the CompressedSparseColumn.

__author__ = "Jérôme Kieffer"
__contact__ = "[email protected]"
__date__ = "29/09/2023"
__date__ = "04/10/2023"
__status__ = "stable"
__license__ = "MIT"

Expand Down Expand Up @@ -90,7 +90,7 @@ class FullSplitCSC_1d(CscIntegrator, FullSplitIntegrator):
:param chiDiscAtPi: tell if azimuthal discontinuity is at 0° or 180°
"""
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (tuple, list)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (tuple, list)) else str(unit).split("_")[0]
FullSplitIntegrator.__init__(self, pos, bins, pos0_range, pos1_range, mask, mask_checksum, allow_pos0_neg, chiDiscAtPi)

self.delta = (self.pos0_max - self.pos0_min) / (<position_t> (self.bins))
Expand Down Expand Up @@ -160,7 +160,7 @@ class FullSplitCSC_2d(CscIntegrator, FullSplitIntegrator):
"""
FullSplitIntegrator.__init__(self, pos, bins, pos0_range, pos1_range, mask, mask_checksum, allow_pos0_neg, chiDiscAtPi, clip_pos1)
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.bin_centers = None
self.delta0 = (self.pos0_max - self.pos0_min) / (<position_t> (self.bins[0]))
self.delta1 = (self.pos1_max - self.pos1_min) / (<position_t> (self.bins[1]))
Expand Down
6 changes: 3 additions & 3 deletions pyFAI/ext/splitPixelFullCSR.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Sparse matrix represented using the CompressedSparseRow.

__author__ = "Jérôme Kieffer"
__contact__ = "[email protected]"
__date__ = "29/09/2023"
__date__ = "04/10/2023"
__status__ = "stable"
__license__ = "MIT"

Expand Down Expand Up @@ -90,7 +90,7 @@ class FullSplitCSR_1d(CsrIntegrator, FullSplitIntegrator):
:param chiDiscAtPi: tell if azimuthal discontinuity is at 0° or 180°
"""
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
FullSplitIntegrator.__init__(self, pos, bins, pos0_range, pos1_range, mask, mask_checksum, allow_pos0_neg, chiDiscAtPi)

self.delta = (self.pos0_max - self.pos0_min) / (<position_t> (self.bins))
Expand Down Expand Up @@ -157,7 +157,7 @@ class FullSplitCSR_2d(CsrIntegrator, FullSplitIntegrator):
"""
FullSplitIntegrator.__init__(self, pos, bins, pos0_range, pos1_range, mask, mask_checksum, allow_pos0_neg, chiDiscAtPi, clip_pos1)
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.bin_centers = None
self.delta0 = (self.pos0_max - self.pos0_min) / (<position_t> (self.bins[0]))
self.delta1 = (self.pos1_max - self.pos1_min) / (<position_t> (self.bins[1]))
Expand Down
6 changes: 3 additions & 3 deletions pyFAI/ext/splitPixelFullLUT.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Sparse matrix represented using the LUT representation.

__author__ = "Jérôme Kieffer"
__contact__ = "[email protected]"
__date__ = "29/09/2023"
__date__ = "04/10/2023"
__status__ = "stable"
__license__ = "MIT"

Expand Down Expand Up @@ -81,7 +81,7 @@ class HistoLUT1dFullSplit(LutIntegrator, FullSplitIntegrator):
:param chiDiscAtPi: tell if azimuthal discontinuity is at 0° or 180°
"""
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
FullSplitIntegrator.__init__(self, pos, bins, pos0_range, pos1_range, mask, mask_checksum, allow_pos0_neg, chiDiscAtPi)

self.delta = (self.pos0_max - self.pos0_min) / (<position_t> (self.bins))
Expand Down Expand Up @@ -146,7 +146,7 @@ class HistoLUT2dFullSplit(LutIntegrator, FullSplitIntegrator):
"""
FullSplitIntegrator.__init__(self, pos, bins, pos0_range, pos1_range, mask, mask_checksum, allow_pos0_neg, chiDiscAtPi, clip_pos1)
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.bin_centers = None
self.delta0 = (self.pos0_max - self.pos0_min) / (<position_t> (self.bins[0]))
self.delta1 = (self.pos1_max - self.pos1_min) / (<position_t> (self.bins[1]))
Expand Down
2 changes: 1 addition & 1 deletion pyFAI/opencl/azim_csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __init__(self, lut, image_size, checksum=None,
self.size = image_size
self.empty = empty or 0
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.bin_centers = bin_centers
self.azim_centers = azim_centers
# a few place-folders
Expand Down
4 changes: 2 additions & 2 deletions pyFAI/opencl/azim_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"""
__author__ = "Jérôme Kieffer"
__license__ = "MIT"
__date__ = "29/09/2023"
__date__ = "04/10/2023"
__copyright__ = "2012-2021, ESRF, Grenoble"
__contact__ = "[email protected]"

Expand Down Expand Up @@ -124,7 +124,7 @@ def __init__(self, radial, bins, radial_checksum=None, empty=None, unit=None,
" but it can be present and not declared as Nvidia does",
self.ctx.devices[0].name)
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.bins = numpy.uint32(bins)
self.size = numpy.uint32(radial.size)
self.empty = numpy.float32(empty) if empty is not None else numpy.float32(0.0)
Expand Down
2 changes: 1 addition & 1 deletion pyFAI/opencl/azim_lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, lut, image_size, checksum=None,
self.size = image_size
self.empty = empty or 0 # numpy.NaN
self.unit = unit
self.space = (str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.space = tuple(str(u).split("_")[0] for u in unit) if isinstance(unit, (list, tuple)) else str(unit).split("_")[0]
self.bin_centers = bin_centers
self.azim_centers = azim_centers
# a few place-folders
Expand Down