Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: 1.9.1 backports #16901

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/API.rst.txt
Expand Up @@ -125,6 +125,8 @@ change is made.

* `scipy.optimize`

- `scipy.optimize.cython_optimize
rgommers marked this conversation as resolved.
Show resolved Hide resolved

* `scipy.signal`

- `scipy.signal.windows`
Expand Down
31 changes: 30 additions & 1 deletion doc/release/1.9.1-notes.rst
Expand Up @@ -5,15 +5,44 @@ SciPy 1.9.1 Release Notes
.. contents::

SciPy 1.9.1 is a bug-fix release with no new features
compared to 1.9.0.
compared to 1.9.0. Notably, some important meson build
fixes are included.

Authors
=======

* Anirudh Dagar (1)
* Ralf Gommers (4)
* Matt Haberland (2)
* Tyler Reddy (10)
* Atsushi Sakai (1)
* Eli Schwartz (1)
* Warren Weckesser (1)

A total of 7 people contributed to this release.
People with a "+" by their names contributed a patch for the first time.
This list of names is automatically generated, and may not be fully complete.

Issues closed for 1.9.1
-----------------------

* `#14517 <https://github.com/scipy/scipy/issues/14517>`__: scipy/linalg/tests/test_decomp.py::TestSchur::test_sort test...
* `#16765 <https://github.com/scipy/scipy/issues/16765>`__: DOC: \`scipy.stats.skew\` no longer returns 0 on constant input
* `#16787 <https://github.com/scipy/scipy/issues/16787>`__: BUG: Can't build 1.10 with mingw-w64 toolchain and numpy 1.21.6...
* `#16813 <https://github.com/scipy/scipy/issues/16813>`__: BUG: scipy.interpolate interp1d extrapolate behaviour change...
* `#16878 <https://github.com/scipy/scipy/issues/16878>`__: BUG: optimize.milp fails to execute when given exactly 3 constraints


Pull requests for 1.9.1
-----------------------

* `#16736 <https://github.com/scipy/scipy/pull/16736>`__: REL: prep for SciPy 1.9.1
* `#16749 <https://github.com/scipy/scipy/pull/16749>`__: BLD: install missing \`.pxd\` files, and update TODOs/FIXMEs...
* `#16750 <https://github.com/scipy/scipy/pull/16750>`__: BLD: make OpenBLAS detection work with CMake
* `#16760 <https://github.com/scipy/scipy/pull/16760>`__: BLD: use a bit more idiomatic approach to constructing paths...
* `#16768 <https://github.com/scipy/scipy/pull/16768>`__: DOC: stats.skew/kurtosis: returns NaN when input has only one...
* `#16794 <https://github.com/scipy/scipy/pull/16794>`__: BLD/REL: on Windows use numpy 1.22.3 as the version to build...
* `#16822 <https://github.com/scipy/scipy/pull/16822>`__: BUG/TST: linalg: Check the results of 'schur' more carefully.
* `#16825 <https://github.com/scipy/scipy/pull/16825>`__: BUG: interpolate: fix "previous" and "next" extrapolate logic...
* `#16862 <https://github.com/scipy/scipy/pull/16862>`__: BUG, DOC: Fix sphinx autosummary generation for \`odr\` and \`czt\`
* `#16881 <https://github.com/scipy/scipy/pull/16881>`__: MAINT: optimize.milp: fix input validation when three constraints...
10 changes: 10 additions & 0 deletions doc/source/conf.py
Expand Up @@ -261,6 +261,16 @@

autosummary_generate = True

# maps functions with a name same as a class name that is indistinguishable
# Ex: scipy.signal.czt and scipy.signal.CZT or scipy.odr.odr and scipy.odr.ODR
# Otherwise, the stubs are overwritten when the name is same for
# OS (like MacOS) which has a filesystem that ignores the case
# See https://github.com/sphinx-doc/sphinx/pull/7927
autosummary_filename_map = {
"scipy.odr.odr": "odr-function",
"scipy.signal.czt": "czt-function",
}


