Skip to content

Commit

Permalink
Merge pull request #17412 from meeseeksmachine/auto-backport-of-pr-17…
Browse files Browse the repository at this point in the history
…410-on-v7.0.x

Backport PR #17410 on branch v7.0.x (Add sigma_clip tests for MaskedArray masks)
  • Loading branch information
saimn authored Nov 19, 2024
2 parents 00caf1b + a7b9f6c commit dd8f585
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions astropy/stats/tests/test_sigma_clipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ def test_sigma_clip_scalar_mask():
assert result.mask.shape != ()


def test_sigma_clip_masked_array():
"""
Regression test to check that MaskedArray masks are propagated
correctly if cenfunc/stdfunc is not the default, axis is not None,
and masked=False.
"""
arr = np.ones(10).astype(float)
arr[-2:] = 5
arr = np.ma.masked_where(arr > 1, arr)
out = sigma_clip(arr, cenfunc=np.mean, axis=0, masked=False)
assert np.all(np.isnan(out[-2:]))
assert_allclose(np.nanmean(out), 1.0)

out = sigma_clip(arr, stdfunc=np.std, axis=0, masked=False)
assert np.all(np.isnan(out[-2:]))
assert_allclose(np.nanmean(out), 1.0)


def test_sigma_clip_class():
with NumpyRNGContext(12345):
data = np.random.randn(100)
Expand Down

0 comments on commit dd8f585

Please sign in to comment.