stormvogel.parametric._backend¶
Backend registry for stormvogel.parametric.
A backend is anything that owns a concrete value type representing a polynomial / rational function, knows how to construct its symbols and constants, and can move values to and from pycarl (the representation stormpy uses internally).
Backends are registered with register(). The first backend to register
also becomes the default; callers can change that with set_default().
Attributes¶
Classes¶
The contract a parametric-value backend must implement. |
Functions¶
|
Register a parametric backend. |
|
Select the backend used by |
|
Return the currently-selected default backend. |
|
Return the union of all |
|
Return the backend that owns |
Module Contents¶
- stormvogel.parametric._backend.Number¶
- class stormvogel.parametric._backend.ParametricBackend¶
Bases:
ProtocolThe contract a parametric-value backend must implement.
A backend is responsible for constructing its values (symbols, constants) and for bridging them to pycarl. All introspection operations (
is_zero,evaluate, …) are registered asfunctools.singledispatch()overloads on the generics instormvogel.parametric; the backend itself does not need to expose them on its instance.- name: str¶
- expr_types: tuple[type, Ellipsis]¶
- symbol(name: str, **kwargs: Any) Any¶
Create a parameter symbol with the given name.
- constant(n: Number) Any¶
Lift a Python number into a backend-native constant.
- to_pycarl(value: Any, var_map: dict[str, Any]) Any¶
Convert
valueto a pycarl factorized rational function.var_mapmaps parameter names to the pycarlVariableobjects created by the stormpy bridge. Callers guarantee that every free symbol invaluehas an entry.
- from_pycarl(pycarl_value: Any) Any¶
Convert a pycarl rational function into a backend-native value.
- stormvogel.parametric._backend._BACKENDS: list[ParametricBackend] = []¶
- stormvogel.parametric._backend._default: ParametricBackend | None = None¶
- stormvogel.parametric._backend.register(backend: ParametricBackend) None¶
Register a parametric backend.
If no default has been set yet, the first backend registered becomes it. Re-registering the same backend (by
name) is a no-op — the existing entry is replaced in-place — so importing a backend module twice is harmless.
- stormvogel.parametric._backend.set_default(name: str) None¶
Select the backend used by
stormvogel.parametric.symbol()/stormvogel.parametric.constant().
- stormvogel.parametric._backend.get_default() ParametricBackend¶
Return the currently-selected default backend.
- Raises:
RuntimeError – If no backend has been registered yet (should not happen in practice: importing
stormvogel.parametricauto-registers the sympy backend).
- stormvogel.parametric._backend.registered_types() tuple[type, Ellipsis]¶
Return the union of all
expr_typesacross registered backends.Used by
stormvogel.parametric.is_parametric()as theisinstance()check.
- stormvogel.parametric._backend.backend_for(value: Any) ParametricBackend¶
Return the backend that owns
value’s concrete type.- Raises:
LookupError – If no registered backend claims the type.