Skip to content

Commit

Permalink
Exposes key_values and set_key_values for PyFkTable
Browse files Browse the repository at this point in the history
  • Loading branch information
Radonirinaunimi committed Nov 26, 2024
1 parent 95ff7eb commit 230f648
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pineappl/src/fk_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ impl FkTable {
muf2
}

/// Set a metadata key-value pair for this FK table.
pub fn set_key_value(&mut self, key: &str, value: &str) {
self.grid
.metadata_mut()
.insert(key.to_owned(), value.to_owned());
}

/// Returns the x grid that all subgrids for all hadronic initial states share.
#[must_use]
pub fn x_grid(&self) -> Vec<f64> {
Expand Down
26 changes: 26 additions & 0 deletions pineappl_py/src/fk_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use pineappl::convolutions::ConvolutionCache;
use pineappl::fk_table::{FkAssumptions, FkTable};
use pineappl::grid::Grid;
use pyo3::prelude::*;
use std::collections::BTreeMap;
use std::fs::File;
use std::io::BufReader;
use std::path::PathBuf;
Expand Down Expand Up @@ -251,6 +252,31 @@ impl PyFkTable {
.unwrap();
}

/// Set a metadata key-value pair in the FK Table.
///
/// Parameters
/// ----------
/// key : str
/// key
/// value : str
/// value
pub fn set_key_value(&mut self, key: &str, value: &str) {
self.fk_table.set_key_value(key, value);
}

/// Get metadata values stored in the grid.
///
///
/// Returns
/// -------
/// dict :
/// key, value map
#[getter]
#[must_use]
pub fn key_values(&self) -> BTreeMap<String, String> {
self.fk_table.grid().metadata().clone()
}

/// Convolve the FK table with as many distributions.
///
/// # Panics
Expand Down

0 comments on commit 230f648

Please sign in to comment.