Skip to content

Commit

Permalink
Use unit.name as key cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar committed Jan 17, 2025
1 parent 44bd521 commit fe90e8a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/pyFAI/geometry/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ def corner_array(self, shape=None, unit=None, use_cython=True, scale=True):
space = "r"
# unit = to_unit("r_m")
key = space + "_corner"

if isinstance(unit, UnitFiber):
key = f"{unit.name}_corner"

if self._cached_array.get(key) is None or shape != self._cached_array.get(key).shape[:2]:
with self._sem:
if self._cached_array.get(key) is None or shape != self._cached_array.get(key).shape[:2]:
Expand Down Expand Up @@ -920,8 +924,11 @@ def center_array(self, shape=None, unit="2th_deg", scale=True):
"""

unit = to_unit(unit)
space = unit.name.split("_")[0]
key = space + "_center"
if isinstance(unit, UnitFiber):
key = f"{unit.name}_center"
else:
space = unit.name.split("_")[0]
key = space + "_center"
ary = self._cached_array.get(key)

shape = self.get_shape(shape)
Expand Down Expand Up @@ -966,7 +973,10 @@ def delta_array(self, shape=None, unit="2th_deg", scale=False):
"""

unit = to_unit(unit)
space = unit.name.split("_")[0] + "_delta"
if isinstance(unit, UnitFiber):
space = f"{unit.name}_delta"
else:
space = unit.name.split("_")[0] + "_delta"
ary = self._cached_array.get(space)

shape = self.get_shape(shape)
Expand Down

0 comments on commit fe90e8a

Please sign in to comment.