Skip to content

Commit a7ad935

Browse files
authored
Merge pull request #2230 from larrybradley/deprecation-tools
Add (private) deprecated_getattr helper function
2 parents a789901 + 10ce0a3 commit a7ad935

File tree

12 files changed

+415
-38
lines changed

12 files changed

+415
-38
lines changed

photutils/background/background_2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import numpy as np
1111
from astropy.nddata import NDData, block_replicate, reshape_as_blocks
1212
from astropy.utils import lazyproperty
13-
from astropy.utils.decorators import deprecated_renamed_argument
1413
from astropy.utils.exceptions import AstropyUserWarning
1514
from scipy.ndimage import generic_filter
1615

@@ -20,6 +19,7 @@
2019
from photutils.background.interpolators import (BkgIDWInterpolator,
2120
_BkgZoomInterpolator)
2221
from photutils.utils import ShepardIDWInterpolator
22+
from photutils.utils._deprecation import deprecated_renamed_argument
2323
from photutils.utils._parameters import as_pair, create_default_sigmaclip
2424
from photutils.utils._repr import make_repr
2525
from photutils.utils._stats import nanmedian, nanmin
@@ -182,7 +182,7 @@ class Background2D:
182182
map will simply be a constant image.
183183
"""
184184

185-
@deprecated_renamed_argument('interpolator', None, '3.0')
185+
@deprecated_renamed_argument('interpolator', None, '3.0', until='4.0')
186186
def __init__(self, data, box_size, *, mask=None, coverage_mask=None,
187187
fill_value=0.0, exclude_percentile=10.0, filter_size=(3, 3),
188188
filter_threshold=None, sigma_clip=SIGMA_CLIP,

photutils/background/tests/test_background_2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def test_interpolator_keyword_deprecation(self, test_data):
735735
with pytest.warns(AstropyDeprecationWarning, match=match):
736736
interp = BkgZoomInterpolator()
737737

738-
match = '"interpolator" was deprecated'
738+
match = "'interpolator' was deprecated"
739739
with pytest.warns(AstropyDeprecationWarning, match=match):
740740
bkg = Background2D(test_data, (25, 25), interpolator=interp)
741741

photutils/centroids/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
import numpy as np
1010
from astropy.nddata import overlap_slices
11-
from astropy.utils.decorators import deprecated_renamed_argument
1211
from astropy.utils.exceptions import AstropyUserWarning
1312

1413
from photutils.centroids._utils import _process_data_mask
15-
from photutils.utils._deprecation import deprecated_positional_kwargs
14+
from photutils.utils._deprecation import (deprecated_positional_kwargs,
15+
deprecated_renamed_argument)
1616
from photutils.utils._parameters import as_pair
1717
from photutils.utils._quantity_helpers import process_quantities
1818
from photutils.utils._repr import make_repr
@@ -116,9 +116,9 @@ def centroid_com(data, mask=None):
116116

117117

118118
@deprecated_positional_kwargs(since='3.0', until='4.0')
119-
@deprecated_renamed_argument('xpeak', None, '3.0')
120-
@deprecated_renamed_argument('ypeak', None, '3.0')
121-
@deprecated_renamed_argument('search_boxsize', None, '3.0')
119+
@deprecated_renamed_argument('xpeak', None, '3.0', until='4.0')
120+
@deprecated_renamed_argument('ypeak', None, '3.0', until='4.0')
121+
@deprecated_renamed_argument('search_boxsize', None, '3.0', until='4.0')
122122
def centroid_quadratic(data, mask=None, fit_boxsize=5, xpeak=None,
123123
ypeak=None, search_boxsize=None):
124124
"""

photutils/detection/core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
from astropy.stats import gaussian_fwhm_to_sigma
1818
from astropy.table import QTable
1919
from astropy.utils import lazyproperty
20-
from astropy.utils.decorators import deprecated_renamed_argument
2120
from astropy.utils.exceptions import AstropyDeprecationWarning
2221

