diff --git a/src/ctapipe/calib/camera/extractor.py b/src/ctapipe/calib/camera/extractor.py index f669df82e34..6462fc31b70 100644 --- a/src/ctapipe/calib/camera/extractor.py +++ b/src/ctapipe/calib/camera/extractor.py @@ -72,7 +72,7 @@ def __call__( f"The length of the provided table ({len(table)}) is insufficient to meet the required statistics for a single extraction chunk of size ({self.chunk_size})." ) # Check if the chunk_shift is smaller than the chunk_size - if chunk_shift is None and chunk_shift > self.chunk_size: + if chunk_shift is not None and chunk_shift > self.chunk_size: raise ValueError( f"The chunk_shift ({chunk_shift}) must be smaller than the chunk_size ({self.chunk_size})." ) diff --git a/src/ctapipe/calib/camera/tests/test_extractor.py b/src/ctapipe/calib/camera/tests/test_extractor.py index 2c777934088..63df2d5bab6 100644 --- a/src/ctapipe/calib/camera/tests/test_extractor.py +++ b/src/ctapipe/calib/camera/tests/test_extractor.py @@ -3,6 +3,7 @@ """ import numpy as np +import pytest from astropy.table import Table from astropy.time import Time @@ -83,3 +84,9 @@ def test_check_chunk_shift(example_subarray): assert len(chunk_stats) == 3 # Check if two chunks are used for the extraction as the last chunk is dropped assert len(chunk_stats_shift) == 2 + # Check if ValueError is raised when the chunk_size is larger than the length of table + with pytest.raises(ValueError): + _ = extractor(table=charge_table[1000:1500]) + # Check if ValueError is raised when the chunk_shift is smaller than the chunk_size + with pytest.raises(ValueError): + _ = extractor(table=charge_table, chunk_shift=3000)