Skip to content

refactor: split modpods into package, remove dead weight, cut deps - #24

Merged
dantzert merged 3 commits into
mainfrom
18-make-modpods-as-small-as-possible
Jul 25, 2026
Merged

refactor: split modpods into package, remove dead weight, cut deps#24
dantzert merged 3 commits into
mainfrom
18-make-modpods-as-small-as-possible

Conversation

@dantzert

Copy link
Copy Markdown
Owner
  • Split 3,369-line modpods.py monolith into 8-file package:

    • transforms.py: TransformCache, transform_inputs, Bayesian helpers
    • model.py: SINDY_delays_MI
    • train.py: delay_io_train, _run_scipy_optimizer
    • predict.py: delay_io_predict
    • lti.py: lti_from_gamma, lti_system_gen
    • topology.py: find_topology_no_geo, infer_causative_topology
    • metrics.py: compute_basic_metrics (deduplicated from model.py/predict.py)
    • init.py: explicit public API re-exports
  • Delete dead weight:

    • modpods_backup.py (2,685 lines, never imported)
    • 16 loose PNG/SVG/TMP test artifacts
    • ~150 lines of commented-out code blocks
    • deprecated find_topology() wrapper
  • Cut dependencies:

    • Removed cvxpy (pysindy constrained SR3 works without it)
    • Removed statsmodels, dill, pystorms, pyswmm (zero imports)
    • Core install shrinks from 12 to 7 direct deps
  • Extract duplicated metric computation (MAE, RMSE, NSE, alpha, beta) into compute_basic_metrics() in modpods/metrics.py

  • Speed up tests:

    • Reduced max_iter in optimization fixtures from 20 to 10
    • Reduced max_iter in lti_system_gen test from 10 to 5
    • Reduced max_iter in forcing_coef_constraints test from 10 to 5
    • Replace transform_inputs_correctness FFT convolution with known-good literal array (n=20 instead of n=100)
  • Lint/typecheck clean: ruff passes, mypy passes

  • Public API unchanged: import modpods; dir(modpods) identical

  • 23/23 non-slow tests pass; full suite passes including slow

- Split 3,369-line modpods.py monolith into 8-file package:
  - transforms.py: TransformCache, transform_inputs, Bayesian helpers
  - model.py: SINDY_delays_MI
  - train.py: delay_io_train, _run_scipy_optimizer
  - predict.py: delay_io_predict
  - lti.py: lti_from_gamma, lti_system_gen
  - topology.py: find_topology_no_geo, infer_causative_topology
  - metrics.py: compute_basic_metrics (deduplicated from model.py/predict.py)
  - __init__.py: explicit public API re-exports

- Delete dead weight:
  - modpods_backup.py (2,685 lines, never imported)
  - 16 loose PNG/SVG/TMP test artifacts
  - ~150 lines of commented-out code blocks
  - deprecated find_topology() wrapper

- Cut dependencies:
  - Removed cvxpy (pysindy constrained SR3 works without it)
  - Removed statsmodels, dill, pystorms, pyswmm (zero imports)
  - Core install shrinks from 12 to 7 direct deps

- Extract duplicated metric computation (MAE, RMSE, NSE, alpha, beta)
  into compute_basic_metrics() in modpods/metrics.py

- Speed up tests:
  - Reduced max_iter in optimization fixtures from 20 to 10
  - Reduced max_iter in lti_system_gen test from 10 to 5
  - Reduced max_iter in forcing_coef_constraints test from 10 to 5
  - Replace transform_inputs_correctness FFT convolution with
    known-good literal array (n=20 instead of n=100)

- Lint/typecheck clean: ruff passes, mypy passes

- Public API unchanged: import modpods; dir(modpods) identical
- 23/23 non-slow tests pass; full suite passes including slow
@dantzert dantzert linked an issue Jul 25, 2026 that may be closed by this pull request
dantzert added 2 commits July 25, 2026 10:38
pysindy.optimizers._constrained_sr3 imports cvxpy as cp at module
load time, so removing cvxpy from pyproject.toml/requirements.txt
causes import failures in CI even though modpods.py never directly
imports cvxpy. Add it back.
@dantzert
dantzert merged commit d182828 into main Jul 25, 2026
2 checks passed
@dantzert
dantzert deleted the 18-make-modpods-as-small-as-possible branch July 25, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make modpods as small as possible

1 participant