Skip to content

Commit

Permalink
MAINT: numpy cleanup version bumps: fixes issue #20458 (#20711)
Browse files Browse the repository at this point in the history
* The minimum numpy version in `scipy/scipy/__init__.py` has been aligned to the minimum requirement of `pyproject.toml`.

* A numpy version check has been removed from test `test_moments` in `scipy/stats/tests/test_multivariate.py` because the check looked for a numpy version earlier than the minimum.

* After checking discussion to PR #20459, found that the pytest guards could be removed.
So I did, and removed a couple imports and a function which would became unused too.

Co-authored-by: jacobogle <jacob.ogle94@outlook.com>
  • Loading branch information
peppedilillo and JacobOgle committed May 14, 2024
1 parent 471c3d1 commit 0f87966
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 27 deletions.
2 changes: 1 addition & 1 deletion scipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

from scipy._lib import _pep440
# In maintenance branch, change to np_maxversion N+3 if numpy is at N
np_minversion = '1.22.4'
np_minversion = '1.23.5'
np_maxversion = '9.9.99'
if (_pep440.parse(__numpy_version__) < _pep440.Version(np_minversion) or
_pep440.parse(__numpy_version__) >= _pep440.Version(np_maxversion)):
Expand Down
13 changes: 2 additions & 11 deletions scipy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from scipy._lib._fpumode import get_fpu_mode
from scipy._lib._testutils import FPUModeChangeWarning
from scipy._lib import _pep440
from scipy._lib._array_api import SCIPY_ARRAY_API, SCIPY_DEVICE


Expand Down Expand Up @@ -39,16 +38,8 @@ def pytest_configure(config):
"mark the desired skip configuration for the `skip_xp_backends` fixture.")


def _get_mark(item, name):
if _pep440.parse(pytest.__version__) >= _pep440.Version("3.6.0"):
mark = item.get_closest_marker(name)
else:
mark = item.get_marker(name)
return mark


def pytest_runtest_setup(item):
mark = _get_mark(item, "xslow")
mark = item.get_closest_marker("xslow")
if mark is not None:
try:
v = int(os.environ.get('SCIPY_XSLOW', '0'))
Expand All @@ -57,7 +48,7 @@ def pytest_runtest_setup(item):
if not v:
pytest.skip("very slow test; "
"set environment variable SCIPY_XSLOW=1 to run it")
mark = _get_mark(item, 'xfail_on_32bit')
mark = item.get_closest_marker("xfail_on_32bit")
if mark is not None and np.intp(0).itemsize < 8:
pytest.xfail(f'Fails on our 32-bit test platform(s): {mark.args[0]}')

Expand Down
14 changes: 4 additions & 10 deletions scipy/sparse/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class for generic tests" section.
import platform
import itertools
import sys
from scipy._lib import _pep440

import numpy as np
from numpy import (arange, zeros, array, dot, asarray,
Expand Down Expand Up @@ -5032,15 +5031,10 @@ def cases_64bit():
if bool(msg):
marks += [pytest.mark.skip(reason=msg)]

if _pep440.parse(pytest.__version__) >= _pep440.Version("3.6.0"):
markers = getattr(method, 'pytestmark', [])
for mark in markers:
if mark.name in ('skipif', 'skip', 'xfail', 'xslow'):
marks.append(mark)
else:
for mname in ['skipif', 'skip', 'xfail', 'xslow']:
if hasattr(method, mname):
marks += [getattr(method, mname)]
markers = getattr(method, 'pytestmark', [])
for mark in markers:
if mark.name in ('skipif', 'skip', 'xfail', 'xslow'):
marks.append(mark)

yield pytest.param(cls, method_name, marks=marks)

Expand Down
5 changes: 0 additions & 5 deletions scipy/stats/tests/test_multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

from scipy.integrate import romb, qmc_quad, tplquad
from scipy.special import multigammaln
from scipy._lib._pep440 import Version

from .common_tests import check_random_state_property
from .data._mvt import _qsimvtv
Expand Down Expand Up @@ -3775,10 +3774,6 @@ def test_against_betabinom_moments(self, method_name):
assert_allclose(res, ref)

def test_moments(self):
message = 'Needs NumPy 1.22.0 for multinomial broadcasting'
if Version(np.__version__) < Version("1.22.0"):
pytest.skip(reason=message)

rng = np.random.default_rng(28469824356873456)
dim = 5
n = rng.integers(1, 100)
Expand Down

0 comments on commit 0f87966

Please sign in to comment.