8000 Merge branch 'main' into remove-set_string_function · numpy/numpy@6ff8609 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ff8609

Browse files
committed
Merge branch 'main' into remove-set_string_function
2 parents 2ad1c9d + 6f428f2 commit 6ff8609

File tree

93 files changed

+1956
-418
lines changed

Some content is hidden

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

93 files changed

+1956
-418
lines changed

.github/workflows/codeql.yml

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

4646
# Initializes the CodeQL tools for scanning.
4747
- name: Initialize CodeQL
48-
uses: github/codeql-action/init@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7
48+
uses: github/codeql-action/init@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
4949
with:
5050
languages: ${{ matrix.language }}
5151
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -55,7 +55,7 @@ jobs:
5555
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5656
# If this step fails, then you should remove it and run the build manually (see below)
5757
- name: Autobuild
58-
uses: github/codeql-action/autobuild@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7
58+
uses: github/codeql-action/autobuild@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
5959

6060
# ℹ️ Command-line programs to run using the OS shell.
6161
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -68,6 +68,6 @@ jobs:
6868
# ./location_of_script_within_repo/buildscript.sh
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7
71+
uses: github/codeql-action/analyze@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
7272
with:
7373
category: "/language:${{matrix.language}}"

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ jobs:
1717
- name: 'Checkout Repository'
1818
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
1919
- name: 'Dependency Review'
20-
uses: actions/dependency-review-action@0c155c5e8556a497adf53f2c18edabf945ed8e70 # v4.3.2
20+
uses: actions/dependency-review-action@72eb03d02c7872a771aacd928f3123ac62ad6d3a # v4.3.3

.github/workflows/free-threaded-wheels.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ jobs:
7676
buildplat:
7777
- [ubuntu-20.04, manylinux_x86_64, ""]
7878
- [ubuntu-20.04, musllinux_x86_64, ""]
79-
# TODO: build numpy and set up Windows and MacOS
80-
# cibuildwheel does not yet support Mac for free-threaded python
81-
# windows is supported but numpy doesn't build on the image yet
79+
- [macos-13, macosx_x86_64, openblas]
80+
# targeting macos >= 14. Could probably build on macos-14, but it would be a cross-compile
81+
- [macos-13, macosx_x86_64, accelerate]
82+
- [macos-14, macosx_arm64, accelerate] # always use accelerate
83+
# TODO: set up Windows wheels windows is supported on cibuildwheel but
84+
# numpy doesn't build on the image yet
8285
python: ["cp313t"]
8386
env:
8487
IS_32_BIT: ${{ matrix.buildplat[1] == 'win32' }}
@@ -134,7 +137,7 @@ jobs:
134137
fi
135138
136139
- name: Build wheels
137-
uses: pypa/cibuildwheel@ba8be0d98853f5744f24e7f902c8adef7ae2e7f3 # v2.18.1
140+
uses: pypa/cibuildwheel@932529cab190fafca8c735a551657247fa8f8eaf # v2.19.1
138141
env:
139142
CIBW_PRERELEASE_PYTHONS: True
140143
CIBW_FREE_THREADED_SUPPORT: True

.github/workflows/linux.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
pytest --pyargs numpy -m "not slow"
115115
116116
full:
117-
# Build a wheel, install it, then run the full test suite with code coverage
117+
# Install as editable, then run the full test suite with code coverage
118118
needs: [smoke_test]
119119
runs-on: ubuntu-22.04
120120
steps:
@@ -138,16 +138,14 @@ jobs:
138138
mkdir -p ./.openblas
139139
python -c"import scipy_openblas32 as ob32; print(ob32.get_pkg_config())" > ./.openblas/scipy-openblas.pc
140140
141-
- name: Build a wheel
141+
- name: Install as editable
142142
env:
143143
PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas
144144
run: |
145-
python -m build --wheel --no-isolation --skip-dependency-check
146-
pip install dist/numpy*.whl
145+
pip install -e . --no-build-isolation
147146
- name: Run full test suite
148147
run: |
149-
cd tools
150-
pytest --pyargs numpy --cov-report=html:build/coverage
148+
pytest numpy --cov-report=html:build/coverage
151149
# TODO: gcov
152150
153151
benchmark:
@@ -180,6 +178,11 @@ jobs:
180178
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
181179
run: |
182180
spin bench --quick
181+
- name: Check docstests
182+
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
183+
run: |
184+
pip install scipy-doctest hypothesis matplotlib scipy pytz
185+
spin check-docs -v
183186
184187
sdist:
185188
needs: [smoke_test]

.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@f079b8493333aace61c81488f8bd40919487bd9f # v2.1.27
53+
uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # v2.1.27
5454
with:
5555
sarif_file: results.sarif

.github/workflows/wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ jobs:
149149
fi
150150
151151
- name: Build wheels
152-
uses: pypa/cibuildwheel@ba8be0d98853f5744f24e7f902c8adef7ae2e7f3 # v2.18.1
152+
uses: pypa/cibuildwheel@932529cab190fafca8c735a551657247fa8f8eaf # v2.19.1
153153
env:
154154
CIBW_PRERELEASE_PYTHONS: True
155155
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}

.github/workflows/windows.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ jobs:
4848
- name: Install Clang-cl
4949
if: matrix.compiler == 'Clang-cl'
5050
run: |
51-
choco install llvm -y --version=16.0.6
51+
# llvm is preinstalled, but leave
52+
# this here in case we need to pin the
53+
# version at some point.
54+
#choco install llvm -y
5255
5356
- name: Install NumPy (MSVC)
5457
if: matrix.compiler == 'MSVC'

