From e165edbe53be3fb2024d33a739fb641bfe56b01e Mon Sep 17 00:00:00 2001 From: John Evans Date: Fri, 21 Nov 2014 10:21:55 -0500 Subject: [PATCH] progress --- docs/source/how_do_i.rst | 7 ++----- glymur/test/test_jp2k.py | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/source/how_do_i.rst b/docs/source/how_do_i.rst index 65647fa..8a62b32 100644 --- a/docs/source/how_do_i.rst +++ b/docs/source/how_do_i.rst @@ -14,15 +14,12 @@ retrieve a full resolution and first lower-resolution image :: >>> jp2file = glymur.data.nemo() # just a path to a JPEG2000 file >>> jp2 = glymur.Jp2k(jp2file) >>> fullres = jp2[:] - >>> print(fullres.shape) + >>> fullres.shape (1456, 2592, 3) >>> thumbnail = jp2[::2, ::2] - >>> print(thumbnail.shape) + >>> thumbnail.shape (728, 1296, 3) -The :py:meth:`read` method exposes many more options for other JPEG 2000 -features such as quality layers. - ... write images? ================= It's pretty simple, just supply the image data as the 2nd argument to the Jp2k diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index 99e655f..b903dda 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -345,11 +345,24 @@ class TestJp2k(unittest.TestCase): self.assertEqual(newjp2.filename, self.j2kfile) self.assertEqual(len(newjp2.box), 0) - @unittest.skip("see issue 302") - def test_rlevel_max(self): - """Verify that rlevel=-1 gets us the lowest resolution image""" + @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) + def test_rlevel_max_backwards_compatibility(self): + """ + Verify that rlevel=-1 gets us the lowest resolution image + + This is an old option only available via the read method, not via + array-style slicing. + """ j = Jp2k(self.j2kfile) - thumbnail1 = j.read(rlevel=-1) + if sys.hexversion < 0x03000000: + with warnings.catch_warnings(): + # Suppress a warning due to deprecated syntax + # Not as easy to verify the warning under python2. + warnings.simplefilter("ignore") + thumbnail1 = j.read(rlevel=-1) + else: + with self.assertWarns(DeprecationWarning): + thumbnail1 = j.read(rlevel=-1) thumbnail2 = j[::32, ::32] np.testing.assert_array_equal(thumbnail1, thumbnail2) self.assertEqual(thumbnail1.shape, (25, 15, 3))