Skip to content

Commit

Permalink
Remove numpy version upper bound restriction (#324)
Browse files Browse the repository at this point in the history
* remove numpy version upper bound restriction

* avoid warning when converting images with nans

* install crick via pip in conda env

---------

Co-authored-by: Dion Häfner <dion.haefner@simulation.science>
  • Loading branch information
serj90 and dionhaefner committed Dec 14, 2023
1 parent 3cbc26c commit 066fde4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- numpy
- rasterio>=1.3.0
- shapely
- crick
- pip
- pip:
- crick
- -e .[recommended]
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

numpy_version = ">=1.15,!=1.17.0"

# TODO: remove when crick is updated
numpy_version += ",<1.24"

setup(
# metadata
name="terracotta",
Expand Down
2 changes: 2 additions & 0 deletions terracotta/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def to_uint8(data: Array, lower_bound: Number, upper_bound: Number) -> Array:
"""Re-scale an array to [1, 255] and cast to uint8 (0 is used for transparency)"""
rescaled = contrast_stretch(data, (lower_bound, upper_bound), (1, 255), clip=True)
rescaled = np.rint(rescaled)
# explicitly set NaNs to 0 to avoid warnings
rescaled[~np.isfinite(rescaled)] = 0
return rescaled.astype(np.uint8)


Expand Down

0 comments on commit 066fde4

Please sign in to comment.