.spin/cmds.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ def docs(ctx, sphinx_target, clean, first_build, jobs, *args, **kwargs):
161161
"""
162162
meson.docs.ignore_unknown_options = True
163163

164+
# See https://github.com/scientific-python/spin/pull/199
165+
# Can be changed when spin updates to 0.11, and moved to pyproject.toml
166+
if clean:
167+
clean_dirs = [
168+
'./doc/build/',
169+
'./doc/source/reference/generated',
170+
'./doc/source/reference/random/bit_generators/generated',
171+
'./doc/source/reference/random/generated',
172+
]
173+
174+
for target_dir in clean_dirs:
175+
if os.path.isdir(target_dir):
176+
print(f"Removing {target_dir!r}")
177+
shutil.rmtree(target_dir)
178+
164179
# Run towncrier without staging anything for commit. This is the way to get
165180
# release notes snippets included in a local doc build.
166181
cmd = ['towncrier', 'build', '--version', '2.x.y', '--keep', '--draft']
@@ -258,6 +273,83 @@ def test(ctx, pytest_args, markexpr, n_jobs, tests, verbose, *args, **kwargs):
258273
ctx.forward(meson.test)
259274

260275

276+
@click.command()
277+
@click.argument("pytest_args", nargs=-1)
278+
@click.option(
279+
"-j",
280+
"n_jobs",
281+
metavar='N_JOBS',
282+
default="1",
283+
help=("Number of parallel jobs for testing. "
284+
"Can be set to `auto` to use all cores.")
285+
)
286+
@click.option(
287+
'--verbose', '-v', is_flag=True, default=False
288+
)
289+
@click.pass_context
290+
def check_docs(ctx, pytest_args, n_jobs, verbose, *args, **kwargs):
291+
"""🔧 Run doctests of objects in the public API.
292+
293+
PYTEST_ARGS are passed through directly to pytest, e.g.:
294+
295+
spin check-docs -- --pdb
296+
297+
To run tests on a directory:
298+
299+
\b
300+
spin check-docs numpy/linalg
301+
302+
To report the durations of the N slowest doctests:
303+
304+
spin check-docs -- --durations=N
305+
306+
To run doctests that match a given pattern:
307+
308+
\b
309+
spin check-docs -- -k "slogdet"
310+
spin check-docs numpy/linalg -- -k "det and not slogdet"
311+
312+
\b
313+
Note:
314+
-----
315+
316+
\b
317+
- This command only runs doctests and skips everything under tests/
318+
- This command only doctests public objects: those which are accessible
319+
from the top-level `__init__.py` file.
320+
321+
""" # noqa: E501
322+
try:
323+
# prevent obscure error later
324+
import scipy_doctest
325+
except ModuleNotFoundError as e:
326+
raise ModuleNotFoundError("scipy-doctest not installed") from e
327+
if (not pytest_args):
328+
pytest_args = ('numpy',)
329+
330+
if (n_jobs != "1") and ('-n' not in pytest_args):
331+
pytest_args = ('-n', str(n_jobs)) + pytest_args
332+
333+
if verbose:
334+
pytest_args = ('-v',) + pytest_args
335+
336+
# turn doctesting on:
337+
doctest_args = (
338+
'--doctest-modules',
339+
'--doctest-collect=api'
340+
)
341+
342+
pytest_args = pytest_args + doctest_args
343+
344+
ctx.params['pytest_args'] = pytest_args
345+
346+
for extra_param in ('n_jobs', 'verbose'):
347+
del ctx.params[extra_param]
348+
349+
ctx.forward(meson.test)
350+
351+
352+
261353
# From scipy: benchmarks/benchmarks/common.py
262354
def _set_mem_rlimit(max_mem=None):
263355
"""

benchmarks/benchmarks/bench_clip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class ClipFloat(Benchmark):
1111
]
1212

1313
def setup(self, dtype, size):
14-
rng = np.random.default_rng()
15-
self.array = rng.random(size=size).astype(dtype)
14+
rnd = np.random.RandomState(994584855)
15+
self.array = rnd.random(size=size).astype(dtype)
1616
self.dataout = np.full_like(self.array, 0.5)
1717

1818
def time_clip(self, dtype, size):
@@ -27,8 +27,8 @@ class ClipInteger(Benchmark):
2727
]
2828

2929
def setup(self, dtype, size):
30-
rng = np.random.default_rng()
31-
self.array = rng.integers(256, size=size, dtype=dtype)
30+
rnd = np.random.RandomState(1301109903)
31+
self.array = rnd.randint(256, size=size, dtype=dtype)
3232
self.dataout = np.full_like(self.array, 128)
3333

3434
def time_clip(self, dtype, size):

benchmarks/benchmarks/bench_creation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class MeshGrid(Benchmark):
1313
timeout = 10
1414

1515
def setup(self, size, ndims, ind, ndtype):
16-
self.grid_dims = [(np.random.ranf(size)).astype(ndtype) for
16+
rnd = np.random.RandomState(1864768776)
17+
self.grid_dims = [(rnd.random_sample(size)).astype(ndtype) for
1718
x in range(ndims)]
1819

1920
def time_meshgrid(self, size, ndims, ind, ndtype):

0 commit comments

Comments
 (0)
0