Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate floats when passed to IntParameter #30

Merged
merged 4 commits into from
Jan 31, 2024

Conversation

mcflugen
Copy link
Member

This pull request should fix #29.

With v0.8.0, I made a change to IntParameter whereby if it was passed a float, an error was raised. In the past, the float would have silently converted to an int. This PR makes a change so that, in such a circumstance, the floating point value is truncated and an warning is issued.

In #29, this was a problem when loading metadata from pymt_cem because it contained the following section in its parameters file,

run_duration:
  description: Simulation run time
  value:
    default: 3650.0
    range:
      max: 1.79769313486e+308
      min: 1.0
    type: int
    units: d

Notice the default is a float but the type is int.

@coveralls
Copy link

coveralls commented Jan 30, 2024

Pull Request Test Coverage Report for Build 7706479613

  • -5 of 10 (50.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 73.839%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/model_metadata/model_parameter.py 5 10 50.0%
Totals Coverage Status
Change from base Build 7691377978: 0.2%
Covered Lines: 652
Relevant Lines: 883

💛 - Coveralls

@mcflugen mcflugen merged commit faefc59 into main Jan 31, 2024
13 checks passed
@mcflugen mcflugen deleted the mcflugen/fix-float-as-int-parameter branch January 31, 2024 06:57
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.

model_metadata v0.8.0 breaks pymt_era5 import
2 participants