1889 cache (#1890)

* Regression test for bug #1889

* close #1889
This commit is contained in:
Jerome Kieffer 2023-05-31 16:31:18 +02:00 committed by GitHub
parent 7897e5a7aa
commit 44174097f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -40,7 +40,7 @@ __author__ = "Jerome Kieffer"
__contact__ = "Jerome.Kieffer@ESRF.eu"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "03/05/2023"
__date__ = "31/05/2023"
__status__ = "production"
__docformat__ = 'restructuredtext'
@ -1800,7 +1800,7 @@ class Geometry(object):
self.chiDiscAtPi = False
self._cached_array["chi_center"] = None
for key in list(self._cached_array.keys()):
if key.startswith("corner"):
if isinstance(key, str) and "corner" in key:
self._cached_array[key] = None
def setChiDiscAtPi(self):
@ -1814,7 +1814,7 @@ class Geometry(object):
self.chiDiscAtPi = True
self._cached_array["chi_center"] = None
for key in list(self._cached_array.keys()):
if key.startswith("corner"):
if isinstance(key, str) and "corner" in key:
self._cached_array[key] = None
@deprecated

View File

@ -36,7 +36,7 @@ __author__ = "Jérôme Kieffer"
__contact__ = "Jerome.Kieffer@esrf.fr"
__license__ = "MIT"
__copyright__ = "2015-2022 European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "26/01/2023"
__date__ = "31/05/2023"
import sys
import os
@ -559,6 +559,19 @@ class TestBugRegression(unittest.TestCase):
sg = SingleGeometry("frame", ary, "frame", lambda x:x, cp, lab6, "pilatus100k")
self.assertNotEqual(id(sg), id(copy.deepcopy(sg)), "SingleGeometry copy works and id differs")
def test_bug_1889(self):
"reset cached arrays"
ai = load({"detector": "Pilatus100k", "wavelength": 1.54e-10})
ai.polarization(factor=0.9)
img = numpy.empty(ai.detector.shape, "float32")
ai.integrate2d(img, 10,9, method=("no", "histogram", "cython"))
ai.integrate2d(img, 10,9, method=("bbox", "histogram", "cython"))
ai.setChiDiscAtZero()
ai.integrate2d(img, 10,9, method=("no", "histogram", "cython"))
ai.integrate2d(img, 10,9, method=("bbox", "histogram", "cython"))
ai.setChiDiscAtPi()
class TestBug1703(unittest.TestCase):
"""
Check the normalization affect propely the propagated errors/intensity