[Git][debian-gis-team/trollimage][master] 5 commits: New upstream version 1.24.0

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Sun Jun 23 17:41:54 BST 2024



Antonio Valentino pushed to branch master at Debian GIS Project / trollimage


Commits:
ed00c289 by Antonio Valentino at 2024-06-23T16:19:01+00:00
New upstream version 1.24.0
- - - - -
dca0926d by Antonio Valentino at 2024-06-23T16:19:06+00:00
Update upstream source from tag 'upstream/1.24.0'

Update to upstream version '1.24.0'
with Debian dir b610b17b0e3e45db8dfef2f0f9012f258f4a7e11
- - - - -
1527127c by Antonio Valentino at 2024-06-23T16:19:35+00:00
New upstream release

- - - - -
43eac3c2 by Antonio Valentino at 2024-06-23T16:20:51+00:00
Refresh all patches

- - - - -
45baa03a by Antonio Valentino at 2024-06-23T16:21:26+00:00
Set distribution to unstable

- - - - -


10 changed files:

- .github/workflows/ci.yaml
- .github/workflows/deploy.yaml
- CHANGELOG.md
- debian/changelog
- debian/patches/0002-Compatibility-with-numpy-2.patch
- pyproject.toml
- trollimage/colormap.py
- trollimage/tests/test_colormap.py
- trollimage/version.py
- trollimage/xrimage.py


Changes:

=====================================
.github/workflows/ci.yaml
=====================================
@@ -59,7 +59,6 @@ jobs:
           git+https://github.com/dask/distributed \
           git+https://github.com/rasterio/rasterio \
           git+https://github.com/pydata/bottleneck \
-          git+https://github.com/zarr-developers/zarr \
           git+https://github.com/pydata/xarray;
           python -m pip install -e . --no-deps --no-build-isolation;
 


=====================================
.github/workflows/deploy.yaml
=====================================
@@ -59,7 +59,7 @@ jobs:
           platforms: all
 
       - name: Build wheels
-        uses: pypa/cibuildwheel at v2.17.0
+        uses: pypa/cibuildwheel at v2.18.1
         env:
           CIBW_SKIP: "cp36-* cp37-* cp38-* pp* *-manylinux_i686 *-musllinux_i686 *-musllinux_aarch64 *-win32"
           CIBW_ARCHS: "${{ matrix.cibw_archs }}"


