Skip to content

Commit

Permalink
Merge pull request #23 from kbg/master
Browse files Browse the repository at this point in the history
Fixed pytest and some Pandas issues, and updated the documentation
  • Loading branch information
kbg committed Feb 17, 2019
2 parents 635044e + cc1e7bc commit d4ab3b3
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 21 deletions.
3 changes: 3 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ Contributors:
- Monica Bobra
- Arthur Amezcua
- David Perez-Suarez
- Nitin Choudhary
- Stuart Mumford
- Nabil Freij
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014-2016 Kolja Glogowski and others.
Copyright (c) 2014-2019 Kolja Glogowski and others.
See AUTHORS.txt for a list of contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ drms
====

`Docs <http://drms.readthedocs.io/>`_ |
`Tutorial <http://drms.readthedocs.io/en/stable/tutorial.html>`_ |
`Github <https://github.com/kbg/drms>`_ |
`Tutorial <https://drms.readthedocs.io/en/latest/tutorial.html>`_ |
`Github <https://github.com/sunpy/drms>`_ |
`PyPI <https://pypi.python.org/pypi/drms>`_

The ``drms`` module provides an easy-to-use interface for accessing HMI,
Expand All @@ -22,7 +22,7 @@ The ``drms`` module supports Python 2.7 and Python 3.4 or newer. It
requires the following Python packages:

- NumPy, version 1.9.0 or newer
- Pandas, version 0.14.1 or newer
- Pandas, version 0.15.0 or newer
- Six, version 1.8.0 or newer

The module might also work with earlier versions, but it has not been
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ drms documentation

:Release: |version|
:Date: |today|
:Github: https://github.com/kbg/drms
:Github: https://github.com/sunpy/drms
:PyPI: https://pypi.python.org/pypi/drms

Python module for accessing HMI, AIA and MDI data.
Expand Down
2 changes: 1 addition & 1 deletion doc/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The ``drms`` module supports Python 2.7 and Python 3.4 or newer. It
requires the following Python packages:

- NumPy, version 1.9.0 or newer
- Pandas, version 0.14.1 or newer
- Pandas, version 0.15.0 or newer
- Six, version 1.8.0 or newer

The module might also work with earlier versions, but it has not been
Expand Down
6 changes: 3 additions & 3 deletions doc/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This tutorial gives an introduction on how to use the ``drms`` Python
module. More detailed information on the different classes and functions
can be found in the :ref:`API Reference Manual <api>`. In addition to
this tutorial, many example scripts are available in the
`source code package <https://github.com/kbg/drms/releases/latest>`_
`source code package <https://github.com/sunpy/drms/releases/latest>`_
of the ``drms`` module.

.. tip::
Expand Down Expand Up @@ -414,10 +414,10 @@ Example scripts
---------------

There are many example scripts available in the
`examples directory <https://github.com/kbg/drms/tree/master/examples>`_
`examples directory <https://github.com/sunpy/drms/tree/master/examples>`_
of the ``drms`` Python package source code. An archive of the latest
source code release can be downloaded from the
`drms relase page <https://github.com/kbg/drms/releases/latest>`_
`drms relase page <https://github.com/sunpy/drms/releases/latest>`_
on Github.

.. For more information, use ``help(drms)`` inside the Python interpreter,
4 changes: 2 additions & 2 deletions drms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2014-2016 Kolja Glogowski and others.
# Copyright (c) 2014-2019 Kolja Glogowski and others.
# See AUTHORS.txt for a list of contributors.
#
# Permission is hereby granted, free of charge, to any person
Expand All @@ -25,7 +25,7 @@
"""
Access HMI, AIA and MDI data with Python
The latest release is avaiable at https://github.com/kbg/drms .
The latest release is avaiable at https://github.com/sunpy/drms .
"""

