pub struct PyPDF { /* private fields */ }Expand description
Python wrapper for the neopdf::pdf::PDF struct.
This class provides a Python-friendly interface to the core PDF
interpolation functionalities of the neopdf Rust library.
Implementations§
Source§impl PyPDF
impl PyPDF
Sourcepub fn mkpdf_lhaid(lhaid: u32) -> Self
pub fn mkpdf_lhaid(lhaid: u32) -> Self
Loads a PDF member by its LHAPDF ID (LHAID).
The set name and member index are resolved by fetching the LHAPDF set
index from https://lhapdfsets.web.cern.ch/current/pdfsets.index.
§Parameters
lhaid : int The LHAPDF ID uniquely identifying both the PDF set and the member.
§Returns
PDF
A new PDF instance for the set and member encoded in lhaid.
Sourcepub fn mkpdf_lhapdf_file(path: &str) -> Self
pub fn mkpdf_lhapdf_file(path: &str) -> Self
Sourcepub fn mkpdfs(pdf_name: &str, method: &PyLoaderMethod) -> Vec<Self>
pub fn mkpdfs(pdf_name: &str, method: &PyLoaderMethod) -> Vec<Self>
Sourcepub fn mkpdfs_lazy(pdf_name: &str) -> PyLazyPDFs
pub fn mkpdfs_lazy(pdf_name: &str) -> PyLazyPDFs
Creates an iterator that loads PDF members lazily.
This function is suitable for .neopdf.lz4 files, which support lazy loading.
It returns an iterator that yields PDF instances on demand, which is useful
for reducing memory consumption when working with large PDF sets.
§Arguments
pdf_name- The name of the PDF set (must end with.neopdf.lz4).
§Returns
An iterator over Result<PDF, Box<dyn std::error::Error>>.
Sourcepub fn subgrid_knots(
&self,
param: &PyGridParams,
subgrid_index: usize,
) -> Vec<f64>
pub fn subgrid_knots( &self, param: &PyGridParams, subgrid_index: usize, ) -> Vec<f64>
Returns the subgrid knots of a parameter for a given subgrid index.
The parameter could be the nucleon numbers A, the strong coupling
alphas, the momentum fraction x, or the momentum scale Q2.
§Panics
This panics if the parameter is not valid.
§Returns
list[float] The subgrid knots for a given parameter.
Sourcepub fn set_force_positive(&mut self, option: PyForcePositive)
pub fn set_force_positive(&mut self, option: PyForcePositive)
Clip the negative or small values for the PDF object.
§Parameters
id : PyFrocePositive The clipping method use to handle negative or small values.
Sourcepub fn set_force_positive_members(
pdfs: Vec<PyRefMut<'_, Self>>,
option: PyForcePositive,
)
pub fn set_force_positive_members( pdfs: Vec<PyRefMut<'_, Self>>, option: PyForcePositive, )
Sourcepub fn is_force_positive(&self) -> PyForcePositive
pub fn is_force_positive(&self) -> PyForcePositive
Returns the clipping method used for a single PDF object.
§Returns
PyForcePositive
The clipping method used for the PDF object.
Sourcepub fn flavour_pids(&self) -> Vec<i32>
pub fn flavour_pids(&self) -> Vec<i32>
Sourcepub fn xfxq2(&self, id: i32, x: f64, q2: f64) -> f64
pub fn xfxq2(&self, id: i32, x: f64, q2: f64) -> f64
Interpolates the PDF value (xf) for a given flavor, x, and Q2.
§Parameters
id : int The flavor ID (e.g., 21 for gluon, 1 for d-quark). x : float The momentum fraction. q2 : float The energy scale squared.
§Returns
float The interpolated PDF value. Returns 0.0 if extrapolation is attempted and not allowed.
Sourcepub fn xfxq2_nd(&self, id: i32, params: Vec<f64>) -> f64
pub fn xfxq2_nd(&self, id: i32, params: Vec<f64>) -> f64
Interpolates the PDF value (xf) for a given set of parameters.
§Parameters
id : int
The flavor ID (e.g., 21 for gluon, 1 for d-quark).
params: list[float]
A list of parameters that the grids depends on. If the PDF
grid only contains x and Q2 dependence then its value is
[x, q2]; if it contains either the A and alpha_s
dependence, then its value is [A, x, q2] or [alpha_s, x, q2]
respectively; if it contains both, then [A, alpha_s, x, q2].
§Returns
float The interpolated PDF value. Returns 0.0 if extrapolation is attempted and not allowed.
Sourcepub fn xfxq2_allpids<'py>(
&self,
pids: Vec<i32>,
x: f64,
q2: f64,
py: Python<'py>,
) -> Bound<'py, PyArray1<f64>> ⓘ
pub fn xfxq2_allpids<'py>( &self, pids: Vec<i32>, x: f64, q2: f64, py: Python<'py>, ) -> Bound<'py, PyArray1<f64>> ⓘ
Sourcepub fn xfxq2_allpids_nd<'py>(
&self,
pids: Vec<i32>,
params: Vec<f64>,
py: Python<'py>,
) -> Bound<'py, PyArray1<f64>> ⓘ
pub fn xfxq2_allpids_nd<'py>( &self, pids: Vec<i32>, params: Vec<f64>, py: Python<'py>, ) -> Bound<'py, PyArray1<f64>> ⓘ
Sourcepub fn xfxq2_cheby_batch(&self, id: i32, params: Vec<Vec<f64>>) -> Vec<f64>
pub fn xfxq2_cheby_batch(&self, id: i32, params: Vec<Vec<f64>>) -> Vec<f64>
Interpolates the PDF value (xf) for a list containg a set of parameters.
§Parameters
id : int
The flavor ID (e.g., 21 for gluon, 1 for d-quark).
params: list[list[float]]
A list containing the list of points. Each element in the list
is in turn a list containing the parameters that the grids depends
on. If the PDF grid only contains x and Q2 dependence then its
value is [x, q2]; if it contains either the A and alpha_s
dependence, then its value is [A, x, q2] or [alpha_s, x, q2]
respectively; if it contains both, then [A, alpha_s, x, q2].
§Returns
float The interpolated PDF value. Returns 0.0 if extrapolation is attempted and not allowed.
Sourcepub fn xfxq2s<'py>(
&self,
pids: Vec<i32>,
xs: Vec<f64>,
q2s: Vec<f64>,
py: Python<'py>,
) -> Bound<'py, PyArray2<f64>> ⓘ
pub fn xfxq2s<'py>( &self, pids: Vec<i32>, xs: Vec<f64>, q2s: Vec<f64>, py: Python<'py>, ) -> Bound<'py, PyArray2<f64>> ⓘ
Interpolates the PDF value (xf) for lists of flavors, x-values, and Q2-values.
§Parameters
id : list[int] A list of flavor IDs. xs : list[float] A list of momentum fractions. q2s : list[float] A list of energy scales squared.
§Returns
numpy.ndarray A 2D NumPy array containing the interpolated PDF values.
Sourcepub fn metadata(&self) -> PyMetaData
pub fn metadata(&self) -> PyMetaData
Returns the metadata associated with this PDF set.
Provides access to the metadata describing the PDF set, including information such as the set description, number of members, parameter ranges, and other relevant details.
§Returns
MetaData
The metadata for this PDF set as a MetaData Python object.
Sourcepub fn flavors(&self) -> Vec<i32>
pub fn flavors(&self) -> Vec<i32>
Return the list of available flavor PIDs (LHAPDF name for pids).
Sourcepub fn has_flavor(&self, id: i32) -> bool
pub fn has_flavor(&self, id: i32) -> bool
Return True if the given PID is available in this set.
Sourcepub fn in_range_x(&self, x: f64) -> bool
pub fn in_range_x(&self, x: f64) -> bool
Return True if x lies within the grid x-range.
Sourcepub fn in_range_q(&self, q: f64) -> bool
pub fn in_range_q(&self, q: f64) -> bool
Return True if Q (not Q²) lies within the grid Q-range.
Sourcepub fn in_range_q2(&self, q2: f64) -> bool
pub fn in_range_q2(&self, q2: f64) -> bool
Return True if Q² lies within the grid Q²-range.
Sourcepub fn in_range_xq(&self, x: f64, q: f64) -> bool
pub fn in_range_xq(&self, x: f64, q: f64) -> bool
Return True if both x and Q are within their respective ranges.
Sourcepub fn in_range_xq2(&self, x: f64, q2: f64) -> bool
pub fn in_range_xq2(&self, x: f64, q2: f64) -> bool
Return True if both x and Q² are within their respective ranges.
Sourcepub const fn member_id(&self) -> usize
pub const fn member_id(&self) -> usize
Index of this member within its PDF set (0 = central value).
Sourcepub fn x_max_lhapdf(&self) -> f64
pub fn x_max_lhapdf(&self) -> f64
Maximum x value in the grid (camelCase LHAPDF alias).
Sourcepub fn x_min_lhapdf(&self) -> f64
pub fn x_min_lhapdf(&self) -> f64
Minimum x value in the grid (camelCase LHAPDF alias).
Sourcepub fn q2_max_lhapdf(&self) -> f64
pub fn q2_max_lhapdf(&self) -> f64
Maximum Q² value in the grid (camelCase LHAPDF alias).
Sourcepub fn q2_min_lhapdf(&self) -> f64
pub fn q2_min_lhapdf(&self) -> f64
Minimum Q² value in the grid (camelCase LHAPDF alias).
Sourcepub fn quark_mass(&self, id: i32) -> f64
pub fn quark_mass(&self, id: i32) -> f64
Pole mass of the quark with the given flavor ID.
Returns 0.0 for unknown flavor IDs.
Sourcepub fn quark_threshold(&self, id: i32) -> f64
pub fn quark_threshold(&self, id: i32) -> f64
Flavor threshold for the given quark ID (equal to the quark mass).
Sourcepub fn description(&self) -> String
pub fn description(&self) -> String
Human-readable description of this PDF set.
Sourcepub fn set(&self) -> Option<PyPDFSet>
pub fn set(&self) -> Option<PyPDFSet>
Return the PDFSet this member belongs to.
Only available when the PDF was loaded by name; returns None when
loaded via LHAID or file path.
Sourcepub fn has_key(&self, key: &str) -> bool
pub fn has_key(&self, key: &str) -> bool
Return True if the given LHAPDF-canonical key is present in this PDF’s metadata.
Trait Implementations§
impl DerefToPyAny for PyPDF
impl ExtractPyClassWithClone for PyPDF
Source§impl<'py> IntoPyObject<'py> for PyPDF
impl<'py> IntoPyObject<'py> for PyPDF
Source§type Output = Bound<'py, <PyPDF as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <PyPDF as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClassImpl for PyPDF
impl PyClassImpl for PyPDF
Source§const MODULE: Option<&str> = ::core::option::Option::None
const MODULE: Option<&str> = ::core::option::Option::None
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// Python wrapper for the `neopdf::pdf::PDF` struct.
///
/// This class provides a Python-friendly interface to the core PDF
/// interpolation functionalities of the `neopdf` Rust library.
const RAW_DOC: &'static CStr = /// Python wrapper for the `neopdf::pdf::PDF` struct. /// /// This class provides a Python-friendly interface to the core PDF /// interpolation functionalities of the `neopdf` Rust library.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type Layout = <<PyPDF as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<PyPDF>
type Layout = <<PyPDF as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<PyPDF>
Source§type ThreadChecker = NoopThreadChecker
type ThreadChecker = NoopThreadChecker
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
Source§fn dict_offset() -> Option<PyObjectOffset>
fn dict_offset() -> Option<PyObjectOffset>
Source§fn weaklist_offset() -> Option<PyObjectOffset>
fn weaklist_offset() -> Option<PyObjectOffset>
Source§impl PyClassNewTextSignature for PyPDF
impl PyClassNewTextSignature for PyPDF
const TEXT_SIGNATURE: &'static str = "(pdf_name, member=0)"
Source§impl PyMethods<PyPDF> for PyClassImplCollector<PyPDF>
impl PyMethods<PyPDF> for PyClassImplCollector<PyPDF>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for PyPDF
impl PyTypeInfo for PyPDF
Source§const NAME: &str = <Self as ::pyo3::PyClass>::NAME
const NAME: &str = <Self as ::pyo3::PyClass>::NAME
prefer using ::type_object(py).name() to get the correct runtime value
Source§const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
prefer using ::type_object(py).module() to get the correct runtime value
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
Auto Trait Implementations§
impl !RefUnwindSafe for PyPDF
impl !UnwindSafe for PyPDF
impl Freeze for PyPDF
impl Send for PyPDF
impl Sync for PyPDF
impl Unpin for PyPDF
impl UnsafeUnpin for PyPDF
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
Source§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
Source§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
Use ::classinfo_object() instead and format the type name at runtime. Note that using built-in cast features is often better than manual PyTypeCheck usage.