Skip to content

Commit

Permalink
Move tests out of source tree
Browse files Browse the repository at this point in the history
  • Loading branch information
zblz committed Nov 8, 2019
1 parent 565bfcd commit e9059de
Show file tree
Hide file tree
Showing 20 changed files with 23 additions and 28 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/naima/tests/fixtures.py → tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from astropy.tests.helper import pytest
from astropy.utils.data import get_pkg_data_filename

from ..core import run_sampler, uniform_prior
from naima.core import run_sampler, uniform_prior

# Read data
fname = get_pkg_data_filename("data/CrabNebula_HESS_ipac.dat")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from astropy.tests.helper import pytest
from astropy.utils.data import get_pkg_data_filename

from ..core import (
from naima.core import (
get_sampler,
lnprob,
normal_prior,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from astropy.tests.helper import pytest
from astropy.utils.data import get_pkg_data_filename

from ..model_fitter import InteractiveModelFitter
from ..models import ExponentialCutoffPowerLaw
from naima.model_fitter import InteractiveModelFitter
from naima.models import ExponentialCutoffPowerLaw

try:
import matplotlib
Expand Down
10 changes: 5 additions & 5 deletions src/naima/tests/test_models.py → tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from astropy.tests.helper import pytest
from numpy.testing import assert_allclose

from ..models import (
from naima.models import (
Bremsstrahlung,
BrokenPowerLaw,
EblAbsorptionModel,
Expand All @@ -20,8 +20,8 @@
Synchrotron,
TableModel,
)
from ..radiative import PionDecayKelner06
from ..utils import trapz_loglog
from naima.radiative import PionDecayKelner06
from naima.utils import trapz_loglog

try:
import scipy
Expand Down Expand Up @@ -454,7 +454,7 @@ def test_pion_decay_no_nuc_enh(particle_dists):
"""
test PionDecayKelner06
"""
from ..radiative import PionDecay
from naima.radiative import PionDecay

ECPL, PL, BPL = particle_dists

Expand Down Expand Up @@ -542,7 +542,7 @@ def test_tablemodel():
assert_allclose(tm(e3).value, 0.0)

# use tablemodel as pdist
from ..radiative import Synchrotron, InverseCompton, PionDecay
from naima.radiative import Synchrotron, InverseCompton, PionDecay

SY = Synchrotron(tm)
_ = SY.flux(e / 10)
Expand Down
6 changes: 2 additions & 4 deletions src/naima/tests/test_plotting.py → tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
from astropy.tests.helper import pytest
from astropy.utils.data import get_pkg_data_filename

from ..analysis import save_diagnostic_plots, save_results_table
from ..core import run_sampler, uniform_prior
from ..plot import plot_chain, plot_data, plot_fit
from .fixtures import sampler
from naima.analysis import save_diagnostic_plots, save_results_table
from naima.plot import plot_chain, plot_data, plot_fit

try:
import matplotlib
Expand Down
11 changes: 4 additions & 7 deletions src/naima/tests/test_saveread.py → tests/test_saveread.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
from astropy.tests.helper import pytest
from astropy.utils.data import get_pkg_data_filename

from ..analysis import read_run, save_run
from ..core import run_sampler, uniform_prior
from ..model_fitter import InteractiveModelFitter
from ..models import ExponentialCutoffPowerLaw
from ..plot import plot_chain, plot_data, plot_fit
from ..utils import validate_data_table
from .fixtures import simple_sampler as sampler
from naima.analysis import read_run, save_run
from naima.model_fitter import InteractiveModelFitter
from naima.plot import plot_chain, plot_data, plot_fit
from naima.utils import validate_data_table

try:
import matplotlib
Expand Down
12 changes: 6 additions & 6 deletions src/naima/tests/test_sherpamod.py → tests/test_sherpamod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
from astropy.tests.helper import pytest

from ..utils import trapz_loglog
from naima.utils import trapz_loglog

try:
from sherpa import ui
Expand Down Expand Up @@ -31,7 +31,7 @@ def test_electron_models():
test import
"""

from ..sherpa_models import InverseCompton, Synchrotron, Bremsstrahlung
from naima.sherpa_models import InverseCompton, Synchrotron, Bremsstrahlung

for modelclass in [InverseCompton, Synchrotron, Bremsstrahlung]:
model = modelclass()
Expand All @@ -42,13 +42,13 @@ def test_electron_models():
print(model)

# point calc
output = model.calc([p.val for p in model.pars], energies)
model.calc([p.val for p in model.pars], energies)

# test as well ECPL
model.cutoff = 100

# integrated
output = model.calc([p.val for p in model.pars], elo, xhi=ehi)
model.calc([p.val for p in model.pars], elo, xhi=ehi)

if modelclass is InverseCompton:
# Perform a fit to fake data
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_proton_model():
test import
"""

from ..sherpa_models import PionDecay
from naima.sherpa_models import PionDecay

model = PionDecay()

Expand All @@ -88,7 +88,7 @@ def test_proton_model():
output = model.calc([p.val for p in model.pars], energies)

# integrated
output = model.calc([p.val for p in model.pars], elo, xhi=ehi)
model.calc([p.val for p in model.pars], elo, xhi=ehi)

# test as well ECPL
model.cutoff = 1000
Expand Down
2 changes: 1 addition & 1 deletion src/naima/tests/test_utils.py → tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from astropy.utils.data import get_pkg_data_filename
from numpy.testing import assert_allclose

from ..utils import (
from naima.utils import (
build_data_table,
estimate_B,
generate_energy_edges,
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sitepackages = False
deps =
pytest
commands =
pytest {posargs:--verbose src/naima/tests}
pytest {posargs:--verbose tests}

[testenv:flake8]
skip_install = True
Expand Down

0 comments on commit e9059de

Please sign in to comment.