11import copy
2- from typing import Any , Dict , Optional , Tuple , Union
2+ from typing import Any , Dict , Optional , Set , Tuple , Union
3+
4+ import boost_histogram
35
46from .._core import axis as ca
57from .axis_transform import AxisTransform
68from .traits import Traits
7- from .utils import MAIN_FAMILY , cast , register , set_family , set_module
9+ from .utils import cast , register , set_module
810
911
1012def _isstr (value : Any ) -> bool :
@@ -20,14 +22,19 @@ def _isstr(value: Any) -> bool:
2022 return False
2123
2224
23- def opts (** kwargs : bool ):
25+ def opts (** kwargs : bool ) -> Set [ str ] :
2426 return {k for k , v in kwargs .items () if v }
2527
2628
2729# Contains common methods and properties to all axes
2830@set_module ("boost_histogram.axis" )
2931class Axis :
3032 __slots__ = ("_ax" , "__dict__" )
33+ _family : object
34+
35+ def __init_subclass__ (cls , * , family : object ) -> None :
36+ super ().__init_subclass__ ()
37+ cls ._family = family
3138
3239 def __setattr__ (self , attr : str , value : Any ) -> None :
3340 if attr == "__dict__" :
@@ -244,8 +251,7 @@ def widths(self):
244251 }
245252)
246253@set_module ("boost_histogram.axis" )
247- @set_family (MAIN_FAMILY )
248- class Regular (Axis ):
254+ class Regular (Axis , family = boost_histogram ):
249255 __slots__ = ()
250256
251257 def __init__ (
@@ -361,9 +367,8 @@ def transform(self) -> Optional[AxisTransform]:
361367 ca .variable_circular ,
362368 }
363369)
364- @set_family (MAIN_FAMILY )
365370@set_module ("boost_histogram.axis" )
366- class Variable (Axis ):
371+ class Variable (Axis , family = boost_histogram ):
367372 __slots__ = ()
368373
369374 def __init__ (
@@ -444,9 +449,8 @@ def _repr_args(self) -> str:
444449 ca .integer_circular ,
445450 }
446451)
447- @set_family (MAIN_FAMILY )
448452@set_module ("boost_histogram.axis" )
449- class Integer (Axis ):
453+ class Integer (Axis , family = boost_histogram ):
450454 __slots__ = ()
451455
452456 def __init__ (
@@ -514,7 +518,7 @@ def _repr_args(self):
514518 return "{start:g}, {stop:g}" .format (start = self .edges [0 ], stop = self .edges [- 1 ])
515519
516520
517- class BaseCategory (Axis ):
521+ class BaseCategory (Axis , family = boost_histogram ):
518522 __slots__ = ()
519523
520524 def _repr_kwargs (self ):
@@ -536,10 +540,9 @@ def _repr_kwargs(self):
536540 return ret
537541
538542
539- @set_family (MAIN_FAMILY )
540543@set_module ("boost_histogram.axis" )
541544@register ({ca .category_str_growth , ca .category_str })
542- class StrCategory (BaseCategory ):
545+ class StrCategory (BaseCategory , family = boost_histogram ):
543546 __slots__ = ()
544547
545548 def __init__ (
@@ -603,10 +606,9 @@ def _repr_args(self):
603606 return "[{}]" .format (", " .join (repr (c ) for c in self ))
604607
605608
606- @set_family (MAIN_FAMILY )
607609@set_module ("boost_histogram.axis" )
608610@register ({ca .category_int , ca .category_int_growth })
609- class IntCategory (BaseCategory ):
611+ class IntCategory (BaseCategory , family = boost_histogram ):
610612 __slots__ = ()
611613
612614 def __init__ (
@@ -655,9 +657,8 @@ def _repr_args(self) -> str:
655657
656658# Contains all common methods and properties for the boolean axis
657659@register ({ca .boolean })
658- @set_family (MAIN_FAMILY )
659660@set_module ("boost_histogram.axis" )
660- class Boolean (Axis ):
661+ class Boolean (Axis , family = boost_histogram ):
661662 __slots__ = ()
662663
663664 def __init__ (self , * , metadata : Any = None , __dict__ : Dict [str , Any ] = None ):
0 commit comments