2322
from photutils.detection.peakfinder import find_peaks
24-
from photutils.utils._deprecation import deprecated_positional_kwargs
23+
from photutils.utils._deprecation import (deprecated_positional_kwargs,
24+
deprecated_renamed_argument)
2525
from photutils.utils._misc import _get_meta
2626
from photutils.utils._quantity_helpers import process_quantities
2727
from photutils.utils._repr import make_repr
@@ -205,8 +205,9 @@ class StarFinderCatalogBase(metaclass=abc.ABCMeta):
205205
value filtering will be performed.
206206
"""
207207

208-
@deprecated_renamed_argument('brightest', 'n_brightest', '3.0')
209-
@deprecated_renamed_argument('peakmax', 'peak_max', '3.0')
208+
@deprecated_renamed_argument('brightest', 'n_brightest', '3.0',
209+
until='4.0')
210+
@deprecated_renamed_argument('peakmax', 'peak_max', '3.0', until='4.0')
210211
def __init__(self, data, xypos, kernel, *, n_brightest=None,
211212
peak_max=None):
212213
# Validate the units, but do not strip them

photutils/detection/daofinder.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import astropy.units as u
99
import numpy as np
1010
from astropy.utils import lazyproperty
11-
from astropy.utils.decorators import deprecated_renamed_argument
1211

1312
from photutils.detection.core import (_DEPR_DEFAULT, StarFinderBase,
1413
StarFinderCatalogBase,
1514
_handle_deprecated_range,
1615
_StarFinderKernel, _validate_n_brightest)
1716
from photutils.utils._convolution import _filter_data
18-
from photutils.utils._deprecation import deprecated_positional_kwargs
17+
from photutils.utils._deprecation import (deprecated_positional_kwargs,
18+
deprecated_renamed_argument)
1919
from photutils.utils._quantity_helpers import isscalar, process_quantities
2020
from photutils.utils._repr import make_repr
2121
from photutils.utils.exceptions import NoDetectionsWarning
@@ -204,8 +204,9 @@ class DAOStarFinder(StarFinderBase):
204204
"""
205205

