qilisdk.core.interpolator
Attributes
Classes
str(object='') -> str |
|
Mapping of time points to coefficients with optional interpolation. |
Module Contents
- TimeDict[font]
- class Interpolation[font]
Bases:
str,enum.Enumstr(object=””) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to “utf-8”. errors defaults to “strict”.
Initialize self. See help(type(self)) for accurate signature.
- STEP = 'Step function interpolation between schedule points'[font]
- LINEAR = 'linear interpolation between schedule points'[font]
- class Interpolator(time_dict: TimeDict, interpolation: Interpolation = Interpolation.LINEAR, nsamples: int = 100)[font]
Bases:
qilisdk.core.parameterizable.ParameterizableMapping of time points to coefficients with optional interpolation.
Initialize an interpolator over discrete points or intervals.
- Paràmetres:
time_dict (
TimeDict) – Mapping from time points or intervals to coefficients or callables.interpolation (
Interpolation) – Interpolation rule between provided points (LINEARorSTEP).nsamples (
int) – Number of samples used to expand interval definitions.
- Llença:
ValueError – If the time intervals contain a number of points different than 2.
- iter_time_step = 0[font]
- property tlist: list[PARAMETERIZED_NUMBER][font]
Return the (possibly rescaled) list of time points used for interpolation.
- Retorna:
Interpolation time points, rescaled if
max_timeis set.- Tipus de retorn:
list[PARAMETERIZED_NUMBER]
- property fixed_tlist: list[float][font]
Return the list of time points as plain floats.
- Retorna:
Evaluated time points.
- Tipus de retorn:
list[float]
- property total_time: float[font]
Return the maximum time among all points.
- Retorna:
Largest time value in
fixed_tlist.- Tipus de retorn:
float
- items() list[tuple[PARAMETERIZED_NUMBER, PARAMETERIZED_NUMBER]][font]
Return (time, coefficient) pairs, rescaling time if a max is set.
- Retorna:
Time and coefficient pairs.
- Tipus de retorn:
list[tuple[PARAMETERIZED_NUMBER, PARAMETERIZED_NUMBER]]
- fixed_items() list[tuple[float, float]][font]
Return (time, coefficient) pairs evaluated to floats.
- Retorna:
Evaluated time and coefficient pairs.
- Tipus de retorn:
list[tuple[float, float]]
- property coefficients: list[PARAMETERIZED_NUMBER][font]
Return coefficients in the order of
tlistwithout evaluation.- Retorna:
Coefficients aligned with
tlist.- Tipus de retorn:
list[PARAMETERIZED_NUMBER]
- property coefficients_dict: dict[PARAMETERIZED_NUMBER, PARAMETERIZED_NUMBER][font]
Return a shallow copy of the internal time-to-coefficient mapping.
- Retorna:
Mapping from time to coefficient expressions.
- Tipus de retorn:
dict[PARAMETERIZED_NUMBER, PARAMETERIZED_NUMBER]
- property fixed_coefficients: list[float][font]
Return coefficients evaluated to floats in the order of
fixed_tlist.- Retorna:
Evaluated coefficients.
- Tipus de retorn:
list[float]
- set_max_time(max_time: PARAMETERIZED_NUMBER) None[font]
Rescale all time points to a new maximum duration while keeping relative spacing.
- Paràmetres:
max_time (
PARAMETERIZED_NUMBER) – Desired maximum time after rescaling.- Llença:
ValueError – If the max time is set to zero.
- delete_cache() None[font]
Clear cached evaluations and derived lists.
- add_time_point(time: PARAMETERIZED_NUMBER, coefficient: PARAMETERIZED_NUMBER | collections.abc.Callable[Ellipsis, PARAMETERIZED_NUMBER]) None[font]
Add or update a coefficient associated with a time point, processing callables if needed.
- Paràmetres:
time (
PARAMETERIZED_NUMBER) – Time point for the coefficient.coefficient (
PARAMETERIZED_NUMBER | Callable[...,PARAMETERIZED_NUMBER]) – Coefficient value or callable.
- Llença:
ValueError – If the coefficient type is unsupported or the callable uses invalid variables.
- set_parameter_values(values: list[float], where: collections.abc.Callable[[qilisdk.core.variables.Parameter], bool] | None = None) None[font]
Assign parameter values by position and clear caches.
- Paràmetres:
values (
list[float]) – New values ordered consistently withget_parameter_names().where (
Callable[[Parameter],bool] | None) – Optional predicate selecting parameters to update.
- set_parameters(parameters: dict[str, int | float]) None[font]
Assign parameter values by name and clear caches.
- Paràmetres:
parameters (
dict[str,int | float]) – Mapping from parameter labels to numeric values.
- set_parameter_bounds(ranges: dict[str, tuple[float, float]]) None[font]
Update parameter bounds and clear caches.
- Paràmetres:
ranges (
dict[str,tuple[float,float]]) – Bounds keyed by parameter label.
- get_coefficient(time_step: float) float[font]
Return the numeric coefficient at a given time, applying interpolation and scaling.
- Paràmetres:
time_step (
float) – Time at which to evaluate the coefficient.- Retorna:
Evaluated coefficient.
- Tipus de retorn:
float
- get_coefficient_expression(time_step: float) qilisdk.core.types.Number | qilisdk.core.variables.Term | qilisdk.core.variables.Parameter[font]
Return the raw expression for the coefficient at
time_stepwithout final evaluation.