Skip to content

Commit

Permalink
Ignore init setup etc from codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Mar 5, 2024
1 parent bbaf664 commit 52d8708
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
10 changes: 6 additions & 4 deletions drizzle/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,14 @@ def __init__(self, kernel="square", fillval=None, out_shape=None,
``out_ctx`` is provided.
"""
if begin_ctx_id < 0:
ValueError("Invalid context image ID")

self._ctx_id = begin_ctx_id # the ID of the *last* image to be resampled
if max_ctx_id is None:
max_ctx_id = begin_ctx_id
elif max_ctx_id < begin_ctx_id:
raise ValueError("'max_ctx_id' cannot be smaller than 'begin_ctx_id'.")

Check warning on line 243 in drizzle/resample.py

View check run for this annotation

Codecov / codecov/patch

drizzle/resample.py#L242-L243

Added lines #L242 - L243 were not covered by tests
self._max_ctx_id = max_ctx_id

if exptime < 0.0:
Expand Down Expand Up @@ -305,7 +310,7 @@ def __init__(self, kernel="square", fillval=None, out_shape=None,
shapes.add(out_ctx.shape[1:])

if out_shape is not None:
shapes.add(out_shape)
shapes.add(tuple(out_shape))

if len(shapes) == 1:
self._out_shape = shapes.pop()
Expand Down Expand Up @@ -406,9 +411,6 @@ def _increment_ctx_id(self):
plane and increments context image ID
(after computing the return value).
"""
if self._ctx_id < 0:
ValueError("Invalid context image ID")

self._plane_no = self._ctx_id // CTX_PLANE_BITS
depth = self._out_ctx.shape[0]

Expand Down
26 changes: 25 additions & 1 deletion drizzle/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ def test_blot_with_lan5(tmpdir):

def test_context_planes():
"""Reproduce error seen in issue #50"""
shape = [10, 10]
shape = (10, 10)
output_wcs = wcs.WCS()
output_wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN']
output_wcs.wcs.pc = [[1, 0], [0, 1]]
Expand All @@ -898,6 +898,30 @@ def test_context_planes():
"'out_ctx' must be either a 2D or 3D array."
)

# starting context ID must be positive
with pytest.raises(ValueError) as err_info:
resample.Drizzle(
kernel='square',
exptime=0.0,
out_shape=shape,
begin_ctx_id=-1,
)
assert str(err_info.value).startswith(
"Invalid context image ID"
)

with pytest.raises(ValueError) as err_info:
resample.Drizzle(
kernel='square',
exptime=0.0,
out_shape=shape,
begin_ctx_id=1,
max_ctx_id=0,
)
assert str(err_info.value).startswith(
"'max_ctx_id' cannot be smaller than 'begin_ctx_id'."
)

driz = resample.Drizzle(
kernel='square',
out_shape=output_wcs.array_shape,
Expand Down

0 comments on commit 52d8708

Please sign in to comment.