Skip to content

Use cosmic-settings.json to perform error checks on BSEDict#740

Merged
TomWagg merged 30 commits intoCOSMIC-PopSynth:developfrom
TomWagg:better_error_check
Jan 27, 2026
Merged

Use cosmic-settings.json to perform error checks on BSEDict#740
TomWagg merged 30 commits intoCOSMIC-PopSynth:developfrom
TomWagg:better_error_check

Conversation

@TomWagg
Copy link
Copy Markdown
Collaborator

@TomWagg TomWagg commented Dec 18, 2025

This PR changes the error_check function from a gargantuan collection of if statements to a loop based on the settings JSON file. The valid values are based off the options listed in the JSON file. These values can be

  • "positive values" = more than 0
  • "negative values" = less than 0
  • "range [a, b]" = a <= x <= b
  • "range (a, b]" = a < x <= b
  • An exact int/float

A value is defined as valid if it matches one of the values/ranges listed in the settings.

Exceptions are the array settings, those I left manually as exceptions.

Separately, I also created a cosmic.utils.explain_setting function, which queries the JSON for the setting and prints out its description as well as all of the valid options, what they mean, and which one is the COSMIC default choice.

e.g.

explain_setting("alpha1")

gives

alpha1
------
Common-envelope efficiency parameter which scales the efficiency of transferring orbital energy to the envelope. See Hurley+2002, Eq. 71.

Valid options (default marked with *):
  - positive values: Sets the common-envelope efficiency parameter, \(\alpha\)
  * 1.0: Default value

Closes #737

@TomWagg TomWagg requested a review from katiebreivik December 18, 2025 18:00
@TomWagg TomWagg self-assigned this Dec 18, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 0% with 110 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.67%. Comparing base (8772c07) to head (14f6773).
⚠️ Report is 118 commits behind head on develop.

Files with missing lines Patch % Lines
src/cosmic/utils.py 0.00% 84 Missing ⚠️
src/cosmic/evolve.py 0.00% 25 Missing ⚠️
src/cosmic/_version.py 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #740      +/-   ##
===========================================
- Coverage    86.91%   78.67%   -8.24%     
===========================================
  Files           40       49       +9     
  Lines        25542    27132    +1590     
  Branches         0      908     +908     
===========================================
- Hits         22198    21345     -853     
- Misses        3344     5514    +2170     
- Partials         0      273     +273     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added the needs-cmc-review PR touches cosmic core settings and needs CMC review label Jan 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 CMC review requested

This pull request modifies one or more of the following files:

  • src/cosmic/utils.py
  • docs/cosmic-settings.json
  • src/cosmic/evolve.py

A CMC developer should review this PR to ensure corresponding changes are propagated upstream as needed.

@COSMIC-PopSynth COSMIC-PopSynth deleted a comment from github-actions Bot Jan 27, 2026
@COSMIC-PopSynth COSMIC-PopSynth deleted a comment from github-actions Bot Jan 27, 2026
@COSMIC-PopSynth COSMIC-PopSynth deleted a comment from github-actions Bot Jan 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 CMC review requested

This pull request modifies one or more of the following files:

  • src/cosmic/utils.py
  • docs/cosmic-settings.json
  • src/cosmic/evolve.py

A CMC developer should review this PR to ensure corresponding changes are propagated upstream as needed.

@github-actions
Copy link
Copy Markdown
Contributor

🚨 CMC review requested

This pull request modifies one or more of the following files:

  • src/cosmic/utils.py
  • docs/cosmic-settings.json
  • src/cosmic/evolve.py

A CMC developer should review this PR to ensure corresponding changes are propagated upstream as needed.

@github-actions
Copy link
Copy Markdown
Contributor

🚨 CMC review requested

This pull request modifies one or more of the following files:

  • src/cosmic/utils.py
  • docs/cosmic-settings.json
  • src/cosmic/evolve.py

A CMC developer should review this PR to ensure corresponding changes are propagated upstream as needed.

@github-actions
Copy link
Copy Markdown
Contributor

🚨 CMC review requested

This pull request modifies one or more of the following files:

  • src/cosmic/utils.py
  • docs/cosmic-settings.json
  • src/cosmic/evolve.py

A CMC developer should review this PR to ensure corresponding changes are propagated upstream as needed.

@github-actions
Copy link
Copy Markdown
Contributor

🚨 CMC review requested

This pull request modifies one or more of the following files:

  • src/cosmic/utils.py
  • docs/cosmic-settings.json
  • src/cosmic/evolve.py

A CMC developer should review this PR to ensure corresponding changes are propagated upstream as needed.

@github-actions
Copy link
Copy Markdown
Contributor

🚨 CMC review requested

This pull request modifies one or more of the following files:

  • src/cosmic/utils.py
  • docs/cosmic-settings.json
  • src/cosmic/evolve.py

A CMC developer should review this PR to ensure corresponding changes are propagated upstream as needed.

@TomWagg TomWagg merged commit e96bfd0 into COSMIC-PopSynth:develop Jan 27, 2026
5 of 7 checks passed
@TomWagg TomWagg deleted the better_error_check branch January 27, 2026 19:58
MarkGM02 pushed a commit to MarkGM02/COSMIC that referenced this pull request Feb 4, 2026
…-PopSynth#740)

* move cosmic-settings.json, clearer valid values

* add data in meson build

* overhaul error_check to use the json

* add explain_setting function

* update __all__

* condition was reversed

* lists are not okay

* need to let it ecsn_mlow be 0.0

* add empty init to avoid being a namespace package

* change import based on python version

* version bump for cosmic and python version add up to 3.14 and remove 3.9

* ensure setuptools is up to date

* remove extra line

* hail mary from gpt with versioning

* bad comma

* removing importlib-metadata since it allegedly is only needed for <3.8

* removing 3.14

* adding back in importlib-metadata for linting

* avoid inserting one column at a time, use concat, avoid warning

* remove importlib-metadata

* update flake8 install

* use concat for kicks too

* axe flake8, who needs linting anyway?

* remove flake8 here too

---------

Co-authored-by: Katie Breivik <kbreivik@andrew.cmu.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement needs-cmc-review PR touches cosmic core settings and needs CMC review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the 700 line error_check function in utils.py with a loop

2 participants