Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autofit/mapper/model_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_class_path():
loaded_ids=loaded_ids,
)
for key, value in d["arguments"].items()
if value
if value is not None
}
elif type_ == "instance":
class_path = get_class_path()
Expand Down
16 changes: 16 additions & 0 deletions test_autofit/serialise/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,19 @@ def test_generic_from_dict(summary_dict):
summary = from_dict(summary_dict)
assert isinstance(summary, SamplesSummary)
assert isinstance(summary.max_log_likelihood_sample, af.Sample)


def test_sample_zero_valued_kwargs_round_trip():
"""
Sample kwargs whose value is exactly 0.0 (e.g. a prior-median centre) must
survive to_dict -> from_dict — the dict branch previously filtered falsy
values, silently dropping them.
"""
sample = af.Sample(
log_likelihood=1.0,
log_prior=0.0,
weight=1.0,
kwargs={"centre.centre_0": 0.0, "sigma": 6.0},
)
loaded = from_dict(to_dict(sample))
assert loaded.kwargs == {("centre", "centre_0"): 0.0, ("sigma",): 6.0}
Loading