Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
added check for exceptions
  • Loading branch information
TjarkMiener committed Jul 17, 2024
1 parent 452ec1b commit ac03f5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ctapipe/calib/camera/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})."
)
Expand Down
7 changes: 7 additions & 0 deletions src/ctapipe/calib/camera/tests/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import numpy as np
import pytest
from astropy.table import Table
from astropy.time import Time

Expand Down Expand Up @@ -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)

0 comments on commit ac03f5b

Please sign in to comment.