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 a1ccb52 commit bbaf664
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 29 deletions.
37 changes: 24 additions & 13 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
[run]
source = {packagename}
omit = */tests/*
source = drizzle

omit =
drizzle/__init__*
drizzle/**/conftest.py
drizzle/**/setup*
drizzle/**/tests/*
drizzle/version*
drizzle/_version.py
*/drizzle/__init__*
*/drizzle/**/conftest.py
*/drizzle/**/setup*
*/drizzle/**/tests/*

[report]
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about packages we have installed
except ImportError
# Don't complain about packages we have installed
except ImportError

# Don't complain if tests don't hit assertions
raise AssertionError
raise NotImplementedError
# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

# Don't complain about script hooks
def main\(.*\):
# Don't complain about script hooks
'def main(.*):'

# Ignore branches that don't pertain to this version of Python
pragma: py{ignore_python_version}
# Ignore branches that don't pertain to this version of Python
pragma: py{ignore_python_version}
7 changes: 3 additions & 4 deletions drizzle/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,7 @@ def __init__(self, kernel="square", fillval=None, out_shape=None,
raise ValueError("'out_ctx' must be either a 2D or 3D array.")
shapes.add(out_ctx.shape[1:])

if out_shape is None:
if shapes:
out_shape = shapes.pop()
else:
if out_shape is not None:
shapes.add(out_shape)

if len(shapes) == 1:
Expand Down Expand Up @@ -396,9 +393,11 @@ def _alloc_output_arrays(self, out_shape, max_ctx_id, out_img, out_wht,
)

if out_img is None:
print("setting self._out_img")
self._out_img = np.empty(out_shape, dtype=np.float32)
self._out_img.fill(self._fillval)
else:
print("setting self._out_img")
self._out_img = out_img

def _increment_ctx_id(self):
Expand Down
27 changes: 16 additions & 11 deletions drizzle/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,18 @@ def test_context_planes():

pixmap = utils.calc_pixmap(inwcs, output_wcs)

# context image must be 2D or 3D:
with pytest.raises(ValueError) as err_info:
resample.Drizzle(
kernel='point',
exptime=0.0,
out_shape=shape,
out_ctx=[0, 0, 0],
)
assert str(err_info.value).startswith(
"'out_ctx' must be either a 2D or 3D array."
)

driz = resample.Drizzle(
kernel='square',
out_shape=output_wcs.array_shape,
Expand All @@ -901,6 +913,8 @@ def test_context_planes():
assert driz.out_ctx.shape == (2, 10, 10)




@pytest.mark.parametrize(
'kernel,fc',
[
Expand Down Expand Up @@ -1287,23 +1301,14 @@ def test_resample_inconsistent_output():
assert driz.out_img.shape == out_shape

# inconsistent shapes:
out_shape = (n + 1, n)
with pytest.raises(ValueError) as err_info:
resample.Drizzle(
kernel='point',
exptime=0.0,
out_shape=out_shape,
out_img=out_img,
out_ctx=out_ctx,
out_wht=out_wht,
)
assert str(err_info.value).startswith("Inconsistent data shapes specified")


# # make sure code raises exception for unsuported fillval:
# with pytest.raises(ValueError) as err_info:
# resample.Drizzle(
# kernel='square',
# out_shape=out_shape,
# fillval="fillval",
# exptime=0.0,
# )
# assert str(err_info.value) == "could not convert string to float: 'fillval'"
31 changes: 30 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,33 @@ exempt-modules = []
known-first-party = ["astropy", "extension_helpers"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"
convention = "numpy"

[tool.coverage.run]
omit = [
"drizzle/__init__*",
"drizzle/**/conftest.py",
"drizzle/**/setup*",
"drizzle/**/tests/*",
"drizzle/version*",
"drizzle/_version.py",
"*/drizzle/__init__*",
"*/drizzle/**/conftest.py",
"*/drizzle/**/setup*",
"*/drizzle/**/tests/*",
]

[tool.coverage.report]
exclude_lines = [
# Have to re-enable the standard pragma
"pragma: no cover",
# Don't complain about packages we have installed
"except ImportError",
# Don't complain if tests don't hit defensive assertion code:
"raise AssertionError",
"raise NotImplementedError",
# Don't complain about script hooks
"'def main(.*):'",
# Ignore branches that don't pertain to this version of Python
"pragma: py{ignore_python_version}",
]

0 comments on commit bbaf664

Please sign in to comment.