diff --git a/glymur/jp2k.py b/glymur/jp2k.py index 1d751e0..897d6a6 100644 --- a/glymur/jp2k.py +++ b/glymur/jp2k.py @@ -187,8 +187,9 @@ class Jp2k(Jp2kBox): msg += "profile if the file type box brand is 'jp2 '." warnings.warn(msg) - def _validate_write_parameters(self, img_array, code_block_size, precinct_sizes, cratios, - psnr, mct, colorspace, codec_fmt): + def _validate_write_parameters(self, img_array, code_block_size, + precinct_sizes, cratios, psnr, mct, + colorspace, codec_fmt): """Check that the input parameters to the write function are valid. Parameters @@ -250,7 +251,7 @@ class Jp2k(Jp2kBox): raise IOError(msg) if _OPENJP2_IS_OFFICIAL_V2: - if (((img_array.ndim != 2) and + 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 " msg += "greyscale images or three-channel RGB images when " @@ -274,7 +275,6 @@ class Jp2k(Jp2kBox): msg = "Only uint8 and uint16 images are currently supported." raise RuntimeError(msg) - # pylint: disable-msg=W0221 def write(self, img_array, cratios=None, eph=False, psnr=None, numres=None, cbsize=None, psizes=None, grid_offset=None, sop=False, diff --git a/glymur/lib/c.py b/glymur/lib/c.py index 7ae9fd6..984adc5 100644 --- a/glymur/lib/c.py +++ b/glymur/lib/c.py @@ -8,6 +8,7 @@ import ctypes.util libc_path = ctypes.util.find_library('c') C_LIB = ctypes.CDLL(libc_path) + def fopen(filename, mode): """Opens the file with the specified mode. @@ -29,6 +30,7 @@ def fopen(filename, mode): ctypes.c_char_p(mode.encode())) return fptr + def fclose(fptr): """Closes a file stream. @@ -42,4 +44,3 @@ def fclose(fptr): status = C_LIB.fclose(fptr) if status != 0: raise IOError("Unable to close file.") - diff --git a/glymur/lib/config.py b/glymur/lib/config.py index 764934e..bbdb056 100644 --- a/glymur/lib/config.py +++ b/glymur/lib/config.py @@ -145,7 +145,7 @@ def get_configdir(): if 'HOME' in os.environ and os.name != 'nt': # HOME is set by WinPython to something unusual, so we don't - # necessarily want that. + # necessarily want that. return os.path.join(os.environ['HOME'], '.config', 'glymur') # Last stand. Should handle windows... others? diff --git a/glymur/lib/openjp2.py b/glymur/lib/openjp2.py index a92a231..66a3cba 100644 --- a/glymur/lib/openjp2.py +++ b/glymur/lib/openjp2.py @@ -1384,6 +1384,7 @@ def set_error_message(msg): global ERROR_MSG_LST ERROR_MSG_LST.append(msg) + def version(): """Wrapper for opj_version library routine.""" OPENJP2.opj_version.restype = ctypes.c_char_p @@ -1392,4 +1393,3 @@ def version(): return library_version.decode('utf-8') else: return library_version - diff --git a/glymur/lib/test/test_openjp2.py b/glymur/lib/test/test_openjp2.py index 00404bd..710f265 100644 --- a/glymur/lib/test/test_openjp2.py +++ b/glymur/lib/test/test_openjp2.py @@ -16,10 +16,12 @@ import numpy as np import glymur -OPENJP2_IS_V2_OFFICIAL=False +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 + if not hasattr(glymur.lib.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(glymur.lib.openjp2.OPENJP2 is None, diff --git a/glymur/test/fixtures.py b/glymur/test/fixtures.py index 54710ef..3e5cfbb 100644 --- a/glymur/test/fixtures.py +++ b/glymur/test/fixtures.py @@ -5,10 +5,11 @@ import numpy as np import glymur -OPENJP2_IS_V2_OFFICIAL=False +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 + if not hasattr(glymur.lib.openjp2.OPENJP2, + 'opj_stream_create_default_file_stream_v3'): + OPENJP2_IS_V2_OFFICIAL = True def mse(amat, bmat): diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index 7091920..b42e033 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -30,10 +30,7 @@ import numpy as np from glymur import Jp2k import glymur -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 +from .fixtures import OPENJP2_IS_V2_OFFICIAL from .fixtures import *