Skip to content

Commit

Permalink
Merge pull request astropy#10900 from pllim/min-python-3.7
Browse files Browse the repository at this point in the history
MNT: Bump minversion of Python to 3.7 (also Scipy, PyYAML, Matplotlib)
  • Loading branch information
bsipocz authored Oct 27, 2020
2 parents 3421137 + 3a9b0d2 commit 3b4a74c
Show file tree
Hide file tree
Showing 27 changed files with 72 additions and 134 deletions.
44 changes: 1 addition & 43 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@ jobs:
command: |
mkdir -p $HOME/.astropy/config/
printf "unicode_output = True\nmax_width = 500" > $HOME/.astropy/config/astropy.cfg
# In addition to testing 32-bit, we also use the 3.6 and 3.7 builds to
# In addition to testing 32-bit, we also use the 3.7 builds to
# test the ability to run the test suite in parallel.
- run:
name: Install dependencies for Python 3.6
command: /opt/python/cp36-cp36m/bin/pip install tox
- run:
name: Run tests for Python 3.6
command: /opt/python/cp36-cp36m/bin/python -m tox -e py36-test -- -n=4 --durations=50
- run:
name: Install dependencies for Python 3.7
command: /opt/python/cp37-cp37m/bin/pip install tox
Expand All @@ -39,40 +33,6 @@ jobs:
name: Run tests for Python 3.8
command: /opt/python/cp38-cp38/bin/python -m tox -e py38-test-double

image-tests-mpl212:
docker:
- image: astropy/image-tests-py36-mpl212:1.10
steps:
- checkout
- run:
name: Install dependencies
command: pip install -e .[test] pytest-mpl
- run:
name: Force scipy upgrade
command: pip install scipy -U
- run:
name: Run tests
command: pytest -P visualization --remote-data=astropy --open-files --mpl --mpl-results-path=$PWD/results -W ignore:np.asscalar
- store_artifacts:
path: results

image-tests-mpl222:
docker:
- image: astropy/image-tests-py36-mpl222:1.10
steps:
- checkout
- run:
name: Install dependencies
command: pip install -e .[test] pytest-mpl
- run:
name: Force scipy upgrade
command: pip install scipy -U
- run:
name: Run tests
command: pytest -P visualization --remote-data=astropy --open-files --mpl --mpl-results-path=$PWD/results -W ignore:np.asscalar
- store_artifacts:
path: results

image-tests-mpl302:
docker:
- image: astropy/image-tests-py37-mpl302:1.10
Expand Down Expand Up @@ -123,8 +83,6 @@ workflows:
tests:
jobs:
- 32bit-and-parallel
- image-tests-mpl212
- image-tests-mpl222
- image-tests-mpl302
- image-tests-mpl310
- image-tests-mpldev
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ matrix:
# that tests do not open and leave open any files. This has a performance
# impact on running the tests, hence why it is not enabled by default.
- language: python
python: 3.6
python: 3.7
stage: Comprehensive tests
name: Python 3.6 with oldest supported version of all dependencies
env: TOXENV="py36-test-oldestdeps"
name: Python 3.7 with oldest supported version of all dependencies
env: TOXENV="py37-test-oldestdeps"
TOXPOSARGS="--open-files"

# Now try with all optional dependencies.
Expand Down
18 changes: 16 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ astropy.modeling
^^^^^^^^^^^^^^^^

