[Git][debian-gis-team/glymur][master] 4 commits: New upstream version 0.13.1

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Sun Apr 28 10:26:20 BST 2024



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


Commits:
08a9c021 by Antonio Valentino at 2024-04-28T09:12:55+00:00
New upstream version 0.13.1
- - - - -
0ff1e7b9 by Antonio Valentino at 2024-04-28T09:13:04+00:00
Update upstream source from tag 'upstream/0.13.1'

Update to upstream version '0.13.1'
with Debian dir d1d9e2295ef5d18e36efaa587d7bbefa3ab2833c
- - - - -
77da3ceb by Antonio Valentino at 2024-04-28T09:16:01+00:00
New upstream release

- - - - -
1137c2f2 by Antonio Valentino at 2024-04-28T09:16:56+00:00
Set distribution to unstable

- - - - -


13 changed files:

- CHANGES.txt
- debian/changelog
- docs/source/conf.py
- docs/source/whatsnew/0.13.rst
- glymur/jp2box.py
- glymur/jp2kr.py
- glymur/lib/tiff.py
- glymur/version.py
- setup.cfg
- tests/test_jp2k.py
- tests/test_libtiff.py
- tests/test_printing.py
- tests/test_set_decoded_components.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -1,3 +1,7 @@
+Apr 22, 2024 - v0.13.1
+    Remove debugging code
+    Improve code coverage
+
 Apr 19, 2024 - v0.13.0
     Refactor Jp2k class into Jp2k, Jp2kr
     Simplify example file nemo.jp2


