Skip to content

Commit

Permalink
Merge pull request #297 from mkelley/testing-updates-sep21
Browse files Browse the repository at this point in the history
Testing updates
  • Loading branch information
mkelley committed Sep 26, 2021
2 parents 6f5ce47 + ca42494 commit da3230c
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 59 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@ jobs:
- name: Python 3.8 with all optional dependencies and coverage checking
os: ubuntu-latest
python: 3.8
toxenv: py38-test-alldeps-cov
toxenv: py38-test-alldeps

- name: OS X - Python 3.8 with all optional dependencies
os: macos-latest
python: 3.8
toxenv: py38-test-alldeps

- name: Python 3.8 with all optional dependencies, remote tests, and coverage checking
os: ubuntu-latest
python: 3.8
toxenv: py38-test-alldeps-cov
toxposargs: --remote-data

# - name: Windows - Python 3.8 with all optional dependencies
# os: windows-latest
# python: 3.8
Expand Down
18 changes: 18 additions & 0 deletions docs/development/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ will indicate which functions are ready to be tested on this dedicated
:doc:`/status`. Keep in mind that there might be issues, so feel free to
compare the function results with your own results.

`sbpy` tests are run with `pytest`. To install `pytest` and all
requirements for testing:
```
pip install sbpy[test]
```
or install `sbpy` from the source tree in editable mode:
```
pip install -e .[test]
```
Then the tests may be run
```
import sbpy
sbpy.test()
# use test(remote_data=True) to enable tests requiring an internet connection
```

For more testing options, including testing multiple dependency versions,
see `astropy`'s `testing guidelines <https://docs.astropy.org/en/latest/development/testguide.html>`__.

Reporting Problems
------------------
Expand Down
29 changes: 14 additions & 15 deletions sbpy/activity/gas/tests/test_prodrate_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from astroquery.jplspec import JPLSpec
import pytest

try:
import pyradex
except ImportError:
pyradex = None

from .. import (Haser, photo_timescale, LTE, NonLTE, einstein_coeff,
intensity_conversion, beta_factor, total_number, from_Haser)
from ....data import Ephem, Phys
Expand Down Expand Up @@ -146,6 +151,9 @@ def test_remote_prodrate_simple_ch3oh():
assert np.all(err < 0.35)


# Issue #296
# MSK: disabling test as CO and HCN are no longer present in LAMDA database(?)
@pytest.mark.skip
@remote_data
def test_einstein():

Expand All @@ -159,7 +167,7 @@ def test_einstein():

cat = JPLSpec.get_species_table()

for i in range(0, 2):
for i in range(2):

transition_freq = transition_freq_list[i]
mol_tag = mol_tag_list[i]
Expand Down Expand Up @@ -257,14 +265,9 @@ def test_Haser_prodrate():
'''


@pytest.mark.skipif('pyradex is None')
@remote_data
def test_Haser_pyradex():

try:
import pyradex
except ImportError:
return None

co = Table.read(data_path('CO.csv'), format="ascii.csv")

nonlte = NonLTE()
Expand Down Expand Up @@ -321,7 +324,7 @@ def test_intensity_conversion():
# test untested case for intensity conversion function

temp_estimate = 47. * u.K
vgas = 0.8 * u.km / u.s
# vgas = 0.8 * u.km / u.s
mol_tag = 27001
transition_freq = (265.886434 * u.GHz).to('MHz')
mol_data = Phys.from_jplspec(temp_estimate, transition_freq, mol_tag)
Expand All @@ -337,7 +340,7 @@ def test_einsteincoeff_case():
# test untested case for einstein coefficient

temp_estimate = 47. * u.K
vgas = 0.8 * u.km / u.s
# vgas = 0.8 * u.km / u.s
mol_tag = 27001
transition_freq = (265.886434 * u.GHz).to('MHz')
mol_data = Phys.from_jplspec(temp_estimate, transition_freq, mol_tag)
Expand Down Expand Up @@ -377,14 +380,9 @@ def test_betafactor_case():
'''


@pytest.mark.skipif('pyradex is None')
@remote_data
def test_pyradex_case():
# test untested case for Pyradex
try:
import pyradex
except ImportError:
return None

transition_freq = (177.196 * u.GHz).to(u.MHz)
mol_tag = 29002
cdensity_guess = (1.89*10.**(14) / (u.cm * u.cm))
Expand All @@ -403,6 +401,7 @@ def test_pyradex_case():
assert np.isclose(cdensity.value[0], 1.134e14)


@pytest.mark.skipif('pyradex is None')
@remote_data
def test_Haser_prodrate_pyradex(mock_nonlte):

Expand Down
5 changes: 3 additions & 2 deletions sbpy/calib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,10 @@ class Sun(SpectralStandard):
>>> import astropy.units as u
>>> import astropy.constants as const
>>> from astropy.modeling.models import BlackBody
>>> from sbpy.calib import Sun
>>> B = BlackBody(
... temperature=5770 * u.K,
... scale=((const.R_sun.to('au') / const.au)**2)
... scale=((const.R_sun / const.au)**2
... * u.W / u.m**2 / u.um / u.sr)
... )
>>> wave = np.logspace(-1, 2, 300) * u.um
Expand All @@ -634,7 +635,7 @@ class Sun(SpectralStandard):
Interpolate to / evaluate at 0.62 μm:
>>> print(sun(0.62 * u.um)) # doctest: +FLOAT_CMP
1611.7057927532567 W / (m2 um)
1611.7080046473307 W / (m2 um)
Observe as through a spectrometer:
Expand Down

0 comments on commit da3230c

Please sign in to comment.