Skip to content

Commit

Permalink
Remove PyMu2 from Python interface
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Oct 30, 2024
1 parent 67edab5 commit 23628b3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 75 deletions.
60 changes: 0 additions & 60 deletions pineappl_py/src/subgrid.rs
Original file line number Diff line number Diff line change
@@ -1,67 +1,8 @@
//! Subgrid interface.
use pineappl::subgrid::Mu2;
use pineappl::subgrid::{Subgrid, SubgridEnum};
use pyo3::prelude::*;

/// PyO3 wrapper to :rustdoc:`pineappl::subgrid::Mu2 <subgrid/struct.Mu2.html>`
#[pyclass(name = "Mu2")]
#[repr(transparent)]
pub struct PyMu2 {
pub(crate) mu2: Mu2,
}

#[pymethods]
impl PyMu2 {
/// Constructor.
///
/// Parameters
/// ----------
/// ren : float
/// renormalization scale
/// fac : float
/// factorization scale
/// frg : float
/// fragmentation scale
#[new]
#[must_use]
pub const fn new(ren: f64, fac: f64, frg: f64) -> Self {
Self {
mu2: Mu2 { ren, fac, frg },
}
}

#[getter]
const fn ren(&self) -> f64 {
self.mu2.ren
}

#[setter]
fn set_ren(&mut self, value: f64) {
self.mu2.ren = value;
}

#[getter]
const fn fac(&self) -> f64 {
self.mu2.fac
}

#[setter]
fn set_fac(&mut self, value: f64) {
self.mu2.fac = value;
}

#[getter]
const fn frg(&self) -> f64 {
self.mu2.frg
}

#[setter]
fn set_frg(&mut self, value: f64) {
self.mu2.frg = value;
}
}

/// PyO3 wrapper to :rustdoc:`pineappl::subgrid::SubgridEnum <subgrid/struct.SubgridEnum.html>`
#[pyclass(name = "SubgridEnum")]
#[derive(Clone)]
Expand Down Expand Up @@ -103,6 +44,5 @@ pub fn register(parent_module: &Bound<'_, PyModule>) -> PyResult<()> {
"import sys; sys.modules['pineappl.subgrid'] = m"
);
m.add_class::<PySubgridEnum>()?;
m.add_class::<PyMu2>()?;
parent_module.add_submodule(&m)
}
16 changes: 1 addition & 15 deletions pineappl_py/tests/test_subgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pineappl.import_subgrid import ImportSubgridV1
from pineappl.interpolation import Interp
from pineappl.pids import PidBasis
from pineappl.subgrid import Mu2, SubgridEnum
from pineappl.subgrid import SubgridEnum

# Define some default for the minimum value of `Q2`
Q2_MIN = 1e2
Expand Down Expand Up @@ -110,20 +110,6 @@ def fake_importonlysubgrid(self, nb_dim: int = 2) -> tuple:
subgrid = ImportSubgridV1(array=array, node_values=[scale, *x_grids])
return subgrid, [*x_grids, scale, array]

def test_mu2(self):
mu2_obj = Mu2(ren=1.0, fac=2.0, frg=0.0)
assert mu2_obj.ren == 1.0
assert mu2_obj.fac == 2.0
assert mu2_obj.frg == 0.0

# Overwrite the constructed values
mu2_obj.ren = 10.0
mu2_obj.fac = 20.0
mu2_obj.frg = 10.0
assert mu2_obj.ren == 10.0
assert mu2_obj.fac == 20.0
assert mu2_obj.frg == 10.0

def test_subgrid_methods(self):
# TODO: extract the values of the scales and x grids
grid = self.fake_grid()
Expand Down

0 comments on commit 23628b3

Please sign in to comment.