From 90aa59a7c959bc8503de294466a9a389fa8a7be6 Mon Sep 17 00:00:00 2001 From: Antonio Valentino Date: Mon, 16 Jan 2023 04:02:57 +0100 Subject: [PATCH] Make CI work with numpy v1.24 (#100) * Fix pytests warnings * Fix compatibility with numpy v1.24 * Fix tox syntax * Update tox configurarion * Improve xfail manageement for np 1.24 * Do not use the deprecated distutils package * Dtop the obsolete indexserver in tox.ini * Re-enable te "-W" flag for sphinx_build * Simplify the version checking for matplotlib * Update "reason" string for xfail tests * Update docstring of the xfail method of the test generator * Cleanup --- README.rst | 2 +- erfa/tests/helper.py | 3 +-- erfa/tests/test_erfa.py | 6 +++--- erfa_generator.py | 6 +++--- tox.ini | 11 ++++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index 6846206..4d306af 100644 --- a/README.rst +++ b/README.rst @@ -80,7 +80,7 @@ as `numpy.dtype` corresponding to structures used by ERFA_. Examples:: ([ 0.11260694, -0.38275202, -0.21613731], [0.02160375, 0.00826891, 0.00217806]), ([ 0.13401992, -0.37387798, -0.21361622], [0.0212094 , 0.00947838, 0.00286503]), ([ 0.15500031, -0.36379788, -0.21040601], [0.02073822, 0.01068061, 0.0035561 ])], - dtype={'names':['p','v'], 'formats':[('>> erfa.dt_pv dtype([('p', '>> erfa.dt_eraLDBODY diff --git a/erfa/tests/helper.py b/erfa/tests/helper.py index 8074020..a208477 100644 --- a/erfa/tests/helper.py +++ b/erfa/tests/helper.py @@ -6,7 +6,6 @@ import sys import types import warnings -from distutils.version import LooseVersion _deprecations_as_exceptions = False @@ -80,7 +79,7 @@ def treat_deprecations_as_exceptions(): except ImportError: pass else: - if LooseVersion(matplotlib.__version__) < '3': + if matplotlib.__version__[0] < '3': warnings.filterwarnings('ignore', category=DeprecationWarning, module='numpy.lib.type_check') diff --git a/erfa/tests/test_erfa.py b/erfa/tests/test_erfa.py index 8b5c51a..e582a34 100644 --- a/erfa/tests/test_erfa.py +++ b/erfa/tests/test_erfa.py @@ -364,7 +364,7 @@ def test_float32_input(): class TestAstromNotInplace: - def setup(self): + def setup_method(self): self.mjd_array = np.array( [58827.15925499, 58827.15925499, 58827.15925499, 58827.15925499, 58827.15925499]) @@ -420,12 +420,12 @@ def test_leap_seconds_expires(self): class TestLeapSeconds: """Test basic methods to control the ERFA leap-second table.""" - def setup(self): + def setup_method(self): self.erfa_ls = erfa.leap_seconds.get() self.expires = erfa.leap_seconds.expires self._expires = erfa.leap_seconds._expires - def teardown(self): + def teardown_method(self): erfa.leap_seconds.set(self.erfa_ls) erfa.leap_seconds._expires = self._expires diff --git a/erfa_generator.py b/erfa_generator.py index 0f9205f..5e6f311 100644 --- a/erfa_generator.py +++ b/erfa_generator.py @@ -597,17 +597,17 @@ def from_function(cls, func, t_erfa_c): nout=len(func.args_by_inout('out'))) def xfail(self): - """Whether the python test produced for this function will fail. + """Whether the python test produced for this function will fail when the xfail condition is verified. Right now this will be true for functions without inputs such - as eraIr. + as eraIr with numpy < 1.24. """ if self.nin + self.ninout == 0: if self.name == 'zpv': # Works on newer numpy return "np.__version__ < '1.21', reason='needs numpy >= 1.21'" else: - return "reason='do not yet support no-input ufuncs'" + return "np.__version__ < '1.24', reason='numpy < 1.24 do not support no-input ufuncs'" else: return None diff --git a/tox.ini b/tox.ini index 9d87a9f..74c9c31 100644 --- a/tox.ini +++ b/tox.ini @@ -8,13 +8,14 @@ requires = setuptools >= 30.3.0 pip >= 19.3.1 isolated_build = true -indexserver = - NIGHTLY = https://pypi.anaconda.org/scipy-wheels-nightly/simple [testenv] # Pass through the following environemnt variables which may be needed for the CI -passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI TRAVIS +passenv = HOME,WINDIR,LC_ALL,LC_CTYPE,CC,CI,TRAVIS + +setenv = + devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/scipy-wheels-nightly/simple # Run the tests in a temporary directory to make sure that we don't import # pyerfa from the source tree @@ -35,8 +36,8 @@ description = # The following provides some specific pinnings for key packages deps = - oldestdeps: numpy==1.17.* - devdeps: :NIGHTLY:numpy + oldestdeps: numpy==1.20.* + devdeps: numpy>=0.0.dev0 # The following indicates which extras_require from setup.cfg will be installed extras =