Skip to content

Commit

Permalink
Merge branch 'main' into real-imag-remove
Browse files Browse the repository at this point in the history
  • Loading branch information
lysnikolaou committed Jul 31, 2023
2 parents 530cbc5 + 8bbfa6d commit 2665d56
Show file tree
Hide file tree
Showing 50 changed files with 494 additions and 617 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
. venv/bin/activate
pip install --progress-bar=off -r test_requirements.txt
pip install --progress-bar=off -r doc_requirements.txt
pip install .
pip install . --config-settings=setup-args="-Dallow-noblas=true"
- run:
name: create release notes
Expand Down
28 changes: 20 additions & 8 deletions .cirrus.star
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,28 @@ def main(ctx):
# only contains the actual commit message on a non-PR trigger event.
# For a PR event it contains the PR title and description.
SHA = env.get("CIRRUS_CHANGE_IN_REPO")
url = "https://api.github.com/repos/scipy/scipy/git/commits/" + SHA
url = "https://api.github.com/repos/numpy/numpy/git/commits/" + SHA
dct = http.get(url).json()
# if "[wheel build]" in dct["message"]:
# return fs.read("ci/cirrus_wheels.yml")

if "[skip cirrus]" in dct["message"] or "[skip ci]" in dct["message"]:
commit_msg = dct["message"]
if "[skip cirrus]" in commit_msg or "[skip ci]" in commit_msg:
return []

# add extra jobs to the cirrus run by += adding to config
config = fs.read("tools/ci/cirrus_wheels.yml")
config += fs.read("tools/ci/cirrus_macosx_arm64.yml")
wheel = False
labels = env.get("CIRRUS_PR_LABELS", "")
pr_number = env.get("CIRRUS_PR", "-1")
tag = env.get("CIRRUS_TAG", "")

return config
if "[wheel build]" in commit_msg:
wheel = True

# if int(pr_number) > 0 and ("14 - Release" in labels or "36 - Build" in labels):
# wheel = True

if tag.startswith("v") and "dev0" not in tag:
wheel = True

if wheel:
return fs.read("tools/ci/cirrus_wheels.yml")

