SciPy 1.9.0
SciPy 1.9.0 Release Notes
SciPy 1.9.0 is the culmination of 6 months of hard work. It contains
many new features, numerous bug-fixes, improved test coverage and better
documentation. There have been a number of deprecations and API changes
in this release, which are documented below. All users are encouraged to
upgrade to this release, as there are a large number of bug-fixes and
optimizations. Before upgrading, we recommend that users check that
their own code does not use deprecated SciPy functionality (to do so,
run your code with python -Wd and check for DeprecationWarning s).
Our development attention will now shift to bug-fix releases on the
1.9.x branch, and on adding new features on the main branch.
This release requires Python 3.8-3.11 and NumPy 1.18.5 or greater.
For running on PyPy, PyPy3 6.0+ is required.
Highlights of this release
- We have modernized our build system to use
meson, substantially improving
our build performance, and providing better build-time configuration and
cross-compilation support, - Added
scipy.optimize.milp, new function for mixed-integer linear
programming, - Added
scipy.stats.fitfor fitting discrete and continuous distributions
to data, - Tensor-product spline interpolation modes were added to
scipy.interpolate.RegularGridInterpolator, - A new global optimizer (DIviding RECTangles algorithm)
scipy.optimize.direct.
New features
scipy.interpolate improvements
- Speed up the
RBFInterpolatorevaluation with high dimensional
interpolants. - Added new spline based interpolation methods for
scipy.interpolate.RegularGridInterpolatorand its tutorial. scipy.interpolate.RegularGridInterpolatorandscipy.interpolate.interpn
now accept descending ordered points.RegularGridInterpolatornow handles length-1 grid axes.- The
BivariateSplinesubclasses have a new methodpartial_derivative
which constructs a new spline object representing a derivative of an
original spline. This mirrors the corresponding functionality for univariate
splines,splderandBSpline.derivative, and can substantially speed
up repeated evaluation of derivatives.
scipy.linalg improvements
scipy.linalg.expmnow accepts nD arrays. Its speed is also improved.- Minimum required LAPACK version is bumped to
3.7.1.
scipy.fft improvements
- Added
uarraymultimethods forscipy.fft.fhtandscipy.fft.ifht
to allow provision of third party backend implementations such as those
recently added to CuPy.
scipy.optimize improvements
-
A new global optimizer,
scipy.optimize.direct(DIviding RECTangles algorithm)
was added. For problems with inexpensive function evaluations, like the ones
in the SciPy benchmark suite,directis competitive with the best other
solvers in SciPy (dual_annealinganddifferential_evolution) in terms
of execution time. See
gh-14300 <https://github.com/scipy/scipy/pull/14300>__ for more details. -
Add a
full_outputparameter toscipy.optimize.curve_fitto output
additional solution information. -
Add a
integralityparameter toscipy.optimize.differential_evolution,
enabling integer constraints on parameters. -
Add a
vectorizedparameter to call a vectorized objective function only
once per iteration. This can improve minimization speed by reducing
interpreter overhead from the multiple objective function calls. -
The default method of
scipy.optimize.linprogis now'highs'. -
Added
scipy.optimize.milp, new function for mixed-integer linear
programming. -
Added Newton-TFQMR method to
newton_krylov. -
Added support for the
Boundsclass inshgoanddual_annealingfor
a more uniform API acrossscipy.optimize. -
Added the
vectorizedkeyword todifferential_evolution. -
approx_fprimenow works with vector-valued functions.
scipy.signal improvements
- The new window function
scipy.signal.windows.kaiser_bessel_derivedwas
added to compute the Kaiser-Bessel derived window. - Single-precision
hilbertoperations are now faster as a result of more
consistentdtypehandling.
scipy.sparse improvements
- Add a
copyparameter toscipy.sparce.csgraph.laplacian. Using inplace
computation withcopy=Falsereduces the memory footprint. - Add a
dtypeparameter toscipy.sparce.csgraph.laplacianfor type casting. - Add a
symmetrizedparameter toscipy.sparce.csgraph.laplacianto produce
symmetric Laplacian for directed graphs. - Add a
formparameter toscipy.sparce.csgraph.laplaciantaking one of the
three values:array, orfunction, orlodetermining the format of
the output Laplacian:arrayis a numpy array (backward compatible default);functionis a pointer to a lambda-function evaluating the
Laplacian-vector or Laplacian-matrix product;loresults in the format of theLinearOperator.
scipy.sparse.linalg improvements
lobpcgperformance improvements for small input cases.
scipy.spatial improvements
- Add an
orderparameter toscipy.spatial.transform.Rotation.from_quat
andscipy.spatial.transform.Rotation.as_quatto specify quaternion format.
scipy.stats improvements
-
scipy.stats.monte_carlo_testperforms one-sample Monte Carlo hypothesis
tests to assess whether a sample was drawn from a given distribution. Besides
reproducing the results of hypothesis tests likescipy.stats.ks_1samp,
scipy.stats.normaltest, andscipy.stats.cramervonmiseswithout small sample
size limitations, it makes it possible to perform similar tests using arbitrary
statistics and distributions. -
Several
scipy.statsfunctions support newaxis(integer or tuple of
integers) andnan_policy('raise', 'omit', or 'propagate'), and
keepdimsarguments.
These functions also support masked arrays as inputs, even if they do not have
ascipy.stats.mstatscounterpart. Edge cases for multidimensional arrays,
such as when axis-slices have no unmasked elements or entire inputs are of
size zero, are handled consistently. -
Add a
weightparameter toscipy.stats.hmean. -
Several improvements have been made to
scipy.stats.levy_stable. Substantial
improvement has been made for numerical evaluation of the pdf and cdf,
resolving #12658 and
#14944. The improvement is
particularly dramatic for stability parameteralphaclose to or equal to 1
and foralphabelow but approaching its maximum value of 2. The alternative
fast Fourier transform based method for pdf calculation has also been updated
to use the approach of Wang and Zhang from their 2008 conference paper
Simpson’s rule based FFT method to compute densities of stable distribution,
making this method more competitive with the default method. In addition,
users now have the option to change the parametrization of the Levy Stable
distribution to Nolan's "S0" parametrization which is used internally by
SciPy's pdf and cdf implementations. The "S0" parametrization is described in
Nolan's paper Numerical calculation of stable densities and distribution
functions upon which SciPy's
implementation is based. "S0" has the advantage thatdeltaandgamma
are proper location and scale parameters. Withdeltaandgammafixed,
the location and scale of the resulting distribution remain unchanged as
alphaandbetachange. This is not the case for the default "S1"
parametrization. Finally, more options have been exposed to allow users to
trade off between runtime and accuracy for both the default and FFT methods of
pdf and cdf calculation. More information can be found in the documentation
here (to be linked). -
Added
scipy.stats.fitfor fitting discrete and continuous distributions to
data. -
The methods
"pearson"and"tippet"fromscipy.stats.combine_pvalues
have been fixed to return the correct p-values, resolving
#15373. In addition, the
documentation forscipy.stats.combine_pvalueshas been expanded and improved. -
Unlike other reduction functions,
stats.modedidn't consume the axis
being operated on and failed for negative axis inputs. Both the bugs have been
fixed. Note thatstats.modewill now consume the input axis and return an
ndarray with theaxisdimension removed. -
Replaced implementation of
scipy.stats.ncfwith the implementation from
Boost for improved reliability. -
Add a
bitsparameter toscipy.stats.qmc.Sobol. It allows to use from 0
to 64 bits to compute the sequence. Default isNonewhich corresponds to
30 for backward compatibility. Using a higher value allow to sample more
points. Note:bitsdoes not affect the output dtype. -
Add a
integersmethod toscipy.stats.qmc.QMCEngine. It allows sampling
integers using any QMC sampler. -
Improved the fit speed and accuracy of
stats.pareto. -
Added
qrvsmethod toNumericalInversePolynomialto match the
situation forNumericalInverseHermite. -
Faster random variate generation for
gennormandnakagami. -
lloyd_centroidal_voronoi_tessellationhas been added to allow improved
sample distributions via iterative application of Voronoi diagrams and
centering operations -
Add
scipy.stats.qmc.PoissonDiskto sample using the Poisson disk sampling
method. It guarantees that samples are separated from each other by a
givenradius. -
Add
scipy.stats.pmeanto calculate the weighted power mean also called
generalized mean.
Deprecated features
- Due to collision with the shape parameter
nof several distributions,
use of the distributionmomentmethod with keyword argumentnis
deprecated. Keywordnis replaced with keywordorder. - Similarly, use of the distribution
intervalmethod with keyword arguments
alphais deprecated. Keywordalphais replaced with keyword
confidence. - The
'simplex','revised simplex', and'interior-point'methods
ofscipy.optimize.linprogare deprecated. Methodshighs,highs-ds,
orhighs-ipmshould be used in new code. - Support for non-numeric arrays has been deprecated from
stats.mode.
pandas.DataFrame.modecan be used instead. - The function
spatial.distance.kulsinskihas been deprecated in favor
ofspatial.distance.kulczynski1. - The
maxiterkeyword of the truncated Newton (TNC) algorithm has been
deprecated in favour ofmaxfun. - The
verticeskeyword ofDelauney.qhullnow raises a
DeprecationWarning, after having been deprecated in documentation only
for a long time. - The
extradockeyword ofrv_continuous,rv_discreteand
rv_samplenow raises a DeprecationWarning, after having been deprecated in
documentation only for a long time.
Expired Deprecations
There is an ongoing effort to follow through on long-standing deprecations.
The following previously deprecated features are affected:
- Object arrays in sparse matrices now raise an error.
- Inexact indices into sparse matrices now raise an error.
- Passing
radius=Nonetoscipy.spatial.SphericalVoronoinow raises an
error (not addingradiusdefaults to 1, as before). - Several BSpline methods now raise an error if inputs have
ndim > 1. - The
_rvsmethod of statistical distributions now requires asize
parameter. - Passing a
fillvaluethat cannot be cast to the output type in
scipy.signal.convolve2dnow raises an error. scipy.spatial.distancenow enforces that the input vectors are
one-dimensional.- Removed
stats.itemfreq. - Removed
stats.median_absolute_deviation. - Removed
n_jobskeyword argument and use ofk=Nonefrom
kdtree.query. - Removed
rightkeyword frominterpolate.PPoly.extend. - Removed
debugkeyword fromscipy.linalg.solve_*. - Removed class
_ppformscipy.interpolate. - Removed BSR methods
matvecandmatmat. - Removed
mlabtruncation mode fromcluster.dendrogram. - Removed
cluster.vq.py_vq2. - Removed keyword arguments
ftolandxtolfrom
optimize.minimize(method='Nelder-Mead'). - Removed
signal.windows.hanning. - Removed LAPACK
gegvfunctions fromlinalg; this raises the minimally
required LAPACK version to 3.7.1. - Removed
spatial.distance.matching. - Removed the alias
scipy.randomfornumpy.random. - Removed docstring related functions from
scipy.misc(docformat,
inherit_docstring_from,extend_notes_in_docstring,
replace_notes_in_docstring,indentcount_lines,filldoc,
unindent_dict,unindent_string). - Removed
linalg.pinv2.
Backwards incompatible changes
- Several
scipy.statsfunctions now convertnp.matrixtonp.ndarrays
before the calculation is performed. In this case, the output will be a scalar
ornp.ndarrayof appropriate shape rather than a 2Dnp.matrix.
Similarly, while masked elements of masked arrays are still ignored, the
output will be a scalar ornp.ndarrayrather than a masked array with
mask=False. - The default method of
scipy.optimize.linprogis now'highs', not
'interior-point'(which is now deprecated), so callback functions and
some options are no longer supported with the default method. With the
default method, thexattribute of the returnedOptimizeResultis
nowNone(instead of a non-optimal array) when an optimal solution
cannot be found (e.g. infeasible problem). - For
scipy.stats.combine_pvalues, the sign of the test statistic returned
for the method"pearson"has been flipped so that higher values of the
statistic now correspond to lower p-values, making the statistic more
consistent with those of the other methods and with the majority of the
literature. scipy.linalg.expmdue to historical reasons was using the sparse
implementation and thus was accepting sparse arrays. Now it only works with
nDarrays. For sparse usage,scipy.sparse.linalg.expmneeds to be used
explicitly.- The definition of
scipy.stats.circvarhas reverted to the one that is
standard in the literature; note that this is not the same as the square of
scipy.stats.circstd. - Remove inheritance to
QMCEngineinMultinomialQMCand
MultivariateNormalQMC. It removes the methodsfast_forwardandreset. - Init of
MultinomialQMCnow require the number of trials withn_trials.
Hence,MultinomialQMC.randomoutput has now the correct shape(n, pvals). - Several function-specific warnings (
F_onewayConstantInputWarning,
F_onewayBadInputSizesWarning,PearsonRConstantInputWarning,
PearsonRNearConstantInputWarning,SpearmanRConstantInputWarning, and
BootstrapDegenerateDistributionWarning) have been replaced with more
general warnings.
Other changes
-
A draft developer CLI is available for SciPy, leveraging the
doit,
clickandrich-clicktools. For more details, see
gh-15959. -
The SciPy contributor guide has been reorganized and updated
(see #15947 for details). -
QUADPACK Fortran routines in
scipy.integrate, which power
scipy.integrate.quad, have been marked asrecursive. This should fix rare
issues in multivariate integration (nquadand friends) and obviate the need
for compiler-specific compile flags (/recursivefor ifort etc). Please file
an issue if this change turns out problematic for you. This is also true for
FITPACKroutines inscipy.interpolate, which powersplrep,
splevetc., and*UnivariateSplineand*BivariateSplineclasses. -
the
USE_PROPACKenvironment variable has been renamed to
SCIPY_USE_PROPACK; setting to a non-zero value will enable
the usage of thePROPACKlibrary as before -
Building SciPy on windows with MSVC now requires at least the vc142
toolset (available in Visual Studio 2019 and higher).
Lazy access to subpackages
Before this release, all subpackages of SciPy (cluster, fft, ndimage,
etc.) had to be explicitly imported. Now, these subpackages are lazily loaded
as soon as they are accessed, so that the following is possible (if desired
for interactive use, it's not actually recommended for code,
see :ref:scipy-api):
import scipy as sp; sp.fft.dct([1, 2, 3]). Advantages include: making it
easier to navigate SciPy in interactive terminals, reducing subpackage import
conflicts (which before required
import networkx.linalg as nla; import scipy.linalg as sla),
and avoiding repeatedly having to update imports during teaching &
experimentation. Also see
the related community specification document.
SciPy switched to Meson as its build system
This is the first release that ships with Meson as
the build system. When installing with pip or pypa/build, Meson will be
used (invoked via the meson-python build hook). This change brings
significant benefits - most importantly much faster build times, but also
better support for cross-compilation and cleaner build logs.
Note:
This release still ships with support for numpy.distutils-based builds
as well. Those can be invoked through the setup.py command-line
interface (e.g., python setup.py install). It is planned to remove
numpy.distutils support before the 1.10.0 release.
When building from source, a number of things have changed compared to building
with numpy.distutils:
- New build dependencies:
meson,ninja, andpkg-config.
setuptoolsandwheelare no longer needed. - BLAS and LAPACK libraries that are supported haven't changed, however the
discovery mechanism has: that is now usingpkg-configinstead of hardcoded
paths or asite.cfgfile. - The build defaults to using OpenBLAS. See :ref:
blas-lapack-selectionfor
details.
The two CLIs that can be used to build wheels are pip and build. In
addition, the SciPy repo contains a python dev.py CLI for any kind of
development task (see its --help for details). For a comparison between old
(distutils) and new (meson) build commands, see :ref:meson-faq.
For more information on the introduction of Meson support in SciPy, see
gh-13615 <https://github.com/scipy/scipy/issues/13615>__ and
this blog post <https://labs.quansight.org/blog/2021/07/moving-scipy-to-meson/>__.
Authors
- endolith (12)
- h-vetinari (11)
- Caio Agiani (2) +
- Emmy Albert (1) +
- Joseph Albert (1)
- Tania Allard (3)
- Carsten Allefeld (1) +
- Kartik Anand (1) +
- Virgile Andreani (2) +
- Weh Andreas (1) +
- Francesco Andreuzzi (5) +
- Kian-Meng Ang (2) +
- Gerrit Ansmann (1)
- Ar-Kareem (1) +
- Shehan Atukorala (1) +
- avishai231 (1) +
- Blair Azzopardi (1)
- Sayantika Banik (2) +
- Ross Barnowski (9)
- Christoph Baumgarten (3)
- Nickolai Belakovski (1)
- Peter Bell (9)
- Sebastian Berg (3)
- Bharath (1) +
- bobcatCA (2) +
- boussoffara (2) +
- Islem BOUZENIA (1) +
- Jake Bowhay (41) +
- Matthew Brett (11)
- Dietrich Brunn (2) +
- Michael Burkhart (2) +
- Evgeni Burovski (96)
- Matthias Bussonnier (20)
- Dominic C (1)
- Cameron (1) +
- CJ Carey (3)
- Thomas A Caswell (2)
- Ali Cetin (2) +
- Hood Chatham (5) +
- Klesk Chonkin (1)
- Craig Citro (1) +
- Dan Cogswell (1) +
- Luigi Cruz (1) +
- Anirudh Dagar (5)
- Brandon David (1)
- deepakdinesh1123 (1) +
- Denton DeLoss (1) +
- derbuihan (2) +
- Sameer Deshmukh (13) +
- Niels Doucet (1) +
- DWesl (8)
- eytanadler (30) +
- Thomas J. Fan (5)
- Isuru Fernando (3)
- Joseph Fox-Rabinovitz (1)
- Ryan Gibson (4) +
- Ralf Gommers (327)
- Srinivas Gorur-Shandilya (1) +
- Alex Griffing (2)
- Matt Haberland (461)
- Tristan Hearn (1) +
- Jonathan Helgert (1) +
- Samuel Hinton (1) +
- Jake (1) +
- Stewart Jamieson (1) +
- Jan-Hendrik Müller (1)
- Yikun Jiang (1) +
- JuliaMelle01 (1) +
- jyuv (12) +
- Toshiki Kataoka (1)
- Chris Keefe (1) +
- Robert Kern (4)
- Andrew Knyazev (11)
- Matthias Koeppe (4) +
- Sergey Koposov (1)
- Volodymyr Kozachynskyi (1) +
- Yotaro Kubo (2) +
- Jacob Lapenna (1) +
- Peter Mahler Larsen (8)
- Eric Larson (4)
- Laurynas Mikšys (1) +
- Antony Lee (1)
- Gregory R. Lee (2)
- lerichi (1) +
- Tim Leslie (2)
- P. L. Lim (1)
- Smit Lunagariya (43)
- lutefiskhotdish (1) +
- Cong Ma (12)
- Syrtis Major (1)
- Nicholas McKibben (18)
- Melissa Weber Mendonça (10)
- Mark Mikofski (1)
- Jarrod Millman (13)
- Harsh Mishra (6)
- ML-Nielsen (3) +
- Matthew Murray (1) +
- Andrew Nelson (50)
- Dimitri Papadopoulos Orfanos (1) +
- Evgueni Ovtchinnikov (2) +
- Sambit Panda (1)
- Nick Papior (2)
- Tirth Patel (43)
- Petar Mlinarić (1)
- petroselo (1) +
- Ilhan Polat (64)
- Anthony Polloreno (1)
- Amit Portnoy (1) +
- Quentin Barthélemy (9)
- Patrick N. Raanes (1) +
- Tyler Reddy (185)
- Pamphile Roy (199)
- Vivek Roy (2) +
- sabonerune (1) +
- Niyas Sait (2) +
- Atsushi Sakai (25)
- Mazen Sayed (1) +
- Eduardo Schettino (5) +
- Daniel Schmitz (6) +
- Eli Schwartz (4) +
- SELEE (2) +
- Namami Shanker (4)
- siddhantwahal (1) +
- Gagandeep Singh (8)
- Soph (1) +
- Shivnaren Srinivasan (1) +
- Scott Staniewicz (1) +
- Leo C. Stein (4)
- Albert Steppi (7)
- Christopher Strickland (1) +
- Kai Striega (4)
- Søren Fuglede Jørgensen (1)
- Aleksandr Tagilov (1) +
- Masayuki Takagi (1) +
- Sai Teja (1) +
- Ewout ter Hoeven (2) +
- Will Tirone (2)
- Bas van Beek (7)
- Dhruv Vats (1)
- Arthur Volant (1)
- Samuel Wallan (5)
- Stefan van der Walt (8)
- Warren Weckesser (84)
- Anreas Weh (1)
- Nils Werner (1)
- Aviv Yaish (1) +
- Dowon Yi (1)
- Rory Yorke (1)
- Yosshi999 (1) +
- yuanx749 (2) +
- Gang Zhao (23)
- ZhihuiChen0903 (1)
- Pavel Zun (1) +
- David Zwicker (1) +
A total of 154 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.