[Git][debian-gis-team/trollimage][master] 4 commits: New upstream version 1.22.1

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Sat Nov 25 07:53:26 GMT 2023



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


Commits:
0b4066e6 by Antonio Valentino at 2023-11-25T07:45:23+00:00
New upstream version 1.22.1
- - - - -
671dba76 by Antonio Valentino at 2023-11-25T07:45:29+00:00
Update upstream source from tag 'upstream/1.22.1'

Update to upstream version '1.22.1'
with Debian dir b6445ca98da25a85156ee329ca64413e28396265
- - - - -
4d6fb0ad by Antonio Valentino at 2023-11-25T07:46:32+00:00
New upstream release

- - - - -
aaf7754f by Antonio Valentino at 2023-11-25T07:48:05+00:00
Refresh all patches

- - - - -


6 changed files:

- CHANGELOG.md
- debian/changelog
- debian/patches/0001-No-display.patch
- trollimage/tests/test_image.py
- trollimage/version.py
- trollimage/xrimage.py


Changes:

=====================================
CHANGELOG.md
=====================================
@@ -1,3 +1,20 @@
+## Version 1.22.1 (2023/11/24)
+
+### Issues Closed
+
+* [Issue 152](https://github.com/pytroll/trollimage/issues/152) - Linear stretch of `uint8` data gives unexpected results ([PR 153](https://github.com/pytroll/trollimage/pull/153) by [@pnuu](https://github.com/pnuu))
+
+In this release 1 issue was closed.
+
+### Pull Requests Merged
+
+#### Bugs fixed
+
+* [PR 153](https://github.com/pytroll/trollimage/pull/153) - Fix stretching integer data ([152](https://github.com/pytroll/trollimage/issues/152))
+
+In this release 1 pull request was closed.
+
+
 ## Version 1.22.0 (2023/11/23)
 
 


=====================================
debian/changelog
=====================================
@@ -1,6 +1,9 @@
-trollimage (1.22.0-2) UNRELEASED; urgency=medium
+trollimage (1.22.1-1) UNRELEASED; urgency=medium
 
+  * New upstream release.
   * Disable SALSA_CI_DISABLE_CROSSBUILD_ARM64 in salsa CI.
+  * debian/patches:
+    - Refresh all patches.
 
  -- Antonio Valentino <antonio.valentino at tiscali.it>  Fri, 24 Nov 2023 07:49:16 +0000
 


=====================================
debian/patches/0001-No-display.patch
=====================================
@@ -8,10 +8,10 @@ Skip tests that require display.
  1 file changed, 1 insertion(+)
 
 diff --git a/trollimage/tests/test_image.py b/trollimage/tests/test_image.py
-index 3421efe..64650c1 100644
+index 1f8820c..f8e4ea8 100644
 --- a/trollimage/tests/test_image.py
 +++ b/trollimage/tests/test_image.py
-@@ -2034,6 +2034,7 @@ class TestXRImage:
+@@ -2053,6 +2053,7 @@ class TestXRImage:
          """Test putalpha."""
          pass
  


=====================================
trollimage/tests/test_image.py
=====================================
@@ -1631,6 +1631,25 @@ class TestXRImage:
 
         np.testing.assert_allclose(img.data.values, res, atol=1.e-6)
 
+    @pytest.mark.parametrize(("dtype", "max_val", "exp_min", "exp_max"),
+                             ((np.uint8, 255, -0.005358012691140175, 1.0053772069513798),
+                              (np.int8, 127, -0.004926108196377754, 1.0058689523488282),
+                              (np.uint16, 65535, -0.005050825305515899, 1.005050893505104),
+                              (np.int16, 32767, -0.005052744992717635, 1.0050527782880818),
+                              (np.uint32, 4294967295, -0.005050505077517274, 1.0050505395923495),
+                              (np.int32, 2147483647, -0.00505050499355784, 1.0050505395923495),
+                              (int, 2147483647, -0.00505050499355784, 1.0050505395923495),
+                              ))
+    def test_linear_stretch_integers(self, dtype, max_val, exp_min, exp_max):
+        """Test linear stretch with low-bit unsigned integer data."""
+        arr = np.linspace(0, max_val, num=75, dtype=dtype).reshape(5, 5, 3)
+        data = xr.DataArray(arr.copy(), dims=['y', 'x', 'bands'],
+                            coords={'bands': ['R', 'G', 'B']})
+        img = xrimage.XRImage(data)
+        img.stretch_linear()
+        assert img.data.values.min() == pytest.approx(exp_min)
+        assert img.data.values.max() == pytest.approx(exp_max)
+
     @pytest.mark.parametrize("dtype", (np.float32, np.float64, float))
     def test_histogram_stretch(self, dtype):
         """Test histogram stretching."""


=====================================
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.22.0)"
-    git_full = "dd16cdfbf40d8a245454ab5675166a1e9282b20c"
-    git_date = "2023-11-23 08:59:37 +0100"
+    git_refnames = " (HEAD -> main, tag: v1.22.1)"
+    git_full = "a84299fffaee504540cb7ab69a70b5690fb23156"
+    git_date = "2023-11-24 13:21:19 +0100"
     keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
     return keywords
 


=====================================
trollimage/xrimage.py
=====================================
@@ -1082,6 +1082,7 @@ class XRImage:
 
         attrs = self.data.attrs
         offset = -min_stretch * scale_factor
+
         self.data = np.multiply(self.data, scale_factor, dtype=scale_factor.dtype) + offset
         self.data.attrs = attrs
         self.data.attrs.setdefault('enhancement_history', []).append({'scale': scale_factor,
@@ -1095,8 +1096,13 @@ class XRImage:
         if isinstance(val, (list, tuple)):
             val = self.xrify_tuples(val)
 
+        dtype = self.data.dtype
+        if dtype in (np.uint8, np.int8, np.uint16, np.int16):
+            dtype = np.dtype(np.float32)
+        elif np.issubdtype(dtype, np.integer) or isinstance(dtype, int):
+            dtype = np.dtype(np.float64)
         try:
-            val = val.astype(self.data.dtype)
+            val = val.astype(dtype)
         except AttributeError:
             val = self.data.dtype.type(val)
 



View it on GitLab: https://salsa.debian.org/debian-gis-team/trollimage/-/compare/669b6651ee67773da0765d4fb1b4924062e6202a...aaf7754ff1d17e730aefa11a1e1a23fde2ac37a6

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/trollimage/-/compare/669b6651ee67773da0765d4fb1b4924062e6202a...aaf7754ff1d17e730aefa11a1e1a23fde2ac37a6
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/20231125/78c0c820/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list