summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.circleci/config.yml2
-rw-r--r--.github/workflows/build_test.yml2
-rw-r--r--.github/workflows/wheels.yml15
-rw-r--r--.gitignore1
-rw-r--r--.mailmap51
-rw-r--r--azure-steps-windows.yml9
-rw-r--r--doc/release/upcoming_changes/17530.improvement.rst5
-rw-r--r--doc/release/upcoming_changes/17582.new_feature.rst10
-rw-r--r--doc/release/upcoming_changes/18536.improvement.rst7
-rw-r--r--doc/release/upcoming_changes/18585.new_feature.rst15
-rw-r--r--doc/release/upcoming_changes/18884.new_feature.rst7
-rw-r--r--doc/release/upcoming_changes/19062.new_feature.rst21
-rw-r--r--doc/release/upcoming_changes/19083.new_feature.rst6
-rw-r--r--doc/release/upcoming_changes/19135.change.rst10
-rw-r--r--doc/release/upcoming_changes/19151.improvement.rst6
-rw-r--r--doc/release/upcoming_changes/19211.new_feature.rst7
-rw-r--r--doc/release/upcoming_changes/19259.c_api.rst12
-rw-r--r--doc/release/upcoming_changes/19355.new_feature.rst13
-rw-r--r--doc/release/upcoming_changes/19356.change.rst7
-rw-r--r--doc/release/upcoming_changes/19459.new_feature.rst4
-rw-r--r--doc/release/upcoming_changes/19462.change.rst3
-rw-r--r--doc/release/upcoming_changes/19478.performance.rst11
-rw-r--r--doc/release/upcoming_changes/19479.compatibility.rst7
-rw-r--r--doc/release/upcoming_changes/19513.new_feature.rst4
-rw-r--r--doc/release/upcoming_changes/19527.new_feature.rst3
-rw-r--r--doc/release/upcoming_changes/19539.expired.rst2
-rw-r--r--doc/release/upcoming_changes/19615.expired.rst8
-rw-r--r--doc/release/upcoming_changes/19665.change.rst4
-rw-r--r--doc/release/upcoming_changes/19680.improvement.rst5
-rw-r--r--doc/release/upcoming_changes/19687.change.rst8
-rw-r--r--doc/release/upcoming_changes/19754.new_feature.rst7
-rw-r--r--doc/release/upcoming_changes/19803.new_feature.rst14
-rw-r--r--doc/release/upcoming_changes/19805.new_feature.rst5
-rw-r--r--doc/release/upcoming_changes/19857.improvement.rst8
-rw-r--r--doc/release/upcoming_changes/19879.new_feature.rst15
-rw-r--r--doc/release/upcoming_changes/19921.deprecation.rst3
-rw-r--r--doc/release/upcoming_changes/20000.deprecation.rst5
-rw-r--r--doc/release/upcoming_changes/20027.improvement.rst17
-rw-r--r--doc/release/upcoming_changes/20049.change.rst5
-rw-r--r--doc/release/upcoming_changes/20201.deprecation.rst5
-rw-r--r--doc/release/upcoming_changes/20217.improvement.rst10
-rw-r--r--doc/release/upcoming_changes/20314.change.rst10
-rw-r--r--doc/release/upcoming_changes/20394.deprecation.rst6
-rw-r--r--doc/release/upcoming_changes/20414.expired.rst4
-rw-r--r--doc/source/dev/development_advanced_debugging.rst2
-rw-r--r--doc/source/dev/development_workflow.rst21
-rw-r--r--doc/source/f2py/buildtools/cmake.rst60
-rw-r--r--doc/source/f2py/buildtools/distutils.rst (renamed from doc/source/f2py/distutils.rst)20
-rw-r--r--doc/source/f2py/buildtools/index.rst102
-rw-r--r--doc/source/f2py/buildtools/meson.rst114
-rw-r--r--doc/source/f2py/buildtools/skbuild.rst94
-rw-r--r--doc/source/f2py/code/CMakeLists.txt65
-rw-r--r--doc/source/f2py/code/CMakeLists_skbuild.txt95
-rw-r--r--doc/source/f2py/code/meson.build38
-rw-r--r--doc/source/f2py/code/meson_upd.build37
-rw-r--r--doc/source/f2py/code/pyproj_skbuild.toml3
-rw-r--r--doc/source/f2py/code/setup_skbuild.py10
-rw-r--r--doc/source/f2py/f2py.getting-started.rst2
-rw-r--r--doc/source/f2py/index.rst2
-rw-r--r--doc/source/reference/c-api/data_memory.rst16
-rw-r--r--doc/source/reference/c-api/types-and-structures.rst5
-rw-r--r--doc/source/reference/routines.array-manipulation.rst1
-rw-r--r--doc/source/release.rst1
-rw-r--r--doc/source/release/1.23.0-notes.rst45
-rw-r--r--doc/source/user/basics.copies.rst2
-rw-r--r--doc/source/user/basics.indexing.rst6
-rw-r--r--doc/source/user/basics.io.genfromtxt.rst14
-rw-r--r--doc/source/user/basics.rec.rst11
-rw-r--r--doc/source/user/how-to-index.rst351
-rw-r--r--doc/source/user/howtos_index.rst1
-rw-r--r--environment.yml2
-rw-r--r--numpy/__init__.pyi6
-rw-r--r--numpy/array_api/_array_object.py2
-rw-r--r--numpy/array_api/tests/test_array_object.py14
-rw-r--r--numpy/compat/py3k.py4
-rw-r--r--numpy/core/_add_newdocs.py5
-rw-r--r--numpy/core/code_generators/cversions.txt5
-rw-r--r--numpy/core/code_generators/ufunc_docstrings.py1
-rw-r--r--numpy/core/fromnumeric.py59
-rw-r--r--numpy/core/function_base.pyi184
-rw-r--r--numpy/core/include/numpy/numpyconfig.h17
-rw-r--r--numpy/core/numeric.py8
-rw-r--r--numpy/core/setup.py2
-rw-r--r--numpy/core/setup_common.py1
-rw-r--r--numpy/core/src/_simd/_simd.dispatch.c.src4
-rw-r--r--numpy/core/src/common/simd/avx2/math.h4
-rw-r--r--numpy/core/src/common/simd/avx512/math.h4
-rw-r--r--numpy/core/src/common/simd/neon/math.h33
-rw-r--r--numpy/core/src/common/simd/sse/math.h28
-rw-r--r--numpy/core/src/common/simd/vsx/math.h4
-rw-r--r--numpy/core/src/multiarray/alloc.c45
-rw-r--r--numpy/core/src/multiarray/methods.c2
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c2
-rw-r--r--numpy/core/src/multiarray/nditer_pywrap.c20
-rw-r--r--numpy/core/src/multiarray/scalartypes.c.src10
-rw-r--r--numpy/core/src/umath/_operand_flag_tests.c (renamed from numpy/core/src/umath/_operand_flag_tests.c.src)0
-rw-r--r--numpy/core/src/umath/loops_exponent_log.dispatch.c.src18
-rw-r--r--numpy/core/tests/test_deprecations.py47
-rw-r--r--numpy/core/tests/test_multiarray.py36
-rw-r--r--numpy/core/tests/test_simd.py16
-rw-r--r--numpy/core/tests/test_umath.py31
-rw-r--r--numpy/distutils/ccompiler_opt.py4
-rw-r--r--numpy/distutils/checks/cpu_asimdfhm.c4
-rw-r--r--numpy/distutils/misc_util.py27
-rw-r--r--numpy/f2py/__init__.py4
-rw-r--r--numpy/f2py/capi_maps.py2
-rw-r--r--numpy/f2py/cfuncs.py59
-rwxr-xr-xnumpy/f2py/crackfortran.py12
-rwxr-xr-xnumpy/f2py/f2py2e.py4
-rw-r--r--numpy/f2py/tests/test_string.py11
-rw-r--r--numpy/lib/function_base.py269
-rw-r--r--numpy/lib/function_base.pyi26
-rw-r--r--numpy/lib/index_tricks.py4
-rw-r--r--numpy/lib/nanfunctions.py161
-rw-r--r--numpy/lib/npyio.py24
-rw-r--r--numpy/lib/recfunctions.py21
-rw-r--r--numpy/lib/scimath.py9
-rw-r--r--numpy/lib/scimath.pyi101
-rw-r--r--numpy/lib/shape_base.pyi4
-rw-r--r--numpy/lib/tests/test_function_base.py108
-rw-r--r--numpy/lib/tests/test_io.py4
-rw-r--r--numpy/lib/tests/test_nanfunctions.py4
-rw-r--r--numpy/lib/type_check.py74
-rw-r--r--numpy/lib/type_check.pyi3
-rw-r--r--numpy/lib/utils.py13
-rw-r--r--numpy/linalg/tests/test_build.py53
-rw-r--r--numpy/ma/core.py16
-rw-r--r--numpy/ma/tests/test_subclassing.py42
-rw-r--r--numpy/random/_examples/cython/setup.py1
-rw-r--r--numpy/random/_mt19937.pyx2
-rw-r--r--numpy/random/mtrand.pyx17
-rw-r--r--numpy/random/tests/test_extending.py8
-rw-r--r--numpy/random/tests/test_randomstate_regression.py13
-rw-r--r--numpy/testing/_private/utils.py4
-rw-r--r--numpy/typing/tests/data/fail/array_constructors.pyi6
-rw-r--r--numpy/typing/tests/data/fail/shape_base.pyi8
-rw-r--r--numpy/typing/tests/data/reveal/array_constructors.pyi22
-rw-r--r--numpy/typing/tests/data/reveal/emath.pyi52
-rw-r--r--numpy/typing/tests/data/reveal/lib_function_base.pyi4
-rw-r--r--numpy/typing/tests/data/reveal/ndarray_misc.pyi3
-rw-r--r--numpy/typing/tests/test_typing.py8
-rw-r--r--pavement.py2
-rw-r--r--pyproject.toml4
-rw-r--r--test_requirements.txt5
-rw-r--r--tools/allocation_tracking/README.md8
-rw-r--r--tools/allocation_tracking/alloc_hook.pyx42
-rw-r--r--tools/allocation_tracking/setup.py9
-rw-r--r--tools/allocation_tracking/sorttable.js493
-rw-r--r--tools/allocation_tracking/track_allocations.py140
-rwxr-xr-xtools/functions_missing_types.py1
-rw-r--r--tools/wheels/LICENSE_win32.txt938
-rw-r--r--tools/wheels/cibw_before_build.sh17
-rw-r--r--tools/wheels/cibw_test_command.sh8
153 files changed, 3289 insertions, 1700 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index de7f52f81..182f7e678 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -44,8 +44,8 @@ jobs:
. venv/bin/activate
pip install --progress-bar=off --upgrade pip 'setuptools<49.2.0'
pip install --progress-bar=off -r test_requirements.txt
- pip install .
pip install --progress-bar=off -r doc_requirements.txt
+ pip install .
- run:
name: create release notes
diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml
index 86fb094c6..620d9c1ef 100644
--- a/.github/workflows/build_test.yml
+++ b/.github/workflows/build_test.yml
@@ -212,7 +212,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
- python-version: pypy-3.8-v7.3.6rc1
+ python-version: pypy-3.8-v7.3.7
- uses: ./.github/actions
sdist:
diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml
index 3c382f8b3..0268e7ce3 100644
--- a/.github/workflows/wheels.yml
+++ b/.github/workflows/wheels.yml
@@ -70,6 +70,17 @@ jobs:
- os: macos-latest
python: "310"
platform: macosx_x86_64
+
+ # Windows builds
+ - os: windows-2019
+ python: "38"
+ platform: win_amd64
+ - os: windows-2019
+ python: "39"
+ platform: win_amd64
+ - os: windows-2019
+ python: "310"
+ platform: win_amd64
steps:
- name: Checkout numpy
@@ -91,9 +102,13 @@ jobs:
CIBW_ENVIRONMENT_LINUX: CFLAGS='-std=c99 -fno-strict-aliasing'
LDFLAGS='-Wl,--strip-debug'
OPENBLAS64_=/usr/local
+ RUNNER_OS='Linux'
# MACOS linker doesn't support stripping symbols
CIBW_ENVIRONMENT_MACOS: CFLAGS='-std=c99 -fno-strict-aliasing'
OPENBLAS64_=/usr/local
+ # Hardcode for now,blas stuff needs changes for 32-bit
+ CIBW_ENVIRONMENT_WINDOWS: NPY_USE_BLAS_ILP64=1
+ OPENBLAS64_=openblas
CIBW_BUILD_VERBOSITY: 3
CIBW_BEFORE_BUILD: bash {project}/tools/wheels/cibw_before_build.sh {project}
CIBW_BEFORE_TEST: pip install -r {project}/test_requirements.txt
diff --git a/.gitignore b/.gitignore
index 52997523c..b7c776b2f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -157,7 +157,6 @@ numpy/core/src/npysort/sort.c
numpy/core/src/private/npy_binsearch.h
numpy/core/src/private/npy_partition.h
numpy/core/src/private/templ_common.h
-numpy/core/src/umath/_operand_flag_tests.c
numpy/core/src/umath/_rational_tests.c
numpy/core/src/umath/_struct_ufunc_tests.c
numpy/core/src/umath/_umath_tests.c
diff --git a/.mailmap b/.mailmap
index 3f45904fc..fd020c818 100644
--- a/.mailmap
+++ b/.mailmap
@@ -26,20 +26,26 @@
@sfolje0 <sfolje0@github>
@spacescientist <aspacescientist@protonmail.com> <spacescientist@pm.me>
@tautaus <sunt9751@gmail.com>
+@vinith2 <85550536+vinith2@users.noreply.github.com>
@xoviat <49173759+xoviat@users.noreply.github.com>
@xoviat <49173759+xoviat@users.noreply.github.com> <xoviat@users.noreply.github.com>
+@yan-wyb <yan-wyb@foxmail.com>
@yetanothercheer <yetanothercheer@protonmail.com>
Aaron Baecker <abaecker@localhost>
Aarthi Agurusa <agurusa@gmail.com>
+Ajay DS <turingman@protonmail.com>
+Ajay DS <turingman@protonmail.com> <ajayds2001@gmail.com>
Alan Fontenot <logeaux@yahoo.com>
Alan Fontenot <logeaux@yahoo.com> <36168460+logeaux@users.noreply.github.com>
Abdul Muneer <abdulmuneer@gmail.com>
Abhilash Barigidad <abhilash.ub@gmail.com>
Abhilash Barigidad <abhilash.ub@gmail.com> <64172584+abhilash42@users.noreply.github.com>
Abhinav Reddy <abhinav071197@gmail.com>
+Abel Aoun <aoun@cerfacs.fr>
Adam Ginsburg <adam.g.ginsburg@gmail.com> <keflavich@gmail.com>
Aerik Pawson <45904740+aerikpawson@users.noreply.github.com>
Albert Jornet Puig <albert.jornet@ic3.cat>
+Alberto Rubiales <arubiales11@gmail.com>
Alex Rockhill <aprockhill206@gmail.com>
Alex Griffing <argriffi@ncsu.edu>
Alex Griffing <argriffi@ncsu.edu> <argriffing@gmail.com>
@@ -78,7 +84,9 @@ Anne Bonner <bonn0062@yahoo.com> <35413198+bonn0062@users.noreply.github.com>
Anthony Vo <anthonyhvo12@gmail.com> <43098273+anthonyhvo12@users.noreply.github.com>
Antoine Pitrou <antoine@python.org> <pitrou@free.fr>
Anže StariÄ <anze.staric@gmail.com>
+Arfy Slowy <slowy.arfy@gmail.com>
Aron Ahmadia <aron@ahmadia.net>
+Arun Palaniappen <arun.palaniappan1999@gmail.com>
Arun Persaud <apersaud@lbl.gov> <arun@nubati.net>
Ashutosh Singh <ashutoshsinghrkt@gmail.com>
Ashutosh Singh <ashutoshsinghrkt@gmail.com> <55102089+Ashutosh619-sudo@users.noreply.github.com>
@@ -98,6 +106,7 @@ Bertrand Lefebvre <bertrand.l3f@gmail.com>
Bharat Raghunathan <bharatraghunthan9767@gmail.com>
Bharat Raghunathan <bharatraghunthan9767@gmail.com> <bharatr@symphonyai.com>
Bob Eldering <eldering@jive.eu>
+Brent Brewington <brent.brewington@gmail.com>
Brett R Murphy <bmurphy@enthought.com>
Brigitta Sipocz <bsipocz@gmail.com> <b.sipocz@gmail.com>
Brian Soto <iambriansoto@gmail.com>
@@ -111,6 +120,7 @@ Carl Leake <leakec57@gmail.com>
Charles Stern <62192187+cisaacstern@users.noreply.github.com>
Chris Barker <Chris.Barker@noaa.gov> <chris.barker@local>
Chris Burns <chris.burns@localhost>
+Chris Fu (傅立业) <17433201@qq.com>
Chris Holland <chrisholland3553@gmail.com> <41524756+ChrisAHolland@users.noreply.github.com>
Chris Kerr <debdepba@dasganma.tk> <cjk34@cam.ac.uk>
Chris Vavaliaris <cv1038@wildcats.unh.edu>
@@ -137,6 +147,8 @@ Daniel Rasmussen <daniel.rasmussen@appliedbrainresearch.com>
Daniel G. A. Smith <dgasmith@icloud.com>
Daniel G. A. Smith <dgasmith@icloud.com> <malorian@me.com>
Dario Mory <daaawx@gmail.com>
+David Badnar <bdvd001@gmail.com>
+David Cortes <david.cortes.rivera@gmail.com>
David Huard <david.huard@gmail.com> dhuard <dhuard@localhost>
David M Cooke <cookedm@localhost>
David Nicholson <davidjn@google.com> <dnic12345@gmail.com>
@@ -161,6 +173,9 @@ Erik M. Bray <erik.m.bray@gmail.com> <embray@stsci.edu>
Eric Fode <ericfode@gmail.com> Eric Fode <ericfode@linuxlaptop.(none)>
Eric Quintero <eric.antonio.quintero@gmail.com>
Ernest N. Mamikonyan <ernest.mamikonyan@gmail.com>
+Eskild Eriksen <eskild.eriksen122@gmail.com>
+Eskild Eriksen <eskild.eriksen122@gmail.com> <42120229+iameskild@users.noreply.github.com>
+Eskild Eriksen <eskild.eriksen122@gmail.com> <eskild@doublee.io>
Etienne Guesnet <etienne.guesnet.external@atos.net> <51407514+EGuesnet@users.noreply.github.com>
Eva Jau <evaj@posteo.de>
Evgeni Burovski <evgeny.burovskiy@gmail.com> Evgeni Burovski <evgeni@burovski.me>
@@ -173,6 +188,7 @@ Friedrich Dunne <dunneff@tcd.ie> dunneff <dunneff@tcd.ie>
Frederic Bastien <nouiz@nouiz.org> Frederic <nouiz@nouiz.org>
FX Coudert <fxcoudert@gmail.com>
Gael Varoquaux <gael.varoquaux@normalesup.org>
+Gagandeep Singh <gdp.1807@gmail.com>
Gerrit Holl <gerrit.holl@gmail.com> <gerrit.holl@utoronto.ca>
Gerrit Holl <gerrit.holl@gmail.com> <g.holl@reading.ac.uk>
Giuseppe Venturini <ggventurini@users.noreply.github.com>
@@ -185,6 +201,7 @@ Greg Young <gfyoung17@gmail.com> <gfyoung@mit.edu>
Gregory R. Lee <grlee77@gmail.com>
Gregory R. Lee <grlee77@gmail.com> <gregory.lee@cchmc.org>
Guo Ci <zguoci@gmail.com> guoci <zguoci@gmail.com>
+Guo Shuai <gs0801@foxmail.com>
Hameer Abbasi <einstein.edison@gmail.com> <hameerabbasi@yahoo.com>
Han Genuit <hangenuit@gmail.com>
Hanno Klemm <hanno.klemm@maerskoil.com> hklemm <hanno.klemm@maerskoil.com>
@@ -193,7 +210,9 @@ Hemil Desai <desai38@purdue.edu>
Hiroyuki V. Yamazaki <hiroyuki.vincent.yamazaki@gmail.com>
Hugo van Kemenade <hugovk@users.noreply.github.com>
I-Shen Leong <i-shenl@activestate.com>
+Imen Rajhi <imen.rajhi.ir@gmail.com>
Inessa Pawson <albuscode@gmail.com>
+Irina Maria Mocan <28827042+IrinaMaria@users.noreply.github.com>
Irvin Probst <irvin.probst@ensta-bretagne.fr>
Isabela Presedo-Floyd <irpf.design@gmail.com> <ipresedo@calpoly.edu>
Gerhard Hobler <gerhard.hobler@tuwien.ac.at>
@@ -220,6 +239,7 @@ Jeremy Lay <jlay80@gmail.com>
Jérémie du Boisberranger <jeremie.du-boisberranger@inria.fr> jeremiedbb <34657725+jeremiedbb@users.noreply.github.com>
Jérome Eertmans <jeertmans@icloud.com>
Jerome Kelleher <jerome.kelleher@ed.ac.uk>
+Jessi J Zhao <35235453+jessijzhao@users.noreply.github.com>
Johannes Hampp <johannes.hampp@zeu.uni-giessen.de> <42553970+euronion@users.noreply.github.com>
Johannes Schönberger <hannesschoenberger@gmail.com> <jschoenberger@demuc.de>
Johann Faouzi <johann.faouzi@gmail.com> <johann.faouzi@icm-institute.org>
@@ -231,6 +251,7 @@ Joseph Fox-Rabinovitz <jfoxrabinovitz@gmail.com>
Joseph Fox-Rabinovitz <jfoxrabinovitz@gmail.com> <joseph.r.fox-rabinovitz@nasa.gov>
Joseph Fox-Rabinovitz <jfoxrabinovitz@gmail.com> <madphysicist@users.noreply.github.com>
Joseph Martinot-Lagarde <contrebasse@gmail.com> <joseph.martinot-lagarde@onera.fr>
+Joshua Himmens <joshua.himmens@gmail.com>
Julian Taylor <juliantaylor108@gmail.com>
Julian Taylor <juliantaylor108@gmail.com> <jtaylor.debian@googlemail.com>
Julian Taylor <juliantaylor108@gmail.com> <jtaylor108@googlemail.com>
@@ -244,6 +265,9 @@ Kasia Leszek <kati.leszek@gmail.com>
Kasia Leszek <kati.leszek@gmail.com> <39829548+katleszek@users.noreply.github.com>
Karan Dhir <karan.dhir@berkeley.edu> <kurrandhir@gmail.com>
Keller Meier <max.kellermeier@hotmail.de>
+Kenny Huynh <hkennyv@gmail.com>
+Kevin Granados <kevingranados62@gmail.com>
+Kevin Granados <kevingranados62@gmail.com> <54990613+NectDz@users.noreply.github.com>
Kevin Sheppard <kevin.k.sheppard@gmail.com> <bashtage@users.noreply.github.com>
Kevin Sheppard <kevin.k.sheppard@gmail.com> <kevin.sheppard@gmail.com>
Kerem Hallaç <hallackerem@gmail.com>
@@ -254,6 +278,7 @@ Konrad Kapp <k_kapp@yahoo.com>
Kriti Singh <kritisingh1.ks@gmail.com>
Kmol Yuan <pyslvs@gmail.com>
Kumud Lakara <55556183+kumudlakara@users.noreply.github.com>
+Lalit Musmade <lalitmusmade2@gmail.com>
Lars Buitinck <larsmans@gmail.com> Lars Buitinck <l.buitinck@esciencecenter.nl>
Lars Buitinck <larsmans@gmail.com> Lars Buitinck <L.J.Buitinck@uva.nl>
Lars Grüter <lagru@mailbox.org>
@@ -265,18 +290,24 @@ Luke Zoltan Kelley <lkelley@cfa.harvard.edu>
Madhulika Jain Chambers <madhulikajain@gmail.com> <53166646+madhulikajc@users.noreply.github.com>
Magdalena Proszewska <magdalena.proszewska@gmail.com>
Magdalena Proszewska <magdalena.proszewska@gmail.com> <38814059+mproszewska@users.noreply.github.com>
+Malik Idrees Hasan Khan <77000356+MalikIdreesHasanKhan@users.noreply.github.com>C
Manoj Kumar <manojkumarsivaraj334@gmail.com>
Marcin Podhajski <podhajskimarcin@gmail.com> <36967358+m-podhajski@users.noreply.github.com>
+Margret Pax <pax.margret@tutanota.com>
+Margret Pax <pax.margret@tutanota.com> <13646646+paxcodes@users.noreply.github.com>
Mark DePristo <mdepristo@synapdx.com>
Mark Weissman <mw9050@gmail.com>
Mark Wiebe <mwwiebe@gmail.com>
Mark Wiebe <mwwiebe@gmail.com> <mwiebe@continuum.io>
Mark Wiebe <mwwiebe@gmail.com> <mwiebe@enthought.com>
Mark Wiebe <mwwiebe@gmail.com> <mwiebe@georg.(none)>
+Mars Lee <mlee@quansight.com>
+Mars Lee <mlee@quansight.com> <46167686+MarsBarLee@users.noreply.github.com>
Martin Goodson <martingoodson@gmail.com>
Martin Reinecke <martin@mpa-garching.mpg.de>
Martin Teichmann <martin.teichmann@xfel.eu> <lkb.teichmann@gmail.com>
Mary Conley <sleeplessinseattle.dev@gmail.com>
+Masashi Kishimoto <drehbleistift@gmail.com>
Matheus Vieira Portela <matheus.v.portela@gmail.com>
Mathieu Lamarre <mlamarre@ea.com> <mathieu@vlam3d.com>
Matías Ríos <riosm@dickinson.edu>
@@ -285,11 +316,13 @@ Matt Ord <Matthew.ord1@gmail.com> <55235095+Matt-Ord@users.noreply.github.com>
Matt Hancock <not.matt.hancock@gmail.com> <mhancock743@gmail.com>
Martino Sorbaro <martino.sorbaro@ed.ac.uk>
Mattheus Ueckermann <empeeu@yahoo.com>
+Matthew Barber <quitesimplymatt@gmail.com>
Matthew Harrigan <harrigan.matthew@gmail.com>
Matthias Bussonnier <bussonniermatthias@gmail.com> <mbussonnier@ucmerced.edu>
Matti Picus <matti.picus@gmail.com>
Maximilian Konrad <maximilianlukaskonrad@hotmail.de>
-Melissa Weber Mendonça <melissawm@gmail.com> <melissawm@gmail.com>
+Melissa Weber Mendonça <melissawm@gmail.com>
+Melissa Weber Mendonça <melissawm@gmail.com> <melissawm.github@gmail.com>
Meltem Eren Copur <mecopur@outlook.com>
Michael Behrisch <oss@behrisch.de> behrisch <behrisch@users.sourceforge.net>
Michael Droettboom <mdboom@gmail.com> mdroe <mdroe@localhost>
@@ -307,8 +340,8 @@ Mircea Akos Bruma <bruma.mircea.a@gmail.com>
Mircea Akos Bruma <bruma.mircea.a@gmail.com> <akos@debian-gnu-linux-vm.localdomain>
Mitchell Faas <Faas.Mitchell@gmail.com> <35742861+Mitchell-Faas@users.noreply.github.com>
Muhammad Kasim <firman.kasim@gmail.com>
-Masashi Kishimoto <drehbleistift@gmail.com>
-Mukulikaa Parhari <mukulikapahari@gmail.com> <60316606+Mukulikaa@users.noreply.github.com>
+Mukulika Pahari <mukulikapahari@gmail.com>
+Mukulika Pahari <mukulikapahari@gmail.com> <60316606+Mukulikaa@users.noreply.github.com>
Nathaniel J. Smith <njs@pobox.com>
Naveen Arunachalam <notatroll.troll@gmail.com> naveenarun <notatroll.troll@gmail.com>
Neil Girdhar <mistersheik@gmail.com>
@@ -337,6 +370,8 @@ Pierre GM <pierregmcode@gmail.com> pierregm <pierregm@localhost>
Piotr Gaiński <dociebieaniuszlem@gmail.com>
Piotr Gaiński <dociebieaniuszlem@gmail.com> Pan Jan <rumcajsgajos@gmail.com>
Prabhu Ramachandran <prabhu@localhost> prabhu <prabhu@localhost>
+Prathmesh Shirsat <patushir@gmail.com>
+Prathmesh Shirsat <patushir@gmail.com> <55539563+Fayyr@users.noreply.github.com>
Przemyslaw Bartosik <sendthenote@gmail.com>
Raghuveer Devulapalli <me.raghuveer@gmail.com> <raghuveer.devulapalli@intel.com>
Raghuveer Devulapalli <me.raghuveer@gmail.com> <44766858+r-devulap@users.noreply.github.com>
@@ -352,6 +387,7 @@ Robert T. McGibbon <rmcgibbo@gmail.com>
Roland Kaufmann <rka081+numpy@uib.no> <roland.kaufmann@uni.no>
Roman Yurchak <rth.yurchak@gmail.com> <rth.yurchak@pm.me>
Ronan Lamy <ronan.lamy@gmail.com> Ronan Lamy <Ronan.Lamy@normalesup.org>
+Roy Jacobson <roi.jacobson1@gmail.com>
Russell Hewett <rhewett@mit.edu>
Ryan Blakemore <rbtnet@gmail.com>
Ryan Polley <rypolley@gmail.com> <rypolley+github@gmail.com>
@@ -367,8 +403,13 @@ Sami Salonen <ssalonen@gmail.com> <sami.salonen@eniram.fi>
Sanchez Gonzalez Alvaro <as12513@imperial.ac.uk>
Saullo Giovani <saullogiovani@gmail.com>
Saurabh Mehta <e.samehta@gmail.com>
+Sayantika Banik <sayantikabanik122@gmail.com>
Sebastian Berg <sebastian@sipsolutions.net>
+Sebastian Schleehauf <slepton@posteo.de>
+Serge Guelton <serge.guelton@telecom-bretagne.eu>
Sergei Vorfolomeev <svorfolomeev@vmssoftware.com> <39548292+vorfol@users.noreply.github.com>
+Shubham Gupta <mastershubham@gmail.com>
+Shubham Gupta <mastershubham@gmail.com> <63910248+shubham11941140@users.noreply.github.com>
Shekhar Prasad Rajak <shekharrajak@live.com>
Shen Zhou <shen_zhou@u.nus.edu>
Shota Kawabuchi <shota.kawabuchi+GitHub@gmail.com>
@@ -389,6 +430,8 @@ Stuart Archibald <stuart.archibald@googlemail.com> <stuart@opengamma.com>
Stuart Archibald <stuart.archibald@googlemail.com> <stuartarchibald@users.noreply.github.com>
SuryaChand P <psschand@gmail.com>
Takanori Hirano <takanori17h@gmail.com>
+Theodoros Nikolaou <nikolaoutheod@gmail.com>
+David Cortes <david.cortes.rivera@gmail.com>
Thomas A Caswell <tcaswell@gmail.com> <tcaswell@bnl.gov>
Thomas Kluyver <takowl@gmail.com> <thomas@kluyver.me.uk>
Thomas Orgis <thomas.orgis@uni-hamburg.de>
@@ -413,6 +456,7 @@ Varun Nayyar <nayyarv@gmail.com> <nayyarv@users.noreply.github.com>
Vrinda Narayan <talk2vrinda@gmail.com> <vrinda18120@iiitd.ac.in>
Vrinda Narayan <talk2vrinda@gmail.com> <48102157+vrindaaa@users.noreply.github.com>
Wansoo Kim <rladhkstn8@gmail.com>
+Warren Weckesser <warren.weckesser@gmail.com>
Warren Weckesser <warren.weckesser@gmail.com> <warren.weckesser@enthought.com>
Weitang Li <liwt31@163.com>
Wendell Smith <wendellwsmith@gmail.com> <wackywendell@gmail.com>
@@ -428,6 +472,7 @@ Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
Yury Kirienko <yury.kirienko@gmail.com>
Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Zé Vinícius <jvmirca@gmail.com>
+Zhang Na <zhangna@loongson.cn>
Zixu Zhao <zixu.zhao.tireless@gmail.com>
Ziyan Zhou <ziyan.zhou@mujin.co.jp>
Zieji Pohz <poh.ziji@gmail.com>
diff --git a/azure-steps-windows.yml b/azure-steps-windows.yml
index 34f9797de..95a359c89 100644
--- a/azure-steps-windows.yml
+++ b/azure-steps-windows.yml
@@ -6,22 +6,23 @@ steps:
architecture: $(PYTHON_ARCH)
condition: not(contains(variables['PYTHON_VERSION'], 'PyPy'))
- powershell: |
- $url = "http://buildbot.pypy.org/nightly/py3.8/pypy-c-jit-latest-win64.zip"
+ # $url = "http://buildbot.pypy.org/nightly/py3.8/pypy-c-jit-latest-win64.zip"
+ $url = "https://downloads.python.org/pypy/pypy3.8-v7.3.7-win64.zip"
$output = "pypy.zip"
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $output)
echo "downloaded $url to $output"
mkdir pypy3
Expand-Archive $output -DestinationPath pypy3
- move pypy3/pypy-c-*/* pypy3
- cp pypy3/pypy3.exe pypy3/python.exe
+ # move pypy3/pypy-c-*/* pypy3
+ move pypy3/pypy*/* pypy3
$pypypath = Join-Path (Get-Item .).FullName pypy3
$env:Path = $pypypath + ";" + $env:Path
setx PATH $env:Path
python -mensurepip
echo "##vso[task.prependpath]$pypypath"
condition: contains(variables['PYTHON_VERSION'], 'PyPy')
- displayName: "Install PyPy pre-release"
+ displayName: "Install PyPy3.8 "
- script: python -m pip install --upgrade pip wheel
displayName: 'Install tools'
diff --git a/doc/release/upcoming_changes/17530.improvement.rst b/doc/release/upcoming_changes/17530.improvement.rst
deleted file mode 100644
index 07a23f0e5..000000000
--- a/doc/release/upcoming_changes/17530.improvement.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-`ctypeslib.load_library` can now take any path-like object
------------------------------------------------------------------------
-All parameters in the can now take any :term:`python:path-like object`.
-This includes the likes of strings, bytes and objects implementing the
-:meth:`__fspath__<os.PathLike.__fspath__>` protocol.
diff --git a/doc/release/upcoming_changes/17582.new_feature.rst b/doc/release/upcoming_changes/17582.new_feature.rst
deleted file mode 100644
index c2426330c..000000000
--- a/doc/release/upcoming_changes/17582.new_feature.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-NEP 49 configurable allocators
-------------------------------
-As detailed in `NEP 49`_, the function used for allocation of the data segment
-of a ndarray can be changed. The policy can be set globally or in a context.
-For more information see the NEP and the :ref:`data_memory` reference docs.
-Also add a ``NUMPY_WARN_IF_NO_MEM_POLICY`` override to warn on dangerous use
-of transfering ownership by setting ``NPY_ARRAY_OWNDATA``.
-
-.. _`NEP 49`: https://numpy.org/neps/nep-0049.html
-
diff --git a/doc/release/upcoming_changes/18536.improvement.rst b/doc/release/upcoming_changes/18536.improvement.rst
deleted file mode 100644
index 8693916db..000000000
--- a/doc/release/upcoming_changes/18536.improvement.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-Add ``smallest_normal`` and ``smallest_subnormal`` attributes to `finfo`
--------------------------------------------------------------------------
-
-The attributes ``smallest_normal`` and ``smallest_subnormal`` are available as
-an extension of `finfo` class for any floating-point data type. To use these
-new attributes, write ``np.finfo(np.float64).smallest_normal`` or
-``np.finfo(np.float64).smallest_subnormal``.
diff --git a/doc/release/upcoming_changes/18585.new_feature.rst b/doc/release/upcoming_changes/18585.new_feature.rst
deleted file mode 100644
index bb83d755c..000000000
--- a/doc/release/upcoming_changes/18585.new_feature.rst
+++ /dev/null
@@ -1,15 +0,0 @@
-Implementation of the NEP 47 (adopting the array API standard)
---------------------------------------------------------------
-
-An initial implementation of `NEP 47`_ (adoption the array API standard) has
-been added as ``numpy.array_api``. The implementation is experimental and will
-issue a UserWarning on import, as the `array API standard
-<https://data-apis.org/array-api/latest/index.html>`_ is still in draft state.
-``numpy.array_api`` is a conforming implementation of the array API standard,
-which is also minimal, meaning that only those functions and behaviors that
-are required by the standard are implemented (see the NEP for more info).
-Libraries wishing to make use of the array API standard are encouraged to use
-``numpy.array_api`` to check that they are only using functionality that is
-guaranteed to be present in standard conforming implementations.
-
-.. _`NEP 47`: https://numpy.org/neps/nep-0047-array-api-standard.html
diff --git a/doc/release/upcoming_changes/18884.new_feature.rst b/doc/release/upcoming_changes/18884.new_feature.rst
deleted file mode 100644
index 41503b00e..000000000
--- a/doc/release/upcoming_changes/18884.new_feature.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-Generate C/C++ API reference documentation from comments blocks is now possible
--------------------------------------------------------------------------------
-This feature depends on Doxygen_ in the generation process and on Breathe_
-to integrate it with Sphinx.
-
-.. _`Doxygen`: https://www.doxygen.nl/index.html
-.. _`Breathe`: https://breathe.readthedocs.io/en/latest/
diff --git a/doc/release/upcoming_changes/19062.new_feature.rst b/doc/release/upcoming_changes/19062.new_feature.rst
deleted file mode 100644
index 171715568..000000000
--- a/doc/release/upcoming_changes/19062.new_feature.rst
+++ /dev/null
@@ -1,21 +0,0 @@
-Assign the platform-specific ``c_intp`` precision via a mypy plugin
--------------------------------------------------------------------
-
-The mypy_ plugin, introduced in `numpy/numpy#17843`_, has again been expanded:
-the plugin now is now responsible for setting the platform-specific precision
-of `numpy.ctypeslib.c_intp`, the latter being used as data type for various
-`numpy.ndarray.ctypes` attributes.
-
-Without the plugin, aforementioned type will default to `ctypes.c_int64`.
-
-To enable the plugin, one must add it to their mypy `configuration file`_:
-
-.. code-block:: ini
-
- [mypy]
- plugins = numpy.typing.mypy_plugin
-
-
-.. _mypy: http://mypy-lang.org/
-.. _configuration file: https://mypy.readthedocs.io/en/stable/config_file.html
-.. _`numpy/numpy#17843`: https://github.com/numpy/numpy/pull/17843
diff --git a/doc/release/upcoming_changes/19083.new_feature.rst b/doc/release/upcoming_changes/19083.new_feature.rst
deleted file mode 100644
index 92f00c0d6..000000000
--- a/doc/release/upcoming_changes/19083.new_feature.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Add NEP 47-compatible dlpack support
-------------------------------------
-
-Add a ``ndarray.__dlpack__()`` method which returns a ``dlpack`` C structure
-wrapped in a ``PyCapsule``. Also add a ``np._from_dlpack(obj)`` function, where
-``obj`` supports ``__dlpack__()``, and returns an ``ndarray``.
diff --git a/doc/release/upcoming_changes/19135.change.rst b/doc/release/upcoming_changes/19135.change.rst
deleted file mode 100644
index 0b900a16a..000000000
--- a/doc/release/upcoming_changes/19135.change.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-Removed floor division support for complex types
-------------------------------------------------
-
-Floor division of complex types will now result in a `TypeError`
-
-.. code-block:: python
-
- >>> a = np.arange(10) + 1j* np.arange(10)
- >>> a // 1
- TypeError: ufunc 'floor_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
diff --git a/doc/release/upcoming_changes/19151.improvement.rst b/doc/release/upcoming_changes/19151.improvement.rst
deleted file mode 100644
index 2108b9c4f..000000000
--- a/doc/release/upcoming_changes/19151.improvement.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-`numpy.linalg.qr` accepts stacked matrices as inputs
-----------------------------------------------------
-
-`numpy.linalg.qr` is able to produce results for stacked matrices as inputs.
-Moreover, the implementation of QR decomposition has been shifted to C
-from Python.
diff --git a/doc/release/upcoming_changes/19211.new_feature.rst b/doc/release/upcoming_changes/19211.new_feature.rst
deleted file mode 100644
index 40e42387c..000000000
--- a/doc/release/upcoming_changes/19211.new_feature.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-``keepdims`` optional argument added to `numpy.argmin`, `numpy.argmax`
-----------------------------------------------------------------------
-
-``keepdims`` argument is added to `numpy.argmin`, `numpy.argmax`.
-If set to ``True``, the axes which are reduced are left in the result as dimensions with size one.
-The resulting array has the same number of dimensions and will broadcast with the
-input array.
diff --git a/doc/release/upcoming_changes/19259.c_api.rst b/doc/release/upcoming_changes/19259.c_api.rst
deleted file mode 100644
index dac9f520a..000000000
--- a/doc/release/upcoming_changes/19259.c_api.rst
+++ /dev/null
@@ -1,12 +0,0 @@
-Masked inner-loops cannot be customized anymore
------------------------------------------------
-The masked inner-loop selector is now never used. A warning
-will be given in the unlikely event that it was customized.
-
-We do not expect that any code uses this. If you do use it,
-you must unset the selector on newer NumPy version.
-Please also contact the NumPy developers, we do anticipate
-providing a new, more specific, mechanism.
-
-The customization was part of a never-implemented feature to allow
-for faster masked operations.
diff --git a/doc/release/upcoming_changes/19355.new_feature.rst b/doc/release/upcoming_changes/19355.new_feature.rst
deleted file mode 100644
index cfa50b7a1..000000000
--- a/doc/release/upcoming_changes/19355.new_feature.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-``bit_count`` to compute the number of 1-bits in an integer
------------------------------------------------------------
-
-Computes the number of 1-bits in the absolute value of the input.
-This works on all the numpy integer types. Analogous to the builtin
-``int.bit_count`` or ``popcount`` in C++.
-
-.. code-block:: python
-
- >>> np.uint32(1023).bit_count()
- 10
- >>> np.int32(-127).bit_count()
- 7
diff --git a/doc/release/upcoming_changes/19356.change.rst b/doc/release/upcoming_changes/19356.change.rst
deleted file mode 100644
index 3c5ef4a91..000000000
--- a/doc/release/upcoming_changes/19356.change.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-`numpy.vectorize` functions now produce the same output class as the base function
-----------------------------------------------------------------------------------
-When a function that respects `numpy.ndarray` subclasses is vectorized using
-`numpy.vectorize`, the vectorized function will now be subclass-safe
-also for cases that a signature is given (i.e., when creating a ``gufunc``):
-the output class will be the same as that returned by the first call to
-the underlying function.
diff --git a/doc/release/upcoming_changes/19459.new_feature.rst b/doc/release/upcoming_changes/19459.new_feature.rst
deleted file mode 100644
index aecae670f..000000000
--- a/doc/release/upcoming_changes/19459.new_feature.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-The ``ndim`` and ``axis`` attributes have been added to `numpy.AxisError`
--------------------------------------------------------------------------
-The ``ndim`` and ``axis`` parameters are now also stored as attributes
-within each `numpy.AxisError` instance.
diff --git a/doc/release/upcoming_changes/19462.change.rst b/doc/release/upcoming_changes/19462.change.rst
deleted file mode 100644
index 8fbadb394..000000000
--- a/doc/release/upcoming_changes/19462.change.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-OpenBLAS v0.3.17
-----------------
-Update the OpenBLAS used in testing and in wheels to v0.3.17
diff --git a/doc/release/upcoming_changes/19478.performance.rst b/doc/release/upcoming_changes/19478.performance.rst
deleted file mode 100644
index 6a389c20e..000000000
--- a/doc/release/upcoming_changes/19478.performance.rst
+++ /dev/null
@@ -1,11 +0,0 @@
-Vectorize umath module using AVX-512
--------------------------------------
-
-By leveraging Intel Short Vector Math Library (SVML), 18 umath functions
-(``exp2``, ``log2``, ``log10``, ``expm1``, ``log1p``, ``cbrt``, ``sin``,
-``cos``, ``tan``, ``arcsin``, ``arccos``, ``arctan``, ``sinh``, ``cosh``,
-``tanh``, ``arcsinh``, ``arccosh``, ``arctanh``) are vectorized using AVX-512
-instruction set for both single and double precision implementations. This
-change is currently enabled only for Linux users and on processors with
-AVX-512 instruction set. It provides an average speed up of 32x and 14x for
-single and double precision functions respectively.
diff --git a/doc/release/upcoming_changes/19479.compatibility.rst b/doc/release/upcoming_changes/19479.compatibility.rst
deleted file mode 100644
index 83533a305..000000000
--- a/doc/release/upcoming_changes/19479.compatibility.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-Distutils forces strict floating point model on clang
------------------------------------------------------
-NumPy now sets the ``-ftrapping-math`` option on clang to enforce correct
-floating point error handling for universal functions.
-Clang defaults to non-IEEE and C99 conform behaviour otherwise.
-This change (using the equivalent but newer ``-ffp-exception-behavior=strict``)
-was attempted in NumPy 1.21, but was effectively never used.
diff --git a/doc/release/upcoming_changes/19513.new_feature.rst b/doc/release/upcoming_changes/19513.new_feature.rst
deleted file mode 100644
index 5f945cea2..000000000
--- a/doc/release/upcoming_changes/19513.new_feature.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-Preliminary support for `windows/arm64` target
-----------------------------------------------
-``numpy`` added support for windows/arm64 target. Please note
-``OpenBLAS`` support is not yet available for windows/arm64 target.
diff --git a/doc/release/upcoming_changes/19527.new_feature.rst b/doc/release/upcoming_changes/19527.new_feature.rst
deleted file mode 100644
index 3967f1841..000000000
--- a/doc/release/upcoming_changes/19527.new_feature.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Added support for LoongArch
-------------------------------------------------
-LoongArch is a new instruction set, numpy compilation failure on LoongArch architecture, so add the commit.
diff --git a/doc/release/upcoming_changes/19539.expired.rst b/doc/release/upcoming_changes/19539.expired.rst
deleted file mode 100644
index 6e94f175d..000000000
--- a/doc/release/upcoming_changes/19539.expired.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-* Using the strings ``"Bytes0"``, ``"Datetime64"``, ``"Str0"``, ``"Uint32"``,
- and ``"Uint64"`` as a dtype will now raise a ``TypeError``. \ No newline at end of file
diff --git a/doc/release/upcoming_changes/19615.expired.rst b/doc/release/upcoming_changes/19615.expired.rst
deleted file mode 100644
index 4e02771e3..000000000
--- a/doc/release/upcoming_changes/19615.expired.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-Expired deprecations for ``loads``, ``ndfromtxt``, and ``mafromtxt`` in npyio
------------------------------------------------------------------------------
-
-``numpy.loads`` was deprecated in v1.15, with the recommendation that users
-use `pickle.loads` instead.
-``ndfromtxt`` and ``mafromtxt`` were both deprecated in v1.17 - users should
-use `numpy.genfromtxt` instead with the appropriate value for the
-``usemask`` parameter.
diff --git a/doc/release/upcoming_changes/19665.change.rst b/doc/release/upcoming_changes/19665.change.rst
deleted file mode 100644
index 2c2315dd2..000000000
--- a/doc/release/upcoming_changes/19665.change.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-Python 3.7 is no longer supported
----------------------------------
-Python support has been dropped. This is rather strict, there are
-changes that require Python >=3.8.
diff --git a/doc/release/upcoming_changes/19680.improvement.rst b/doc/release/upcoming_changes/19680.improvement.rst
deleted file mode 100644
index 1a2a3496b..000000000
--- a/doc/release/upcoming_changes/19680.improvement.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-`numpy.fromregex` now accepts ``os.PathLike`` implementations
--------------------------------------------------------------
-
-`numpy.fromregex` now accepts objects implementing the `__fspath__<os.PathLike>`
-protocol, *e.g.* `pathlib.Path`.
diff --git a/doc/release/upcoming_changes/19687.change.rst b/doc/release/upcoming_changes/19687.change.rst
deleted file mode 100644
index c7f7512b6..000000000
--- a/doc/release/upcoming_changes/19687.change.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-str/repr of complex dtypes now include space after punctuation
---------------------------------------------------------------
-
-The repr of ``np.dtype({"names": ["a"], "formats": [int], "offsets": [2]})`` is
-now ``dtype({'names': ['a'], 'formats': ['<i8'], 'offsets': [2], 'itemsize': 10})``,
-whereas spaces where previously omitted after colons and between fields.
-
-The old behavior can be restored via ``np.set_printoptions(legacy="1.21")``.
diff --git a/doc/release/upcoming_changes/19754.new_feature.rst b/doc/release/upcoming_changes/19754.new_feature.rst
deleted file mode 100644
index 4e91e4cb3..000000000
--- a/doc/release/upcoming_changes/19754.new_feature.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-A ``.clang-format`` file has been added
----------------------------------------
-Clang-format is a C/C++ code formatter, together with the added
-``.clang-format`` file, it produces code close enough to the NumPy
-C_STYLE_GUIDE for general use. Clang-format version 12+ is required
-due to the use of several new features, it is available in
-Fedora 34 and Ubuntu Focal among other distributions.
diff --git a/doc/release/upcoming_changes/19803.new_feature.rst b/doc/release/upcoming_changes/19803.new_feature.rst
deleted file mode 100644
index 942325822..000000000
--- a/doc/release/upcoming_changes/19803.new_feature.rst
+++ /dev/null
@@ -1,14 +0,0 @@
-``is_integer`` is now available to `numpy.floating` and `numpy.integer`
------------------------------------------------------------------------
-Based on its counterpart in `float` and `int`, the numpy floating point and
-integer types now support `~float.is_integer`. Returns ``True`` if the
-number is finite with integral value, and ``False`` otherwise.
-
-.. code-block:: python
-
- >>> np.float32(-2.0).is_integer()
- True
- >>> np.float64(3.2).is_integer()
- False
- >>> np.int32(-2).is_integer()
- True
diff --git a/doc/release/upcoming_changes/19805.new_feature.rst b/doc/release/upcoming_changes/19805.new_feature.rst
deleted file mode 100644
index f59409254..000000000
--- a/doc/release/upcoming_changes/19805.new_feature.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-Symbolic parser for Fortran dimension specifications
-----------------------------------------------------
-A new symbolic parser has been added to f2py in order to correctly parse
-dimension specifications. The parser is the basis for future improvements
-and provides compatibility with Draft Fortran 202x.
diff --git a/doc/release/upcoming_changes/19857.improvement.rst b/doc/release/upcoming_changes/19857.improvement.rst
deleted file mode 100644
index e39d413cc..000000000
--- a/doc/release/upcoming_changes/19857.improvement.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-Add new linear interpolation methods for ``quantile`` and ``percentile``
-------------------------------------------------------------------------
-
-``quantile`` and ``percentile`` now have 13 linear interpolation methods,
-nine of which can be found in the scientific literature.
-The remaining methods are NumPy specific and are kept for backwards
-compatibility. The default is "inclusive" (method 7), whose behavior is equivalent
-to the former default "linear".
diff --git a/doc/release/upcoming_changes/19879.new_feature.rst b/doc/release/upcoming_changes/19879.new_feature.rst
deleted file mode 100644
index c6624138b..000000000
--- a/doc/release/upcoming_changes/19879.new_feature.rst
+++ /dev/null
@@ -1,15 +0,0 @@
-``ndarray``, ``dtype`` and ``number`` are now runtime-subscriptable
--------------------------------------------------------------------
-Mimicking :pep:`585`, the `~numpy.ndarray`, `~numpy.dtype` and `~numpy.number`
-classes are now subscriptable for python 3.9 and later.
-Consequently, expressions that were previously only allowed in .pyi stub files
-or with the help of ``from __future__ import annotations`` are now also legal
-during runtime.
-
-.. code-block:: python
-
- >>> import numpy as np
- >>> from typing import Any
-
- >>> np.ndarray[Any, np.dtype[np.float64]]
- numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
diff --git a/doc/release/upcoming_changes/19921.deprecation.rst b/doc/release/upcoming_changes/19921.deprecation.rst
deleted file mode 100644
index 17fa0f605..000000000
--- a/doc/release/upcoming_changes/19921.deprecation.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-* the misspelled keyword argument ``delimitor`` of
- ``numpy.ma.mrecords.fromtextfile()`` has been changed into
- ``delimiter``, using it will emit a deprecation warning.
diff --git a/doc/release/upcoming_changes/20000.deprecation.rst b/doc/release/upcoming_changes/20000.deprecation.rst
deleted file mode 100644
index e0a56cd47..000000000
--- a/doc/release/upcoming_changes/20000.deprecation.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-Passing boolean ``kth`` values to (arg-)partition has been deprecated
----------------------------------------------------------------------
-`~numpy.partition` and `~numpy.argpartition` would previously accept boolean
-values for the ``kth`` parameter, which would subsequently be converted into
-integers. This behavior has now been deprecated.
diff --git a/doc/release/upcoming_changes/20027.improvement.rst b/doc/release/upcoming_changes/20027.improvement.rst
deleted file mode 100644
index 86b3bed74..000000000
--- a/doc/release/upcoming_changes/20027.improvement.rst
+++ /dev/null
@@ -1,17 +0,0 @@
-Missing parameters have been added to the ``nan<x>`` functions
---------------------------------------------------------------
-A number of the ``nan<x>`` functions previously lacked parameters that were
-present in their ``<x>``-based counterpart, *e.g.* the ``where`` parameter was
-present in `~numpy.mean` but absent from `~numpy.nanmean`.
-
-The following parameters have now been added to the ``nan<x>`` functions:
-
-* nanmin: ``initial`` & ``where``
-* nanmax: ``initial`` & ``where``
-* nanargmin: ``keepdims`` & ``out``
-* nanargmax: ``keepdims`` & ``out``
-* nansum: ``initial`` & ``where``
-* nanprod: ``initial`` & ``where``
-* nanmean: ``where``
-* nanvar: ``where``
-* nanstd: ``where``
diff --git a/doc/release/upcoming_changes/20049.change.rst b/doc/release/upcoming_changes/20049.change.rst
deleted file mode 100644
index e1f08b343..000000000
--- a/doc/release/upcoming_changes/20049.change.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-Corrected ``advance`` in ``PCG64DSXM`` and ``PCG64``
-----------------------------------------------------
-Fixed a bug in the ``advance`` method of ``PCG64DSXM`` and ``PCG64``. The bug only
-affects results when the step was larger than :math:`2^{64}` on platforms
-that do not support 128-bit integers(e.g., Windows and 32-bit Linux).
diff --git a/doc/release/upcoming_changes/20201.deprecation.rst b/doc/release/upcoming_changes/20201.deprecation.rst
deleted file mode 100644
index db8cda21f..000000000
--- a/doc/release/upcoming_changes/20201.deprecation.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-The ``np.MachAr`` class has been deprecated
--------------------------------------------
-The `~numpy.MachAr` class and `finfo.machar <numpy.finfo>` attribute have
-been deprecated. Users are encouraged to access the property if interest
-directly from the corresponding `~numpy.finfo` attribute.
diff --git a/doc/release/upcoming_changes/20217.improvement.rst b/doc/release/upcoming_changes/20217.improvement.rst
deleted file mode 100644
index 28e5c8ff7..000000000
--- a/doc/release/upcoming_changes/20217.improvement.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-Annotating the main Numpy namespace
---------------------------------------
-Starting from the 1.20 release, PEP 484 type annotations have been included
-for parts of the NumPy library; annotating the remaining functions being a
-work in progress. With the release of 1.22 this process has been completed for
-the main NumPy namespace, which is now fully annotated.
-
-Besides the main namespace, a limited number of sub-packages contain
-annotations as well. This includes, among others, `numpy.testing`,
-`numpy.linalg` and `numpy.random` (available since 1.21).
diff --git a/doc/release/upcoming_changes/20314.change.rst b/doc/release/upcoming_changes/20314.change.rst
deleted file mode 100644
index ea7e29aff..000000000
--- a/doc/release/upcoming_changes/20314.change.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-Change in generation of random 32 bit floating point variates
--------------------------------------------------------------
-There was bug in the generation of 32 bit floating point values from
-the uniform distribution that would result in the least significant
-bit of the random variate always being 0. This has been fixed.
-
-This change affects the variates produced by the `random.Generator`
-methods ``random``, ``standard_normal``, ``standard_exponential``, and
-``standard_gamma``, but only when the dtype is specified as
-``numpy.float32``.
diff --git a/doc/release/upcoming_changes/20394.deprecation.rst b/doc/release/upcoming_changes/20394.deprecation.rst
new file mode 100644
index 000000000..44d1c8a20
--- /dev/null
+++ b/doc/release/upcoming_changes/20394.deprecation.rst
@@ -0,0 +1,6 @@
+Deprecate PyDataMem_SetEventHook
+--------------------------------
+
+The ability to track allocations is now built-in to python via ``tracemalloc``.
+The hook function ``PyDataMem_SetEventHook`` has been deprecated and the
+demonstration of its use in tool/allocation_tracking has been removed.
diff --git a/doc/release/upcoming_changes/20414.expired.rst b/doc/release/upcoming_changes/20414.expired.rst
new file mode 100644
index 000000000..51f113ab3
--- /dev/null
+++ b/doc/release/upcoming_changes/20414.expired.rst
@@ -0,0 +1,4 @@
+``alen`` and ``asscalar`` removed
+---------------------------------
+
+The deprecated ``np.alen`` and ``np.asscalar`` functions were removed.
diff --git a/doc/source/dev/development_advanced_debugging.rst b/doc/source/dev/development_advanced_debugging.rst
index 18a7f6ae9..2dbd6ac22 100644
--- a/doc/source/dev/development_advanced_debugging.rst
+++ b/doc/source/dev/development_advanced_debugging.rst
@@ -106,7 +106,7 @@ Valgrind is a powerful tool to find certain memory access problems and should
be run on complicated C code.
Basic use of ``valgrind`` usually requires no more than::
- PYTHONMALLOC=malloc python runtests.py
+ PYTHONMALLOC=malloc valgrind python runtests.py
where ``PYTHONMALLOC=malloc`` is necessary to avoid false positives from python
itself.
diff --git a/doc/source/dev/development_workflow.rst b/doc/source/dev/development_workflow.rst
index 8c56f6fb2..585aacfc9 100644
--- a/doc/source/dev/development_workflow.rst
+++ b/doc/source/dev/development_workflow.rst
@@ -187,6 +187,27 @@ Standard acronyms to start the commit message with are::
TST: addition or modification of tests
REL: related to releasing numpy
+Commands to skip continuous integration
+```````````````````````````````````````
+
+By default a lot of continuous integration (CI) jobs are run for every PR,
+from running the test suite on different operating systems and hardware
+platforms to building the docs. In some cases you already know that CI isn't
+needed (or not all of it), for example if you work on CI config files, text in
+the README, or other files that aren't involved in regular build, test or docs
+sequences. In such cases you may explicitly skip CI by including one of these
+fragments in your commit message::
+
+ ``[ci skip]``: skip as much CI as possible (not all jobs can be skipped)
+ ``[skip github]``: skip GitHub Actions "build numpy and run tests" jobs
+ ``[skip travis]``: skip TravisCI jobs
+ ``[skip azurepipelines]``: skip Azure jobs
+
+*Note: unfortunately not all CI systems implement this feature well, or at all.
+CircleCI supports ``ci skip`` but has no command to skip only CircleCI.
+Azure chooses to still run jobs with skip commands on PRs, the jobs only get
+skipped on merging to master.*
+
.. _workflow_mailing_list:
diff --git a/doc/source/f2py/buildtools/cmake.rst b/doc/source/f2py/buildtools/cmake.rst
new file mode 100644
index 000000000..8c654c73e
--- /dev/null
+++ b/doc/source/f2py/buildtools/cmake.rst
@@ -0,0 +1,60 @@
+.. _f2py-cmake:
+
+===================
+Using via ``cmake``
+===================
+
+In terms of complexity, ``cmake`` falls between ``make`` and ``meson``. The
+learning curve is steeper since CMake syntax is not pythonic and is closer to
+``make`` with environment variables.
+
+However, the trade-off is enhanced flexibility and support for most architectures
+and compilers. An introduction to the syntax is out of scope for this document,
+but this `extensive CMake collection`_ of resources is great.
+
+.. note::
+
+ ``cmake`` is very popular for mixed-language systems, however support for
+ ``f2py`` is not particularly native or pleasant; and a more natural approach
+ is to consider :ref:`f2py-skbuild`
+
+Fibonacci Walkthrough (F77)
+===========================
+
+Returning to the ``fib`` example from :ref:`f2py-getting-started` section.
+
+.. literalinclude:: ./../code/fib1.f
+ :language: fortran
+
+We do not need to explicitly generate the ``python -m numpy.f2py fib1.f``
+output, which is ``fib1module.c``, which is beneficial. With this; we can now
+initialize a ``CMakeLists.txt`` file as follows:
+
+.. literalinclude:: ./../code/CMakeLists.txt
+ :language: cmake
+
+A key element of the ``CMakeLists.txt`` file defined above is that the
+``add_custom_command`` is used to generate the wrapper ``C`` files and then
+added as a dependency of the actual shared library target via a
+``add_custom_target`` directive which prevents the command from running every
+time. Additionally, the method used for obtaining the ``fortranobject.c`` file
+can also be used to grab the ``numpy`` headers on older ``cmake`` versions.
+
+This then works in the same manner as the other modules, although the naming
+conventions are different and the output library is not automatically prefixed
+with the ``cython`` information.
+
+.. code:: bash
+
+ ls .
+ # CMakeLists.txt fib1.f
+ cmake -S . -B build
+ cmake --build build
+ cd build
+ python -c "import numpy as np; import fibby; a = np.zeros(9); fibby.fib(a); print (a)"
+ # [ 0. 1. 1. 2. 3. 5. 8. 13. 21.]
+
+This is particularly useful where an existing toolchain already exists and
+``scikit-build`` or other additional ``python`` dependencies are discouraged.
+
+.. _extensive CMake collection: https://cliutils.gitlab.io/modern-cmake/
diff --git a/doc/source/f2py/distutils.rst b/doc/source/f2py/buildtools/distutils.rst
index 575dacdff..9abeee8b8 100644
--- a/doc/source/f2py/distutils.rst
+++ b/doc/source/f2py/buildtools/distutils.rst
@@ -1,3 +1,5 @@
+.. _f2py-distutils:
+
=============================
Using via `numpy.distutils`
=============================
@@ -10,23 +12,21 @@ compile Fortran sources, call F2PY to construct extension modules, etc.
.. topic:: Example
- Consider the following `setup file`__ for the ``fib`` examples in the previous
- section:
+ Consider the following ``setup_file.py`` for the ``fib`` and ``scalar``
+ examples from :ref:`f2py-getting-started` section:
- .. literalinclude:: ./code/setup_example.py
+ .. literalinclude:: ./../code/setup_example.py
:language: python
Running
- ::
+ .. code-block:: bash
python setup_example.py build
will build two extension modules ``scalar`` and ``fib2`` to the
build directory.
-
- __ setup_example.py
-
+
Extensions to ``distutils``
===========================
@@ -57,7 +57,7 @@ Extensions to ``distutils``
Run
- ::
+ .. code-block:: bash
python <setup.py file> config_fc build_src build_ext --help
@@ -73,6 +73,6 @@ Extensions to ``distutils``
See ``numpy_distutils/fcompiler.py`` for an up-to-date list of
supported compilers for different platforms, or run
- ::
+ .. code-block:: bash
- f2py -c --help-fcompiler
+ python -m numpy.f2py -c --help-fcompiler
diff --git a/doc/source/f2py/buildtools/index.rst b/doc/source/f2py/buildtools/index.rst
new file mode 100644
index 000000000..aa41fd37f
--- /dev/null
+++ b/doc/source/f2py/buildtools/index.rst
@@ -0,0 +1,102 @@
+.. _f2py-bldsys:
+
+=======================
+F2PY and Build Systems
+=======================
+
+In this section we will cover the various popular build systems and their usage
+with ``f2py``.
+
+.. note::
+ **As of November 2021**
+
+ The default build system for ``F2PY`` has traditionally been the through the
+ enhanced ``numpy.distutils`` module. This module is based on ``distutils`` which
+ will be removed in ``Python 3.12.0`` in **October 2023**; ``setuptools`` does not
+ have support for Fortran or ``F2PY`` and it is unclear if it will be supported
+ in the future. Alternative methods are thus increasingly more important.
+
+
+Basic Concepts
+===============
+
+Building an extension module which includes Python and Fortran consists of:
+
+- Fortran source(s)
+- One or more generated files from ``f2py``
+
+ + A ``C`` wrapper file is always created
+ + Code with modules require an additional ``.f90`` wrapper
+
+- ``fortranobject.{c,h}``
+
+ + Distributed with ``numpy``
+ + Can be queried via ``python -c "import numpy.f2py; print(numpy.f2py.get_include())"``
+
+- NumPy headers
+
+ + Can be queried via ``python -c "import numpy; print(numpy.get_include())"``
+
+- Python libraries and development headers
+
+Broadly speaking there are three cases which arise when considering the outputs of ``f2py``:
+
+Fortran 77 programs
+ - Input file ``blah.f``
+ - Generates
+
+ + ``blahmodule.c``
+ + ``f2pywrappers.f``
+
+ When no ``COMMON`` blocks are present only a ``C`` wrapper file is generated.
+ Wrappers are also generated to rewrite assumed shape arrays as automatic
+ arrays.
+
+Fortran 90 programs
+ - Input file ``blah.f90``
+ - Generates:
+
+ + ``blahmodule.c``
+ + ``blah-f2pywrappers2.f90``
+
+ The secondary wrapper is used to handle code which is subdivided into
+ modules. It rewrites assumed shape arrays as automatic arrays.
+
+Signature files
+ - Input file ``blah.pyf``
+ - Generates:
+
+ + ``blahmodule.c``
+ + ``blah-f2pywrappers2.f90`` (occasionally)
+ + ``f2pywrappers.f`` (occasionally)
+
+ Signature files ``.pyf`` do not signal their language standard via the file
+ extension, they may generate the F90 and F77 specific wrappers depending on
+ their contents; which shifts the burden of checking for generated files onto
+ the build system.
+
+.. note::
+
+ The signature file output situation is being reconsidered in `issue 20385`_ .
+
+
+In theory keeping the above requirements in hand, any build system can be
+adapted to generate ``f2py`` extension modules. Here we will cover a subset of
+the more popular systems.
+
+.. note::
+ ``make`` has no place in a modern multi-language setup, and so is not
+ discussed further.
+
+Build Systems
+==============
+
+.. toctree::
+ :maxdepth: 2
+
+ distutils
+ meson
+ cmake
+ skbuild
+
+.. _`issue 20385`: https://github.com/numpy/numpy/issues/20385
diff --git a/doc/source/f2py/buildtools/meson.rst b/doc/source/f2py/buildtools/meson.rst
new file mode 100644
index 000000000..d98752e65
--- /dev/null
+++ b/doc/source/f2py/buildtools/meson.rst
@@ -0,0 +1,114 @@
+.. _f2py-meson:
+
+===================
+Using via ``meson``
+===================
+
+The key advantage gained by leveraging ``meson`` over the techniques described
+in :ref:`f2py-distutils` is that this feeds into existing systems and larger
+projects with ease. ``meson`` has a rather pythonic syntax which makes it more
+comfortable and amenable to extension for ``python`` users.
+
+.. note::
+
+ Meson needs to be at-least ``0.46.0`` in order to resolve the ``python`` include directories.
+
+
+Fibonacci Walkthrough (F77)
+===========================
+
+
+We will need the generated ``C`` wrapper before we can use a general purpose
+build system like ``meson``. We will acquire this by:
+
+.. code-block:: bash
+
+ python -n numpy.f2py fib1.f -m fib2
+
+Now, consider the following ``meson.build`` file for the ``fib`` and ``scalar``
+examples from :ref:`f2py-getting-started` section:
+
+.. literalinclude:: ./../code/meson.build
+ :language: meson
+
+At this point the build will complete, but the import will fail:
+
+.. code-block:: bash
+
+ meson setup builddir
+ meson compile -C builddir
+ cd builddir
+ python -c 'import fib2'
+ Traceback (most recent call last):
+ File "<string>", line 1, in <module>
+ ImportError: fib2.cpython-39-x86_64-linux-gnu.so: undefined symbol: FIB_
+ # Check this isn't a false positive
+ nm -A fib2.cpython-39-x86_64-linux-gnu.so | grep FIB_
+ fib2.cpython-39-x86_64-linux-gnu.so: U FIB_
+
+Recall that the original example, as reproduced below, was in SCREAMCASE:
+
+.. literalinclude:: ./../code/fib1.f
+ :language: fortran
+
+With the standard approach, the subroutine exposed to ``python`` is ``fib`` and
+not ``FIB``. This means we have a few options. One approach (where possible) is
+to lowercase the original Fortran file with say:
+
+.. code-block:: bash
+
+ tr "[:upper:]" "[:lower:]" < fib1.f > fib1.f
+ python -n numpy.f2py fib1.f -m fib2
+ meson --wipe builddir
+ meson compile -C builddir
+ cd builddir
+ python -c 'import fib2'
+
+However this requires the ability to modify the source which is not always
+possible. The easiest way to solve this is to let ``f2py`` deal with it:
+
+.. code-block:: bash
+
+ python -n numpy.f2py fib1.f -m fib2 --lower
+ meson --wipe builddir
+ meson compile -C builddir
+ cd builddir
+ python -c 'import fib2'
+
+
+Automating wrapper generation
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A major pain point in the workflow defined above, is the manual tracking of
+inputs. Although it would require more effort to figure out the actual outputs
+for reasons discussed in :ref:`f2py-bldsys`.
+
+However, we can augment our workflow in a straightforward to take into account
+files for which the outputs are known when the build system is set up.
+
+.. literalinclude:: ./../code/meson_upd.build
+ :language: meson
+
+This can be compiled and run as before.
+
+.. code-block:: bash
+
+ rm -rf builddir
+ meson setup builddir
+ meson compile -C builddir
+ cd builddir
+ python -c "import numpy as np; import fibby; a = np.zeros(9); fibby.fib(a); print (a)"
+ # [ 0. 1. 1. 2. 3. 5. 8. 13. 21.]
+
+Salient points
+===============
+
+It is worth keeping in mind the following:
+
+* ``meson`` will default to passing ``-fimplicit-none`` under ``gfortran`` by
+ default, which differs from that of the standard ``np.distutils`` behaviour
+
+* It is not possible to use SCREAMCASE in this context, so either the contents
+ of the ``.f`` file or the generated wrapper ``.c`` needs to be lowered to
+ regular letters; which can be facilitated by the ``--lower`` option of
+ ``F2PY``
diff --git a/doc/source/f2py/buildtools/skbuild.rst b/doc/source/f2py/buildtools/skbuild.rst
new file mode 100644
index 000000000..f1a0bf65e
--- /dev/null
+++ b/doc/source/f2py/buildtools/skbuild.rst
@@ -0,0 +1,94 @@
+.. _f2py-skbuild:
+
+============================
+Using via ``scikit-build``
+============================
+
+``scikit-build`` provides two separate concepts geared towards the users of Python extension modules.
+
+1. A ``setuptools`` replacement (legacy behaviour)
+2. A series of ``cmake`` modules with definitions which help building Python extensions
+
+.. note::
+
+ It is possible to use ``scikit-build``'s ``cmake`` modules to `bypass the
+ cmake setup mechanism`_ completely, and to write targets which call ``f2py
+ -c``. This usage is **not recommended** since the point of these build system
+ documents are to move away from the internal ``numpy.distutils`` methods.
+
+For situations where no ``setuptools`` replacements are required or wanted (i.e.
+if ``wheels`` are not needed), it is recommended to instead use the vanilla
+``cmake`` setup described in :ref:`f2py-cmake`.
+
+Fibonacci Walkthrough (F77)
+===========================
+
+We will consider the ``fib`` example from :ref:`f2py-getting-started` section.
+
+.. literalinclude:: ./../code/fib1.f
+ :language: fortran
+
+``CMake`` modules only
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Consider using the following ``CMakeLists.txt``.
+
+.. literalinclude:: ./../code/CMakeLists_skbuild.txt
+ :language: cmake
+
+Much of the logic is the same as in :ref:`f2py-cmake`, however notably here the
+appropriate module suffix is generated via ``sysconfig.get_config_var("SO")``.
+The resulting extension can be built and loaded in the standard workflow.
+
+.. code:: bash
+
+ ls .
+ # CMakeLists.txt fib1.f
+ cmake -S . -B build
+ cmake --build build
+ cd build
+ python -c "import numpy as np; import fibby; a = np.zeros(9); fibby.fib(a); print (a)"
+ # [ 0. 1. 1. 2. 3. 5. 8. 13. 21.]
+
+
+``setuptools`` replacement
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. note::
+
+ **As of November 2021**
+
+ The behavior described here of driving the ``cmake`` build of a module is
+ considered to be legacy behaviour and should not be depended on.
+
+The utility of ``scikit-build`` lies in being able to drive the generation of
+more than extension modules, in particular a common usage pattern is the
+generation of Python distributables (for example for PyPI).
+
+The workflow with ``scikit-build`` straightforwardly supports such packaging requirements. Consider augmenting the project with a ``setup.py`` as defined:
+
+.. literalinclude:: ./../code/setup_skbuild.py
+ :language: python
+
+Along with a commensurate ``pyproject.toml``
+
+.. literalinclude:: ./../code/pyproj_skbuild.toml
+ :language: toml
+
+Together these can build the extension using ``cmake`` in tandem with other
+standard ``setuptools`` outputs. Running ``cmake`` through ``setup.py`` is
+mostly used when it is necessary to integrate with extension modules not built
+with ``cmake``.
+
+.. code:: bash
+
+ ls .
+ # CMakeLists.txt fib1.f pyproject.toml setup.py
+ python setup.py build_ext --inplace
+ python -c "import numpy as np; import fibby.fibby; a = np.zeros(9); fibby.fibby.fib(a); print (a)"
+ # [ 0. 1. 1. 2. 3. 5. 8. 13. 21.]
+
+Where we have modified the path to the module as ``--inplace`` places the
+extension module in a subfolder.
+
+.. _bypass the cmake setup mechanism: https://scikit-build.readthedocs.io/en/latest/cmake-modules/F2PY.html
diff --git a/doc/source/f2py/code/CMakeLists.txt b/doc/source/f2py/code/CMakeLists.txt
new file mode 100644
index 000000000..d16ddf77e
--- /dev/null
+++ b/doc/source/f2py/code/CMakeLists.txt
@@ -0,0 +1,65 @@
+cmake_minimum_required(VERSION 3.18) # Needed to avoid requiring embedded Python libs too
+
+project(fibby
+ VERSION 1.0
+ DESCRIPTION "FIB module"
+ LANGUAGES C Fortran
+)
+
+# Safety net
+if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
+ message(
+ FATAL_ERROR
+ "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.\n"
+ )
+endif()
+
+# Grab Python, 3.7 or newer
+find_package(Python 3.7 REQUIRED
+ COMPONENTS Interpreter Development.Module NumPy)
+
+# Grab the variables from a local Python installation
+# F2PY headers
+execute_process(
+ COMMAND "${Python_EXECUTABLE}"
+ -c "import numpy.f2py; print(numpy.f2py.get_include())"
+ OUTPUT_VARIABLE F2PY_INCLUDE_DIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+# Print out the discovered paths
+include(CMakePrintHelpers)
+cmake_print_variables(Python_INCLUDE_DIRS)
+cmake_print_variables(F2PY_INCLUDE_DIR)
+cmake_print_variables(Python_NumPy_INCLUDE_DIRS)
+
+# Common variables
+set(f2py_module_name "fibby")
+set(fortran_src_file "${CMAKE_SOURCE_DIR}/fib1.f")
+set(f2py_module_c "${f2py_module_name}module.c")
+
+# Generate sources
+add_custom_target(
+ genpyf
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${f2py_module_c}"
+)
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${f2py_module_c}"
+ COMMAND ${Python_EXECUTABLE} -m "numpy.f2py"
+ "${fortran_src_file}"
+ -m "fibby"
+ --lower # Important
+ DEPENDS fib1.f # Fortran source
+)
+
+# Set up target
+Python_add_library(${CMAKE_PROJECT_NAME} MODULE WITH_SOABI
+ "${CMAKE_CURRENT_BINARY_DIR}/${f2py_module_c}" # Generated
+ "${F2PY_INCLUDE_DIR}/fortranobject.c" # From NumPy
+ "${fortran_src_file}" # Fortran source(s)
+)
+
+# Depend on sources
+target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Python::NumPy)
+add_dependencies(${CMAKE_PROJECT_NAME} genpyf)
+target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE "${F2PY_INCLUDE_DIR}")
diff --git a/doc/source/f2py/code/CMakeLists_skbuild.txt b/doc/source/f2py/code/CMakeLists_skbuild.txt
new file mode 100644
index 000000000..3d092760b
--- /dev/null
+++ b/doc/source/f2py/code/CMakeLists_skbuild.txt
@@ -0,0 +1,95 @@
+### setup project ###
+cmake_minimum_required(VERSION 3.9)
+
+project(fibby
+ VERSION 1.0
+ DESCRIPTION "FIB module"
+ LANGUAGES C Fortran
+ )
+
+# Safety net
+if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
+ message(
+ FATAL_ERROR
+ "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.\n"
+ )
+endif()
+
+# Ensure scikit-build modules
+if (NOT SKBUILD)
+ find_package(PythonInterp 3.7 REQUIRED)
+ # Kanged --> https://github.com/Kitware/torch_liberator/blob/master/CMakeLists.txt
+ # If skbuild is not the driver; include its utilities in CMAKE_MODULE_PATH
+ execute_process(
+ COMMAND "${PYTHON_EXECUTABLE}"
+ -c "import os, skbuild; print(os.path.dirname(skbuild.__file__))"
+ OUTPUT_VARIABLE SKBLD_DIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ list(APPEND CMAKE_MODULE_PATH "${SKBLD_DIR}/resources/cmake")
+ message(STATUS "Looking in ${SKBLD_DIR}/resources/cmake for CMake modules")
+endif()
+
+# scikit-build style includes
+find_package(PythonExtensions REQUIRED) # for ${PYTHON_EXTENSION_MODULE_SUFFIX}
+
+# Grab the variables from a local Python installation
+# NumPy headers
+execute_process(
+ COMMAND "${PYTHON_EXECUTABLE}"
+ -c "import numpy; print(numpy.get_include())"
+ OUTPUT_VARIABLE NumPy_INCLUDE_DIRS
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# F2PY headers
+execute_process(
+ COMMAND "${PYTHON_EXECUTABLE}"
+ -c "import numpy.f2py; print(numpy.f2py.get_include())"
+ OUTPUT_VARIABLE F2PY_INCLUDE_DIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+# Prepping the module
+set(f2py_module_name "fibby")
+set(fortran_src_file "${CMAKE_SOURCE_DIR}/fib1.f")
+set(f2py_module_c "${f2py_module_name}module.c")
+
+# Target for enforcing dependencies
+add_custom_target(genpyf
+ DEPENDS "${fortran_src_file}"
+)
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${f2py_module_c}"
+ COMMAND ${PYTHON_EXECUTABLE} -m "numpy.f2py"
+ "${fortran_src_file}"
+ -m "fibby"
+ --lower # Important
+ DEPENDS fib1.f # Fortran source
+)
+
+add_library(${CMAKE_PROJECT_NAME} MODULE
+ "${f2py_module_name}module.c"
+ "${F2PY_INCLUDE_DIR}/fortranobject.c"
+ "${fortran_src_file}")
+
+target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
+ ${F2PY_INCLUDE_DIR}
+ ${NumPy_INCLUDE_DIRS}
+ ${PYTHON_INCLUDE_DIRS})
+set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES SUFFIX "${PYTHON_EXTENSION_MODULE_SUFFIX}")
+set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
+
+# Linker fixes
+if (UNIX)
+ if (APPLE)
+ set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
+ LINK_FLAGS '-Wl,-dylib,-undefined,dynamic_lookup')
+ else()
+ set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
+ LINK_FLAGS '-Wl,--allow-shlib-undefined')
+ endif()
+endif()
+
+add_dependencies(${CMAKE_PROJECT_NAME} genpyf)
+
+install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION fibby)
diff --git a/doc/source/f2py/code/meson.build b/doc/source/f2py/code/meson.build
new file mode 100644
index 000000000..b756abf8f
--- /dev/null
+++ b/doc/source/f2py/code/meson.build
@@ -0,0 +1,38 @@
+project('f2py_examples', 'c',
+ version : '0.1',
+ default_options : ['warning_level=2'])
+
+add_languages('fortran')
+
+py_mod = import('python')
+py3 = py_mod.find_installation('python3')
+py3_dep = py3.dependency()
+message(py3.path())
+message(py3.get_install_dir())
+
+incdir_numpy = run_command(py3,
+ ['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'],
+ check : true
+).stdout().strip()
+
+incdir_f2py = run_command(py3,
+ ['-c', 'import os; os.chdir(".."); import numpy.f2py; print(numpy.f2py.get_include())'],
+ check : true
+).stdout().strip()
+
+fibby_source = custom_target('fibbymodule.c',
+ input : ['fib1.f'],
+ output : ['fibbymodule.c'],
+ command : [ py3, '-m', 'numpy.f2py', '@INPUT@',
+ '-m', 'fibby', '--lower' ]
+ )
+
+inc_np = include_directories(incdir_numpy, incdir_f2py)
+
+py3.extension_module('fibby',
+ 'fib1.f',
+ fibby_source,
+ incdir_f2py+'/fortranobject.c',
+ include_directories: inc_np,
+ dependencies : py3_dep,
+ install : true)
diff --git a/doc/source/f2py/code/meson_upd.build b/doc/source/f2py/code/meson_upd.build
new file mode 100644
index 000000000..97bd8d175
--- /dev/null
+++ b/doc/source/f2py/code/meson_upd.build
@@ -0,0 +1,37 @@
+project('f2py_examples', 'c',
+ version : '0.1',
+ default_options : ['warning_level=2'])
+
+add_languages('fortran')
+
+py_mod = import('python')
+py3 = py_mod.find_installation('python3')
+py3_dep = py3.dependency()
+message(py3.path())
+message(py3.get_install_dir())
+
+incdir_numpy = run_command(py3,
+ ['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'],
+ check : true
+).stdout().strip()
+
+incdir_f2py = run_command(py3,
+ ['-c', 'import os; os.chdir(".."); import numpy.f2py; print(numpy.f2py.get_include())'],
+ check : true
+).stdout().strip()
+
+fibby_source = custom_target('fibbymodule.c',
+ input : ['fib1.f'],
+ output : ['fibbymodule.c'],
+ command : [ py3, '-m', 'numpy.f2py', '@INPUT@',
+ '-m', 'fibby', '--lower' ])
+
+inc_np = include_directories(incdir_numpy, incdir_f2py)
+
+py3.extension_module('fibby',
+ 'fib1.f',
+ fibby_source,
+ incdir_f2py+'/fortranobject.c',
+ include_directories: inc_np,
+ dependencies : py3_dep,
+ install : true)
diff --git a/doc/source/f2py/code/pyproj_skbuild.toml b/doc/source/f2py/code/pyproj_skbuild.toml
new file mode 100644
index 000000000..bcd6ae99c
--- /dev/null
+++ b/doc/source/f2py/code/pyproj_skbuild.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["setuptools>=42", "wheel", "scikit-build", "cmake>=3.9", "numpy>=1.21"]
+build-backend = "setuptools.build_meta"
diff --git a/doc/source/f2py/code/setup_skbuild.py b/doc/source/f2py/code/setup_skbuild.py
new file mode 100644
index 000000000..28dcdcb1f
--- /dev/null
+++ b/doc/source/f2py/code/setup_skbuild.py
@@ -0,0 +1,10 @@
+from skbuild import setup
+
+setup(
+ name="fibby",
+ version="0.0.1",
+ description="a minimal example package (fortran version)",
+ license="MIT",
+ packages=['fibby'],
+ python_requires=">=3.7",
+)
diff --git a/doc/source/f2py/f2py.getting-started.rst b/doc/source/f2py/f2py.getting-started.rst
index 1709aad61..c1a006f6f 100644
--- a/doc/source/f2py/f2py.getting-started.rst
+++ b/doc/source/f2py/f2py.getting-started.rst
@@ -1,3 +1,5 @@
+.. _f2py-getting-started:
+
======================================
Three ways to wrap - getting started
======================================
diff --git a/doc/source/f2py/index.rst b/doc/source/f2py/index.rst
index c774a0df6..56df31b4e 100644
--- a/doc/source/f2py/index.rst
+++ b/doc/source/f2py/index.rst
@@ -23,9 +23,9 @@ from Python.
usage
f2py.getting-started
- distutils
python-usage
signature-file
+ buildtools/index
advanced
.. _Python: https://www.python.org/
diff --git a/doc/source/reference/c-api/data_memory.rst b/doc/source/reference/c-api/data_memory.rst
index b779026b4..2084ab5d0 100644
--- a/doc/source/reference/c-api/data_memory.rst
+++ b/doc/source/reference/c-api/data_memory.rst
@@ -20,8 +20,8 @@ Historical overview
Since version 1.7.0, NumPy has exposed a set of ``PyDataMem_*`` functions
(:c:func:`PyDataMem_NEW`, :c:func:`PyDataMem_FREE`, :c:func:`PyDataMem_RENEW`)
which are backed by `alloc`, `free`, `realloc` respectively. In that version
-NumPy also exposed the `PyDataMem_EventHook` function described below, which
-wrap the OS-level calls.
+NumPy also exposed the `PyDataMem_EventHook` function (now deprecated)
+described below, which wrap the OS-level calls.
Since those early days, Python also improved its memory management
capabilities, and began providing
@@ -50,10 +50,10 @@ management routines can use :c:func:`PyDataMem_SetHandler`, which uses a
:c:type:`PyDataMem_Handler` structure to hold pointers to functions used to
manage the data memory. The calls are still wrapped by internal routines to
call :c:func:`PyTraceMalloc_Track`, :c:func:`PyTraceMalloc_Untrack`, and will
-use the :c:func:`PyDataMem_EventHookFunc` mechanism. Since the functions may
-change during the lifetime of the process, each ``ndarray`` carries with it the
-functions used at the time of its instantiation, and these will be used to
-reallocate or free the data memory of the instance.
+use the deprecated :c:func:`PyDataMem_EventHookFunc` mechanism. Since the
+functions may change during the lifetime of the process, each ``ndarray``
+carries with it the functions used at the time of its instantiation, and these
+will be used to reallocate or free the data memory of the instance.
.. c:type:: PyDataMem_Handler
@@ -119,7 +119,9 @@ For an example of setting up and using the PyDataMem_Handler, see the test in
thread. The hook should be written to be reentrant, if it performs
operations that might cause new allocation events (such as the
creation/destruction numpy objects, or creating/destroying Python
- objects which might cause a gc)
+ objects which might cause a gc).
+
+ Deprecated in v1.23
What happens when deallocating if there is no policy set
--------------------------------------------------------
diff --git a/doc/source/reference/c-api/types-and-structures.rst b/doc/source/reference/c-api/types-and-structures.rst
index 605a4ae71..1ea47b498 100644
--- a/doc/source/reference/c-api/types-and-structures.rst
+++ b/doc/source/reference/c-api/types-and-structures.rst
@@ -286,6 +286,11 @@ PyArrayDescr_Type and PyArray_Descr
array like behavior. Each bit in this member is a flag which are named
as:
+ .. c:member:: int alignment
+
+ Non-NULL if this type is an array (C-contiguous) of some other type
+
+
..
dedented to allow internal linking, pending a refactoring
diff --git a/doc/source/reference/routines.array-manipulation.rst b/doc/source/reference/routines.array-manipulation.rst
index 1c96495d9..95fc39876 100644
--- a/doc/source/reference/routines.array-manipulation.rst
+++ b/doc/source/reference/routines.array-manipulation.rst
@@ -59,7 +59,6 @@ Changing kind of array
asfortranarray
ascontiguousarray
asarray_chkfinite
- asscalar
require
Joining arrays
diff --git a/doc/source/release.rst b/doc/source/release.rst
index a4a5bde63..9504c6e97 100644
--- a/doc/source/release.rst
+++ b/doc/source/release.rst
@@ -5,6 +5,7 @@ Release notes
.. toctree::
:maxdepth: 3
+ 1.23.0 <release/1.23.0-notes>
1.22.0 <release/1.22.0-notes>
1.21.4 <release/1.21.4-notes>
1.21.3 <release/1.21.3-notes>
diff --git a/doc/source/release/1.23.0-notes.rst b/doc/source/release/1.23.0-notes.rst
new file mode 100644
index 000000000..330e7fd44
--- /dev/null
+++ b/doc/source/release/1.23.0-notes.rst
@@ -0,0 +1,45 @@
+.. currentmodule:: numpy
+
+==========================
+NumPy 1.23.0 Release Notes
+==========================
+
+
+Highlights
+==========
+
+
+New functions
+=============
+
+
+Deprecations
+============
+
+
+Future Changes
+==============
+
+
+Expired deprecations
+====================
+
+
+Compatibility notes
+===================
+
+
+C API changes
+=============
+
+
+New Features
+============
+
+
+Improvements
+============
+
+
+Changes
+=======
diff --git a/doc/source/user/basics.copies.rst b/doc/source/user/basics.copies.rst
index 583a59b95..e8ba68bc0 100644
--- a/doc/source/user/basics.copies.rst
+++ b/doc/source/user/basics.copies.rst
@@ -39,6 +39,8 @@ do not reflect on the original array. Making a copy is slower and
memory-consuming but sometimes necessary. A copy can be forced by using
:meth:`.ndarray.copy`.
+.. _indexing-operations:
+
Indexing operations
===================
diff --git a/doc/source/user/basics.indexing.rst b/doc/source/user/basics.indexing.rst
index 264c3d721..e99682f02 100644
--- a/doc/source/user/basics.indexing.rst
+++ b/doc/source/user/basics.indexing.rst
@@ -28,6 +28,7 @@ Note that in Python, ``x[(exp1, exp2, ..., expN)]`` is equivalent to
``x[exp1, exp2, ..., expN]``; the latter is just syntactic sugar
for the former.
+.. _basic-indexing:
Basic indexing
--------------
@@ -88,6 +89,7 @@ that is subsequently indexed by 2.
rapidly changing location in memory. This difference represents a
great potential for confusion.
+.. _slicing-and-striding:
Slicing and striding
^^^^^^^^^^^^^^^^^^^^
@@ -226,6 +228,7 @@ concepts to remember include:
.. index::
pair: ndarray; view
+.. _dimensional-indexing-tools:
Dimensional indexing tools
^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -470,6 +473,7 @@ such an array with an image with shape (ny, nx) with dtype=np.uint8
lookup table) will result in an array of shape (ny, nx, 3) where a
triple of RGB values is associated with each pixel location.
+.. _boolean-indexing:
Boolean array indexing
^^^^^^^^^^^^^^^^^^^^^^
@@ -851,7 +855,7 @@ For this reason, it is possible to use the output from the
:meth:`np.nonzero() <ndarray.nonzero>` function directly as an index since
it always returns a tuple of index arrays.
-Because the special treatment of tuples, they are not automatically
+Because of the special treatment of tuples, they are not automatically
converted to an array as a list would be. As an example: ::
>>> z[[1, 1, 1, 1]] # produces a large array
diff --git a/doc/source/user/basics.io.genfromtxt.rst b/doc/source/user/basics.io.genfromtxt.rst
index 8fe7565aa..6a1ba75dd 100644
--- a/doc/source/user/basics.io.genfromtxt.rst
+++ b/doc/source/user/basics.io.genfromtxt.rst
@@ -231,9 +231,7 @@ When ``dtype=None``, the type of each column is determined iteratively from
its data. We start by checking whether a string can be converted to a
boolean (that is, if the string matches ``true`` or ``false`` in lower
cases); then whether it can be converted to an integer, then to a float,
-then to a complex and eventually to a string. This behavior may be changed
-by modifying the default mapper of the
-:class:`~numpy.lib._iotools.StringConverter` class.
+then to a complex and eventually to a string.
The option ``dtype=None`` is provided for convenience. However, it is
significantly slower than setting the dtype explicitly.
@@ -514,15 +512,15 @@ output array will then be a :class:`~numpy.ma.MaskedArray`.
Shortcut functions
==================
-In addition to :func:`~numpy.genfromtxt`, the :mod:`numpy.lib.npyio` module
+In addition to :func:`~numpy.genfromtxt`, the ``numpy.lib.npyio`` module
provides several convenience functions derived from
:func:`~numpy.genfromtxt`. These functions work the same way as the
original, but they have different default values.
-:func:`~numpy.npyio.recfromtxt`
+``numpy.lib.npyio.recfromtxt``
Returns a standard :class:`numpy.recarray` (if ``usemask=False``) or a
- :class:`~numpy.ma.mrecords.MaskedRecords` array (if ``usemaske=True``). The
+ ``numpy.ma.mrecords.MaskedRecords`` array (if ``usemaske=True``). The
default dtype is ``dtype=None``, meaning that the types of each column
will be automatically determined.
-:func:`~numpy.npyio.recfromcsv`
- Like :func:`~numpy.npyio.recfromtxt`, but with a default ``delimiter=","``.
+``numpy.lib.npyio.recfromcsv``
+ Like ``numpy.lib.npyio.recfromtxt``, but with a default ``delimiter=","``.
diff --git a/doc/source/user/basics.rec.rst b/doc/source/user/basics.rec.rst
index 1e6f30506..7f487f39b 100644
--- a/doc/source/user/basics.rec.rst
+++ b/doc/source/user/basics.rec.rst
@@ -579,12 +579,13 @@ As an optional convenience numpy provides an ndarray subclass,
attribute instead of only by index.
Record arrays use a special datatype, :class:`numpy.record`, that allows
field access by attribute on the structured scalars obtained from the array.
-The :mod:`numpy.rec` module provides functions for creating recarrays from
+The ``numpy.rec`` module provides functions for creating recarrays from
various objects.
Additional helper functions for creating and manipulating structured arrays
can be found in :mod:`numpy.lib.recfunctions`.
-The simplest way to create a record array is with ``numpy.rec.array``::
+The simplest way to create a record array is with
+:func:`numpy.rec.array <numpy.core.records.array>`::
>>> recordarr = np.rec.array([(1, 2., 'Hello'), (2, 3., "World")],
... dtype=[('foo', 'i4'),('bar', 'f4'), ('baz', 'S10')])
@@ -600,14 +601,14 @@ The simplest way to create a record array is with ``numpy.rec.array``::
>>> recordarr[1].baz
b'World'
-:func:`numpy.rec.array` can convert a wide variety of arguments into record
-arrays, including structured arrays::
+:func:`numpy.rec.array <numpy.core.records.array>` can convert a wide variety
+of arguments into record arrays, including structured arrays::
>>> arr = np.array([(1, 2., 'Hello'), (2, 3., "World")],
... dtype=[('foo', 'i4'), ('bar', 'f4'), ('baz', 'S10')])
>>> recordarr = np.rec.array(arr)
-The :mod:`numpy.rec` module provides a number of other convenience functions for
+The ``numpy.rec`` module provides a number of other convenience functions for
creating record arrays, see :ref:`record array creation routines
<routines.array-creation.rec>`.
diff --git a/doc/source/user/how-to-index.rst b/doc/source/user/how-to-index.rst
new file mode 100644
index 000000000..41061d5f4
--- /dev/null
+++ b/doc/source/user/how-to-index.rst
@@ -0,0 +1,351 @@
+.. currentmodule:: numpy
+
+.. _how-to-index.rst:
+
+*****************************************
+How to index :class:`ndarrays <.ndarray>`
+*****************************************
+
+.. seealso:: :ref:`basics.indexing`
+
+This page tackles common examples. For an in-depth look into indexing, refer
+to :ref:`basics.indexing`.
+
+Access specific/arbitrary rows and columns
+==========================================
+
+Use :ref:`basic-indexing` features like :ref:`slicing-and-striding`, and
+:ref:`dimensional-indexing-tools`.
+
+ >>> a = np.arange(30).reshape(2, 3, 5)
+ >>> a
+ array([[[ 0, 1, 2, 3, 4],
+ [ 5, 6, 7, 8, 9],
+ [10, 11, 12, 13, 14]],
+ <BLANKLINE>
+ [[15, 16, 17, 18, 19],
+ [20, 21, 22, 23, 24],
+ [25, 26, 27, 28, 29]]])
+ >>> a[0, 2, :]
+ array([10, 11, 12, 13, 14])
+ >>> a[0, :, 3]
+ array([ 3, 8, 13])
+
+Note that the output from indexing operations can have different shape from the
+original object. To preserve the original dimensions after indexing, you can
+use :func:`newaxis`. To use other such tools, refer to
+:ref:`dimensional-indexing-tools`.
+
+ >>> a[0, :, 3].shape
+ (3,)
+ >>> a[0, :, 3, np.newaxis].shape
+ (3, 1)
+ >>> a[0, :, 3, np.newaxis, np.newaxis].shape
+ (3, 1, 1)
+
+Variables can also be used to index::
+
+ >>> y = 0
+ >>> a[y, :, y+3]
+ array([ 3, 8, 13])
+
+Refer to :ref:`dealing-with-variable-indices` to see how to use
+:term:`python:slice` and :py:data:`Ellipsis` in your index variables.
+
+Index columns
+-------------
+
+To index columns, you have to index the last axis. Use
+:ref:`dimensional-indexing-tools` to get the desired number of dimensions::
+
+ >>> a = np.arange(24).reshape(2, 3, 4)
+ >>> a
+ array([[[ 0, 1, 2, 3],
+ [ 4, 5, 6, 7],
+ [ 8, 9, 10, 11]],
+ <BLANKLINE>
+ [[12, 13, 14, 15],
+ [16, 17, 18, 19],
+ [20, 21, 22, 23]]])
+ >>> a[..., 3]
+ array([[ 3, 7, 11],
+ [15, 19, 23]])
+
+To index specific elements in each column, make use of :ref:`advanced-indexing`
+as below::
+
+ >>> arr = np.arange(3*4).reshape(3, 4)
+ >>> arr
+ array([[ 0, 1, 2, 3],
+ [ 4, 5, 6, 7],
+ [ 8, 9, 10, 11]])
+ >>> column_indices = [[1, 3], [0, 2], [2, 2]]
+ >>> np.arange(arr.shape[0])
+ array([0, 1, 2])
+ >>> row_indices = np.arange(arr.shape[0])[:, np.newaxis]
+ >>> row_indices
+ array([[0],
+ [1],
+ [2]])
+
+Use the ``row_indices`` and ``column_indices`` for advanced
+indexing::
+
+ >>> arr[row_indices, column_indices]
+ array([[ 1, 3],
+ [ 4, 6],
+ [10, 10]])
+
+Index along a specific axis
+---------------------------
+
+Use :meth:`take`. See also :meth:`take_along_axis` and
+:meth:`put_along_axis`.
+
+ >>> a = np.arange(30).reshape(2, 3, 5)
+ >>> a
+ array([[[ 0, 1, 2, 3, 4],
+ [ 5, 6, 7, 8, 9],
+ [10, 11, 12, 13, 14]],
+ <BLANKLINE>
+ [[15, 16, 17, 18, 19],
+ [20, 21, 22, 23, 24],
+ [25, 26, 27, 28, 29]]])
+ >>> np.take(a, [2, 3], axis=2)
+ array([[[ 2, 3],
+ [ 7, 8],
+ [12, 13]],
+ <BLANKLINE>
+ [[17, 18],
+ [22, 23],
+ [27, 28]]])
+ >>> np.take(a, [2], axis=1)
+ array([[[10, 11, 12, 13, 14]],
+ <BLANKLINE>
+ [[25, 26, 27, 28, 29]]])
+
+Create subsets of larger matrices
+=================================
+
+Use :ref:`slicing-and-striding` to access chunks of a large array::
+
+ >>> a = np.arange(100).reshape(10, 10)
+ >>> a
+ array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
+ [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
+ [20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
+ [30, 31, 32, 33, 34, 35, 36, 37, 38, 39],
+ [40, 41, 42, 43, 44, 45, 46, 47, 48, 49],
+ [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],
+ [60, 61, 62, 63, 64, 65, 66, 67, 68, 69],
+ [70, 71, 72, 73, 74, 75, 76, 77, 78, 79],
+ [80, 81, 82, 83, 84, 85, 86, 87, 88, 89],
+ [90, 91, 92, 93, 94, 95, 96, 97, 98, 99]])
+ >>> a[2:5, 2:5]
+ array([[22, 23, 24],
+ [32, 33, 34],
+ [42, 43, 44]])
+ >>> a[2:5, 1:3]
+ array([[21, 22],
+ [31, 32],
+ [41, 42]])
+ >>> a[:5, :5]
+ array([[ 0, 1, 2, 3, 4],
+ [10, 11, 12, 13, 14],
+ [20, 21, 22, 23, 24],
+ [30, 31, 32, 33, 34],
+ [40, 41, 42, 43, 44]])
+
+The same thing can be done with advanced indexing in a slightly more complex
+way. Remember that
+:ref:`advanced indexing creates a copy <indexing-operations>`::
+
+ >>> a[np.arange(5)[:, None], np.arange(5)[None, :]]
+ array([[ 0, 1, 2, 3, 4],
+ [10, 11, 12, 13, 14],
+ [20, 21, 22, 23, 24],
+ [30, 31, 32, 33, 34],
+ [40, 41, 42, 43, 44]])
+
+You can also use :meth:`mgrid` to generate indices::
+
+ >>> indices = np.mgrid[0:6:2]
+ >>> indices
+ array([0, 2, 4])
+ >>> a[:, indices]
+ array([[ 0, 2, 4],
+ [10, 12, 14],
+ [20, 22, 24],
+ [30, 32, 34],
+ [40, 42, 44],
+ [50, 52, 54],
+ [60, 62, 64],
+ [70, 72, 74],
+ [80, 82, 84],
+ [90, 92, 94]])
+
+Filter values
+=============
+
+Non-zero elements
+-----------------
+
+Use :meth:`nonzero` to get a tuple of array indices of non-zero elements
+corresponding to every dimension::
+
+ >>> z = np.array([[1, 2, 3, 0], [0, 0, 5, 3], [4, 6, 0, 0]])
+ >>> z
+ array([[1, 2, 3, 0],
+ [0, 0, 5, 3],
+ [4, 6, 0, 0]])
+ >>> np.nonzero(z)
+ (array([0, 0, 0, 1, 1, 2, 2]), array([0, 1, 2, 2, 3, 0, 1]))
+
+Use :meth:`flatnonzero` to fetch indices of elements that are non-zero in
+the flattened version of the ndarray::
+
+ >>> np.flatnonzero(z)
+ array([0, 1, 2, 6, 7, 8, 9])
+
+Arbitrary conditions
+--------------------
+
+Use :meth:`where` to generate indices based on conditions and then
+use :ref:`advanced-indexing`.
+
+ >>> a = np.arange(30).reshape(2, 3, 5)
+ >>> indices = np.where(a % 2 == 0)
+ >>> indices
+ (array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]),
+ array([0, 0, 0, 1, 1, 2, 2, 2, 0, 0, 1, 1, 1, 2, 2]),
+ array([0, 2, 4, 1, 3, 0, 2, 4, 1, 3, 0, 2, 4, 1, 3]))
+ >>> a[indices]
+ array([ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28])
+
+Or, use :ref:`boolean-indexing`::
+
+ >>> a > 14
+ array([[[False, False, False, False, False],
+ [False, False, False, False, False],
+ [False, False, False, False, False]],
+ <BLANKLINE>
+ [[ True, True, True, True, True],
+ [ True, True, True, True, True],
+ [ True, True, True, True, True]]])
+ >>> a[a > 14]
+ array([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29])
+
+Replace values after filtering
+------------------------------
+
+Use assignment with filtering to replace desired values::
+
+ >>> p = np.arange(-10, 10).reshape(2, 2, 5)
+ >>> p
+ array([[[-10, -9, -8, -7, -6],
+ [ -5, -4, -3, -2, -1]],
+ <BLANKLINE>
+ [[ 0, 1, 2, 3, 4],
+ [ 5, 6, 7, 8, 9]]])
+ >>> q = p < 0
+ >>> q
+ array([[[ True, True, True, True, True],
+ [ True, True, True, True, True]],
+ <BLANKLINE>
+ [[False, False, False, False, False],
+ [False, False, False, False, False]]])
+ >>> p[q] = 0
+ >>> p
+ array([[[0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0]],
+ <BLANKLINE>
+ [[0, 1, 2, 3, 4],
+ [5, 6, 7, 8, 9]]])
+
+Fetch indices of max/min values
+===============================
+
+Use :meth:`argmax` and :meth:`argmin`::
+
+ >>> a = np.arange(30).reshape(2, 3, 5)
+ >>> np.argmax(a)
+ 29
+ >>> np.argmin(a)
+ 0
+
+Use the ``axis`` keyword to get the indices of maximum and minimum
+values along a specific axis::
+
+ >>> np.argmax(a, axis=0)
+ array([[1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1]])
+ >>> np.argmax(a, axis=1)
+ array([[2, 2, 2, 2, 2],
+ [2, 2, 2, 2, 2]])
+ >>> np.argmax(a, axis=2)
+ array([[4, 4, 4],
+ [4, 4, 4]])
+ <BLANKLINE>
+ >>> np.argmin(a, axis=1)
+ array([[0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0]])
+ >>> np.argmin(a, axis=2)
+ array([[0, 0, 0],
+ [0, 0, 0]])
+
+Set ``keepdims`` to ``True`` to keep the axes which are reduced in the
+result as dimensions with size one::
+
+ >>> np.argmin(a, axis=2, keepdims=True)
+ array([[[0],
+ [0],
+ [0]],
+ <BLANKLINE>
+ [[0],
+ [0],
+ [0]]])
+ >>> np.argmax(a, axis=1, keepdims=True)
+ array([[[2, 2, 2, 2, 2]],
+ <BLANKLINE>
+ [[2, 2, 2, 2, 2]]])
+
+Index the same ndarray multiple times efficiently
+=================================================
+
+It must be kept in mind that basic indexing produces :term:`views <view>`
+and advanced indexing produces :term:`copies <copy>`, which are
+computationally less efficient. Hence, you should take care to use basic
+indexing wherever possible instead of advanced indexing.
+
+Further reading
+===============
+
+Nicolas Rougier's `100 NumPy exercises <https://github.com/rougier/numpy-100>`_
+provide a good insight into how indexing is combined with other operations.
+Exercises `6`_, `8`_, `10`_, `15`_, `16`_, `19`_, `20`_, `45`_, `59`_,
+`64`_, `65`_, `70`_, `71`_, `72`_, `76`_, `80`_, `81`_, `84`_, `87`_, `90`_,
+`93`_, `94`_ are specially focused on indexing.
+
+.. _6: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#6-create-a-null-vector-of-size-10-but-the-fifth-value-which-is-1-
+.. _8: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#8-reverse-a-vector-first-element-becomes-last-
+.. _10: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#10-find-indices-of-non-zero-elements-from-120040-
+.. _15: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#15-create-a-2d-array-with-1-on-the-border-and-0-inside-
+.. _16: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#16-how-to-add-a-border-filled-with-0s-around-an-existing-array-
+.. _19: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#19-create-a-8x8-matrix-and-fill-it-with-a-checkerboard-pattern-
+.. _20: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#20-consider-a-678-shape-array-what-is-the-index-xyz-of-the-100th-element-
+.. _45: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#45-create-random-vector-of-size-10-and-replace-the-maximum-value-by-0-
+.. _59: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#59-how-to-sort-an-array-by-the-nth-column-
+.. _64: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#64-consider-a-given-vector-how-to-add-1-to-each-element-indexed-by-a-second-vector-be-careful-with-repeated-indices-
+.. _65: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#65-how-to-accumulate-elements-of-a-vector-x-to-an-array-f-based-on-an-index-list-i-
+.. _70: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#70-consider-the-vector-1-2-3-4-5-how-to-build-a-new-vector-with-3-consecutive-zeros-interleaved-between-each-value-
+.. _71: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#71-consider-an-array-of-dimension-553-how-to-mulitply-it-by-an-array-with-dimensions-55-
+.. _72: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#72-how-to-swap-two-rows-of-an-array-
+.. _76: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#76-consider-a-one-dimensional-array-z-build-a-two-dimensional-array-whose-first-row-is-z0z1z2-and-each-subsequent-row-is--shifted-by-1-last-row-should-be-z-3z-2z-1-
+.. _80: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#80-consider-an-arbitrary-array-write-a-function-that-extract-a-subpart-with-a-fixed-shape-and-centered-on-a-given-element-pad-with-a-fill-value-when-necessary-
+.. _81: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#81-consider-an-array-z--1234567891011121314-how-to-generate-an-array-r--1234-2345-3456--11121314-
+.. _84: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#84-extract-all-the-contiguous-3x3-blocks-from-a-random-10x10-matrix-
+.. _87: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#87-consider-a-16x16-array-how-to-get-the-block-sum-block-size-is-4x4-
+.. _90: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#90-given-an-arbitrary-number-of-vectors-build-the-cartesian-product-every-combinations-of-every-item-
+.. _93: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#93-consider-two-arrays-a-and-b-of-shape-83-and-22-how-to-find-rows-of-a-that-contain-elements-of-each-row-of-b-regardless-of-the-order-of-the-elements-in-b-
+.. _94: https://github.com/rougier/numpy-100/blob/master/100_Numpy_exercises_with_solutions.md#94-considering-a-10x3-matrix-extract-rows-with-unequal-values-eg-223- \ No newline at end of file
diff --git a/doc/source/user/howtos_index.rst b/doc/source/user/howtos_index.rst
index 89a6f54e7..2d66d0638 100644
--- a/doc/source/user/howtos_index.rst
+++ b/doc/source/user/howtos_index.rst
@@ -13,3 +13,4 @@ the package, see the :ref:`API reference <reference>`.
how-to-how-to
how-to-io
+ how-to-index
diff --git a/environment.yml b/environment.yml
index 1bc8b44a7..701f7d46c 100644
--- a/environment.yml
+++ b/environment.yml
@@ -12,7 +12,7 @@ dependencies:
- compilers
- openblas
- nomkl
- - setuptools=58.4
+ - setuptools=59.2.0
# For testing
- pytest
- pytest-cov
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index e01df7c90..eb1e81c6a 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -2445,11 +2445,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def __ior__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
@overload
def __ior__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
- @overload
- def __ior__(self: NDArray[_ScalarType], other: _RecursiveSequence) -> NDArray[_ScalarType]: ...
- @overload
+
def __dlpack__(self: NDArray[number[Any]], *, stream: None = ...) -> _PyCapsule: ...
- @overload
def __dlpack_device__(self) -> Tuple[int, L[0]]: ...
# Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
@@ -4342,4 +4339,3 @@ class _SupportsDLPack(Protocol[_T_contra]):
def __dlpack__(self, *, stream: None | _T_contra = ...) -> _PyCapsule: ...
def _from_dlpack(__obj: _SupportsDLPack[None]) -> NDArray[Any]: ...
-
diff --git a/numpy/array_api/_array_object.py b/numpy/array_api/_array_object.py
index 8794c5ea5..ead061882 100644
--- a/numpy/array_api/_array_object.py
+++ b/numpy/array_api/_array_object.py
@@ -1072,4 +1072,4 @@ class Array:
# https://data-apis.org/array-api/latest/API_specification/array_object.html#t
if self.ndim != 2:
raise ValueError("x.T requires x to have 2 dimensions. Use x.mT to transpose stacks of matrices and permute_dims() to permute dimensions.")
- return self._array.T
+ return self.__class__._new(self._array.T)
diff --git a/numpy/array_api/tests/test_array_object.py b/numpy/array_api/tests/test_array_object.py
index 12479d765..deab50693 100644
--- a/numpy/array_api/tests/test_array_object.py
+++ b/numpy/array_api/tests/test_array_object.py
@@ -4,6 +4,7 @@ from numpy.testing import assert_raises
import numpy as np
from .. import ones, asarray, result_type, all, equal
+from .._array_object import Array
from .._dtypes import (
_all_dtypes,
_boolean_dtypes,
@@ -301,3 +302,16 @@ def test_device_property():
assert all(equal(asarray(a, device='cpu'), a))
assert_raises(ValueError, lambda: asarray(a, device='gpu'))
+
+def test_array_properties():
+ a = ones((1, 2, 3))
+ b = ones((2, 3))
+ assert_raises(ValueError, lambda: a.T)
+
+ assert isinstance(b.T, Array)
+ assert b.T.shape == (3, 2)
+
+ assert isinstance(a.mT, Array)
+ assert a.mT.shape == (1, 3, 2)
+ assert isinstance(b.mT, Array)
+ assert b.mT.shape == (3, 2)
diff --git a/numpy/compat/py3k.py b/numpy/compat/py3k.py
index 1fa17621a..3d10bb988 100644
--- a/numpy/compat/py3k.py
+++ b/numpy/compat/py3k.py
@@ -107,7 +107,9 @@ class contextlib_nullcontext:
def npy_load_module(name, fn, info=None):
"""
- Load a module.
+ Load a module. Uses ``load_module`` which will be deprecated in python
+ 3.12. An alternative that uses ``exec_module`` is in
+ numpy.distutils.misc_util.exec_mod_from_location
.. versionadded:: 1.11.2
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index 078c58976..7d009ad9f 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -2658,8 +2658,9 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('shape',
See Also
--------
- numpy.reshape : similar function
- ndarray.reshape : similar method
+ numpy.shape : Equivalent getter function.
+ numpy.reshape : Function similar to setting ``shape``.
+ ndarray.reshape : Method similar to setting ``shape``.
"""))
diff --git a/numpy/core/code_generators/cversions.txt b/numpy/core/code_generators/cversions.txt
index f0a128d3d..e1ee8a860 100644
--- a/numpy/core/code_generators/cversions.txt
+++ b/numpy/core/code_generators/cversions.txt
@@ -1,6 +1,8 @@
# Hash below were defined from numpy_api_order.txt and ufunc_api_order.txt
# When adding a new version here for a new minor release, also add the same
-# version as NPY_x_y_API_VERSION in numpyconfig.h
+# version as NPY_x_y_API_VERSION in numpyconfig.h and C_API_VERSION in
+# setup_common.py.
+
0x00000001 = 603580d224763e58c5e7147f804dc0f5
0x00000002 = 8ecb29306758515ae69749c803a75da1
0x00000003 = bf22c0d05b31625d2a7015988d61ce5a
@@ -59,4 +61,5 @@
0x0000000e = 17a0f366e55ec05e5c5c149123478452
# Version 15 (NumPy 1.22) Configurable memory allocations
+# Version 14 (NumPy 1.23) No change.
0x0000000f = b8783365b873681cd204be50cdfb448d
diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py
index c9be94569..cd584eea7 100644
--- a/numpy/core/code_generators/ufunc_docstrings.py
+++ b/numpy/core/code_generators/ufunc_docstrings.py
@@ -3827,6 +3827,7 @@ add_newdoc('numpy.core.umath', 'sqrt',
--------
lib.scimath.sqrt
A version which returns complex numbers when given negative reals.
+ Note: 0.0 and -0.0 are handled differently for complex inputs.
Notes
-----
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 3242124ac..f26f306fa 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -17,7 +17,7 @@ _dt_ = nt.sctype2char
# functions that are methods
__all__ = [
- 'alen', 'all', 'alltrue', 'amax', 'amin', 'any', 'argmax',
+ 'all', 'alltrue', 'amax', 'amin', 'any', 'argmax',
'argmin', 'argpartition', 'argsort', 'around', 'choose', 'clip',
'compress', 'cumprod', 'cumproduct', 'cumsum', 'diagonal', 'mean',
'ndim', 'nonzero', 'partition', 'prod', 'product', 'ptp', 'put',
@@ -1980,25 +1980,27 @@ def shape(a):
See Also
--------
- len
+ len : ``len(a)`` is equivalent to ``np.shape(a)[0]`` for N-D arrays with
+ ``N>=1``.
ndarray.shape : Equivalent array method.
Examples
--------
>>> np.shape(np.eye(3))
(3, 3)
- >>> np.shape([[1, 2]])
+ >>> np.shape([[1, 3]])
(1, 2)
>>> np.shape([0])
(1,)
>>> np.shape(0)
()
- >>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
+ >>> a = np.array([(1, 2), (3, 4), (5, 6)],
+ ... dtype=[('x', 'i4'), ('y', 'i4')])
>>> np.shape(a)
- (2,)
+ (3,)
>>> a.shape
- (2,)
+ (3,)
"""
try:
@@ -2917,51 +2919,6 @@ def amin(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
keepdims=keepdims, initial=initial, where=where)
-def _alen_dispathcer(a):
- return (a,)
-
-
-@array_function_dispatch(_alen_dispathcer)
-def alen(a):
- """
- Return the length of the first dimension of the input array.
-
- .. deprecated:: 1.18
- `numpy.alen` is deprecated, use `len` instead.
-
- Parameters
- ----------
- a : array_like
- Input array.
-
- Returns
- -------
- alen : int
- Length of the first dimension of `a`.
-
- See Also
- --------
- shape, size
-
- Examples
- --------
- >>> a = np.zeros((7,4,5))
- >>> a.shape[0]
- 7
- >>> np.alen(a)
- 7
-
- """
- # NumPy 1.18.0, 2019-08-02
- warnings.warn(
- "`np.alen` is deprecated, use `len` instead",
- DeprecationWarning, stacklevel=2)
- try:
- return len(a)
- except TypeError:
- return len(array(a, ndmin=1))
-
-
def _prod_dispatcher(a, axis=None, dtype=None, out=None, keepdims=None,
initial=None, where=None):
return (a, out)
diff --git a/numpy/core/function_base.pyi b/numpy/core/function_base.pyi
index 68d3b3a98..6e0843a0e 100644
--- a/numpy/core/function_base.pyi
+++ b/numpy/core/function_base.pyi
@@ -1,55 +1,195 @@
-from typing import overload, Tuple, Union, Sequence, Any, SupportsIndex, Literal, List
+from typing import (
+ Literal as L,
+ overload,
+ Tuple,
+ Union,
+ Any,
+ SupportsIndex,
+ List,
+ Type,
+ TypeVar,
+)
-from numpy import ndarray
-from numpy.typing import ArrayLike, DTypeLike, _SupportsArray, _NumberLike_co
+from numpy import floating, complexfloating, generic, dtype
+from numpy.typing import (
+ NDArray,
+ ArrayLike,
+ DTypeLike,
+ _SupportsDType,
+ _SupportsArray,
+ _NumberLike_co,
+ _ArrayLikeFloat_co,
+ _ArrayLikeComplex_co,
+)
-# TODO: wait for support for recursive types
-_ArrayLikeNested = Sequence[Sequence[Any]]
-_ArrayLikeNumber = Union[
- _NumberLike_co, Sequence[_NumberLike_co], ndarray, _SupportsArray, _ArrayLikeNested
+_SCT = TypeVar("_SCT", bound=generic)
+
+_DTypeLike = Union[
+ dtype[_SCT],
+ Type[_SCT],
+ _SupportsDType[dtype[_SCT]],
]
__all__: List[str]
@overload
def linspace(
- start: _ArrayLikeNumber,
- stop: _ArrayLikeNumber,
+ start: _ArrayLikeFloat_co,
+ stop: _ArrayLikeFloat_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ retstep: L[False] = ...,
+ dtype: None = ...,
+ axis: SupportsIndex = ...,
+) -> NDArray[floating[Any]]: ...
+@overload
+def linspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ retstep: L[False] = ...,
+ dtype: None = ...,
+ axis: SupportsIndex = ...,
+) -> NDArray[complexfloating[Any, Any]]: ...
+@overload
+def linspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ retstep: L[False] = ...,
+ dtype: _DTypeLike[_SCT] = ...,
+ axis: SupportsIndex = ...,
+) -> NDArray[_SCT]: ...
+@overload
+def linspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
num: SupportsIndex = ...,
endpoint: bool = ...,
- retstep: Literal[False] = ...,
+ retstep: L[False] = ...,
dtype: DTypeLike = ...,
axis: SupportsIndex = ...,
-) -> ndarray: ...
+) -> NDArray[Any]: ...
@overload
def linspace(
- start: _ArrayLikeNumber,
- stop: _ArrayLikeNumber,
+ start: _ArrayLikeFloat_co,
+ stop: _ArrayLikeFloat_co,
num: SupportsIndex = ...,
endpoint: bool = ...,
- retstep: Literal[True] = ...,
+ retstep: L[True] = ...,
+ dtype: None = ...,
+ axis: SupportsIndex = ...,
+) -> Tuple[NDArray[floating[Any]], floating[Any]]: ...
+@overload
+def linspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ retstep: L[True] = ...,
+ dtype: None = ...,
+ axis: SupportsIndex = ...,
+) -> Tuple[NDArray[complexfloating[Any, Any]], complexfloating[Any, Any]]: ...
+@overload
+def linspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ retstep: L[True] = ...,
+ dtype: _DTypeLike[_SCT] = ...,
+ axis: SupportsIndex = ...,
+) -> Tuple[NDArray[_SCT], _SCT]: ...
+@overload
+def linspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ retstep: L[True] = ...,
dtype: DTypeLike = ...,
axis: SupportsIndex = ...,
-) -> Tuple[ndarray, Any]: ...
+) -> Tuple[NDArray[Any], Any]: ...
+@overload
def logspace(
- start: _ArrayLikeNumber,
- stop: _ArrayLikeNumber,
+ start: _ArrayLikeFloat_co,
+ stop: _ArrayLikeFloat_co,
num: SupportsIndex = ...,
endpoint: bool = ...,
- base: _ArrayLikeNumber = ...,
+ base: _ArrayLikeFloat_co = ...,
+ dtype: None = ...,
+ axis: SupportsIndex = ...,
+) -> NDArray[floating[Any]]: ...
+@overload
+def logspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ base: _ArrayLikeComplex_co = ...,
+ dtype: None = ...,
+ axis: SupportsIndex = ...,
+) -> NDArray[complexfloating[Any, Any]]: ...
+@overload
+def logspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ base: _ArrayLikeComplex_co = ...,
+ dtype: _DTypeLike[_SCT] = ...,
+ axis: SupportsIndex = ...,
+) -> NDArray[_SCT]: ...
+@overload
+def logspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ base: _ArrayLikeComplex_co = ...,
dtype: DTypeLike = ...,
axis: SupportsIndex = ...,
-) -> ndarray: ...
+) -> NDArray[Any]: ...
+@overload
+def geomspace(
+ start: _ArrayLikeFloat_co,
+ stop: _ArrayLikeFloat_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ dtype: None = ...,
+ axis: SupportsIndex = ...,
+) -> NDArray[floating[Any]]: ...
+@overload
+def geomspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ dtype: None = ...,
+ axis: SupportsIndex = ...,
+) -> NDArray[complexfloating[Any, Any]]: ...
+@overload
+def geomspace(
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
+ num: SupportsIndex = ...,
+ endpoint: bool = ...,
+ dtype: _DTypeLike[_SCT] = ...,
+ axis: SupportsIndex = ...,
+) -> NDArray[_SCT]: ...
+@overload
def geomspace(
- start: _ArrayLikeNumber,
- stop: _ArrayLikeNumber,
+ start: _ArrayLikeComplex_co,
+ stop: _ArrayLikeComplex_co,
num: SupportsIndex = ...,
endpoint: bool = ...,
dtype: DTypeLike = ...,
axis: SupportsIndex = ...,
-) -> ndarray: ...
+) -> NDArray[Any]: ...
# Re-exported to `np.lib.function_base`
def add_newdoc(
diff --git a/numpy/core/include/numpy/numpyconfig.h b/numpy/core/include/numpy/numpyconfig.h
index 1c3686769..b2e7c458e 100644
--- a/numpy/core/include/numpy/numpyconfig.h
+++ b/numpy/core/include/numpy/numpyconfig.h
@@ -23,12 +23,18 @@
#undef NPY_SIZEOF_LONGDOUBLE
#undef NPY_SIZEOF_COMPLEX_LONGDOUBLE
- #ifdef __x86_64
- #define NPY_SIZEOF_LONGDOUBLE 16
- #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 32
- #elif defined(__arm64__)
+ #if defined(__arm64__)
#define NPY_SIZEOF_LONGDOUBLE 8
#define NPY_SIZEOF_COMPLEX_LONGDOUBLE 16
+ #elif defined(__x86_64)
+ #define NPY_SIZEOF_LONGDOUBLE 16
+ #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 32
+ #elif defined (__i386)
+ #define NPY_SIZEOF_LONGDOUBLE 12
+ #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 24
+ #elif defined(__ppc__) || defined (__ppc64__)
+ #define NPY_SIZEOF_LONGDOUBLE 16
+ #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 32
#else
#error "unknown architecture"
#endif
@@ -56,6 +62,7 @@
#define NPY_1_19_API_VERSION 0x00000008
#define NPY_1_20_API_VERSION 0x0000000e
#define NPY_1_21_API_VERSION 0x0000000e
-#define NPY_1_22_API_VERSION 0x0000000e
+#define NPY_1_22_API_VERSION 0x0000000f
+#define NPY_1_23_API_VERSION 0x0000000f
#endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_NUMPYCONFIG_H_ */
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 344d40d93..014fa0a39 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -1829,6 +1829,14 @@ def fromfunction(function, shape, *, dtype=float, like=None, **kwargs):
Examples
--------
+ >>> np.fromfunction(lambda i, j: i, (2, 2), dtype=float)
+ array([[0., 0.],
+ [1., 1.]])
+
+ >>> np.fromfunction(lambda i, j: j, (2, 2), dtype=float)
+ array([[0., 1.],
+ [0., 1.]])
+
>>> np.fromfunction(lambda i, j: i == j, (3, 3), dtype=int)
array([[ True, False, False],
[False, True, False],
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index a5f423d8f..17fbd99af 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -1065,7 +1065,7 @@ def configuration(parent_package='',top_path=None):
#######################################################################
config.add_extension('_operand_flag_tests',
- sources=[join('src', 'umath', '_operand_flag_tests.c.src')])
+ sources=[join('src', 'umath', '_operand_flag_tests.c')])
#######################################################################
# SIMD module #
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
index 70e8fc897..772c87c96 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -44,6 +44,7 @@ C_ABI_VERSION = 0x01000009
# 0x0000000e - 1.20.x
# 0x0000000e - 1.21.x
# 0x0000000f - 1.22.x
+# 0x0000000f - 1.23.x
C_API_VERSION = 0x0000000f
class MismatchCAPIWarning(Warning):
diff --git a/numpy/core/src/_simd/_simd.dispatch.c.src b/numpy/core/src/_simd/_simd.dispatch.c.src
index 5c494ae7a..84de9a059 100644
--- a/numpy/core/src/_simd/_simd.dispatch.c.src
+++ b/numpy/core/src/_simd/_simd.dispatch.c.src
@@ -381,7 +381,7 @@ SIMD_IMPL_INTRIN_1(sumup_@sfx@, @esfx@, v@sfx@)
***************************/
#if @fp_only@
/**begin repeat1
- * #intrin = sqrt, recip, abs, square, ceil#
+ * #intrin = sqrt, recip, abs, square, ceil, trunc#
*/
SIMD_IMPL_INTRIN_1(@intrin@_@sfx@, v@sfx@, v@sfx@)
/**end repeat1**/
@@ -615,7 +615,7 @@ SIMD_INTRIN_DEF(sumup_@sfx@)
***************************/
#if @fp_only@
/**begin repeat1
- * #intrin = sqrt, recip, abs, square, ceil#
+ * #intrin = sqrt, recip, abs, square, ceil, trunc#
*/
SIMD_INTRIN_DEF(@intrin@_@sfx@)
/**end repeat1**/
diff --git a/numpy/core/src/common/simd/avx2/math.h b/numpy/core/src/common/simd/avx2/math.h
index b1f3915a6..ec15e50e1 100644
--- a/numpy/core/src/common/simd/avx2/math.h
+++ b/numpy/core/src/common/simd/avx2/math.h
@@ -109,4 +109,8 @@ NPY_FINLINE npyv_s64 npyv_min_s64(npyv_s64 a, npyv_s64 b)
#define npyv_ceil_f32 _mm256_ceil_ps
#define npyv_ceil_f64 _mm256_ceil_pd
+// trunc
+#define npyv_trunc_f32(A) _mm256_round_ps(A, _MM_FROUND_TO_ZERO)
+#define npyv_trunc_f64(A) _mm256_round_pd(A, _MM_FROUND_TO_ZERO)
+
#endif // _NPY_SIMD_AVX2_MATH_H
diff --git a/numpy/core/src/common/simd/avx512/math.h b/numpy/core/src/common/simd/avx512/math.h
index c4f8d3410..f30e50ad0 100644
--- a/numpy/core/src/common/simd/avx512/math.h
+++ b/numpy/core/src/common/simd/avx512/math.h
@@ -116,4 +116,8 @@ NPY_FINLINE npyv_f64 npyv_minp_f64(npyv_f64 a, npyv_f64 b)
#define npyv_ceil_f32(A) _mm512_roundscale_ps(A, _MM_FROUND_TO_POS_INF)
#define npyv_ceil_f64(A) _mm512_roundscale_pd(A, _MM_FROUND_TO_POS_INF)
+// trunc
+#define npyv_trunc_f32(A) _mm512_roundscale_ps(A, _MM_FROUND_TO_ZERO)
+#define npyv_trunc_f64(A) _mm512_roundscale_pd(A, _MM_FROUND_TO_ZERO)
+
#endif // _NPY_SIMD_AVX512_MATH_H
diff --git a/numpy/core/src/common/simd/neon/math.h b/numpy/core/src/common/simd/neon/math.h
index 38c3899e4..19e5cd846 100644
--- a/numpy/core/src/common/simd/neon/math.h
+++ b/numpy/core/src/common/simd/neon/math.h
@@ -190,4 +190,37 @@ NPY_FINLINE npyv_s64 npyv_min_s64(npyv_s64 a, npyv_s64 b)
#define npyv_ceil_f64 vrndpq_f64
#endif // NPY_SIMD_F64
+// trunc
+#ifdef NPY_HAVE_ASIMD
+ #define npyv_trunc_f32 vrndq_f32
+#else
+ NPY_FINLINE npyv_f32 npyv_trunc_f32(npyv_f32 a)
+ {
+ const npyv_s32 szero = vreinterpretq_s32_f32(vdupq_n_f32(-0.0f));
+ const npyv_s32 max_int = vdupq_n_s32(0x7fffffff);
+ /**
+ * On armv7, vcvtq.f32 handles special cases as follows:
+ * NaN return 0
+ * +inf or +outrange return 0x80000000(-0.0f)
+ * -inf or -outrange return 0x7fffffff(nan)
+ */
+ npyv_s32 roundi = vcvtq_s32_f32(a);
+ npyv_f32 round = vcvtq_f32_s32(roundi);
+ // respect signed zero, e.g. -0.5 -> -0.0
+ npyv_f32 rzero = vreinterpretq_f32_s32(vorrq_s32(
+ vreinterpretq_s32_f32(round),
+ vandq_s32(vreinterpretq_s32_f32(a), szero)
+ ));
+ // if nan or overflow return a
+ npyv_u32 nnan = npyv_notnan_f32(a);
+ npyv_u32 overflow = vorrq_u32(
+ vceqq_s32(roundi, szero), vceqq_s32(roundi, max_int)
+ );
+ return vbslq_f32(vbicq_u32(nnan, overflow), rzero, a);
+ }
+#endif
+#if NPY_SIMD_F64
+ #define npyv_trunc_f64 vrndq_f64
+#endif // NPY_SIMD_F64
+
#endif // _NPY_SIMD_NEON_MATH_H
diff --git a/numpy/core/src/common/simd/sse/math.h b/numpy/core/src/common/simd/sse/math.h
index 02eb06a29..5daf7711e 100644
--- a/numpy/core/src/common/simd/sse/math.h
+++ b/numpy/core/src/common/simd/sse/math.h
@@ -174,4 +174,32 @@ NPY_FINLINE npyv_s64 npyv_min_s64(npyv_s64 a, npyv_s64 b)
}
#endif
+// trunc
+#ifdef NPY_HAVE_SSE41
+ #define npyv_trunc_f32(A) _mm_round_ps(A, _MM_FROUND_TO_ZERO)
+ #define npyv_trunc_f64(A) _mm_round_pd(A, _MM_FROUND_TO_ZERO)
+#else
+ NPY_FINLINE npyv_f32 npyv_trunc_f32(npyv_f32 a)
+ {
+ const npyv_f32 szero = _mm_set1_ps(-0.0f);
+ npyv_s32 roundi = _mm_cvttps_epi32(a);
+ npyv_f32 trunc = _mm_cvtepi32_ps(roundi);
+ // respect signed zero, e.g. -0.5 -> -0.0
+ npyv_f32 rzero = _mm_or_ps(trunc, _mm_and_ps(a, szero));
+ // if overflow return a
+ return npyv_select_f32(_mm_cmpeq_epi32(roundi, _mm_castps_si128(szero)), a, rzero);
+ }
+ NPY_FINLINE npyv_f64 npyv_trunc_f64(npyv_f64 a)
+ {
+ const npyv_f64 szero = _mm_set1_pd(-0.0);
+ const npyv_f64 one = _mm_set1_pd(1.0);
+ const npyv_f64 two_power_52 = _mm_set1_pd(0x10000000000000);
+ npyv_f64 abs_a = npyv_abs_f64(a);
+ // round by add magic number 2^52
+ npyv_f64 abs_round = _mm_sub_pd(_mm_add_pd(abs_a, two_power_52), two_power_52);
+ npyv_f64 subtrahend = _mm_and_pd(_mm_cmpgt_pd(abs_round, abs_a), one);
+ return _mm_or_pd(_mm_sub_pd(abs_round, subtrahend), _mm_and_pd(a, szero));
+ }
+#endif
+
#endif // _NPY_SIMD_SSE_MATH_H
diff --git a/numpy/core/src/common/simd/vsx/math.h b/numpy/core/src/common/simd/vsx/math.h
index f387dac4d..d138cae8a 100644
--- a/numpy/core/src/common/simd/vsx/math.h
+++ b/numpy/core/src/common/simd/vsx/math.h
@@ -73,4 +73,8 @@ NPY_FINLINE npyv_f64 npyv_square_f64(npyv_f64 a)
#define npyv_ceil_f32 vec_ceil
#define npyv_ceil_f64 vec_ceil
+// trunc
+#define npyv_trunc_f32 vec_trunc
+#define npyv_trunc_f64 vec_trunc
+
#endif // _NPY_SIMD_VSX_MATH_H
diff --git a/numpy/core/src/multiarray/alloc.c b/numpy/core/src/multiarray/alloc.c
index 0a694cf62..94a7daa83 100644
--- a/numpy/core/src/multiarray/alloc.c
+++ b/numpy/core/src/multiarray/alloc.c
@@ -186,6 +186,24 @@ npy_free_cache_dim(void * p, npy_uintp sz)
&PyArray_free);
}
+/* Similar to array_dealloc in arrayobject.c */
+static NPY_INLINE void
+WARN_NO_RETURN(PyObject* warning, const char * msg) {
+ if (PyErr_WarnEx(warning, msg, 1) < 0) {
+ PyObject * s;
+
+ s = PyUnicode_FromString("PyDataMem_UserFREE");
+ if (s) {
+ PyErr_WriteUnraisable(s);
+ Py_DECREF(s);
+ }
+ else {
+ PyErr_WriteUnraisable(Py_None);
+ }
+ }
+}
+
+
/* malloc/free/realloc hook */
NPY_NO_EXPORT PyDataMem_EventHookFunc *_PyDataMem_eventhook = NULL;
@@ -210,6 +228,8 @@ NPY_NO_EXPORT void *_PyDataMem_eventhook_user_data = NULL;
* operations that might cause new allocation events (such as the
* creation/destruction numpy objects, or creating/destroying Python
* objects which might cause a gc)
+ *
+ * Deprecated in 1.23
*/
NPY_NO_EXPORT PyDataMem_EventHookFunc *
PyDataMem_SetEventHook(PyDataMem_EventHookFunc *newhook,
@@ -218,6 +238,10 @@ PyDataMem_SetEventHook(PyDataMem_EventHookFunc *newhook,
PyDataMem_EventHookFunc *temp;
NPY_ALLOW_C_API_DEF
NPY_ALLOW_C_API
+ /* 2021-11-18, 1.23 */
+ WARN_NO_RETURN(PyExc_DeprecationWarning,
+ "PyDataMem_SetEventHook is deprecated, use tracemalloc "
+ "and the 'np.lib.tracemalloc_domain' domain");
temp = _PyDataMem_eventhook;
_PyDataMem_eventhook = newhook;
if (old_data != NULL) {
@@ -435,33 +459,14 @@ PyDataMem_UserNEW_ZEROED(size_t nmemb, size_t size, PyObject *mem_handler)
return result;
}
-/* Similar to array_dealloc in arrayobject.c */
-static NPY_INLINE void
-WARN_IN_FREE(PyObject* warning, const char * msg) {
- if (PyErr_WarnEx(warning, msg, 1) < 0) {
- PyObject * s;
-
- s = PyUnicode_FromString("PyDataMem_UserFREE");
- if (s) {
- PyErr_WriteUnraisable(s);
- Py_DECREF(s);
- }
- else {
- PyErr_WriteUnraisable(Py_None);
- }
- }
-}
-
-
NPY_NO_EXPORT void
PyDataMem_UserFREE(void *ptr, size_t size, PyObject *mem_handler)
{
PyDataMem_Handler *handler = (PyDataMem_Handler *) PyCapsule_GetPointer(mem_handler, "mem_handler");
if (handler == NULL) {
- WARN_IN_FREE(PyExc_RuntimeWarning,
+ WARN_NO_RETURN(PyExc_RuntimeWarning,
"Could not get pointer to 'mem_handler' from PyCapsule");
- PyErr_Clear();
return;
}
PyTraceMalloc_Untrack(NPY_TRACE_DOMAIN, (npy_uintp)ptr);
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
index 627096b3c..b0b6f42f1 100644
--- a/numpy/core/src/multiarray/methods.c
+++ b/numpy/core/src/multiarray/methods.c
@@ -2246,7 +2246,7 @@ array_dumps(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
-array_sizeof(PyArrayObject *self)
+array_sizeof(PyArrayObject *self, PyObject *NPY_UNUSED(args))
{
/* object + dimension and strides */
Py_ssize_t nbytes = Py_TYPE(self)->tp_basicsize +
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index dbf5ab161..cf0160a2b 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -4212,7 +4212,7 @@ normalize_axis_index(PyObject *NPY_UNUSED(self),
static PyObject *
-_reload_guard(PyObject *NPY_UNUSED(self)) {
+_reload_guard(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args)) {
static int initialized = 0;
#if !defined(PYPY_VERSION)
diff --git a/numpy/core/src/multiarray/nditer_pywrap.c b/numpy/core/src/multiarray/nditer_pywrap.c
index 8e072d5f4..2675496ab 100644
--- a/numpy/core/src/multiarray/nditer_pywrap.c
+++ b/numpy/core/src/multiarray/nditer_pywrap.c
@@ -1190,7 +1190,7 @@ npyiter_resetbasepointers(NewNpyArrayIterObject *self)
}
static PyObject *
-npyiter_reset(NewNpyArrayIterObject *self)
+npyiter_reset(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
{
if (self->iter == NULL) {
PyErr_SetString(PyExc_ValueError,
@@ -1227,7 +1227,7 @@ npyiter_reset(NewNpyArrayIterObject *self)
* copied.
*/
static PyObject *
-npyiter_copy(NewNpyArrayIterObject *self)
+npyiter_copy(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
{
NewNpyArrayIterObject *iter;
@@ -1263,7 +1263,7 @@ npyiter_copy(NewNpyArrayIterObject *self)
}
static PyObject *
-npyiter_iternext(NewNpyArrayIterObject *self)
+npyiter_iternext(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
{
if (self->iter != NULL && self->iternext != NULL &&
!self->finished && self->iternext(self->iter)) {
@@ -1320,7 +1320,8 @@ npyiter_remove_axis(NewNpyArrayIterObject *self, PyObject *args)
}
static PyObject *
-npyiter_remove_multi_index(NewNpyArrayIterObject *self)
+npyiter_remove_multi_index(
+ NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
{
if (self->iter == NULL) {
PyErr_SetString(PyExc_ValueError,
@@ -1345,7 +1346,8 @@ npyiter_remove_multi_index(NewNpyArrayIterObject *self)
}
static PyObject *
-npyiter_enable_external_loop(NewNpyArrayIterObject *self)
+npyiter_enable_external_loop(
+ NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
{
if (self->iter == NULL) {
PyErr_SetString(PyExc_ValueError,
@@ -1370,7 +1372,7 @@ npyiter_enable_external_loop(NewNpyArrayIterObject *self)
}
static PyObject *
-npyiter_debug_print(NewNpyArrayIterObject *self)
+npyiter_debug_print(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
{
if (self->iter != NULL) {
NpyIter_DebugPrint(self->iter);
@@ -2315,7 +2317,7 @@ npyiter_ass_subscript(NewNpyArrayIterObject *self, PyObject *op,
}
static PyObject *
-npyiter_enter(NewNpyArrayIterObject *self)
+npyiter_enter(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
{
if (self->iter == NULL) {
PyErr_SetString(PyExc_RuntimeError, "operation on non-initialized iterator");
@@ -2326,7 +2328,7 @@ npyiter_enter(NewNpyArrayIterObject *self)
}
static PyObject *
-npyiter_close(NewNpyArrayIterObject *self)
+npyiter_close(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
{
NpyIter *iter = self->iter;
int ret;
@@ -2347,7 +2349,7 @@ static PyObject *
npyiter_exit(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
{
/* even if called via exception handling, writeback any data */
- return npyiter_close(self);
+ return npyiter_close(self, NULL);
}
static PyMethodDef npyiter_methods[] = {
diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src
index bbbc5bfa2..db1e49db8 100644
--- a/numpy/core/src/multiarray/scalartypes.c.src
+++ b/numpy/core/src/multiarray/scalartypes.c.src
@@ -229,7 +229,7 @@ gentype_multiply(PyObject *m1, PyObject *m2)
* #convert = Long*8, LongLong*2#
*/
static PyObject *
-@type@_bit_count(PyObject *self)
+@type@_bit_count(PyObject *self, PyObject *NPY_UNUSED(args))
{
@type@ scalar = PyArrayScalar_VAL(self, @Name@);
uint8_t count = npy_popcount@c@(scalar);
@@ -1160,7 +1160,7 @@ gentype_size_get(PyObject *NPY_UNUSED(self), void *NPY_UNUSED(ignored))
}
static PyObject *
-gentype_sizeof(PyObject *self)
+gentype_sizeof(PyObject *self, PyObject *NPY_UNUSED(args))
{
Py_ssize_t nbytes;
PyObject * isz = gentype_itemsize_get(self, NULL);
@@ -1918,7 +1918,7 @@ static PyObject *
*/
/* Heavily copied from the builtin float.as_integer_ratio */
static PyObject *
-@name@_as_integer_ratio(PyObject *self)
+@name@_as_integer_ratio(PyObject *self, PyObject *NPY_UNUSED(args))
{
#if @is_half@
npy_double val = npy_half_to_double(PyArrayScalar_VAL(self, @Name@));
@@ -1999,7 +1999,7 @@ error:
* #c = f, f, , l#
*/
static PyObject *
-@name@_is_integer(PyObject *self)
+@name@_is_integer(PyObject *self, PyObject *NPY_UNUSED(args))
{
#if @is_half@
npy_double val = npy_half_to_double(PyArrayScalar_VAL(self, @Name@));
@@ -2022,7 +2022,7 @@ static PyObject *
/**end repeat**/
static PyObject *
-integer_is_integer(PyObject *self) {
+integer_is_integer(PyObject *self, PyObject *NPY_UNUSED(args)) {
Py_RETURN_TRUE;
}
diff --git a/numpy/core/src/umath/_operand_flag_tests.c.src b/numpy/core/src/umath/_operand_flag_tests.c
index c59e13baf..c59e13baf 100644
--- a/numpy/core/src/umath/_operand_flag_tests.c.src
+++ b/numpy/core/src/umath/_operand_flag_tests.c
diff --git a/numpy/core/src/umath/loops_exponent_log.dispatch.c.src b/numpy/core/src/umath/loops_exponent_log.dispatch.c.src
index 95cce553a..2dd43fb85 100644
--- a/numpy/core/src/umath/loops_exponent_log.dispatch.c.src
+++ b/numpy/core/src/umath/loops_exponent_log.dispatch.c.src
@@ -386,7 +386,7 @@ avx512_permute_x8var_pd(__m512d t0, __m512d t1, __m512d t2, __m512d t3,
* #and_masks =_mm256_and_ps, _mm512_kand#
* #xor_masks =_mm256_xor_ps, _mm512_kxor#
* #fmadd = _mm256_fmadd_ps, _mm512_fmadd_ps#
- * #mask_to_int = _mm256_movemask_ps, #
+ * #mask_to_int = _mm256_movemask_ps, npyv_tobits_b32#
* #full_mask= 0xFF, 0xFFFF#
* #masked_store = _mm256_maskstore_ps, _mm512_mask_storeu_ps#
* #cvtps_epi32 = _mm256_cvtps_epi32, #
@@ -833,11 +833,19 @@ AVX512F_exp_DOUBLE(npy_double * op,
op += num_lanes;
num_remaining_elements -= num_lanes;
}
- if (overflow_mask) {
+ /*
+ * Don't count on the compiler for cast between mask and int registers.
+ * On gcc7 with flags -march>=nocona -O3 can cause FP stack overflow
+ * which may lead to putting NaN into certain HW/FP calculations.
+ *
+ * For more details, please check the comments in:
+ * - https://github.com/numpy/numpy/issues/20356
+ */
+ if (npyv_tobits_b64(overflow_mask)) {
npy_set_floatstatus_overflow();
}
- if (underflow_mask) {
+ if (npyv_tobits_b64(underflow_mask)) {
npy_set_floatstatus_underflow();
}
}
@@ -1062,10 +1070,10 @@ AVX512F_log_DOUBLE(npy_double * op,
num_remaining_elements -= num_lanes;
}
- if (invalid_mask) {
+ if (npyv_tobits_b64(invalid_mask)) {
npy_set_floatstatus_invalid();
}
- if (divide_by_zero_mask) {
+ if (npyv_tobits_b64(divide_by_zero_mask)) {
npy_set_floatstatus_divbyzero();
}
}
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index a1b379d92..a269eb519 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -13,7 +13,8 @@ import sys
import numpy as np
from numpy.testing import (
- assert_raises, assert_warns, assert_, assert_array_equal, SkipTest, KnownFailureException
+ assert_raises, assert_warns, assert_, assert_array_equal, SkipTest,
+ KnownFailureException, break_cycles,
)
from numpy.core._multiarray_tests import fromstring_null_term_c_api
@@ -426,11 +427,6 @@ class TestBincount(_DeprecationTestCase):
self.assert_deprecated(lambda: np.bincount([1, 2, 3], minlength=None))
-class TestAlen(_DeprecationTestCase):
- # 2019-08-02, 1.18.0
- def test_alen(self):
- self.assert_deprecated(lambda: np.alen(np.array([1, 2, 3])))
-
class TestGeneratorSum(_DeprecationTestCase):
# 2018-02-25, 1.15.0
@@ -1230,3 +1226,42 @@ class TestMachAr(_DeprecationTestCase):
def test_deprecated_attr(self):
finfo = np.finfo(float)
self.assert_deprecated(lambda: getattr(finfo, "machar"))
+
+
+class TestQuantileInterpolationDeprecation(_DeprecationTestCase):
+ # Deprecated 2021-11-08, NumPy 1.22
+ @pytest.mark.parametrize("func",
+ [np.percentile, np.quantile, np.nanpercentile, np.nanquantile])
+ def test_deprecated(self, func):
+ self.assert_deprecated(
+ lambda: func([0., 1.], 0., interpolation="linear"))
+ self.assert_deprecated(
+ lambda: func([0., 1.], 0., interpolation="nearest"))
+
+ @pytest.mark.parametrize("func",
+ [np.percentile, np.quantile, np.nanpercentile, np.nanquantile])
+ def test_both_passed(self, func):
+ with warnings.catch_warnings():
+ # catch the DeprecationWarning so that it does not raise:
+ warnings.simplefilter("always", DeprecationWarning)
+ with pytest.raises(TypeError):
+ func([0., 1.], 0., interpolation="nearest", method="nearest")
+
+
+class TestMemEventHook(_DeprecationTestCase):
+ # Deprecated 2021-11-18, NumPy 1.23
+ def test_mem_seteventhook(self):
+ # The actual tests are within the C code in
+ # multiarray/_multiarray_tests.c.src
+ import numpy.core._multiarray_tests as ma_tests
+ with pytest.warns(DeprecationWarning,
+ match='PyDataMem_SetEventHook is deprecated'):
+ ma_tests.test_pydatamem_seteventhook_start()
+ # force an allocation and free of a numpy array
+ # needs to be larger then limit of small memory cacher in ctors.c
+ a = np.zeros(1000)
+ del a
+ break_cycles()
+ with pytest.warns(DeprecationWarning,
+ match='PyDataMem_SetEventHook is deprecated'):
+ ma_tests.test_pydatamem_seteventhook_end()
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 4413cd0d0..9d728afa4 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -6888,26 +6888,6 @@ class TestInner:
assert_equal(np.inner(b, a).transpose(2,3,0,1), desired)
-class TestAlen:
- def test_basic(self):
- with pytest.warns(DeprecationWarning):
- m = np.array([1, 2, 3])
- assert_equal(np.alen(m), 3)
-
- m = np.array([[1, 2, 3], [4, 5, 7]])
- assert_equal(np.alen(m), 2)
-
- m = [1, 2, 3]
- assert_equal(np.alen(m), 3)
-
- m = [[1, 2, 3], [4, 5, 7]]
- assert_equal(np.alen(m), 2)
-
- def test_singleton(self):
- with pytest.warns(DeprecationWarning):
- assert_equal(np.alen(5), 1)
-
-
class TestChoose:
def setup(self):
self.x = 2*np.ones((3,), dtype=int)
@@ -7832,9 +7812,9 @@ class TestArrayCreationCopyArgument(object):
pyscalar = arr.item(0)
# Test never-copy raises error:
- assert_raises(ValueError, np.array, scalar,
+ assert_raises(ValueError, np.array, scalar,
copy=np._CopyMode.NEVER)
- assert_raises(ValueError, np.array, pyscalar,
+ assert_raises(ValueError, np.array, pyscalar,
copy=np._CopyMode.NEVER)
assert_raises(ValueError, np.array, pyscalar,
copy=self.RaiseOnBool())
@@ -8187,18 +8167,6 @@ def test_scalar_element_deletion():
assert_raises(ValueError, a[0].__delitem__, 'x')
-class TestMemEventHook:
- def test_mem_seteventhook(self):
- # The actual tests are within the C code in
- # multiarray/_multiarray_tests.c.src
- _multiarray_tests.test_pydatamem_seteventhook_start()
- # force an allocation and free of a numpy array
- # needs to be larger then limit of small memory cacher in ctors.c
- a = np.zeros(1000)
- del a
- break_cycles()
- _multiarray_tests.test_pydatamem_seteventhook_end()
-
class TestMapIter:
def test_mapiter(self):
# The actual tests are within the C code in
diff --git a/numpy/core/tests/test_simd.py b/numpy/core/tests/test_simd.py
index 379fef8af..12a67c44d 100644
--- a/numpy/core/tests/test_simd.py
+++ b/numpy/core/tests/test_simd.py
@@ -330,12 +330,15 @@ class _SIMD_FP(_Test_Utility):
square = self.square(vdata)
assert square == data_square
- @pytest.mark.parametrize("intrin, func", [("self.ceil", math.ceil)])
+ @pytest.mark.parametrize("intrin, func", [("self.ceil", math.ceil),
+ ("self.trunc", math.trunc)])
def test_rounding(self, intrin, func):
"""
Test intrinsics:
npyv_ceil_##SFX
+ npyv_trunc_##SFX
"""
+ intrin_name = intrin
intrin = eval(intrin)
pinf, ninf, nan = self._pinfinity(), self._ninfinity(), self._nan()
# special cases
@@ -352,11 +355,12 @@ class _SIMD_FP(_Test_Utility):
_round = intrin(vdata)
assert _round == data_round
# signed zero
- for w in (-0.25, -0.30, -0.45):
- _round = self._to_unsigned(intrin(self.setall(w)))
- data_round = self._to_unsigned(self.setall(-0.0))
- assert _round == data_round
-
+ if "ceil" in intrin_name or "trunc" in intrin_name:
+ for w in (-0.25, -0.30, -0.45):
+ _round = self._to_unsigned(intrin(self.setall(w)))
+ data_round = self._to_unsigned(self.setall(-0.0))
+ assert _round == data_round
+
def test_max(self):
"""
Test intrinsics:
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 8f5a85824..c0b26e75b 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -28,9 +28,7 @@ def get_glibc_version():
glibcver = get_glibc_version()
-glibc_newerthan_2_17 = pytest.mark.xfail(
- glibcver != '0.0' and glibcver < '2.17',
- reason="Older glibc versions may not raise appropriate FP exceptions")
+glibc_older_than = lambda x: (glibcver != '0.0' and glibcver < x)
def on_powerpc():
""" True if we are running on a Power PC platform."""
@@ -50,14 +48,6 @@ def bad_arcsinh():
# The eps for float128 is 1-e33, so this is way bigger
return abs((v1 / v2) - 1.0) > 1e-23
-if platform.machine() == 'aarch64' and bad_arcsinh():
- skip_longcomplex_msg = ('Trig functions of np.longcomplex values known to be '
- 'inaccurate on aarch64 for some compilation '
- 'configurations, should be fixed by building on a '
- 'platform using glibc>2.17')
-else:
- skip_longcomplex_msg = ''
-
class _FilterInvalids:
def setup(self):
@@ -1022,9 +1012,11 @@ class TestSpecialFloats:
yf = np.array(y, dtype=dt)
assert_equal(np.exp(yf), xf)
- # Older version of glibc may not raise the correct FP exceptions
# See: https://github.com/numpy/numpy/issues/19192
- @glibc_newerthan_2_17
+ @pytest.mark.xfail(
+ glibc_older_than("2.17"),
+ reason="Older glibc versions may not raise appropriate FP exceptions"
+ )
def test_exp_exceptions(self):
with np.errstate(over='raise'):
assert_raises(FloatingPointError, np.exp, np.float32(100.))
@@ -1405,8 +1397,10 @@ class TestAVXFloat32Transcendental:
M = np.int_(N/20)
index = np.random.randint(low=0, high=N, size=M)
x_f32 = np.float32(np.random.uniform(low=-100.,high=100.,size=N))
- # test coverage for elements > 117435.992f for which glibc is used
- x_f32[index] = np.float32(10E+10*np.random.rand(M))
+ if not glibc_older_than("2.17"):
+ # test coverage for elements > 117435.992f for which glibc is used
+ # this is known to be problematic on old glibc, so skip it there
+ x_f32[index] = np.float32(10E+10*np.random.rand(M))
x_f64 = np.float64(x_f32)
assert_array_max_ulp(np.sin(x_f32), np.float32(np.sin(x_f64)), maxulp=2)
assert_array_max_ulp(np.cos(x_f32), np.float32(np.cos(x_f64)), maxulp=2)
@@ -3440,12 +3434,13 @@ class TestComplexFunctions:
x_basic = np.logspace(-2.999, 0, 10, endpoint=False)
if dtype is np.longcomplex:
+ if (platform.machine() == 'aarch64' and bad_arcsinh()):
+ pytest.skip("Trig functions of np.longcomplex values known "
+ "to be inaccurate on aarch64 for some compilation "
+ "configurations.")
# It's not guaranteed that the system-provided arc functions
# are accurate down to a few epsilons. (Eg. on Linux 64-bit)
# So, give more leeway for long complex tests here:
- # Can use 2.1 for > Ubuntu LTS Trusty (2014), glibc = 2.19.
- if skip_longcomplex_msg:
- pytest.skip(skip_longcomplex_msg)
check(x_series, 50.0*eps)
else:
check(x_series, 2.1*eps)
diff --git a/numpy/distutils/ccompiler_opt.py b/numpy/distutils/ccompiler_opt.py
index 39847c20f..b38e47c13 100644
--- a/numpy/distutils/ccompiler_opt.py
+++ b/numpy/distutils/ccompiler_opt.py
@@ -654,9 +654,9 @@ class _Distutils:
@staticmethod
def dist_load_module(name, path):
"""Load a module from file, required by the abstract class '_Cache'."""
- from numpy.compat import npy_load_module
+ from .misc_util import exec_mod_from_location
try:
- return npy_load_module(name, path)
+ return exec_mod_from_location(name, path)
except Exception as e:
_Distutils.dist_log(e, stderr=True)
return None
diff --git a/numpy/distutils/checks/cpu_asimdfhm.c b/numpy/distutils/checks/cpu_asimdfhm.c
index bb437aa40..cb49751c4 100644
--- a/numpy/distutils/checks/cpu_asimdfhm.c
+++ b/numpy/distutils/checks/cpu_asimdfhm.c
@@ -10,8 +10,8 @@ int main(void)
float32x4_t vf = vdupq_n_f32(1.0f);
float32x2_t vlf = vdup_n_f32(1.0f);
- int ret = (int)vget_lane_f32(vfmlal_low_u32(vlf, vlhp, vlhp), 0);
- ret += (int)vgetq_lane_f32(vfmlslq_high_u32(vf, vhp, vhp), 0);
+ int ret = (int)vget_lane_f32(vfmlal_low_f16(vlf, vlhp, vlhp), 0);
+ ret += (int)vgetq_lane_f32(vfmlslq_high_f16(vf, vhp, vhp), 0);
return ret;
}
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
index f0f9b4bd7..513be75db 100644
--- a/numpy/distutils/misc_util.py
+++ b/numpy/distutils/misc_util.py
@@ -31,8 +31,6 @@ def clean_up_temporary_directory():
atexit.register(clean_up_temporary_directory)
-from numpy.compat import npy_load_module
-
__all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',
'dict_append', 'appendpath', 'generate_config_py',
'get_cmd', 'allpath', 'get_mathlibs',
@@ -44,7 +42,8 @@ __all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',
'dot_join', 'get_frame', 'minrelpath', 'njoin',
'is_sequence', 'is_string', 'as_list', 'gpaths', 'get_language',
'get_build_architecture', 'get_info', 'get_pkg_info',
- 'get_num_build_jobs', 'sanitize_cxx_flags']
+ 'get_num_build_jobs', 'sanitize_cxx_flags',
+ 'exec_mod_from_location']
class InstallableLib:
"""
@@ -945,9 +944,8 @@ class Configuration:
try:
setup_name = os.path.splitext(os.path.basename(setup_py))[0]
n = dot_join(self.name, subpackage_name, setup_name)
- setup_module = npy_load_module('_'.join(n.split('.')),
- setup_py,
- ('.py', 'U', 1))
+ setup_module = exec_mod_from_location(
+ '_'.join(n.split('.')), setup_py)
if not hasattr(setup_module, 'configuration'):
if not self.options['assume_default_configuration']:
self.warn('Assuming default configuration '\
@@ -1993,8 +1991,8 @@ class Configuration:
name = os.path.splitext(os.path.basename(fn))[0]
n = dot_join(self.name, name)
try:
- version_module = npy_load_module('_'.join(n.split('.')),
- fn, info)
+ version_module = exec_mod_from_location(
+ '_'.join(n.split('.')), fn)
except ImportError as e:
self.warn(str(e))
version_module = None
@@ -2481,7 +2479,7 @@ def get_build_architecture():
return get_build_architecture()
-_cxx_ignore_flags = {'-Werror=implicit-function-declaration'}
+_cxx_ignore_flags = {'-Werror=implicit-function-declaration', '-std=c99'}
def sanitize_cxx_flags(cxxflags):
@@ -2491,3 +2489,14 @@ def sanitize_cxx_flags(cxxflags):
return [flag for flag in cxxflags if flag not in _cxx_ignore_flags]
+def exec_mod_from_location(modname, modfile):
+ '''
+ Use importlib machinery to import a module `modname` from the file
+ `modfile`. Depending on the `spec.loader`, the module may not be
+ registered in sys.modules.
+ '''
+ spec = importlib.util.spec_from_file_location(modname, modfile)
+ foo = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(foo)
+ return foo
+
diff --git a/numpy/f2py/__init__.py b/numpy/f2py/__init__.py
index a0fb73619..b1cb74fae 100644
--- a/numpy/f2py/__init__.py
+++ b/numpy/f2py/__init__.py
@@ -71,7 +71,7 @@ def compile(source,
Examples
--------
- .. literalinclude:: code/results/compile_session.dat
+ .. literalinclude:: ../../source/f2py/code/results/compile_session.dat
:language: python
"""
@@ -145,7 +145,7 @@ def get_include():
Notes
-----
- .. versionadded:: 1.22.0
+ .. versionadded:: 1.21.1
Unless the build system you are using has specific support for f2py,
building a Python extension using a ``.pyf`` signature file is a two-step
diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py
index 655cfd768..581f946e5 100644
--- a/numpy/f2py/capi_maps.py
+++ b/numpy/f2py/capi_maps.py
@@ -442,7 +442,7 @@ def getpydocsign(a, var):
sigout = sig
else:
errmess(
- 'getpydocsign: Could not resolve docsignature for "%s".\\n' % a)
+ 'getpydocsign: Could not resolve docsignature for "%s".\n' % a)
return sig, sigout
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py
index 1d9236dcd..528c4adee 100644
--- a/numpy/f2py/cfuncs.py
+++ b/numpy/f2py/cfuncs.py
@@ -845,20 +845,26 @@ int_from_pyobj(int* v, PyObject *obj, const char *errmess)
return !(*v == -1 && PyErr_Occurred());
}
- if (PyComplex_Check(obj))
+ if (PyComplex_Check(obj)) {
+ PyErr_Clear();
tmp = PyObject_GetAttrString(obj,\"real\");
- else if (PyBytes_Check(obj) || PyUnicode_Check(obj))
+ }
+ else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {
/*pass*/;
- else if (PySequence_Check(obj))
+ }
+ else if (PySequence_Check(obj)) {
+ PyErr_Clear();
tmp = PySequence_GetItem(obj, 0);
+ }
+
if (tmp) {
- PyErr_Clear();
if (int_from_pyobj(v, tmp, errmess)) {
Py_DECREF(tmp);
return 1;
}
Py_DECREF(tmp);
}
+
{
PyObject* err = PyErr_Occurred();
if (err == NULL) {
@@ -888,15 +894,19 @@ long_from_pyobj(long* v, PyObject *obj, const char *errmess) {
return !(*v == -1 && PyErr_Occurred());
}
- if (PyComplex_Check(obj))
+ if (PyComplex_Check(obj)) {
+ PyErr_Clear();
tmp = PyObject_GetAttrString(obj,\"real\");
- else if (PyBytes_Check(obj) || PyUnicode_Check(obj))
+ }
+ else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {
/*pass*/;
- else if (PySequence_Check(obj))
- tmp = PySequence_GetItem(obj,0);
+ }
+ else if (PySequence_Check(obj)) {
+ PyErr_Clear();
+ tmp = PySequence_GetItem(obj, 0);
+ }
if (tmp) {
- PyErr_Clear();
if (long_from_pyobj(v, tmp, errmess)) {
Py_DECREF(tmp);
return 1;
@@ -934,14 +944,19 @@ long_long_from_pyobj(long_long* v, PyObject *obj, const char *errmess)
return !(*v == -1 && PyErr_Occurred());
}
- if (PyComplex_Check(obj))
+ if (PyComplex_Check(obj)) {
+ PyErr_Clear();
tmp = PyObject_GetAttrString(obj,\"real\");
- else if (PyBytes_Check(obj) || PyUnicode_Check(obj))
+ }
+ else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {
/*pass*/;
- else if (PySequence_Check(obj))
- tmp = PySequence_GetItem(obj,0);
- if (tmp) {
+ }
+ else if (PySequence_Check(obj)) {
PyErr_Clear();
+ tmp = PySequence_GetItem(obj, 0);
+ }
+
+ if (tmp) {
if (long_long_from_pyobj(v, tmp, errmess)) {
Py_DECREF(tmp);
return 1;
@@ -1001,14 +1016,20 @@ double_from_pyobj(double* v, PyObject *obj, const char *errmess)
Py_DECREF(tmp);
return !(*v == -1.0 && PyErr_Occurred());
}
- if (PyComplex_Check(obj))
+
+ if (PyComplex_Check(obj)) {
+ PyErr_Clear();
tmp = PyObject_GetAttrString(obj,\"real\");
- else if (PyBytes_Check(obj) || PyUnicode_Check(obj))
+ }
+ else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {
/*pass*/;
- else if (PySequence_Check(obj))
- tmp = PySequence_GetItem(obj,0);
- if (tmp) {
+ }
+ else if (PySequence_Check(obj)) {
PyErr_Clear();
+ tmp = PySequence_GetItem(obj, 0);
+ }
+
+ if (tmp) {
if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}
Py_DECREF(tmp);
}
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py
index 67675af45..b02eb68b7 100755
--- a/numpy/f2py/crackfortran.py
+++ b/numpy/f2py/crackfortran.py
@@ -1170,10 +1170,10 @@ def analyzeline(m, case, line):
groupcache[groupcounter]['args'].append(k)
else:
errmess(
- 'analyzeline: intent(callback) %s is ignored' % (k))
+ 'analyzeline: intent(callback) %s is ignored\n' % (k))
else:
errmess('analyzeline: intent(callback) %s is already'
- ' in argument list' % (k))
+ ' in argument list\n' % (k))
if case in ['optional', 'required', 'public', 'external', 'private', 'intrinsic']:
ap = case
if 'attrspec' in edecl[k]:
@@ -1868,11 +1868,11 @@ def get_useparameters(block, param_map=None):
continue
# XXX: apply mapping
if mapping:
- errmess('get_useparameters: mapping for %s not impl.' % (mapping))
+ errmess('get_useparameters: mapping for %s not impl.\n' % (mapping))
for k, v in list(params.items()):
if k in param_map:
outmess('get_useparameters: overriding parameter %s with'
- ' value from module %s' % (repr(k), repr(usename)))
+ ' value from module %s\n' % (repr(k), repr(usename)))
param_map[k] = v
return param_map
@@ -2385,7 +2385,7 @@ def get_parameters(vars, global_params={}):
elif iscomplex(vars[n]):
outmess(f'get_parameters[TODO]: '
- f'implement evaluation of complex expression {v}')
+ f'implement evaluation of complex expression {v}\n')
try:
params[n] = eval(v, g_params, params)
@@ -2633,7 +2633,7 @@ def analyzevars(block):
vars[n]['intent'].append('c')
else:
errmess(
- "analyzevars: charselector=%r unhandled." % (d))
+ "analyzevars: charselector=%r unhandled.\n" % (d))
if 'check' not in vars[n] and 'args' in block and n in block['args']:
# n is an argument that has no checks defined. Here we
diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py
index 605495574..4d79c304a 100755
--- a/numpy/f2py/f2py2e.py
+++ b/numpy/f2py/f2py2e.py
@@ -286,7 +286,7 @@ def scaninputline(inputline):
sys.exit()
if not os.path.isdir(buildpath):
if not verbose:
- outmess('Creating build directory %s' % (buildpath))
+ outmess('Creating build directory %s\n' % (buildpath))
os.mkdir(buildpath)
if signsfile:
signsfile = os.path.join(buildpath, signsfile)
@@ -416,7 +416,7 @@ def run_main(comline_list):
Examples
--------
- .. literalinclude:: code/results/run_main_session.dat
+ .. literalinclude:: ../../source/f2py/code/results/run_main_session.dat
:language: python
"""
diff --git a/numpy/f2py/tests/test_string.py b/numpy/f2py/tests/test_string.py
index 7b27f8786..3a945ff8b 100644
--- a/numpy/f2py/tests/test_string.py
+++ b/numpy/f2py/tests/test_string.py
@@ -34,19 +34,10 @@ C FILE: STRING.F
CHARACTER*(*) C,D
Cf2py intent(in) a,c
Cf2py intent(inout) b,d
- PRINT*, "A=",A
- PRINT*, "B=",B
- PRINT*, "C=",C
- PRINT*, "D=",D
- PRINT*, "CHANGE A,B,C,D"
A(1:1) = 'A'
B(1:1) = 'B'
C(1:1) = 'C'
D(1:1) = 'D'
- PRINT*, "A=",A
- PRINT*, "B=",B
- PRINT*, "C=",C
- PRINT*, "D=",D
END
C END OF FILE STRING.F
"""
@@ -60,7 +51,7 @@ C END OF FILE STRING.F
self.module.foo(a, b, c, d)
assert a.tobytes() == b'123\0\0'
- assert b.tobytes() == b'B23\0\0', (b.tobytes(),)
+ assert b.tobytes() == b'B23\0\0'
assert c.tobytes() == b'123'
assert d.tobytes() == b'D23'
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 3c9983edf..a215f63d3 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -50,8 +50,8 @@ __all__ = [
'quantile'
]
-# _QuantileInterpolation is a dictionary listing all the supported
-# interpolation methods to compute quantile/percentile.
+# _QuantileMethods is a dictionary listing all the supported methods to
+# compute quantile/percentile.
#
# Below virtual_index refer to the index of the element where the percentile
# would be found in the sorted sample.
@@ -61,13 +61,13 @@ __all__ = [
# is made of a integer part (a.k.a 'i' or 'left') and a fractional part
# (a.k.a 'g' or 'gamma')
#
-# Each _QuantileInterpolation have two properties
+# Each method in _QuantileMethods has two properties
# get_virtual_index : Callable
# The function used to compute the virtual_index.
# fix_gamma : Callable
# A function used for discret methods to force the index to a specific value.
-_QuantileInterpolation = dict(
- # --- HYNDMAN AND FAN METHODS
+_QuantileMethods = dict(
+ # --- HYNDMAN and FAN METHODS
# Discrete methods
inverted_cdf=dict(
get_virtual_index=lambda n, quantiles: _inverted_cdf(n, quantiles),
@@ -3854,7 +3854,7 @@ def _median(a, axis=None, out=None, overwrite_input=False):
def _percentile_dispatcher(a, q, axis=None, out=None, overwrite_input=None,
- interpolation=None, keepdims=None):
+ method=None, keepdims=None, *, interpolation=None):
return (a, q, out)
@@ -3864,8 +3864,10 @@ def percentile(a,
axis=None,
out=None,
overwrite_input=False,
- interpolation="linear",
- keepdims=False):
+ method="linear",
+ keepdims=False,
+ *,
+ interpolation=None):
"""
Compute the q-th percentile of the data along the specified axis.
@@ -3893,31 +3895,33 @@ def percentile(a,
If True, then allow the input array `a` to be modified by intermediate
calculations, to save memory. In this case, the contents of the input
`a` after this function completes is undefined.
- interpolation : str, optional
- This parameter specifies the interpolation method to
- use when the desired percentile lies between two data points
- There are many different methods, some unique to NumPy. See the
- notes for explanation. Options
-
- * (NPY 1): 'lower'
- * (NPY 2): 'higher',
- * (NPY 3): 'midpoint'
- * (NPY 4): 'nearest'
- * (NPY 5): 'linear'
-
- New options:
-
- * (H&F 1): 'inverted_cdf'
- * (H&F 2): 'averaged_inverted_cdf'
- * (H&F 3): 'closest_observation'
- * (H&F 4): 'interpolated_inverted_cdf'
- * (H&F 5): 'hazen'
- * (H&F 6): 'weibull'
- * (H&F 7): 'linear' (default)
- * (H&F 8): 'median_unbiased'
- * (H&F 9): 'normal_unbiased'
+ method : str, optional
+ This parameter specifies the method to use for estimating the
+ percentile. There are many different methods, some unique to NumPy.
+ See the notes for explanation. The options sorted by their R type
+ as summarized in the H&F paper [1]_ are:
+
+ 1. 'inverted_cdf'
+ 2. 'averaged_inverted_cdf'
+ 3. 'closest_observation'
+ 4. 'interpolated_inverted_cdf'
+ 5. 'hazen'
+ 6. 'weibull'
+ 7. 'linear' (default)
+ 8. 'median_unbiased'
+ 9. 'normal_unbiased'
+
+ The first three methods are discontiuous. NumPy further defines the
+ following discontinuous variations of the default 'linear' (7.) option:
+
+ * 'lower'
+ * 'higher',
+ * 'midpoint'
+ * 'nearest'
.. versionchanged:: 1.22.0
+ This argument was previously called "interpolation" and only
+ offered the "linear" default and last four options.
keepdims : bool, optional
If this is set to True, the axes which are reduced are left in
@@ -3926,6 +3930,11 @@ def percentile(a,
.. versionadded:: 1.9.0
+ interpolation : str, optional
+ Deprecated name for the method keyword argument.
+
+ .. deprecated:: 1.22.0
+
Returns
-------
percentile : scalar or ndarray
@@ -3950,16 +3959,16 @@ def percentile(a,
Given a vector ``V`` of length ``N``, the q-th percentile of ``V`` is
the value ``q/100`` of the way from the minimum to the maximum in a
sorted copy of ``V``. The values and distances of the two nearest
- neighbors as well as the `interpolation` parameter will determine the
+ neighbors as well as the `method` parameter will determine the
percentile if the normalized ranking does not match the location of
``q`` exactly. This function is the same as the median if ``q=50``, the
same as the minimum if ``q=0`` and the same as the maximum if
``q=100``.
- This optional `interpolation` parameter specifies the interpolation
- method to use when the desired quantile lies between two data points
- ``i < j``. If ``g`` is the fractional part of the index surrounded by
- ``i`` and alpha and beta are correction constants modifying i and j.
+ This optional `method` parameter specifies the method to use when the
+ desired quantile lies between two data points ``i < j``.
+ If ``g`` is the fractional part of the index surrounded by ``i`` and
+ alpha and beta are correction constants modifying i and j.
Below, 'q' is the quantile value, 'n' is the sample size and
alpha and beta are constants.
@@ -3970,7 +3979,7 @@ def percentile(a,
.. math::
i + g = (q - alpha) / ( n - alpha - beta + 1 )
- The different interpolation methods then work as follows
+ The different methods then work as follows
inverted_cdf:
method 1 of H&F [1]_.
@@ -4075,7 +4084,7 @@ def percentile(a,
array([7., 2.])
>>> assert not np.all(a == b)
- The different types of interpolation can be visualized graphically:
+ The different methods can be visualized graphically:
.. plot::
@@ -4085,20 +4094,25 @@ def percentile(a,
p = np.linspace(0, 100, 6001)
ax = plt.gca()
lines = [
- ('linear', None),
- ('higher', '--'),
- ('lower', '--'),
- ('nearest', '-.'),
- ('midpoint', '-.'),
- ]
- for interpolation, style in lines:
+ ('linear', '-', 'C0'),
+ ('inverted_cdf', ':', 'C1'),
+ # Almost the same as `inverted_cdf`:
+ ('averaged_inverted_cdf', '-.', 'C1'),
+ ('closest_observation', ':', 'C2'),
+ ('interpolated_inverted_cdf', '--', 'C1'),
+ ('hazen', '--', 'C3'),
+ ('weibull', '-.', 'C4'),
+ ('median_unbiased', '--', 'C5'),
+ ('normal_unbiased', '-.', 'C6'),
+ ]
+ for method, style, color in lines:
ax.plot(
- p, np.percentile(a, p, interpolation=interpolation),
- label=interpolation, linestyle=style)
+ p, np.percentile(a, p, method=method),
+ label=method, linestyle=style, color=color)
ax.set(
- title='Interpolation methods for list: ' + str(a),
+ title='Percentiles for different methods and data: ' + str(a),
xlabel='Percentile',
- ylabel='List item returned',
+ ylabel='Estimated percentile value',
yticks=a)
ax.legend()
plt.show()
@@ -4110,16 +4124,19 @@ def percentile(a,
The American Statistician, 50(4), pp. 361-365, 1996
"""
+ if interpolation is not None:
+ method = _check_interpolation_as_method(
+ method, interpolation, "percentile")
q = np.true_divide(q, 100)
q = asanyarray(q) # undo any decay that the ufunc performed (see gh-13105)
if not _quantile_is_valid(q):
raise ValueError("Percentiles must be in the range [0, 100]")
return _quantile_unchecked(
- a, q, axis, out, overwrite_input, interpolation, keepdims)
+ a, q, axis, out, overwrite_input, method, keepdims)
def _quantile_dispatcher(a, q, axis=None, out=None, overwrite_input=None,
- interpolation=None, keepdims=None):
+ method=None, keepdims=None, *, interpolation=None):
return (a, q, out)
@@ -4129,8 +4146,10 @@ def quantile(a,
axis=None,
out=None,
overwrite_input=False,
- interpolation="linear",
- keepdims=False):
+ method="linear",
+ keepdims=False,
+ *,
+ interpolation=None):
"""
Compute the q-th quantile of the data along the specified axis.
@@ -4155,37 +4174,44 @@ def quantile(a,
intermediate calculations, to save memory. In this case, the
contents of the input `a` after this function completes is
undefined.
- interpolation : str, optional
- This parameter specifies the interpolation method to use when the
- desired quantile lies between two data points There are many
- different methods, some unique to NumPy. See the notes for
- explanation. Options:
-
- * (NPY 1): 'lower'
- * (NPY 2): 'higher',
- * (NPY 3): 'midpoint'
- * (NPY 4): 'nearest'
- * (NPY 5): 'linear'
-
- New options:
-
- * (H&F 1): 'inverted_cdf'
- * (H&F 2): 'averaged_inverted_cdf'
- * (H&F 3): 'closest_observation'
- * (H&F 4): 'interpolated_inverted_cdf'
- * (H&F 5): 'hazen'
- * (H&F 6): 'weibull'
- * (H&F 7): 'linear' (default)
- * (H&F 8): 'median_unbiased'
- * (H&F 9): 'normal_unbiased'
-
- .. versionadded:: 1.22.0
+ method : str, optional
+ This parameter specifies the method to use for estimating the
+ quantile. There are many different methods, some unique to NumPy.
+ See the notes for explanation. The options sorted by their R type
+ as summarized in the H&F paper [1]_ are:
+
+ 1. 'inverted_cdf'
+ 2. 'averaged_inverted_cdf'
+ 3. 'closest_observation'
+ 4. 'interpolated_inverted_cdf'
+ 5. 'hazen'
+ 6. 'weibull'
+ 7. 'linear' (default)
+ 8. 'median_unbiased'
+ 9. 'normal_unbiased'
+
+ The first three methods are discontiuous. NumPy further defines the
+ following discontinuous variations of the default 'linear' (7.) option:
+
+ * 'lower'
+ * 'higher',
+ * 'midpoint'
+ * 'nearest'
+
+ .. versionchanged:: 1.22.0
+ This argument was previously called "interpolation" and only
+ offered the "linear" default and last four options.
keepdims : bool, optional
If this is set to True, the axes which are reduced are left in
the result as dimensions with size one. With this option, the
result will broadcast correctly against the original array `a`.
+ interpolation : str, optional
+ Deprecated name for the method keyword argument.
+
+ .. deprecated:: 1.22.0
+
Returns
-------
quantile : scalar or ndarray
@@ -4210,20 +4236,20 @@ def quantile(a,
Given a vector ``V`` of length ``N``, the q-th quantile of ``V`` is the
value ``q`` of the way from the minimum to the maximum in a sorted copy of
``V``. The values and distances of the two nearest neighbors as well as the
- `interpolation` parameter will determine the quantile if the normalized
+ `method` parameter will determine the quantile if the normalized
ranking does not match the location of ``q`` exactly. This function is the
same as the median if ``q=0.5``, the same as the minimum if ``q=0.0`` and
the same as the maximum if ``q=1.0``.
- This optional `interpolation` parameter specifies the interpolation method
- to use when the desired quantile lies between two data points ``i < j``. If
- ``g`` is the fractional part of the index surrounded by ``i`` and alpha
- and beta are correction constants modifying i and j.
+ This optional `method` parameter specifies the method to use when the
+ desired quantile lies between two data points ``i < j``.
+ If ``g`` is the fractional part of the index surrounded by ``i`` and
+ alpha and beta are correction constants modifying i and j.
.. math::
i + g = (q - alpha) / ( n - alpha - beta + 1 )
- The different interpolation methods then work as follows
+ The different methods then work as follows
inverted_cdf:
method 1 of H&F [1]_.
@@ -4326,6 +4352,8 @@ def quantile(a,
array([7., 2.])
>>> assert not np.all(a == b)
+ See also `numpy.percentile` for a visualization of most methods.
+
References
----------
.. [1] R. J. Hyndman and Y. Fan,
@@ -4333,11 +4361,15 @@ def quantile(a,
The American Statistician, 50(4), pp. 361-365, 1996
"""
+ if interpolation is not None:
+ method = _check_interpolation_as_method(
+ method, interpolation, "quantile")
+
q = np.asanyarray(q)
if not _quantile_is_valid(q):
raise ValueError("Quantiles must be in the range [0, 1]")
return _quantile_unchecked(
- a, q, axis, out, overwrite_input, interpolation, keepdims)
+ a, q, axis, out, overwrite_input, method, keepdims)
def _quantile_unchecked(a,
@@ -4345,7 +4377,7 @@ def _quantile_unchecked(a,
axis=None,
out=None,
overwrite_input=False,
- interpolation="linear",
+ method="linear",
keepdims=False):
"""Assumes that q is in [0, 1], and is an ndarray"""
r, k = _ureduce(a,
@@ -4354,7 +4386,7 @@ def _quantile_unchecked(a,
axis=axis,
out=out,
overwrite_input=overwrite_input,
- interpolation=interpolation)
+ method=method)
if keepdims:
return r.reshape(q.shape + k)
else:
@@ -4373,6 +4405,23 @@ def _quantile_is_valid(q):
return True
+def _check_interpolation_as_method(method, interpolation, fname):
+ # Deprecated NumPy 1.22, 2021-11-08
+ warnings.warn(
+ f"the `interpolation=` argument to {fname} was renamed to "
+ "`method=`, which has additional options.\n"
+ "Users of the modes 'nearest', 'lower', 'higher', or "
+ "'midpoint' are encouraged to review the method they. "
+ "(Deprecated NumPy 1.22)",
+ DeprecationWarning, stacklevel=4)
+ if method != "linear":
+ # sanity check, we assume this basically never happens
+ raise TypeError(
+ "You shall not pass both `method` and `interpolation`!\n"
+ "(`interpolation` is Deprecated in favor of `method`)")
+ return interpolation
+
+
def _compute_virtual_index(n, quantiles, alpha: float, beta: float):
"""
Compute the floating point indexes of an array for the linear
@@ -4398,9 +4447,7 @@ def _compute_virtual_index(n, quantiles, alpha: float, beta: float):
) - 1
-def _get_gamma(virtual_indexes,
- previous_indexes,
- interpolation: _QuantileInterpolation):
+def _get_gamma(virtual_indexes, previous_indexes, method):
"""
Compute gamma (a.k.a 'm' or 'weight') for the linear interpolation
of quantiles.
@@ -4410,7 +4457,7 @@ def _get_gamma(virtual_indexes,
sample.
previous_indexes : array_like
The floor values of virtual_indexes.
- interpolation : _QuantileInterpolation
+ interpolation : dict
The interpolation method chosen, which may have a specific rule
modifying gamma.
@@ -4418,7 +4465,7 @@ def _get_gamma(virtual_indexes,
by the interpolation method.
"""
gamma = np.asanyarray(virtual_indexes - previous_indexes)
- gamma = interpolation["fix_gamma"](gamma, virtual_indexes)
+ gamma = method["fix_gamma"](gamma, virtual_indexes)
return np.asanyarray(gamma)
@@ -4447,7 +4494,7 @@ def _lerp(a, b, t, out=None):
def _get_gamma_mask(shape, default_value, conditioned_value, where):
out = np.full(shape, default_value)
- out[where] = conditioned_value
+ np.copyto(out, conditioned_value, where=where, casting="unsafe")
return out
@@ -4455,11 +4502,14 @@ def _discret_interpolation_to_boundaries(index, gamma_condition_fun):
previous = np.floor(index)
next = previous + 1
gamma = index - previous
- return _get_gamma_mask(shape=index.shape,
- default_value=next,
- conditioned_value=previous,
- where=gamma_condition_fun(gamma, index)
- ).astype(np.intp)
+ res = _get_gamma_mask(shape=index.shape,
+ default_value=next,
+ conditioned_value=previous,
+ where=gamma_condition_fun(gamma, index)
+ ).astype(np.intp)
+ # Some methods can lead to out-of-bound integers, clip them:
+ res[res < 0] = 0
+ return res
def _closest_observation(n, quantiles):
@@ -4480,7 +4530,7 @@ def _quantile_ureduce_func(
axis: int = None,
out=None,
overwrite_input: bool = False,
- interpolation="linear",
+ method="linear",
) -> np.array:
if q.ndim > 2:
# The code below works fine for nd, but it might not have useful
@@ -4502,7 +4552,7 @@ def _quantile_ureduce_func(
result = _quantile(arr,
quantiles=q,
axis=axis,
- interpolation=interpolation,
+ method=method,
out=out)
return result
@@ -4546,7 +4596,7 @@ def _quantile(
arr: np.array,
quantiles: np.array,
axis: int = -1,
- interpolation="linear",
+ method="linear",
out=None,
):
"""
@@ -4556,8 +4606,8 @@ def _quantile(
It computes the quantiles of the array for the given axis.
A linear interpolation is performed based on the `interpolation`.
- By default, the interpolation is "linear" where
- alpha == beta == 1 which performs the 7th method of Hyndman&Fan.
+ By default, the method is "linear" where alpha == beta == 1 which
+ performs the 7th method of Hyndman&Fan.
With "median_unbiased" we get alpha == beta == 1/3
thus the 8th method of Hyndman&Fan.
"""
@@ -4574,13 +4624,12 @@ def _quantile(
# Virtual because it is a floating point value, not an valid index.
# The nearest neighbours are used for interpolation
try:
- interpolation = _QuantileInterpolation[interpolation]
+ method = _QuantileMethods[method]
except KeyError:
raise ValueError(
- f"{interpolation!r} is not a valid interpolation. Use one of: "
- f"{_QuantileInterpolation.keys()}") from None
- virtual_indexes = interpolation["get_virtual_index"](values_count,
- quantiles)
+ f"{method!r} is not a valid method. Use one of: "
+ f"{_QuantileMethods.keys()}") from None
+ virtual_indexes = method["get_virtual_index"](values_count, quantiles)
virtual_indexes = np.asanyarray(virtual_indexes)
if np.issubdtype(virtual_indexes.dtype, np.integer):
# No interpolation needed, take the points along axis
@@ -4614,9 +4663,7 @@ def _quantile(
previous = np.take(arr, previous_indexes, axis=DATA_AXIS)
next = np.take(arr, next_indexes, axis=DATA_AXIS)
# --- Linear interpolation
- gamma = _get_gamma(virtual_indexes,
- previous_indexes,
- interpolation)
+ gamma = _get_gamma(virtual_indexes, previous_indexes, method)
result_shape = virtual_indexes.shape + (1,) * (arr.ndim - 1)
gamma = gamma.reshape(result_shape)
result = _lerp(previous,
diff --git a/numpy/lib/function_base.pyi b/numpy/lib/function_base.pyi
index 82c625fed..7e227f9da 100644
--- a/numpy/lib/function_base.pyi
+++ b/numpy/lib/function_base.pyi
@@ -500,7 +500,7 @@ def median(
keepdims: bool = ...,
) -> _ArrayType: ...
-_InterpolationKind = L[
+_MethodKind = L[
"inverted_cdf",
"averaged_inverted_cdf",
"closest_observation",
@@ -523,7 +523,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> floating[Any]: ...
@overload
@@ -533,7 +533,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> complexfloating[Any, Any]: ...
@overload
@@ -543,7 +543,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> timedelta64: ...
@overload
@@ -553,7 +553,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> datetime64: ...
@overload
@@ -563,7 +563,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> Any: ...
@overload
@@ -573,7 +573,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> NDArray[floating[Any]]: ...
@overload
@@ -583,7 +583,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> NDArray[complexfloating[Any, Any]]: ...
@overload
@@ -593,7 +593,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> NDArray[timedelta64]: ...
@overload
@@ -603,7 +603,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> NDArray[datetime64]: ...
@overload
@@ -613,7 +613,7 @@ def percentile(
axis: None = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: L[False] = ...,
) -> NDArray[object_]: ...
@overload
@@ -623,7 +623,7 @@ def percentile(
axis: None | _ShapeLike = ...,
out: None = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: bool = ...,
) -> Any: ...
@overload
@@ -633,7 +633,7 @@ def percentile(
axis: None | _ShapeLike = ...,
out: _ArrayType = ...,
overwrite_input: bool = ...,
- interpolation: _InterpolationKind = ...,
+ method: _MethodKind = ...,
keepdims: bool = ...,
) -> _ArrayType: ...
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index 2a4402c89..b69226d48 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -227,13 +227,13 @@ class MGridClass(nd_grid):
See Also
--------
- numpy.lib.index_tricks.nd_grid : class of `ogrid` and `mgrid` objects
+ lib.index_tricks.nd_grid : class of `ogrid` and `mgrid` objects
ogrid : like mgrid but returns open (not fleshed out) mesh grids
r_ : array concatenator
Examples
--------
- >>> np.mgrid[0:5,0:5]
+ >>> np.mgrid[0:5, 0:5]
array([[[0, 0, 0, 0, 0],
[1, 1, 1, 1, 1],
[2, 2, 2, 2, 2],
diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py
index 7e953be03..d7ea1ca65 100644
--- a/numpy/lib/nanfunctions.py
+++ b/numpy/lib/nanfunctions.py
@@ -1223,8 +1223,9 @@ def nanmedian(a, axis=None, out=None, overwrite_input=False, keepdims=np._NoValu
return r
-def _nanpercentile_dispatcher(a, q, axis=None, out=None, overwrite_input=None,
- interpolation=None, keepdims=None):
+def _nanpercentile_dispatcher(
+ a, q, axis=None, out=None, overwrite_input=None,
+ method=None, keepdims=None, *, interpolation=None):
return (a, q, out)
@@ -1235,8 +1236,10 @@ def nanpercentile(
axis=None,
out=None,
overwrite_input=False,
- interpolation="linear",
+ method="linear",
keepdims=np._NoValue,
+ *,
+ interpolation=None,
):
"""
Compute the qth percentile of the data along the specified axis,
@@ -1267,31 +1270,33 @@ def nanpercentile(
intermediate calculations, to save memory. In this case, the
contents of the input `a` after this function completes is
undefined.
- interpolation : str, optional
- This parameter specifies the interpolation method to use when the
- desired percentile lies between two data points There are many
- different methods, some unique to NumPy. See the notes for
- explanation. Options:
-
- * (NPY 1): 'lower'
- * (NPY 2): 'higher',
- * (NPY 3): 'midpoint'
- * (NPY 4): 'nearest'
- * (NPY 5): 'linear' (default)
-
- New options:
-
- * (H&F 1): 'inverted_cdf'
- * (H&F 2): 'averaged_inverted_cdf'
- * (H&F 3): 'closest_observation'
- * (H&F 4): 'interpolated_inverted_cdf'
- * (H&F 5): 'hazen'
- * (H&F 6): 'weibull'
- * (H&F 7): 'linear' (default)
- * (H&F 8): 'median_unbiased'
- * (H&F 9): 'normal_unbiased'
+ method : str, optional
+ This parameter specifies the method to use for estimating the
+ percentile. There are many different methods, some unique to NumPy.
+ See the notes for explanation. The options sorted by their R type
+ as summarized in the H&F paper [1]_ are:
+
+ 1. 'inverted_cdf'
+ 2. 'averaged_inverted_cdf'
+ 3. 'closest_observation'
+ 4. 'interpolated_inverted_cdf'
+ 5. 'hazen'
+ 6. 'weibull'
+ 7. 'linear' (default)
+ 8. 'median_unbiased'
+ 9. 'normal_unbiased'
+
+ The first three methods are discontiuous. NumPy further defines the
+ following discontinuous variations of the default 'linear' (7.) option:
+
+ * 'lower'
+ * 'higher',
+ * 'midpoint'
+ * 'nearest'
- .. versionadded:: 1.22.0
+ .. versionchanged:: 1.22.0
+ This argument was previously called "interpolation" and only
+ offered the "linear" default and last four options.
keepdims : bool, optional
If this is set to True, the axes which are reduced are left in
@@ -1304,6 +1309,11 @@ def nanpercentile(
a sub-class and `mean` does not have the kwarg `keepdims` this
will raise a RuntimeError.
+ interpolation : str, optional
+ Deprecated name for the method keyword argument.
+
+ .. deprecated:: 1.22.0
+
Returns
-------
percentile : scalar or ndarray
@@ -1355,7 +1365,17 @@ def nanpercentile(
array([7., 2.])
>>> assert not np.all(a==b)
+ References
+ ----------
+ .. [1] R. J. Hyndman and Y. Fan,
+ "Sample quantiles in statistical packages,"
+ The American Statistician, 50(4), pp. 361-365, 1996
+
"""
+ if interpolation is not None:
+ method = function_base._check_interpolation_as_method(
+ method, interpolation, "nanpercentile")
+
a = np.asanyarray(a)
q = np.true_divide(q, 100.0)
# undo any decay that the ufunc performed (see gh-13105)
@@ -1363,11 +1383,11 @@ def nanpercentile(
if not function_base._quantile_is_valid(q):
raise ValueError("Percentiles must be in the range [0, 100]")
return _nanquantile_unchecked(
- a, q, axis, out, overwrite_input, interpolation, keepdims)
+ a, q, axis, out, overwrite_input, method, keepdims)
def _nanquantile_dispatcher(a, q, axis=None, out=None, overwrite_input=None,
- interpolation=None, keepdims=None):
+ method=None, keepdims=None, *, interpolation=None):
return (a, q, out)
@@ -1378,8 +1398,10 @@ def nanquantile(
axis=None,
out=None,
overwrite_input=False,
- interpolation="linear",
+ method="linear",
keepdims=np._NoValue,
+ *,
+ interpolation=None,
):
"""
Compute the qth quantile of the data along the specified axis,
@@ -1408,31 +1430,33 @@ def nanquantile(
If True, then allow the input array `a` to be modified by intermediate
calculations, to save memory. In this case, the contents of the input
`a` after this function completes is undefined.
- interpolation : str, optional
- This parameter specifies the interpolation method to
- use when the desired quantile lies between two data points
- There are many different methods, some unique to NumPy. See the
- notes for explanation. Options:
-
- * (NPY 1): 'lower'
- * (NPY 2): 'higher',
- * (NPY 3): 'midpoint'
- * (NPY 4): 'nearest'
- * (NPY 5): 'linear' (default)
-
- New options:
-
- * (H&F 1): 'inverted_cdf'
- * (H&F 2): 'averaged_inverted_cdf'
- * (H&F 3): 'closest_observation'
- * (H&F 4): 'interpolated_inverted_cdf'
- * (H&F 5): 'hazen'
- * (H&F 6): 'weibull'
- * (H&F 7): 'linear' (default)
- * (H&F 8): 'median_unbiased'
- * (H&F 9): 'normal_unbiased'
+ method : str, optional
+ This parameter specifies the method to use for estimating the
+ quantile. There are many different methods, some unique to NumPy.
+ See the notes for explanation. The options sorted by their R type
+ as summarized in the H&F paper [1]_ are:
+
+ 1. 'inverted_cdf'
+ 2. 'averaged_inverted_cdf'
+ 3. 'closest_observation'
+ 4. 'interpolated_inverted_cdf'
+ 5. 'hazen'
+ 6. 'weibull'
+ 7. 'linear' (default)
+ 8. 'median_unbiased'
+ 9. 'normal_unbiased'
+
+ The first three methods are discontiuous. NumPy further defines the
+ following discontinuous variations of the default 'linear' (7.) option:
+
+ * 'lower'
+ * 'higher',
+ * 'midpoint'
+ * 'nearest'
.. versionchanged:: 1.22.0
+ This argument was previously called "interpolation" and only
+ offered the "linear" default and last four options.
keepdims : bool, optional
If this is set to True, the axes which are reduced are left in
@@ -1445,6 +1469,11 @@ def nanquantile(
a sub-class and `mean` does not have the kwarg `keepdims` this
will raise a RuntimeError.
+ interpolation : str, optional
+ Deprecated name for the method keyword argument.
+
+ .. deprecated:: 1.22.0
+
Returns
-------
quantile : scalar or ndarray
@@ -1495,13 +1524,23 @@ def nanquantile(
array([7., 2.])
>>> assert not np.all(a==b)
+ References
+ ----------
+ .. [1] R. J. Hyndman and Y. Fan,
+ "Sample quantiles in statistical packages,"
+ The American Statistician, 50(4), pp. 361-365, 1996
+
"""
+ if interpolation is not None:
+ method = function_base._check_interpolation_as_method(
+ method, interpolation, "nanquantile")
+
a = np.asanyarray(a)
q = np.asanyarray(q)
if not function_base._quantile_is_valid(q):
raise ValueError("Quantiles must be in the range [0, 1]")
return _nanquantile_unchecked(
- a, q, axis, out, overwrite_input, interpolation, keepdims)
+ a, q, axis, out, overwrite_input, method, keepdims)
def _nanquantile_unchecked(
@@ -1510,7 +1549,7 @@ def _nanquantile_unchecked(
axis=None,
out=None,
overwrite_input=False,
- interpolation="linear",
+ method="linear",
keepdims=np._NoValue,
):
"""Assumes that q is in [0, 1], and is an ndarray"""
@@ -1524,7 +1563,7 @@ def _nanquantile_unchecked(
axis=axis,
out=out,
overwrite_input=overwrite_input,
- interpolation=interpolation)
+ method=method)
if keepdims and keepdims is not np._NoValue:
return r.reshape(q.shape + k)
else:
@@ -1532,7 +1571,7 @@ def _nanquantile_unchecked(
def _nanquantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False,
- interpolation="linear"):
+ method="linear"):
"""
Private function that doesn't support extended axis or keepdims.
These methods are extended to this function using _ureduce
@@ -1540,10 +1579,10 @@ def _nanquantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False,
"""
if axis is None or a.ndim == 1:
part = a.ravel()
- result = _nanquantile_1d(part, q, overwrite_input, interpolation)
+ result = _nanquantile_1d(part, q, overwrite_input, method)
else:
result = np.apply_along_axis(_nanquantile_1d, axis, a, q,
- overwrite_input, interpolation)
+ overwrite_input, method)
# apply_along_axis fills in collapsed axis with results.
# Move that axis to the beginning to match percentile's
# convention.
@@ -1555,7 +1594,7 @@ def _nanquantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False,
return result
-def _nanquantile_1d(arr1d, q, overwrite_input=False, interpolation="linear"):
+def _nanquantile_1d(arr1d, q, overwrite_input=False, method="linear"):
"""
Private function for rank 1 arrays. Compute quantile ignoring NaNs.
See nanpercentile for parameter usage
@@ -1567,7 +1606,7 @@ def _nanquantile_1d(arr1d, q, overwrite_input=False, interpolation="linear"):
return np.full(q.shape, np.nan, dtype=arr1d.dtype)[()]
return function_base._quantile_unchecked(
- arr1d, q, overwrite_input=overwrite_input, interpolation=interpolation)
+ arr1d, q, overwrite_input=overwrite_input, method=method)
def _nanvar_dispatcher(a, axis=None, dtype=None, out=None, ddof=None,
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 6c34e95fe..a839b892a 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -285,7 +285,8 @@ def load(file, mmap_mode=None, allow_pickle=False, fix_imports=True,
----------
file : file-like object, string, or pathlib.Path
The file to read. File-like objects must support the
- ``seek()`` and ``read()`` methods. Pickled files require that the
+ ``seek()`` and ``read()`` methods and must always
+ be opened in binary mode. Pickled files require that the
file-like object support the ``readline()`` method as well.
mmap_mode : {None, 'r+', 'r', 'w+', 'c'}, optional
If not None, then memory-map the file, using the given mode (see
@@ -1806,22 +1807,21 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
byte_converters = False
# Initialize the filehandle, the LineSplitter and the NameValidator
+ if isinstance(fname, os_PathLike):
+ fname = os_fspath(fname)
+ if isinstance(fname, str):
+ fid = np.lib._datasource.open(fname, 'rt', encoding=encoding)
+ fid_ctx = contextlib.closing(fid)
+ else:
+ fid = fname
+ fid_ctx = contextlib.nullcontext(fid)
try:
- if isinstance(fname, os_PathLike):
- fname = os_fspath(fname)
- if isinstance(fname, str):
- fid = np.lib._datasource.open(fname, 'rt', encoding=encoding)
- fid_ctx = contextlib.closing(fid)
- else:
- fid = fname
- fid_ctx = contextlib.nullcontext(fid)
fhd = iter(fid)
except TypeError as e:
raise TypeError(
- f"fname must be a string, filehandle, list of strings,\n"
- f"or generator. Got {type(fname)} instead."
+ "fname must be a string, a filehandle, a sequence of strings,\n"
+ f"or an iterator of strings. Got {type(fname)} instead."
) from e
-
with fid_ctx:
split_line = LineSplitter(delimiter=delimiter, comments=comments,
autostrip=autostrip, encoding=encoding)
diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py
index a491f612e..ee4fbcd74 100644
--- a/numpy/lib/recfunctions.py
+++ b/numpy/lib/recfunctions.py
@@ -784,7 +784,8 @@ def repack_fields(a, align=False, recurse=False):
This method removes any overlaps and reorders the fields in memory so they
have increasing byte offsets, and adds or removes padding bytes depending
- on the `align` option, which behaves like the `align` option to `np.dtype`.
+ on the `align` option, which behaves like the `align` option to
+ `numpy.dtype`.
If `align=False`, this method produces a "packed" memory layout in which
each field starts at the byte the previous field ended, and any padding
@@ -917,11 +918,12 @@ def structured_to_unstructured(arr, dtype=None, copy=False, casting='unsafe'):
dtype : dtype, optional
The dtype of the output unstructured array.
copy : bool, optional
- See copy argument to `ndarray.astype`. If true, always return a copy.
- If false, and `dtype` requirements are satisfied, a view is returned.
+ See copy argument to `numpy.ndarray.astype`. If true, always return a
+ copy. If false, and `dtype` requirements are satisfied, a view is
+ returned.
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
- See casting argument of `ndarray.astype`. Controls what kind of data
- casting may occur.
+ See casting argument of `numpy.ndarray.astype`. Controls what kind of
+ data casting may occur.
Returns
-------
@@ -1020,11 +1022,12 @@ def unstructured_to_structured(arr, dtype=None, names=None, align=False,
align : boolean, optional
Whether to create an aligned memory layout.
copy : bool, optional
- See copy argument to `ndarray.astype`. If true, always return a copy.
- If false, and `dtype` requirements are satisfied, a view is returned.
+ See copy argument to `numpy.ndarray.astype`. If true, always return a
+ copy. If false, and `dtype` requirements are satisfied, a view is
+ returned.
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
- See casting argument of `ndarray.astype`. Controls what kind of data
- casting may occur.
+ See casting argument of `numpy.ndarray.astype`. Controls what kind of
+ data casting may occur.
Returns
-------
diff --git a/numpy/lib/scimath.py b/numpy/lib/scimath.py
index 308f1328b..b7ef0d710 100644
--- a/numpy/lib/scimath.py
+++ b/numpy/lib/scimath.py
@@ -234,6 +234,15 @@ def sqrt(x):
>>> np.emath.sqrt([-1,4])
array([0.+1.j, 2.+0.j])
+ Different results are expected because:
+ floating point 0.0 and -0.0 are distinct.
+
+ For more control, explicitly use complex() as follows:
+
+ >>> np.emath.sqrt(complex(-4.0, 0.0))
+ 2j
+ >>> np.emath.sqrt(complex(-4.0, -0.0))
+ -2j
"""
x = _fix_real_lt_zero(x)
return nx.sqrt(x)
diff --git a/numpy/lib/scimath.pyi b/numpy/lib/scimath.pyi
index d0d4af41e..6f196497d 100644
--- a/numpy/lib/scimath.pyi
+++ b/numpy/lib/scimath.pyi
@@ -1,13 +1,94 @@
-from typing import List
+from typing import List, overload, Any
+
+from numpy import complexfloating
+
+from numpy.typing import (
+ NDArray,
+ _ArrayLikeFloat_co,
+ _ArrayLikeComplex_co,
+ _ComplexLike_co,
+ _FloatLike_co,
+)
__all__: List[str]
-def sqrt(x): ...
-def log(x): ...
-def log10(x): ...
-def logn(n, x): ...
-def log2(x): ...
-def power(x, p): ...
-def arccos(x): ...
-def arcsin(x): ...
-def arctanh(x): ...
+@overload
+def sqrt(x: _FloatLike_co) -> Any: ...
+@overload
+def sqrt(x: _ComplexLike_co) -> complexfloating[Any, Any]: ...
+@overload
+def sqrt(x: _ArrayLikeFloat_co) -> NDArray[Any]: ...
+@overload
+def sqrt(x: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
+
+@overload
+def log(x: _FloatLike_co) -> Any: ...
+@overload
+def log(x: _ComplexLike_co) -> complexfloating[Any, Any]: ...
+@overload
+def log(x: _ArrayLikeFloat_co) -> NDArray[Any]: ...
+@overload
+def log(x: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
+
+@overload
+def log10(x: _FloatLike_co) -> Any: ...
+@overload
+def log10(x: _ComplexLike_co) -> complexfloating[Any, Any]: ...
+@overload
+def log10(x: _ArrayLikeFloat_co) -> NDArray[Any]: ...
+@overload
+def log10(x: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
+
+@overload
+def log2(x: _FloatLike_co) -> Any: ...
+@overload
+def log2(x: _ComplexLike_co) -> complexfloating[Any, Any]: ...
+@overload
+def log2(x: _ArrayLikeFloat_co) -> NDArray[Any]: ...
+@overload
+def log2(x: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
+
+@overload
+def logn(n: _FloatLike_co, x: _FloatLike_co) -> Any: ...
+@overload
+def logn(n: _ComplexLike_co, x: _ComplexLike_co) -> complexfloating[Any, Any]: ...
+@overload
+def logn(n: _ArrayLikeFloat_co, x: _ArrayLikeFloat_co) -> NDArray[Any]: ...
+@overload
+def logn(n: _ArrayLikeComplex_co, x: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
+
+@overload
+def power(x: _FloatLike_co, p: _FloatLike_co) -> Any: ...
+@overload
+def power(x: _ComplexLike_co, p: _ComplexLike_co) -> complexfloating[Any, Any]: ...
+@overload
+def power(x: _ArrayLikeFloat_co, p: _ArrayLikeFloat_co) -> NDArray[Any]: ...
+@overload
+def power(x: _ArrayLikeComplex_co, p: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
+
+@overload
+def arccos(x: _FloatLike_co) -> Any: ...
+@overload
+def arccos(x: _ComplexLike_co) -> complexfloating[Any, Any]: ...
+@overload
+def arccos(x: _ArrayLikeFloat_co) -> NDArray[Any]: ...
+@overload
+def arccos(x: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
+
+@overload
+def arcsin(x: _FloatLike_co) -> Any: ...
+@overload
+def arcsin(x: _ComplexLike_co) -> complexfloating[Any, Any]: ...
+@overload
+def arcsin(x: _ArrayLikeFloat_co) -> NDArray[Any]: ...
+@overload
+def arcsin(x: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
+
+@overload
+def arctanh(x: _FloatLike_co) -> Any: ...
+@overload
+def arctanh(x: _ComplexLike_co) -> complexfloating[Any, Any]: ...
+@overload
+def arctanh(x: _ArrayLikeFloat_co) -> NDArray[Any]: ...
+@overload
+def arctanh(x: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
diff --git a/numpy/lib/shape_base.pyi b/numpy/lib/shape_base.pyi
index 8aa283d02..17016c999 100644
--- a/numpy/lib/shape_base.pyi
+++ b/numpy/lib/shape_base.pyi
@@ -18,7 +18,7 @@ from numpy.typing import (
NDArray,
_ShapeLike,
_FiniteNestedSequence,
- _SupportsDType,
+ _SupportsArray,
_ArrayLikeBool_co,
_ArrayLikeUInt_co,
_ArrayLikeInt_co,
@@ -31,7 +31,7 @@ from numpy.core.shape_base import vstack
_SCT = TypeVar("_SCT", bound=generic)
-_ArrayLike = _FiniteNestedSequence[_SupportsDType[dtype[_SCT]]]
+_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
# The signatures of `__array_wrap__` and `__array_prepare__` are the same;
# give them unique names for the sake of clarity
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 1c274afae..b67a31b18 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2867,7 +2867,7 @@ class TestPercentile:
assert_equal(np.percentile(x, 50), 1.75)
x[1] = np.nan
assert_equal(np.percentile(x, 0), np.nan)
- assert_equal(np.percentile(x, 0, interpolation='nearest'), np.nan)
+ assert_equal(np.percentile(x, 0, method='nearest'), np.nan)
def test_fraction(self):
x = [Fraction(i, 2) for i in range(8)]
@@ -2910,7 +2910,7 @@ class TestPercentile:
res = np.percentile(
arr,
40.0,
- interpolation="linear")
+ method="linear")
np.testing.assert_equal(res, np.NAN)
np.testing.assert_equal(res.dtype, arr.dtype)
@@ -2926,7 +2926,7 @@ class TestPercentile:
(np.dtype("O"), np.float64)]
@pytest.mark.parametrize(["input_dtype", "expected_dtype"], H_F_TYPE_CODES)
- @pytest.mark.parametrize(["interpolation", "expected"],
+ @pytest.mark.parametrize(["method", "expected"],
[("inverted_cdf", 20),
("averaged_inverted_cdf", 27.5),
("closest_observation", 20),
@@ -2938,16 +2938,16 @@ class TestPercentile:
("normal_unbiased", 27.125),
])
def test_linear_interpolation(self,
- interpolation,
+ method,
expected,
input_dtype,
expected_dtype):
arr = np.asarray([15.0, 20.0, 35.0, 40.0, 50.0], dtype=input_dtype)
- actual = np.percentile(arr, 40.0, interpolation=interpolation)
+ actual = np.percentile(arr, 40.0, method=method)
np.testing.assert_almost_equal(actual, expected, 14)
- if interpolation in ["inverted_cdf", "closest_observation"]:
+ if method in ["inverted_cdf", "closest_observation"]:
if input_dtype == "O":
np.testing.assert_equal(np.asarray(actual).dtype, np.float64)
else:
@@ -2962,27 +2962,27 @@ class TestPercentile:
@pytest.mark.parametrize("dtype", TYPE_CODES)
def test_lower_higher(self, dtype):
assert_equal(np.percentile(np.arange(10, dtype=dtype), 50,
- interpolation='lower'), 4)
+ method='lower'), 4)
assert_equal(np.percentile(np.arange(10, dtype=dtype), 50,
- interpolation='higher'), 5)
+ method='higher'), 5)
@pytest.mark.parametrize("dtype", TYPE_CODES)
def test_midpoint(self, dtype):
assert_equal(np.percentile(np.arange(10, dtype=dtype), 51,
- interpolation='midpoint'), 4.5)
+ method='midpoint'), 4.5)
assert_equal(np.percentile(np.arange(9, dtype=dtype) + 1, 50,
- interpolation='midpoint'), 5)
+ method='midpoint'), 5)
assert_equal(np.percentile(np.arange(11, dtype=dtype), 51,
- interpolation='midpoint'), 5.5)
+ method='midpoint'), 5.5)
assert_equal(np.percentile(np.arange(11, dtype=dtype), 50,
- interpolation='midpoint'), 5)
+ method='midpoint'), 5)
@pytest.mark.parametrize("dtype", TYPE_CODES)
def test_nearest(self, dtype):
assert_equal(np.percentile(np.arange(10, dtype=dtype), 51,
- interpolation='nearest'), 5)
+ method='nearest'), 5)
assert_equal(np.percentile(np.arange(10, dtype=dtype), 49,
- interpolation='nearest'), 4)
+ method='nearest'), 4)
def test_linear_interpolation_extrapolation(self):
arr = np.random.rand(5)
@@ -3019,19 +3019,19 @@ class TestPercentile:
assert_equal(
np.percentile(x, (25, 50, 75), axis=1).shape, (3, 3, 5, 6))
assert_equal(np.percentile(x, (25, 50),
- interpolation="higher").shape, (2,))
+ method="higher").shape, (2,))
assert_equal(np.percentile(x, (25, 50, 75),
- interpolation="higher").shape, (3,))
+ method="higher").shape, (3,))
assert_equal(np.percentile(x, (25, 50), axis=0,
- interpolation="higher").shape, (2, 4, 5, 6))
+ method="higher").shape, (2, 4, 5, 6))
assert_equal(np.percentile(x, (25, 50), axis=1,
- interpolation="higher").shape, (2, 3, 5, 6))
+ method="higher").shape, (2, 3, 5, 6))
assert_equal(np.percentile(x, (25, 50), axis=2,
- interpolation="higher").shape, (2, 3, 4, 6))
+ method="higher").shape, (2, 3, 4, 6))
assert_equal(np.percentile(x, (25, 50), axis=3,
- interpolation="higher").shape, (2, 3, 4, 5))
+ method="higher").shape, (2, 3, 4, 5))
assert_equal(np.percentile(x, (25, 50, 75), axis=1,
- interpolation="higher").shape, (3, 3, 5, 6))
+ method="higher").shape, (3, 3, 5, 6))
def test_scalar_q(self):
# test for no empty dimensions for compatibility with old percentile
@@ -3057,33 +3057,33 @@ class TestPercentile:
# test for no empty dimensions for compatibility with old percentile
x = np.arange(12).reshape(3, 4)
- assert_equal(np.percentile(x, 50, interpolation='lower'), 5.)
+ assert_equal(np.percentile(x, 50, method='lower'), 5.)
assert_(np.isscalar(np.percentile(x, 50)))
r0 = np.array([4., 5., 6., 7.])
- c0 = np.percentile(x, 50, interpolation='lower', axis=0)
+ c0 = np.percentile(x, 50, method='lower', axis=0)
assert_equal(c0, r0)
assert_equal(c0.shape, r0.shape)
r1 = np.array([1., 5., 9.])
- c1 = np.percentile(x, 50, interpolation='lower', axis=1)
+ c1 = np.percentile(x, 50, method='lower', axis=1)
assert_almost_equal(c1, r1)
assert_equal(c1.shape, r1.shape)
out = np.empty((), dtype=x.dtype)
- c = np.percentile(x, 50, interpolation='lower', out=out)
+ c = np.percentile(x, 50, method='lower', out=out)
assert_equal(c, 5)
assert_equal(out, 5)
out = np.empty(4, dtype=x.dtype)
- c = np.percentile(x, 50, interpolation='lower', axis=0, out=out)
+ c = np.percentile(x, 50, method='lower', axis=0, out=out)
assert_equal(c, r0)
assert_equal(out, r0)
out = np.empty(3, dtype=x.dtype)
- c = np.percentile(x, 50, interpolation='lower', axis=1, out=out)
+ c = np.percentile(x, 50, method='lower', axis=1, out=out)
assert_equal(c, r1)
assert_equal(out, r1)
def test_exception(self):
assert_raises(ValueError, np.percentile, [1, 2], 56,
- interpolation='foobar')
+ method='foobar')
assert_raises(ValueError, np.percentile, [1], 101)
assert_raises(ValueError, np.percentile, [1], -1)
assert_raises(ValueError, np.percentile, [1], list(range(50)) + [101])
@@ -3124,12 +3124,12 @@ class TestPercentile:
# q.dim > 1, int
r0 = np.array([[0, 1, 2, 3], [4, 5, 6, 7]])
out = np.empty((2, 4), dtype=x.dtype)
- c = np.percentile(x, (25, 50), interpolation='lower', axis=0, out=out)
+ c = np.percentile(x, (25, 50), method='lower', axis=0, out=out)
assert_equal(c, r0)
assert_equal(out, r0)
r1 = np.array([[0, 4, 8], [1, 5, 9]])
out = np.empty((2, 3), dtype=x.dtype)
- c = np.percentile(x, (25, 50), interpolation='lower', axis=1, out=out)
+ c = np.percentile(x, (25, 50), method='lower', axis=1, out=out)
assert_equal(c, r1)
assert_equal(out, r1)
@@ -3146,10 +3146,10 @@ class TestPercentile:
assert_array_equal(np.percentile(d, 50, axis=-4).shape, (1, 2, 1))
assert_array_equal(np.percentile(d, 50, axis=2,
- interpolation='midpoint').shape,
+ method='midpoint').shape,
(11, 1, 1))
assert_array_equal(np.percentile(d, 50, axis=-2,
- interpolation='midpoint').shape,
+ method='midpoint').shape,
(11, 1, 1))
assert_array_equal(np.array(np.percentile(d, [10, 50], axis=0)).shape,
@@ -3172,10 +3172,10 @@ class TestPercentile:
def test_no_p_overwrite(self):
p = np.linspace(0., 100., num=5)
- np.percentile(np.arange(100.), p, interpolation="midpoint")
+ np.percentile(np.arange(100.), p, method="midpoint")
assert_array_equal(p, np.linspace(0., 100., num=5))
p = np.linspace(0., 100., num=5).tolist()
- np.percentile(np.arange(100.), p, interpolation="midpoint")
+ np.percentile(np.arange(100.), p, method="midpoint")
assert_array_equal(p, np.linspace(0., 100., num=5).tolist())
def test_percentile_overwrite(self):
@@ -3253,14 +3253,14 @@ class TestPercentile:
o = np.zeros((4,))
d = np.ones((3, 4))
assert_equal(np.percentile(d, 0, 0, out=o), o)
- assert_equal(np.percentile(d, 0, 0, interpolation='nearest', out=o), o)
+ assert_equal(np.percentile(d, 0, 0, method='nearest', out=o), o)
o = np.zeros((3,))
assert_equal(np.percentile(d, 1, 1, out=o), o)
- assert_equal(np.percentile(d, 1, 1, interpolation='nearest', out=o), o)
+ assert_equal(np.percentile(d, 1, 1, method='nearest', out=o), o)
o = np.zeros(())
assert_equal(np.percentile(d, 2, out=o), o)
- assert_equal(np.percentile(d, 2, interpolation='nearest', out=o), o)
+ assert_equal(np.percentile(d, 2, method='nearest', out=o), o)
def test_out_nan(self):
with warnings.catch_warnings(record=True):
@@ -3270,15 +3270,15 @@ class TestPercentile:
d[2, 1] = np.nan
assert_equal(np.percentile(d, 0, 0, out=o), o)
assert_equal(
- np.percentile(d, 0, 0, interpolation='nearest', out=o), o)
+ np.percentile(d, 0, 0, method='nearest', out=o), o)
o = np.zeros((3,))
assert_equal(np.percentile(d, 1, 1, out=o), o)
assert_equal(
- np.percentile(d, 1, 1, interpolation='nearest', out=o), o)
+ np.percentile(d, 1, 1, method='nearest', out=o), o)
o = np.zeros(())
assert_equal(np.percentile(d, 1, out=o), o)
assert_equal(
- np.percentile(d, 1, interpolation='nearest', out=o), o)
+ np.percentile(d, 1, method='nearest', out=o), o)
def test_nan_behavior(self):
a = np.arange(24, dtype=float)
@@ -3333,13 +3333,13 @@ class TestPercentile:
b[:, 1] = np.nan
b[:, 2] = np.nan
assert_equal(np.percentile(a, [0.3, 0.6], (0, 2)), b)
- # axis02 not zerod with nearest interpolation
+ # axis02 not zerod with method='nearest'
b = np.percentile(np.arange(24, dtype=float).reshape(2, 3, 4),
- [0.3, 0.6], (0, 2), interpolation='nearest')
+ [0.3, 0.6], (0, 2), method='nearest')
b[:, 1] = np.nan
b[:, 2] = np.nan
assert_equal(np.percentile(
- a, [0.3, 0.6], (0, 2), interpolation='nearest'), b)
+ a, [0.3, 0.6], (0, 2), method='nearest'), b)
def test_nan_q(self):
# GH18830
@@ -3412,26 +3412,36 @@ class TestQuantile:
# this is worth retesting, because quantile does not make a copy
p0 = np.array([0, 0.75, 0.25, 0.5, 1.0])
p = p0.copy()
- np.quantile(np.arange(100.), p, interpolation="midpoint")
+ np.quantile(np.arange(100.), p, method="midpoint")
assert_array_equal(p, p0)
p0 = p0.tolist()
p = p.tolist()
- np.quantile(np.arange(100.), p, interpolation="midpoint")
+ np.quantile(np.arange(100.), p, method="midpoint")
assert_array_equal(p, p0)
@pytest.mark.parametrize("dtype", np.typecodes["AllInteger"])
def test_quantile_preserve_int_type(self, dtype):
res = np.quantile(np.array([1, 2], dtype=dtype), [0.5],
- interpolation="nearest")
+ method="nearest")
assert res.dtype == dtype
- def test_quantile_monotonic(self):
+ @pytest.mark.parametrize("method",
+ ['inverted_cdf', 'averaged_inverted_cdf', 'closest_observation',
+ 'interpolated_inverted_cdf', 'hazen', 'weibull', 'linear',
+ 'median_unbiased', 'normal_unbiased',
+ 'nearest', 'lower', 'higher', 'midpoint'])
+ def test_quantile_monotonic(self, method):
# GH 14685
# test that the return value of quantile is monotonic if p0 is ordered
- p0 = np.arange(0, 1, 0.01)
+ # Also tests that the boundary values are not mishandled.
+ p0 = np.linspace(0, 1, 101)
quantile = np.quantile(np.array([0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 1, 1, 9, 9, 9,
- 8, 8, 7]) * 0.1, p0)
+ 8, 8, 7]) * 0.1, p0, method=method)
+ assert_equal(np.sort(quantile), quantile)
+
+ # Also test one where the number of data points is clearly divisible:
+ quantile = np.quantile([0., 1., 2., 3.], p0, method=method)
assert_equal(np.sort(quantile), quantile)
@hypothesis.given(
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 5201b8e6e..c19660cf0 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -1425,6 +1425,10 @@ class TestFromTxt(LoadTxtBase):
('F', 25.0, 60.0)], dtype=descriptor)
assert_equal(test, control)
+ def test_bad_fname(self):
+ with pytest.raises(TypeError, match='fname must be a string,'):
+ np.genfromtxt(123)
+
def test_commented_header(self):
# Check that names can be retrieved even if the line is commented out.
data = TextIO("""
diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py
index 126dba495..733a077ea 100644
--- a/numpy/lib/tests/test_nanfunctions.py
+++ b/numpy/lib/tests/test_nanfunctions.py
@@ -1108,12 +1108,12 @@ class TestNanFunctions_Quantile:
# this is worth retesting, because quantile does not make a copy
p0 = np.array([0, 0.75, 0.25, 0.5, 1.0])
p = p0.copy()
- np.nanquantile(np.arange(100.), p, interpolation="midpoint")
+ np.nanquantile(np.arange(100.), p, method="midpoint")
assert_array_equal(p, p0)
p0 = p0.tolist()
p = p.tolist()
- np.nanquantile(np.arange(100.), p, interpolation="midpoint")
+ np.nanquantile(np.arange(100.), p, method="midpoint")
assert_array_equal(p, p0)
@pytest.mark.parametrize("axis", [None, 0, 1])
diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py
index 56afd83ce..94d525f51 100644
--- a/numpy/lib/type_check.py
+++ b/numpy/lib/type_check.py
@@ -6,7 +6,7 @@ import warnings
__all__ = ['iscomplexobj', 'isrealobj', 'imag', 'iscomplex',
'isreal', 'nan_to_num', 'real', 'real_if_close',
- 'typename', 'asfarray', 'mintypecode', 'asscalar',
+ 'typename', 'asfarray', 'mintypecode',
'common_type']
import numpy.core.numeric as _nx
@@ -276,22 +276,22 @@ def isreal(x):
>>> a = np.array([1+1j, 1+0j, 4.5, 3, 2, 2j], dtype=complex)
>>> np.isreal(a)
array([False, True, True, True, True, False])
-
+
The function does not work on string arrays.
>>> a = np.array([2j, "a"], dtype="U")
>>> np.isreal(a) # Warns about non-elementwise comparison
False
-
+
Returns True for all elements in input array of ``dtype=object`` even if
any of the elements is complex.
>>> a = np.array([1, "2", 3+4j], dtype=object)
>>> np.isreal(a)
array([ True, True, True])
-
+
isreal should not be used with object arrays
-
+
>>> a = np.array([1+2j, 2+1j], dtype=object)
>>> np.isreal(a)
array([ True, True])
@@ -405,14 +405,14 @@ def _nan_to_num_dispatcher(x, copy=None, nan=None, posinf=None, neginf=None):
def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):
"""
Replace NaN with zero and infinity with large finite numbers (default
- behaviour) or with the numbers defined by the user using the `nan`,
+ behaviour) or with the numbers defined by the user using the `nan`,
`posinf` and/or `neginf` keywords.
If `x` is inexact, NaN is replaced by zero or by the user defined value in
- `nan` keyword, infinity is replaced by the largest finite floating point
- values representable by ``x.dtype`` or by the user defined value in
- `posinf` keyword and -infinity is replaced by the most negative finite
- floating point values representable by ``x.dtype`` or by the user defined
+ `nan` keyword, infinity is replaced by the largest finite floating point
+ values representable by ``x.dtype`` or by the user defined value in
+ `posinf` keyword and -infinity is replaced by the most negative finite
+ floating point values representable by ``x.dtype`` or by the user defined
value in `neginf` keyword.
For complex dtypes, the above is applied to each of the real and
@@ -429,27 +429,27 @@ def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):
in-place (False). The in-place operation only occurs if
casting to an array does not require a copy.
Default is True.
-
+
.. versionadded:: 1.13
nan : int, float, optional
- Value to be used to fill NaN values. If no value is passed
+ Value to be used to fill NaN values. If no value is passed
then NaN values will be replaced with 0.0.
-
+
.. versionadded:: 1.17
posinf : int, float, optional
- Value to be used to fill positive infinity values. If no value is
+ Value to be used to fill positive infinity values. If no value is
passed then positive infinity values will be replaced with a very
large number.
-
+
.. versionadded:: 1.17
neginf : int, float, optional
- Value to be used to fill negative infinity values. If no value is
+ Value to be used to fill negative infinity values. If no value is
passed then negative infinity values will be replaced with a very
small (or negative) number.
-
+
.. versionadded:: 1.17
-
+
Returns
-------
@@ -483,7 +483,7 @@ def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):
array([ 1.79769313e+308, -1.79769313e+308, 0.00000000e+000, # may vary
-1.28000000e+002, 1.28000000e+002])
>>> np.nan_to_num(x, nan=-9999, posinf=33333333, neginf=33333333)
- array([ 3.3333333e+07, 3.3333333e+07, -9.9990000e+03,
+ array([ 3.3333333e+07, 3.3333333e+07, -9.9990000e+03,
-1.2800000e+02, 1.2800000e+02])
>>> y = np.array([complex(np.inf, np.nan), np.nan, complex(np.nan, np.inf)])
array([ 1.79769313e+308, -1.79769313e+308, 0.00000000e+000, # may vary
@@ -529,7 +529,7 @@ def _real_if_close_dispatcher(a, tol=None):
@array_function_dispatch(_real_if_close_dispatcher)
def real_if_close(a, tol=100):
"""
- If input is complex with all imaginary parts close to zero, return
+ If input is complex with all imaginary parts close to zero, return
real parts.
"Close to zero" is defined as `tol` * (machine epsilon of the type for
@@ -583,40 +583,6 @@ def real_if_close(a, tol=100):
return a
-def _asscalar_dispatcher(a):
- # 2018-10-10, 1.16
- warnings.warn('np.asscalar(a) is deprecated since NumPy v1.16, use '
- 'a.item() instead', DeprecationWarning, stacklevel=3)
- return (a,)
-
-
-@array_function_dispatch(_asscalar_dispatcher)
-def asscalar(a):
- """
- Convert an array of size 1 to its scalar equivalent.
-
- .. deprecated:: 1.16
-
- Deprecated, use `numpy.ndarray.item()` instead.
-
- Parameters
- ----------
- a : ndarray
- Input array of size 1.
-
- Returns
- -------
- out : scalar
- Scalar representation of `a`. The output data type is the same type
- returned by the input's `item` method.
-
- Examples
- --------
- >>> np.asscalar(np.array([24]))
- 24
- """
- return a.item()
-
#-----------------------------------------------------------------------------
_namefromtype = {'S1': 'character',
diff --git a/numpy/lib/type_check.pyi b/numpy/lib/type_check.pyi
index 0a55dbf21..510f36cd7 100644
--- a/numpy/lib/type_check.pyi
+++ b/numpy/lib/type_check.pyi
@@ -151,9 +151,6 @@ def real_if_close(
tol: float = ...,
) -> NDArray[Any]: ...
-# NOTE: deprecated
-# def asscalar(a): ...
-
@overload
def typename(char: L['S1']) -> L['character']: ...
@overload
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 1df2ab09b..c74ee127d 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -429,7 +429,7 @@ def _makenamedict(module='numpy'):
return thedict, dictlist
-def _info(obj, output=sys.stdout):
+def _info(obj, output=None):
"""Provide information about ndarray obj.
Parameters
@@ -455,6 +455,9 @@ def _info(obj, output=sys.stdout):
strides = obj.strides
endian = obj.dtype.byteorder
+ if output is None:
+ output = sys.stdout
+
print("class: ", nm, file=output)
print("shape: ", obj.shape, file=output)
print("strides: ", strides, file=output)
@@ -481,7 +484,7 @@ def _info(obj, output=sys.stdout):
@set_module('numpy')
-def info(object=None, maxwidth=76, output=sys.stdout, toplevel='numpy'):
+def info(object=None, maxwidth=76, output=None, toplevel='numpy'):
"""
Get help information for a function, class, or module.
@@ -496,7 +499,8 @@ def info(object=None, maxwidth=76, output=sys.stdout, toplevel='numpy'):
Printing width.
output : file like object, optional
File like object that the output is written to, default is
- ``stdout``. The object has to be opened in 'w' or 'a' mode.
+ ``None``, in which case ``sys.stdout`` will be used.
+ The object has to be opened in 'w' or 'a' mode.
toplevel : str, optional
Start search at this level.
@@ -541,6 +545,9 @@ def info(object=None, maxwidth=76, output=sys.stdout, toplevel='numpy'):
elif hasattr(object, '_ppimport_attr'):
object = object._ppimport_attr
+ if output is None:
+ output = sys.stdout
+
if object is None:
info(info)
elif isinstance(object, ndarray):
diff --git a/numpy/linalg/tests/test_build.py b/numpy/linalg/tests/test_build.py
deleted file mode 100644
index 868341ff2..000000000
--- a/numpy/linalg/tests/test_build.py
+++ /dev/null
@@ -1,53 +0,0 @@
-from subprocess import PIPE, Popen
-import sys
-import re
-import pytest
-
-from numpy.linalg import lapack_lite
-from numpy.testing import assert_
-
-
-class FindDependenciesLdd:
-
- def __init__(self):
- self.cmd = ['ldd']
-
- try:
- p = Popen(self.cmd, stdout=PIPE, stderr=PIPE)
- stdout, stderr = p.communicate()
- except OSError as e:
- raise RuntimeError(f'command {self.cmd} cannot be run') from e
-
- def get_dependencies(self, lfile):
- p = Popen(self.cmd + [lfile], stdout=PIPE, stderr=PIPE)
- stdout, stderr = p.communicate()
- if not (p.returncode == 0):
- raise RuntimeError(f'failed dependencies check for {lfile}')
-
- return stdout
-
- def grep_dependencies(self, lfile, deps):
- stdout = self.get_dependencies(lfile)
-
- rdeps = dict([(dep, re.compile(dep)) for dep in deps])
- founds = []
- for l in stdout.splitlines():
- for k, v in rdeps.items():
- if v.search(l):
- founds.append(k)
-
- return founds
-
-
-class TestF77Mismatch:
-
- @pytest.mark.skipif(not(sys.platform[:5] == 'linux'),
- reason="no fortran compiler on non-Linux platform")
- def test_lapack(self):
- f = FindDependenciesLdd()
- deps = f.grep_dependencies(lapack_lite.__file__,
- [b'libg2c', b'libgfortran'])
- assert_(len(deps) <= 1,
- """Both g77 and gfortran runtimes linked in lapack_lite ! This is likely to
-cause random crashes and wrong results. See numpy INSTALL.txt for more
-information.""")
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 036d6312c..12836967c 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -2837,6 +2837,12 @@ class MaskedArray(ndarray):
_data = ndarray.view(_data, type(data))
else:
_data = ndarray.view(_data, cls)
+
+ # Handle the case where data is not a subclass of ndarray, but
+ # still has the _mask attribute like MaskedArrays
+ if hasattr(data, '_mask') and not isinstance(data, ndarray):
+ _data._mask = data._mask
+ # FIXME: should we set `_data._sharedmask = True`?
# Process mask.
# Type of the mask
mdtype = make_mask_descr(_data.dtype)
@@ -5660,9 +5666,12 @@ class MaskedArray(ndarray):
Parameters
----------
- axis : {None, int}, optional
+ axis : None or int or tuple of ints, optional
Axis along which to operate. By default, ``axis`` is None and the
flattened input is used.
+ .. versionadded:: 1.7.0
+ If this is a tuple of ints, the minimum is selected over multiple
+ axes, instead of a single axis or all the axes as before.
out : array_like, optional
Alternative output array in which to place the result. Must be of
the same shape and buffer length as the expected output.
@@ -5794,9 +5803,12 @@ class MaskedArray(ndarray):
Parameters
----------
- axis : {None, int}, optional
+ axis : None or int or tuple of ints, optional
Axis along which to operate. By default, ``axis`` is None and the
flattened input is used.
+ .. versionadded:: 1.7.0
+ If this is a tuple of ints, the maximum is selected over multiple
+ axes, instead of a single axis or all the axes as before.
out : array_like, optional
Alternative output array in which to place the result. Must
be of the same shape and buffer length as the expected output.
diff --git a/numpy/ma/tests/test_subclassing.py b/numpy/ma/tests/test_subclassing.py
index 1af539625..83a9b2f51 100644
--- a/numpy/ma/tests/test_subclassing.py
+++ b/numpy/ma/tests/test_subclassing.py
@@ -343,3 +343,45 @@ class TestSubclassing:
diff2 = arr1 - arr2
assert_('info' in diff2._optinfo)
assert_(diff2._optinfo['info'] == 'test')
+
+
+class ArrayNoInheritance:
+ """Quantity-like class that does not inherit from ndarray"""
+ def __init__(self, data, units):
+ self.magnitude = data
+ self.units = units
+
+ def __getattr__(self, attr):
+ return getattr(self.magnitude, attr)
+
+
+def test_array_no_inheritance():
+ data_masked = np.ma.array([1, 2, 3], mask=[True, False, True])
+ data_masked_units = ArrayNoInheritance(data_masked, 'meters')
+
+ # Get the masked representation of the Quantity-like class
+ new_array = np.ma.array(data_masked_units)
+ assert_equal(data_masked.data, new_array.data)
+ assert_equal(data_masked.mask, new_array.mask)
+ # Test sharing the mask
+ data_masked.mask = [True, False, False]
+ assert_equal(data_masked.mask, new_array.mask)
+ assert_(new_array.sharedmask)
+
+ # Get the masked representation of the Quantity-like class
+ new_array = np.ma.array(data_masked_units, copy=True)
+ assert_equal(data_masked.data, new_array.data)
+ assert_equal(data_masked.mask, new_array.mask)
+ # Test that the mask is not shared when copy=True
+ data_masked.mask = [True, False, True]
+ assert_equal([True, False, False], new_array.mask)
+ assert_(not new_array.sharedmask)
+
+ # Get the masked representation of the Quantity-like class
+ new_array = np.ma.array(data_masked_units, keep_mask=False)
+ assert_equal(data_masked.data, new_array.data)
+ # The change did not affect the original mask
+ assert_equal(data_masked.mask, [True, False, True])
+ # Test that the mask is False and not shared when keep_mask=False
+ assert_(not new_array.mask)
+ assert_(not new_array.sharedmask)
diff --git a/numpy/random/_examples/cython/setup.py b/numpy/random/_examples/cython/setup.py
index 7e0dd3e05..f41150fdb 100644
--- a/numpy/random/_examples/cython/setup.py
+++ b/numpy/random/_examples/cython/setup.py
@@ -4,6 +4,7 @@ Build the Cython demonstrations of low-level access to NumPy random
Usage: python setup.py build_ext -i
"""
+import setuptools # triggers monkeypatching distutils
from distutils.core import setup
from os.path import dirname, join, abspath
diff --git a/numpy/random/_mt19937.pyx b/numpy/random/_mt19937.pyx
index 16a377cc6..e9a703e2f 100644
--- a/numpy/random/_mt19937.pyx
+++ b/numpy/random/_mt19937.pyx
@@ -109,7 +109,7 @@ cdef class MT19937(BitGenerator):
**Compatibility Guarantee**
- ``MT19937`` makes a guarantee that a fixed seed and will always produce
+ ``MT19937`` makes a guarantee that a fixed seed will always produce
the same random integer stream.
References
diff --git a/numpy/random/mtrand.pyx b/numpy/random/mtrand.pyx
index a99f06693..d3724fcb5 100644
--- a/numpy/random/mtrand.pyx
+++ b/numpy/random/mtrand.pyx
@@ -4240,18 +4240,21 @@ cdef class RandomState:
ValueError: pvals < 0, pvals > 1 or pvals contains NaNs
"""
- cdef np.npy_intp d, i, sz, offset
+ cdef np.npy_intp d, i, sz, offset, niter
cdef np.ndarray parr, mnarr
cdef double *pix
cdef long *mnix
cdef long ni
- d = len(pvals)
parr = <np.ndarray>np.PyArray_FROMANY(
- pvals, np.NPY_DOUBLE, 1, 1, np.NPY_ARRAY_ALIGNED | np.NPY_ARRAY_C_CONTIGUOUS)
+ pvals, np.NPY_DOUBLE, 0, 1, np.NPY_ARRAY_ALIGNED | np.NPY_ARRAY_C_CONTIGUOUS)
+ if np.PyArray_NDIM(parr) == 0:
+ raise TypeError("pvals must be a 1-d sequence")
+ d = np.PyArray_SIZE(parr)
pix = <double*>np.PyArray_DATA(parr)
check_array_constraint(parr, 'pvals', CONS_BOUNDED_0_1)
- if kahan_sum(pix, d-1) > (1.0 + 1e-12):
+ # Only check if pvals is non-empty due no checks in kahan_sum
+ if d and kahan_sum(pix, d-1) > (1.0 + 1e-12):
# When floating, but not float dtype, and close, improve the error
# 1.0001 works for float16 and float32
if (isinstance(pvals, np.ndarray)
@@ -4266,7 +4269,6 @@ cdef class RandomState:
else:
msg = "sum(pvals[:-1]) > 1.0"
raise ValueError(msg)
-
if size is None:
shape = (d,)
else:
@@ -4274,7 +4276,6 @@ cdef class RandomState:
shape = (operator.index(size), d)
except:
shape = tuple(size) + (d,)
-
multin = np.zeros(shape, dtype=int)
mnarr = <np.ndarray>multin
mnix = <long*>np.PyArray_DATA(mnarr)
@@ -4282,8 +4283,10 @@ cdef class RandomState:
ni = n
check_constraint(ni, 'n', CONS_NON_NEGATIVE)
offset = 0
+ # gh-20483: Avoids divide by 0
+ niter = sz // d if d else 0
with self.lock, nogil:
- for i in range(sz // d):
+ for i in range(niter):
legacy_random_multinomial(&self._bitgen, ni, &mnix[offset], pix, d, &self._binomial)
offset += d
diff --git a/numpy/random/tests/test_extending.py b/numpy/random/tests/test_extending.py
index 99a819efb..d362092b5 100644
--- a/numpy/random/tests/test_extending.py
+++ b/numpy/random/tests/test_extending.py
@@ -5,6 +5,7 @@ import subprocess
import sys
import warnings
import numpy as np
+from numpy.distutils.misc_util import exec_mod_from_location
try:
import cffi
@@ -75,10 +76,9 @@ def test_cython(tmp_path):
assert so1 is not None
assert so2 is not None
# import the so's without adding the directory to sys.path
- from importlib.machinery import ExtensionFileLoader
- extending = ExtensionFileLoader('extending', so1).load_module()
- extending_distributions = ExtensionFileLoader('extending_distributions', so2).load_module()
-
+ exec_mod_from_location('extending', so1)
+ extending_distributions = exec_mod_from_location(
+ 'extending_distributions', so2)
# actually test the cython c-extension
from numpy.random import PCG64
values = extending_distributions.uniforms_ex(PCG64(0), 10, 'd')
diff --git a/numpy/random/tests/test_randomstate_regression.py b/numpy/random/tests/test_randomstate_regression.py
index 595fb5fd3..7ad19ab55 100644
--- a/numpy/random/tests/test_randomstate_regression.py
+++ b/numpy/random/tests/test_randomstate_regression.py
@@ -201,3 +201,16 @@ class TestRegression:
[3, 4, 2, 3, 3, 1, 5, 3, 1, 3]])
assert_array_equal(random.binomial([[0], [10]], 0.25, size=(2, 10)),
expected)
+
+
+def test_multinomial_empty():
+ # gh-20483
+ # Ensure that empty p-vals are correctly handled
+ assert random.multinomial(10, []).shape == (0,)
+ assert random.multinomial(3, [], size=(7, 5, 3)).shape == (7, 5, 3, 0)
+
+
+def test_multinomial_1d_pval():
+ # gh-20483
+ with pytest.raises(TypeError, match="pvals must be a 1-d"):
+ random.multinomial(10, 0.3)
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py
index 4c6b64bc9..0eb945d15 100644
--- a/numpy/testing/_private/utils.py
+++ b/numpy/testing/_private/utils.py
@@ -1228,13 +1228,13 @@ def rundocs(filename=None, raise_on_error=True):
>>> np.lib.test(doctests=True) # doctest: +SKIP
"""
- from numpy.compat import npy_load_module
+ from numpy.distutils.misc_util import exec_mod_from_location
import doctest
if filename is None:
f = sys._getframe(1)
filename = f.f_globals['__file__']
name = os.path.splitext(os.path.basename(filename))[0]
- m = npy_load_module(name, filename)
+ m = exec_mod_from_location(name, filename)
tests = doctest.DocTestFinder().find(m)
runner = doctest.DocTestRunner(verbose=False)
diff --git a/numpy/typing/tests/data/fail/array_constructors.pyi b/numpy/typing/tests/data/fail/array_constructors.pyi
index 4f0a60b5b..065b7d8a0 100644
--- a/numpy/typing/tests/data/fail/array_constructors.pyi
+++ b/numpy/typing/tests/data/fail/array_constructors.pyi
@@ -21,10 +21,10 @@ np.linspace(0, 2, retstep=b'False') # E: No overload variant
np.linspace(0, 2, dtype=0) # E: No overload variant
np.linspace(0, 2, axis=None) # E: No overload variant
-np.logspace(None, 'bob') # E: Argument 1
-np.logspace(0, 2, base=None) # E: Argument "base"
+np.logspace(None, 'bob') # E: No overload variant
+np.logspace(0, 2, base=None) # E: No overload variant
-np.geomspace(None, 'bob') # E: Argument 1
+np.geomspace(None, 'bob') # E: No overload variant
np.stack(generator) # E: No overload variant
np.hstack({1, 2}) # E: No overload variant
diff --git a/numpy/typing/tests/data/fail/shape_base.pyi b/numpy/typing/tests/data/fail/shape_base.pyi
new file mode 100644
index 000000000..e709741b7
--- /dev/null
+++ b/numpy/typing/tests/data/fail/shape_base.pyi
@@ -0,0 +1,8 @@
+import numpy as np
+
+class DTypeLike:
+ dtype: np.dtype[np.int_]
+
+dtype_like: DTypeLike
+
+np.expand_dims(dtype_like, (5, 10)) # E: No overload variant
diff --git a/numpy/typing/tests/data/reveal/array_constructors.pyi b/numpy/typing/tests/data/reveal/array_constructors.pyi
index 233988e63..ba5710e0f 100644
--- a/numpy/typing/tests/data/reveal/array_constructors.pyi
+++ b/numpy/typing/tests/data/reveal/array_constructors.pyi
@@ -114,10 +114,24 @@ reveal_type(np.require(B, requirements="W")) # E: SubClass[{float64}]
reveal_type(np.require(B, requirements="A")) # E: SubClass[{float64}]
reveal_type(np.require(C)) # E: ndarray[Any, Any]
-reveal_type(np.linspace(0, 10)) # E: ndarray[Any, Any]
-reveal_type(np.linspace(0, 10, retstep=True)) # E: Tuple[ndarray[Any, Any], Any]
-reveal_type(np.logspace(0, 10)) # E: ndarray[Any, Any]
-reveal_type(np.geomspace(1, 10)) # E: ndarray[Any, Any]
+reveal_type(np.linspace(0, 10)) # E: ndarray[Any, dtype[floating[Any]]]
+reveal_type(np.linspace(0, 10j)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+reveal_type(np.linspace(0, 10, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
+reveal_type(np.linspace(0, 10, dtype=int)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.linspace(0, 10, retstep=True)) # E: Tuple[ndarray[Any, dtype[floating[Any]]], floating[Any]]
+reveal_type(np.linspace(0j, 10, retstep=True)) # E: Tuple[ndarray[Any, dtype[complexfloating[Any, Any]]], complexfloating[Any, Any]]
+reveal_type(np.linspace(0, 10, retstep=True, dtype=np.int64)) # E: Tuple[ndarray[Any, dtype[{int64}]], {int64}]
+reveal_type(np.linspace(0j, 10, retstep=True, dtype=int)) # E: Tuple[ndarray[Any, dtype[Any]], Any]
+
+reveal_type(np.logspace(0, 10)) # E: ndarray[Any, dtype[floating[Any]]]
+reveal_type(np.logspace(0, 10j)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+reveal_type(np.logspace(0, 10, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
+reveal_type(np.logspace(0, 10, dtype=int)) # E: ndarray[Any, dtype[Any]]
+
+reveal_type(np.geomspace(0, 10)) # E: ndarray[Any, dtype[floating[Any]]]
+reveal_type(np.geomspace(0, 10j)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+reveal_type(np.geomspace(0, 10, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
+reveal_type(np.geomspace(0, 10, dtype=int)) # E: ndarray[Any, dtype[Any]]
reveal_type(np.zeros_like(A)) # E: ndarray[Any, dtype[{float64}]]
reveal_type(np.zeros_like(C)) # E: ndarray[Any, dtype[Any]]
diff --git a/numpy/typing/tests/data/reveal/emath.pyi b/numpy/typing/tests/data/reveal/emath.pyi
new file mode 100644
index 000000000..9ab2d72d2
--- /dev/null
+++ b/numpy/typing/tests/data/reveal/emath.pyi
@@ -0,0 +1,52 @@
+import numpy as np
+import numpy.typing as npt
+
+AR_f8: npt.NDArray[np.float64]
+AR_c16: npt.NDArray[np.complex128]
+f8: np.float64
+c16: np.complex128
+
+reveal_type(np.emath.sqrt(f8)) # E: Any
+reveal_type(np.emath.sqrt(AR_f8)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.emath.sqrt(c16)) # E: complexfloating[Any, Any]
+reveal_type(np.emath.sqrt(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+
+reveal_type(np.emath.log(f8)) # E: Any
+reveal_type(np.emath.log(AR_f8)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.emath.log(c16)) # E: complexfloating[Any, Any]
+reveal_type(np.emath.log(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+
+reveal_type(np.emath.log10(f8)) # E: Any
+reveal_type(np.emath.log10(AR_f8)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.emath.log10(c16)) # E: complexfloating[Any, Any]
+reveal_type(np.emath.log10(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+
+reveal_type(np.emath.log2(f8)) # E: Any
+reveal_type(np.emath.log2(AR_f8)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.emath.log2(c16)) # E: complexfloating[Any, Any]
+reveal_type(np.emath.log2(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+
+reveal_type(np.emath.logn(f8, 2)) # E: Any
+reveal_type(np.emath.logn(AR_f8, 4)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.emath.logn(f8, 1j)) # E: complexfloating[Any, Any]
+reveal_type(np.emath.logn(AR_c16, 1.5)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+
+reveal_type(np.emath.power(f8, 2)) # E: Any
+reveal_type(np.emath.power(AR_f8, 4)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.emath.power(f8, 2j)) # E: complexfloating[Any, Any]
+reveal_type(np.emath.power(AR_c16, 1.5)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+
+reveal_type(np.emath.arccos(f8)) # E: Any
+reveal_type(np.emath.arccos(AR_f8)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.emath.arccos(c16)) # E: complexfloating[Any, Any]
+reveal_type(np.emath.arccos(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+
+reveal_type(np.emath.arcsin(f8)) # E: Any
+reveal_type(np.emath.arcsin(AR_f8)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.emath.arcsin(c16)) # E: complexfloating[Any, Any]
+reveal_type(np.emath.arcsin(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
+
+reveal_type(np.emath.arctanh(f8)) # E: Any
+reveal_type(np.emath.arctanh(AR_f8)) # E: ndarray[Any, dtype[Any]]
+reveal_type(np.emath.arctanh(c16)) # E: complexfloating[Any, Any]
+reveal_type(np.emath.arctanh(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
diff --git a/numpy/typing/tests/data/reveal/lib_function_base.pyi b/numpy/typing/tests/data/reveal/lib_function_base.pyi
index 854b955b4..c559eb295 100644
--- a/numpy/typing/tests/data/reveal/lib_function_base.pyi
+++ b/numpy/typing/tests/data/reveal/lib_function_base.pyi
@@ -144,7 +144,7 @@ reveal_type(np.percentile(AR_O, 50)) # E: Any
reveal_type(np.percentile(AR_f8, [50])) # E: ndarray[Any, dtype[floating[Any]]]
reveal_type(np.percentile(AR_c16, [50])) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
reveal_type(np.percentile(AR_m, [50])) # E: ndarray[Any, dtype[timedelta64]]
-reveal_type(np.percentile(AR_M, [50], interpolation="nearest")) # E: ndarray[Any, dtype[datetime64]]
+reveal_type(np.percentile(AR_M, [50], method="nearest")) # E: ndarray[Any, dtype[datetime64]]
reveal_type(np.percentile(AR_O, [50])) # E: ndarray[Any, dtype[object_]]
reveal_type(np.percentile(AR_f8, [50], keepdims=True)) # E: Any
reveal_type(np.percentile(AR_f8, [50], axis=[1])) # E: Any
@@ -158,7 +158,7 @@ reveal_type(np.quantile(AR_O, 0.5)) # E: Any
reveal_type(np.quantile(AR_f8, [0.5])) # E: ndarray[Any, dtype[floating[Any]]]
reveal_type(np.quantile(AR_c16, [0.5])) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
reveal_type(np.quantile(AR_m, [0.5])) # E: ndarray[Any, dtype[timedelta64]]
-reveal_type(np.quantile(AR_M, [0.5], interpolation="nearest")) # E: ndarray[Any, dtype[datetime64]]
+reveal_type(np.quantile(AR_M, [0.5], method="nearest")) # E: ndarray[Any, dtype[datetime64]]
reveal_type(np.quantile(AR_O, [0.5])) # E: ndarray[Any, dtype[object_]]
reveal_type(np.quantile(AR_f8, [0.5], keepdims=True)) # E: Any
reveal_type(np.quantile(AR_f8, [0.5], axis=[1])) # E: Any
diff --git a/numpy/typing/tests/data/reveal/ndarray_misc.pyi b/numpy/typing/tests/data/reveal/ndarray_misc.pyi
index cd1c3136f..f91d6351b 100644
--- a/numpy/typing/tests/data/reveal/ndarray_misc.pyi
+++ b/numpy/typing/tests/data/reveal/ndarray_misc.pyi
@@ -24,6 +24,9 @@ AR_V: NDArray[np.void]
ctypes_obj = AR_f8.ctypes
+reveal_type(AR_f8.__dlpack__()) # E: Any
+reveal_type(AR_f8.__dlpack_device__()) # E: Tuple[int, Literal[0]]
+
reveal_type(ctypes_obj.data) # E: int
reveal_type(ctypes_obj.shape) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj.strides) # E: ctypes.Array[{c_intp}]
diff --git a/numpy/typing/tests/test_typing.py b/numpy/typing/tests/test_typing.py
index fe58a8f4c..bb3914434 100644
--- a/numpy/typing/tests/test_typing.py
+++ b/numpy/typing/tests/test_typing.py
@@ -136,7 +136,7 @@ def test_fail(path: str) -> None:
output_mypy = OUTPUT_MYPY
assert path in output_mypy
for error_line in output_mypy[path]:
- error_line = _strip_filename(error_line)
+ error_line = _strip_filename(error_line).split("\n", 1)[0]
match = re.match(
r"(?P<lineno>\d+): (error|note): .+$",
error_line,
@@ -368,6 +368,7 @@ Expression: {}
Expected reveal: {!r}
Observed reveal: {!r}
"""
+_STRIP_PATTERN = re.compile(r"(\w+\.)+(\w+)")
def _test_reveal(
@@ -378,9 +379,8 @@ def _test_reveal(
lineno: int,
) -> None:
"""Error-reporting helper function for `test_reveal`."""
- strip_pattern = re.compile(r"(\w+\.)+(\w+)")
- stripped_reveal = strip_pattern.sub(strip_func, reveal)
- stripped_expected_reveal = strip_pattern.sub(strip_func, expected_reveal)
+ stripped_reveal = _STRIP_PATTERN.sub(strip_func, reveal)
+ stripped_expected_reveal = _STRIP_PATTERN.sub(strip_func, expected_reveal)
if stripped_reveal not in stripped_expected_reveal:
raise AssertionError(
_REVEAL_MSG.format(lineno,
diff --git a/pavement.py b/pavement.py
index 6fdaae975..025489cbd 100644
--- a/pavement.py
+++ b/pavement.py
@@ -38,7 +38,7 @@ from paver.easy import Bunch, options, task, sh
#-----------------------------------
# Path to the release notes
-RELEASE_NOTES = 'doc/source/release/1.22.0-notes.rst'
+RELEASE_NOTES = 'doc/source/release/1.23.0-notes.rst'
#-------------------------------------------------------
diff --git a/pyproject.toml b/pyproject.toml
index 941c8fa8c..39d6fcd98 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,8 +2,8 @@
# Minimum requirements for the build system to execute.
requires = [
"packaging==20.5; platform_machine=='arm64'", # macos M1
- "setuptools<49.2.0",
- "wheel==0.36.2",
+ "setuptools==59.2.0",
+ "wheel==0.37.0",
"Cython>=0.29.24,<3.0", # Note: keep in sync with tools/cythonize.py
]
diff --git a/test_requirements.txt b/test_requirements.txt
index 256b26d9b..9532e3346 100644
--- a/test_requirements.txt
+++ b/test_requirements.txt
@@ -1,11 +1,10 @@
cython==0.29.24
-wheel<0.37.1
-setuptools<49.2.0
+wheel==0.37.0
+setuptools==59.2.0
hypothesis==6.24.1
pytest==6.2.5
pytz==2021.3
pytest-cov==3.0.0
-pickle5; python_version == '3.7' and platform_python_implementation != 'PyPy'
# for numpy.random.test.test_extending
cffi; python_version < '3.10'
# For testing types. Notes on the restrictions:
diff --git a/tools/allocation_tracking/README.md b/tools/allocation_tracking/README.md
index fd4f2c871..6cc4c2a58 100644
--- a/tools/allocation_tracking/README.md
+++ b/tools/allocation_tracking/README.md
@@ -1,11 +1,7 @@
-Example for using the `PyDataMem_SetEventHook` to track allocations inside numpy.
-
-`alloc_hook.pyx` implements a hook in Cython that calls back into a python
-function. `track_allocations.py` uses it for a simple listing of allocations.
-It can be built with the `setup.py` file in this folder.
-
Note that since Python 3.6 the builtin tracemalloc module can be used to
track allocations inside numpy.
Numpy places its CPU memory allocations into the `np.lib.tracemalloc_domain`
domain.
See https://docs.python.org/3/library/tracemalloc.html.
+
+The tool that used to be here has been deprecated.
diff --git a/tools/allocation_tracking/alloc_hook.pyx b/tools/allocation_tracking/alloc_hook.pyx
deleted file mode 100644
index eeefe1704..000000000
--- a/tools/allocation_tracking/alloc_hook.pyx
+++ /dev/null
@@ -1,42 +0,0 @@
-# A cython wrapper for using python functions as callbacks for
-# PyDataMem_SetEventHook.
-
-cimport numpy as np
-
-cdef extern from "Python.h":
- object PyLong_FromVoidPtr(void *)
- void *PyLong_AsVoidPtr(object)
-
-ctypedef void PyDataMem_EventHookFunc(void *inp, void *outp, size_t size,
- void *user_data)
-cdef extern from "numpy/arrayobject.h":
- PyDataMem_EventHookFunc * \
- PyDataMem_SetEventHook(PyDataMem_EventHookFunc *newhook,
- void *user_data, void **old_data)
-
-np.import_array()
-
-cdef void pyhook(void *old, void *new, size_t size, void *user_data):
- cdef object pyfunc = <object> user_data
- pyfunc(PyLong_FromVoidPtr(old),
- PyLong_FromVoidPtr(new),
- size)
-
-class NumpyAllocHook:
- def __init__(self, callback):
- self.callback = callback
-
- def __enter__(self):
- cdef void *old_hook, *old_data
- old_hook = <void *> \
- PyDataMem_SetEventHook(<PyDataMem_EventHookFunc *> pyhook,
- <void *> self.callback,
- <void **> &old_data)
- self.old_hook = PyLong_FromVoidPtr(old_hook)
- self.old_data = PyLong_FromVoidPtr(old_data)
-
- def __exit__(self):
- PyDataMem_SetEventHook(<PyDataMem_EventHookFunc *> \
- PyLong_AsVoidPtr(self.old_hook),
- <void *> PyLong_AsVoidPtr(self.old_data),
- <void **> 0)
diff --git a/tools/allocation_tracking/setup.py b/tools/allocation_tracking/setup.py
deleted file mode 100644
index 4462f9f4e..000000000
--- a/tools/allocation_tracking/setup.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from distutils.core import setup
-from distutils.extension import Extension
-from Cython.Distutils import build_ext
-import numpy
-
-setup(
- cmdclass = {'build_ext': build_ext},
- ext_modules = [Extension("alloc_hook", ["alloc_hook.pyx"],
- include_dirs=[numpy.get_include()])])
diff --git a/tools/allocation_tracking/sorttable.js b/tools/allocation_tracking/sorttable.js
deleted file mode 100644
index c9528873e..000000000
--- a/tools/allocation_tracking/sorttable.js
+++ /dev/null
@@ -1,493 +0,0 @@
-/*
- SortTable
- version 2
- 7th April 2007
- Stuart Langridge, https://www.kryogenix.org/code/browser/sorttable/
-
- Instructions:
- Download this file
- Add <script src="sorttable.js"></script> to your HTML
- Add class="sortable" to any table you'd like to make sortable
- Click on the headers to sort
-
- Thanks to many, many people for contributions and suggestions.
- Licenced as X11: https://www.kryogenix.org/code/browser/licence.html
- This basically means: do what you want with it.
-*/
-
-
-var stIsIE = /*@cc_on!@*/false;
-
-sorttable = {
- init: function() {
- // quit if this function has already been called
- if (arguments.callee.done) return;
- // flag this function so we don't do the same thing twice
- arguments.callee.done = true;
- // kill the timer
- if (_timer) clearInterval(_timer);
-
- if (!document.createElement || !document.getElementsByTagName) return;
-
- sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
-
- forEach(document.getElementsByTagName('table'), function(table) {
- if (table.className.search(/\bsortable\b/) != -1) {
- sorttable.makeSortable(table);
- }
- });
-
- },
-
- makeSortable: function(table) {
- if (table.getElementsByTagName('thead').length == 0) {
- // table doesn't have a tHead. Since it should have, create one and
- // put the first table row in it.
- the = document.createElement('thead');
- the.appendChild(table.rows[0]);
- table.insertBefore(the,table.firstChild);
- }
- // Safari doesn't support table.tHead, sigh
- if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
-
- if (table.tHead.rows.length != 1) return; // can't cope with two header rows
-
- // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
- // "total" rows, for example). This is B&R, since what you're supposed
- // to do is put them in a tfoot. So, if there are sortbottom rows,
- // for backwards compatibility, move them to tfoot (creating it if needed).
- sortbottomrows = [];
- for (var i=0; i<table.rows.length; i++) {
- if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
- sortbottomrows[sortbottomrows.length] = table.rows[i];
- }
- }
- if (sortbottomrows) {
- if (table.tFoot == null) {
- // table doesn't have a tfoot. Create one.
- tfo = document.createElement('tfoot');
- table.appendChild(tfo);
- }
- for (var i=0; i<sortbottomrows.length; i++) {
- tfo.appendChild(sortbottomrows[i]);
- }
- delete sortbottomrows;
- }
-
- // work through each column and calculate its type
- headrow = table.tHead.rows[0].cells;
- for (var i=0; i<headrow.length; i++) {
- // manually override the type with a sorttable_type attribute
- if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
- mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
- if (mtch) { override = mtch[1]; }
- if (mtch && typeof sorttable["sort_"+override] == 'function') {
- headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
- } else {
- headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
- }
- // make it clickable to sort
- headrow[i].sorttable_columnindex = i;
- headrow[i].sorttable_tbody = table.tBodies[0];
- dean_addEvent(headrow[i],"click", function(e) {
-
- if (this.className.search(/\bsorttable_sorted\b/) != -1) {
- // if we're already sorted by this column, just
- // reverse the table, which is quicker
- sorttable.reverse(this.sorttable_tbody);
- this.className = this.className.replace('sorttable_sorted',
- 'sorttable_sorted_reverse');
- this.removeChild(document.getElementById('sorttable_sortfwdind'));
- sortrevind = document.createElement('span');
- sortrevind.id = "sorttable_sortrevind";
- sortrevind.innerHTML = stIsIE ? '&nbsp<font face="webdings">5</font>' : '&nbsp;&#x25B4;';
- this.appendChild(sortrevind);
- return;
- }
- if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
- // if we're already sorted by this column in reverse, just
- // re-reverse the table, which is quicker
- sorttable.reverse(this.sorttable_tbody);
- this.className = this.className.replace('sorttable_sorted_reverse',
- 'sorttable_sorted');
- this.removeChild(document.getElementById('sorttable_sortrevind'));
- sortfwdind = document.createElement('span');
- sortfwdind.id = "sorttable_sortfwdind";
- sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
- this.appendChild(sortfwdind);
- return;
- }
-
- // remove sorttable_sorted classes
- theadrow = this.parentNode;
- forEach(theadrow.childNodes, function(cell) {
- if (cell.nodeType == 1) { // an element
- cell.className = cell.className.replace('sorttable_sorted_reverse','');
- cell.className = cell.className.replace('sorttable_sorted','');
- }
- });
- sortfwdind = document.getElementById('sorttable_sortfwdind');
- if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
- sortrevind = document.getElementById('sorttable_sortrevind');
- if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
-
- this.className += ' sorttable_sorted';
- sortfwdind = document.createElement('span');
- sortfwdind.id = "sorttable_sortfwdind";
- sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
- this.appendChild(sortfwdind);
-
- // build an array to sort. This is a Schwartzian transform thing,
- // i.e., we "decorate" each row with the actual sort key,
- // sort based on the sort keys, and then put the rows back in order
- // which is a lot faster because you only do getInnerText once per row
- row_array = [];
- col = this.sorttable_columnindex;
- rows = this.sorttable_tbody.rows;
- for (var j=0; j<rows.length; j++) {
- row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];
- }
- /* If you want a stable sort, uncomment the following line */
- //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
- /* and comment out this one */
- row_array.sort(this.sorttable_sortfunction);
-
- tb = this.sorttable_tbody;
- for (var j=0; j<row_array.length; j++) {
- tb.appendChild(row_array[j][1]);
- }
-
- delete row_array;
- });
- }
- }
- },
-
- guessType: function(table, column) {
- // guess the type of a column based on its first non-blank row
- sortfn = sorttable.sort_alpha;
- for (var i=0; i<table.tBodies[0].rows.length; i++) {
- text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
- if (text != '') {
- if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
- return sorttable.sort_numeric;
- }
- // check for a date: dd/mm/yyyy or dd/mm/yy
- // can have / or . or - as separator
- // can be mm/dd as well
- possdate = text.match(sorttable.DATE_RE)
- if (possdate) {
- // looks like a date
- first = parseInt(possdate[1]);
- second = parseInt(possdate[2]);
- if (first > 12) {
- // definitely dd/mm
- return sorttable.sort_ddmm;
- } else if (second > 12) {
- return sorttable.sort_mmdd;
- } else {
- // looks like a date, but we can't tell which, so assume
- // that it's dd/mm (English imperialism!) and keep looking
- sortfn = sorttable.sort_ddmm;
- }
- }
- }
- }
- return sortfn;
- },
-
- getInnerText: function(node) {
- // gets the text we want to use for sorting for a cell.
- // strips leading and trailing whitespace.
- // this is *not* a generic getInnerText function; it's special to sorttable.
- // for example, you can override the cell text with a customkey attribute.
- // it also gets .value for <input> fields.
-
- hasInputs = (typeof node.getElementsByTagName == 'function') &&
- node.getElementsByTagName('input').length;
-
- if (node.getAttribute("sorttable_customkey") != null) {
- return node.getAttribute("sorttable_customkey");
- }
- else if (typeof node.textContent != 'undefined' && !hasInputs) {
- return node.textContent.replace(/^\s+|\s+$/g, '');
- }
- else if (typeof node.innerText != 'undefined' && !hasInputs) {
- return node.innerText.replace(/^\s+|\s+$/g, '');
- }
- else if (typeof node.text != 'undefined' && !hasInputs) {
- return node.text.replace(/^\s+|\s+$/g, '');
- }
- else {
- switch (node.nodeType) {
- case 3:
- if (node.nodeName.toLowerCase() == 'input') {
- return node.value.replace(/^\s+|\s+$/g, '');
- }
- case 4:
- return node.nodeValue.replace(/^\s+|\s+$/g, '');
- break;
- case 1:
- case 11:
- var innerText = '';
- for (var i = 0; i < node.childNodes.length; i++) {
- innerText += sorttable.getInnerText(node.childNodes[i]);
- }
- return innerText.replace(/^\s+|\s+$/g, '');
- break;
- default:
- return '';
- }
- }
- },
-
- reverse: function(tbody) {
- // reverse the rows in a tbody
- newrows = [];
- for (var i=0; i<tbody.rows.length; i++) {
- newrows[newrows.length] = tbody.rows[i];
- }
- for (var i=newrows.length-1; i>=0; i--) {
- tbody.appendChild(newrows[i]);
- }
- delete newrows;
- },
-
- /* sort functions
- each sort function takes two parameters, a and b
- you are comparing a[0] and b[0] */
- sort_numeric: function(a,b) {
- aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
- if (isNaN(aa)) aa = 0;
- bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
- if (isNaN(bb)) bb = 0;
- return aa-bb;
- },
- sort_alpha: function(a,b) {
- if (a[0]==b[0]) return 0;
- if (a[0]<b[0]) return -1;
- return 1;
- },
- sort_ddmm: function(a,b) {
- mtch = a[0].match(sorttable.DATE_RE);
- y = mtch[3]; m = mtch[2]; d = mtch[1];
- if (m.length == 1) m = '0'+m;
- if (d.length == 1) d = '0'+d;
- dt1 = y+m+d;
- mtch = b[0].match(sorttable.DATE_RE);
- y = mtch[3]; m = mtch[2]; d = mtch[1];
- if (m.length == 1) m = '0'+m;
- if (d.length == 1) d = '0'+d;
- dt2 = y+m+d;
- if (dt1==dt2) return 0;
- if (dt1<dt2) return -1;
- return 1;
- },
- sort_mmdd: function(a,b) {
- mtch = a[0].match(sorttable.DATE_RE);
- y = mtch[3]; d = mtch[2]; m = mtch[1];
- if (m.length == 1) m = '0'+m;
- if (d.length == 1) d = '0'+d;
- dt1 = y+m+d;
- mtch = b[0].match(sorttable.DATE_RE);
- y = mtch[3]; d = mtch[2]; m = mtch[1];
- if (m.length == 1) m = '0'+m;
- if (d.length == 1) d = '0'+d;
- dt2 = y+m+d;
- if (dt1==dt2) return 0;
- if (dt1<dt2) return -1;
- return 1;
- },
-
- shaker_sort: function(list, comp_func) {
- // A stable sort function to allow multi-level sorting of data
- // see: https://en.wikipedia.org/wiki/Cocktail_shaker_sort
- // thanks to Joseph Nahmias
- var b = 0;
- var t = list.length - 1;
- var swap = true;
-
- while(swap) {
- swap = false;
- for(var i = b; i < t; ++i) {
- if ( comp_func(list[i], list[i+1]) > 0 ) {
- var q = list[i]; list[i] = list[i+1]; list[i+1] = q;
- swap = true;
- }
- } // for
- t--;
-
- if (!swap) break;
-
- for(var i = t; i > b; --i) {
- if ( comp_func(list[i], list[i-1]) < 0 ) {
- var q = list[i]; list[i] = list[i-1]; list[i-1] = q;
- swap = true;
- }
- } // for
- b++;
-
- } // while(swap)
- }
-}
-
-/* ******************************************************************
- Supporting functions: bundled here to avoid depending on a library
- ****************************************************************** */
-
-// Dean Edwards/Matthias Miller/John Resig
-
-/* for Mozilla/Opera9 */
-if (document.addEventListener) {
- document.addEventListener("DOMContentLoaded", sorttable.init, false);
-}
-
-/* for Internet Explorer */
-/*@cc_on @*/
-/*@if (@_win32)
- document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
- var script = document.getElementById("__ie_onload");
- script.onreadystatechange = function() {
- if (this.readyState == "complete") {
- sorttable.init(); // call the onload handler
- }
- };
-/*@end @*/
-
-/* for Safari */
-if (/WebKit/i.test(navigator.userAgent)) { // sniff
- var _timer = setInterval(function() {
- if (/loaded|complete/.test(document.readyState)) {
- sorttable.init(); // call the onload handler
- }
- }, 10);
-}
-
-/* for other browsers */
-window.onload = sorttable.init;
-
-// written by Dean Edwards, 2005
-// with input from Tino Zijdel, Matthias Miller, Diego Perini
-
-// http://dean.edwards.name/weblog/2005/10/add-event/
-
-function dean_addEvent(element, type, handler) {
- if (element.addEventListener) {
- element.addEventListener(type, handler, false);
- } else {
- // assign each event handler a unique ID
- if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;
- // create a hash table of event types for the element
- if (!element.events) element.events = {};
- // create a hash table of event handlers for each element/event pair
- var handlers = element.events[type];
- if (!handlers) {
- handlers = element.events[type] = {};
- // store the existing event handler (if there is one)
- if (element["on" + type]) {
- handlers[0] = element["on" + type];
- }
- }
- // store the event handler in the hash table
- handlers[handler.$$guid] = handler;
- // assign a global event handler to do all the work
- element["on" + type] = handleEvent;
- }
-};
-// a counter used to create unique IDs
-dean_addEvent.guid = 1;
-
-function removeEvent(element, type, handler) {
- if (element.removeEventListener) {
- element.removeEventListener(type, handler, false);
- } else {
- // delete the event handler from the hash table
- if (element.events && element.events[type]) {
- delete element.events[type][handler.$$guid];
- }
- }
-};
-
-function handleEvent(event) {
- var returnValue = true;
- // grab the event object (IE uses a global event object)
- event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
- // get a reference to the hash table of event handlers
- var handlers = this.events[event.type];
- // execute each event handler
- for (var i in handlers) {
- this.$$handleEvent = handlers[i];
- if (this.$$handleEvent(event) === false) {
- returnValue = false;
- }
- }
- return returnValue;
-};
-
-function fixEvent(event) {
- // add W3C standard event methods
- event.preventDefault = fixEvent.preventDefault;
- event.stopPropagation = fixEvent.stopPropagation;
- return event;
-};
-fixEvent.preventDefault = function() {
- this.returnValue = false;
-};
-fixEvent.stopPropagation = function() {
- this.cancelBubble = true;
-}
-
-// Dean's forEach: http://dean.edwards.name/base/forEach.js
-/*
- forEach, version 1.0
- Copyright 2006, Dean Edwards
- License: https://www.opensource.org/licenses/mit-license.php
-*/
-
-// array-like enumeration
-if (!Array.forEach) { // mozilla already supports this
- Array.forEach = function(array, block, context) {
- for (var i = 0; i < array.length; i++) {
- block.call(context, array[i], i, array);
- }
- };
-}
-
-// generic enumeration
-Function.prototype.forEach = function(object, block, context) {
- for (var key in object) {
- if (typeof this.prototype[key] == "undefined") {
- block.call(context, object[key], key, object);
- }
- }
-};
-
-// character enumeration
-String.forEach = function(string, block, context) {
- Array.forEach(string.split(""), function(chr, index) {
- block.call(context, chr, index, string);
- });
-};
-
-// globally resolve forEach enumeration
-var forEach = function(object, block, context) {
- if (object) {
- var resolve = Object; // default
- if (object instanceof Function) {
- // functions have a "length" property
- resolve = Function;
- } else if (object.forEach instanceof Function) {
- // the object implements a custom forEach method so use that
- object.forEach(block, context);
- return;
- } else if (typeof object == "string") {
- // the object is a string
- resolve = String;
- } else if (typeof object.length == "number") {
- // the object is array-like
- resolve = Array;
- }
- resolve.forEach(object, block, context);
- }
-};
-
diff --git a/tools/allocation_tracking/track_allocations.py b/tools/allocation_tracking/track_allocations.py
deleted file mode 100644
index 2a80d8f87..000000000
--- a/tools/allocation_tracking/track_allocations.py
+++ /dev/null
@@ -1,140 +0,0 @@
-import numpy as np
-import gc
-import inspect
-from alloc_hook import NumpyAllocHook
-
-class AllocationTracker:
- def __init__(self, threshold=0):
- '''track numpy allocations of size threshold bytes or more.'''
-
- self.threshold = threshold
-
- # The total number of bytes currently allocated with size above
- # threshold
- self.total_bytes = 0
-
- # We buffer requests line by line and move them into the allocation
- # trace when a new line occurs
- self.current_line = None
- self.pending_allocations = []
-
- self.blocksizes = {}
-
- # list of (lineinfo, bytes allocated, bytes freed, # allocations, #
- # frees, maximum memory usage, long-lived bytes allocated)
- self.allocation_trace = []
-
- self.numpy_hook = NumpyAllocHook(self.hook)
-
- def __enter__(self):
- self.numpy_hook.__enter__()
-
- def __exit__(self, type, value, traceback):
- self.check_line_changed() # forces pending events to be handled
- self.numpy_hook.__exit__()
-
- def hook(self, inptr, outptr, size):
- # minimize the chances that the garbage collector kicks in during a
- # cython __dealloc__ call and causes a double delete of the current
- # object. To avoid this fully the hook would have to avoid all python
- # api calls, e.g. by being implemented in C like python 3.4's
- # tracemalloc module
- gc_on = gc.isenabled()
- gc.disable()
- if outptr == 0: # it's a free
- self.free_cb(inptr)
- elif inptr != 0: # realloc
- self.realloc_cb(inptr, outptr, size)
- else: # malloc
- self.alloc_cb(outptr, size)
- if gc_on:
- gc.enable()
-
- def alloc_cb(self, ptr, size):
- if size >= self.threshold:
- self.check_line_changed()
- self.blocksizes[ptr] = size
- self.pending_allocations.append(size)
-
- def free_cb(self, ptr):
- size = self.blocksizes.pop(ptr, 0)
- if size:
- self.check_line_changed()
- self.pending_allocations.append(-size)
-
- def realloc_cb(self, newptr, oldptr, size):
- if (size >= self.threshold) or (oldptr in self.blocksizes):
- self.check_line_changed()
- oldsize = self.blocksizes.pop(oldptr, 0)
- self.pending_allocations.append(size - oldsize)
- self.blocksizes[newptr] = size
-
- def get_code_line(self):
- # first frame is this line, then check_line_changed(), then 2 callbacks,
- # then actual code.
- try:
- return inspect.stack()[4][1:]
- except Exception:
- return inspect.stack()[0][1:]
-
- def check_line_changed(self):
- line = self.get_code_line()
- if line != self.current_line and (self.current_line is not None):
- # move pending events into the allocation_trace
- max_size = self.total_bytes
- bytes_allocated = 0
- bytes_freed = 0
- num_allocations = 0
- num_frees = 0
- before_size = self.total_bytes
- for allocation in self.pending_allocations:
- self.total_bytes += allocation
- if allocation > 0:
- bytes_allocated += allocation
- num_allocations += 1
- else:
- bytes_freed += -allocation
- num_frees += 1
- max_size = max(max_size, self.total_bytes)
- long_lived = max(self.total_bytes - before_size, 0)
- self.allocation_trace.append((self.current_line, bytes_allocated,
- bytes_freed, num_allocations,
- num_frees, max_size, long_lived))
- # clear pending allocations
- self.pending_allocations = []
- # move to the new line
- self.current_line = line
-
- def write_html(self, filename):
- with open(filename, "w") as f:
- f.write('<HTML><HEAD><script src="sorttable.js"></script></HEAD><BODY>\n')
- f.write('<TABLE class="sortable" width=100%>\n')
- f.write("<TR>\n")
- cols = "event#,lineinfo,bytes allocated,bytes freed,#allocations,#frees,max memory usage,long lived bytes".split(',')
- for header in cols:
- f.write(" <TH>{0}</TH>".format(header))
- f.write("\n</TR>\n")
- for idx, event in enumerate(self.allocation_trace):
- f.write("<TR>\n")
- event = [idx] + list(event)
- for col, val in zip(cols, event):
- if col == 'lineinfo':
- # special handling
- try:
- filename, line, module, code, index = val
- val = "{0}({1}): {2}".format(filename, line, code[index])
- except Exception:
- # sometimes this info is not available (from eval()?)
- val = str(val)
- f.write(" <TD>{0}</TD>".format(val))
- f.write("\n</TR>\n")
- f.write("</TABLE></BODY></HTML>\n")
-
-
-if __name__ == '__main__':
- tracker = AllocationTracker(1000)
- with tracker:
- for i in range(100):
- np.zeros(i * 100)
- np.zeros(i * 200)
- tracker.write_html("allocations.html")
diff --git a/tools/functions_missing_types.py b/tools/functions_missing_types.py
index 0461aabd3..99c6887a9 100755
--- a/tools/functions_missing_types.py
+++ b/tools/functions_missing_types.py
@@ -32,7 +32,6 @@ EXCLUDE_LIST = {
"math",
# Accidentally public, deprecated, or shouldn't be used
"Tester",
- "alen",
"add_docstring",
"add_newdoc",
"add_newdoc_ufunc",
diff --git a/tools/wheels/LICENSE_win32.txt b/tools/wheels/LICENSE_win32.txt
new file mode 100644
index 000000000..1014d77cd
--- /dev/null
+++ b/tools/wheels/LICENSE_win32.txt
@@ -0,0 +1,938 @@
+
+----
+
+This binary distribution of NumPy also bundles the following software:
+
+
+Name: OpenBLAS
+Files: extra-dll\libopenb*.dll
+Description: bundled as a dynamically linked library
+Availability: https://github.com/xianyi/OpenBLAS/
+License: 3-clause BSD
+ Copyright (c) 2011-2014, The OpenBLAS Project
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. Neither the name of the OpenBLAS project nor the names of
+ its contributors may be used to endorse or promote products
+ derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+Name: LAPACK
+Files: extra-dll\libopenb*.dll
+Description: bundled in OpenBLAS
+Availability: https://github.com/xianyi/OpenBLAS/
+License 3-clause BSD
+ Copyright (c) 1992-2013 The University of Tennessee and The University
+ of Tennessee Research Foundation. All rights
+ reserved.
+ Copyright (c) 2000-2013 The University of California Berkeley. All
+ rights reserved.
+ Copyright (c) 2006-2013 The University of Colorado Denver. All rights
+ reserved.
+
+ $COPYRIGHT$
+
+ Additional copyrights may follow
+
+ $HEADER$
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer listed
+ in this license in the documentation and/or other materials
+ provided with the distribution.
+
+ - Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ The copyright holders provide no reassurances that the source code
+ provided does not infringe any patent, copyright, or any other
+ intellectual property rights of third parties. The copyright holders
+ disclaim any liability to any recipient for claims brought against
+ recipient by any third party for infringement of that parties
+ intellectual property rights.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+Name: GCC runtime library
+Files: extra-dll\*.dll
+Description: statically linked, in DLL files compiled with gfortran only
+Availability: https://gcc.gnu.org/viewcvs/gcc/
+License: GPLv3 + runtime exception
+ Copyright (C) 2002-2017 Free Software Foundation, Inc.
+
+ Libgfortran is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Libgfortran is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>.
+
+
+Name: Microsoft Visual C++ Runtime Files
+Files: extra-dll\msvcp140.dll
+License: MSVC
+ https://www.visualstudio.com/license-terms/distributable-code-microsoft-visual-studio-2015-rc-microsoft-visual-studio-2015-sdk-rc-includes-utilities-buildserver-files/#visual-c-runtime
+
+ Subject to the License Terms for the software, you may copy and
+ distribute with your program any of the files within the followng
+ folder and its subfolders except as noted below. You may not modify
+ these files.
+
+ C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist
+
+ You may not distribute the contents of the following folders:
+
+ C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\debug_nonredist
+ C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\onecore\debug_nonredist
+
+ Subject to the License Terms for the software, you may copy and
+ distribute the following files with your program in your program’s
+ application local folder or by deploying them into the Global
+ Assembly Cache (GAC):
+
+ VC\atlmfc\lib\mfcmifc80.dll
+ VC\atlmfc\lib\amd64\mfcmifc80.dll
+
+
+Name: Microsoft Visual C++ Runtime Files
+Files: extra-dll\msvc*90.dll, extra-dll\Microsoft.VC90.CRT.manifest
+License: MSVC
+ For your convenience, we have provided the following folders for
+ use when redistributing VC++ runtime files. Subject to the license
+ terms for the software, you may redistribute the folder
+ (unmodified) in the application local folder as a sub-folder with
+ no change to the folder name. You may also redistribute all the
+ files (*.dll and *.manifest) within a folder, listed below the
+ folder for your convenience, as an entire set.
+
+ \VC\redist\x86\Microsoft.VC90.ATL\
+ atl90.dll
+ Microsoft.VC90.ATL.manifest
+ \VC\redist\ia64\Microsoft.VC90.ATL\
+ atl90.dll
+ Microsoft.VC90.ATL.manifest
+ \VC\redist\amd64\Microsoft.VC90.ATL\
+ atl90.dll
+ Microsoft.VC90.ATL.manifest
+ \VC\redist\x86\Microsoft.VC90.CRT\
+ msvcm90.dll
+ msvcp90.dll
+ msvcr90.dll
+ Microsoft.VC90.CRT.manifest
+ \VC\redist\ia64\Microsoft.VC90.CRT\
+ msvcm90.dll
+ msvcp90.dll
+ msvcr90.dll
+ Microsoft.VC90.CRT.manifest
+
+----
+
+Full text of license texts referred to above follows (that they are
+listed below does not necessarily imply the conditions apply to the
+present binary release):
+
+----
+
+GCC RUNTIME LIBRARY EXCEPTION
+
+Version 3.1, 31 March 2009
+
+Copyright (C) 2009 Free Software Foundation, Inc. <http://fsf.org/>
+
+Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+
+This GCC Runtime Library Exception ("Exception") is an additional
+permission under section 7 of the GNU General Public License, version
+3 ("GPLv3"). It applies to a given file (the "Runtime Library") that
+bears a notice placed by the copyright holder of the file stating that
+the file is governed by GPLv3 along with this Exception.
+
+When you use GCC to compile a program, GCC may combine portions of
+certain GCC header files and runtime libraries with the compiled
+program. The purpose of this Exception is to allow compilation of
+non-GPL (including proprietary) programs to use, in this way, the
+header files and runtime libraries covered by this Exception.
+
+0. Definitions.
+
+A file is an "Independent Module" if it either requires the Runtime
+Library for execution after a Compilation Process, or makes use of an
+interface provided by the Runtime Library, but is not otherwise based
+on the Runtime Library.
+
+"GCC" means a version of the GNU Compiler Collection, with or without
+modifications, governed by version 3 (or a specified later version) of
+the GNU General Public License (GPL) with the option of using any
+subsequent versions published by the FSF.
+
+"GPL-compatible Software" is software whose conditions of propagation,
+modification and use would permit combination with GCC in accord with
+the license of GCC.
+
+"Target Code" refers to output from any compiler for a real or virtual
+target processor architecture, in executable form or suitable for
+input to an assembler, loader, linker and/or execution
+phase. Notwithstanding that, Target Code does not include data in any
+format that is used as a compiler intermediate representation, or used
+for producing a compiler intermediate representation.
+
+The "Compilation Process" transforms code entirely represented in
+non-intermediate languages designed for human-written code, and/or in
+Java Virtual Machine byte code, into Target Code. Thus, for example,
+use of source code generators and preprocessors need not be considered
+part of the Compilation Process, since the Compilation Process can be
+understood as starting with the output of the generators or
+preprocessors.
+
+A Compilation Process is "Eligible" if it is done using GCC, alone or
+with other GPL-compatible software, or if it is done without using any
+work based on GCC. For example, using non-GPL-compatible Software to
+optimize any GCC intermediate representations would not qualify as an
+Eligible Compilation Process.
+
+1. Grant of Additional Permission.
+
+You have permission to propagate a work of Target Code formed by
+combining the Runtime Library with Independent Modules, even if such
+propagation would otherwise violate the terms of GPLv3, provided that
+all Target Code was generated by Eligible Compilation Processes. You
+may then convey such a combination under terms of your choice,
+consistent with the licensing of the Independent Modules.
+
+2. No Weakening of GCC Copyleft.
+
+The availability of this Exception does not imply any general
+presumption that third-party software is unaffected by the copyleft
+requirements of the license of GCC.
+
+----
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>. \ No newline at end of file
diff --git a/tools/wheels/cibw_before_build.sh b/tools/wheels/cibw_before_build.sh
index 36410ba1f..6da6434b7 100644
--- a/tools/wheels/cibw_before_build.sh
+++ b/tools/wheels/cibw_before_build.sh
@@ -1,24 +1,31 @@
set -xe
PROJECT_DIR="$1"
-UNAME="$(uname)"
# Update license
-if [[ $UNAME == "Linux" ]] ; then
+# TODO: Add in License for Windows
+if [[ $RUNNER_OS == "Linux" ]] ; then
cat $PROJECT_DIR/tools/wheels/LICENSE_linux.txt >> $PROJECT_DIR/LICENSE.txt
-elif [[ $UNAME == "Darwin" ]]; then
+elif [[ $RUNNER_OS == "macOS" ]]; then
cat $PROJECT_DIR/tools/wheels/LICENSE_osx.txt >> $PROJECT_DIR/LICENSE.txt
+elif [[ $RUNNER_OS == "Windows" ]]; then
+ cat $PROJECT_DIR/tools/wheels/LICENSE_win32.txt >> $PROJECT_DIR/LICENSE.txt
fi
# Install Openblas
-if [[ $UNAME == "Linux" || $UNAME == "Darwin" ]] ; then
+if [[ $RUNNER_OS == "Linux" || $RUNNER_OS == "macOS" ]] ; then
basedir=$(python tools/openblas_support.py)
cp -r $basedir/lib/* /usr/local/lib
cp $basedir/include/* /usr/local/include
+elif [[ $RUNNER_OS == "Windows" ]]; then
+ PYTHONPATH=tools python -c "import openblas_support; openblas_support.make_init('numpy')"
+ target=$(python tools/openblas_support.py)
+ mkdir -p openblas
+ cp $target openblas
fi
# Install GFortran
-if [[ $UNAME == "Darwin" ]]; then
+if [[ $RUNNER_OS == "macOS" ]]; then
# same version of gfortran as the openblas-libs and numpy-wheel builds
curl -L https://github.com/MacPython/gfortran-install/raw/master/archives/gfortran-4.9.0-Mavericks.dmg -o gfortran.dmg
GFORTRAN_SHA256=$(shasum -a 256 gfortran.dmg)
diff --git a/tools/wheels/cibw_test_command.sh b/tools/wheels/cibw_test_command.sh
index f09395e84..ef67172d8 100644
--- a/tools/wheels/cibw_test_command.sh
+++ b/tools/wheels/cibw_test_command.sh
@@ -4,10 +4,14 @@
set -xe
PROJECT_DIR="$1"
-UNAME="$(uname)"
python -c "import numpy; numpy.show_config()"
-python -c "import sys; import numpy; sys.exit(not numpy.test('full', extra_argv=['-vv']))"
+if [[ $RUNNER_OS == "Windows" ]]; then
+ # GH 20391
+ PY_DIR=$(python -c "import sys; print(sys.prefix)")
+ mkdir $PY_DIR/libs
+fi
+python -c "import sys; import numpy; sys.exit(not numpy.test('full', extra_argv=['-v']))"
python $PROJECT_DIR/tools/wheels/check_license.py
if [[ $UNAME == "Linux" || $UNAME == "Darwin" ]] ; then