Skip to content

Commit

Permalink
Merge pull request silx-kit#2381 from EdgarGF93/unitfiber_keycache
Browse files Browse the repository at this point in the history
Use unit.name as key cache
  • Loading branch information
kif authored Jan 21, 2025
2 parents 44bd521 + 6a6de8a commit 48cb3ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/pyFAI/geometry/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,7 @@ def center_array(self, shape=None, unit="2th_deg", scale=True):
"""

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

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

unit = to_unit(unit)
space = unit.name.split("_")[0] + "_delta"
space = f"{unit.space}_delta"
ary = self._cached_array.get(space)

shape = self.get_shape(shape)
Expand Down
2 changes: 1 addition & 1 deletion src/pyFAI/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self, name, scale=1, label=None, equation=None, formula=None,
:param period: None or the periodicity of the unit (angles are periodic)
"""
self.name = name
self.space = name.split("_")[0] # used to idenfify compatible spaces.
self.space = "_".join(self.name.split("_")[:-1]) # used to idenfify compatible spaces.
self.scale = scale
self.label = label if label is not None else name
self.corner = corner
Expand Down

0 comments on commit 48cb3ca

Please sign in to comment.