Skip to content

Commit

Permalink
Merge pull request #2960 from nabobalis/master
Browse files Browse the repository at this point in the history
version fix for doc builds and tox test changes
  • Loading branch information
nabobalis committed Mar 7, 2019
2 parents 05c92fc + 1f646d0 commit 7a16f81
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 104 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Expand Up @@ -84,7 +84,7 @@ jobs:
- run:
name: Install dependencies one
# Cat here to suppress the progress bar
command: pip3 install cython numpy scipy astropy matplotlib | cat
command: pip3 install cython numpy scipy astropy matplotlib asdf | cat
- run:
name: Install dependencies two
# Cat here to suppress the progress bar
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
- run: *merge-check
- run: *apt-install
- run: *tox-install
- run: tox -e py37-build_docs
- run: tox -e build_docs
- store_artifacts:
path: docs/_build/html

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -49,6 +49,7 @@ coverage.xml
*.cover
.hypothesis/
.pytest_cache/
junit/

# Translations
*.mo
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Expand Up @@ -6,6 +6,7 @@ include pyproject.toml
include README.rst
include RELEASE.rst
include setup.py
include setup.cfg

recursive-include astropy_helpers *
exclude astropy_helpers/.*
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Expand Up @@ -27,7 +27,7 @@ jobs:
parameters:
name: Linux_37_online
os: linux
tox: py37-online -- -n=6
tox: py37-online -- -n=4

- template: azure-templates.yml
parameters:
Expand Down
8 changes: 0 additions & 8 deletions conftest.py

This file was deleted.

4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -103,9 +103,9 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
# The short X.Y version.
version = '.'.join(versionmod.version.split('.')[:2])
release = '.'.join(versionmod.version.split('.')[:3])
# The full version, including alpha/beta/rc tags.
release = versionmod.version
version = versionmod.version.split('+')[0]


# -- Shut up numpy warnings from WCSAxes --------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Expand Up @@ -50,14 +50,16 @@ docs =
towncrier

