-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit handling and round-trip .nc conversion fixes (#13)
* Fix roundtrip conversion of named_options * Fix unit-conversion error ("" as ureg.dimensionless, not skip conversion) * Pre-commit fixes * Remove unnecessary string catch in fileio * Add test to check conversion to dimensionless * Add netcdf4 to environment * Add back in fix for str in netcdf * Mypy fixes * Add default value for netcdf engine * Update cfspopcon/file_io.py Co-authored-by: Christoph Hasse <[email protected]> * fix pre-commit error --------- Co-authored-by: Christoph Hasse <[email protected]>
- Loading branch information
Showing
13 changed files
with
777 additions
and
721 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import warnings | ||
|
||
import numpy as np | ||
import pytest | ||
import xarray as xr | ||
|
||
from cfspopcon.unit_handling import dimensionless_magnitude, ureg, Quantity, ureg, convert_to_default_units | ||
|
||
|
||
def test_conversion_of_dimensionless(): | ||
|
||
val = Quantity(2.0, ureg.percent) | ||
|
||
assert np.isclose(dimensionless_magnitude(val), 2e-2) | ||
assert np.isclose(convert_to_default_units(val, key="beta"), 2e-2) |