return fs.read("tools/ci/cirrus_macosx_arm64.yml")
6 changes: 2 additions & 4 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Intel SDE
run: |
curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/751535/sde-external-9.14.0-2022-10-25-lin.tar.xz
curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/784319/sde-external-9.24.0-2023-07-13-lin.tar.xz
mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/
sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde
- name: Install dependencies
Expand All @@ -440,8 +440,6 @@ jobs:
python -c "import numpy as np; np.show_config()"
# Run only a few tests, running everything in an SDE takes a long time
# Using pytest directly, unable to use python runtests.py -n -t ...
# Disabled running in the SDE because of an SDE bug
- name: Run linalg/ufunc/umath tests
run: |
python -m pytest numpy/core/tests/test_umath* numpy/core/tests/test_ufunc.py numpy/linalg/tests/test_*
#sde -spr -- python -m pytest numpy/core/tests/test_umath* numpy/core/tests/test_ufunc.py numpy/linalg/tests/test_*
sde -spr -- python -m pytest numpy/core/tests/test_umath* numpy/core/tests/test_ufunc.py numpy/linalg/tests/test_*
5 changes: 3 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ jobs:
python-version: "3.9"
- name: Build sdist
run: |
python setup.py sdist
python -m pip install -U pip build
python -m build --sdist -Csetup-args=-Dallow-noblas=true
- name: Test the sdist
run: |
# TODO: Don't run test suite, and instead build wheels from sdist
# Depends on pypa/cibuildwheel#1020
python -m pip install dist/*.gz
python -m pip install dist/*.gz -Csetup-args=-Dallow-noblas=true
pip install ninja
pip install -r test_requirements.txt
cd .. # Can't import numpy within numpy src directory
Expand Down
41 changes: 38 additions & 3 deletions .github/workflows/windows_meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ permissions:
contents: read # to fetch code (actions/checkout)

jobs:
meson:
name: Meson windows build/test
msvc_64bit_python_openblas:
name: MSVC, x86-64, LP64 OpenBLAS
runs-on: windows-2019
# if: "github.repository == 'numpy/numpy'"
if: "github.repository == 'numpy/numpy'"
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
Expand Down Expand Up @@ -86,3 +86,38 @@ jobs:
echo "LASTEXITCODE is '$LASTEXITCODE'"
python -c "import numpy, sys; sys.exit(numpy.test(verbose=3) is False)"
echo "LASTEXITCODE is '$LASTEXITCODE'"
msvc_32bit_python_openblas:
name: MSVC, 32-bit Python, no BLAS
runs-on: windows-2019
if: "github.repository == 'numpy/numpy'"
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
submodules: recursive
fetch-depth: 0

- name: Setup Python (32-bit)
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: '3.10'
architecture: 'x86'

- name: Setup MSVC (32-bit)
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
with:
architecture: 'x86'

- name: Build and install
run: |
python -m pip install . -v -Ccompile-args="-j2" -Csetup-args="-Dallow-noblas=true"
- name: Install test dependencies
run: |
python -m pip install -r test_requirements.txt
- name: Run test suite (fast)
run: |
cd tools
python -m pytest --pyargs numpy -m "not slow" -n2
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ stages:
TEST_MODE: fast
BITS: 64
NPY_USE_BLAS_ILP64: '1'
# Broken - it builds but _multiarray_umath doesn't import - needs investigating
DISABLE_BLAS: '1'

steps:
- template: azure-steps-windows.yml
Expand Down
17 changes: 12 additions & 5 deletions azure-steps-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,33 @@ steps:
mkdir C:/opt/openblas/openblas_dll
mkdir C:/opt/32/lib/pkgconfig
mkdir C:/opt/64/lib/pkgconfig
# TBD: support 32 bit testing
$target=$(python -c "import tools.openblas_support as obs; plat=obs.get_plat(); ilp64=obs.get_ilp64(); target=f'openblas_{plat}.zip'; obs.download_openblas(target, plat, ilp64);print(target)")
unzip -o -d c:/opt/ $target
echo "##vso[task.setvariable variable=PKG_CONFIG_PATH]c:/opt/64/lib/pkgconfig"
copy C:/opt/64/bin/*.dll C:/opt/openblas/openblas_dll
displayName: 'Download / Install OpenBLAS'

- powershell: |
# Note: ensure the `pip install .` command remains the last one here, to
# avoid "green on failure" issues
python -c "from tools import openblas_support; openblas_support.make_init('numpy')"
If ( Test-Path env:NPY_USE_BLAS_ILP64 ) {
python -m pip install . -Csetup-args="--vsenv" -Csetup-args="-Duse-ilp64=true" -Csetup-args="-Dblas-symbol-suffix=64_"
If ( Test-Path env:DISABLE_BLAS ) {
python -m pip install . -v -Csetup-args="--vsenv" -Csetup-args="-Dblas=none" -Csetup-args="-Dlapack=none" -Csetup-args="-Dallow-noblas=true"
}
elseif ( Test-Path env:NPY_USE_BLAS_ILP64 ) {
python -m pip install . -v -Csetup-args="--vsenv" -Csetup-args="-Duse-ilp64=true" -Csetup-args="-Dblas-symbol-suffix=64_"
} else {
python -m pip install . -Csetup-args="--vsenv"
python -m pip install . -v -Csetup-args="--vsenv"
}
displayName: 'Build NumPy'

- powershell: |
# copy from c:/opt/openblas/openblas_dll to numpy/.libs to ensure it can
# get loaded when numpy is imported (no RPATH on Windows)
$target = $(python -c "import sysconfig; print(sysconfig.get_path('platlib'))")
mkdir $target/numpy/.libs
copy C:/opt/openblas/openblas_dll/*.dll $target/numpy/.libs
displayName: 'Build NumPy'
displayName: 'Copy OpenBLAS DLL to site-packages'

- script: |
python -m pip install threadpoolctl
Expand Down
19 changes: 11 additions & 8 deletions doc/neps/nep-0053-c-abi-evolution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,14 @@ Cython users may use the NumPy C-API via ``cimport numpy as cnp``.
Due to the uncertainty of Cython development, there are two scenarios for
impact on Cython users.

If Cython 3 can be relied on, Cython users would be impacted *less* then C-API
If Cython 3 can be relied on, Cython users would be impacted *less* than C-API
users, because Cython 3 allows us to hide struct layout changes (i.e. changes
to ``PyArray_Descr``).
If this is not the case and we must support Cython 2.x, then Cython users
will also have to use a function/macro like ``PyDataType_ITEMSIZE()`` (or
use the Python object). This is unfortunately less typical in Cython code,
but also unlikely to be a common pattern for dtype struct fields/attributes.
If this is not the case and we must support Cython 0.29.x (which is the historic branch
before Cython 3), then Cython users will also have to use a function/macro like
``PyDataType_ITEMSIZE()`` (or use the Python object). This is unfortunately less
typical in Cython code, but also unlikely to be a common pattern for dtype struct
fields/attributes.

A further impact is that some future API additions such as new classes may
need to placed in a distinct ``.pyd`` file to avoid Cython generating code
Expand All @@ -199,7 +200,7 @@ is missing.

Some new API can be backported
-------------------------------
One large advantage of allowing users to compile with the newst version of
One large advantage of allowing users to compile with the newest version of
NumPy is that in some cases we will be able to backport new API.
Some new API functions can be written in terms of old ones or included
directly.
Expand Down Expand Up @@ -229,7 +230,7 @@ An implementation can be found in the `PR 23528`_.
The second part is mainly about identifying and implementing the desired
changes in a way that backwards compatibility will not be broken and API
breaks remain manageable for downstream libraries.
Everyone change we do must have a brief note on how to adapt to the
Every change we do must have a brief note on how to adapt to the
API change (i.e. alternative functions).

NumPy 2 compatibility and API table changes
Expand All @@ -239,12 +240,13 @@ NumPy 1.x (a table is a list of functions and symbols).

For compatibility we would need to translate the 1.x table to the 2.0 table.
This could be done in headers only in theory, but this seems unwieldy.
We thus propose to add a ``numpy2_compat`` package. This packages main
We thus propose to add a ``numpy2_compat`` package. This package's main
purpose would be to provide a translation of the 1.x table to the 2.x one
in a single place (filling in any necessary blanks).

Introducing this package solves the "transition" issue because it allows
a user to:

* Install a SciPy version that is compatible with 2.0 and 1.x
* and keep using NumPy 1.x because of other packages they are using are not
yet compatible.
Expand Down Expand Up @@ -278,6 +280,7 @@ Backward compatibility
======================

As mentioned above backwards compatibility is achieved by:

1. Forcing downstream to recompile with NumPy 2.0
2. Providing a ``numpy2_compat`` library.

Expand Down
7 changes: 7 additions & 0 deletions doc/release/upcoming_changes/24144.python_removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* ``np.cast`` has been removed. The literal replacement for
``np.cast[dtype](arg)`` is ``np.asarray(arg, dtype=dtype)``.

* ``np.source`` has been removed. The preferred replacement is
``inspect.getsource``.

* ``np.lookfor`` has been removed.
3 changes: 3 additions & 0 deletions doc/release/upcoming_changes/24271.c_api_removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* The ``legacy_inner_loop_selector`` member of the ufunc struct is removed
to simplify improvements to the dispatching system.
There are no known users overriding or directly accessing this member.
4 changes: 2 additions & 2 deletions doc/source/reference/c-api/array.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1630,8 +1630,8 @@ Conversion
<https://docs.python.org/3/c-api/intro.html?reference-count-details>`_
to `PyArray_Descr` and returns a new array of the given `dtype` using
the data in the current array at a specified `offset` in bytes. The
`offset` plus the itemsize of the new array type must be less than ``self
->descr->elsize`` or an error is raised. The same shape and strides
`offset` plus the itemsize of the new array type must be less than
``self->descr->elsize`` or an error is raised. The same shape and strides
as the original array are used. Therefore, this function has the
effect of returning a field from a structured array. But, it can also
be used to select specific bytes or groups of bytes from any array
Expand Down
19 changes: 1 addition & 18 deletions doc/source/reference/c-api/types-and-structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,8 @@ PyUFunc_Type and PyUFuncObject
int *core_offsets;
char *core_signature;
PyUFunc_TypeResolutionFunc *type_resolver;
PyUFunc_LegacyInnerLoopSelectionFunc *legacy_inner_loop_selector;
void *reserved2;
void *reserved3;
npy_uint32 *op_flags;
npy_uint32 *iter_flags;
/* new in API version 0x0000000D */
Expand Down Expand Up @@ -890,10 +890,6 @@ PyUFunc_Type and PyUFuncObject
specifies how many different 1-d loops (of the builtin data
types) are available.
.. c:member:: int reserved1
Unused.
.. c:member:: char *name
A string name for the ufunc. This is used dynamically to build
Expand Down Expand Up @@ -966,19 +962,6 @@ PyUFunc_Type and PyUFuncObject
A function which resolves the types and fills an array with the dtypes
for the inputs and outputs
.. c:member:: PyUFunc_LegacyInnerLoopSelectionFunc *legacy_inner_loop_selector
.. deprecated:: 1.22
Some fallback support for this slot exists, but will be removed
eventually. A universal function that relied on this will
have to be ported eventually.
See :ref:`NEP 41 <NEP41>` and :ref:`NEP 43 <NEP43>`
.. c:member:: void *reserved2
For a possible future loop selector with a different signature.
.. c:member:: npy_uint32 op_flags
Override the default operand flags for each ufunc operand.
Expand Down
13 changes: 0 additions & 13 deletions doc/source/reference/routines.help.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,7 @@ NumPy-specific help functions

