@@ -186,11 +186,15 @@ def histplot(
186
186
continue
187
187
elif flow is None :
188
188
continue
189
- elif hasattr (h , "plot1d" ):
189
+ elif (
190
+ hasattr (h , "axes" )
191
+ and hasattr (h .axes [0 ], "traits" )
192
+ and hasattr (h .axes [0 ].traits , "underflow" )
193
+ ):
190
194
if h .axes [0 ].traits .underflow :
191
195
underflow = underflow + h .values (flow = True )[0 ]
192
196
if h .axes [0 ].traits .overflow :
193
- overflow = overflow + h .values (flow = True )[0 ]
197
+ overflow = overflow + h .values (flow = True )[- 1 ]
194
198
else :
195
199
underflow = underflow + h .values (flow = True )[0 ]
196
200
overflow = overflow + h .values (flow = True )[- 1 ]
@@ -199,10 +203,7 @@ def histplot(
199
203
plottables = []
200
204
flow_bins = final_bins
201
205
for i , h in enumerate (hists ):
202
- if hasattr (h , "plot1d" ):
203
- value , variance = h .values ().copy (), h .variances ().copy ()
204
- else :
205
- value , variance = h .values (), h .variances ()
206
+ value , variance = h .values (), h .variances ()
206
207
if (
207
208
hasattr (h , "values" )
208
209
and "flow" not in inspect .getfullargspec (h .values ).args
@@ -213,7 +214,13 @@ def histplot(
213
214
flow = None
214
215
plottables .append (Plottable (value , edges = final_bins , variances = variance ))
215
216
# check the original hist as flow bins
216
- elif hasattr (h , "plot1d" ) and len (h .values (flow = True )) < len (final_bins ):
217
+ elif (
218
+ hasattr (h , "axes" )
219
+ and hasattr (h .axes [0 ], "traits" )
220
+ and hasattr (h .axes [0 ].traits , "underflow" )
221
+ and not h .axes [0 ].traits .underflow
222
+ and not h .axes [0 ].traits .overflow
223
+ ):
217
224
print (f"Warning: you don't have flow bins stored in { h } " )
218
225
flow = None
219
226
plottables .append (Plottable (value , edges = final_bins , variances = variance ))
@@ -251,6 +258,7 @@ def histplot(
251
258
)
252
259
plottables .append (Plottable (value , edges = flow_bins , variances = variance ))
253
260
elif flow == "sum" :
261
+ value , variance = h .values ().copy (), h .variances ().copy ()
254
262
value [0 ], value [- 1 ] = (
255
263
value [0 ] + h .values (flow = True )[0 ],
256
264
value [- 1 ] + h .values (flow = True )[- 1 ],
@@ -631,7 +639,7 @@ def hist2dplot(
631
639
632
640
# TODO: use Histogram everywhere
633
641
634
- H = h .values () if not hasattr ( h , "plot1d" ) else h . values (). copy ()
642
+ H = h .values ()
635
643
xbins , xtick_labels = get_plottable_protocol_bins (h .axes [0 ])
636
644
ybins , ytick_labels = get_plottable_protocol_bins (h .axes [1 ])
637
645
# Show under/overflow bins
@@ -646,9 +654,11 @@ def hist2dplot(
646
654
)
647
655
flow = None
648
656
elif (
649
- hasattr (h , "plot1d" )
650
- and len (h .values (flow = True )[0 ]) < len (xbins )
651
- and len (h .values (flow = True )[1 ]) < len (ybins )
657
+ hasattr (h , "axes" )
658
+ and hasattr (h .axes [0 ], "traits" )
659
+ and hasattr (h .axes [0 ].traits , "underflow" )
660
+ and not h .axes [0 ].traits .underflow
661
+ and not h .axes [0 ].traits .overflow
652
662
):
653
663
flow = None
654
664
print (f"Warning: you don't have flow bins stored in { h } " )
@@ -696,6 +706,7 @@ def hist2dplot(
696
706
if any (h .values (flow = True )[:, - 1 ] > 0 ):
697
707
H = np .insert (H , (- 1 ), np .full (np .shape (H )[1 ], np .nan ), axis = 0 )
698
708
elif flow == "sum" :
709
+ H = h .values ().copy ()
699
710
# Sum borders
700
711
H [0 ], H [- 1 ] = (
701
712
H [0 ] + h .values (flow = True )[0 , 1 :- 1 ],
0 commit comments