Repository navigation
Warn before overwriting a mismatched isochrone file; fix NaN IMF masses; NumPy scalars in IMF helpers - #173
Merged
jluastro merged 7 commits intoNov 13, 2026
Conversation
The other IMF helpers test isinstance(x, (float, np.floating)); these three still tested type(x) == float, so a NumPy scalar came back as a one-element array instead of a float. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With recomp=False, IsochronePhot (and IsochronePhotExternalEvolution) regenerates an isochrone whose save file exists but was made with a different evolution model, atmosphere, reddening law or model version, overwriting that file. This happened silently unless verbose. - save_file_mismatches() lists each mismatched input as (key, value in file, requested value); check_save_file() uses it and returns the same results as before. - Before overwriting a mismatched save file, warn regardless of verbose, naming the mismatched inputs. A missing file or recomp=True regenerates without a warning, as before. - Verbose mismatch lines now read "KEY: file has X, requested Y" (was "KEY: X != Y"), and a model version mismatch is listed with the others. A file that gets the warning is not also reported in the verbose output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The warning now opens with the same multiline block as the verbose output (one "KEY: file has X, requested Y" line per mismatched input) and ends with "Regenerating it, which overwrites the file." Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jluastro
approved these changes
Oct 29, 2026
jluastro
left a comment
Contributor
There was a problem hiding this comment.
This all looks good to me. I've reviewed all the code changes. Can you confirm that you have run all the tests and that they pass?
…smatch-warning Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dev now regenerates isochrone files made before SPISEA version 3 (or with no SPISEAVERSION recorded). Fold that check into save_file_mismatches so it is listed in the verbose report and the overwrite warning like the other mismatched inputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Ran the full test suite on the updated branch: 91 passed, 2 skipped (the COSMIC integration tests; the optional cosmic package is not installed here). |
dice_star_cl evaluated the inverse primitive for draws beyond each segment as well. For a slope steeper than -1 that inverse is NaN there, and multiplying it by 0 kept the NaN. Evaluate it only for draws inside the segment. Add a regression test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mwhosek
pushed a commit
that referenced
this pull request
Nov 14, 2026
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
IsochronePhotregenerates an isochrone when its save file exists but was made with a different evolution model, atmosphere, reddening law or model version. That overwrites the existing file, and with the defaultverbose=Falseit happened silently. It now issues aUserWarninglisting the mismatched inputs, and the verbose mismatch messages say which value is the file's and which was requested.theta_closed,theta_openanddeltainimf.pynow testisinstance(x, (float, np.floating))like the other IMF helpers, so NumPy scalars return floats instead of one-element arrays.IMF_broken_powerlaw. When a segment other than the last is steeper than m^-1,dice_star_clreturned NaN for some draws (19% for slopes -2.3, -1.3 with limits 0.08, 0.5, 150 Msun; 0.4% for -2.7, -2.3). Fixed; masses are unchanged wherever they were not NaN.ResolvedCluster. The "Remove low mass stars ..." messages are printed only withverbose=True.Behaviour
recomp=False, no matching legacy file (file is overwritten)verbose=TrueUserWarningnaming the mismatched inputs, regardless ofverboseverbose=TrueSPISEAVERSION(dev now regenerates these)verbose=TrueUserWarningwithSPISEAVERSION: file has None, requested 3.1.0recomp=Trueverbose=TrueExample warning:
The warning uses the same multiline block as the verbose report.
IsochronePhotExternalEvolutiongets the same warning.Changes
save_file_mismatches()returns each mismatched input as(key, value in file, requested value), orNoneif the file does not exist.check_save_file()now uses it; its return values are unchanged (checked on 40 existing isochrone files with two model sets).check_save_fileis now part ofsave_file_mismatches: a file made before SPISEA 3, or with noSPISEAVERSION, is listed as aSPISEAVERSIONmismatch. Whether a file is regenerated is unchanged from dev (checked on 20 Wd1 isochrone files, with and without a v3 version tag: 140 checks, 0 differences). Dev stops at the version check; this lists every mismatched input.REDLAW: file has H18b, requested N09instead ofREDLAW: H18b != N09, and a model-version mismatch is listed with the other keys instead of in a separate sentence. When the warning is issued, the same file is not also reported in the verbose output.theta_closed,theta_openanddeltainimf.pynow testisinstance(x, (float, np.floating))like the other IMF helpers, so NumPy scalars return floats instead of one-element arrays.IMF_broken_powerlaw.dice_star_clevaluated the inverse primitive((1+p) t)^(1/(1+p))for every draw at or beyond segment i and then multiplied it by 0 for draws past the segment. For p < -1 the inverse is NaN past the segment, and 0 × NaN stays NaN. It is now evaluated only for draws inside the segment.ResolvedClusterare now behindverbose.Tests
New tests in
test_synthetic.pycoversave_file_mismatches(including a pre-v3 or missingSPISEAVERSION), the verbose messages, and the warning: issued for a mismatched file with and withoutverbose, and not issued for a missing file,recomp=True, or a matching legacy file. The isochrone computation is patched out, so they run in seconds. A new test intest_imf.pydraws 10,000 masses for slopes -2.3, -1.3 and checks for no NaN and masses within the limits; it fails without the fix.test_imf.pypasses.