-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #428 from ameraner/fix_resolution_formatting
Fix resolution formatting for numpy floats
- Loading branch information
Showing
5 changed files
with
38 additions
and
3 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
Empty file.
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,25 @@ | ||
from decimal import Decimal | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from uwsift.util.common import format_resolution | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"resolution, expected", | ||
[ | ||
(999, "999 m"), # Test with a value less than 1000 meters | ||
(1000, "1.0 km"), # Test with exactly 1000 meters | ||
(1500, "1.5 km"), # Test with a value greater than 1000 meters | ||
(25000, "25.0 km"), # Test with a large value | ||
(1, "1 m"), # Test with a value close to 1 meter | ||
(1234.56, "1.2 km"), # Test with a float value | ||
(np.float32(500), "500 m"), # Test with a numpy numeric value less than 1000 meters | ||
(np.float64(1500), "1.5 km"), # Test with a numpy numeric value greater than 1000 meters | ||
(Decimal("750.0"), "750 m"), # Test with a Decimal value less than 1000 meters | ||
(Decimal("1250.0"), "1.2 km"), # Test with a Decimal value greater than 1000 meters | ||
], | ||
) | ||
def test_format_resolution(resolution, expected): | ||
assert format_resolution(resolution) == expected |
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