=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+glymur (0.13.1-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Antonio Valentino <antonio.valentino at tiscali.it>  Sun, 28 Apr 2024 09:16:40 +0000
+
 glymur (0.13.0-1) unstable; urgency=medium
 
   * New upstream release.


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


=====================================
docs/source/whatsnew/0.13.rst
=====================================
@@ -9,3 +9,11 @@ Changes in 0.13.0
     * Refactor Jp2k class into Jp2kr (just for reading) and Jp2k (reading and writing).  Backwards compatibility should be maintained.
     * Simplify example file nemo.jp2
     * Fix doctests
+
+*****************
+Changes in 0.13.1
+*****************
+
+    * Remove debugging code
+    * Improve code coverage
+


=====================================
glymur/jp2box.py
=====================================
@@ -179,9 +179,6 @@ class Jp2kBox(object):
         Jp2kBox
             Object corresponding to the current box.
         """
-        if fptr.tell() == 1392953:
-            # breakpoint()
-            pass
         try:
             parser = _BOX_WITH_ID[box_id].parse
 


=====================================
glymur/jp2kr.py
=====================================
@@ -915,62 +915,6 @@ class Jp2kr(Jp2kBox):
 
             return codestream
 
-    def _populate_image_struct(
-        self, image, imgdata, tile_x_factor=1, tile_y_factor=1
-    ):
-        """Populates image struct needed for compression.
-
-        Parameters
-        ----------
-        image : ImageType(ctypes.Structure)
-            Corresponds to image_t type in openjp2 headers.
-        imgdata : ndarray
-            Image data to be written to file.
-        tile_x_factor, tile_y_factor: int
-            Used only when writing tile-by-tile.  In this case, the image data
-            that we have is only the size of a single tile.
-        """
-
-        if len(self.shape) < 3:
-            (numrows, numcols), num_comps = self.shape, 1
-        else:
-            numrows, numcols, num_comps = self.shape
-
-        for k in range(num_comps):
-            self._validate_nonzero_image_size(numrows, numcols, k)
-
-        # set image offset and reference grid
-        image.contents.x0 = self._cparams.image_offset_x0
-        image.contents.y0 = self._cparams.image_offset_y0
-        image.contents.x1 = (
-            image.contents.x0
-            + (numcols - 1) * self._cparams.subsampling_dx * tile_x_factor
-            + 1
-        )
-        image.contents.y1 = (
-            image.contents.y0
-            + (numrows - 1) * self._cparams.subsampling_dy * tile_y_factor
-            + 1
-        )
-
-        if tile_x_factor != 1 or tile_y_factor != 1:
-            # don't stage the data if writing tiles
-            return image
-
-        # Stage the image data to the openjpeg data structure.
-        for k in range(0, num_comps):
-            if self._cparams.rsiz in (core.OPJ_PROFILE_CINEMA_2K,
-                                      core.OPJ_PROFILE_CINEMA_4K):
-                image.contents.comps[k].prec = 12
-                image.contents.comps[k].bpp = 12
-
-            layer = np.ascontiguousarray(imgdata[:, :, k], dtype=np.int32)
-            dest = image.contents.comps[k].data
-            src = layer.ctypes.data
-            ctypes.memmove(dest, src, layer.nbytes)
-
-        return image
-
     def _validate_nonzero_image_size(self, nrows, ncols, component_index):
         """The image cannot have area of zero."""
         if nrows == 0 or ncols == 0:


=====================================
glymur/lib/tiff.py
=====================================
@@ -552,24 +552,6 @@ def getVersion():
     return m.group('version')
 
 
-def printDirectory(tiff_fp, ofp, mode=0):
-    """Corresponds to TIFFPrintDirectory
-
-    Parameters
-    ----------
-    filename : path or str
-        Path to TIFF
-    """
-    err_handler, warn_handler = _set_error_warning_handlers()
-
-    ARGTYPES = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_long]
-    _LIBTIFF.TIFFPrintDirectory.argtypes = ARGTYPES
-    _LIBTIFF.TIFFPrintDirectory.restype = ctypes.c_void_p
-    _LIBTIFF.TIFFPrintDirectory(tiff_fp, ofp, mode)
-
-    _reset_error_warning_handlers(err_handler, warn_handler)
-
-
 def open(filename, mode='r'):
     """Corresponds to TIFFOpen
 


=====================================
glymur/version.py
=====================================
@@ -20,7 +20,7 @@ from .lib import tiff
 
 # Do not change the format of this next line!  Doing so risks breaking
 # setup.py
-version = "0.13.0"
+version = "0.13.1"
 
 version_tuple = parse(version).release
 


=====================================
setup.cfg
=====================================
@@ -1,6 +1,6 @@
 [metadata]
 name = Glymur
-version = 0.13.0
+version = 0.13.1
 author = 'John Evans'
 author_email = "John Evans" <jevans667cc at proton.me>
 license = 'MIT'


=====================================
tests/test_jp2k.py
=====================================
@@ -57,6 +57,15 @@ class TestJp2k(fixtures.TestCommon):
         super().setUp()
         glymur.reset_option('all')
 
+    def test_repr(self):
+        """
+        Scenario:  run repr on Jp2k object
+
+        Expected response:  the representation is verified
+        """
+        j = Jp2k(self.j2kfile)
+        self.assertRegex(repr(j), 'glymur.Jp2k(.*?)')
+
     def test_write_using_slicing(self):
         """
         Scenario: write to a file using slicing then read it back


=====================================
tests/test_libtiff.py
=====================================
@@ -79,3 +79,48 @@ class TestSuite(fixtures.TestCommon):
         self.assertEqual(actual_tw, tw)
 
         libtiff.close(fp)
+
+    def test_simple_strip(self):
+        """
+        SCENARIO:  create a simple monochromatic 2 strip image
+
+        Expected result:  The image matches.  The number of tiles checks out.
+        The tile width and height checks out.
+        """
+        data = fixtures.skimage.data.moon()
+        h, w = data.shape
+        rps = h // 2
+
+        fp = libtiff.open(self.temp_tiff_filename, mode='w')
+
+        libtiff.setField(fp, 'Photometric', libtiff.Photometric.MINISBLACK)
+        libtiff.setField(fp, 'Compression', libtiff.Compression.ADOBE_DEFLATE)
+        libtiff.setField(fp, 'ImageLength', data.shape[0])
+        libtiff.setField(fp, 'ImageWidth', data.shape[1])
+        libtiff.setField(fp, 'RowsPerStrip', rps)
+        libtiff.setField(fp, 'BitsPerSample', 8)
+        libtiff.setField(fp, 'SamplesPerPixel', 1)
+        libtiff.setField(fp, 'PlanarConfig', libtiff.PlanarConfig.CONTIG)
+
+        libtiff.writeEncodedStrip(fp, 0, data[:rps, :].copy())
+        libtiff.writeEncodedStrip(fp, 1, data[rps:h, :].copy())
+
+        libtiff.close(fp)
+
+        fp = libtiff.open(self.temp_tiff_filename)
+
+        strip = np.zeros((rps, w), dtype=np.uint8)
+        actual_data = np.zeros((h, w), dtype=np.uint8)
+
+        libtiff.readEncodedStrip(fp, 0, strip)
+        actual_data[:rps, :] = strip
+
+        libtiff.readEncodedStrip(fp, 1, strip)
+        actual_data[rps:h, :] = strip
+
+        np.testing.assert_array_equal(data, actual_data)
+
+        n = libtiff.numberOfStrips(fp)
+        self.assertEqual(n, 2)
+
+        libtiff.close(fp)


=====================================
tests/test_printing.py
=====================================
@@ -21,7 +21,7 @@ import glymur
 from glymur.codestream import LRCP, WAVELET_XFORM_5X3_REVERSIBLE
 from glymur.core import COLOR, RED, GREEN, BLUE, RESTRICTED_ICC_PROFILE
 from glymur.jp2box import BitsPerComponentBox, ColourSpecificationBox
-from glymur.jp2box import LabelBox
+from glymur.jp2box import LabelBox, UUIDBox
 from glymur import Jp2k, command_line
 from glymur.lib import openjp2 as opj2
 from . import fixtures
@@ -1849,3 +1849,64 @@ class TestJp2dump(fixtures.TestCommon):
             '''    alpha: 0\n'''
         )
         self.assertRegex(actual, expected)
+
+    def test_xmp_uuid_short(self):
+        """
+        SCENARIO:  Append an XMP UUID box to an existing JP2 file, print it
+        with the short option.
+
+        EXPECTED RESULT:  strings are validated
+        """
+        the_uuid = UUID('be7acfcb-97a9-42e8-9c71-999491e3afac')
+        raw_data = (
+            ir.files('tests.data')
+              .joinpath('simple_rdf.txt')
+              .read_text()
+              .encode('utf-8')
+        )
+
+        shutil.copyfile(self.jp2file, self.temp_jp2_filename)
+
+        jp2 = Jp2k(self.temp_jp2_filename)
+        ubox = glymur.jp2box.UUIDBox(the_uuid=the_uuid, raw_data=raw_data)
+        jp2.append(ubox)
+
+        glymur.set_option('print.short', True)
+
+        actual = str(jp2.box[-1])
+        expected = 'UUID Box (uuid) @ (1132373, 434)'
+
+        self.assertEqual(actual, expected)
+
+        # now invoke print.xml, answer should be nearly the same.
+        glymur.reset_option('all')
+        glymur.set_option('print.xml', False)
+
+        actual = str(jp2.box[-1])
+        expected = 'UUID Box (uuid) @ (1132373, 434)\n    UUID:  be7acfcb-97a9-42e8-9c71-999491e3afac (XMP)'  # noqa : E501
+
+        self.assertEqual(actual, expected)
+
+    def test__print_malformed_exif_uuid(self):
+        """
+        SCENARIO:  Parse a JpgTiffExif->Jp2 UUID that is not only missing the
+        'EXIF\0\0' lead-in, but even the TIFF header is malformed.  Then print
+        it.
+
+        EXPECTED RESULT:  a UUIDBox string showing that it is invalid
+        """
+        box_data = ir.files('tests.data').joinpath('issue549.dat').read_bytes()
+        bf = BytesIO(box_data[:16] + box_data[20:])
+        with warnings.catch_warnings():
+            warnings.simplefilter("ignore")
+            box = UUIDBox.parse(bf, 0, 37700)
+
+        actual = str(box)
+        expected = [
+            "UUID Box (uuid) @ (0, 37700)",
+            "    UUID:  4a706754-6966-6645-7869-662d3e4a5032 (EXIF)",
+            "    UUID Data:  Invalid Exif UUID",
+        ]
+        expected = '\n'.join(expected)
+
+        self.assertEqual(actual, expected)


=====================================
tests/test_set_decoded_components.py
=====================================
@@ -50,6 +50,7 @@ class TestSuite(unittest.TestCase):
         j2k.decoded_components = 0
         actual = j2k[:]
 
+        self.assertEqual(j2k.decoded_components, [0])
         np.testing.assert_array_equal(actual, expected)
 
         # restore the original configuration



View it on GitLab: https://salsa.debian.org/debian-gis-team/glymur/-/compare/46f01824c9d95cee573c939910b7433eb1905aaf...1137c2f21f0fd7f9608c06dbd40c4887a963de9b

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/glymur/-/compare/46f01824c9d95cee573c939910b7433eb1905aaf...1137c2f21f0fd7f9608c06dbd40c4887a963de9b
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/20240428/21f90c7b/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list