The #1 adoption lever from the competitive analysis: a sklearn-compatible package (python/lawsynth-sklearn) so the scikit-learn ecosystem adopts LawSynth with near-zero switching cost (why gplearn/PySINDy win mindshare). - LawSynthDynamics: fit(X, t=)/predict/simulate/score/equations over the real Study discovery; full get_params/set_params/__sklearn_tags__/NotFittedError. - LawSynthRegressor (RegressorMixin), LawSynthTransformer (feature library + deterministic decorrelation prune), parsimony='auto' (lambda = Cov/Var). - Inherits sklearn mixins when present; faithful standalone fallback otherwise. Demo recovers an oscillator R2=0.999996; 50 tests pass (7 sklearn-integration skip cleanly when sklearn absent). Deterministic, offline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
694 B
Python
29 lines
694 B
Python
"""Shared fixtures: deterministic synthetic dynamical systems."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import math
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def oscillator():
|
|
"""Harmonic oscillator: x = cos t, v = -sin t (x' = v, v' = -x)."""
|
|
n, dt = 160, 0.05
|
|
t = [i * dt for i in range(n)]
|
|
X = [[math.cos(ti), -math.sin(ti)] for ti in t] # columns [x, v]
|
|
return X, t
|
|
|
|
|
|
@pytest.fixture
|
|
def damped():
|
|
"""A lightly damped linear system with two coupled states."""
|
|
n, dt = 200, 0.03
|
|
t = [i * dt for i in range(n)]
|
|
X = []
|
|
for ti in t:
|
|
env = math.exp(-0.15 * ti)
|
|
X.append([env * math.cos(2.0 * ti), -2.0 * env * math.sin(2.0 * ti)])
|
|
return X, t
|