Skip to content

Add confirm_recomp option to IsochronePhot; fix PYSYN_CDBS import-time lookup - #163

Open
wei-lingfeng wants to merge 3 commits into
MovingUniverseLab:devfrom
wei-lingfeng:confirm-recomp-cdbs-fixes
Open

Add confirm_recomp option to IsochronePhot; fix PYSYN_CDBS import-time lookup#163
wei-lingfeng wants to merge 3 commits into
MovingUniverseLab:devfrom
wei-lingfeng:confirm-recomp-cdbs-fixes

Conversation

@wei-lingfeng

Copy link
Copy Markdown
Contributor

Three small, independent changes, one per commit.

1. confirm_recomp option for IsochronePhot

IsochronePhot.__init__ currently prompts before regenerating an isochrone file whenever verbose=True. It accepts only the exact string "yes" and returns on anything else, so a typo silently cancels the run.

This puts the prompt behind a new confirm_recomp argument and loops on invalid input instead of cancelling.

Please note this changes existing behaviour: confirm_recomp defaults to False, so a verbose=True run that prompts today will no longer prompt. That seemed right to us — the prompt makes an otherwise scriptable call block on stdin — but happy to default it to True instead if you'd rather preserve the current behaviour.

Also documents confirm_recomp and the pre-existing verbose argument, and splits the long __init__ signature across lines.

2. Remove trailing whitespace in synthetic.py

Whitespace only. git diff --ignore-space-at-eol on this commit is empty. Split out so it doesn't obscure the change above; drop it if you'd prefer to keep it out.

3. Resolve PYSYN_CDBS at call time rather than import time

rebin_BTSettl_2015 and rebin_WDKoester read os.environ['PYSYN_CDBS'] in their default arguments, which Python evaluates when the module is imported. So import spisea.atmospheres raises KeyError: 'PYSYN_CDBS' on any machine where that variable is not set, even for code that never calls either function:

File "spisea/atmospheres.py", line 2420, in <module>
    def rebin_BTSettl_2015(cdbs_path=os.environ['PYSYN_CDBS']):
KeyError: 'PYSYN_CDBS'

Moving the lookup into the function bodies behind a None default fixes it. Callers with PYSYN_CDBS set see identical behaviour, and an explicit cdbs_path still overrides. The other PYSYN_CDBS references in the file are inside function bodies and were already fine.


Related: the API docs for synthetic are currently blank on RTD

While tracking the above down we noticed that every synthetic.* class section on Read the Docs renders as an empty heading — make_isochrone and make_cluster — while imf and evolution render fine. autodoc cannot import synthetic in the RTD build, and there are three sequential import-time blockers:

  1. atmospheres.py PYSYN_CDBS in default args — fixed by this PR
  2. synthetic.py:42 default_evo_model = evolution.MISTv1() — requires the MISTv1/v1.2-synthpop/ directory to exist
  3. synthetic.py:68 vega = Vega() — reads cdbs/grid/k93models/catalog.fits

So this PR clears only the first. 2 and 3 need the model data at import time, which the RTD builder will not have. We didn't attempt those here since making the module importable without data is a design decision for you — happy to open a separate issue with the details if that's useful.

🤖 Generated with Claude Code

wei-lingfeng and others added 3 commits September 9, 2026 22:08
IsochronePhot already prompted before regenerating an isochrone file
whenever verbose=True, accepting only the exact string "yes" and
returning on anything else. Put that prompt behind a new confirm_recomp
argument, and loop on invalid input instead of silently cancelling.

Also documents confirm_recomp and the existing verbose argument, and
splits the long __init__ signature over one argument group per line.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Whitespace only, no functional change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
rebin_BTSettl_2015 and rebin_WDKoester read os.environ['PYSYN_CDBS'] in
their default arguments, which Python evaluates when the module is
imported. Importing spisea.atmospheres therefore raised KeyError on any
machine where PYSYN_CDBS was not set, even for code that never calls
these two functions.

Move the lookup into the function bodies behind a None default. Callers
that set PYSYN_CDBS see identical behaviour, and an explicit cdbs_path
still overrides it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant