Skip to content

Commit 48563a9

Browse files
committed
Remove final _to_ function
1 parent 509e846 commit 48563a9

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

boost_histogram/_internal/axis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from .kwargs import KWArgs
1010
from .sig_tools import inject_signature
11-
from .axis_transform import AxisTransform, _to_transform
11+
from .axis_transform import AxisTransform
1212
from .utils import cast, register
1313

1414

@@ -183,7 +183,7 @@ def _repr_kwargs(self):
183183
@property
184184
def transform(self):
185185
if hasattr(self._ax, "transform"):
186-
return _to_transform(self._ax.transform)
186+
return cast(self._ax.transform, AxisTransform)
187187
return None
188188

189189
@inject_signature(

boost_histogram/_internal/axis_transform.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from .._core import axis as ca
66

7+
from .utils import register
8+
79

810
class AxisTransform(object):
911
__slots__ = ()
@@ -15,27 +17,23 @@ def _produce(self, bins, start, stop, metadata):
1517
return self.__class__._type(bins, start, stop, metadata)
1618

1719

20+
@register(ca.transform.log)
1821
class Log(ca.transform.log, AxisTransform):
1922
__slots__ = ()
2023
_type = ca.regular_log
2124

2225

26+
@register(ca.transform.sqrt)
2327
class Sqrt(ca.transform.sqrt, AxisTransform):
2428
__slots__ = ()
2529
_type = ca.regular_sqrt
2630

2731

32+
@register(ca.transform.pow)
2833
class Pow(ca.transform.pow, AxisTransform):
2934
__slots__ = ()
3035
_type = ca.regular_pow
3136

3237
# This one does need to be a normal method
3338
def _produce(self, bins, start, stop, metadata):
3439
return self.__class__._type(bins, start, stop, self.power, metadata)
35-
36-
37-
def _to_transform(trans):
38-
for trans_class in AxisTransform.__subclasses__():
39-
if isinstance(trans, trans_class.__bases__):
40-
return trans_class(trans)
41-
raise TypeError("Cannot find transform")

0 commit comments

Comments
 (0)