Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Empty outputs layer removed from flow's partial order.
- Flow well-formedness check does not trigger false negative for flows on open graphs without outputs.

- #569: Keyword arguments for `simulate_pattern` are now type-checked.

### Changed

- #452: Use `uv` for dependency management
Expand Down
22 changes: 19 additions & 3 deletions docs/source/simulator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,27 @@ Pattern Simulation

.. currentmodule:: graphix.simulator

.. autoclass:: PatternSimulator
.. autoclass:: PrepareMethod
:members:

.. autoclass:: DefaultPrepareMethod
:members:

.. autoclass:: MeasureMethod
:members:

.. autoclass:: DefaultMeasureMethod
:members:

.. autoclass:: SimulatorKwargs
:members:

.. automethod:: __init__
.. autoclass:: SimulatorOptions
:members:

.. autoclass:: PatternSimulator
:members:

.. automethod:: run

Simulator backends
++++++++++++++++++
Expand Down
17 changes: 9 additions & 8 deletions graphix/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

if TYPE_CHECKING:
from collections.abc import Callable, Collection, Container, Iterator
from typing import Any, TypeVar
from typing import TypeVar

from numpy.random import Generator

Expand All @@ -51,7 +51,7 @@
from graphix.sim import Backend, Data, DensityMatrixBackend, StatevectorBackend
from graphix.sim.base_backend import _StateT_co
from graphix.sim.tensornet import TensorNetworkBackend
from graphix.simulator import _BackendLiteral
from graphix.simulator import SimulatorKwargs, _BackendLiteral
from graphix.space_minimization import SpaceMinimizationHeuristic
from graphix.states import State
from graphix.visualization import DrawKwargs
Expand Down Expand Up @@ -1408,7 +1408,7 @@ def simulate_pattern(
| Iterable[Iterable[ExpressionOrSupportsComplex]]
| None = ...,
rng: Generator | None = ...,
**kwargs: Any,
**kwargs: Unpack[SimulatorKwargs],
) -> Statevec: ...

@overload
Expand All @@ -1422,7 +1422,7 @@ def simulate_pattern(
| Iterable[Iterable[ExpressionOrSupportsComplex]]
| None = ...,
rng: Generator | None = ...,
**kwargs: Any,
**kwargs: Unpack[SimulatorKwargs],
) -> DensityMatrix: ...

@overload
Expand All @@ -1435,7 +1435,7 @@ def simulate_pattern(
| Iterable[Iterable[ExpressionOrSupportsComplex]]
| None = ...,
rng: Generator | None = ...,
**kwargs: Any,
**kwargs: Unpack[SimulatorKwargs],
) -> MBQCTensorNet: ...

@overload
Expand All @@ -1444,7 +1444,7 @@ def simulate_pattern(
backend: Backend[_StateT_co],
input_state: Data | None = ...,
rng: Generator | None = ...,
**kwargs: Any,
**kwargs: Unpack[SimulatorKwargs],
) -> _StateT_co: ...

def simulate_pattern(
Expand All @@ -1454,7 +1454,7 @@ def simulate_pattern(
rng: Generator | None = None,
*,
stacklevel: int = 1,
**kwargs: Any,
**kwargs: Unpack[SimulatorKwargs],
) -> _StateT_co | _BuiltinBackendState:
"""Simulate the execution of the pattern by using :class:`graphix.simulator.PatternSimulator`.

Expand All @@ -1474,7 +1474,8 @@ def simulate_pattern(
stacklevel : int, optional
Stack level to use for warnings. Defaults to 1, meaning that warnings
are reported at this function's call site.
kwargs: keyword args for specified backend.
kwargs: Unpack[SimulatorKwargs]
Options controlling simulator. See :class:`SimulatorOptions`.

Returns
-------
Expand Down
Loading
Loading