206206
@deprecated_positional_kwargs(since='3.0', until='4.0')
207-
@deprecated_renamed_argument('brightest', 'n_brightest', '3.0')
208-
@deprecated_renamed_argument('peakmax', 'peak_max', '3.0')
207+
@deprecated_renamed_argument('brightest', 'n_brightest', '3.0',
208+
until='4.0')
209+
@deprecated_renamed_argument('peakmax', 'peak_max', '3.0', until='4.0')
209210
def __init__(self, threshold, fwhm, ratio=1.0, theta=0.0,
210211
sigma_radius=1.5, sharplo=_DEPR_DEFAULT,
211212
sharphi=_DEPR_DEFAULT, roundlo=_DEPR_DEFAULT,

photutils/detection/irafstarfinder.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
import numpy as np
99
from astropy.utils import lazyproperty
10-
from astropy.utils.decorators import deprecated_renamed_argument
1110
from astropy.utils.exceptions import AstropyDeprecationWarning
1211

1312
from photutils.detection.core import (_DEPR_DEFAULT, StarFinderBase,
1413
StarFinderCatalogBase,
1514
_handle_deprecated_range,
1615
_StarFinderKernel, _validate_n_brightest)
1716
from photutils.utils._convolution import _filter_data
18-
from photutils.utils._deprecation import deprecated_positional_kwargs
17+
from photutils.utils._deprecation import (deprecated_positional_kwargs,
18+
deprecated_renamed_argument)
1919
from photutils.utils._quantity_helpers import isscalar, process_quantities
2020
from photutils.utils._repr import make_repr
2121
from photutils.utils.exceptions import NoDetectionsWarning
@@ -169,8 +169,9 @@ class IRAFStarFinder(StarFinderBase):
169169
"""
170170

171171
@deprecated_positional_kwargs(since='3.0', until='4.0')
172-
@deprecated_renamed_argument('brightest', 'n_brightest', '3.0')
173-
@deprecated_renamed_argument('peakmax', 'peak_max', '3.0')
172+
@deprecated_renamed_argument('brightest', 'n_brightest', '3.0',
173+
until='4.0')
174+
@deprecated_renamed_argument('peakmax', 'peak_max', '3.0', until='4.0')
174175
def __init__(self, threshold, fwhm, sigma_radius=1.5,
175176
minsep_fwhm=_DEPR_DEFAULT,
176177
sharplo=_DEPR_DEFAULT, sharphi=_DEPR_DEFAULT,

photutils/detection/starfinder.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
import numpy as np
99
from astropy.utils import lazyproperty
10-
from astropy.utils.decorators import deprecated_renamed_argument
1110

1211
from photutils.detection.core import (StarFinderBase, StarFinderCatalogBase,
1312
_validate_n_brightest)
1413
from photutils.utils._convolution import _filter_data
15-
from photutils.utils._deprecation import deprecated_positional_kwargs
14+
from photutils.utils._deprecation import (deprecated_positional_kwargs,
15+
deprecated_renamed_argument)
1616
from photutils.utils._quantity_helpers import process_quantities
1717
from photutils.utils._repr import make_repr
1818
from photutils.utils.exceptions import NoDetectionsWarning
@@ -82,8 +82,9 @@ class StarFinder(StarFinderBase):
8282
"""
8383

8484
@deprecated_positional_kwargs(since='3.0', until='4.0')
85-
@deprecated_renamed_argument('brightest', 'n_brightest', '3.0')
86-
@deprecated_renamed_argument('peakmax', 'peak_max', '3.0')
85+
@deprecated_renamed_argument('brightest', 'n_brightest', '3.0',
86+
until='4.0')
87+
@deprecated_renamed_argument('peakmax', 'peak_max', '3.0', until='4.0')
8788
def __init__(self, threshold, kernel, min_separation=None,
8889
exclude_border=False, n_brightest=None, peak_max=None):
8990

photutils/detection/tests/test_daofinder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def test_deprecated_brightest(self):
551551
Test that the deprecated 'brightest' keyword raises a warning
552552
and still works.
553553
"""
554-
match = '"brightest" was deprecated'
554+
match = "'brightest' was deprecated"
555555
with pytest.warns(AstropyDeprecationWarning, match=match):
556556
finder = DAOStarFinder(threshold=5.0, fwhm=3.0, brightest=5)
557557
assert finder.n_brightest == 5
@@ -561,7 +561,7 @@ def test_deprecated_peakmax(self):
561561
Test that the deprecated 'peakmax' keyword raises a warning
562562
and still works.
563563
"""
564-
match = '"peakmax" was deprecated'
564+
match = "'peakmax' was deprecated"
565565
with pytest.warns(AstropyDeprecationWarning, match=match):
566566
finder = DAOStarFinder(threshold=5.0, fwhm=3.0, peakmax=100.0)
567567
assert finder.peak_max == 100.0

photutils/detection/tests/test_irafstarfinder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def test_deprecated_brightest(self):
502502
Test that the deprecated 'brightest' keyword raises a warning
503503
and still works.
504504
"""
505-
match = '"brightest" was deprecated'
505+
match = "'brightest' was deprecated"
506506
with pytest.warns(AstropyDeprecationWarning, match=match):
507507
finder = IRAFStarFinder(threshold=5.0, fwhm=3.0, brightest=5)
508508
assert finder.n_brightest == 5
@@ -512,7 +512,7 @@ def test_deprecated_peakmax(self):
512512
Test that the deprecated 'peakmax' keyword raises a warning
513513
and still works.
514514
"""
515-
match = '"peakmax" was deprecated'
515+
match = "'peakmax' was deprecated"
516516
with pytest.warns(AstropyDeprecationWarning, match=match):
517517
finder = IRAFStarFinder(threshold=5.0, fwhm=3.0, peakmax=100.0)
518518
assert finder.peak_max == 100.0

photutils/detection/tests/test_starfinder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def test_deprecated_brightest(self, kernel):
335335
Test that the deprecated 'brightest' keyword raises a warning
336336
and still works.
337337
"""
338-
match = '"brightest" was deprecated'
338+
match = "'brightest' was deprecated"
339339
with pytest.warns(AstropyDeprecationWarning, match=match):
340340
finder = StarFinder(threshold=5.0, kernel=kernel, brightest=5)
341341
assert finder.n_brightest == 5
@@ -345,7 +345,7 @@ def test_deprecated_peakmax(self, kernel):
345345
Test that the deprecated 'peakmax' keyword raises a warning
346346
and still works.
347347
"""
348-
match = '"peakmax" was deprecated'
348+
match = "'peakmax' was deprecated"
349349
with pytest.warns(AstropyDeprecationWarning, match=match):
350350
finder = StarFinder(threshold=5.0, kernel=kernel, peakmax=100.0)
351351
assert finder.peak_max == 100.0

0 commit comments

Comments
 (0)