Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions src/pyFAI/detectors/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
__contact__ = "Jerome.Kieffer@ESRF.eu"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "05/01/2026"
__date__ = "27/01/2026"
__status__ = "stable"

import logging
Expand Down Expand Up @@ -264,7 +264,7 @@ def __init__(self,

if isinstance(sensor, SensorConfig):
if sensor not in self.SENSORS:
logger.warning("Sensor %s not in allowed SENSORS: %s", sensor, self.SENSORS)
logger.warning("Sensor %s not in allowed SENSORS: [%s].", sensor, "|".join([str(i) for i in self.SENSORS]))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kif Could you also choose here directly a generator comprehension?

self.sensor = sensor
elif sensor is None:
logger.info("No sensor configuration provided; using default behaviour.")
Expand Down
11 changes: 10 additions & 1 deletion src/pyFAI/detectors/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
__contact__ = "Jerome.Kieffer@ESRF.eu"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "05/01/2026"
__date__ = "27/01/2026"
__status__ = "stable"

import os
Expand Down Expand Up @@ -179,6 +179,15 @@ def copy(self):
return self.__class__(self.material, # expected to be immutable
self.thickness)

def __eq__(self, other):
"""Check for equality, especially for the thickness within 1µm"""
if (self.material == other.material):
if self.thickness and other.thickness and abs(self.thickness - other.thickness)<1e-6:
return True
else:
return self.thickness == other.thickness
return False

def as_dict(self):
"""Like asdict, but with some more features:
"""
Expand Down
38 changes: 37 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-2025 European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "05/01/2026"
__date__ = "27/01/2026"

import sys
import os
Expand Down Expand Up @@ -733,6 +733,42 @@ def test_bug_2750(self):
self.assertEqual(ai.detector, cpy.detector)
self.assertEqual(ai.detector.sensor, cpy.detector.sensor)

def test_bug_2765(self):
"""Check that loading a config file with approximate sensor thickness does not emit a warning"""
config_almost_good = {'poni_version': 2.1,
'dist': 1.0,
'poni1': 2.0,
'poni2': 3.0,
'rot1': 0.0,
'rot2': 0.0,
'rot3': 0.0,
'detector': 'Pilatus1M',
'detector_config': {'pixel1': 0.000172,
'pixel2': 0.000172,
'orientation': 3,
'sensor': {'material': 'Si', 'thickness': 0.00031999999999999997}}}
config_not_good = {'poni_version': 2.1,
'dist': 1.0,
'poni1': 2.0,
'poni2': 3.0,
'rot1': 0.0,
'rot2': 0.0,
'rot3': 0.0,
'detector': 'Pilatus1M',
'detector_config': {'pixel1': 0.000172,
'pixel2': 0.000172,
'orientation': 3,
'sensor': {'material': 'Si', 'thickness': 0.0003}}}
with self.assertLogs("pyFAI.detectors._common", level="WARNING") as cm:
_ = load(config_almost_good)
print(cm.output)
self.assertEqual(len(cm.output), 0, "No warning when almost good")

_ = load(config_not_good)
print(cm.output)
self.assertEqual(len(cm.output), 1, "Warning when not good")



class TestBug1703(unittest.TestCase):
"""
Expand Down
Loading