File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 1+ A warning is now raised if the input data to `~sunkit_image.enhance.mgn ` contain any NaNs.
Original file line number Diff line number Diff line change 11"""
22This module contains functions that will enhance the entire image.
33"""
4+ import warnings
45
56import numpy as np
67import scipy .ndimage as ndimage
@@ -79,6 +80,12 @@ def mgn(
7980 arXiv preprint arXiv:1403.6613 (2014).
8081 Ref: Sol Phys (2014) 289: 2945. doi:10.1007/s11207-014-0523-9
8182 """
83+ if np .isnan (data ).any ():
84+ warnings .warn (
85+ "One or more entries in the input data are NaN. This implementation does not account "
86+ "for the presence of NaNs in the input data. As such, this may result in undefined "
87+ "behavior."
88+ )
8289
8390 if weights is None :
8491 weights = np .ones (len (sigma ))
Original file line number Diff line number Diff line change @@ -56,3 +56,9 @@ def test_multiscale_gaussian(map_test):
5656 expect4 = enhance .mgn (map_test )
5757
5858 assert np .allclose (result2 , expect4 )
59+
60+
61+ def test_nans_raise_warning (map_test ):
62+ map_test [0 , 0 ] = np .nan
63+ with pytest .warns (UserWarning , match = "One or more entries in the input data are NaN." ):
64+ _ = enhance .mgn (map_test )
You can’t perform that action at this time.
0 commit comments