From 2cce31fe7f51b7f984d2f232d171ee034c2babb6 Mon Sep 17 00:00:00 2001 From: Mihai Cara Date: Tue, 4 May 2021 18:55:06 -0400 Subject: [PATCH] Keep only changes to tox and setup --- synphot/tests/test_binning.py | 9 +++--- synphot/tests/test_blackbody.py | 4 +-- synphot/tests/test_integrator.py | 6 ++-- synphot/tests/test_models.py | 9 +++--- synphot/tests/test_observation.py | 39 +++++++++---------------- synphot/tests/test_reddening.py | 21 ++++++------- synphot/tests/test_specio.py | 6 ++-- synphot/tests/test_spectrum_bandpass.py | 13 ++++----- synphot/tests/test_spectrum_misc.py | 10 +++---- synphot/tests/test_spectrum_source.py | 22 ++++++-------- synphot/tests/test_thermal.py | 10 +++---- synphot/tests/test_units.py | 2 +- synphot/tests/test_utils.py | 4 +-- 13 files changed, 66 insertions(+), 89 deletions(-) diff --git a/synphot/tests/test_binning.py b/synphot/tests/test_binning.py index 79dd4828..80cbe4c6 100644 --- a/synphot/tests/test_binning.py +++ b/synphot/tests/test_binning.py @@ -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( @@ -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. @@ -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) diff --git a/synphot/tests/test_blackbody.py b/synphot/tests/test_blackbody.py index 761663e5..df1aaa21 100644 --- a/synphot/tests/test_blackbody.py +++ b/synphot/tests/test_blackbody.py @@ -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 diff --git a/synphot/tests/test_integrator.py b/synphot/tests/test_integrator.py index e690c37d..82f5f5e6 100644 --- a/synphot/tests/test_integrator.py +++ b/synphot/tests/test_integrator.py @@ -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: diff --git a/synphot/tests/test_models.py b/synphot/tests/test_models.py index e5c631a1..76302172 100644 --- a/synphot/tests/test_models.py +++ b/synphot/tests/test_models.py @@ -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): @@ -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 diff --git a/synphot/tests/test_observation.py b/synphot/tests/test_observation.py index 032ea7d9..70d7258d 100644 --- a/synphot/tests/test_observation.py +++ b/synphot/tests/test_observation.py @@ -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: @@ -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'), @@ -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 diff --git a/synphot/tests/test_reddening.py b/synphot/tests/test_reddening.py index 336d07c2..e01efa69 100644 --- a/synphot/tests/test_reddening.py +++ b/synphot/tests/test_reddening.py @@ -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) @@ -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): diff --git a/synphot/tests/test_specio.py b/synphot/tests/test_specio.py index 7a4e56ca..878abba9 100644 --- a/synphot/tests/test_specio.py +++ b/synphot/tests/test_specio.py @@ -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 @@ -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) @@ -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) diff --git a/synphot/tests/test_spectrum_bandpass.py b/synphot/tests/test_spectrum_bandpass.py index c3d464bb..75840ad5 100644 --- a/synphot/tests/test_spectrum_bandpass.py +++ b/synphot/tests/test_spectrum_bandpass.py @@ -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 @@ -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): diff --git a/synphot/tests/test_spectrum_misc.py b/synphot/tests/test_spectrum_misc.py index 07b09f86..dcc4c987 100644 --- a/synphot/tests/test_spectrum_misc.py +++ b/synphot/tests/test_spectrum_misc.py @@ -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): diff --git a/synphot/tests/test_spectrum_source.py b/synphot/tests/test_spectrum_source.py index b35cf469..b8306a06 100644 --- a/synphot/tests/test_spectrum_source.py +++ b/synphot/tests/test_spectrum_source.py @@ -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() @@ -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): @@ -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) diff --git a/synphot/tests/test_thermal.py b/synphot/tests/test_thermal.py index 5c8f93b8..12429b5c 100644 --- a/synphot/tests/test_thermal.py +++ b/synphot/tests/test_thermal.py @@ -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): @@ -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): @@ -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') diff --git a/synphot/tests/test_units.py b/synphot/tests/test_units.py index 95aef73d..8132847a 100644 --- a/synphot/tests/test_units.py +++ b/synphot/tests/test_units.py @@ -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 diff --git a/synphot/tests/test_utils.py b/synphot/tests/test_utils.py index 64356473..00a7ad97 100644 --- a/synphot/tests/test_utils.py +++ b/synphot/tests/test_utils.py @@ -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( @@ -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')