Skip to content

Commit

Permalink
Merge pull request #2076 from kif/2072_diffmap
Browse files Browse the repository at this point in the history
Fix diff_tomo tool
  • Loading branch information
kif authored Feb 2, 2024
2 parents ff2169a + 158c52a commit c0773fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
21 changes: 12 additions & 9 deletions src/pyFAI/diffmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#
Expand Down Expand Up @@ -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'

Expand All @@ -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')
Expand Down Expand Up @@ -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" % \
Expand Down Expand Up @@ -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)

Expand Down
7 changes: 6 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-2024 European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "30/01/2024"
__date__ = "02/02/2024"

import sys
import os
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit c0773fa

Please sign in to comment.