merlin.utils.deprecations module
- merlin.utils.deprecations.sanitize_parameters(*args, **_kw)
Decorate methods to centralize parameter sanitization.
- Parameters:
args (Any) – Either the decorated callable itself, for bare decorator usage, or a sequence of sanitizer callables for factory usage.
_kw (Any) – Unused keyword arguments accepted for signature flexibility.
- Returns:
Decorated callable or decorator factory result, depending on how the function is invoked.
- Return type:
Any
Notes
Supported usage patterns are:
@sanitize_parameters@sanitize_parameters(proc1, proc2, ...)
The decorator emits standardized warnings or errors based on the global deprecation registry, applies registered converter functions for present deprecated parameters, and then applies any additional processors sequentially.
- merlin.utils.deprecations.error_deprecated_enum_access(owner, name)
Fail on deprecated enum-style attribute access.
- Parameters:
- Return type:
None
- Raises:
AttributeError – If
owneris"MeasurementStrategy"andnameis one of the deprecated enum-style attributes listed in_MEASUREMENT_STRATEGY_ENUM_MIGRATIONS.
- merlin.utils.deprecations.raise_no_bunching_removed()
Raise when the removed
no_bunchingflag is used.- Returns:
This function never returns normally.
- Return type:
None
- Raises:
ValueError – Always raised with the 0.4 migration guidance.
- merlin.utils.deprecations.normalize_measurement_strategy(measurement_strategy)
Normalize measurement strategy and computation space with deprecation errors.
- Parameters:
measurement_strategy (
MeasurementStrategyLike| str | None) – Measurement strategy provided by the caller. Supports the modern strategy object, legacy enum aliases, legacy strings, orNone.- Returns:
Normalized measurement strategy and resolved computation space.
- Return type:
tuple[
MeasurementStrategyLike, ComputationSpace]- Raises:
TypeError – If the provided strategy is a string: which is an invalid measurement strategy.
ValueError – If a modern
MeasurementStrategydoes not define a computation space.
Notes
The normalization follows these rules:
If MeasurementStrategy instance (new API) + constructor computation_space provided → ERROR: user must move computation_space into the factory method
If MeasurementStrategy instance only → use its computation_space
If MeasurementStrategy.NONE -> use amplitudes with the default computation space