Skip to content

Commit

Permalink
Add missed PyGrid.set_key_value back
Browse files Browse the repository at this point in the history
  • Loading branch information
Radonirinaunimi committed Oct 30, 2024
1 parent 4aeb2a2 commit 1149688
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pineappl_py/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,23 @@ impl PyGrid {
self.grid.set_remapper(remapper.bin_remapper).unwrap();
}

/// Set a metadata key-value pair in the grid.
///
/// # Panics
/// TODO
///
/// Parameters
/// ----------
/// key : str
/// key
/// value : str
/// value
pub fn set_key_value(&mut self, key: &str, value: &str) {
self.grid
.metadata_mut()
.insert(key.to_owned(), value.to_owned());
}

/// Convolve the grid with as many distributions.
///
/// # Panics
Expand Down
10 changes: 10 additions & 0 deletions pineappl_py/tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,16 @@ def test_io(self, tmp_path, fake_grids):
assert isinstance(gg, Grid)
_ = Grid.read(str(p))

def test_set_key_value(self, fake_grids):
g = fake_grids.grid_with_two_convolutions(
channels=CHANNELS,
orders=ORDERS,
convolutions=[CONVOBJECT, CONVOBJECT],
)
g.set_key_value("bla", "blub")
g.set_key_value('"', "'")
g.set_key_value("äöü", \\")

def test_fill(self, fake_grids):
g = fake_grids.grid_with_two_convolutions(
channels=CHANNELS,
Expand Down

0 comments on commit 1149688

Please sign in to comment.