fix: reloaded fit curve matches the original#28
Open
ahmadomira wants to merge 1 commit into
Open
Conversation
The smooth Median Fit line is fully determined by the fitted parameters, the assay conditions, the assay type, and the data x-range, yet the display trusted the resolution serialized in x_fit/y_fit. Exports made before the dense-curve change (and the linear/failed-fit paths) stored the curve only at the measured concentrations, so a reloaded fit was drawn as coarse straight segments that no longer matched the original. Re-derive the dense curve from the stored parameters at render time via resolve_fit_curve(), falling back to the serialized arrays when the curve cannot be rebuilt. Reload now renders the identical line regardless of the serialized resolution. Closes #25
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+102
to
+105
| stored = (result.x_fit, result.y_fit) | ||
| if not result.parameters: | ||
| return stored | ||
| try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A reloaded Median Fit curve did not match the line drawn during the original fit.
Root cause: the smooth fit line is fully determined by the fitted parameters, the assay conditions, the assay type, and the data x-range — but the display layer trusted the resolution serialized in
FitResult.x_fit/y_fit. Exports made before the dense-curve change (commitd532d9d), and the linear / failed-fit paths, stored the curve only at the measured concentrations. On reload the line was therefore drawn as coarse straight segments that no longer matched the dense curve a fresh fit renders.Fix: re-derive the dense curve from the stored parameters + conditions at render time via a new
resolve_fit_curve(), instead of trusting the serialized arrays. Serialization stays faithful (to_dict/from_dictunchanged), so the fix lives in the display path:core/pipeline/fit_pipeline.py—resolve_fit_curve()rebuilds a minimal assay from the result'sassay_type+ conditions and re-evaluates_dense_fit_curve(); falls back to the stored arrays when the curve can't be rebuilt (unknown/linear assay, no parameters, invalid conditions).core/data_processing/plotting.py—prepare_plot_data()uses it (covers the common reload paths).gui/fitting_session.py— the source-file-missing import branch uses it too.A reloaded fit now renders the identical line regardless of the serialized resolution; fresh fits are unchanged (the regenerated curve is bit-identical to the stored one).
Tests
New
tests/unit/test_fit_curve_reload.py:uv run pytest -k "reload or plot or pipeline"passes (65); full unit layer green (373 passed, 3 skipped); ruff check + format clean.Closes #25