Skip to content

fix: from_dict dropped dict entries with falsy values (0.0 parameters vanish on load)#1384

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/aggregator-lens-profiling
Jul 17, 2026
Merged

fix: from_dict dropped dict entries with falsy values (0.0 parameters vanish on load)#1384
Jammy2211 merged 1 commit into
mainfrom
feature/aggregator-lens-profiling

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

from_dict's dict branch (autofit/mapper/model_object.py) filtered entries with if value, silently dropping any dictionary entry whose deserialized value is falsy — including parameters whose value is exactly 0.0. Exposed by the PYAUTO_TEST_MODE_SAMPLES bypass (#1381), which writes exact prior-median sample values: lens-model centres and ell_comps have zero medians, so a bypass-written samples_summary.json loaded back with 8 of 15 parameters missing and TracerAgg/FitImagingAgg reconstruction crashed with KeyError on the missing paths. Any stored dict with a legitimately-zero value (sample kwargs, info dicts) was affected — this predates #1381, which merely made it deterministic.

API Changes

None — bug fix only: from_dict on a serialized dict now keeps entries whose value is 0.0/False/"" and drops only None (the original intent of the filter).
See full details below.

Test Plan

  • pytest test_autofit/ — 1494 passed, 1 skipped
  • New regression test test_autofit/serialise/test_samples.py::test_sample_zero_valued_kwargs_round_trip
  • End-to-end: a PYAUTO_TEST_MODE=2 bypass fit of a lens model (zero-median centre priors) round-trips its summary and reconstructs tracers/fits through al.agg (aggregator-lens-profiling harness, autolens_workspace_test PR)
Full API Changes (for automation & release notes)

Changed Behaviour

  • ModelObject.from_dict (type == "dict" branch) — entries with falsy non-None values (0.0, False, "") are no longer silently dropped on deserialization; only None values are skipped.

Generated by the PyAutoLabs agent workflow.

The type=="dict" branch filtered entries with `if value`, silently
dropping any entry whose deserialized value is falsy — including
parameters exactly 0.0. Exposed by PYAUTO_TEST_MODE_SAMPLES (#1381)
bypass output: lens centres/ell_comps have zero prior medians, so
bypass-written summaries loaded with 8 of 15 parameters missing and
al.agg reconstruction crashed with KeyError. Only None is skipped now.

Regression test: zero-valued Sample kwargs round-trip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 17, 2026
@Jammy2211
Jammy2211 merged commit 6a591df into main Jul 17, 2026
5 checks passed
@Jammy2211
Jammy2211 deleted the feature/aggregator-lens-profiling branch July 17, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant