Skip to content

Commit

Permalink
Keep only changes to tox and setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed May 4, 2021
1 parent 16107c6 commit 2cce31f
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 89 deletions.
9 changes: 4 additions & 5 deletions synphot/tests/test_binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from astropy.utils.data import get_pkg_data_filename

# LOCAL
from synphot import binning, exceptions, specio
from synphot.utils import merge_wavelengths, generate_wavelengths
from .. import binning, exceptions, specio
from ..utils import merge_wavelengths, generate_wavelengths


@pytest.mark.parametrize(
Expand Down Expand Up @@ -196,8 +196,7 @@ def setup_class(self):
# Get bandpass data for interpolation.
hdr, wave, thru = specio.read_fits_spec(
get_pkg_data_filename(
os.path.join('data', 'hst_acs_hrc_f555w.fits'),
package='synphot.tests'),
os.path.join('data', 'hst_acs_hrc_f555w.fits')),
flux_col='THROUGHPUT', flux_unit=u.dimensionless_unscaled)

# Binned data.
Expand Down Expand Up @@ -233,7 +232,7 @@ def setup_class(self):

def test_c_ext(self):
# C-EXT: Sum over each bin.
from synphot import synphot_utils
from .. import synphot_utils

binflux_c, intwave_c = synphot_utils.calcbinflux(
self.size, self.i_beg, self.i_end, self.avflux, self.deltaw)
Expand Down
4 changes: 2 additions & 2 deletions synphot/tests/test_blackbody.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from astropy import constants as const
from astropy import units as u

from synphot.blackbody import blackbody_nu
from synphot.units import FNU
from ..blackbody import blackbody_nu
from ..units import FNU


# This test was removed from astropy in
Expand Down
6 changes: 3 additions & 3 deletions synphot/tests/test_integrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from numpy.testing import assert_allclose

# LOCAL
from synphot import models, units
from synphot.exceptions import SynphotError
from synphot.spectrum import SourceSpectrum, SpectralElement
from .. import models, units
from ..exceptions import SynphotError
from ..spectrum import SourceSpectrum, SpectralElement


class TestSourceConstFlux1D:
Expand Down
9 changes: 4 additions & 5 deletions synphot/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from astropy.utils.exceptions import AstropyUserWarning

# LOCAL
from synphot import specio, units
from synphot.models import (BlackBody1D, ConstFlux1D, Empirical1D,
PowerLawFlux1D, get_metadata)
from .. import specio, units
from ..models import (BlackBody1D, ConstFlux1D, Empirical1D, PowerLawFlux1D,
get_metadata)


def setup_module(module):
Expand Down Expand Up @@ -123,8 +123,7 @@ class TestEmpirical1D:
"""Test Empirical1D model."""
def setup_class(self):
filename = get_pkg_data_filename(
os.path.join('data', 'hst_acs_hrc_f555w_x_grw70d5824.fits'),
package='synphot.tests')
os.path.join('data', 'hst_acs_hrc_f555w_x_grw70d5824.fits'))
hdr, x, f = specio.read_spec(filename)
y = units.convert_flux(x, f, units.PHOTLAM)
self.flux_flam = f.value
Expand Down
39 changes: 14 additions & 25 deletions synphot/tests/test_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,19 @@
AstropyUserWarning)

# LOCAL
from synphot.tests.test_units import _area
from synphot import exceptions, units
from synphot.compat import HAS_SPECUTILS # noqa
from synphot.models import (
BlackBodyNorm1D, Box1D, ConstFlux1D, Empirical1D, GaussianFlux1D
)
from synphot.observation import Observation
from synphot.spectrum import SourceSpectrum, SpectralElement
from .test_units import _area
from .. import exceptions, units
from ..compat import HAS_SPECUTILS # noqa
from ..models import (BlackBodyNorm1D, Box1D, ConstFlux1D, Empirical1D,
GaussianFlux1D)
from ..observation import Observation
from ..spectrum import SourceSpectrum, SpectralElement

# Global test data files
_specfile = get_pkg_data_filename(
os.path.join('data', 'grw_70d5824_stisnic_005.fits'),
package='synphot.tests'
)
os.path.join('data', 'grw_70d5824_stisnic_005.fits'))
_bandfile = get_pkg_data_filename(
os.path.join('data', 'hst_acs_hrc_f555w.fits'),
package='synphot.tests'
)
os.path.join('data', 'hst_acs_hrc_f555w.fits'))


class TestObservation:
Expand Down Expand Up @@ -417,11 +412,8 @@ class TestCountRateNegFlux:
"""Test countrate with files containing negative flux/throughput values."""
def setup_class(self):
self.bp = SpectralElement.from_file(get_pkg_data_filename(
os.path.join('data', 'cos_fuv_g130m_c1309_psa.fits'),
package='synphot.tests'))
self.spfile = get_pkg_data_filename(
os.path.join('data', 'us7.txt'), package='synphot.tests'
)
os.path.join('data', 'cos_fuv_g130m_c1309_psa.fits')))
self.spfile = get_pkg_data_filename(os.path.join('data', 'us7.txt'))

@pytest.mark.parametrize(
('keep_neg', 'ans'),
Expand All @@ -447,14 +439,11 @@ def test_countrate_neg_leak():
"""
# This bug only manifests itself in very specific cases.
bp = SpectralElement.from_file(get_pkg_data_filename(
os.path.join('data', 'stis_fuv_f25ndq2_mjd58300_0822774.fits'),
package='synphot.tests'))
os.path.join('data', 'stis_fuv_f25ndq2_mjd58300_0822774.fits')))
sp = SourceSpectrum.from_file(get_pkg_data_filename(
os.path.join('data', 'k93_4500_0_5_rn_box.fits'),
package='synphot.tests'))
os.path.join('data', 'k93_4500_0_5_rn_box.fits')))
binset = np.fromfile(get_pkg_data_filename(
os.path.join('data', 'stis_fuv_f25ndq2_binset.bin'),
package='synphot.tests'))
os.path.join('data', 'stis_fuv_f25ndq2_binset.bin')))
obs = Observation(sp, bp, binset=binset)
area = 45238.93416 # HST cm^2
wrange = [1109.22, 12000.0] # Angstrom
Expand Down
21 changes: 9 additions & 12 deletions synphot/tests/test_reddening.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@
from astropy.utils.exceptions import AstropyUserWarning

# LOCAL
from synphot import exceptions, units
from synphot.compat import HAS_DUST_EXTINCTION # noqa
from synphot.models import ConstFlux1D, Empirical1D
from synphot.observation import Observation
from synphot.reddening import ReddeningLaw, etau_madau
from synphot.spectrum import SourceSpectrum, SpectralElement
from .. import exceptions, units
from ..compat import HAS_DUST_EXTINCTION # noqa
from ..models import ConstFlux1D, Empirical1D
from ..observation import Observation
from ..reddening import ReddeningLaw, etau_madau
from ..spectrum import SourceSpectrum, SpectralElement


class TestExtinction:
"""Test ReddeningLaw and ExtinctionCurve classes (most methods)."""
def setup_class(self):
rfile = get_pkg_data_filename(
os.path.join('data', 'milkyway_diffuse_001.fits'),
package='synphot.tests')
os.path.join('data', 'milkyway_diffuse_001.fits'))
self.redlaw = ReddeningLaw.from_file(rfile)
self.extcurve = self.redlaw.extinction_curve(0.3 * u.mag)

Expand Down Expand Up @@ -91,11 +90,9 @@ def test_qso_countrate(self):
https://github.com/spacetelescope/synphot_refactor/issues/129
"""
bp = SpectralElement.from_file(get_pkg_data_filename(
os.path.join('data', 'hst_acs_hrc_f850lp.fits'),
package='synphot.tests'))
os.path.join('data', 'hst_acs_hrc_f850lp.fits')))
qso = SourceSpectrum.from_file(get_pkg_data_filename(
os.path.join('data', 'qso_template_001.dat'),
package='synphot.tests'))
os.path.join('data', 'qso_template_001.dat')))
extcurve = self.redlaw.extinction_curve(1.0 * u.mag)
spext = qso * extcurve
with pytest.warns(AstropyUserWarning):
Expand Down
6 changes: 3 additions & 3 deletions synphot/tests/test_specio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from astropy.utils.exceptions import AstropyUserWarning

# LOCAL
from synphot import exceptions, specio, units
from .. import exceptions, specio, units


@pytest.mark.remote_data
Expand All @@ -28,7 +28,7 @@ def test_read_remote_spec():
.. note:: This is just I/O test. No check on data quality.
"""
from synphot import config
from .. import config

hdr, wave, flux = specio.read_remote_spec(
config.conf.vega_file, cache=False, show_progress=False)
Expand All @@ -41,7 +41,7 @@ def test_read_remote_spec():
def test_read_ascii_spec():
"""Test read local ASCII spectrum."""
specfile = get_pkg_data_filename(
os.path.join('data', 'qso_template_001.dat'), package='synphot.tests')
os.path.join('data', 'qso_template_001.dat'))
hdr, wave, flux = specio.read_spec(specfile)

assert_quantity_allclose(wave[::500], [800, 2050, 3300, 4550, 5800] * u.AA)
Expand Down
13 changes: 6 additions & 7 deletions synphot/tests/test_spectrum_bandpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
from astropy.utils.exceptions import AstropyUserWarning

# LOCAL
from synphot.tests.test_units import _area, _wave, _flux_photlam
from synphot import exceptions, units
from synphot.compat import HAS_SPECUTILS # noqa
from synphot.models import Box1D, Empirical1D, GaussianAbsorption1D
from synphot.spectrum import SpectralElement
from .test_units import _area, _wave, _flux_photlam
from .. import exceptions, units
from ..compat import HAS_SPECUTILS # noqa
from ..models import Box1D, Empirical1D, GaussianAbsorption1D
from ..spectrum import SpectralElement


@pytest.mark.remote_data
Expand Down Expand Up @@ -52,8 +52,7 @@ class TestEmpiricalBandpassFromFile:
"""This is the most common model used in ASTROLIB PYSYNPHOT."""
def setup_class(self):
bandfile = get_pkg_data_filename(
os.path.join('data', 'hst_acs_hrc_f555w.fits'),
package='synphot.tests')
os.path.join('data', 'hst_acs_hrc_f555w.fits'))
self.bp = SpectralElement.from_file(bandfile)

def test_invalid_flux_unit(self):
Expand Down
10 changes: 5 additions & 5 deletions synphot/tests/test_spectrum_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
from astropy.tests.helper import assert_quantity_allclose

# LOCAL
from synphot.tests.test_units import _wave, _flux_jy, _flux_photlam
from synphot import exceptions, units
from synphot.compat import ASTROPY_LT_4_0
from synphot.models import Box1D, Empirical1D, GaussianFlux1D, get_waveset
from synphot.spectrum import SourceSpectrum, SpectralElement
from .test_units import _wave, _flux_jy, _flux_photlam
from .. import exceptions, units
from ..compat import ASTROPY_LT_4_0
from ..models import Box1D, Empirical1D, GaussianFlux1D, get_waveset
from ..spectrum import SourceSpectrum, SpectralElement


def setup_module(module):
Expand Down
22 changes: 9 additions & 13 deletions synphot/tests/test_spectrum_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
from astropy.utils.exceptions import AstropyUserWarning

# LOCAL
from synphot.tests.test_units import (
_area, _wave, _flux_jy, _flux_photlam, _flux_vegamag
)
from synphot import exceptions, units
from synphot.compat import ASTROPY_LT_4_0
from synphot.compat import HAS_SPECUTILS # noqa
from synphot.models import (
from .test_units import _area, _wave, _flux_jy, _flux_photlam, _flux_vegamag
from .. import exceptions, units
from ..compat import ASTROPY_LT_4_0
from ..compat import HAS_SPECUTILS # noqa
from ..models import (
BlackBodyNorm1D, Box1D, ConstFlux1D, Empirical1D, Gaussian1D,
GaussianFlux1D, Lorentz1D, RickerWavelet1D, PowerLawFlux1D)
from synphot.observation import Observation
from synphot.spectrum import SourceSpectrum, SpectralElement
from ..observation import Observation
from ..spectrum import SourceSpectrum, SpectralElement

# GLOBAL VARIABLES
_vspec = None # Loaded in test_load_vspec()
Expand Down Expand Up @@ -94,8 +92,7 @@ class TestEmpiricalSourceFromFile:
"""This is the most common model used in ASTROLIB PYSYNPHOT."""
def setup_class(self):
specfile = get_pkg_data_filename(
os.path.join('data', 'hst_acs_hrc_f555w_x_grw70d5824.fits'),
package='synphot.tests')
os.path.join('data', 'hst_acs_hrc_f555w_x_grw70d5824.fits'))
self.sp = SourceSpectrum.from_file(specfile)

def test_invalid_flux_unit(self):
Expand Down Expand Up @@ -397,8 +394,7 @@ def setup_class(self):

# ACS bandpass: band(acs,hrc,f555w)
bandfile = get_pkg_data_filename(
os.path.join('data', 'hst_acs_hrc_f555w.fits'),
package='synphot.tests')
os.path.join('data', 'hst_acs_hrc_f555w.fits'))
self.acs = SpectralElement.from_file(bandfile)

# Box bandpass: box(5500,1)
Expand Down
10 changes: 4 additions & 6 deletions synphot/tests/test_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from astropy.utils.data import get_pkg_data_filename

# LOCAL
from synphot import exceptions
from synphot.thermal import ThermalSpectralElement
from .. import exceptions
from ..thermal import ThermalSpectralElement


def setup_module(module):
Expand All @@ -39,8 +39,7 @@ class TestThermalSpectralElement:
"""Test ``ThermalSpectralElement``."""
def setup_class(self):
thfile = get_pkg_data_filename(
os.path.join('data', 'wfc3_ir_g141_src_003_th.fits'),
package='synphot.tests')
os.path.join('data', 'wfc3_ir_g141_src_003_th.fits'))
self.th = ThermalSpectralElement.from_file(thfile)

def test_taper(self):
Expand All @@ -67,7 +66,6 @@ def test_from_file_exceptions(self):

# Missing DEFT keyword
thfile = get_pkg_data_filename(
os.path.join('data', 'hst_acs_hrc_f555w.fits'),
package='synphot.tests')
os.path.join('data', 'hst_acs_hrc_f555w.fits'))
with pytest.raises(exceptions.SynphotError):
ThermalSpectralElement.from_file(thfile, flux_col='THROUGHPUT')
2 changes: 1 addition & 1 deletion synphot/tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from astropy import units as u

# LOCAL
from synphot import exceptions, units
from .. import exceptions, units

# Wavelength conversions
_wave_angstrom = [0.1, 5000.0, 10000.0] * u.AA
Expand Down
4 changes: 2 additions & 2 deletions synphot/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from astropy import units as u

# LOCAL
from synphot import exceptions, utils, units
from .. import exceptions, utils, units


@pytest.mark.parametrize(
Expand Down Expand Up @@ -131,7 +131,7 @@ def test_download_bad_root(tmpdir):

def test_download_data(tmpdir):
"""Test data download helper in dry run mode."""
from synphot.config import conf
from ..config import conf

# Use case where user downloads all data into new dir.
cdbs_root = os.path.join(tmpdir.strpath, 'cdbs')
Expand Down

0 comments on commit 2cce31f

Please sign in to comment.