Skip to content

Refactor: break the 3 module couplings blocking a clean forward/inverse split#106

Open
joglekara wants to merge 1 commit into
mainfrom
refactor/break-coupling-prereqs
Open

Refactor: break the 3 module couplings blocking a clean forward/inverse split#106
joglekara wants to merge 1 commit into
mainfrom
refactor/break-coupling-prereqs

Conversation

@joglekara

Copy link
Copy Markdown
Member

What

Behavior-preserving refactor that breaks the three module couplings identified in #105. These are the prerequisites for isolating a clean, light-dependency forward kernel — they're required regardless of whether we ultimately pick Option A (1 repo + install extras) or Option B (2 repos), so they don't block on that decision.

Why

The package had two true dependency cycles and one wrong-direction edge. Separate packages can't have circular deps, so these had to go before any split — and they're worth fixing even within one package:

Coupling Before After
utils/data_handlingutils/process mutually recursive merged into one tsadar/data/ package (cycle is now intra-package)
inverseutils/process postprocess imported inverse.{loss_function,loops}; fitter imported postprocess back postprocess moved into inverse/; now intra-inverse
forwardinverse interactive runner calc_vs_data imported inverse.{fitter,loss_function} calc_vs_data moved to inverse/; forward no longer imports inverse

Changes

  • utils/data_handling + utils/processtsadar/data/. The split was artificial — preprocessing is data handling, and the two were mutually recursive.
  • utils/process/postprocess.pytsadar/inverse/postprocess.py. It's post-fit processing; it belongs with the inverse code that produces the fit.
  • forward/calc_vs_data.pyinverse/calc_vs_data.py. The interactive "fit forward vs. data" runner sits naturally beside the fitter.
  • Import-path updates across tsadar/ and the test suite. No logic changes.

Verification

The local env has a pre-existing, unrelated jax version mismatch (sph_harm_y), so this was validated statically:

  • ✅ AST walk of every module: all intra-tsadar imports resolve to existing files/symbols.
  • py_compile on every tracked tsadar/ + tests/ file passes.
  • ✅ Coupling checks: forward→inverse, data→inverse, data→forward edges are gone; the core kernel still imports nothing from inverse/forward/data/plotting.

A reviewer with a working jax should confirm import tsadar and the test suite still pass.

Not in scope

The A vs B packaging decision (#105) and the pyproject.toml extras / dependency-gating — those follow once the boundaries are settled.

Toward #105.


🤖 Generated with Claude Code

…se split

Prerequisite, behavior-preserving moves toward #105. These break the only
dependency cycles/wrong-direction edges in the package, so the forward kernel
can later be isolated (as extras or a separate repo) without further surgery.

- Merge `utils/data_handling` + `utils/process` into one `tsadar/data/`
  package. They were mutually recursive (data_handling->process and
  process->data_handling); the split was artificial since preprocessing *is*
  data handling. Now the cycle is intra-package.
- Move `postprocess.py` into `tsadar/inverse/`. It is post-*fit* processing
  and imported `inverse.loss_function`/`inverse.loops` while `inverse.fitter`
  imported it back — a true `inverse <-> process` cycle. Now intra-`inverse`.
- Move the interactive runner `calc_vs_data.py` from `forward/` to `inverse/`.
  It imported `inverse.fitter`/`inverse.loss_function`, making `forward` depend
  on `inverse` (wrong direction). `forward` no longer imports `inverse`.

No behavior change: pure file moves + import-path updates (incl. tests).
Verified statically — all intra-tsadar imports resolve, every module compiles,
and forward->inverse / data->inverse / data->forward edges are gone; `core`
kernel remains free of inverse/forward/data/plotting deps.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.

1 participant