@@ -220,6 +220,23 @@ def test_noflow_slicing():
220220 assert_array_equal (h [:, :, False ].view (), 0 )
221221
222222
223+ def test_singleflow_slicing ():
224+ h = bh .Histogram (
225+ bh .axis .Integer (0 , 4 , underflow = False ), bh .axis .Integer (0 , 4 , overflow = False )
226+ )
227+
228+ vals = np .arange (4 * 4 ).reshape (4 , 4 )
229+ h [:, :] = vals
230+
231+ assert h [0 , 0 ] == 0
232+ assert h [0 , 1 ] == 1
233+ assert h [1 , 0 ] == 4
234+ assert h [1 , 1 ] == 5
235+
236+ assert_array_equal (h [:, 1 : 3 : bh .sum ], vals [:, 1 :3 ].sum (axis = 1 ))
237+ assert_array_equal (h [1 : 3 : bh .sum , :], vals [1 :3 , :].sum (axis = 0 ))
238+
239+
223240def test_pick_str_category ():
224241 noflow = dict (underflow = False , overflow = False )
225242
@@ -247,17 +264,19 @@ def test_pick_int_category():
247264 h = bh .Histogram (
248265 bh .axis .Regular (10 , 0 , 10 ),
249266 bh .axis .Regular (10 , 0 , 10 , ** noflow ),
250- bh .axis .IntCategory ([3 , 5 , 7 ]),
267+ bh .axis .IntCategory ([3 , 5 , 7 , 12 , 13 ]),
251268 )
252269
253270 vals = np .arange (100 ).reshape (10 , 10 )
254271 h [:, :, bh .loc (3 )] = vals
255272 h [:, :, bh .loc (5 )] = vals + 1
273+ h [:, :, 3 ] = vals + 100
256274
257275 assert h [0 , 1 , bh .loc (3 )] == 1
258276 assert h [1 , 0 , bh .loc (5 )] == 10 + 1
259277 assert h [1 , 1 , bh .loc (5 )] == 11 + 1
260278 assert h [3 , 4 , bh .loc (7 )] == 0
279+ assert h [3 , 4 , bh .loc (12 )] == 134
261280
262281 assert_array_equal (h [:, :, bh .loc (3 )].view (), vals )
263282 assert_array_equal (h [:, :, bh .loc (5 )].view (), vals + 1 )
0 commit comments