phaseprobe 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- phaseprobe/__init__.py +30 -0
- phaseprobe/__main__.py +5 -0
- phaseprobe/adapters/__init__.py +4 -0
- phaseprobe/adapters/loader.py +51 -0
- phaseprobe/adapters/scipy.py +539 -0
- phaseprobe/api.py +64 -0
- phaseprobe/artifacts.py +124 -0
- phaseprobe/cli.py +242 -0
- phaseprobe/config.py +132 -0
- phaseprobe/data/__init__.py +1 -0
- phaseprobe/data/examples/__init__.py +1 -0
- phaseprobe/data/examples/logistic-negative.json +27 -0
- phaseprobe/data/examples/logistic-scan.json +27 -0
- phaseprobe/data/examples/lorenz-negative.json +30 -0
- phaseprobe/data/examples/lorenz-perturb.json +30 -0
- phaseprobe/data/examples/predator-prey-check.json +25 -0
- phaseprobe/data/examples/predator-prey-negative.json +25 -0
- phaseprobe/data/examples/toggle-negative.json +30 -0
- phaseprobe/data/examples/toggle-perturb.json +31 -0
- phaseprobe/engine.py +810 -0
- phaseprobe/errors.py +31 -0
- phaseprobe/examples/__init__.py +1 -0
- phaseprobe/examples/scipy_models.py +151 -0
- phaseprobe/generate.py +72 -0
- phaseprobe/models/__init__.py +36 -0
- phaseprobe/models/_common.py +56 -0
- phaseprobe/models/logistic.py +63 -0
- phaseprobe/models/lorenz.py +64 -0
- phaseprobe/models/predator_prey.py +86 -0
- phaseprobe/models/toggle.py +73 -0
- phaseprobe/replay.py +496 -0
- phaseprobe/reporting.py +173 -0
- phaseprobe/types.py +131 -0
- phaseprobe-0.2.0.dist-info/METADATA +275 -0
- phaseprobe-0.2.0.dist-info/RECORD +38 -0
- phaseprobe-0.2.0.dist-info/WHEEL +4 -0
- phaseprobe-0.2.0.dist-info/entry_points.txt +2 -0
- phaseprobe-0.2.0.dist-info/licenses/LICENSE +201 -0
phaseprobe/types.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"""Typed public model-adapter and result interfaces."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Mapping, Sequence
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import Literal, Protocol, TypeAlias, runtime_checkable
|
|
8
|
+
|
|
9
|
+
Scalar: TypeAlias = float | int | str
|
|
10
|
+
State: TypeAlias = tuple[float, ...]
|
|
11
|
+
Parameters: TypeAlias = Mapping[str, float]
|
|
12
|
+
ModelConfig: TypeAlias = Mapping[str, object]
|
|
13
|
+
Tolerances: TypeAlias = Mapping[str, float]
|
|
14
|
+
ReplayMode: TypeAlias = Literal["exact", "tolerance"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True, slots=True)
|
|
18
|
+
class TracePoint:
|
|
19
|
+
"""One retained point from a bounded simulation trace."""
|
|
20
|
+
|
|
21
|
+
step: int
|
|
22
|
+
time: float
|
|
23
|
+
state: State
|
|
24
|
+
observations: Mapping[str, Scalar]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True, slots=True)
|
|
28
|
+
class InvariantResult:
|
|
29
|
+
"""Result of evaluating a declared model invariant or boundedness rule."""
|
|
30
|
+
|
|
31
|
+
name: str
|
|
32
|
+
passed: bool
|
|
33
|
+
measured: float
|
|
34
|
+
tolerance: float
|
|
35
|
+
detail: str
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True, slots=True)
|
|
39
|
+
class SimulationTrace:
|
|
40
|
+
"""One completed trajectory-level simulation before engine retention.
|
|
41
|
+
|
|
42
|
+
``metadata`` contains JSON-serializable execution evidence supplied by the adapter. It must
|
|
43
|
+
describe solver termination and the numerical environment without embedding callable code.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
points: tuple[TracePoint, ...]
|
|
47
|
+
final_state: State
|
|
48
|
+
success: bool
|
|
49
|
+
status: int
|
|
50
|
+
message: str
|
|
51
|
+
metadata: Mapping[str, object]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@runtime_checkable
|
|
55
|
+
class ModelAdapter(Protocol):
|
|
56
|
+
"""Small interface implemented by built-in and downstream simulation adapters.
|
|
57
|
+
|
|
58
|
+
The explicit state tuple makes perturbation, serialization, and finite-value validation
|
|
59
|
+
deterministic. Classifiers and invariants receive declared tolerances rather than hiding
|
|
60
|
+
thresholds inside the engine.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
name: str
|
|
64
|
+
identity: str
|
|
65
|
+
dimensions: tuple[str, ...]
|
|
66
|
+
|
|
67
|
+
def initial_state(self, config: ModelConfig, seed: int) -> State:
|
|
68
|
+
"""Return a deterministic initial state for ``config`` and ``seed``."""
|
|
69
|
+
|
|
70
|
+
def step(self, state: State, parameters: Parameters, dt: float) -> State:
|
|
71
|
+
"""Advance exactly one declared step."""
|
|
72
|
+
|
|
73
|
+
def observe(self, state: State) -> Mapping[str, Scalar]:
|
|
74
|
+
"""Expose bounded scalar observables used in reports and classification."""
|
|
75
|
+
|
|
76
|
+
def classify(self, trace: Sequence[TracePoint], tolerances: Tolerances) -> str:
|
|
77
|
+
"""Return a qualitative class using only retained trace evidence."""
|
|
78
|
+
|
|
79
|
+
def invariants(
|
|
80
|
+
self,
|
|
81
|
+
trace: Sequence[TracePoint],
|
|
82
|
+
parameters: Parameters,
|
|
83
|
+
tolerances: Tolerances,
|
|
84
|
+
) -> list[InvariantResult]:
|
|
85
|
+
"""Evaluate declared invariants or boundedness conditions."""
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@runtime_checkable
|
|
89
|
+
class TrajectoryAdapter(Protocol):
|
|
90
|
+
"""Optional protocol for solvers that naturally integrate a whole trajectory.
|
|
91
|
+
|
|
92
|
+
The engine dispatches this protocol without manufacturing a fake fixed-step loop. Search,
|
|
93
|
+
perturbation, policy, artifact, replay, and reporting code is shared with ``ModelAdapter``.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
name: str
|
|
97
|
+
identity: str
|
|
98
|
+
dimensions: tuple[str, ...]
|
|
99
|
+
|
|
100
|
+
@property
|
|
101
|
+
def replay_mode(self) -> ReplayMode:
|
|
102
|
+
"""Declare whether numerical replay is exact or tolerance-based."""
|
|
103
|
+
|
|
104
|
+
def initial_state(self, config: ModelConfig, seed: int) -> State:
|
|
105
|
+
"""Return the declared initial state for ``config`` and ``seed``."""
|
|
106
|
+
|
|
107
|
+
def simulate(
|
|
108
|
+
self,
|
|
109
|
+
initial_state: State,
|
|
110
|
+
parameters: Parameters,
|
|
111
|
+
config: ModelConfig,
|
|
112
|
+
seed: int,
|
|
113
|
+
) -> SimulationTrace:
|
|
114
|
+
"""Integrate once and return a finite, serializable trajectory."""
|
|
115
|
+
|
|
116
|
+
def observe(self, trace: SimulationTrace) -> Mapping[str, Scalar]:
|
|
117
|
+
"""Return bounded summary observables for the completed trajectory."""
|
|
118
|
+
|
|
119
|
+
def classify(self, trace: SimulationTrace, tolerances: Tolerances) -> str:
|
|
120
|
+
"""Return a qualitative class from retained trajectory evidence."""
|
|
121
|
+
|
|
122
|
+
def invariants(
|
|
123
|
+
self,
|
|
124
|
+
trace: SimulationTrace,
|
|
125
|
+
parameters: Parameters,
|
|
126
|
+
tolerances: Tolerances,
|
|
127
|
+
) -> list[InvariantResult]:
|
|
128
|
+
"""Evaluate declared invariants or boundedness conditions."""
|
|
129
|
+
|
|
130
|
+
def configuration(self) -> Mapping[str, object]:
|
|
131
|
+
"""Serialize adapter settings and explicit identity, never callable source."""
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: phaseprobe
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Find reproducible qualitative simulation transitions and turn them into regression tests.
|
|
5
|
+
Project-URL: Documentation, https://github.com/aliengineering-byte/phaseprobe#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/aliengineering-byte/phaseprobe/issues
|
|
7
|
+
Project-URL: Source, https://github.com/aliengineering-byte/phaseprobe
|
|
8
|
+
Author: Ali
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: dynamical-systems,regression-testing,reproducibility,simulation,testing
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering
|
|
24
|
+
Classifier: Topic :: Software Development :: Testing
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Provides-Extra: demo
|
|
27
|
+
Requires-Dist: pillow==11.3.0; extra == 'demo'
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: build==1.3.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: mypy==1.17.1; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest-cov==6.2.1; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest==8.4.1; extra == 'dev'
|
|
33
|
+
Requires-Dist: ruff==0.12.7; extra == 'dev'
|
|
34
|
+
Provides-Extra: scipy
|
|
35
|
+
Requires-Dist: numpy<2.5,>=1.23.5; extra == 'scipy'
|
|
36
|
+
Requires-Dist: scipy<1.19,>=1.15; extra == 'scipy'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# PhaseProbe
|
|
40
|
+
|
|
41
|
+
> Find a simulation behavior boundary. Preserve it as a replay. Turn it into a test.
|
|
42
|
+
|
|
43
|
+
Maintaining a simulation is risky when a tiny parameter or initial-condition change can cross a qualitative boundary while ordinary numeric assertions still look plausible. PhaseProbe runs a bounded, deterministic search, records exactly what it tested, and emits an offline report plus an executable pytest regression.
|
|
44
|
+
|
|
45
|
+
```console
|
|
46
|
+
$ python -m pip install .
|
|
47
|
+
$ phaseprobe scan --example logistic
|
|
48
|
+
QUALITATIVE TRANSITION FOUND
|
|
49
|
+
|
|
50
|
+
Model: logistic-map
|
|
51
|
+
Search dimension: r
|
|
52
|
+
Baseline regime: period-2
|
|
53
|
+
Changed regime: period-4
|
|
54
|
+
Replay: .phaseprobe/runs/<run-id>/replay.json
|
|
55
|
+
|
|
56
|
+
$ phaseprobe generate-test .phaseprobe/runs/<run-id>/replay.json
|
|
57
|
+
$ python -m pytest -q tests/generated
|
|
58
|
+
1 passed
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
[](assets/demo.gif)
|
|
62
|
+
|
|
63
|
+
No API key, LLM, GPU, Docker, account, telemetry, network connection, or hosted service is required at runtime. PhaseProbe's base installation has no third-party runtime dependencies; NumPy and SciPy are isolated in the optional `scipy` extra.
|
|
64
|
+
|
|
65
|
+
## Five-minute quick start
|
|
66
|
+
|
|
67
|
+
Requires Python 3.10 or newer on Windows or Linux.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
python -m pip install .
|
|
71
|
+
phaseprobe scan --example logistic
|
|
72
|
+
phaseprobe replay .phaseprobe/runs/<run-id>/replay.json
|
|
73
|
+
phaseprobe generate-test .phaseprobe/runs/<run-id>/replay.json
|
|
74
|
+
python -m pytest -q tests/generated
|
|
75
|
+
phaseprobe report .phaseprobe/runs/<run-id>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Replace `<run-id>` with the directory printed by `scan`. The scan returns `0` when it successfully finds a transition. Add `--fail-on-finding` only when a finding should fail CI.
|
|
79
|
+
|
|
80
|
+
The quick-start evidence is empirical: the built-in classifier finds a finite-time period-2/period-4 bracket for the logistic map, performs bounded binary refinement, repeats both endpoints, saves trace hashes and a versioned fixture, and generates a fixed pytest template. It does not claim an exact bifurcation point.
|
|
81
|
+
|
|
82
|
+
## Use with SciPy
|
|
83
|
+
|
|
84
|
+
SciPy integrates trajectories. PhaseProbe searches declared dimensions, preserves qualitative
|
|
85
|
+
boundaries, and creates regressions. PhaseProbe is an independent project and does not imply
|
|
86
|
+
endorsement by SciPy.
|
|
87
|
+
|
|
88
|
+
Five-minute path:
|
|
89
|
+
|
|
90
|
+
[](assets/scipy-demo.gif)
|
|
91
|
+
|
|
92
|
+
The verified command transcript is [assets/scipy-demo-session.txt](assets/scipy-demo-session.txt),
|
|
93
|
+
with a self-contained [HTML example report](examples/scipy/report.html).
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
python -m pip install "phaseprobe[scipy]"
|
|
97
|
+
phaseprobe perturb --config examples/scipy/lorenz.json
|
|
98
|
+
phaseprobe check --config examples/scipy/predator-prey.json
|
|
99
|
+
phaseprobe replay .phaseprobe/runs/<run-id>/replay.json
|
|
100
|
+
phaseprobe generate-test .phaseprobe/runs/<run-id>/replay.json
|
|
101
|
+
python -m pytest -q tests/generated
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The Lorenz command searches a declared initial-`x` perturbation and reports only finite-time
|
|
105
|
+
divergence evidence. `examples/scipy/lorenz-negative.json` is its short-window negative control.
|
|
106
|
+
The predator–prey command checks the declared first integral with tightly resolved DOP853 settings;
|
|
107
|
+
`examples/scipy/predator-prey-coarse.json` deliberately fails the same policy with loose RK23
|
|
108
|
+
settings.
|
|
109
|
+
|
|
110
|
+
For a direct Python API:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from phaseprobe import run_perturbation
|
|
114
|
+
from phaseprobe.adapters.scipy import SolveIVPAdapter
|
|
115
|
+
|
|
116
|
+
adapter = SolveIVPAdapter(
|
|
117
|
+
name="lorenz-scipy",
|
|
118
|
+
identity="my-lorenz-v1",
|
|
119
|
+
rhs=lorenz_rhs,
|
|
120
|
+
state_names=("x", "y", "z"),
|
|
121
|
+
initial_state=(1.0, 1.0, 1.0),
|
|
122
|
+
t_span=(0.0, 25.0),
|
|
123
|
+
t_eval=1001,
|
|
124
|
+
method="DOP853",
|
|
125
|
+
rtol=1e-9,
|
|
126
|
+
atol=1e-12,
|
|
127
|
+
max_step=0.05,
|
|
128
|
+
classifier=classify_lorenz,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
outcome = run_perturbation(adapter, config)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
JSON CLI configurations name an absolute dotted Python module and factory. Running, replaying, or
|
|
135
|
+
generating from that configuration executes the selected trusted Python code; validation alone
|
|
136
|
+
does not import it. See [the audited contract](docs/SCIPY_SOLVE_IVP_AUDIT.md),
|
|
137
|
+
[architecture](ARCHITECTURE.md), and [security boundary](SECURITY.md).
|
|
138
|
+
|
|
139
|
+
## Commands
|
|
140
|
+
|
|
141
|
+
| command | job | normal success |
|
|
142
|
+
| --- | --- | --- |
|
|
143
|
+
| `scan` | Bounded one-dimensional parameter scan, adjacent class-change detection, and stable bracket refinement | Finding or no finding, exit `0` |
|
|
144
|
+
| `perturb` | Baseline/perturbed twin runs over bounded initial-state changes | Finding or no finding, exit `0` |
|
|
145
|
+
| `check` | Execute a declared configuration policy for CI | Exit `1` only when policy fails |
|
|
146
|
+
| `replay` | Validate fixture integrity and re-execute model, parameters, seed, initial state, tolerances, and retention | Declared `exact` or `tolerance` comparison passes |
|
|
147
|
+
| `generate-test` | Validate and copy a fixture into a non-extensible pytest template | Executable test under `tests/generated/` |
|
|
148
|
+
| `report` | Regenerate terminal, versioned JSON, and self-contained offline HTML evidence | Local report files |
|
|
149
|
+
|
|
150
|
+
Common options:
|
|
151
|
+
|
|
152
|
+
```console
|
|
153
|
+
phaseprobe scan --config examples/configs/logistic-scan.json
|
|
154
|
+
phaseprobe perturb --example lorenz --json
|
|
155
|
+
phaseprobe check --example predator-prey
|
|
156
|
+
phaseprobe scan --example logistic --fail-on-finding
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Exit codes are stable: `0` completed, `1` declared policy or explicit `--fail-on-finding`, `2` invalid input/configuration, `3` numerical failure, and `4` internal PhaseProbe defect.
|
|
160
|
+
|
|
161
|
+
## Included deterministic examples
|
|
162
|
+
|
|
163
|
+
| example | command | positive evidence | negative control | direct technical source |
|
|
164
|
+
| --- | --- | --- | --- | --- |
|
|
165
|
+
| Logistic map | `phaseprobe scan --example logistic` | Finite-time period-2 to period-4 classification bracket | `--example logistic-negative` stays period-2 over its declared range | [May, 1976](https://www.nature.com/articles/261459a0) |
|
|
166
|
+
| Lorenz system | `phaseprobe perturb --example lorenz` | Small initial separation exceeds the declared finite-time trajectory-distance threshold | Short window plus unreachable threshold reports no finding | [Lorenz, 1963](https://journals.ametsoc.org/view/journals/atsc/20/2/1520-0469_1963_020_0130_dnf_2_0_co_2.xml) |
|
|
167
|
+
| Predator–prey | `phaseprobe check --example predator-prey` | Refined RK4 step preserves the analytic first integral within tolerance | Coarse step fails the invariant-drift policy | [Lotka, 1920](https://doi.org/10.1073/pnas.6.7.410) |
|
|
168
|
+
| Genetic toggle | `phaseprobe perturb --example toggle` | Bounded initial-state perturbation reaches the opposite dominant state | Smaller declared range stays in the baseline basin | [Gardner, Cantor & Collins, 2000](https://www.nature.com/articles/35002131) |
|
|
169
|
+
|
|
170
|
+
Each configuration records the seed, fixed integration/iteration settings, tolerances, burn-in, observation window, classification rule, refinement rule, invalid-state policy, and trace cap. See [examples/README.md](examples/README.md) for equations and interpretation.
|
|
171
|
+
|
|
172
|
+
### Measured reference run
|
|
173
|
+
|
|
174
|
+
On 2026-08-01 with CPython 3.12.13 on Windows, the instrumented logistic quick-start scan completed in 10.114 seconds with a 34.81 MiB peak process-tree working set. All eight positive/negative example commands completed in 12.238 seconds. The final 38-test suite with branch coverage completed in 64.86 seconds at 87.92% coverage. These are observations from one local run, not cross-machine performance claims; the generated transcript is in [assets/demo-session.txt](assets/demo-session.txt).
|
|
175
|
+
|
|
176
|
+
## Evidence artifacts
|
|
177
|
+
|
|
178
|
+
Every execution is bounded under `.phaseprobe/runs/<run-id>/`:
|
|
179
|
+
|
|
180
|
+
```text
|
|
181
|
+
run.json complete versioned evidence
|
|
182
|
+
findings.json compact finding or negative result
|
|
183
|
+
replay.json schema-versioned integrity-protected fixture
|
|
184
|
+
trace.jsonl capped baseline/changed retained points
|
|
185
|
+
report.html self-contained offline report
|
|
186
|
+
manifest.json sizes and SHA-256 hashes
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Model names used for generated test paths are sanitized. The generated source comes from a fixed template; configuration strings never become executable Python.
|
|
190
|
+
|
|
191
|
+
## What PhaseProbe adds—and what it does not
|
|
192
|
+
|
|
193
|
+
| existing category | established strength | PhaseProbe’s narrower job |
|
|
194
|
+
| --- | --- | --- |
|
|
195
|
+
| Solvers such as SciPy | Integrate differential equations with mature numerical methods | Consume an adapter’s trajectories and preserve a discovered qualitative boundary as test evidence |
|
|
196
|
+
| Property-based testing such as Hypothesis | Generate and shrink broad input domains | Search declared simulation dimensions with model-specific observables and classes |
|
|
197
|
+
| Bifurcation/attractor tools such as AUTO, PyDSTool, and Attractors.jl | Deep continuation, bifurcation, attractor, and basin analysis | Lightweight black-box numerical brackets plus replay and pytest materialization |
|
|
198
|
+
| Sensitivity tools such as SALib | Quantify input contributions to output variation | Find a reproducible qualitative predicate change |
|
|
199
|
+
| Simulation environments such as Mesa, NetLogo, cadCAD, and Golly | Build, run, and explore models | Test adapters without becoming another simulation environment |
|
|
200
|
+
|
|
201
|
+
The evidence-backed audit is in [PRIOR_ART.md](PRIOR_ART.md).
|
|
202
|
+
|
|
203
|
+
## Adapter interfaces
|
|
204
|
+
|
|
205
|
+
Adapters implement a small typed protocol:
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
class ModelAdapter(Protocol):
|
|
209
|
+
name: str
|
|
210
|
+
identity: str
|
|
211
|
+
dimensions: tuple[str, ...]
|
|
212
|
+
|
|
213
|
+
def initial_state(self, config, seed): ...
|
|
214
|
+
def step(self, state, parameters, dt): ...
|
|
215
|
+
def observe(self, state): ...
|
|
216
|
+
def classify(self, trace, tolerances): ...
|
|
217
|
+
def invariants(self, trace, parameters, tolerances): ...
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The explicit serializable state tuple makes bounded perturbation, invalid-value detection, trace hashing, and replay straightforward. See [ARCHITECTURE.md](ARCHITECTURE.md) for extension guidance.
|
|
221
|
+
|
|
222
|
+
Whole-trajectory solvers use the optional protocol instead of a fake step loop:
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
class TrajectoryAdapter(Protocol):
|
|
226
|
+
name: str
|
|
227
|
+
identity: str
|
|
228
|
+
dimensions: tuple[str, ...]
|
|
229
|
+
replay_mode: Literal["exact", "tolerance"]
|
|
230
|
+
|
|
231
|
+
def initial_state(self, config, seed): ...
|
|
232
|
+
def simulate(self, initial_state, parameters, config, seed): ...
|
|
233
|
+
def observe(self, trace): ...
|
|
234
|
+
def classify(self, trace, tolerances): ...
|
|
235
|
+
def invariants(self, trace, parameters, tolerances): ...
|
|
236
|
+
def configuration(self): ...
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
`SolveIVPAdapter` records the explicit identity plus a digest of serializable numerical settings.
|
|
240
|
+
It never serializes or claims to securely hash arbitrary callable source.
|
|
241
|
+
|
|
242
|
+
## Scientific scope
|
|
243
|
+
|
|
244
|
+
PhaseProbe uses these terms deliberately:
|
|
245
|
+
|
|
246
|
+
- finite-time trajectory divergence: measured separation over the recorded window;
|
|
247
|
+
- sensitive-dependence evidence: repeatable finite-time divergence under a declared small perturbation, not by itself a proof of chaos;
|
|
248
|
+
- numerical instability: behavior attributable to the numerical method or step size;
|
|
249
|
+
- invariant violation: a declared conservation or boundedness rule failed;
|
|
250
|
+
- qualitative regime change: the adapter’s declared classifier changed;
|
|
251
|
+
- bifurcation evidence: a numerical class-change bracket, not an exact bifurcation point;
|
|
252
|
+
- invalid integration: NaN, infinity, overflow, state-shape mismatch, or hard bound breach;
|
|
253
|
+
- solver failure: the step method could not advance a valid state.
|
|
254
|
+
|
|
255
|
+
The Lorenz examples report `finite-time divergence rate`; they do not compute or claim a Lyapunov exponent. Adaptive SciPy replay is tolerance-based, never exact deterministic replay. “Smallest” always means smallest found within the declared bounded search. Read [SCIENTIFIC_METHODS.md](SCIENTIFIC_METHODS.md) and [LIMITATIONS.md](LIMITATIONS.md).
|
|
256
|
+
|
|
257
|
+
## Development
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
python -m pip install -e ".[dev]"
|
|
261
|
+
python -m pip install -e ".[dev,scipy]" # include optional adapter tests
|
|
262
|
+
python -m ruff format --check .
|
|
263
|
+
python -m ruff check .
|
|
264
|
+
python -m mypy src tests
|
|
265
|
+
python -m pytest --cov=phaseprobe
|
|
266
|
+
python -m build
|
|
267
|
+
python scripts/check_links.py
|
|
268
|
+
python scripts/hygiene.py
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) and the concrete good-first-issue templates in `.github/ISSUE_TEMPLATE/`.
|
|
272
|
+
|
|
273
|
+
## License and citation
|
|
274
|
+
|
|
275
|
+
Apache-2.0. Copyright 2026 Ali. Citation metadata is in [CITATION.cff](CITATION.cff).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
phaseprobe/__init__.py,sha256=ht4xnN86rh39Vx-lkwMZfQRtKHpLKb6ZN8rxQFFj8k0,598
|
|
2
|
+
phaseprobe/__main__.py,sha256=iABGk3Kw-W4fzqm2qkUHKEtRff9MvLvHYlO-yEDxt4M,97
|
|
3
|
+
phaseprobe/api.py,sha256=koepGJ4dkAVqDKIh2vEPLHxZQWojqwv_0SfFsfzqUJ8,1912
|
|
4
|
+
phaseprobe/artifacts.py,sha256=M98epi8FY16ZjiV45iUuW8naJUCRw6ZCrUsP5Y-u_dY,4237
|
|
5
|
+
phaseprobe/cli.py,sha256=MEXf9xqX5SPxGWmYjxtjAmUN6t6y0FHRmIU3-5C6bTI,9611
|
|
6
|
+
phaseprobe/config.py,sha256=S6-VtZLRoKWHl_0Sx6SJBqgrUlMQ43FMRhR54mZNrcs,4868
|
|
7
|
+
phaseprobe/engine.py,sha256=EkGWfyto9CNmLtR8UGitpTZrQ9FUGA53RPVxT62hmoo,31728
|
|
8
|
+
phaseprobe/errors.py,sha256=h7cCdFl5usWF6gOVRhnur9INjNuI3q6Fx_xNyzihRKc,737
|
|
9
|
+
phaseprobe/generate.py,sha256=nEfcyhWLOEb9LR42paF_aro_fdzfqV4zgEe5-P82ZIc,2590
|
|
10
|
+
phaseprobe/replay.py,sha256=BNEJVkVY_s0NV03SX35Z2ReMPX5YrnguyFU8GDe1eBE,21825
|
|
11
|
+
phaseprobe/reporting.py,sha256=90zuEP6Ysu-87YDTJ8fT-EAcTkxP903E6IHHSgDF3KY,8433
|
|
12
|
+
phaseprobe/types.py,sha256=AS1qGvkOMkHwSrYezRyx3Y8om0e15DAjIkN-SE0bI6g,4277
|
|
13
|
+
phaseprobe/adapters/__init__.py,sha256=SO1QpFcYe93UYkPj1Pafyvl0peZZHa7FNnI9NrZSc9E,138
|
|
14
|
+
phaseprobe/adapters/loader.py,sha256=0UGUu5Tz1pSc2_rsRIeY5f7Hlcs2q0YfXN4VHi1b4g0,2031
|
|
15
|
+
phaseprobe/adapters/scipy.py,sha256=11T2CIJ__u7dUJwEE-Nky6E2SGXiwl9FD0LAcRPtJHo,23821
|
|
16
|
+
phaseprobe/data/__init__.py,sha256=-kMzR8oeUFEPCZHZL4BR9bbr4kl25coIuqzZfrnIeb0,32
|
|
17
|
+
phaseprobe/data/examples/__init__.py,sha256=mkH3uRDdFbO2MSfHDoWHEB3XOn7AlULVBsNEJCf88Hs,53
|
|
18
|
+
phaseprobe/data/examples/logistic-negative.json,sha256=mlNPFsuP1n_WDdp9mfyIBw6NGK38uKg82BwMcbBb4e4,720
|
|
19
|
+
phaseprobe/data/examples/logistic-scan.json,sha256=e6dOcMg29UtDxS5J9vW4esr-n9pE3MlsCjexmRLP6UM,986
|
|
20
|
+
phaseprobe/data/examples/lorenz-negative.json,sha256=Zi7b2OciwMVT_vj1USLyffJKfjKzO-qVbYaml3th0yU,863
|
|
21
|
+
phaseprobe/data/examples/lorenz-perturb.json,sha256=NAckKUDGeGcIiFi1LIgUh6FILhkxvlVQJoZG9oL3GBg,1071
|
|
22
|
+
phaseprobe/data/examples/predator-prey-check.json,sha256=9rdNQrE3OEt3pdz5LOGSds2ZhOwi7xQMv7ZeaXWWwdE,928
|
|
23
|
+
phaseprobe/data/examples/predator-prey-negative.json,sha256=hVenZ329MUD1YVIlUApppFiQ6-lJ2db3AmZPoBQyyUc,860
|
|
24
|
+
phaseprobe/data/examples/toggle-negative.json,sha256=Y89l0CD-IcefKdddOWQSf_tAaMV4kOjXlfOHtsLlxwo,925
|
|
25
|
+
phaseprobe/data/examples/toggle-perturb.json,sha256=0khzSmrtGi0DEnhlSDvXxidk54_jGazryr-eeye5ub8,1084
|
|
26
|
+
phaseprobe/examples/__init__.py,sha256=phhqLGfpAdKxwsbqHWNH1FfuFOftNXPZTJqOo2-fLVI,85
|
|
27
|
+
phaseprobe/examples/scipy_models.py,sha256=9-jrHoAaN5i_ZfbdAQiTGRUq-8I531jluHYBln1FaKk,4940
|
|
28
|
+
phaseprobe/models/__init__.py,sha256=JqjmuvMNlexE2IVIfwwA5vDHzvjhKh6hehtjjhp_PKo,1179
|
|
29
|
+
phaseprobe/models/_common.py,sha256=pP8pjIaY5bNrjI3dOLAyxzKuNCfxV66QIn6b2u2p4Pk,1988
|
|
30
|
+
phaseprobe/models/logistic.py,sha256=gYvfbYZbkvySNRJmqee4HcyJRbvS7PULks1bnEuraJQ,2238
|
|
31
|
+
phaseprobe/models/lorenz.py,sha256=kKxcRblLbOyvcx2ShVS89vCfDgon7zitYmrFMUh96LA,2430
|
|
32
|
+
phaseprobe/models/predator_prey.py,sha256=a15Ywws-mgWB3P1siyqIOTTx7_zJUkG9XXXJObihF4c,3381
|
|
33
|
+
phaseprobe/models/toggle.py,sha256=G5IKqsVY3AaXM5M8dfqiZ_k0pWmfRa3x02zTK547tE8,2575
|
|
34
|
+
phaseprobe-0.2.0.dist-info/METADATA,sha256=tD9J4W5dCIU_i6wRdGxjeUY0V8ZDEz0tDKTKmP0dUB0,13693
|
|
35
|
+
phaseprobe-0.2.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
36
|
+
phaseprobe-0.2.0.dist-info/entry_points.txt,sha256=wkMn2BCLr1xJ_7XVaW7WoR-4Lrut3SyvPDJMO1RW4vM,51
|
|
37
|
+
phaseprobe-0.2.0.dist-info/licenses/LICENSE,sha256=Xe3YpndiWAZpJ6ZLQFDDVXqct2xHvycju1NpDr1ndZg,11333
|
|
38
|
+
phaseprobe-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Ali
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|