# -----------------------------------------------------------------------------
# Autodoc
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Expand Up @@ -10,7 +10,7 @@ project(
default_options: [
'buildtype=debugoptimized',
'c_std=c99',
'cpp_std=c++14', # TODO: use c++11 if 14 is not available
'cpp_std=c++14',
# TODO: the below -Wno flags are all needed to silence warnings in
# f2py-generated code. This should be fixed in f2py itself.
'c_args=-Wno-unused-function -Wno-conversion -Wno-misleading-indentation -Wno-incompatible-pointer-types',
Expand Down
14 changes: 11 additions & 3 deletions pyproject.toml
Expand Up @@ -37,24 +37,32 @@ requires = [
# loongarch64 requires numpy>=1.22.0
"numpy==1.22.0; platform_machine=='loongarch64'",

# On Windows we need to avoid 1.21.6, 1.22.0 and 1.22.1 because they were
# built with vc142. 1.22.3 is the first version that has 32-bit Windows
# wheels *and* was built with vc141. So use that:
"numpy==1.22.3; python_version=='3.10' and platform_machine=='win32' and platform_python_implementation != 'PyPy'",

# default numpy requirements
"numpy==1.18.5; python_version=='3.8' and (platform_machine!='arm64' or platform_system!='Darwin') and platform_machine!='aarch64' and platform_machine!='loongarch64' and platform_python_implementation != 'PyPy'",
"numpy==1.19.3; python_version=='3.9' and (platform_machine!='arm64' or platform_system!='Darwin') and platform_machine!='loongarch64' and platform_python_implementation != 'PyPy'",
# Note that 1.21.3 was the first version with a complete set of 3.10 wheels,
# however macOS was broken and it's safe to build against 1.21.6 on all platforms
# however macOS was broken and it's safe C API/ABI-wise to build against 1.21.6
# (see oldest-supported-numpy issues gh-28 and gh-45)
"numpy==1.21.6; python_version=='3.10' and platform_machine!='loongarch64' and platform_python_implementation != 'PyPy'",
"numpy==1.21.6; python_version=='3.10' and (platform_machine!='win32' and platform_machine!='loongarch64') and platform_python_implementation != 'PyPy'",
"numpy==1.23.2; python_version=='3.11' and platform_python_implementation != 'PyPy'",

# For Python versions which aren't yet officially supported,
# we specify an unpinned NumPy which allows source distributions
# to be used and allows wheels to be used as soon as they
# become available.
"numpy; python_version>='3.11'",
"numpy; python_version>='3.12'",
"numpy; python_version>='3.8' and platform_python_implementation=='PyPy'",
]

[project]
name = "SciPy"
# TODO: add `license-files` once PEP 639 is accepted (see meson-python#88)
# at that point, no longer include them in `py3.install_sources()`
license = {file = "LICENSE.txt"}
description = "Fundamental algorithms for scientific computing in Python"
maintainers = [
Expand Down
6 changes: 1 addition & 5 deletions scipy/_lib/_uarray/meson.build
@@ -1,8 +1,3 @@
# TODO: add_data_files('license')

# TODO: this used -std=c++14 if available, add c++11 otherwise
# can we now rely on c++14 unconditionally?

py3.extension_module('_uarray',
['_uarray_dispatch.cxx', 'vectorcall.cxx'],
cpp_args: ['-Wno-terminate', '-Wno-unused-function'],
Expand All @@ -15,6 +10,7 @@ py3.extension_module('_uarray',
python_sources = [
'__init__.py',
'_backend.py',
'LICENSE'
]

py3.install_sources(
Expand Down
2 changes: 1 addition & 1 deletion scipy/fft/_pocketfft/meson.build
Expand Up @@ -16,7 +16,6 @@ else
pocketfft_threads += ['-DPOCKETFFT_NO_MULTITHREADING']
endif

#TODO: add the equivalent of set_cxx_flags_hook
py3.extension_module('pypocketfft',
'pypocketfft.cxx',
cpp_args: pocketfft_threads,
Expand All @@ -32,6 +31,7 @@ python_sources = [
'__init__.py',
'basic.py',
'helper.py',
'LICENSE.md',
'realtransforms.py'
]

Expand Down
2 changes: 0 additions & 2 deletions scipy/integrate/meson.build
Expand Up @@ -190,8 +190,6 @@ py3.extension_module('_test_multivariate',
subdir: 'scipy/integrate'
)

# FIXME: something is wrong with the signature file, subroutines are not used
# _test_odeint_banded
_test_odeint_banded_module = custom_target('_test_odeint_banded_module',
output: ['_test_odeint_bandedmodule.c', '_test_odeint_banded-f2pywrappers.f'],
input: 'tests/banded5x5.pyf',
Expand Down
6 changes: 4 additions & 2 deletions scipy/interpolate/_interpolate.py
Expand Up @@ -519,7 +519,8 @@ def __init__(self, x, y, kind='linear', axis=-1,
self._call = self.__class__._call_previousnext
if _do_extrapolate(fill_value):
self._check_and_update_bounds_error_for_extrapolation()
fill_value = (np.nan, self.y.max(axis=axis))
# assume y is sorted by x ascending order here.
fill_value = (np.nan, np.take(self.y, -1, axis))
elif kind == 'next':
self._side = 'right'
self._ind = 1
Expand All @@ -528,7 +529,8 @@ def __init__(self, x, y, kind='linear', axis=-1,
self._call = self.__class__._call_previousnext
if _do_extrapolate(fill_value):
self._check_and_update_bounds_error_for_extrapolation()
fill_value = (self.y.min(axis=axis), np.nan)
# assume y is sorted by x ascending order here.
fill_value = (np.take(self.y, 0, axis), np.nan)
else:
# Check if we can delegate to numpy.interp (2x-10x faster).
np_types = (np.float_, np.int_)
Expand Down
82 changes: 82 additions & 0 deletions scipy/interpolate/tests/test_interpolate.py
Expand Up @@ -122,6 +122,28 @@ def setup_method(self):
self.y235 = np.arange(30.).reshape((2, 3, 5))
self.y325 = np.arange(30.).reshape((3, 2, 5))

# Edge updated test matrix 1
# array([[ 30, 1, 2, 3, 4, 5, 6, 7, 8, -30],
# [ 30, 11, 12, 13, 14, 15, 16, 17, 18, -30]])
self.y210_edge_updated = np.arange(20.).reshape((2, 10))
self.y210_edge_updated[:, 0] = 30
self.y210_edge_updated[:, -1] = -30

# Edge updated test matrix 2
# array([[ 30, 30],
# [ 2, 3],
# [ 4, 5],
# [ 6, 7],
# [ 8, 9],
# [ 10, 11],
# [ 12, 13],
# [ 14, 15],
# [ 16, 17],
# [-30, -30]])
self.y102_edge_updated = np.arange(20.).reshape((10, 2))
self.y102_edge_updated[0, :] = 30
self.y102_edge_updated[-1, :] = -30

self.fill_value = -100.0

def test_validation(self):
Expand Down Expand Up @@ -386,6 +408,36 @@ def test_previous(self):
bounds_error=True)
assert_raises(ValueError, interp1d, self.x10, self.y10, **opts)

# Tests for gh-16813
interpolator1D = interp1d([0, 1, 2],
[0, 1, -1], kind="previous",
fill_value='extrapolate',
assume_sorted=True)
assert_allclose(interpolator1D([-2, -1, 0, 1, 2, 3, 5]),
[np.nan, np.nan, 0, 1, -1, -1, -1])

interpolator1D = interp1d([2, 0, 1], # x is not ascending
[-1, 0, 1], kind="previous",
fill_value='extrapolate',
assume_sorted=False)
assert_allclose(interpolator1D([-2, -1, 0, 1, 2, 3, 5]),
[np.nan, np.nan, 0, 1, -1, -1, -1])

interpolator2D = interp1d(self.x10, self.y210_edge_updated,
kind="previous",
fill_value='extrapolate')
assert_allclose(interpolator2D([-1, -2, 5, 8, 12, 25]),
[[np.nan, np.nan, 5, 8, -30, -30],
[np.nan, np.nan, 15, 18, -30, -30]])

interpolator2DAxis0 = interp1d(self.x10, self.y102_edge_updated,
kind="previous",
axis=0, fill_value='extrapolate')
assert_allclose(interpolator2DAxis0([-2, 5, 12]),
[[np.nan, np.nan],
[10, 11],
[-30, -30]])

def test_next(self):
# Check the actual implementation of next interpolation.
interp10 = interp1d(self.x10, self.y10, kind='next')
Expand Down Expand Up @@ -425,6 +477,36 @@ def test_next(self):
bounds_error=True)
assert_raises(ValueError, interp1d, self.x10, self.y10, **opts)

# Tests for gh-16813
interpolator1D = interp1d([0, 1, 2],
[0, 1, -1], kind="next",
fill_value='extrapolate',
assume_sorted=True)
assert_allclose(interpolator1D([-2, -1, 0, 1, 2, 3, 5]),
[0, 0, 0, 1, -1, np.nan, np.nan])

interpolator1D = interp1d([2, 0, 1], # x is not ascending
[-1, 0, 1], kind="next",
fill_value='extrapolate',
assume_sorted=False)
assert_allclose(interpolator1D([-2, -1, 0, 1, 2, 3, 5]),
[0, 0, 0, 1, -1, np.nan, np.nan])

interpolator2D = interp1d(self.x10, self.y210_edge_updated,
kind="next",
fill_value='extrapolate')
assert_allclose(interpolator2D([-1, -2, 5, 8, 12, 25]),
[[30, 30, 5, 8, np.nan, np.nan],
[30, 30, 15, 18, np.nan, np.nan]])

interpolator2DAxis0 = interp1d(self.x10, self.y102_edge_updated,
kind="next",
axis=0, fill_value='extrapolate')
assert_allclose(interpolator2DAxis0([-2, 5, 12]),
[[30, 30],
[10, 11],
[np.nan, np.nan]])

def test_zero(self):
# Check the actual implementation of zero-order spline interpolation.
interp10 = interp1d(self.x10, self.y10, kind='zero')
Expand Down
11 changes: 5 additions & 6 deletions scipy/linalg/meson.build
Expand Up @@ -25,10 +25,10 @@ cython_linalg = custom_target('cython_linalg',
],
input: '_generate_pyx.py',
command: [py3, '@INPUT@', '-o', '@OUTDIR@'],
# FIXME - we only want to install the .pxd files! See comments for
# `pxd_files` further down.
# TODO - we only want to install the .pxd files! See comments for
# `pxd_files` further down.
install: true,
install_dir: py3.get_install_dir() + 'scipy/linalg'
install_dir: py3.get_install_dir() / 'scipy/linalg'
)

# pyx -> c, pyx -> cpp generators, depending on __init__.py here.
Expand Down Expand Up @@ -166,7 +166,6 @@ py3.extension_module('_interpolative',
'-Wno-tabs', '-Wno-conversion', '-Wno-argument-mismatch',
'-Wno-unused-dummy-argument', '-Wno-maybe-uninitialized'
],
# TODO: add -fallow-argument-mismatch for gfortran >= 10, see gh-11842
include_directories: [inc_np, inc_f2py],
dependencies: [py3_dep, lapack],
install: true,
Expand Down Expand Up @@ -332,7 +331,7 @@ py3.install_sources(
# https://mesonbuild.com/Installing.html says is for build targets to
# use:
# `custom_target(..., install: true, install_dir: ...)
# # should use `py3.get_install_dir() + 'scipy/linalg'` ?
# # should use `py3.get_install_dir() / 'scipy/linalg'` ?
# see https://github.com/mesonbuild/meson/issues/3206
#
# For the below code to work, the script generating the files should use
Expand All @@ -350,7 +349,7 @@ py3.install_sources(
# output : ['cython_blas2.pxd', 'cython_lapack2.pxd'],
# command : ['cp', '@INPUT0@', '@OUTPUT0@', '&&', 'cp', '@INPUT1@', '@OUTPUT1@'],
# install : true,
# install_dir: py3.get_install_dir() + 'scipy/linalg'
# install_dir: py3.get_install_dir() / 'scipy/linalg'
#)

subdir('tests')