forked from LSSTDESC/Spectractor
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from lsst/tickets/DM-38622
DM-38622: Replace deprecated make_source_mask function
- Loading branch information
Showing
3 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import matplotlib as mpl | ||
mpl.use('Agg') # must be run first! But therefore requires noqa E402 on all other imports | ||
|
||
import pytest # noqa: E402 | ||
import numpy as np # noqa: E402 | ||
from numpy.testing import run_module_suite # noqa: E402 | ||
from photutils.datasets import make_4gaussians_image # noqa: E402 | ||
from spectractor.extractor.background import make_source_mask # noqa: E402 | ||
from photutils.utils.exceptions import NoDetectionsWarning # noqa: E402 | ||
|
||
|
||
def test_make_source_mask(): | ||
data = make_4gaussians_image() | ||
mask1 = make_source_mask(data, 5, 10) | ||
mask2 = make_source_mask(data, 5, 10, dilate_size=20) | ||
assert np.count_nonzero(mask2) > np.count_nonzero(mask1) | ||
|
||
with pytest.warns(NoDetectionsWarning): | ||
mask = make_source_mask(data, 100, 100) | ||
assert np.count_nonzero(mask) == 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
run_module_suite() |