[options.package_data]
sunpy.data = sunpyrc, test/**
sunpy.data = sunpyrc, test/*, test/*/*
sunpy.database = tests/test_table.txt
sunpy.io = special/asdf/schemas/sunpy.org/sunpy/*/*.yaml, special/asdf/schemas/sunpy.org/sunpy/*/*/*.yaml
sunpy.tests = figure_hashes_py36.json

[options.entry_points]
asdf_extensions =
sunpy = sunpy.io.special.asdf.extension:SunpyExtension
pytest11 =
asdf = asdf.tests.schema_tester

[ah_bootstrap]
auto_use = True
Expand Down
12 changes: 5 additions & 7 deletions sunpy/conftest.py
Expand Up @@ -4,7 +4,11 @@
import importlib

import pytest
from pkg_resources import parse_version

import sunpy.tests.helpers
from sunpy.tests.hash import HASH_LIBRARY_NAME
from sunpy.tests.helpers import new_hash_library, generate_figure_webpage
from sunpy.util.exceptions import SunpyDeprecationWarning

# Force MPL to use non-gui backends for testing.
try:
Expand All @@ -14,12 +18,6 @@
else:
matplotlib.use('Agg')

# isort:imports-firstparty
import sunpy.tests.helpers
from sunpy.tests.hash import HASH_LIBRARY_NAME
from sunpy.tests.helpers import new_hash_library, generate_figure_webpage
from sunpy.util.exceptions import SunpyDeprecationWarning

# Don't actually import pytest_remotedata because that can do things to the
# entrypoints code in pytest.
remotedata_spec = importlib.util.find_spec("pytest_remotedata")
Expand Down
1 change: 0 additions & 1 deletion sunpy/data/test/__init__.py
Expand Up @@ -14,7 +14,6 @@
file_list = glob.glob(os.path.join(rootdir, '*.[!p]*'))



def get_test_filepath(filename, **kwargs):
"""
Return the full path to a test file in the ``data/test`` directory.
Expand Down
1 change: 0 additions & 1 deletion sunpy/instr/fermi.py
@@ -1,7 +1,6 @@
import os
import copy
import urllib
import datetime
import tempfile
from collections import OrderedDict

Expand Down
65 changes: 40 additions & 25 deletions sunpy/instr/goes.py
Expand Up @@ -230,25 +230,31 @@ def calculate_temperature_em(goests, abundances="coronal",
>>> from sunpy.instr.goes import calculate_temperature_em
>>> from sunpy.data.sample import GOES_XRS_TIMESERIES # doctest: +REMOTE_DATA
>>> goests = ts.TimeSeries(GOES_XRS_TIMESERIES) # doctest: +REMOTE_DATA
>>> goests.data # doctest: +REMOTE_DATA
xrsa xrsb
>>> goests.data[0:10] # doctest: +REMOTE_DATA
xrsa xrsb
2011-06-06 23:59:59.961999893 1.000000e-09 1.887100e-07
2011-06-07 00:00:02.008999944 1.000000e-09 1.834600e-07
2011-06-07 00:00:04.058999896 1.000000e-09 1.860900e-07
2011-06-07 00:00:06.104999900 1.000000e-09 1.808400e-07
2011-06-07 00:00:08.151999950 1.000000e-09 1.860900e-07
...
2011-06-07 00:00:10.201999903 1.000000e-09 1.808400e-07
2011-06-07 00:00:12.248999953 1.000000e-09 1.860900e-07
2011-06-07 00:00:14.298999906 1.000000e-09 1.834600e-07
2011-06-07 00:00:16.344999909 1.000000e-09 1.808400e-07
2011-06-07 00:00:18.391999960 1.000000e-09 1.834600e-07
>>> goests_new = calculate_temperature_em(goests) # doctest: +REMOTE_DATA
>>> goests_new.data # doctest: +REMOTE_DATA
xrsa xrsb temperature em
>>> goests_new.data[0:10] # doctest: +REMOTE_DATA
xrsa xrsb temperature em
2011-06-06 23:59:59.961999893 1.000000e-09 1.887100e-07 3.503510 2.190626e+48
2011-06-07 00:00:02.008999944 1.000000e-09 1.834600e-07 3.534262 2.055847e+48
2011-06-07 00:00:04.058999896 1.000000e-09 1.860900e-07 3.518700 2.122771e+48
2011-06-07 00:00:06.104999900 1.000000e-09 1.808400e-07 3.550100 1.990333e+48
2011-06-07 00:00:08.151999950 1.000000e-09 1.860900e-07 3.518700 2.122771e+48
...
2011-06-07 00:00:10.201999903 1.000000e-09 1.808400e-07 3.550100 1.990333e+48
2011-06-07 00:00:12.248999953 1.000000e-09 1.860900e-07 3.518700 2.122771e+48
2011-06-07 00:00:14.298999906 1.000000e-09 1.834600e-07 3.534262 2.055847e+48
2011-06-07 00:00:16.344999909 1.000000e-09 1.808400e-07 3.550100 1.990333e+48
2011-06-07 00:00:18.391999960 1.000000e-09 1.834600e-07 3.534262 2.055847e+48
"""
# Check that input argument is of correct type
if not isinstance(goests, timeseries.XRSTimeSeries):
Expand Down Expand Up @@ -805,27 +811,31 @@ def calculate_radiative_loss_rate(goests, force_download=False,
>>> from sunpy.instr.goes import calculate_radiative_loss_rate
>>> from sunpy.data.sample import GOES_XRS_TIMESERIES # doctest: +REMOTE_DATA
>>> goests = ts.TimeSeries(GOES_XRS_TIMESERIES) # doctest: +REMOTE_DATA
>>> goests.data # doctest: +REMOTE_DATA
xrsa xrsb
>>> goests.data[0:10] # doctest: +REMOTE_DATA
xrsa xrsb
2011-06-06 23:59:59.961999893 1.000000e-09 1.887100e-07
2011-06-07 00:00:02.008999944 1.000000e-09 1.834600e-07
2011-06-07 00:00:04.058999896 1.000000e-09 1.860900e-07
2011-06-07 00:00:06.104999900 1.000000e-09 1.808400e-07
2011-06-07 00:00:08.151999950 1.000000e-09 1.860900e-07
2011-06-07 00:00:10.201999903 1.000000e-09 1.808400e-07
...
2011-06-07 00:00:12.248999953 1.000000e-09 1.860900e-07
2011-06-07 00:00:14.298999906 1.000000e-09 1.834600e-07
2011-06-07 00:00:16.344999909 1.000000e-09 1.808400e-07
2011-06-07 00:00:18.391999960 1.000000e-09 1.834600e-07
>>> goests_new = calculate_radiative_loss_rate(goests) # doctest: +REMOTE_DATA
>>> goests_new.data # doctest: +REMOTE_DATA
xrsa xrsb temperature em rad_loss_rate
>>> goests_new.data[0:10] # doctest: +REMOTE_DATA
xrsa xrsb temperature em rad_loss_rate
2011-06-06 23:59:59.961999893 1.000000e-09 1.887100e-07 3.503510 2.190626e+48 1.781001e+19
2011-06-07 00:00:02.008999944 1.000000e-09 1.834600e-07 3.534262 2.055847e+48 1.660031e+19
2011-06-07 00:00:04.058999896 1.000000e-09 1.860900e-07 3.518700 2.122771e+48 1.719931e+19
2011-06-07 00:00:06.104999900 1.000000e-09 1.808400e-07 3.550100 1.990333e+48 1.601718e+19
2011-06-07 00:00:08.151999950 1.000000e-09 1.860900e-07 3.518700 2.122771e+48 1.719931e+19
2011-06-07 00:00:10.201999903 1.000000e-09 1.808400e-07 3.550100 1.990333e+48 1.601718e+19
...
2011-06-07 00:00:12.248999953 1.000000e-09 1.860900e-07 3.518700 2.122771e+48 1.719931e+19
2011-06-07 00:00:14.298999906 1.000000e-09 1.834600e-07 3.534262 2.055847e+48 1.660031e+19
2011-06-07 00:00:16.344999909 1.000000e-09 1.808400e-07 3.550100 1.990333e+48 1.601718e+19
2011-06-07 00:00:18.391999960 1.000000e-09 1.834600e-07 3.534262 2.055847e+48 1.660031e+19
"""
if not download_dir:
download_dir = get_and_create_download_dir()
Expand Down Expand Up @@ -1054,26 +1064,31 @@ def calculate_xray_luminosity(goests):
>>> from sunpy.instr.goes import calculate_xray_luminosity
>>> from sunpy.data.sample import GOES_XRS_TIMESERIES # doctest: +REMOTE_DATA
>>> goests = ts.TimeSeries(GOES_XRS_TIMESERIES) # doctest: +REMOTE_DATA
>>> goests.data # doctest: +REMOTE_DATA
xrsa xrsb
>>> goests.data[0:10] # doctest: +REMOTE_DATA
xrsa xrsb
2011-06-06 23:59:59.961999893 1.000000e-09 1.887100e-07
2011-06-07 00:00:02.008999944 1.000000e-09 1.834600e-07
2011-06-07 00:00:04.058999896 1.000000e-09 1.860900e-07
2011-06-07 00:00:06.104999900 1.000000e-09 1.808400e-07
2011-06-07 00:00:08.151999950 1.000000e-09 1.860900e-07
...
2011-06-07 00:00:10.201999903 1.000000e-09 1.808400e-07
2011-06-07 00:00:12.248999953 1.000000e-09 1.860900e-07
2011-06-07 00:00:14.298999906 1.000000e-09 1.834600e-07
2011-06-07 00:00:16.344999909 1.000000e-09 1.808400e-07
2011-06-07 00:00:18.391999960 1.000000e-09 1.834600e-07
>>> goests_new = calculate_xray_luminosity(goests) # doctest: +REMOTE_DATA
>>> goests_new.data # doctest: +REMOTE_DATA
xrsa xrsb luminosity_xrsa luminosity_xrsb
>>> goests_new.data[0:10] # doctest: +REMOTE_DATA
xrsa xrsb luminosity_xrsa luminosity_xrsb
2011-06-06 23:59:59.961999893 1.000000e-09 1.887100e-07 2.896209e+14 5.465435e+16
2011-06-07 00:00:02.008999944 1.000000e-09 1.834600e-07 2.896209e+14 5.313384e+16
2011-06-07 00:00:04.058999896 1.000000e-09 1.860900e-07 2.896209e+14 5.389555e+16
2011-06-07 00:00:06.104999900 1.000000e-09 1.808400e-07 2.896209e+14 5.237503e+16
2011-06-07 00:00:08.151999950 1.000000e-09 1.860900e-07 2.896209e+14 5.389555e+16
...
2011-06-07 00:00:10.201999903 1.000000e-09 1.808400e-07 2.896209e+14 5.237503e+16
2011-06-07 00:00:12.248999953 1.000000e-09 1.860900e-07 2.896209e+14 5.389555e+16
2011-06-07 00:00:14.298999906 1.000000e-09 1.834600e-07 2.896209e+14 5.313384e+16
2011-06-07 00:00:16.344999909 1.000000e-09 1.808400e-07 2.896209e+14 5.237503e+16
2011-06-07 00:00:18.391999960 1.000000e-09 1.834600e-07 2.896209e+14 5.313384e+16
"""
# Check that input argument is of correct type
if not isinstance(goests, timeseries.XRSTimeSeries):
Expand Down
11 changes: 6 additions & 5 deletions sunpy/net/dataretriever/tests/test_noaa.py
Expand Up @@ -21,13 +21,13 @@ def mock_query_object(start_date, end_date):
"""
# Create a mock QueryResponse object
map_ = {
'TimeRange' : TimeRange(parse_time(start_date), parse_time(end_date)),
'TimeRange': TimeRange(parse_time(start_date), parse_time(end_date)),
'Time_start': parse_time(start_date),
'Time_end': parse_time(end_date),
'source': 'sdic',
'instrument': 'noaa-indices',
'physobs':'sunspot number',
'provider':'swpc'
'physobs': 'sunspot number',
'provider': 'swpc'
}

resp = QueryResponse.create(map_, LCClient._get_default_uri())
Expand All @@ -37,7 +37,7 @@ def mock_query_object(start_date, end_date):


@pytest.mark.remote_data
def test_fetch_working():
def test_fetch_working(tmpdir):
"""
Tests if the online server for noaa is working.
Uses the url : ftp://ftp.swpc.noaa.gov/pub/weekly/RecentIndices.txt
Expand All @@ -63,7 +63,8 @@ def test_fetch_working():
# Assert if the timerange is same
assert qr1.time_range() == TimeRange('2012/10/4', '2012/10/6')

res = LCClient.fetch(qr1)
target_dir = tmpdir.mkdir("down")
res = LCClient.fetch(qr1, path=target_dir.strpath)
download_list = res.wait(progress=False)
assert len(download_list) == len(qr1)
assert download_list[0].split('/')[-1] == 'RecentIndices.txt'
Expand Down
35 changes: 17 additions & 18 deletions sunpy/net/tests/test_fido.py
@@ -1,23 +1,21 @@
import os
import copy
import tempfile
import pathlib

import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, example, settings
from hypothesis import given, assume, settings

import astropy.units as u
from drms import DrmsQueryError

from sunpy.net import attr
from sunpy.net.vso import attrs as va
from sunpy.net import Fido, attrs as a
from sunpy.net.base_client import BaseClient
from sunpy.net.vso import QueryResponse as vsoQueryResponse
from sunpy.net.fido_factory import DownloadResponse, UnifiedResponse
from sunpy.net.dataretriever.client import QueryResponse
from sunpy.util.datatype_factory_base import NoMatchError, MultipleMatchError
from sunpy.util.datatype_factory_base import MultipleMatchError
from sunpy.time import TimeRange, parse_time
from sunpy import config

Expand Down Expand Up @@ -95,29 +93,30 @@ def check_response(query, unifiedresp):


@pytest.mark.remote_data
def test_save_path():
def test_save_path(tmpdir):
qr = Fido.search(a.Instrument('EVE'), a.Time("2016/10/01", "2016/10/02"), a.Level(0))

# Test when path is str
with tempfile.TemporaryDirectory() as target_dir:
files = Fido.fetch(qr, path=os.path.join(target_dir, "{instrument}", "{level}"))
for f in files:
assert target_dir in f
assert "eve{}0".format(os.path.sep) in f
target_dir = tmpdir.mkdir("down")
path = os.path.join(target_dir, "{instrument}", "{level}")
files = Fido.fetch(qr, path=path)
for f in files:
assert target_dir.strpath in f
assert "eve{}0".format(os.path.sep) in f


@pytest.mark.remote_data
def test_save_path_pathlib():
pathlib = pytest.importorskip('pathlib')
@pytest.mark.flaky(reruns=5)
def test_save_path_pathlib(tmpdir):
qr = Fido.search(a.Instrument('EVE'), a.Time("2016/10/01", "2016/10/02"), a.Level(0))

# Test when path is pathlib.Path
with tempfile.TemporaryDirectory() as target_dir:
path = pathlib.Path(target_dir, "{instrument}", "{level}")
files = Fido.fetch(qr, path=path)
for f in files:
assert target_dir in f
assert "eve{}0".format(os.path.sep) in f
target_dir = tmpdir.mkdir("down")
path = pathlib.Path(target_dir, "{instrument}", "{level}")
files = Fido.fetch(qr, path=path)
for f in files:
assert target_dir.strpath in f
assert "eve{}0".format(os.path.sep) in f


"""
Expand Down

0 comments on commit 7a16f81

Please sign in to comment.