Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions openjpeg/_openjpeg.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ def encode_array(
"Only one of 'compression_ratios' or 'signal_noise_ratios' is "
"allowed when performing lossy compression"
)
if len(compression_ratios) > 10 or len(signal_noise_ratios) > 10:
raise ValueError("More than 10 compression layers is not supported")
if len(compression_ratios) > 100 or len(signal_noise_ratios) > 100:
raise ValueError("More than 100 compression layers is not supported")

# The destination for the encoded J2K codestream, needs to support BinaryIO
dst = BytesIO()
Expand Down Expand Up @@ -449,8 +449,8 @@ def encode_buffer(
"Only one of 'compression_ratios' or 'signal_noise_ratios' is "
"allowed when performing lossy compression"
)
if len(compression_ratios) > 10 or len(signal_noise_ratios) > 10:
raise ValueError("More than 10 compression layers is not supported")
if len(compression_ratios) > 100 or len(signal_noise_ratios) > 100:
raise ValueError("More than 100 compression layers is not supported")

dst = BytesIO()
return_code = EncodeBuffer(
Expand Down
16 changes: 8 additions & 8 deletions openjpeg/tests/test_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ def test_invalid_photometric_raises(self):

def test_invalid_compression_ratios_raises(self):
"""Test an invalid 'compression_ratios' raises exceptions."""
msg = "More than 10 compression layers is not supported"
msg = "More than 100 compression layers is not supported"
with pytest.raises(ValueError, match=msg):
encode_array(np.ones((1, 2), dtype="u1"), compression_ratios=[1] * 11)
encode_array(np.ones((1, 2), dtype="u1"), compression_ratios=[1] * 101)

msg = (
"Error encoding the data: invalid compression ratio, lowest value "
Expand All @@ -232,9 +232,9 @@ def test_invalid_compression_ratios_raises(self):

def test_invalid_signal_noise_ratios_raises(self):
"""Test an invalid 'signal_noise_ratios' raises exceptions."""
msg = "More than 10 compression layers is not supported"
msg = "More than 100 compression layers is not supported"
with pytest.raises(ValueError, match=msg):
encode_array(np.ones((1, 2), dtype="u1"), signal_noise_ratios=[1] * 11)
encode_array(np.ones((1, 2), dtype="u1"), signal_noise_ratios=[1] * 101)

msg = (
"Error encoding the data: invalid signal-to-noise ratio, lowest "
Expand Down Expand Up @@ -802,9 +802,9 @@ def test_compression_snr_raises(self):

def test_invalid_compression_ratios_raises(self):
"""Test an invalid 'compression_ratios' raises exceptions."""
msg = "More than 10 compression layers is not supported"
msg = "More than 100 compression layers is not supported"
with pytest.raises(ValueError, match=msg):
encode_buffer(b"\x00", 1, 1, 1, 8, False, compression_ratios=[1] * 11)
encode_buffer(b"\x00", 1, 1, 1, 8, False, compression_ratios=[1] * 101)

msg = (
"Error encoding the data: invalid compression ratio, lowest value "
Expand All @@ -815,9 +815,9 @@ def test_invalid_compression_ratios_raises(self):

def test_invalid_signal_noise_ratios_raises(self):
"""Test an invalid 'signal_noise_ratios' raises exceptions."""
msg = "More than 10 compression layers is not supported"
msg = "More than 100 compression layers is not supported"
with pytest.raises(ValueError, match=msg):
encode_buffer(b"\x00", 1, 1, 1, 8, False, signal_noise_ratios=[1] * 11)
encode_buffer(b"\x00", 1, 1, 1, 8, False, signal_noise_ratios=[1] * 101)

msg = (
"Error encoding the data: invalid signal-to-noise ratio, lowest "
Expand Down