Commit de048a10 authored by Ole Streicher's avatar Ole Streicher

New upstream version 3.1~rc1

parent b336b84f
This diff is collapsed.
Metadata-Version: 2.1
Name: astropy
Version: 3.0.5
Version: 3.1rc1
Summary: Community-developed python astronomy tools
Home-page: http://astropy.org
Author: The Astropy Developers
......
......@@ -30,9 +30,13 @@ Project Status
:target: https://travis-ci.org/astropy/astropy
:alt: Astropy's Travis CI Status
.. image:: https://coveralls.io/repos/astropy/astropy/badge.svg
:target: https://coveralls.io/r/astropy/astropy
:alt: Astropy's Coveralls Status
.. image:: https://circleci.com/gh/astropy/astropy.svg?style=svg
:target: https://circleci.com/gh/astropy/astropy
:alt: Astropy's CircleCI Status
.. image:: https://codecov.io/gh/astropy/astropy/branch/master/graph/badge.svg
:target: https://codecov.io/gh/astropy/astropy
:alt: Astropy's Coverage Status
.. image:: https://ci.appveyor.com/api/projects/status/ym7lxajcs5qwm31e/branch/master?svg=true
:target: https://ci.appveyor.com/project/Astropy/astropy/branch/master
......
......@@ -116,6 +116,7 @@ except:
# End compatibility imports...
# In case it didn't successfully import before the ez_setup checks
import pkg_resources
from setuptools import Distribution
......
......@@ -11,7 +11,8 @@ import sys
import os
from warnings import warn
__minimum_numpy_version__ = '1.10.0'
__minimum_python_version__ = '3.5'
__minimum_numpy_version__ = '1.13.0'
class UnsupportedPythonError(Exception):
......@@ -19,7 +20,6 @@ class UnsupportedPythonError(Exception):
# This is the same check as the one at the top of setup.py
__minimum_python_version__ = '3.5'
if sys.version_info < tuple((int(val) for val in __minimum_python_version__.split('.'))):
raise UnsupportedPythonError("Astropy does not support Python < {}".format(__minimum_python_version__))
......@@ -260,14 +260,12 @@ def _rebuild_extensions():
pass
# Set the bibtex entry to the article referenced in CITATION
# Set the bibtex entry to the article referenced in CITATION.
def _get_bibtex():
import re
citation_file = os.path.join(os.path.dirname(__file__), 'CITATION')
with open(citation_file, 'r') as citation:
refs = re.findall(r'\{[^()]*\}', citation.read())
refs = citation.read().split('@ARTICLE')[1:]
if len(refs) == 0: return ''
bibtexreference = "@ARTICLE{0}".format(refs[0])
return bibtexreference
......
This diff is collapsed.
/* -*- mode: c -*- */
/* Licensed under a 3-clause BSD style license - see LICENSE.rst */
/* "core.c" is auto-generated by erfa_generator.py from the template
"core.c.templ". Do *not* edit "core.c" directly, instead edit
"core.c.templ" and run erfa_generator.py from the source directory to
update it. */
#include <Python.h>
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <numpy/arrayobject.h>
#include "erfa.h"
typedef struct {
PyObject_HEAD
NpyIter *iter;
} _NpyIterObject;
#define MODULE_DOCSTRING \
"This module contains the C part of the ERFA python wrappers.\n" \
"This implements only the inner iterator loops, while the heavy lifting\n" \
"happens in Python in core.py\n\n" \
"For more about the module and how to use it, see the ``core.py``\n" \
"docstrings."
{%- for func in funcs %}
static PyObject *Py_{{ func.pyname }}(PyObject *self, PyObject *args, PyObject *kwds)
{
{%- for arg in func.args_by_inout('in|inout|out') %}
{{ arg.ctype }} (*_{{ arg.name }}){{ arg.cshape }};
{%- endfor %}
{%- for arg in func.args_by_inout('ret|stat') %}
{{ arg.ctype_ptr }} _{{ arg.name }};
{%- endfor %}
{%- if func.args_by_inout('stat')|length > 0 %}
int stat_ok = 1;
{%- endif %}
NpyIter *it = ((_NpyIterObject *)args)->iter;
char **dataptrarray = NpyIter_GetDataPtrArray(it);
NpyIter_IterNextFunc *iternext = NpyIter_GetIterNext(it, NULL);
Py_BEGIN_ALLOW_THREADS
do {
{%- for arg in func.args_by_inout('in|inout|out') %}
_{{ arg.name }} = (({{ arg.ctype }} (*){{ arg.cshape }})(dataptrarray[{{ func.args.index(arg) }}]));
{%- endfor %}
{{ func.args_by_inout('ret|stat')|map(attribute='name')|surround('_', ' = ')|join }}{{func.name}}({{ func.args_by_inout('in|inout|out')|map(attribute='name_for_call')|join(', ') }});
{%- for arg in func.args_by_inout('ret|stat') %}
*(({{ arg.ctype_ptr }} *)(dataptrarray[{{ func.args.index(arg) }}])) = _{{ arg.name }};
{%- endfor %}
{%- for arg in func.args_by_inout('stat') %}
if (_{{ arg.name }}) {
stat_ok = 0;
}
{%- endfor %}
} while (iternext(it));
Py_END_ALLOW_THREADS
{%- if func.args_by_inout('stat')|length > 0 %}
if (stat_ok) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
}
{%- else %}
Py_RETURN_NONE;
{%- endif %}
}
{%- endfor %}
static PyMethodDef module_functions[] = {
{%- for func in funcs %}
{ "_" "{{ func.pyname }}", (PyCFunction)Py_{{ func.pyname }}, METH_O, NULL },
{%- endfor %}
{ NULL }
};
struct module_state
{
int _dummy;
};
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_core",
MODULE_DOCSTRING,
sizeof(struct module_state),
module_functions,
NULL,
NULL,
NULL,
NULL
};
PyMODINIT_FUNC PyInit__core(void)
{
PyObject *m;
m = PyModule_Create(&moduledef);
if (m == NULL) {
return NULL;
}
import_array();
return m;
}
This diff is collapsed.
This diff is collapsed.
#ifndef ERFAADDITIONSDEF
#define ERFAADDITIONSDEF
/*
** - - - - - - - - - - - - - - - - -
** e r f a _ a d d i t i o n s . h
** - - - - - - - - - - - - - - - - -
**
** A few extra routines which are particularly handy for constructing
** pv vectors inside the coordinate transforms.
**
** MHvK proposed these to Catherine Hohenkerk for inclusion in SOFA
** on 2018-05-24, with the response suggesting this was reasonable and
** might thus be done.
*/
/* Extra/PVMergeExtract */
void eraPav2pv(double p[3], double v[3], double pv[2][3]);
void eraPv2pav(double pv[2][3], double p[3], double v[3]);
#endif
This diff is collapsed.
#include "erfa.h"
void eraPav2pv(double p[3], double v[3], double pv[2][3])
/*
** - - - - - - - - - -
** e r a P a v 2 p v
** - - - - - - - - - -
**
** Extend a p-vector to a pv-vector by appending a zero velocity.
**
** Given:
** p double[3] p-vector
** v double[3] v-vector
**
** Returned:
** pv double[2][3] pv-vector
**
** Called:
** eraCp copy p-vector
**
** Copyright (C) 2013-2017, NumFOCUS Foundation.
** Derived, with permission, from the SOFA library. See notes at end of file.
*/
{
eraCp(p, pv[0]);
eraCp(v, pv[1]);
return;
}
#include "erfa.h"
void eraPv2pav(double pv[2][3], double p[3], double v[3])
/*
** - - - - - - - - -
** e r a P v 2 p a v
** - - - - - - - - -
**
** Extend a p-vector to a pv-vector by appending a zero velocity.
**
** Given:
** pv double[2][3] pv-vector
**
** Returned:
** p double[3] p-vector
** v double[3] v-vector
**
** Called:
** eraCp copy p-vector
**
** Copyright (C) 2013-2017, NumFOCUS Foundation.
** Derived, with permission, from the SOFA library. See notes at end of file.
*/
{
eraCp(pv[0], p);
eraCp(pv[1], v);
return;
}
......@@ -11,13 +11,17 @@ from astropy_helpers.version_helpers import get_pkg_version_module
ERFAPKGDIR = os.path.relpath(os.path.dirname(__file__))
ERFA_SRC = os.path.abspath(os.path.join(ERFAPKGDIR, '..', '..', 'cextern', 'erfa'))
ERFA_SRC = os.path.abspath(os.path.join(ERFAPKGDIR, '..', '..',
'cextern', 'erfa'))
SRC_FILES = glob.glob(os.path.join(ERFA_SRC, '*'))
SRC_FILES += [os.path.join(ERFAPKGDIR, filename)
for filename in ['core.py.templ', 'core.c.templ', 'erfa_generator.py']]
for filename in ['pav2pv.c', 'pv2pav.c', 'erfa_additions.h',
'ufunc.c.templ', 'core.py.templ',
'erfa_generator.py']]
GEN_FILES = [os.path.join(ERFAPKGDIR, 'core.py'), os.path.join(ERFAPKGDIR, 'core.c')]
GEN_FILES = [os.path.join(ERFAPKGDIR, 'core.py'),
os.path.join(ERFAPKGDIR, 'ufunc.c')]
def pre_build_py_hook(cmd_obj):
......@@ -35,7 +39,7 @@ def pre_sdist_hook(cmd_obj):
def preprocess_source():
# Generating the ERFA wrappers should only be done if needed. This also
# ensures that it is not done for any release tarball since those will
# include core.py and core.c.
# include core.py and ufunc.c.
if all(os.path.exists(filename) for filename in GEN_FILES):
# Determine modification times
......@@ -65,7 +69,7 @@ def preprocess_source():
import jinja2 # pylint: disable=W0611
except ImportError:
log.warn("WARNING: jinja2 could not be imported, so the existing "
"ERFA core.py and core.c files will be used")
"ERFA core.py and ufunc.c files will be used")
return
name = 'erfa_generator'
......@@ -79,14 +83,12 @@ def preprocess_source():
import imp
gen = imp.load_source(name, filename)
gen.main(gen.DEFAULT_ERFA_LOC,
os.path.join(ERFAPKGDIR, 'core.py'),
gen.DEFAULT_TEMPLATE_LOC,
verbose=False)
gen.main(verbose=False)
def get_extensions():
sources = [os.path.join(ERFAPKGDIR, "core.c")]
sources = [os.path.join(ERFAPKGDIR, fn)
for fn in ("ufunc.c", "pav2pv.c", "pv2pav.c")]
include_dirs = ['numpy']
libraries = []
......@@ -95,12 +97,13 @@ def get_extensions():
else:
# get all of the .c files in the cextern/erfa directory
erfafns = os.listdir(ERFA_SRC)
sources.extend(['cextern/erfa/'+fn for fn in erfafns if fn.endswith('.c')])
sources.extend(['cextern/erfa/' + fn
for fn in erfafns if fn.endswith('.c')])
include_dirs.append('cextern/erfa')
erfa_ext = Extension(
name="astropy._erfa._core",
name="astropy._erfa.ufunc",
sources=sources,
include_dirs=include_dirs,
libraries=libraries,
......
......@@ -26,24 +26,24 @@ def test_erfa_wrapper():
iy, im, id, ihmsf = erfa.d2dtf("UTC", 3, jd, 0.0)
assert iy.shape == (121,)
assert ihmsf.shape == (121, 4)
assert ihmsf.dtype == np.dtype('i4')
assert ihmsf.shape == (121,)
assert ihmsf.dtype == erfa.dt_hmsf
iy, im, id, ihmsf = erfa.d2dtf("UTC", 3, jd[0], 0.0)
assert iy.shape == ()
assert ihmsf.shape == (4,)
assert ihmsf.dtype == np.dtype('i4')
assert ihmsf.shape == ()
assert ihmsf.dtype == erfa.dt_hmsf
def test_angle_ops():
sign, idmsf = erfa.a2af(6, -np.pi)
assert sign == b'-'
assert (idmsf == [180, 0, 0, 0]).all()
assert idmsf.item() == (180, 0, 0, 0)
sign, ihmsf = erfa.a2tf(6, np.pi)
assert sign == b'+'
assert (ihmsf == [12, 0, 0, 0]).all()
assert ihmsf.item() == (12, 0, 0, 0)
rad = erfa.af2a('-', 180, 0, 0.0)
np.testing.assert_allclose(rad, -np.pi)
......@@ -59,7 +59,7 @@ def test_angle_ops():
sign, ihmsf = erfa.d2tf(1, -1.5)
assert sign == b'-'
assert (ihmsf == [36, 0, 0, 0]).all()
assert ihmsf.item() == (36, 0, 0, 0)
days = erfa.tf2d('+', 3, 0, 0.0)
np.testing.assert_allclose(days, 0.125)
......@@ -76,7 +76,9 @@ def test_spherical_cartesian():
np.testing.assert_allclose(phi, np.pi/4.0)
np.testing.assert_allclose(r, 2.0)
theta, phi, r, td, pd, rd = erfa.pv2s([[0.0, np.sqrt(2.0), np.sqrt(2.0)], [1.0, 0.0, 0.0]])
pv = np.array(([0.0, np.sqrt(2.0), np.sqrt(2.0)], [1.0, 0.0, 0.0]),
dtype=erfa.dt_pv)
theta, phi, r, td, pd, rd = erfa.pv2s(pv)
np.testing.assert_allclose(theta, np.pi/2.0)
np.testing.assert_allclose(phi, np.pi/4.0)
np.testing.assert_allclose(r, 2.0)
......@@ -91,7 +93,8 @@ def test_spherical_cartesian():
np.testing.assert_allclose(c, [0.0, np.sqrt(2.0)/2.0, np.sqrt(2.0)/2.0], atol=1e-14)
pv = erfa.s2pv(np.pi/2.0, np.pi/4.0, 2.0, np.sqrt(2.0)/2.0, 0.0, 0.0)
np.testing.assert_allclose(pv, [[0.0, np.sqrt(2.0), np.sqrt(2.0)], [-1.0, 0.0, 0.0]], atol=1e-14)
np.testing.assert_allclose(pv['p'], [0.0, np.sqrt(2.0), np.sqrt(2.0)], atol=1e-14)
np.testing.assert_allclose(pv['v'], [-1.0, 0.0, 0.0], atol=1e-14)
def test_errwarn_reporting():
......@@ -166,51 +169,46 @@ def test_vector_inouts():
np.testing.assert_allclose(res3, [expected]*4)
def test_matrix_in():
def test_pv_in():
jd1 = 2456165.5
jd2 = 0.401182685
pvmat = np.empty((2, 3))
pvmat[0][0] = -6241497.16
pvmat[0][1] = 401346.896
pvmat[0][2] = -1251136.04
pvmat[1][0] = -29.264597
pvmat[1][1] = -455.021831
pvmat[1][2] = 0.0266151194
pv = np.empty((), dtype=erfa.dt_pv)
pv['p'] = [-6241497.16,
401346.896,
-1251136.04]
pv['v'] = [-29.264597,
-455.021831,
0.0266151194]
astrom = erfa.apcs13(jd1, jd2, pvmat)
astrom = erfa.apcs13(jd1, jd2, pv)
assert astrom.shape == ()
# values from t_erfa_c
np.testing.assert_allclose(astrom['pmt'], 12.65133794027378508)
np.testing.assert_allclose(astrom['em'], 1.010428384373318379)
np.testing.assert_allclose(astrom['eb'], [.9012691529023298391,
-.4173999812023068781,
-.1809906511146821008])
np.testing.assert_allclose(astrom['eb'], [0.9012691529023298391,
-.4173999812023068781,
-.1809906511146821008])
np.testing.assert_allclose(astrom['bpn'], np.eye(3))
# first make sure it *fails* if we mess with the input orders
pvmatbad = np.roll(pvmat.ravel(), 1).reshape((2, 3))
astrombad = erfa.apcs13(jd1, jd2, pvmatbad)
pvbad = np.empty_like(pv)
pvbad['p'], pvbad['v'] = pv['v'], pv['p']
astrombad = erfa.apcs13(jd1, jd2, pvbad)
assert not np.allclose(astrombad['em'], 1.010428384373318379)
pvmatarr = np.array([pvmat]*3)
astrom2 = erfa.apcs13(jd1, jd2, pvmatarr)
pvarr = np.array([pv]*3)
astrom2 = erfa.apcs13(jd1, jd2, pvarr)
assert astrom2.shape == (3,)
np.testing.assert_allclose(astrom2['em'], 1.010428384373318379)
# try striding of the input array to make non-contiguous
pvmatarr = np.array([pvmat]*9)[::3]
pvmatarr = np.array([pv]*9)[::3]
astrom3 = erfa.apcs13(jd1, jd2, pvmatarr)