Struct PyPDF

Source
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

Source

pub fn new(pdf_name: &str, member: usize) -> Self

Creates a new PDF instance for a given PDF set and member.

This is the primary constructor for the PDF class.

§Parameters

pdf_name : str The name of the PDF set. member : int The ID of the PDF member to load. Defaults to 0.

§Returns

PDF A new PDF instance.

Source

pub fn mkpdf(pdf_name: &str, member: usize) -> Self

Loads a given member of the PDF set.

This is an alternative constructor for convenience, equivalent to PDF(pdf_name, member).

§Parameters

pdf_name : str The name of the PDF set. member : int The ID of the PDF member. Defaults to 0.

§Returns

PDF A new PDF instance.

Source

pub fn mkpdfs(pdf_name: &str) -> Vec<Self>

Loads all members of the PDF set.

This function loads all available members for a given PDF set, returning a list of PDF instances.

§Parameters

pdf_name : str The name of the PDF set.

§Returns

listPDF A list of PDF instances, one for each member.

Source

pub fn pids(&self) -> Vec<i32>

Returns the list of PID values.

§Returns

list[int] The PID values.

Source

pub fn subgrids(&self) -> Vec<PySubGrid>

Returns the list of Subgrid objects.

§Returns

list[PySubgrid] The subgrids.

Source

pub fn subgrid_knots(&self, param: &str, 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.

Source

pub fn x_min(&self) -> f64

Retrieves the minimum x-value for this PDF set.

§Returns

float The minimum x-value.

Source

pub fn x_max(&self) -> f64

Retrieves the maximum x-value for this PDF set.

§Returns

float The maximum x-value.

Source

pub fn q2_min(&self) -> f64

Retrieves the minimum Q2-value for this PDF set.

§Returns

float The minimum Q2-value.

Source

pub fn q2_max(&self) -> f64

Retrieves the maximum Q2-value for this PDF set.

§Returns

float The maximum Q2-value.

Source

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.

Source

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.

Source

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.

Source

pub fn alphas_q2(&self, q2: f64) -> f64

Computes the alpha_s value at a given Q2.

§Parameters

q2 : float The energy scale squared.

§Returns

float The interpolated alpha_s value.

Source

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.

Trait Implementations§

Source§

impl<'py> IntoPyObject<'py> for PyPDF

Source§

type Target = PyPDF

The Python output type
Source§

type Output = Bound<'py, <PyPDF as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PyClass for PyPDF

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for PyPDF

Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<PyPDF>

This handles following two situations: Read more
Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

Source§

fn dict_offset() -> Option<isize>

Source§

fn weaklist_offset() -> Option<isize>

Source§

impl PyClassNewTextSignature<PyPDF> for PyClassImplCollector<PyPDF>

Source§

fn new_text_signature(self) -> Option<&'static str>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a PyPDF

Source§

type Holder = Option<PyRef<'py, PyPDF>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut PyPDF

Source§

type Holder = Option<PyRefMut<'py, PyPDF>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl PyMethods<PyPDF> for PyClassImplCollector<PyPDF>

Source§

fn py_methods(self) -> &'static PyClassItems

Source§

impl PyTypeInfo for PyPDF

Source§

const NAME: &'static str = "PDF"

Class name.
Source§

const MODULE: Option<&'static str> = ::core::option::Option::None

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
Source§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
Source§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
Source§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

impl DerefToPyAny for PyPDF

Auto Trait Implementations§

§

impl Freeze for PyPDF

§

impl !RefUnwindSafe for PyPDF

§

impl Send for PyPDF

§

impl Sync for PyPDF

§

impl Unpin for PyPDF

§

impl !UnwindSafe for PyPDF

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

Source§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
Source§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
Source§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

Source§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
Source§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

Source§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
Source§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Ungil for T
where T: Send,