merge branch 'issue281' into devel

This commit is contained in:
John Evans 2014-10-22 09:45:55 -04:00
commit 08ef7846bb
2 changed files with 10 additions and 1 deletions

View file

@ -545,7 +545,8 @@ class Jp2k(Jp2kBox):
raise IOError(msg)
if img_array.dtype != np.uint8 and img_array.dtype != np.uint16:
msg = "Only uint8 and uint16 images are currently supported."
msg = "Only uint8 and uint16 datatypes are currently supported "
msg += "when writing."
raise RuntimeError(msg)
def _determine_colorspace(self, img_array, colorspace=None, **kwargs):

View file

@ -843,6 +843,14 @@ class TestJp2k_write(unittest.TestCase):
def tearDown(self):
pass
def test_unsupported_datatype(self):
"""Should raise a runtime error if trying to write uint32"""
data = np.zeros((128, 128), dtype=np.uint32)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
with self.assertRaises(RuntimeError):
j = Jp2k(tfile.name, 'wb')
j.write(data)
def test_write_with_version_too_early(self):
"""Should raise a runtime error if trying to write with version 1.3"""
data = np.zeros((128, 128), dtype=np.uint8)