new_simulator
¶
Scaffold a new simulator backend (stub, export, and test).
SimulatorNames
dataclass
¶
Derived names for a scaffolded simulator.
Source code in shadowsim/cli/new_simulator.py
ScaffoldError
¶
pascal_to_snake
¶
normalize_base_name
¶
Validate PascalCase input and strip a trailing Simulator suffix.
Source code in shadowsim/cli/new_simulator.py
normalize_kind
¶
Validate a simulator kind.
classical records observables and takes no circuit backend, the same
shape as QuTiP. circuit keeps a backend-shaped stub.
Source code in shadowsim/cli/new_simulator.py
normalize_lindblads
¶
Return whether a classical simulator accepts Lindblad operators.
Source code in shadowsim/cli/new_simulator.py
derive_names
¶
derive_names(raw: str) -> SimulatorNames
Derive class, module, and id names from a user-provided PascalCase name.
Source code in shadowsim/cli/new_simulator.py
default_repo_root
¶
Resolve the repository root from the working directory or package location.
Source code in shadowsim/cli/new_simulator.py
stub_path
¶
stub_path(repo_root: Path, names: SimulatorNames) -> Path
test_path
¶
test_path(repo_root: Path, names: SimulatorNames) -> Path
init_path
¶
check_collisions
¶
check_collisions(
repo_root: Path, names: SimulatorNames
) -> None
Raise if stub, test, or export already exist for this name.
Source code in shadowsim/cli/new_simulator.py
render_stub
¶
render_stub(
names: SimulatorNames,
*,
kind: str = "circuit",
closed_system: bool = False,
) -> str
Return the source for a new simulator stub module.
Source code in shadowsim/cli/new_simulator.py
render_test
¶
render_test(
names: SimulatorNames,
*,
kind: str = "circuit",
closed_system: bool = False,
) -> str
Return the source for a minimal simulator test scaffold.
Source code in shadowsim/cli/new_simulator.py
patch_init_file
¶
patch_init_file(path: Path, names: SimulatorNames) -> None
Register the new simulator in _EXPORTS with no optional extra.
Source code in shadowsim/cli/new_simulator.py
create_simulator
¶
create_simulator(
raw_name: str,
*,
repo_root: Path | None = None,
kind: str = "circuit",
closed_system: bool = False,
) -> SimulatorNames
Validate, check collisions, and write stub + export + test scaffold.
kind="classical" writes a QuTiP-shaped constructor that takes
observables. closed_system is set on that class from the Lindblad
answer. A circuit scaffold leaves both at the backend-shaped default.
Source code in shadowsim/cli/new_simulator.py
build_parser
¶
Build the CLI argument parser.
Source code in shadowsim/cli/new_simulator.py
main
¶
Run the new-simulator scaffolding CLI.