From 158c52a4673230f27a1f2608087ccfb7d1df8644 Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Fri, 2 Feb 2024 09:23:00 +0100 Subject: [PATCH] close #2072 --- src/pyFAI/diffmap.py | 21 ++++++++++++--------- src/pyFAI/test/test_bug_regression.py | 7 ++++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/pyFAI/diffmap.py b/src/pyFAI/diffmap.py index ee8fd36a6..6bb0dcb2a 100644 --- a/src/pyFAI/diffmap.py +++ b/src/pyFAI/diffmap.py @@ -3,7 +3,7 @@ # Project: Azimuthal integration # https://github.com/silx-kit/pyFAI # -# Copyright (C) 2015-2023 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2015-2024 European Synchrotron Radiation Facility, Grenoble, France # # Principal author: Jérôme Kieffer (Jerome.Kieffer@ESRF.eu) # @@ -31,7 +31,7 @@ __contact__ = "Jerome.Kieffer@ESRF.eu" __license__ = "MIT" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "28/08/2023" +__date__ = "02/02/2024" __status__ = "development" __docformat__ = 'restructuredtext' @@ -48,9 +48,10 @@ import json import __main__ as main from .opencl import ocl -from . import version as PyFAI_VERSION, date as PyFAI_DATE, load +from . import version as PyFAI_VERSION, date as PyFAI_DATE, load, load_integrators from .io import Nexus, get_isotime, h5py from .worker import Worker, _reduce_images +from .method_registry import Method, IntegrationMethod DIGITS = [str(i) for i in range(10)] Position = collections.namedtuple('Position', 'index, rot, trans') @@ -96,6 +97,7 @@ def __init__(self, npt_fast=0, npt_slow=1, npt_rad=1000, npt_azim=None): self.nxs = None self.entry_grp = None self.experiment_title = "Diffraction Mapping" + # method is a property from worker def __repr__(self): return "%s experiment with ntp_slow: %s ntp_fast: %s, npt_diff: %s" % \ @@ -604,14 +606,15 @@ def process(self): self.nxs.close() def get_use_gpu(self): - return self.method.impl_lower == "opencl" + return self.worker._method.impl_lower == "opencl" def set_use_gpu(self, value): - if value: - method = self.method.method.fixed("opencl") - else: - method = self.method.method.fixed("cython") - self.method = method + if self.worker: + if value: + method = self.worker._method.method.fixed("opencl") + else: + method = self.worker._method.method.fixed("cython") + self.worker.set_method(method) use_gpu = property(get_use_gpu, set_use_gpu) diff --git a/src/pyFAI/test/test_bug_regression.py b/src/pyFAI/test/test_bug_regression.py index 76da958ec..6c7af339f 100644 --- a/src/pyFAI/test/test_bug_regression.py +++ b/src/pyFAI/test/test_bug_regression.py @@ -36,7 +36,7 @@ __contact__ = "Jerome.Kieffer@esrf.fr" __license__ = "MIT" __copyright__ = "2015-2024 European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "30/01/2024" +__date__ = "02/02/2024" import sys import os @@ -585,6 +585,11 @@ def test_bug_1946(self): res = IntegrationMethod.select_method(dim=1, split="full", algo="csc", impl="python", degradable=False) self.assertGreater(len(res), 0, "method actually exists") + def test_bug_2072(self): + from ..diffmap import DiffMap + d = DiffMap() + d.use_gpu # used to raise AttributeError + d.use_gpu = True # used to raise AttributeError class TestBug1703(unittest.TestCase): """