Skip to content

Commit

Permalink
Make CI work with numpy v1.24 (#100)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
avalentino authored Jan 16, 2023
1 parent fb1f520 commit 90aa59a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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':[('<f8', (3,)),('<f8', (3,))], 'offsets':[0,24], 'itemsize':48, 'aligned':True})
dtype={'names': ['p', 'v'], 'formats': [('<f8', (3,)), ('<f8', (3,))], 'offsets': [0, 24], 'itemsize': 48, 'aligned': True})
>>> erfa.dt_pv
dtype([('p', '<f8', (3,)), ('v', '<f8', (3,))], align=True)
>>> erfa.dt_eraLDBODY
Expand Down
3 changes: 1 addition & 2 deletions erfa/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import sys
import types
import warnings
from distutils.version import LooseVersion


_deprecations_as_exceptions = False
Expand Down Expand Up @@ -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')

Expand Down
6 changes: 3 additions & 3 deletions erfa/tests/test_erfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions erfa_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down

0 comments on commit 90aa59a

Please sign in to comment.