Removed OPENJP2_IS_V2_OFFICIAL token. #224
This can be done by a regular expression against the library version. It had not been done because much of the original development was against the svn 2.0+ version of openjpeg before the library version got bumped to 2.1
This commit is contained in:
parent
346ae47b10
commit
e4578db535
7 changed files with 28 additions and 41 deletions
|
|
@ -167,7 +167,7 @@ class Jp2k(Jp2kBox):
|
|||
fps : int
|
||||
Frames per second, should be either 24 or 48.
|
||||
"""
|
||||
if re.match("(1.5|2.0)", version.openjpeg_version) is not None:
|
||||
if re.match("(1.5|2.0.0)", version.openjpeg_version) is not None:
|
||||
msg = "Writing Cinema2K or Cinema4K files is not supported with "
|
||||
msg += 'openjpeg library versions less than 2.0.1.'
|
||||
raise IOError(msg)
|
||||
|
|
@ -1687,7 +1687,7 @@ def _validate_compression_params(img_array, cparams):
|
|||
msg = "{0}D imagery is not allowed.".format(img_array.ndim)
|
||||
raise IOError(msg)
|
||||
|
||||
if re.match("2.0", version.openjpeg_version) is not None:
|
||||
if re.match("2.0.0", version.openjpeg_version) is not None:
|
||||
if (((img_array.ndim != 2) and
|
||||
(img_array.shape[2] != 1 and img_array.shape[2] != 3))):
|
||||
msg = "Writing images is restricted to single-channel "
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ Tests for libopenjp2 wrapping functions.
|
|||
# pylint: disable=R0904,W0142
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
|
@ -15,17 +16,13 @@ import numpy as np
|
|||
import glymur
|
||||
from glymur.lib import openjp2
|
||||
|
||||
OPENJP2_IS_V2_OFFICIAL = False
|
||||
if openjp2.OPENJP2 is not None:
|
||||
if not hasattr(openjp2.OPENJP2,
|
||||
'opj_stream_create_default_file_stream_v3'):
|
||||
OPENJP2_IS_V2_OFFICIAL = True
|
||||
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
@unittest.skipIf(openjp2.OPENJP2 is None,
|
||||
"Missing openjp2 library.")
|
||||
@unittest.skipIf(OPENJP2_IS_V2_OFFICIAL, "API followed here specific to V2.0+")
|
||||
@unittest.skipIf(re.match(r'''(1|2.0)''',
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Not to be run until 2.1.0")
|
||||
class TestOpenJP2(unittest.TestCase):
|
||||
"""Test openjp2 library functionality.
|
||||
|
||||
|
|
|
|||
|
|
@ -25,14 +25,6 @@ try:
|
|||
except:
|
||||
HAS_PYTHON_XMP_TOOLKIT = False
|
||||
|
||||
# Need to know of the libopenjp2 version is the official 2.0.0 release and NOT
|
||||
# the 2.0+ development version.
|
||||
OPENJP2_IS_V2_OFFICIAL = False
|
||||
if glymur.lib.openjp2.OPENJP2 is not None:
|
||||
if not hasattr(glymur.lib.openjp2.OPENJP2,
|
||||
'opj_stream_create_default_file_stream_v3'):
|
||||
OPENJP2_IS_V2_OFFICIAL = True
|
||||
|
||||
|
||||
NO_READ_BACKEND_MSG = "Matplotlib with the PIL backend must be available in "
|
||||
NO_READ_BACKEND_MSG += "order to run the tests in this suite."
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ from glymur.jp2box import JPEG2000SignatureBox
|
|||
from glymur.core import COLOR, OPACITY
|
||||
from glymur.core import RED, GREEN, BLUE, GREY, WHOLE_IMAGE
|
||||
|
||||
from .fixtures import OPENJP2_IS_V2_OFFICIAL, opj_data_file
|
||||
from .fixtures import opj_data_file
|
||||
|
||||
try:
|
||||
FORMAT_CORPUS_DATA_ROOT = os.environ['FORMAT_CORPUS_DATA_ROOT']
|
||||
|
|
@ -117,9 +117,9 @@ class TestDataEntryURL(unittest.TestCase):
|
|||
self.assertEqual(url + chr(0), read_url)
|
||||
|
||||
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] < 2 or
|
||||
OPENJP2_IS_V2_OFFICIAL,
|
||||
"Not supported until 2.0+.")
|
||||
@unittest.skipIf(re.match(r'''(1|2.0.0)''',
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Not supported until 2.1")
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
class TestChannelDefinition(unittest.TestCase):
|
||||
"""Test suite for channel definition boxes."""
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import pkg_resources
|
|||
import glymur
|
||||
from glymur import Jp2k
|
||||
|
||||
from .fixtures import HAS_PYTHON_XMP_TOOLKIT, OPENJP2_IS_V2_OFFICIAL
|
||||
from .fixtures import HAS_PYTHON_XMP_TOOLKIT
|
||||
if HAS_PYTHON_XMP_TOOLKIT:
|
||||
import libxmp
|
||||
from libxmp import XMPMeta
|
||||
|
|
@ -379,10 +379,9 @@ class TestJp2k(unittest.TestCase):
|
|||
creator_tool = xmp.get_property(libxmp.consts.XMP_NS_XMP, 'CreatorTool')
|
||||
self.assertEqual(creator_tool, 'Google')
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJP2_IS_V2_OFFICIAL,
|
||||
"Feature not supported in 2.0.0 official")
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1,
|
||||
"Feature not supported in 1.5")
|
||||
@unittest.skipIf(re.match(r'''(1|2.0.0)''',
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Not supported until 2.0.1")
|
||||
def test_jpx_mult_codestreams_jp2_brand(self):
|
||||
"""Read JPX codestream when jp2-compatible."""
|
||||
# The file in question has multiple codestreams.
|
||||
|
|
@ -581,7 +580,8 @@ class TestJp2k_1_x(unittest.TestCase):
|
|||
j2k.read(layer=1)
|
||||
|
||||
|
||||
@unittest.skipIf(not OPENJP2_IS_V2_OFFICIAL,
|
||||
@unittest.skipIf(re.match(r'''2.0.0''',
|
||||
glymur.version.openjpeg_version) is None,
|
||||
"Tests only to be run on 2.0 official.")
|
||||
class TestJp2k_2_0_official(unittest.TestCase):
|
||||
"""Test suite to only be run on v2.0 official."""
|
||||
|
|
@ -679,9 +679,9 @@ class TestJp2k_2_0(unittest.TestCase):
|
|||
self.assertEqual(jasoc.box[3].box[1].box_id, 'xml ')
|
||||
|
||||
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] < 2 or
|
||||
OPENJP2_IS_V2_OFFICIAL,
|
||||
"Missing openjp2 library version 2.0+.")
|
||||
@unittest.skipIf(re.match(r'''(1|2.0.0)''',
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Not to be run until unless 2.0.1 or higher is present")
|
||||
class TestJp2k_2_1(unittest.TestCase):
|
||||
"""Only to be run in 2.0+."""
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import numpy as np
|
|||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
||||
from .fixtures import OPENJP2_IS_V2_OFFICIAL, OPJ_DATA_ROOT
|
||||
from .fixtures import OPJ_DATA_ROOT
|
||||
from .fixtures import mse, peak_tolerance, read_pgx, opj_data_file
|
||||
|
||||
|
||||
|
|
@ -6599,10 +6599,9 @@ class TestSuite2point0(unittest.TestCase):
|
|||
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
@unittest.skipIf(OPENJP2_IS_V2_OFFICIAL,
|
||||
"Test not in done in v2.0.0 official")
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1,
|
||||
"Tests not introduced until 2.1")
|
||||
@unittest.skipIf(re.match(r'''(1|2.0.0)''',
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Only supported in 2.0.1 or higher")
|
||||
class TestSuite2point1(unittest.TestCase):
|
||||
"""Runs tests introduced in version 2.0+ or that pass only in 2.0+"""
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,9 @@ import glymur
|
|||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
@unittest.skipIf(os.name == "nt", "no write support on windows, period")
|
||||
@unittest.skipIf(fixtures.OPENJP2_IS_V2_OFFICIAL,
|
||||
"Feature not supported in 2.0.0 official")
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1,
|
||||
"Feature not supported in 1.5")
|
||||
@unittest.skipIf(re.match(r'''(1|2.0.0)''',
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Uses features not supported until 2.0.1")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteWriteCinema(unittest.TestCase):
|
||||
|
|
@ -225,8 +224,8 @@ class TestSuiteWriteCinema(unittest.TestCase):
|
|||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
@unittest.skipIf(not re.match("(1.5|2.0)", glymur.version.openjpeg_version),
|
||||
"Functionality implemented for 2.1")
|
||||
@unittest.skipIf(not re.match("(1.5|2.0.0)", glymur.version.openjpeg_version),
|
||||
"Functionality implemented for 2.0.1")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteNegative2pointzero(unittest.TestCase):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue