@@ -137,6 +137,14 @@ def __init__(self, *axes, **kwargs):
137137
138138 raise TypeError ("Unsupported storage" )
139139
140+ def _generate_axes_ (self ):
141+ """
142+ This is called to fill in the axes. Subclasses can override it if they need
143+ to change the axes tuple.
144+ """
145+
146+ return AxesTuple (self ._axis (i ) for i in range (self .ndim ))
147+
140148 def view (self , flow = False ):
141149 """
142150 Return a view into the data, optionally with overflow turned on.
@@ -151,7 +159,7 @@ def __add__(self, other):
151159
152160 def __iadd__ (self , other ):
153161 self ._hist .__iadd__ (other ._hist )
154- self .axes = AxesTuple ( self ._axis ( i ) for i in range ( self . ndim ) )
162+ self .axes = self ._generate_axes_ ( )
155163 return self
156164
157165 def __eq__ (self , other ):
@@ -390,19 +398,19 @@ def __init__(self, *args, **kwargs):
390398 super (Histogram , self ).__init__ (* args , ** kwargs )
391399
392400 # If this is a property, tab completion in IPython does not work
393- self .axes = AxesTuple ( self ._axis ( i ) for i in range ( self . ndim ) )
401+ self .axes = self ._generate_axes_ ( )
394402
395403 __init__ .__doc__ = BaseHistogram .__init__ .__doc__
396404
397405 def __copy__ (self ):
398406 other = super (Histogram , self ).__copy__ ()
399- other .axes = AxesTuple ( other ._axis ( i ) for i in range ( other . ndim ) )
407+ other .axes = other ._generate_axes_ ( )
400408 return other
401409
402410 def __deepcopy__ (self , memo ):
403411 other = self .__class__ .__new__ (self .__class__ )
404412 other ._hist = copy .deepcopy (self ._hist , memo )
405- other .axes = AxesTuple ( other ._axis ( i ) for i in range ( other . ndim ) )
413+ other .axes = other ._generate_axes_ ( )
406414 return other
407415
408416 def __getstate__ (self ):
@@ -412,7 +420,7 @@ def __getstate__(self):
412420
413421 def __setstate__ (self , state ):
414422 self .__dict__ .update (state )
415- self .axes = AxesTuple ( self ._axis ( i ) for i in range ( self . ndim ) )
423+ self .axes = self ._generate_axes_ ( )
416424
417425 def __repr__ (self ):
418426 newline = "\n "
0 commit comments