- N-dimensional least-squares statistic and specific 1,2,3-D methods [#10670]



4.2 (unreleased)
Expand Down Expand Up @@ -294,6 +294,12 @@ astropy.table

- Raise a TypeError when a scalar column is added to an unsized table. [#10476]

- The order of columns when creating a table from a ``list`` of ``dict`` may be
changed. Previously, the order was alphabetical because the ``dict`` keys
were assumed to be in random order. Since Python 3.7, the keys are always in
order of insertion, so ``Table`` now uses the order of keys in the first row
to set the column order. To alphabetize the columns to match the previous
behavior, use ``t = t[sorted(t.colnames)]``. [#10900]

astropy.tests
^^^^^^^^^^^^^
Expand Down Expand Up @@ -424,7 +430,15 @@ astropy.wcs
Other Changes and Additions
---------------------------

- Minimum version of supported Numpy is now 1.17. [#10664]
- Minimum version of required Python is now 3.7. [#10900]

- Minimum version of required Numpy is now 1.17. [#10664]

- Minimum version of required Scipy is now 1.1. [#10900]

- Minimum version of required PyYAML is now 3.13. [#10900]

- Minimum version of required Matplotlib is now 3.0. [#10900]

- The private ``_erfa`` module has been converted to its own package,
``pyerfa``, which is a required dependency for astropy, and can be imported
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ package.

**Code Quality**
* Are the [coding guidelines](https://docs.astropy.org/en/latest/development/codeguide.html) followed?
* Is the code compatible with Python >=3.6?
* Is the code compatible with Python >=3.7?
* Are there dependencies other than the `astropy` core, the Python Standard
Library, and NumPy 1.17.0 or later?
* Is the package importable even if the C-extensions are not built?
Expand Down
9 changes: 6 additions & 3 deletions astropy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@

from .version import version as __version__

__minimum_python_version__ = '3.6'
__minimum_python_version__ = '3.7'
__minimum_numpy_version__ = '1.17.0'
__minimum_erfa_version__ = '1.7'
__minimum_scipy_version__ = '0.18'
__minimum_scipy_version__ = '1.1'
# ASDF is an optional dependency, but this is the minimum version that is
# compatible with Astropy when it is installed.
__minimum_asdf_version__ = '2.6.0'
# PyYAML is an optional dependency, but this is the minimum version that is
# advertised to be supported.
__minimum_yaml_version__ = '3.12'
__minimum_yaml_version__ = '3.13'
# Matplotlib is an optional dependency, but this is the minimum version that is
# advertised to be supported.
__minimum_matplotlib_version__ = '3.0'


class UnsupportedPythonError(Exception):
Expand Down
4 changes: 2 additions & 2 deletions astropy/coordinates/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def search_around_3d(coords1, coords2, distlimit, storekdtree='kdtree_3d'):
Notes
-----
This function requires `SciPy <https://www.scipy.org/>`_ (>=0.12.0)
This function requires `SciPy <https://www.scipy.org/>`_
to be installed or it will fail.
If you are using this function to search in a catalog for matches around
Expand Down Expand Up @@ -318,7 +318,7 @@ def search_around_sky(coords1, coords2, seplimit, storekdtree='kdtree_sky'):
Notes
-----
This function requires `SciPy <https://www.scipy.org/>`_ (>=0.12.0)
This function requires `SciPy <https://www.scipy.org/>`_
to be installed or it will fail.
In the current implementation, the return values are always sorted in the
Expand Down
4 changes: 2 additions & 2 deletions astropy/coordinates/sky_coordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ def search_around_sky(self, searcharoundcoords, seplimit):
Notes
-----
This method requires `SciPy <https://www.scipy.org/>`_ (>=0.12.0) to be
This method requires `SciPy <https://www.scipy.org/>`_ to be
installed or it will fail.
In the current implementation, the return values are always sorted in
Expand Down Expand Up @@ -1402,7 +1402,7 @@ def search_around_3d(self, searcharoundcoords, distlimit):
Notes
-----
This method requires `SciPy <https://www.scipy.org/>`_ (>=0.12.0) to be
This method requires `SciPy <https://www.scipy.org/>`_ to be
installed or it will fail.
In the current implementation, the return values are always sorted in
Expand Down
9 changes: 2 additions & 7 deletions astropy/io/fits/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@

from astropy.utils.exceptions import AstropyUserWarning

try:
# Support the Python 3.6 PathLike ABC where possible
from os import PathLike
path_like = (str, PathLike)
except ImportError:
path_like = (str,)

from os import PathLike
path_like = (str, PathLike)

cmp = lambda a, b: (a > b) - (a < b)

Expand Down
8 changes: 4 additions & 4 deletions astropy/io/misc/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- `astropy.coordinates.EarthLocation`
- `astropy.table.SerializedColumn`
.. note:: This module requires PyYaml version 3.12 or later.
.. note:: This module requires PyYaml version 3.13 or later.
Example
=======
Expand Down Expand Up @@ -71,10 +71,10 @@
try:
import yaml
except ImportError:
raise ImportError('The PyYAML package is required for astropy.io.misc.yaml and must be 3.12 or later')
raise ImportError('The PyYAML package is required for astropy.io.misc.yaml and must be 3.13 or later')
else:
if not minversion(yaml, '3.12'):
raise ImportError('The PyYAML package is required for astropy.io.misc.yaml and must be 3.12 or later')
if not minversion(yaml, '3.13'):
raise ImportError('The PyYAML package is required for astropy.io.misc.yaml and must be 3.13 or later')


__all__ = ['AstropyLoader', 'AstropyDumper', 'load', 'load_all', 'dump']
Expand Down
6 changes: 3 additions & 3 deletions astropy/modeling/functional_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def evaluate(cls, r, amplitude, r_eff, n):
from scipy.special import gammaincinv
cls._gammaincinv = gammaincinv
except ValueError:
raise ImportError('Sersic1D model requires scipy > 0.11.')
raise ImportError('Sersic1D model requires scipy.')

return (amplitude * np.exp(
-cls._gammaincinv(2 * n, 0.5) * ((r / r_eff) ** (1 / n) - 1)))
Expand Down Expand Up @@ -2125,7 +2125,7 @@ def evaluate(cls, x, y, amplitude, x_0, y_0, radius):
cls._rz = jn_zeros(1, 1)[0] / np.pi
cls._j1 = j1
except ValueError:
raise ImportError('AiryDisk2D model requires scipy > 0.11.')
raise ImportError('AiryDisk2D model requires scipy.')

r = np.sqrt((x - x_0) ** 2 + (y - y_0) ** 2) / (radius / cls._rz)

Expand Down Expand Up @@ -2438,7 +2438,7 @@ def evaluate(cls, x, y, amplitude, r_eff, n, x_0, y_0, ellip, theta):
from scipy.special import gammaincinv
cls._gammaincinv = gammaincinv
except ValueError:
raise ImportError('Sersic2D model requires scipy > 0.11.')
raise ImportError('Sersic2D model requires scipy.')

bn = cls._gammaincinv(2. * n, 0.5)
a, b = r_eff, (1 - ellip) * r_eff
Expand Down
6 changes: 1 addition & 5 deletions astropy/modeling/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@
import numpy as np

from astropy import units as u
from astropy.utils import minversion
from .core import Model

try:
import scipy
from scipy.interpolate import interpn
has_scipy = True
except ImportError:
has_scipy = False

has_scipy = has_scipy and minversion(scipy, "0.14")

__all__ = ['tabular_model', 'Tabular1D', 'Tabular2D']

__doctest_requires__ = {('tabular_model'): ['scipy']}
Expand Down Expand Up @@ -216,7 +212,7 @@ def evaluate(self, *inputs):
inputs = [inp.flatten() for inp in inputs[: self.n_inputs]]
inputs = np.array(inputs).T
if not has_scipy: # pragma: no cover
raise ImportError("This model requires scipy >= v0.14")
raise ImportError("Tabular model requires scipy.")
result = interpn(self.points, self.lookup_table, inputs,
method=self.method, bounds_error=self.bounds_error,
fill_value=self.fill_value)
Expand Down
10 changes: 2 additions & 8 deletions astropy/stats/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,19 +1098,13 @@ def _scipy_kraft_burrows_nousek(N, B, CL):

from scipy.optimize import brentq
from scipy.integrate import quad
from scipy.special import factorial

from math import exp

def eqn8(N, B):
n = np.arange(N + 1, dtype=np.float64)
# Create an array containing the factorials. scipy.special.factorial
# requires SciPy 0.14 (#5064) therefore this is calculated by using
# numpy.cumprod. This could be replaced by factorial again as soon as
# older SciPy are not supported anymore but the cumprod alternative
# might also be a bit faster.
factorial_n = np.ones(n.shape, dtype=np.float64)
np.cumprod(n[1:], out=factorial_n[1:])
return 1. / (exp(-B) * np.sum(np.power(B, n) / factorial_n))
return 1. / (exp(-B) * np.sum(np.power(B, n) / factorial(n)))

# The parameters of eqn8 do not vary between calls so we can calculate the
# result once and reuse it. The same is True for the factorial of N.
Expand Down
7 changes: 1 addition & 6 deletions astropy/table/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,7 @@ def _init_from_list_of_dicts(self, data, names, dtype, n_cols, copy):
for row in data:
names_from_data.update(row)

# Put names into a preferred order, either using the first row of data
# if it is ordered, or alphabetically. Starting with Python 3.7, dict
# is ordered so this test can be relaxed. (In practice CPython 3.6 is
# this way, but not according to the formal spec).
if (isinstance(data[0], OrderedDict)
and set(data[0].keys()) == names_from_data):
if set(data[0].keys()) == names_from_data:
names_from_data = list(data[0].keys())
else:
names_from_data = sorted(names_from_data)
Expand Down
4 changes: 3 additions & 1 deletion astropy/table/tests/test_init_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,10 @@ def test_init_from_row_OrderedDict(table_type):
rows34 = [row3, row4]
t1 = table_type(rows=rows12)
t2 = table_type(rows=rows34)
t3 = t2[sorted(t2.colnames)]
assert t1.colnames == ['b', 'a']
assert t2.colnames == ['a', 'b']
assert t2.colnames == ['b', 'a']
assert t3.colnames == ['a', 'b']


def test_init_from_rows_as_generator():
Expand Down
2 changes: 1 addition & 1 deletion astropy/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __exit__(self, *exc_info):
# https://github.com/astropy/astropy/pull/7372
(r"Importing from numpy\.testing\.decorators is deprecated, "
r"import from numpy\.testing instead\.", DeprecationWarning),
# inspect raises this slightly different warning on Python 3.6-3.7.
# inspect raises this slightly different warning on Python 3.7.
# Keeping it since e.g. lxml as of 3.8.0 is still calling getargspec()
(r"inspect\.getargspec\(\) is deprecated, use "
r"inspect\.signature\(\) or inspect\.getfullargspec\(\)",
Expand Down
4 changes: 0 additions & 4 deletions astropy/units/quantity_helper/scipy_special.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ def get_scipy_special_helpers():
import scipy.special as sps
SCIPY_HELPERS = {}
for name in dimensionless_to_dimensionless_sps_ufuncs:
# TODO: Revert https://github.com/astropy/astropy/pull/7219 when
# astropy requires scipy>=0.18, and loggamma is guaranteed
# to exist.
# See https://github.com/astropy/astropy/issues/7159
ufunc = getattr(sps, name, None)
if ufunc:
SCIPY_HELPERS[ufunc] = helper_dimensionless_to_dimensionless
Expand Down
7 changes: 5 additions & 2 deletions astropy/visualization/mpl_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
# plotting style. It is no longer documented/recommended as of Astropy v3.0
# but is kept here for backward-compatibility.

from astropy import __minimum_matplotlib_version__
from astropy.utils import minversion

# This returns False if matplotlib cannot be imported
MATPLOTLIB_GE_1_5 = minversion('matplotlib', '1.5')
MATPLOTLIB = minversion('matplotlib', __minimum_matplotlib_version__)


__all__ = ['astropy_mpl_style_1', 'astropy_mpl_style']

Expand Down Expand Up @@ -75,12 +77,13 @@
'#188487', # turquoise
'#E24A33'] # orange

if MATPLOTLIB_GE_1_5:
if MATPLOTLIB:
# This is a dependency of matplotlib, so should be present.
from cycler import cycler
astropy_mpl_style_1['axes.prop_cycle'] = cycler('color', color_cycle)
else:
astropy_mpl_style_1['axes.color_cycle'] = color_cycle


astropy_mpl_style = astropy_mpl_style_1
"""The most recent version of the astropy plotting style."""
9 changes: 1 addition & 8 deletions astropy/visualization/scripts/fits2bitmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,9 @@ def fits2bitmap(filename, ext=0, out_fn=None, stretch='linear',
out_fn = os.path.splitext(out_fn)[0]
out_fn += '.png'

# need to explicitly define the output format due to a bug in
# matplotlib (<= 2.1), otherwise the format will always be PNG
# explicitly define the output format
out_format = os.path.splitext(out_fn)[1][1:]

# workaround for matplotlib 2.0.0 bug where png images are inverted
# (mpl-#7656)
if (out_format.lower() == 'png' and
matplotlib.__version__[:5] == '2.0.0'):
image = image[::-1]

try:
cm.get_cmap(cmap)
except ValueError:
Expand Down
Loading

0 comments on commit 3b4a74c

Please sign in to comment.