Skip to content

Commit

Permalink
Merge pull request #2231 from kif/2227_worker_generic_detector
Browse files Browse the repository at this point in the history
Generic detector in worker
  • Loading branch information
kif authored Jul 5, 2024
2 parents 972138d + cc5a972 commit 2edfde1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/pyFAI/io/integration_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
__author__ = "Jerome Kieffer"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "15/04/2024"
__date__ = "04/07/2024"
__docformat__ = 'restructuredtext'

import logging
Expand Down Expand Up @@ -76,9 +76,12 @@ def _patch_v1_to_v2(config):
:param dict config: Dictionary reworked inplace.
"""

value = config.pop("poni", None)
detector = None
value = config.pop("poni", None)
if value is None and "poni_version" in config:
# Anachronistic configuration, bug found in #2227
value = config.copy()
config.clear() # Do not change the object: empty in place
if value:
# Use the poni file while it is not overwrited by a key of the config
# dictionary
Expand Down
25 changes: 24 additions & 1 deletion src/pyFAI/test/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "30/04/2024"
__date__ = "04/07/2024"

import unittest
import logging
Expand Down Expand Up @@ -439,6 +439,29 @@ def test_old(self):
ai = worker.ai
self.assertTrue(numpy.allclose(config["shape"], ai.detector.max_shape))

def test_regression_2227(self):
"""pixel size got lost with generic detector"""
worker_generic = Worker()
integration_options_generic = {'poni_version': 2.1,
'detector': 'Detector',
'detector_config': {'pixel1': 1e-4,
'pixel2': 1e-4,
'max_shape': [576, 748],
'orientation': 3},
'dist': 0.16156348926909264,
'poni1': 1.4999999999999998,
'poni2': 1.4999999999999998,
'rot1': 1.0822864853552985,
'rot2': -0.41026007690779387,
'rot3': 0.0,
'wavelength': 1.0332016536100021e-10}
worker_generic.set_config(integration_options_generic)
self.assertEqual(worker_generic.ai.detector.pixel1, 1e-4, "Pixel1 size matches")
self.assertEqual(worker_generic.ai.detector.pixel2, 1e-4, "Pixel2 size matches")
self.assertEqual(worker_generic.ai.detector.shape, [576, 748], "Shape matches")
self.assertEqual(worker_generic.ai.detector.orientation, 3, "Orientation matches")


def suite():
loader = unittest.defaultTestLoader.loadTestsFromTestCase
testsuite = unittest.TestSuite()
Expand Down
4 changes: 2 additions & 2 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
__authors__ = ["Jérôme Kieffer", "V. Valls"]
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "03/06/2024"
__date__ = "04/07/2024"
__status__ = "production"
__docformat__ = 'restructuredtext'
__all__ = ["date", "version_info", "strictversion", "hexversion", "debianversion",
Expand All @@ -61,7 +61,7 @@
"final": 15}

MAJOR = 2024
MINOR = 6
MINOR = 7
MICRO = 0
RELEV = "dev" # <16
SERIAL = 0 # <16
Expand Down

0 comments on commit 2edfde1

Please sign in to comment.