csdms / model_metadata

Tools for working with CSDMS Model Metadata
MIT License
1 stars 0 forks source link

Truncate floats when passed to IntParameter #30

Closed mcflugen closed 9 months ago

mcflugen commented 9 months ago

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 commented 9 months ago

Pull Request Test Coverage Report for Build 7706479613


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

💛 - Coveralls