Skip to content

Commit

Permalink
Remove obsolete FkTable methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Aug 22, 2024
1 parent afe7aeb commit 2c850ec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 70 deletions.
60 changes: 2 additions & 58 deletions pineappl/src/fk_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

use super::boc::Order;
use super::convolutions::{Convolution, LumiCache};
use super::grid::{Grid, GridError};
use super::grid::Grid;
use super::subgrid::Subgrid;
use float_cmp::approx_eq;
use ndarray::Array4;
use std::collections::HashMap;
use std::fmt::{self, Display, Formatter};
use std::io::Write;
use std::str::FromStr;
use thiserror::Error;

Expand Down Expand Up @@ -152,7 +150,7 @@ impl FkTable {
let x_grid = self.x_grid();

let mut result = Array4::zeros((
self.bins(),
self.grid.bin_info().bins(),
self.grid.channels().len(),
if has_pdf1 { x_grid.len() } else { 1 },
if has_pdf2 { x_grid.len() } else { 1 },
Expand Down Expand Up @@ -188,42 +186,6 @@ impl FkTable {
result
}

/// Returns the number of bins for this `FkTable`.
#[must_use]
pub fn bins(&self) -> usize {
self.grid.bin_info().bins()
}

/// Extract the normalizations for each bin.
#[must_use]
pub fn bin_normalizations(&self) -> Vec<f64> {
self.grid.bin_info().normalizations()
}

/// Extract the number of dimensions for bins.
#[must_use]
pub fn bin_dimensions(&self) -> usize {
self.grid.bin_info().dimensions()
}

/// Extract the left edges of a specific bin dimension.
#[must_use]
pub fn bin_left(&self, dimension: usize) -> Vec<f64> {
self.grid.bin_info().left(dimension)
}

/// Extract the right edges of a specific bin dimension.
#[must_use]
pub fn bin_right(&self, dimension: usize) -> Vec<f64> {
self.grid.bin_info().right(dimension)
}

/// Access meta data
#[must_use]
pub const fn key_values(&self) -> Option<&HashMap<String, String>> {
self.grid.key_values()
}

/// Return the channel definition for this `FkTable`. All factors are `1.0`.
#[must_use]
pub fn channels(&self) -> Vec<(i32, i32)> {
Expand Down Expand Up @@ -251,24 +213,6 @@ impl FkTable {
self.grid.evolve_info(&[true]).x1
}

/// Propagate write to grid
///
/// # Errors
///
/// TODO
pub fn write(&self, writer: impl Write) -> Result<(), GridError> {
self.grid.write(writer)
}

/// Propagate `write_lz4` to `Grid`.
///
/// # Errors
///
/// See [`Grid::write_lz4`].
pub fn write_lz4(&self, writer: impl Write) -> Result<(), GridError> {
self.grid.write_lz4(writer)
}

/// Convolve the FK-table. This method has fewer arguments than [`Grid::convolve`], because
/// FK-tables have all orders merged together and do not support scale variations.
pub fn convolve(
Expand Down
10 changes: 5 additions & 5 deletions pineappl_cli/tests/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,11 @@ fn import_hadronic_fktable() {
]
);

assert_eq!(fk_table.bins(), 1);
assert_eq!(fk_table.bin_normalizations(), [1.0]);
assert_eq!(fk_table.bin_dimensions(), 1);
assert_eq!(fk_table.bin_left(0), [0.0]);
assert_eq!(fk_table.bin_right(0), [1.0]);
assert_eq!(fk_table.grid().bin_info().bins(), 1);
assert_eq!(fk_table.grid().bin_info().normalizations(), [1.0]);
assert_eq!(fk_table.grid().bin_info().dimensions(), 1);
assert_eq!(fk_table.grid().bin_info().left(0), [0.0]);
assert_eq!(fk_table.grid().bin_info().right(0), [1.0]);
assert_eq!(
fk_table.grid().convolutions(),
[Convolution::UnpolPDF(2212), Convolution::UnpolPDF(2212)]
Expand Down
30 changes: 23 additions & 7 deletions pineappl_py/src/fk_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl PyFkTable {
/// int :
/// number of bins
pub fn bins(&self) -> usize {
self.fk_table.bins()
self.fk_table.grid().bin_info().bins()
}

/// Extract the normalizations for each bin.
Expand All @@ -85,7 +85,11 @@ impl PyFkTable {
/// numpy.ndarray
/// bin normalizations
pub fn bin_normalizations<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> {
self.fk_table.bin_normalizations().into_pyarray_bound(py)
self.fk_table
.grid()
.bin_info()
.normalizations()
.into_pyarray_bound(py)
}

/// Extract the number of dimensions for bins.
Expand All @@ -97,7 +101,7 @@ impl PyFkTable {
/// int :
/// bin dimension
pub fn bin_dimensions(&self) -> usize {
self.fk_table.bin_dimensions()
self.fk_table.grid().bin_info().dimensions()
}

/// Extract the left edges of a specific bin dimension.
Expand All @@ -112,7 +116,11 @@ impl PyFkTable {
/// numpy.ndarray(float) :
/// left edges of bins
pub fn bin_left<'py>(&self, dimension: usize, py: Python<'py>) -> Bound<'py, PyArray1<f64>> {
self.fk_table.bin_left(dimension).into_pyarray_bound(py)
self.fk_table
.grid()
.bin_info()
.left(dimension)
.into_pyarray_bound(py)
}

/// Extract the right edges of a specific bin dimension.
Expand All @@ -127,7 +135,11 @@ impl PyFkTable {
/// numpy.ndarray(float) :
/// right edges of bins
pub fn bin_right<'py>(&self, dimension: usize, py: Python<'py>) -> Bound<'py, PyArray1<f64>> {
self.fk_table.bin_right(dimension).into_pyarray_bound(py)
self.fk_table
.grid()
.bin_info()
.right(dimension)
.into_pyarray_bound(py)
}

/// Get metadata values.
Expand All @@ -137,7 +149,7 @@ impl PyFkTable {
/// dict :
/// key, value map
pub fn key_values(&self) -> HashMap<String, String> {
self.fk_table.key_values().unwrap().clone()
self.fk_table.grid().key_values().unwrap().clone()
}

/// Set a metadata key-value pair.
Expand Down Expand Up @@ -189,7 +201,10 @@ impl PyFkTable {
/// path : str
/// file path
pub fn write(&self, path: PathBuf) {
self.fk_table.write(File::create(path).unwrap()).unwrap();
self.fk_table
.grid()
.write(File::create(path).unwrap())
.unwrap();
}

/// Write to file using lz4.
Expand All @@ -200,6 +215,7 @@ impl PyFkTable {
/// file path
pub fn write_lz4(&self, path: PathBuf) {
self.fk_table
.grid()
.write_lz4(File::create(path).unwrap())
.unwrap();
}
Expand Down

0 comments on commit 2c850ec

Please sign in to comment.