Skip to content

Commit

Permalink
fix: Provide default values using options
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Apr 16, 2024
1 parent c42be03 commit 9bace31
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions pineappl_py/src/fk_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,30 @@ impl PyFkTable {
/// -------
/// numpy.ndarray(float) :
/// cross sections for all bins
#[pyo3(signature = (pdf_id, xfx, bin_indices = pyarray![].readonly(), lumi_cache = pyarray![].readonly()))]
#[pyo3(signature = (pdg_id, xfx, bin_indices = None, lumi_mask= None))]
pub fn convolute_with_one<'py>(
&self,
pdg_id: i32,
xfx: &PyAny,
bin_indices: PyReadonlyArray1<usize>,
lumi_mask: PyReadonlyArray1<bool>,
bin_indices: Option<PyReadonlyArray1<usize>>,
lumi_mask: Option<PyReadonlyArray1<bool>>,
py: Python<'py>,
) -> &'py PyArray1<f64> {
let mut xfx = |id, x, q2| f64::extract(xfx.call1((id, x, q2)).unwrap()).unwrap();
let mut alphas = |_| 1.0;
let mut lumi_cache = LumiCache::with_one(pdg_id, &mut xfx, &mut alphas);
let bin_indices = if let Some(b) = bin_indices {
b.to_vec().unwrap()
} else {
vec![]
};
let lumi_mask = if let Some(l) = lumi_mask {
l.to_vec().unwrap()
} else {
vec![]
};
self.fk_table
.convolute(
&mut lumi_cache,
&bin_indices.to_vec().unwrap(),
&lumi_mask.to_vec().unwrap(),
)
.convolute(&mut lumi_cache, &bin_indices, &lumi_mask)
.into_pyarray(py)
}

Expand Down

0 comments on commit 9bace31

Please sign in to comment.