Skip to content

Commit 01cd836

Browse files
authored
Merge branch 'main' into numpygh-29824-vectorize-signature-fix
2 parents 45e59f4 + 39e3c56 commit 01cd836

71 files changed

Lines changed: 1187 additions & 983 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/codeql.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
# Initializes the CodeQL tools for scanning.
4949
- name: Initialize CodeQL
50-
uses: github/codeql-action/init@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
50+
uses: github/codeql-action/init@16140ae1a102900babc80a33c44059580f687047 # v4.30.9
5151
with:
5252
languages: ${{ matrix.language }}
5353
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -57,7 +57,7 @@ jobs:
5757
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5858
# If this step fails, then you should remove it and run the build manually (see below)
5959
- name: Autobuild
60-
uses: github/codeql-action/autobuild@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
60+
uses: github/codeql-action/autobuild@16140ae1a102900babc80a33c44059580f687047 # v4.30.9
6161

6262
# ℹ️ Command-line programs to run using the OS shell.
6363
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -70,6 +70,6 @@ jobs:
7070
# ./location_of_script_within_repo/buildscript.sh
7171

7272
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
73+
uses: github/codeql-action/analyze@16140ae1a102900babc80a33c44059580f687047 # v4.30.9
7474
with:
7575
category: "/language:${{matrix.language}}"

‎.github/workflows/macos.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ jobs:
115115
build_runner:
116116
- [ macos-15-intel, "macos_x86_64" ]
117117
- [ macos-14, "macos_arm64" ]
118-
version: ["3.11", "3.14t-dev"]
118+
version: ["3.11", "3.14t"]
119119

120120
steps:
121121
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -144,4 +144,11 @@ jobs:
144144
spin build -- -Duse-ilp64=true -Ddisable-optimization=true -Dallow-noblas=false
145145
146146
- name: Test (fast tests)
147+
if: ${{ matrix.version != '3.14t' || matrix.build_runner[0] != 'macos-14' }}
147148
run: spin test -j2 -- --timeout=600 --durations=10
149+
150+
- name: Test in multiple threads
151+
if: ${{ matrix.version == '3.14t' && matrix.build_runner[0] == 'macos-14' }}
152+
run: |
153+
pip install pytest-run-parallel==0.7.0
154+
spin test -p 4 -- --timeout=600 --durations=10

‎.github/workflows/mypy.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
submodules: recursive
5959
fetch-tags: true
6060
persist-credentials: false
61-
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
61+
- uses: astral-sh/setup-uv@2ddd2b9cb38ad8efd50337e8ab201519a34c9f24 # v7.1.1
6262
with:
6363
python-version: ${{ matrix.os_python[1] }}
6464
activate-environment: true

‎.github/workflows/scorecards.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ jobs:
5050

5151
# Upload the results to GitHub's code scanning dashboard.
5252
- name: "Upload to code-scanning"
53-
uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v2.1.27
53+
uses: github/codeql-action/upload-sarif@16140ae1a102900babc80a33c44059580f687047 # v2.1.27
5454
with:
5555
sarif_file: results.sarif

‎.spin/cmds.py‎

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,24 @@ def docs(*, parent_callback, **kwargs):
141141
default=default,
142142
help="Run tests with the given markers"
143143
)
144+
@click.option(
145+
"-p",
146+
"--parallel-threads",
147+
metavar='PARALLEL_THREADS',
148+
default="1",
149+
help="Run tests many times in number of parallel threads under pytest-run-parallel."
150+
" Can be set to `auto` to use all cores. Use `spin test -p <number> -- "
151+
"--skip-thread-unsafe=true` to only run tests that can run in parallel. "
152+
"pytest-run-parallel must be installed to use."
153+
)
144154
@spin.util.extend_command(spin.cmds.meson.test)
145-
def test(*, parent_callback, pytest_args, tests, markexpr, **kwargs):
155+
def test(*, parent_callback, pytest_args, tests, markexpr, parallel_threads, **kwargs):
146156
"""
147157
By default, spin will run `-m 'not slow'`. To run the full test suite, use
148158
`spin test -m full`
159+
160+
When pytest-run-parallel is avaliable, use `spin test -p auto` or
161+
`spin test -p <num_of_threads>` to run tests sequentional in parallel threads.
149162
""" # noqa: E501
150163
if (not pytest_args) and (not tests):
151164
pytest_args = ('--pyargs', 'numpy')
@@ -154,6 +167,9 @@ def test(*, parent_callback, pytest_args, tests, markexpr, **kwargs):
154167
if markexpr != "full":
155168
pytest_args = ('-m', markexpr) + pytest_args
156169

170+
if parallel_threads != "1":
171+
pytest_args = ('--parallel-threads', parallel_threads) + pytest_args
172+
157173
kwargs['pytest_args'] = pytest_args
158174
parent_callback(**{'pytest_args': pytest_args, 'tests': tests, **kwargs})
159175

