Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: stats: test marray support for hypothesis tests #118

Open
wants to merge 73 commits into
base: marray_gmean
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
4514296
BUG: fix `minimize` with fixed bounds and callback
yuzie007 Sep 10, 2024
cc6131d
MAINT: stats.dirichlet_multinomial relax n to >= 0
j-towns Oct 10, 2024
6e7767b
ENH: use workers for approx_derivative
andyfaff Dec 20, 2024
2417738
ENH: approx_derivative workers
andyfaff Dec 20, 2024
de51865
ENH: approx_derivative workers
andyfaff Dec 20, 2024
ca0cfb7
MAINT: cruft cleanup
andyfaff Dec 20, 2024
f819e92
MAINT: rename stray variable
andyfaff Dec 20, 2024
c7799f9
MAINT: mypy gremlins
andyfaff Dec 20, 2024
a0394f0
MAINT: parallelise sparse difference
andyfaff Dec 20, 2024
4b3197e
TST: add tests for workers in approx_derivative
andyfaff Dec 20, 2024
35f3ec1
ENH: modify ScalarFunction for workers
andyfaff Dec 21, 2024
a80643b
TST: multiprocess worker example
andyfaff Dec 22, 2024
c3b5746
MAINT: track nfev for parallelised approx_derivative
andyfaff Dec 22, 2024
6c96052
MAINT: HessWrapper with approx_derivative
andyfaff Dec 22, 2024
32b49c2
MAINT: use MapWrapper
andyfaff Dec 24, 2024
90f1ea3
DOC: give example of parallel calc approx_derivative
andyfaff Dec 24, 2024
c81131e
MAINT: fix default workers argument
andyfaff Dec 24, 2024
e91448c
ENH: apply workers kwd to _minimize_lbfgsb
andyfaff Dec 24, 2024
8d7afb4
TST: fix a test
andyfaff Dec 24, 2024
4175488
TST: speed up some tests
andyfaff Dec 25, 2024
8caf388
TST equal bounds
andyfaff Dec 25, 2024
3dd2aea
DOC: amend docstrings
andyfaff Dec 25, 2024
5246a7f
TST: mark workers test as slow
andyfaff Dec 25, 2024
cd49c26
TST fix import
andyfaff Dec 25, 2024
fd88228
MAINT: remove print, lengthen time
andyfaff Dec 25, 2024
d374d4f
MAINT: lengthen time for correct test this time
andyfaff Dec 25, 2024
81a63d3
TST: make test name more explicit
andyfaff Jan 13, 2025
ce60d5a
TST: compare parallel to serial minimize
andyfaff Jan 13, 2025
f7c35b3
Merge branch 'main' into approx_deriv
andyfaff Jan 14, 2025
5ab8d91
MAINT: address review comments
andyfaff Jan 15, 2025
800c663
TST: slow test
andyfaff Jan 15, 2025
afd730e
BENCH:Yen: Introduce `yen` algorithm benchmark
tsery-ns Dec 31, 2024
5cfda31
ENH:Yen: Store found paths in a sorted vector.
tsery-ns Dec 31, 2024
7c3628d
ENH:Yen: Introduce Lawler's modification.
tsery-ns Jan 6, 2025
38febf8
TST: YEN: add dense test
tsery-ns Jan 20, 2025
fe89009
Merge pull request #21684 from j-towns/relax-dm-constraint
mdhaber Jan 31, 2025
e3c6a05
ENH: linalg: wrap ?stevd (#22426)
j-bowhay Jan 31, 2025
fe49d27
DOC: optimize.elementwise.find_minimum: fix documented termination co…
mdhaber Jan 31, 2025
e16c6bb
ENH: signal.vectorstrength: add array API standard support (#22008)
ev-br Feb 1, 2025
36291dc
DOC: Improve docstrs of `dlsim`, `dimpulse`, `dstep`, `dfreqresp` and…
DietBru Feb 1, 2025
0196ab0
ENH: stats.gstd: add array API support (#22455)
mdhaber Feb 2, 2025
7174af2
TST: sparse: add tests for subscriptable types
zitongzhoueric Feb 2, 2025
8724147
BUG: signal.ShortTimeFFT: make attributes `win` and `dual_win` immuta…
DietBru Feb 2, 2025
088174d
DOC: outline workers in optimize tutorial
andyfaff Feb 3, 2025
52c4473
DOC: workers
andyfaff Feb 3, 2025
244fa93
DOC: workers
andyfaff Feb 3, 2025
a6cb7a7
add single type parameter tests for sparray
zitongzhoueric Feb 3, 2025
5ac11a7
Merge pull request #22457 from anonymouspenguin1024/test_sparse__subs…
tylerjereddy Feb 4, 2025
232e5f1
DOC: workers
andyfaff Feb 4, 2025
eecc6da
ENH: stats.pearsonr: two simple (but substantial) efficiency improvem…
mdhaber Feb 4, 2025
4741896
Merge pull request #22330 from tsery-ns/sery/enh_yen
Kai-Striega Feb 4, 2025
59157e3
DOC: stats: update Halton docs (#22463)
tupui Feb 4, 2025
a3d299f
MAINT/TST: address nits from Dask PR (#22467)
lucascolley Feb 4, 2025
76acada
DOC: Prevent A@x=b from becoming a URL (#22464)
star1327p Feb 5, 2025
4ca431d
DOC: address vectorization feedback
andyfaff Feb 5, 2025
1e688e2
Merge pull request #22141 from andyfaff/approx_deriv
andyfaff Feb 5, 2025
f63bd3c
Merge branch 'main' into l-bfgs-b-with-fixed-bounds-and-callback
andyfaff Feb 5, 2025
4ae4626
MAINT: optimize callback with fixed variables
andyfaff Feb 6, 2025
24f31a7
Lint
andyfaff Feb 6, 2025
e93b70f
TST: move equal bounds callback test
andyfaff Feb 6, 2025
1e8e87a
TST: move equal bounds callback test
andyfaff Feb 6, 2025
1852f85
Merge pull request #21538 from yuzie007/l-bfgs-b-with-fixed-bounds-an…
andyfaff Feb 6, 2025
e7a789f
CI: use mpmath pre-release again (#22480)
mdhaber Feb 6, 2025
da0972c
MAINT: pearsonr SIMD-related shim
tylerjereddy Feb 6, 2025
771a1ec
MAINT: missing Cython type in build
tylerjereddy Feb 6, 2025
26a09b3
BUG: fix `make_lsq_spline` with a non-default axis (#22481)
ev-br Feb 6, 2025
656dfb5
Merge pull request #22482 from tylerjereddy/treddy_issue_22479
mdhaber Feb 6, 2025
cb1a1ef
Merge pull request #22483 from tylerjereddy/treddy_transform_missing_…
ev-br Feb 6, 2025
f33dbe0
DOC: optimize.rst, improve workers examples
andyfaff Feb 7, 2025
07eb0f4
Merge pull request #22486 from andyfaff/doc
andyfaff Feb 7, 2025
ab84560
MAINT: bump min NumPy to 1.25.2, min Python to 3.11 (#22012)
tylerjereddy Feb 7, 2025
3921d97
ENH: stats: support for array API compatible masked arrays (#22393)
mdhaber Feb 7, 2025
3daa871
ENH: stats: add marray support to most remaining array API functions
mdhaber Feb 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/array_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ jobs:
run: |
python -m pip install dask[array]

- name: Install MArray
run: |
python -m pip install marray

- name: Prepare compiler cache
id: prep-ccache
shell: bash
Expand Down
55 changes: 27 additions & 28 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: ./.github/workflows/commit_message.yml

test_meson:
name: mypy (py3.10) & dev deps (py3.13), fast, dev.py
name: mypy (py3.11) & dev deps (py3.13), fast, dev.py
needs: get_commit_message
# If using act to run CI locally the github object does not exist and
# the usual skipping should not be enforced
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.10', '3.13-dev'] # this run will use python dev versions when available
python-version: ['3.11', '3.13-dev'] # this run will use python dev versions when available
maintenance-branch:
- ${{ contains(github.ref, 'maintenance/') || contains(github.base_ref, 'maintenance/') }}
exclude:
Expand All @@ -63,7 +63,7 @@ jobs:
sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev gfortran libgmp-dev libmpfr-dev libsuitesparse-dev ccache libmpc-dev

- name: Install Python packages
if: matrix.python-version == '3.10'
if: matrix.python-version == '3.11'
run: |
python -m pip install numpy cython pytest pytest-xdist pytest-timeout pybind11 mpmath gmpy2 pythran ninja meson click rich-click doit pydevtool pooch hypothesis

Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
path: ${{ steps.prep-ccache.outputs.dir }}
# Restores ccache from either a previous build on this branch or on main
key: ${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-${{ steps.prep-ccache.outputs.timestamp }}
# This evaluates to `Linux Tests-3.10-ccache-linux-` which is not unique. As the CI matrix is expanded, this will
# This evaluates to `Linux Tests-3.11-ccache-linux-` which is not unique. As the CI matrix is expanded, this will
# need to be updated to be unique so that the cache is not restored from a different job altogether.
restore-keys: |
${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
run: ninja -C build -t missingdeps

- name: Mypy
if: matrix.python-version == '3.10'
if: matrix.python-version == '3.11'
run: |
# Packages that are only needed for their annotations
python -m pip install mypy==1.10.0 types-psutil typing_extensions
Expand All @@ -148,7 +148,7 @@ jobs:
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
Expand Down Expand Up @@ -202,12 +202,12 @@ jobs:
#################################################################################
python_debug:
# also uses the vcs->sdist->wheel route.
name: Python-debug & ATLAS & sdist+wheel, fast, py3.10/npMin, pip+pytest
name: Python-debug & ATLAS & sdist+wheel, fast, py3.12/npMin, pip+pytest
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-22.04 # provides python3.10-dbg
runs-on: ubuntu-24.04 # provides python3.12-dbg
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
Expand All @@ -232,7 +232,7 @@ jobs:
#################################################################################
gcc9:
# Purpose is to examine builds with oldest-supported gcc and test with pydata/sparse.
name: Oldest GCC & pydata/sparse, fast, py3.10/npMin, pip+pytest
name: Oldest GCC & pydata/sparse, fast, py3.11/npMin, pip+pytest
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
Expand All @@ -246,7 +246,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: "3.10"
python-version: "3.11"

- name: Setup system dependencies
run: |
Expand All @@ -271,7 +271,7 @@ jobs:
- name: Install test dependencies
run: |
# Downgrade numpy to oldest supported version
pip install gmpy2 threadpoolctl mpmath pooch pytest pytest-xdist==2.5.0 pytest-timeout hypothesis sparse "numpy==1.23.5"
pip install gmpy2 threadpoolctl mpmath pooch pytest pytest-xdist==2.5.0 pytest-timeout hypothesis sparse "numpy==1.25.2"

- name: Run tests
run: |
Expand All @@ -284,17 +284,17 @@ jobs:
#################################################################################
prerelease_deps_coverage_64bit_blas:
# TODO: re-enable ILP64 build.
name: Prerelease deps & coverage report, full, py3.10/npMin & py3.11/npPre, dev.py
name: Prerelease deps & coverage report, full, py3.11/npMin & py3.11/npPre, dev.py
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-latest
strategy:
matrix:
# Both use numpy 2.x-dev at build time; 3.10 job then downgrades to
# Both use numpy 2.x-dev at build time; 3.11 job then downgrades to
# lowest supported NumPy version in order to test ABI compatibility.
python-version: ['3.10', '3.11']
python-version: ['3.11', '3.12']

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -321,10 +321,7 @@ jobs:
- name: Install Python packages
run: |
python -m pip install cython pythran ninja meson-python pybind11 click rich_click pydevtool
python -m pip install --pre --upgrade pytest pytest-cov pytest-xdist gmpy2 threadpoolctl pooch hypothesis matplotlib
# Move mpmath back into `install --pre` above once mpmath 1.4.0 with
# the fix is out (xref gh-22395)
python -m pip install mpmath
python -m pip install --pre --upgrade pytest pytest-cov pytest-xdist mpmath gmpy2 threadpoolctl pooch hypothesis matplotlib
python -m pip install -r requirements/openblas.txt
# Install numpy last, to ensure we get nightly (avoid possible <2.0 constraints).
python -m pip install --pre --upgrade --timeout=60 -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
Expand Down Expand Up @@ -357,9 +354,9 @@ jobs:
run: ccache -s

- name: Downgrade NumPy from 2.0-dev to lowest supported
if: matrix.python-version == '3.10'
if: matrix.python-version == '3.11'
run: |
python -m pip install "numpy==1.23.5"
python -m pip install "numpy==1.25.2"

- name: Test SciPy
run: |
Expand All @@ -368,7 +365,7 @@ jobs:

#################################################################################
linux_32bit:
name: 32-bit, fast, py3.10/npMin, dev.py
name: 32-bit, fast, py3.11/npMin, dev.py
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
Expand All @@ -388,7 +385,7 @@ jobs:
docker pull quay.io/pypa/manylinux2014_i686
docker run -v $(pwd):/scipy --platform=linux/i386 quay.io/pypa/manylinux2014_i686 /bin/bash -c "cd /scipy && \
uname -a && \
python3.10 -m venv test && \
python3.11 -m venv test && \
source test/bin/activate && \
python -m pip install doit click rich_click pydevtool meson ninja && \
python -m pip install -r requirements/openblas.txt && \
Expand All @@ -401,7 +398,7 @@ jobs:
runtime_library_dirs = \$(python -c 'import scipy_openblas32; print(scipy_openblas32.get_lib_dir())')
symbol_prefix = scipy_
EOL
python -m pip install numpy==1.23.5 cython pybind11 pytest pytest-timeout pytest-xdist pytest-env 'Pillow<10.0.0' mpmath pythran pooch meson hypothesis && \
python -m pip install numpy==1.25.2 cython pybind11 pytest pytest-timeout pytest-xdist pytest-env 'Pillow<10.0.0' mpmath pythran pooch meson hypothesis && \
python -c 'import numpy as np; np.show_config()' && \
python dev.py build --with-scipy-openblas && \
python dev.py --no-build test"
Expand All @@ -411,12 +408,12 @@ jobs:
# Purpose is to build for a non-default Python interpreter in a Linux distro
# For such a build config, `python`/`python3` executables may not have
# build dependencies like Cython or NumPy installed.
name: non-default Python interpreter, fast, py3.10/npMin, pip+pytest
name: non-default Python interpreter, fast, py3.11/npMin, pip+pytest
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
&& (github.repository == 'scipy/scipy' || github.repository == '')
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
Expand All @@ -425,8 +422,10 @@ jobs:
- name: Setup system dependencies
run: |
sudo apt-get -y update
# `python3-dev` yields Python 3.10 on Ubuntu 22.04
sudo apt install -y python3-dev python3.11-dev ninja-build pkg-config libatlas-base-dev liblapack-dev
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update -y
sudo apt install -y python3.11-dev ninja-build pkg-config libatlas-base-dev liblapack-dev

- name: Setup Python build deps
run: |
Expand All @@ -440,7 +439,7 @@ jobs:
- name: Install test dependencies
run: |
python3.11 -m pip install pytest hypothesis
python3.10 -m pip install meson # ensure compile test work with this
python3.12 -m pip install meson # ensure compile test work with this

- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
with:
path: ${{ steps.prep-ccache.outputs.dir }}
key: ${{ github.workflow }}-${{ matrix.python-version }}-ccache-macos-${{ steps.prep-ccache.outputs.timestamp }}
# This evaluates to `macOS Tests-3.10-ccache-macos-` which is not
# This evaluates to `macOS Tests-3.11-ccache-macos-` which is not
# unique. As the CI matrix is expanded, this will need to be updated to
# be unique so that the cache is not restored from a different job altogether.
restore-keys: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/musllinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: ./.github/workflows/commit_message.yml

musllinux_x86_64:
name: musl Ubuntu-latest, fast, py3.10/npAny, dev.py
name: musl Ubuntu-latest, fast, py3.11/npAny, dev.py
needs: get_commit_message
runs-on: ubuntu-latest
# If using act to run CI locally the github object does not exist and
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
git -c user.email="you@example.com" merge --no-commit my_ref_name
fi

ln -s /usr/local/bin/python3.10 /usr/local/bin/python
ln -s /usr/local/bin/python3.11 /usr/local/bin/python
git submodule update --init


Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- [macos-14, macosx, arm64, openblas, "12.3"]
- [macos-14, macosx, arm64, accelerate, "14.0"]
- [windows-2019, win, AMD64, "", ""]
python: [["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"]]
python: [["cp311", "3.11"], ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"]]
# python[0] is used to specify the python versions made by cibuildwheel

env:
Expand Down Expand Up @@ -243,7 +243,7 @@ jobs:
# Note that this step is *after* specific pythons have been used to
# build and test the wheel
auto-update-conda: true
python-version: "3.10"
python-version: "3.11"
miniforge-version: latest
conda-remove-defaults: "true"

Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

#############################################################################
full_dev_py_min_numpy_fail_slow:
name: fail slow, full, py3.10/npMin, dev.py
name: fail slow, full, py3.11/npMin, dev.py
needs: get_commit_message
if: >
needs.get_commit_message.outputs.message == 1
Expand All @@ -79,7 +79,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.10'
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'environment.yml'

Expand All @@ -90,9 +90,8 @@ jobs:

- name: pip-packages
run: |
# 1.23.5 is currently the oldest numpy usable on cp3.10 according
# to pyproject.toml
python -m pip install numpy==1.23.5 cython pybind11 pythran meson-python meson ninja pytest pytest-xdist pytest-timeout pytest-fail-slow pooch rich_click click doit pydevtool hypothesis
# 1.25.2 is currently our oldest supported NumPy version
python -m pip install numpy==1.25.2 cython pybind11 pythran meson-python meson ninja pytest pytest-xdist pytest-timeout pytest-fail-slow pooch rich_click click doit pydevtool hypothesis
python -m pip install -r requirements/openblas.txt

- name: Build
Expand Down
38 changes: 38 additions & 0 deletions benchmarks/benchmarks/sparse_csgraph_yen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""benchmarks for the scipy.sparse.csgraph module"""
import numpy as np
import scipy.sparse

from .common import Benchmark, safe_import

with safe_import():
from scipy.sparse.csgraph import yen


class Yen(Benchmark):
params = [
[30, 300, 3000],
[10, 100, 300],
]
param_names = ['n', 'K']

def setup(self, n, K):
# make a random connectivity matrix
data = scipy.sparse.rand(
n, n, density=0.4, format='lil', random_state=42, dtype=np.bool_
)
data.setdiag(np.zeros(n, dtype=np.bool_))
self.data = data
self.source = np.random.randint(n)
sink = np.random.randint(n)
while self.source == sink:
sink = np.random.randint(n)
self.sink = sink

def time_yen(self, n, K):
yen(
csgraph=self.data,
source=self.source,
sink=self.sink,
K=K,
directed=False,
)
7 changes: 3 additions & 4 deletions dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def __init__(self, args=None):
self.installed = self.build.parent / (self.build.stem + "-install")

# relative path for site-package with py version
# i.e. 'lib/python3.10/site-packages'
# i.e. 'lib/python3.11/site-packages'
self.site = self.get_site_packages()

def add_sys_path(self):
Expand Down Expand Up @@ -1449,7 +1449,7 @@ class ShowDirs(Python):

PYTHONPATH sets the default search path for module files for the
interpreter. Here, it includes the path to the local SciPy build
(typically `.../build-install/lib/python3.10/site-packages`).
(typically `.../build-install/lib/python3.11/site-packages`).

Use the global option `-n` to skip the building step, e.g.:
`python dev.py -n show_PYTHONPATH`
Expand Down Expand Up @@ -1544,8 +1544,7 @@ def cpu_count(only_physical_cores=False):
or the LOKY_MAX_CPU_COUNT environment variable. If the number of physical
cores is not found, return the number of logical cores.

Note that on Windows, the returned number of CPUs cannot exceed 61 (or 60 for
Python < 3.10), see:
Note that on Windows, the returned number of CPUs cannot exceed 61, see:
https://bugs.python.org/issue26903.

It is also always larger or equal to 1.
Expand Down
Loading