From 066fde4013c43fc561de20ff1e0d0ad67999e970 Mon Sep 17 00:00:00 2001 From: Serzh Voskanyan <32635545+serj90@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:20:16 +0400 Subject: [PATCH] Remove numpy version upper bound restriction (#324) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- environment.yml | 2 +- setup.py | 3 --- terracotta/image.py | 2 ++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/environment.yml b/environment.yml index db275dc5..ed5c2531 100644 --- a/environment.yml +++ b/environment.yml @@ -7,7 +7,7 @@ dependencies: - numpy - rasterio>=1.3.0 - shapely - - crick - pip - pip: + - crick - -e .[recommended] diff --git a/setup.py b/setup.py index 79e1c112..c456bdd3 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/terracotta/image.py b/terracotta/image.py index 229f2c2a..ca62032c 100755 --- a/terracotta/image.py +++ b/terracotta/image.py @@ -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)