.. currentmodule:: numpy

Finding help
------------

.. autosummary::
:toctree: generated/

lookfor


Reading help
------------

.. autosummary::
:toctree: generated/

info
source
12 changes: 6 additions & 6 deletions doc/source/user/basics.dispatch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ For this example we will only handle the method ``__call__``
... elif isinstance(input, self.__class__):
... scalars.append(input._i)
... if N is not None:
... if N != self._N:
... if N != input._N:
... raise TypeError("inconsistent sizes")
... else:
... N = self._N
... N = input._N
... else:
... return NotImplemented
... return self.__class__(N, ufunc(*scalars, **kwargs))
Expand Down Expand Up @@ -147,10 +147,10 @@ conveniently by inheriting from the mixin
... elif isinstance(input, self.__class__):
... scalars.append(input._i)
... if N is not None:
... if N != self._N:
... if N != input._N:
... raise TypeError("inconsistent sizes")
... else:
... N = self._N
... N = input._N
... else:
... return NotImplemented
... return self.__class__(N, ufunc(*scalars, **kwargs))
Expand Down Expand Up @@ -186,10 +186,10 @@ functions to our custom variants.
... elif isinstance(input, self.__class__):
... scalars.append(input._i)
... if N is not None:
... if N != self._N:
... if N != input._N:
... raise TypeError("inconsistent sizes")
... else:
... N = self._N
... N = input._N
... else:
... return NotImplemented
... return self.__class__(N, ufunc(*scalars, **kwargs))
Expand Down
14 changes: 7 additions & 7 deletions doc/source/user/how-to-index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ 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]))
>>> 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::
Expand Down
Loading

0 comments on commit 2665d56

Please sign in to comment.