Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Compatibility with astropy>=5 #321

Merged
merged 2 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions synphot/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
HAS_DUST_EXTINCTION = True


__all__ = ['ASTROPY_LT_4_3', 'ASTROPY_LT_4_1', 'ASTROPY_LT_4_0',
'HAS_SPECUTILS', 'HAS_DUST_EXTINCTION']
__all__ = ['ASTROPY_LT_5_0', 'ASTROPY_LT_4_3', 'ASTROPY_LT_4_1',
'ASTROPY_LT_4_0', 'HAS_SPECUTILS', 'HAS_DUST_EXTINCTION']

ASTROPY_LT_5_0 = not minversion(astropy, '4.99') # astropy<5 but includes 5.0.dev # noqa
ASTROPY_LT_4_3 = not minversion(astropy, '4.3')
ASTROPY_LT_4_1 = not minversion(astropy, '4.1')
ASTROPY_LT_4_0 = not minversion(astropy, '4.0')
12 changes: 9 additions & 3 deletions synphot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# LOCAL
from . import units
from .compat import ASTROPY_LT_4_0, ASTROPY_LT_4_3
from .compat import ASTROPY_LT_4_0, ASTROPY_LT_4_3, ASTROPY_LT_5_0
from .exceptions import SynphotError
from .utils import merge_wavelengths

Expand Down Expand Up @@ -215,7 +215,10 @@ def sampleset(self, step=0.01, minimal=False):
i.e., box edges and a point outside on each side.

"""
w1, w2 = self.bounding_box
if ASTROPY_LT_5_0:
w1, w2 = self.bounding_box
else:
w1, w2 = tuple(self.bounding_box.bounding_box())

if self._n_models == 1:
w = self._calc_sampleset(w1, w2, step, minimal)
Expand Down Expand Up @@ -749,7 +752,10 @@ class Trapezoid1D(_models.Trapezoid1D):
"""
def sampleset(self):
"""Return ``x`` array that samples the feature."""
x1, x4 = self.bounding_box
if ASTROPY_LT_5_0:
x1, x4 = self.bounding_box
else:
x1, x4 = tuple(self.bounding_box.bounding_box())
dw = self.width * 0.5
x2 = self.x_0 - dw
x3 = self.x_0 + dw
Expand Down