[Git][debian-gis-team/glymur][master] 6 commits: New upstream version 0.9.3

Antonio Valentino gitlab at salsa.debian.org
Sat Jan 9 08:54:14 GMT 2021



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


Commits:
c39de64a by Antonio Valentino at 2021-01-09T08:18:38+00:00
New upstream version 0.9.3
- - - - -
eb13fc7e by Antonio Valentino at 2021-01-09T08:19:26+00:00
Update upstream source from tag 'upstream/0.9.3'

Update to upstream version '0.9.3'
with Debian dir 55750498426cb35f40f949a2488c45d7754097a3
- - - - -
476cebea by Antonio Valentino at 2021-01-09T08:22:49+00:00
New upstream release

- - - - -
de7309d2 by Antonio Valentino at 2021-01-09T08:25:20+00:00
Drop skimage.patch

- - - - -
f9a16d82 by Antonio Valentino at 2021-01-09T08:46:24+00:00
Add lintian overrides

- - - - -
01604c61 by Antonio Valentino at 2021-01-09T08:47:04+00:00
Set distribution to unstable

- - - - -


23 changed files:

- .travis.yml
- ci/doc.yml
- ci/travis-38.yaml
- + ci/travis-39-opj2p4.yaml
- + ci/travis-39.yaml
- debian/changelog
- − debian/patches/series
- − debian/patches/skimage.patch
- + debian/python3-glymur.lintian-overrides
- + debian/source/lintian-overrides
- docs/source/conf.py
- docs/source/how_do_i.rst
- docs/source/introduction.rst
- docs/source/whatsnew/0.9.rst
- glymur/config.py
- glymur/jp2k.py
- glymur/lib/openjp2.py
- glymur/version.py
- setup.py
- tests/test_config.py
- tests/test_jp2k.py
- tests/test_openjp2.py
- tests/test_printing.py


Changes:

=====================================
.travis.yml
=====================================
@@ -2,21 +2,27 @@ language: python
 matrix:
     fast_finish: true
     include:
-    - python: 3.6
-      env:
-        - JOB="3.6 No OPENJPEG" ENV_FILE="ci/travis-36-no-opj.yaml"
-    - python: 3.6
-      env:
-        - JOB="3.6" ENV_FILE="ci/travis-36.yaml"
-    - python: 3.7
-      env:
-        - JOB="3.7" ENV_FILE="ci/travis-37.yaml"
-    - python: 3.7
-      env:
-        - JOB="3.7" ENV_FILE="ci/travis-37-no-gdal.yaml"
-    - python: 3.8
-      env:
-        - JOB="3.8" ENV_FILE="ci/travis-38.yaml"
+      - python: 3.9-dev
+        env:
+          - JOB="3.9" ENV_FILE="ci/travis-39.yaml"
+      - python: 3.9-dev
+        env:
+          - JOB="3.9 opj 2.4" ENV_FILE="ci/travis-39-opj2p4.yaml"
+      - python: 3.8
+        env:
+          - JOB="3.8" ENV_FILE="ci/travis-38.yaml"
+      - python: 3.7
+        env:
+          - JOB="3.7" ENV_FILE="ci/travis-37.yaml"
+      - python: 3.7
+        env:
+          - JOB="3.7" ENV_FILE="ci/travis-37-no-gdal.yaml"
+      - python: 3.6
+        env:
+          - JOB="3.6 No OPENJPEG" ENV_FILE="ci/travis-36-no-opj.yaml"
+      - python: 3.6
+        env:
+          - JOB="3.6" ENV_FILE="ci/travis-36.yaml"
 before_install:
   - echo "before_install"
   - sudo apt-get update


=====================================
ci/doc.yml
=====================================
@@ -5,5 +5,3 @@ dependencies:
     - python=3.7
     - numpydoc>=0.8
     - sphinx_rtd_theme>=0.4.2
-    - mock>=2.0.0
-    - contextlib2>=0.5.5


=====================================
ci/travis-38.yaml
=====================================
@@ -1,6 +1,6 @@
 name: glymur
 channels:
-    - conda-forge
+    - defaults
 dependencies:
     - python=3.8.*
     - gdal


=====================================
ci/travis-39-opj2p4.yaml
=====================================
@@ -0,0 +1,8 @@
+name: glymur
+channels:
+    - conda-forge
+dependencies:
+    - python=3.9.*
+    - lxml
+    - numpy
+    - openjpeg >= 2.4.0