from __future__ import absolute_import, division, print_function
Expand Down
10 changes: 7 additions & 3 deletions drms/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import time
import warnings
from collections import OrderedDict
from six import string_types
from six.moves.urllib.request import urlretrieve
from six.moves.urllib.error import HTTPError, URLError
Expand Down Expand Up @@ -1086,7 +1087,8 @@ def query(self, ds, key=None, seg=None, link=None, convert_numeric=True,
if 'keywords' in lres:
names = [it['name'] for it in lres['keywords']]
values = [it['values'] for it in lres['keywords']]
res_key = pd.DataFrame.from_items(zip(names, values))
res_key = pd.DataFrame.from_dict(
OrderedDict(zip(names, values)))
else:
res_key = pd.DataFrame()
if convert_numeric:
Expand All @@ -1097,7 +1099,8 @@ def query(self, ds, key=None, seg=None, link=None, convert_numeric=True,
if 'segments' in lres:
names = [it['name'] for it in lres['segments']]
values = [it['values'] for it in lres['segments']]
res_seg = pd.DataFrame.from_items(zip(names, values))
res_seg = pd.DataFrame.from_dict(
OrderedDict(zip(names, values)))
else:
res_seg = pd.DataFrame()
res.append(res_seg)
Expand All @@ -1106,7 +1109,8 @@ def query(self, ds, key=None, seg=None, link=None, convert_numeric=True,
if 'links' in lres:
names = [it['name'] for it in lres['links']]
values = [it['values'] for it in lres['links']]
res_link = pd.DataFrame.from_items(zip(names, values))
res_link = pd.DataFrame.from_dict(
OrderedDict(zip(names, values)))
else:
res_link = pd.DataFrame()
res.append(res_link)
Expand Down
21 changes: 18 additions & 3 deletions drms/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,34 @@ def site_reachable(url, timeout=3):
kis_reachable = lazily_cached(site_reachable, kis_testurl)


def _get_item_marker(item, name):
"""
Compatibility function for pytest < 3.6.
Notes
-----
The method pytest.Item.get_closest_marker() is available since pytest 3.6,
while the method pytest.Item.get_marker() was removed in pytest 4.1.
"""
if hasattr(item, 'get_closest_marker'):
return item.get_closest_marker(name)
else:
return item.get_marker(name)


def pytest_runtest_setup(item):
# Skip JSOC online site tests if the site is not reachable.
if item.get_marker('jsoc') is not None:
if _get_item_marker(item, 'jsoc') is not None:
if not jsoc_reachable():
pytest.skip('JSOC is not reachable')

# Skip KIS online site tests if the site is not reachable.
if item.get_marker('kis') is not None:
if _get_item_marker(item, 'kis') is not None:
if not kis_reachable():
pytest.skip('KIS is not reachable')

# Skip export tests if no email address was specified.
if item.get_marker('export') is not None:
if _get_item_marker(item, 'export') is not None:
email = item.config.getoption('email')
if email is None:
pytest.skip('No email address specified; use the --email '
Expand Down
Empty file added drms/tests/online/__init__.py
Empty file.
1 change: 1 addition & 0 deletions drms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ def to_datetime(tstr, force=False):
s = s.str.replace('_', ' ')
s = s.str.replace('.', '-', n=2)
res = _pd_to_datetime_coerce(s)
res = res.dt.tz_localize(None) # remove any timezone information
return res.iloc[0] if (len(res) == 1) and np.isscalar(tstr) else res
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
LONG_DESCRIPTION = open('README.rst').read()
AUTHOR = 'Kolja Glogowski'
AUTHOR_EMAIL = '"Kolja Glogowski" <kolja@pixie.de>'
URL = 'https://github.com/kbg/drms'
URL = 'https://github.com/sunpy/drms'
LICENSE = 'MIT'

setup(name=NAME,
Expand All @@ -19,10 +19,10 @@
author_email=AUTHOR_EMAIL,
url=URL,
license=LICENSE,
packages=['drms', 'drms.tests'],
packages=['drms', 'drms.tests', 'drms.tests.online'],
install_requires=[
'numpy>=1.9.0',
'pandas>=0.14.1',
'pandas>=0.15.0',
'six>=1.8.0'],
classifiers=[
'Intended Audience :: Developers',
Expand All @@ -36,5 +36,6 @@
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering :: Astronomy'],
platforms='any')
15 changes: 14 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py34, py35, py36
envlist = py27, py35, py36, py37

[testenv]
deps =
Expand All @@ -12,3 +12,16 @@ commands =
python --version
python -m drms --version
python -m drms.tests

[testenv:py34]
deps =
Cython
six==1.8.0
numpy==1.9.0
pandas==0.15.0
pytest
changedir = {envtmpdir}
commands =
python --version
python -m drms --version
python -m drms.tests

0 comments on commit d4ab3b3

Please sign in to comment.