Skip to content

Fix diff() erroring on NaN parameter values; fix vector diff comparing p1 to itself - #21

Merged
jmcclena merged 2 commits into
masterfrom
fix/nan-diff
Nov 3, 2026
Merged

jmcclena merged 2 commits into
masterfrom
fix/nan-diff

Conversation

@tomneiser

@tomneiser tomneiser commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Problem

FUSE CI (test/runtests_study.jl) started failing after ProjectTorreyPines/FUSE.jl#1124 added ActorSOLPSNN.Psol with default=NaN:

Psol had different value:
act.ActorSOLPSNN.Psol ... value: NaN
act.ActorSOLPSNN.Psol ... value: NaN

diff() compares values through equals_with_missing, which fell through to a == b. Since NaN == NaN is false, two identical NaN values were reported as different and diff errored.

(FUSE side is independently fixed by ProjectTorreyPines/FUSE.jl#1138, which drops the NaN sentinel — this PR remains worthwhile as a robustness fix: parameter values can legitimately contain NaN, e.g. inside arrays.)

Fix

  • equals_with_missing(a, b) = isequal(a, b) — isequal treats missing == missing and NaN == NaN as true (including inside arrays), and otherwise matches ==.
  • Fix a copy-paste bug in diff(::AbstractParametersVector, ...): v2 was read from p1 instead of p2, so vector-parameter diffs silently compared p1 against itself.

Note on the src/io.jl call site

equals_with_missing is also used in par2ystr's skip_defaults sub-tree check. The scalar-parameter path below it already uses value === default, and for floats === treats NaN === NaN as true and -0.0 === 0.0 as false. The old ==-based check diverged from that on exactly those two cases (an untouched NaN-defaulted parameter was wrongly considered "not default" and written out); isequal matches === float semantics, so this change aligns the sub-tree check with the existing scalar check.

Testing

  • Targeted check: NaN-defaulted Entry diffs cleanly, real differences still throw, missing/NaN-array semantics correct.
  • Full Pkg.test() suite passes.

Version bump to be done after merge per repo convention.

🤖 Generated with Claude Code

equals_with_missing used ==, so two identical NaN parameter values
(e.g. FUSE ActorSOLPSNN.Psol with default=NaN) made diff() error.
Use isequal, which treats missing==missing and NaN==NaN as true,
including inside arrays.

Also fix a copy-paste bug in diff(::AbstractParametersVector, ...):
v2 was read from p1 instead of p2, so vector diffs compared p1
against itself.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tomneiser
tomneiser requested a review from jmcclena July 23, 2026 17:48
@jmcclena

Copy link
Copy Markdown
Member

Human @tomneiser, why does the test return act.ActorSOLPSNN.Psol ... value: NaN?

@tomneiser

tomneiser commented Jul 24, 2026 •

Copy link
Copy Markdown
Member Author

Thanks, before being fed any data I made the actor return missing rather than NaN here: ProjectTorreyPines/FUSE.jl#1138. The NaN was over-complicating things

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jmcclena
jmcclena merged commit 32d24f9 into master Nov 3, 2026
2 checks passed
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.

2 participants