=====================================
CHANGELOG.md
=====================================
@@ -1,3 +1,19 @@
+## Version 1.24.0 (2024/06/20)
+
+
+### Pull Requests Merged
+
+#### Bugs fixed
+
+* [PR 171](https://github.com/pytroll/trollimage/pull/171) - Fix various numpy 2 and new xarray casting issues
+
+#### Features added
+
+* [PR 170](https://github.com/pytroll/trollimage/pull/170) - Implement set_alpha_channel in Colorbar
+
+In this release 2 pull requests were closed.
+
+
 ## Version 1.23.2 (2024/04/15)
 
 ### Pull Requests Merged


=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+trollimage (1.24.0-1) unstable; urgency=medium
+
+  * New upstream release.
+  * debian/patches:
+    - Refresh all patches.
+
+ -- Antonio Valentino <antonio.valentino at tiscali.it>  Sun, 23 Jun 2024 16:21:09 +0000
+
 trollimage (1.23.2-1) unstable; urgency=medium
 
   * New upstream release.


=====================================
debian/patches/0002-Compatibility-with-numpy-2.patch
=====================================
@@ -8,7 +8,7 @@ Forwarded: not-needed
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/pyproject.toml b/pyproject.toml
-index 9012fc2..2cc1158 100644
+index 14638ce..f786294 100644
 --- a/pyproject.toml
 +++ b/pyproject.toml
 @@ -1,7 +1,7 @@
@@ -20,7 +20,7 @@ index 9012fc2..2cc1158 100644
      "setuptools>=42",
      "versioneer",
      "Cython>=3.0.0"
-@@ -27,4 +27,4 @@ filterwarnings = [
+@@ -29,4 +29,4 @@ filterwarnings = [
  log_cli_level = "info"
  testpaths = [
      "trollimage/tests",


=====================================
pyproject.toml
=====================================
@@ -20,6 +20,8 @@ xfail_strict = true
 filterwarnings = [
     "error",
     "ignore::rasterio.errors.NotGeoreferencedWarning",
+    # remove when fixed by xarray
+    "ignore:__array_wrap__ must accept context and return_scalar arguments:DeprecationWarning:numpy",
     # dateutil needs a new release
     # https://github.com/dateutil/dateutil/issues/1314
     'ignore:datetime.datetime.utcfromtimestamp\(\) is deprecated and scheduled for removal:DeprecationWarning:dateutil',


=====================================
trollimage/colormap.py
=====================================
@@ -365,6 +365,41 @@ class Colormap(object):
         cmap.values = values
         return cmap
 
+    def set_alpha_range(self, min_alpha, max_alpha, inplace=True):
+        """Set the colormap alpha channel between two values in linear steps.
+
+        If the input colormap does not have an alpha channel,
+        it will be added to it. If an alpha channel is already existing,
+        the values will be overwritten.
+
+        The min and max values shall be between 0 (completely transparent)
+        and 1 (completely opaque).
+
+        Args:
+            min_alpha (float): Start value of the alpha channel [0-1]
+            max_alpha (float): End value of the alpha channel [0-1]
+            inplace (bool): If True (default), modify the values inplace.
+                If False, return a new Colormap instance.
+
+        """
+        if inplace:
+            cmap = self
+        else:
+            cmap = Colormap(
+                values=self.values.copy(),
+                colors=self.colors.copy())
+
+        alpha = np.linspace(min_alpha,
+                            max_alpha,
+                            self.colors.shape[0])
+
+        if cmap.colors.shape[1] == 4:
+            cmap.colors[:, 3] = alpha
+        else:
+            cmap.colors = np.column_stack((cmap.colors, alpha))
+
+        return cmap
+
     def to_rio(self):
         """Convert the colormap to a rasterio colormap.
 
@@ -687,7 +722,7 @@ class Colormap(object):
             # remove the last value because monkeys don't like water sprays
             # on a more serious note, I don't know why we are removing the last
             # value here, but this behaviour was copied from ancient satpy code
-            values = np.arange(squeezed_palette.shape[0]-remove_last)
+            values = np.arange(squeezed_palette.shape[0] - remove_last)
             if remove_last:
                 squeezed_palette = squeezed_palette[:-remove_last, :]
 


=====================================
trollimage/tests/test_colormap.py
=====================================
@@ -30,7 +30,6 @@ import xarray
 
 import pytest
 
-
 COLORS_RGB1 = np.array([
     [0.0, 0.0, 0.0],
     [0.2, 0.2, 0.0],
@@ -340,6 +339,32 @@ class TestColormap:
         _assert_values_changed(cmap, new_cmap, inplace, orig_values)
         _assert_unchanged_colors(cmap, new_cmap, orig_colors)
 
+    @pytest.mark.parametrize(
+        'new_range',
+        [
+            (0.0, 1.0),
+            (1.0, 0.0),
+            (0.2, 0.5),
+            (0.8, 0.3),
+        ])
+    @pytest.mark.parametrize('colors_already_with_alpha', [False, True])
+    @pytest.mark.parametrize('inplace', [False, True])
+    def test_set_alpha_range(self, new_range, inplace, colors_already_with_alpha):
+        """Test 'set_alpha_range' method."""
+        values = np.linspace(0, 1, 11)
+        colors_col_n = 4 if colors_already_with_alpha else 3
+        colors = np.repeat(np.linspace(0, 1, 11)[:, np.newaxis], colors_col_n, 1)
+        orig_values = values.copy()
+
+        cmap = colormap.Colormap(values=values, colors=colors)
+        new_cmap = cmap.set_alpha_range(*new_range, inplace)
+
+        np.testing.assert_equal(new_cmap.colors[0, 3], new_range[0])
+        np.testing.assert_equal(new_cmap.colors[-1, 3], new_range[1])
+
+        _assert_inplace_worked(cmap, new_cmap, inplace)
+        _assert_unchanged_values(cmap, new_cmap, inplace, orig_values)
+
     @pytest.mark.parametrize(
         ("input_cmap_func", "expected_result"),
         [
@@ -690,7 +715,7 @@ def test_cmap_from_sequence_of_colors():
     colors = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]
     cmap = colormap.Colormap.from_sequence_of_colors(colors, color_scale=2)
     np.testing.assert_allclose(cmap.values, [0, 0.33333333, 0.66666667, 1])
-    np.testing.assert_array_equal(cmap.colors*2, colors)
+    np.testing.assert_array_equal(cmap.colors * 2, colors)
 
     vals = [0, 5, 10, 15]
     cmap = colormap.Colormap.from_sequence_of_colors(colors, values=vals, color_scale=2)
@@ -706,7 +731,7 @@ def test_build_colormap_with_int_data_and_without_meanings():
     # test that values are respected even if valid_range is passed
     # see https://github.com/pytroll/satpy/issues/2376
     cmap = colormap.Colormap.from_array_with_metadata(
-            palette, np.uint8, valid_range=[0, 100])
+        palette, np.uint8, valid_range=[0, 100])
 
     np.testing.assert_array_equal(cmap.values, [0, 1])
 
@@ -716,23 +741,23 @@ def test_build_colormap_with_float_data():
     palette = np.array([[0, 0, 0], [127, 127, 127], [255, 255, 255]])
 
     with pytest.raises(AttributeError):
-        colormap.Colormap.from_array_with_metadata(palette/100, np.float32)
+        colormap.Colormap.from_array_with_metadata(palette / 100, np.float32)
 
     cmap = colormap.Colormap.from_array_with_metadata(
-            palette,
-            np.float32,
-            valid_range=[0, 100],
-            scale_factor=2,
-            remove_last=True)
+        palette,
+        np.float32,
+        valid_range=[0, 100],
+        scale_factor=2,
+        remove_last=True)
 
     np.testing.assert_array_equal(cmap.values, [0, 200])
 
     cmap = colormap.Colormap.from_array_with_metadata(
-            palette,
-            np.float32,
-            valid_range=[0, 100],
-            scale_factor=2,
-            remove_last=False)
+        palette,
+        np.float32,
+        valid_range=[0, 100],
+        scale_factor=2,
+        remove_last=False)
 
     np.testing.assert_array_equal(cmap.values, [0, 100, 200])
 


=====================================
trollimage/version.py
=====================================
@@ -26,9 +26,9 @@ def get_keywords():
     # setup.py/versioneer.py will grep for the variable names, so they must
     # each be defined on a line of their own. _version.py will just call
     # get_keywords().
-    git_refnames = " (HEAD -> main, tag: v1.23.2)"
-    git_full = "78c093c210159c7eea5e932e550952b3dabab5f2"
-    git_date = "2024-04-15 14:06:06 -0500"
+    git_refnames = " (HEAD -> main, tag: v1.24.0)"
+    git_full = "5de5037532e3433a2122c57a173c984e76c8a1fb"
+    git_date = "2024-06-20 10:24:19 +0200"
     keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
     return keywords
 


=====================================
trollimage/xrimage.py
=====================================
@@ -673,6 +673,9 @@ class XRImage:
         """
         attrs = data.attrs.copy()
         if np.issubdtype(dtype, np.integer):
+            if np.issubdtype(data, np.bool_):
+                # convert boolean masks to floats so they can be scaled to the output integer dtype
+                data = data.astype(np.float64)
             if np.issubdtype(data, np.integer):
                 # preserve integer data type
                 data = data.clip(np.iinfo(dtype).min, np.iinfo(dtype).max)
@@ -1109,6 +1112,10 @@ class XRImage:
 
         attrs = self.data.attrs
         offset = -min_stretch * scale_factor
+        try:
+            offset = offset.astype(scale_factor.dtype)
+        except AttributeError:
+            offset = scale_factor.dtype.type(offset)
 
         self.data = np.multiply(self.data, scale_factor, dtype=scale_factor.dtype) + offset
         self.data.attrs = attrs
@@ -1225,7 +1232,7 @@ class XRImage:
         log_func = np.log if base == "e" else getattr(np, "log" + base)
         min_stretch, max_stretch = self._convert_log_minmax_stretch(min_stretch, max_stretch)
 
-        b__ = float(crange[1] - crange[0]) / log_func(factor)
+        b__ = float(crange[1] - crange[0]) / self.data.dtype.type(log_func(factor))
         c__ = float(crange[0])
 
         def _band_log(arr, min_input, max_input):



View it on GitLab: https://salsa.debian.org/debian-gis-team/trollimage/-/compare/bec1353dd2ccdf5b6e76fe4f0df1cd2a8d5c8801...45baa03a4edb8e687a783c6db7fc2d2c99dbf6e2

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://salsa.debian.org/debian-gis-team/trollimage/-/compare/bec1353dd2ccdf5b6e76fe4f0df1cd2a8d5c8801...45baa03a4edb8e687a783c6db7fc2d2c99dbf6e2
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20240623/46bff583/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list