@@ -521,6 +537,46 @@ def mypy(ctx):
521537
ctx.forward(test)
522538

523539

540+
@click.command()
541+
@click.option(
542+
'--concise',
543+
is_flag=True,
544+
default=False,
545+
help="Concise output format",
546+
)
547+
@meson.build_dir_option
548+
def stubtest(*, concise: bool, build_dir: str) -> None:
549+
"""🧐 Run stubtest on NumPy's .pyi stubs
550+
551+
Requires mypy to be installed
552+
"""
553+
click.get_current_context().invoke(build)
554+
meson._set_pythonpath(build_dir)
555+
print(f"{build_dir = !r}")
556+
557+
import sysconfig
558+
purellib = sysconfig.get_paths()["purelib"]
559+
print(f"{purellib = !r}")
560+
561+
stubtest_dir = curdir.parent / 'tools' / 'stubtest'
562+
mypy_config = stubtest_dir / 'mypy.ini'
563+
allowlists = [stubtest_dir / 'allowlist.txt']
564+
if sys.version_info >= (3, 12):
565+
allowlists.append(stubtest_dir / 'allowlist_py312.txt')
566+
567+
cmd = [
568+
'stubtest',
569+
'--ignore-disjoint-bases',
570+
f'--mypy-config-file={mypy_config}',
571+
*(f'--allowlist={allowlist}' for allowlist in allowlists),
572+
]
573+
if concise:
574+
cmd.append('--concise')
575+
cmd.append('numpy')
576+
577+
spin.util.run(cmd)
578+
579+
524580
@click.command(context_settings={
525581
'ignore_unknown_options': True
526582
})

‎doc/TESTS.rst‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ Testing a subset of NumPy::
7474

7575
For detailed info on testing, see :ref:`testing-builds`
7676

77+
Running tests in multiple threads
78+
---------------------------------
79+
80+
To help with stress testing NumPy for thread safety, the test suite can be run under
81+
`pytest-run-parallel`_. To install ``pytest-run-parallel``::
82+
83+
$ pip install pytest-run-parallel
84+
85+
To run the test suite in multiple threads::
86+
87+
$ spin test -p auto # have pytest-run-parallel detect the number of available cores
88+
$ spin test -p 4 # run each test under 4 threads
89+
$ spin test -p auto -- --skip-thread-unsafe=true # run ONLY tests that are thread-safe
90+
91+
When you write new tests (see below), it is worth testing to make sure they do not fail
92+
under ``pytest-run-parallel``, since the CI jobs makes use of it.
7793

7894
Running doctests
7995
----------------
@@ -406,3 +422,4 @@ Documentation for ``numpy.test``
406422
.. _Hypothesis: https://hypothesis.readthedocs.io/en/latest/
407423
.. _vscode: https://code.visualstudio.com/docs/python/testing#_enable-a-test-framework
408424
.. _pycharm: https://www.jetbrains.com/help/pycharm/testing-your-first-python-application.html
425+
.. _pytest-run-parallel: https://github.com/Quansight-Labs/pytest-run-parallel
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Removed ``fix_imports`` parameter from ``numpy.save``
2+
-----------------------------------------------------
3+
4+
The ``fix_imports`` parameter was deprecated in NumPy 2.1.0 and is now removed.
5+
This flag has been ignored since NumPy 1.17 and was only needed to support loading files in Python 2 that were written in Python 3.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Remove ``delimitor`` parameter from ``numpy.ma.mrecords.fromtextfile()``
2+
------------------------------------------------------------------------
3+
4+
The ``delimitor`` parameter was deprecated in NumPy 1.22.0 and has been
5+
removed from ``numpy.ma.mrecords.fromtextfile()``. Use ``delimiter`` instead.

‎doc/source/dev/development_environment.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ one of::
9292
$ spin test -v
9393
$ spin test numpy/random # to run the tests in a specific module
9494
$ spin test -v -t numpy/_core/tests/test_nditer.py::test_iter_c_order
95+
$ spin test -p auto # to run tests in parallel threads using pytest-run-parallel
9596

9697
This builds NumPy first, so the first time it may take a few minutes.
9798

‎doc/source/user/basics.subclassing.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ which inputs and outputs it converted. Hence, e.g.,
567567
Note that another approach would be to use ``getattr(ufunc,
568568
methods)(*inputs, **kwargs)`` instead of the ``super`` call. For this example,
569569
the result would be identical, but there is a difference if another operand
570-
also defines ``__array_ufunc__``. E.g., lets assume that we evaluate
570+
also defines ``__array_ufunc__``. E.g., let's assume that we evaluate
571571
``np.add(a, b)``, where ``b`` is an instance of another class ``B`` that has
572572
an override. If you use ``super`` as in the example,
573573
``ndarray.__array_ufunc__`` will notice that ``b`` has an override, which

0 commit comments

Comments
 (0)