@@ -35,8 +35,8 @@ def test_hist():
35
35
36
36
h_regular_bins = cuda_histogram .Hist (
37
37
"regular joe" ,
38
- cuda_histogram .Bin ("x" , "x" , 20 , 0 , 200 ),
39
- cuda_histogram .Bin ("y" , "why" , 20 , - 3 , 3 ),
38
+ cuda_histogram .axis . Bin ("x" , "x" , 20 , 0 , 200 ),
39
+ cuda_histogram .axis . Bin ("y" , "why" , 20 , - 3 , 3 ),
40
40
)
41
41
h_regular_bins .fill (x = test_pt , y = test_eta )
42
42
nentries = np .sum (counts )
@@ -63,8 +63,8 @@ def test_hist():
63
63
assert h_reduced .integrate ("x" , slice (20 , 30 )).values ()[()][2 ] == count_some_bin + 1
64
64
assert h_reduced .integrate ("y" , slice (0 , 0.3 )).values ()[()][1 ] == count_some_bin + 1
65
65
66
- animal = cuda_histogram .Cat ("animal" , "type of animal" )
67
- vocalization = cuda_histogram .Cat (
66
+ animal = cuda_histogram .axis . Cat ("animal" , "type of animal" )
67
+ vocalization = cuda_histogram .axis . Cat (
68
68
"vocalization" , "onomatopoiea is that how you spell it?"
69
69
)
70
70
h_cat_bins = cuda_histogram .Hist ("I like cats" , animal , vocalization )
@@ -80,14 +80,14 @@ def test_hist():
80
80
("dog" ,)
81
81
] == (101.0 , 10001.0 )
82
82
83
- height = cuda_histogram .Bin ("height" , "height [m]" , 10 , 0 , 5 )
83
+ height = cuda_histogram .axis . Bin ("height" , "height [m]" , 10 , 0 , 5 )
84
84
h_mascots_1 = cuda_histogram .Hist (
85
85
"fermi mascot showdown" ,
86
86
animal ,
87
87
vocalization ,
88
88
height ,
89
89
# weight is a reserved keyword
90
- cuda_histogram .Bin (
90
+ cuda_histogram .axis . Bin (
91
91
"mass" , "weight (g=9.81m/s**2) [kg]" , np .power (10.0 , np .arange (5 ) - 1 )
92
92
),
93
93
)
@@ -99,7 +99,7 @@ def test_hist():
99
99
vocalization ,
100
100
height ,
101
101
# weight is a reserved keyword
102
- cuda_histogram .Bin (
102
+ cuda_histogram .axis . Bin (
103
103
"mass" , "weight (g=9.81m/s**2) [kg]" , np .power (10.0 , np .arange (5 ) - 1 )
104
104
),
105
105
),
@@ -111,7 +111,7 @@ def test_hist():
111
111
vocalization ,
112
112
height ,
113
113
# weight is a reserved keyword
114
- cuda_histogram .Bin (
114
+ cuda_histogram .axis . Bin (
115
115
"mass" , "weight (g=9.81m/s**2) [kg]" , np .power (10.0 , np .arange (5 ) - 1 )
116
116
),
117
117
],
@@ -125,15 +125,15 @@ def test_hist():
125
125
vocalization ,
126
126
height ,
127
127
# weight is a reserved keyword
128
- cuda_histogram .Bin (
128
+ cuda_histogram .axis . Bin (
129
129
"mass" , "weight (g=9.81m/s**2) [kg]" , np .power (10.0 , np .arange (5 ) - 1 )
130
130
),
131
131
axes = [
132
132
animal ,
133
133
vocalization ,
134
134
height ,
135
135
# weight is a reserved keyword
136
- cuda_histogram .Bin (
136
+ cuda_histogram .axis . Bin (
137
137
"mass" ,
138
138
"weight (g=9.81m/s**2) [kg]" ,
139
139
np .power (10.0 , np .arange (5 ) - 1 ),
@@ -188,7 +188,7 @@ def test_hist():
188
188
== 1040.0
189
189
)
190
190
191
- species_class = cuda_histogram .Cat (
191
+ species_class = cuda_histogram .axis . Cat (
192
192
"species_class" , "where the subphylum is vertibrates"
193
193
)
194
194
classes = {
@@ -224,7 +224,9 @@ def test_hist():
224
224
assert h_species .axis ("height" ) is height
225
225
assert h_species .integrate ("vocalization" , "h*" ).axis ("height" ) is height
226
226
227
- tall_class = cuda_histogram .Cat ("tall_class" , "species class (species above 1m)" )
227
+ tall_class = cuda_histogram .axis .Cat (
228
+ "tall_class" , "species class (species above 1m)"
229
+ )
228
230
mapping = {
229
231
"birds" : (["goose" , "crane" ], slice (1.0 , None )),
230
232
"mammals" : (["bison" , "fox" ], slice (1.0 , None )),
@@ -246,8 +248,8 @@ def test_hist_serdes():
246
248
247
249
h_regular_bins = cuda_histogram .Hist (
248
250
"regular joe" ,
249
- cuda_histogram .Bin ("x" , "x" , 20 , 0 , 200 ),
250
- cuda_histogram .Bin ("y" , "why" , 20 , - 3 , 3 ),
251
+ cuda_histogram .axis . Bin ("x" , "x" , 20 , 0 , 200 ),
252
+ cuda_histogram .axis . Bin ("y" , "why" , 20 , - 3 , 3 ),
251
253
)
252
254
253
255
h_regular_bins .fill (
@@ -269,7 +271,7 @@ def test_hist_serdes():
269
271
def test_hist_serdes_labels ():
270
272
import pickle
271
273
272
- ax = cuda_histogram .Bin ("asdf" , "asdf" , 3 , 0 , 3 )
274
+ ax = cuda_histogram .axis . Bin ("asdf" , "asdf" , 3 , 0 , 3 )
273
275
ax .identifiers ()[0 ].label = "type 1"
274
276
h = cuda_histogram .Hist ("a" , ax )
275
277
h .identifiers ("asdf" )
@@ -288,9 +290,9 @@ def test_hist_serdes_labels():
288
290
def test_issue_247 ():
289
291
import cuda_histogram
290
292
291
- h = cuda_histogram .Hist ("stuff" , cuda_histogram .Bin ("old" , "old" , 20 , - 1 , 1 ))
293
+ h = cuda_histogram .Hist ("stuff" , cuda_histogram .axis . Bin ("old" , "old" , 20 , - 1 , 1 ))
292
294
h .fill (old = h .axis ("old" ).centers ())
293
- h2 = h .rebin (h .axis ("old" ), cuda_histogram .Bin ("new" , "new" , 10 , - 1 , 1 ))
295
+ h2 = h .rebin (h .axis ("old" ), cuda_histogram .axis . Bin ("new" , "new" , 10 , - 1 , 1 ))
294
296
# check first if its even possible to have correct binning
295
297
assert np .all (h2 .axis ("new" ).edges () == h .axis ("old" ).edges ()[::2 ])
296
298
# make sure the lookup works properly
@@ -300,31 +302,31 @@ def test_issue_247():
300
302
301
303
with pytest .raises (ValueError ):
302
304
# invalid division
303
- _ = h .rebin (h .axis ("old" ), cuda_histogram .Bin ("new" , "new" , 8 , - 1 , 1 ))
305
+ _ = h .rebin (h .axis ("old" ), cuda_histogram .axis . Bin ("new" , "new" , 8 , - 1 , 1 ))
304
306
305
- newaxis = cuda_histogram .Bin (
307
+ newaxis = cuda_histogram .axis . Bin (
306
308
"new" , "new" , h .axis ("old" ).edges ()[np .cumsum ([0 , 2 , 3 , 5 ])]
307
309
)
308
310
h .rebin ("old" , newaxis )
309
311
310
312
311
313
def test_issue_333 ():
312
- axis = cuda_histogram .Bin ("channel" , "Channel b1" , 50 , 0 , 2000 )
314
+ axis = cuda_histogram .axis . Bin ("channel" , "Channel b1" , 50 , 0 , 2000 )
313
315
temp = np .arange (0 , 2000 , 40 , dtype = np .int16 )
314
316
assert np .all (axis .index (temp ).get () == np .arange (50 ) + 1 )
315
317
316
318
317
319
def test_issue_394 ():
318
320
dummy = cuda_histogram .Hist (
319
321
"Dummy" ,
320
- cuda_histogram .Cat ("sample" , "sample" ),
321
- cuda_histogram .Bin ("dummy" , "Number of events" , 1 , 0 , 1 ),
322
+ cuda_histogram .axis . Cat ("sample" , "sample" ),
323
+ cuda_histogram .axis . Bin ("dummy" , "Number of events" , 1 , 0 , 1 ),
322
324
)
323
325
dummy .fill (sample = "test" , dummy = 1 , weight = 0.5 )
324
326
325
327
326
328
def test_fill_none ():
327
- dummy = cuda_histogram .Hist ("Dummy" , cuda_histogram .Bin ("x" , "asdf" , 1 , 0 , 1 ))
329
+ dummy = cuda_histogram .Hist ("Dummy" , cuda_histogram .axis . Bin ("x" , "asdf" , 1 , 0 , 1 ))
328
330
with pytest .raises (ValueError ):
329
331
# attempt to fill with none
330
332
dummy .fill (x = ak .Array ([0.1 , None , 0.3 ]))
@@ -338,8 +340,8 @@ def test_boost_conversion():
338
340
339
341
dummy = cuda_histogram .Hist (
340
342
"Dummy" ,
341
- cuda_histogram .Cat ("sample" , "sample" ),
342
- cuda_histogram .Bin ("dummy" , "Number of events" , 1 , 0 , 1 ),
343
+ cuda_histogram .axis . Cat ("sample" , "sample" ),
344
+ cuda_histogram .axis . Bin ("dummy" , "Number of events" , 1 , 0 , 1 ),
343
345
)
344
346
dummy .fill (sample = "test" , dummy = 1 , weight = 0.5 )
345
347
dummy .fill (sample = "test" , dummy = 0.1 )
@@ -362,8 +364,8 @@ def test_boost_conversion():
362
364
363
365
dummy = cuda_histogram .Hist (
364
366
"Dummy" ,
365
- cuda_histogram .Cat ("sample" , "sample" ),
366
- cuda_histogram .Bin ("dummy" , "Number of events" , 1 , 0 , 1 ),
367
+ cuda_histogram .axis . Cat ("sample" , "sample" ),
368
+ cuda_histogram .axis . Bin ("dummy" , "Number of events" , 1 , 0 , 1 ),
367
369
)
368
370
dummy .fill (sample = "test" , dummy = 0.1 )
369
371
dummy .fill (sample = "test" , dummy = 0.2 )
0 commit comments