=====================================
ci/travis-39.yaml
=====================================
@@ -0,0 +1,10 @@
+name: glymur
+channels:
+    - conda-forge
+dependencies:
+    - python=3.9.*
+    - gdal
+    - lxml
+    - numpy
+    - openjpeg
+    - scikit-image


=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+glymur (0.9.3-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Drop skimage.patch, applied upstream.
+  * Add lintian overrides for repeated-path-segment and
+    maintainer-manual-page
+
+ -- Antonio Valentino <antonio.valentino at tiscali.it>  Sat, 09 Jan 2021 08:46:33 +0000
+
 glymur (0.9.2-2) unstable; urgency=medium
 
   * Team upload.


=====================================
debian/patches/series deleted
=====================================
@@ -1 +0,0 @@
-skimage.patch


=====================================
debian/patches/skimage.patch deleted
=====================================
@@ -1,26 +0,0 @@
-Description: Update function renamed in skimage 0.16.
-Author: Bas Couwenberg <sebastic at debian.org>
-Bug-Debian: https://bugs.debian.org/978255
-Forwarded: https://github.com/quintusdias/glymur/pull/523
-Applied-Upstream: https://github.com/quintusdias/glymur/commit/307b06068539962874451d51358700c961edb279
-
---- a/tests/test_jp2k.py
-+++ b/tests/test_jp2k.py
-@@ -26,7 +26,7 @@ from lxml import etree as ET
- import numpy as np
- try:
-     import skimage.data
--    import skimage.measure
-+    import skimage.metrics
-     _HAVE_SCIKIT_IMAGE = True
- except ModuleNotFoundError:
-     _HAVE_SCIKIT_IMAGE = False
-@@ -1307,7 +1307,7 @@ class TestJp2k_write(fixtures.MetadataBa
-             # warning
-             warnings.simplefilter('ignore')
-             psnr = [
--                skimage.measure.compare_psnr(skimage.data.camera(), d[j])
-+                skimage.metrics.peak_signal_noise_ratio(skimage.data.camera(), d[j])
-                 for j in range(4)
-             ]
- 


=====================================
debian/python3-glymur.lintian-overrides
=====================================
@@ -0,0 +1 @@
+repeated-path-segment lib usr/lib/python3/dist-packages/glymur/lib/


=====================================
debian/source/lintian-overrides
=====================================
@@ -0,0 +1,3 @@
+# the jp2dump is very basic and automatically generated
+# by html2man
+maintainer-manual-page debian/man/jp2dump.1


=====================================
docs/source/conf.py
=====================================
@@ -78,7 +78,7 @@ copyright = '2013-2020, John Evans'
 # The short X.Y version.
 version = '0.9'
 # The full version, including alpha/beta/rc tags.
-release = '0.9.2'
+release = '0.9.3'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


=====================================
docs/source/how_do_i.rst
=====================================
@@ -57,6 +57,30 @@ or::
     >>> jp2[:] = data
 
 
+**********************************************
+... write images using multithreaded encoding?
+**********************************************
+If you have glymur 0.9.2 or higher
+and OpenJPEG 2.4.0 or higher,
+you can make use of OpenJPEG's thread support to speed-up read operations.
+With a puny 2015 macbook, just two cores, and a 5824x10368x3 image, we get::
+
+    >>> import time, numpy as np, glymur
+    >>> data = glymur.Jp2k(glymur.data.nemo())[:]
+    >>> data = np.tile(data, (4, 4, 1))
+    >>> t0 = time.time()
+    >>> glymur.Jp2k('1thread.jp2', data)
+    >>> t1 = time.time()
+    >>> print(f'1 thread:  {(t1 - t0):.3} seconds')
+    12.0 seconds
+    >>> t0 = time.time()
+    >>> glymur.set_option('lib.num_threads', 2)
+    >>> glymur.Jp2k('2threads.jp2', data)
+    >>> t1 = time.time()
+    >>> print(f'2 threads:  {(t1 - t0):.3} seconds')
+    7.24 seconds
+
+
 ************************************************************************
 ... write images with different compression ratios for different layers?
 ************************************************************************
@@ -83,13 +107,13 @@ Values must be increasing, but the last value may be 0 to indicate
 the layer is lossless.  However, the OpenJPEG library will reorder
 the layers to make the first layer lossless, not the last. ::
 
-    >>> import skimage.data, skimage.measure, glymur
+    >>> import skimage.data, skimage.metrics, glymur
     >>> truth = skimage.data.camera()
     >>> jp2 = glymur.Jp2k('myfile.jp2', data=truth, psnr=[30, 40, 50, 0])
     >>> psnr = []
     >>> for layer in range(4):
     ...     jp2.layer = layer
-    ...     psnr.append(skimage.measure.compare_psnr(truth, jp2[:]))
+    ...     psnr.append(skimage.metrics.peak_signal_noise_ratio(truth, jp2[:]))
     >>> print(psnr)
     [inf, 29.028560403833303, 39.206919416670402, 47.593129828702246]
 


=====================================
docs/source/introduction.rst
=====================================
@@ -15,7 +15,7 @@ Glymur will look to use **lxml** when processing boxes with XML content, but can
 fall back upon the standard library's **ElementTree** if **lxml** is not
 available.
 
-The current version of glymur works on Python versions 3.6, 3.7, and 3.8..
+The current version of glymur works on Python versions 3.6, 3.7, 3.8, and 3.9.
 
 For more information about OpenJPEG, please consult http://www.openjpeg.org.
 


=====================================
docs/source/whatsnew/0.9.rst
=====================================
@@ -2,6 +2,14 @@
 Changes in glymur 0.9
 #####################
 
+****************
+Changes in 0.9.3
+****************
+
+    * Qualify on Python 3.9
+    * Qualify on OpenJPEG 2.4.0
+    * Add support for multithreaded writes.
+
 ****************
 Changes in 0.9.2
 ****************


=====================================
glymur/config.py
=====================================
@@ -7,7 +7,6 @@ from ctypes.util import find_library
 import os
 import pathlib
 import platform
-import sys
 import warnings
 
 
@@ -42,11 +41,11 @@ def _determine_full_path(libname):
     Parameters
     ----------
     libname : str
-        Short name for library (openjp2).
+        short name for library (openjp2)
 
     Returns
     -------
-    Path to openjp2 library.
+    path to openjp2 library or None if openjp2 library not found
     """
 
     # A location specified by the glymur configuration file has precedence.
@@ -54,45 +53,19 @@ def _determine_full_path(libname):
     if path is not None:
         return path
 
-    # No joy on configuration file.
-    # Are we using Anaconda?
-    if (
-        'Anaconda' in sys.version
-        or 'Continuum Analytics, Inc.' in sys.version
-        or 'packaged by conda-forge' in sys.version
-    ):
-        # If Anaconda, then openjpeg may have been installed via conda.
-        if platform.system() in ['Linux', 'Darwin']:
-            suffix = '.so' if platform.system() == 'Linux' else '.dylib'
-            basedir = pathlib.Path(sys.executable).parents[1]
-            path = basedir / 'lib' / ('lib' + libname + suffix)
-        elif platform.system() == 'Windows':
-            basedir = pathlib.Path(sys.executable).parents[0]
-            path = basedir / 'Library' / 'bin' / (libname + '.dll')
-
-        return path
-
-    # No joy on config file or Anaconda.
-    # MacPorts?
-    path = pathlib.Path('/opt/local/lib/libopenjp2.dylib')
-    if platform.system() == 'Darwin' and path.exists():
-        return path
-
-    # No joy on config file or Anaconda or macports.
-    # Cygwin?
-    g = pathlib.Path('/usr/bin').glob('cygopenjp2*.dll')
-    try:
-        path = list(g)[0]
-    except IndexError:
-        # If the generator is None... probably not on cygwin.
-        # Try something else.
-        pass
-    else:
-        if platform.system().startswith('CYGWIN') and path.exists():
-            return path
-
-    # No joy on config file, not Anaconda or MacPorts or Cygwin.
-    # Can ctypes find it anyway?
+    # No joy on config file.  Cygwin?  Cygwin is a bit of an odd case.
+    if platform.system().startswith('CYGWIN'):
+        g = pathlib.Path('/usr/bin').glob('cygopenjp2*.dll')
+        try:
+            path = list(g)[0]
+        except IndexError:
+            # openjpeg possibly not installed
+            pass
+        else:
+            if path.exists():
+                return path
+
+    # No joy on config file and not Cygwin.  Can ctypes find it anyway?
     path = find_library(libname)
     if path is not None:
         return pathlib.Path(path)


=====================================
glymur/jp2k.py
=====================================
@@ -750,6 +750,17 @@ class Jp2k(Jp2kBox):
 
             strm = opj2.stream_create_default_file_stream(self.filename,
                                                           False)
+            num_threads = get_option('lib.num_threads')
+            if version.openjpeg_version >= '2.4.0':
+                opj2.codec_set_threads(codec, num_threads)
+            elif num_threads > 1:
+                msg = (
+                    f'Threaded encoding is not supported in library versions '
+                    f'prior to 2.4.0.  Your version is '
+                    f'{version.openjpeg_version}.'
+                )
+                warnings.warn(msg, UserWarning)
+
             stack.callback(opj2.stream_destroy, strm)
 
             opj2.start_compress(codec, image, strm)


=====================================
glymur/lib/openjp2.py
=====================================
@@ -1341,7 +1341,7 @@ def stream_destroy(stream):
     OPENJP2.opj_stream_destroy(stream)
 
 
-def write_tile(codec, tile_index, data, data_size, stream):
+def write_tile(codec, tile_index, data, *pargs):
     """Wraps openjp2 library function opj_write_tile.
 
     Write a tile into an image.
@@ -1354,8 +1354,8 @@ def write_tile(codec, tile_index, data, data_size, stream):
         The index of the tile to write, zero-indexing assumed
     data : array
         Image data arranged in usual C-order
-    data_size : int
-        Size of a tile in bytes
+    data_size : int, optional
+        Size of a tile in bytes.  If not provided, it will be inferred.
     stream : STREAM_TYPE_P
         The stream to write data to
 
@@ -1364,6 +1364,14 @@ def write_tile(codec, tile_index, data, data_size, stream):
     RuntimeError
         If the OpenJPEG library routine opj_write_tile fails.
     """
+    if len(pargs) == 2:
+        # old signature
+        data_size, stream = pargs
+    else:
+        # new signature
+        data_size = data.nbytes
+        stream = pargs[0]
+
     OPENJP2.opj_write_tile.argtypes = [CODEC_TYPE,
                                        ctypes.c_uint32,
                                        ctypes.POINTER(ctypes.c_uint8),


=====================================
glymur/version.py
=====================================
@@ -20,7 +20,7 @@ from .lib import openjp2 as opj2
 
 # Do not change the format of this next line!  Doing so risks breaking
 # setup.py
-version = "0.9.2"
+version = "0.9.3"
 _sv = LooseVersion(version)
 version_tuple = _sv.version
 


=====================================
setup.py
=====================================
@@ -27,6 +27,7 @@ kwargs['classifiers'] = [
     "Programming Language :: Python :: 3.6",
     "Programming Language :: Python :: 3.7",
     "Programming Language :: Python :: 3.8",
+    "Programming Language :: Python :: 3.9",
     "Programming Language :: Python :: Implementation :: CPython",
     "License :: OSI Approved :: MIT License",
     "Development Status :: 5 - Production/Stable",


=====================================
tests/test_config.py
=====================================
@@ -3,11 +3,10 @@ OPENJP2 may be present in some form or other.
 """
 # Standard library imports ...
 import contextlib
-import imp
+import importlib
 import os
 import pathlib
 import platform
-import sys
 import unittest
 from unittest.mock import patch
 import warnings
@@ -59,62 +58,9 @@ class TestSuitePathToLibrary(fixtures.TestCommon):
         """
         super(TestSuitePathToLibrary, self).tearDown()
 
-        imp.reload(glymur)
-        imp.reload(glymur.lib.openjp2)
+        importlib.reload(glymur)
+        importlib.reload(glymur.lib.openjp2)
 
-    @patch('glymur.config.platform.system')
-    @patch('glymur.config.sys.version', 'Anaconda')
-    @patch('glymur.config.sys.executable', '/opt/anaconda/bin/python')
-    def test_anaconda_on_mac(self, mock_platform_system):
-        """
-        SCENARIO:  the platform is Anaconda on mac.
-
-        EXPECTED RESULT:  the path of the openjp2 library is under the anaconda
-        root.
-        """
-        mock_platform_system.return_value = 'Darwin'
-
-        actual = glymur.config._determine_full_path('openjp2')
-        expected = pathlib.Path('/opt/anaconda/lib/libopenjp2.dylib')
-
-        self.assertEqual(actual, expected)
-
-    @unittest.skipIf(platform.system() == 'Windows', 'nonsensical on windows')
-    @patch('glymur.config.platform.system')
-    @patch('glymur.config.sys.version', 'Anaconda')
-    @patch('glymur.config.sys.executable', '/usr/bin/python')
-    def test_windows_path(self, mock_platform_system):
-        """
-        SCENARIO:  the platform is Anaconda on windows, even though we are not
-        actually running on windows.
-
-        EXPECTED RESULT:  the path of the openjp2 library is an Anaconda DLL
-        """
-        mock_platform_system.return_value = 'Windows'
-
-        actual = glymur.config._determine_full_path('openjp2')
-        expected = pathlib.Path('/usr/bin/Library/bin/openjp2.dll')
-
-        self.assertEqual(actual, expected)
-
-    @patch('pathlib.Path.exists')
-    @patch('glymur.config.sys.version', 'not anaconda')
-    @patch('glymur.config.platform.system')
-    def test_macports(self, mock_platform_system, mock_path_exists):
-        """
-        SCENARIO:  the platform is MacPorts.
-
-        EXPECTED RESULT:  the path of the openjp2 library is in /opt/local
-        """
-        mock_platform_system.return_value = 'Darwin'
-        mock_path_exists.return_value = True
-
-        actual = glymur.config._determine_full_path('openjp2')
-        expected = pathlib.Path('/opt/local/lib/libopenjp2.dylib')
-
-        self.assertEqual(actual, expected)
-
-    @patch('glymur.config.sys.version', 'not anaconda')
     @patch('glymur.config.find_library')
     @patch('glymur.config.platform.system')
     def test_via_ctypes(self, mock_platform_system, mock_find_library):
@@ -142,7 +88,6 @@ class TestSuite(fixtures.TestCommon):
     problem in CI environments, just development environments.
     """
 
-    @patch('glymur.config.sys.version', 'not anaconda')
     @patch('glymur.config.find_library')
     @patch('glymur.config.platform.system')
     def test_not_via_ctypes(self,
@@ -243,8 +188,8 @@ class TestSuiteConfigFile(fixtures.TestCommon):
         """
         super(TestSuiteConfigFile, self).tearDown()
 
-        imp.reload(glymur)
-        imp.reload(glymur.lib.openjp2)
+        importlib.reload(glymur)
+        importlib.reload(glymur.lib.openjp2)
 
     def test_config_file_via_environ(self):
         """
@@ -263,7 +208,7 @@ class TestSuiteConfigFile(fixtures.TestCommon):
 
         new = {'XDG_CONFIG_HOME': str(self.config_root)}
         with patch.dict('os.environ', new):
-            imp.reload(glymur.lib.openjp2)
+            importlib.reload(glymur.lib.openjp2)
             Jp2k(self.jp2file)
 
     def test_config_file_without_library_section(self):
@@ -279,7 +224,7 @@ class TestSuiteConfigFile(fixtures.TestCommon):
 
         new = {'XDG_CONFIG_HOME': str(self.config_root)}
         with patch.dict('os.environ', new):
-            imp.reload(glymur.lib.openjp2)
+            importlib.reload(glymur.lib.openjp2)
             # It's enough that we did not error out
             self.assertTrue(True)
 
@@ -294,37 +239,26 @@ class TestSuiteConfigFile(fixtures.TestCommon):
 
         new = {'XDG_CONFIG_HOME': str(self.config_root)}
         with patch.dict('os.environ', new):
-            imp.reload(glymur.lib.openjp2)
+            importlib.reload(glymur.lib.openjp2)
             self.assertIsNotNone(glymur.lib.openjp2.OPENJP2)
 
-    @unittest.skipIf(platform.system() == 'Windows',
-                     'Symlinks require elevated privs on Windows, GH#505')
-    @unittest.skipIf(platform.system() == 'Linux' and sys.prefix == '/usr',
-                     'Difficult to run on Linux unless Anaconda, GH#496')
     def test_config_file_in_current_directory(self):
         """
         SCENARIO:  A configuration file exists in the current directory.
 
-        EXPECTED RESULT:  openjp2 library is loaded normally.
+        EXPECTED RESULT:  the path to the specified openjp2 library is returned
         """
-        existing_library = glymur.lib.openjp2.OPENJP2._name
-
-        # Make a soft link from a fake library directory to the existing
-        # location.
         new_lib_dir = self.test_dir_path / 'lib'
         new_lib_dir.mkdir()
 
-        new_library_path = new_lib_dir / 'libopenjp2.dylib'
-        new_library_path.symlink_to(existing_library)
+        expected = new_lib_dir / 'libopenjp2.dylib'
 
         with self.config_file.open('wt') as f:
             f.write('[library]\n')
-            f.write(f'openjp2: {new_library_path}\n')
+            f.write(f'openjp2: {expected}\n')
 
         with chdir(self.glymur_configdir):
             # Should be able to load openjp2 as before.
-            imp.reload(glymur.lib.openjp2)
+            actual = glymur.config.read_config_file('openjp2')
 
-        actual = glymur.lib.openjp2.OPENJP2._name
-        expected = new_library_path
         self.assertEqual(actual, expected)


=====================================
tests/test_jp2k.py
=====================================
@@ -26,7 +26,7 @@ from lxml import etree as ET
 import numpy as np
 try:
     import skimage.data
-    import skimage.measure
+    import skimage.metrics
     _HAVE_SCIKIT_IMAGE = True
 except ModuleNotFoundError:
     _HAVE_SCIKIT_IMAGE = False
@@ -1104,6 +1104,7 @@ class TestJp2k(fixtures.TestCommon):
 
         self.assertEqual(j.layer, 0)
 
+    @unittest.skipIf(os.cpu_count() < 4, "makes no sense if 4 cores not there")
     def test_thread_support(self):
         """
         SCENARIO:  Set a non-default thread support value.
@@ -1124,6 +1125,7 @@ class TestJp2k(fixtures.TestCommon):
 
         self.assertTrue(delta1 < delta0)
 
+    @unittest.skipIf(os.cpu_count() < 4, "makes no sense if 4 cores not there")
     def test_thread_support_on_openjpeg_lt_220(self):
         """
         SCENARIO:  Set number of threads on openjpeg < 2.2.0
@@ -1134,6 +1136,7 @@ class TestJp2k(fixtures.TestCommon):
             with self.assertRaises(RuntimeError):
                 glymur.set_option('lib.num_threads', 4)
 
+    @unittest.skipIf(os.cpu_count() < 4, "makes no sense if 4 cores not there")
     @patch('glymur.lib.openjp2.has_thread_support')
     def test_thread_support_not_compiled_into_library(self, mock_ts):
         """
@@ -1226,6 +1229,24 @@ class TestJp2k_write(fixtures.MetadataBase):
         os.unlink(cls.single_channel_j2k)
         os.unlink(cls.single_channel_jp2)
 
+    @unittest.skipIf(os.cpu_count() < 2, "makes no sense if 2 cores not there")
+    def test_threads(self):
+        """
+        SCENARIO:  Attempt to encode with threading support.  This feature is
+        new as of openjpeg library version 2.4.0.
+
+        EXPECTED RESULT:  In library versions prior to 2.4.0, a warning is
+        issued.
+        """
+        glymur.set_option('lib.num_threads', 2)
+        with open(self.temp_jp2_filename, mode='wb') as tfile:
+            with warnings.catch_warnings(record=True) as w:
+                Jp2k(tfile.name, data=self.jp2_data)
+                if glymur.version.openjpeg_version >= '2.4.0':
+                    self.assertEqual(len(w), 0)
+                else:
+                    self.assertEqual(len(w), 1)
+
     def test_no_jp2c_box_in_outermost_jp2_list(self):
         """
         SCENARIO:  A JP2 file is encountered without a JP2C box in the outer-
@@ -1307,7 +1328,9 @@ class TestJp2k_write(fixtures.MetadataBase):
             # warning
             warnings.simplefilter('ignore')
             psnr = [
-                skimage.measure.compare_psnr(skimage.data.camera(), d[j])
+                skimage.metrics.peak_signal_noise_ratio(
+                    skimage.data.camera(), d[j]
+                )
                 for j in range(4)
             ]
 
@@ -2343,9 +2366,22 @@ class TestReadArea(unittest.TestCase):
         self.assertEqual(ssdata.shape, (1, 1, 3))
 
     def test_NR_DEC_p1_06_j2k_75_decode(self):
-        # Image size would be 0 x 0.
-        with self.assertRaises(InvalidJp2kError):
-            self.j2k[9:12:4, 9:12:4]
+        """
+        SCENARIO:  Try to read an image area with an impossible stride.
+
+        EXPECTED RESULT:  An error is raised.
+        """
+        if glymur.version.openjpeg_version >= '2.4.0':
+            # The library catches this on its own.
+            expected_error = glymur.lib.openjp2.OpenJPEGLibraryError
+        else:
+            # Image size would be 0 x 0.  We have to manually detect this.
+            expected_error = InvalidJp2kError
+        with self.assertRaises(expected_error):
+            with warnings.catch_warnings():
+                # Only openjpeg 2.4.0 issues warnings
+                warnings.simplefilter('ignore')
+                self.j2k[9:12:4, 9:12:4]
 
     def test_NR_DEC_p0_04_j2k_85_decode(self):
         actual = self.j2k[:256, :256]


=====================================
tests/test_openjp2.py
=====================================
@@ -175,6 +175,12 @@ class TestOpenJP2(fixtures.TestCommon):
         xtx5_setup(filename)
         self.assertTrue(True)
 
+    def test_tte5_short_write_tile_signature(self):
+        """Runs test designated tte5 in OpenJPEG test suite."""
+        filename = str(self.temp_j2k_filename)
+        xtx5_setup(filename, short_sig=True)
+        self.assertTrue(True)
+
 
 def tile_encoder(**kwargs):
     """Fixture used by many tests."""
@@ -243,7 +249,10 @@ def tile_encoder(**kwargs):
     openjp2.start_compress(codec, l_image, stream)
 
     for j in np.arange(num_tiles):
-        openjp2.write_tile(codec, j, data, tile_size, stream)
+        if 'short_sig' in kwargs and kwargs['short_sig']:
+            openjp2.write_tile(codec, j, data, stream)
+        else:
+            openjp2.write_tile(codec, j, data, tile_size, stream)
 
     openjp2.end_compress(codec, stream)
     openjp2.stream_destroy(stream)
@@ -352,17 +361,20 @@ def xtx4_setup(filename):
     tile_encoder(**kwargs)
 
 
-def xtx5_setup(filename):
+def xtx5_setup(filename, short_sig=False):
     """Runs tests rta5, tte5."""
-    kwargs = {'filename': filename,
-              'codec': openjp2.CODEC_J2K,
-              'comp_prec': 8,
-              'irreversible': 0,
-              'num_comps': 1,
-              'image_height': 512,
-              'image_width': 512,
-              'tile_height': 256,
-              'tile_width': 256}
+    kwargs = {
+        'filename': filename,
+        'codec': openjp2.CODEC_J2K,
+        'comp_prec': 8,
+        'irreversible': 0,
+        'num_comps': 1,
+        'image_height': 512,
+        'image_width': 512,
+        'tile_height': 256,
+        'tile_width': 256,
+        'short_sig': short_sig
+    }
     tile_encoder(**kwargs)
 
 


=====================================
tests/test_printing.py
=====================================
@@ -1667,8 +1667,9 @@ class TestJp2dump(unittest.TestCase):
             '''    sgnd: 0\n'''
             '''    resno_decoded: 0\n'''
             '''    factor: 0\n'''
-            '''    data: <glymur.lib.openjp2.LP_c_(int|long) object at '''
-            '''0x[a-fA-F0-9]+>\n'''
+            '''    data: '''
+            '''<(glymur.lib.openjp2|ctypes.wintypes).LP_c_(int|long) '''
+            '''object at 0x[a-fA-F0-9]+>\n'''
             '''    alpha: 0\n'''
         )
         self.assertRegex(actual, expected)



View it on GitLab: https://salsa.debian.org/debian-gis-team/glymur/-/compare/77722251d6738fe888de826ad975f09bc7e2e80a...01604c6132aa5938dd3d5636aabed190cb7000aa

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/glymur/-/compare/77722251d6738fe888de826ad975f09bc7e2e80a...01604c6132aa5938dd3d5636aabed190cb7000aa
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/20210109/ca6de464/attachment-0001.html>


More information about the Pkg-grass-devel mailing list