@@ -7,7 +7,7 @@ use super::fk_table::PyFkTable;
7
7
use super :: subgrid:: { PySubgridEnum , PySubgridParams } ;
8
8
use itertools:: izip;
9
9
use ndarray:: CowArray ;
10
- use numpy:: { IntoPyArray , PyArray1 , PyArrayMethods , PyReadonlyArray1 , PyReadonlyArray4 } ;
10
+ use numpy:: { IntoPyArray , PyArray1 , PyReadonlyArray4 } ;
11
11
use pineappl:: convolutions:: LumiCache ;
12
12
use pineappl:: evolution:: AlphasTable ;
13
13
use pineappl:: grid:: { Grid , Ntuple } ;
@@ -45,14 +45,14 @@ impl PyGrid {
45
45
pub fn new_grid (
46
46
channels : Vec < PyRef < PyChannel > > ,
47
47
orders : Vec < PyRef < PyOrder > > ,
48
- bin_limits : PyReadonlyArray1 < f64 > ,
48
+ bin_limits : Vec < f64 > ,
49
49
subgrid_params : PySubgridParams ,
50
50
) -> Self {
51
51
Self {
52
52
grid : Grid :: new (
53
53
channels. iter ( ) . map ( |pyc| pyc. entry . clone ( ) ) . collect ( ) ,
54
54
orders. iter ( ) . map ( |pyo| pyo. order . clone ( ) ) . collect ( ) ,
55
- bin_limits. to_vec ( ) . unwrap ( ) ,
55
+ bin_limits,
56
56
subgrid_params. subgrid_params ,
57
57
) ,
58
58
}
@@ -116,20 +116,20 @@ impl PyGrid {
116
116
/// cross section weight for all events
117
117
pub fn fill_array (
118
118
& mut self ,
119
- x1s : PyReadonlyArray1 < f64 > ,
120
- x2s : PyReadonlyArray1 < f64 > ,
121
- q2s : PyReadonlyArray1 < f64 > ,
119
+ x1s : Vec < f64 > ,
120
+ x2s : Vec < f64 > ,
121
+ q2s : Vec < f64 > ,
122
122
order : usize ,
123
- observables : PyReadonlyArray1 < f64 > ,
123
+ observables : Vec < f64 > ,
124
124
channel : usize ,
125
- weights : PyReadonlyArray1 < f64 > ,
125
+ weights : Vec < f64 > ,
126
126
) {
127
127
for ( & x1, & x2, & q2, & observable, & weight) in izip ! (
128
- x1s. as_array ( ) . iter( ) ,
129
- x2s. as_array ( ) . iter( ) ,
130
- q2s. as_array ( ) . iter( ) ,
131
- observables. as_array ( ) . iter( ) ,
132
- weights. as_array ( ) . iter( ) ,
128
+ x1s. iter( ) ,
129
+ x2s. iter( ) ,
130
+ q2s. iter( ) ,
131
+ observables. iter( ) ,
132
+ weights. iter( ) ,
133
133
) {
134
134
self . grid . fill (
135
135
order,
@@ -163,7 +163,7 @@ impl PyGrid {
163
163
q2 : f64 ,
164
164
order : usize ,
165
165
observable : f64 ,
166
- weights : PyReadonlyArray1 < f64 > ,
166
+ weights : Vec < f64 > ,
167
167
) {
168
168
self . grid . fill_all (
169
169
order,
@@ -174,7 +174,7 @@ impl PyGrid {
174
174
q2,
175
175
weight : ( ) ,
176
176
} ,
177
- & weights. to_vec ( ) . unwrap ( ) ,
177
+ & weights,
178
178
) ;
179
179
}
180
180
@@ -267,9 +267,9 @@ impl PyGrid {
267
267
pdg_id : i32 ,
268
268
xfx : & Bound < ' py , PyAny > ,
269
269
alphas : & Bound < ' py , PyAny > ,
270
- order_mask : Option < PyReadonlyArray1 < bool > > ,
271
- bin_indices : Option < PyReadonlyArray1 < usize > > ,
272
- channel_mask : Option < PyReadonlyArray1 < bool > > ,
270
+ order_mask : Option < Vec < bool > > ,
271
+ bin_indices : Option < Vec < usize > > ,
272
+ channel_mask : Option < Vec < bool > > ,
273
273
xi : Option < Vec < ( f64 , f64 ) > > ,
274
274
py : Python < ' py > ,
275
275
) -> Bound < ' py , PyArray1 < f64 > > {
@@ -280,10 +280,10 @@ impl PyGrid {
280
280
self . grid
281
281
. convolve (
282
282
& mut lumi_cache,
283
- & order_mask. map_or ( vec ! [ ] , |b| b . to_vec ( ) . unwrap ( ) ) ,
284
- & bin_indices. map_or ( vec ! [ ] , |c| c . to_vec ( ) . unwrap ( ) ) ,
285
- & channel_mask. map_or ( vec ! [ ] , |d| d . to_vec ( ) . unwrap ( ) ) ,
286
- & xi. map_or ( vec ! [ ( 1.0 , 1.0 ) ] , |m| m ) ,
283
+ & order_mask. unwrap_or_default ( ) ,
284
+ & bin_indices. unwrap_or_default ( ) ,
285
+ & channel_mask. unwrap_or_default ( ) ,
286
+ & xi. unwrap_or ( vec ! [ ( 1.0 , 1.0 ) ] ) ,
287
287
)
288
288
. into_pyarray_bound ( py)
289
289
}
@@ -332,9 +332,9 @@ impl PyGrid {
332
332
pdg_id2 : i32 ,
333
333
xfx2 : & Bound < ' py , PyAny > ,
334
334
alphas : & Bound < ' py , PyAny > ,
335
- order_mask : Option < PyReadonlyArray1 < bool > > ,
336
- bin_indices : Option < PyReadonlyArray1 < usize > > ,
337
- channel_mask : Option < PyReadonlyArray1 < bool > > ,
335
+ order_mask : Option < Vec < bool > > ,
336
+ bin_indices : Option < Vec < usize > > ,
337
+ channel_mask : Option < Vec < bool > > ,
338
338
xi : Option < Vec < ( f64 , f64 ) > > ,
339
339
py : Python < ' py > ,
340
340
) -> Bound < ' py , PyArray1 < f64 > > {
@@ -347,10 +347,10 @@ impl PyGrid {
347
347
self . grid
348
348
. convolve (
349
349
& mut lumi_cache,
350
- & order_mask. map_or ( vec ! [ ] , |b| b . to_vec ( ) . unwrap ( ) ) ,
351
- & bin_indices. map_or ( vec ! [ ] , |c| c . to_vec ( ) . unwrap ( ) ) ,
352
- & channel_mask. map_or ( vec ! [ ] , |d| d . to_vec ( ) . unwrap ( ) ) ,
353
- & xi. map_or ( vec ! [ ( 1.0 , 1.0 ) ] , |m| m ) ,
350
+ & order_mask. unwrap_or_default ( ) ,
351
+ & bin_indices. unwrap_or_default ( ) ,
352
+ & channel_mask. unwrap_or_default ( ) ,
353
+ & xi. unwrap_or ( vec ! [ ( 1.0 , 1.0 ) ] ) ,
354
354
)
355
355
. into_pyarray_bound ( py)
356
356
}
@@ -365,10 +365,10 @@ impl PyGrid {
365
365
/// Returns
366
366
/// -------
367
367
/// PyEvolveInfo :
368
- /// evolution informations
369
- pub fn evolve_info ( & self , order_mask : PyReadonlyArray1 < bool > ) -> PyEvolveInfo {
368
+ /// evolution information
369
+ pub fn evolve_info ( & self , order_mask : Vec < bool > ) -> PyEvolveInfo {
370
370
PyEvolveInfo {
371
- evolve_info : self . grid . evolve_info ( order_mask. as_slice ( ) . unwrap ( ) ) ,
371
+ evolve_info : self . grid . evolve_info ( order_mask. as_slice ( ) ) ,
372
372
}
373
373
}
374
374
@@ -394,7 +394,7 @@ impl PyGrid {
394
394
pub fn evolve_with_slice_iter < ' py > (
395
395
& self ,
396
396
slices : & Bound < ' py , PyIterator > ,
397
- order_mask : PyReadonlyArray1 < bool > ,
397
+ order_mask : Vec < bool > ,
398
398
xi : ( f64 , f64 ) ,
399
399
ren1 : Vec < f64 > ,
400
400
alphas : Vec < f64 > ,
@@ -413,8 +413,7 @@ impl PyGrid {
413
413
CowArray :: from ( op. as_array ( ) . to_owned ( ) ) ,
414
414
) )
415
415
} ) ,
416
- // TODO: make `order_mask` a `Vec<f64>`
417
- & order_mask. to_vec ( ) . unwrap ( ) ,
416
+ & order_mask,
418
417
xi,
419
418
& AlphasTable { ren1, alphas } ,
420
419
)
@@ -448,7 +447,7 @@ impl PyGrid {
448
447
& self ,
449
448
slices_a : & Bound < ' py , PyIterator > ,
450
449
slices_b : & Bound < ' py , PyIterator > ,
451
- order_mask : PyReadonlyArray1 < bool > ,
450
+ order_mask : Vec < bool > ,
452
451
xi : ( f64 , f64 ) ,
453
452
ren1 : Vec < f64 > ,
454
453
alphas : Vec < f64 > ,
@@ -478,8 +477,7 @@ impl PyGrid {
478
477
CowArray :: from ( op. as_array ( ) . to_owned ( ) ) ,
479
478
) )
480
479
} ) ,
481
- // TODO: make `order_mask` a `Vec<f64>`
482
- & order_mask. to_vec ( ) . unwrap ( ) ,
480
+ & order_mask,
483
481
xi,
484
482
& AlphasTable { ren1, alphas } ,
485
483
)
@@ -648,8 +646,8 @@ impl PyGrid {
648
646
/// ----------
649
647
/// factors : numpy.ndarray[float]
650
648
/// bin-dependent factors by which to scale
651
- pub fn scale_by_bin ( & mut self , factors : PyReadonlyArray1 < f64 > ) {
652
- self . grid . scale_by_bin ( & factors. to_vec ( ) . unwrap ( ) ) ;
649
+ pub fn scale_by_bin ( & mut self , factors : Vec < f64 > ) {
650
+ self . grid . scale_by_bin ( & factors) ;
653
651
}
654
652
655
653
/// Delete bins.
@@ -660,8 +658,8 @@ impl PyGrid {
660
658
/// ----------
661
659
/// bin_indices : numpy.ndarray[int]
662
660
/// list of indices of bins to removed
663
- pub fn delete_bins ( & mut self , bin_indices : PyReadonlyArray1 < usize > ) {
664
- self . grid . delete_bins ( & bin_indices. to_vec ( ) . unwrap ( ) )
661
+ pub fn delete_bins ( & mut self , bin_indices : Vec < usize > ) {
662
+ self . grid . delete_bins ( & bin_indices)
665
663
}
666
664
}
667
665
0 commit comments