Describe your issue.
A regression seemingly introduced in 1.13. A 2D array with NaNs in some columns ValueErrors out as soon as it reaches a column with a NaN. It must be truly 2D, i.e. A.shape[1] > 1 is True. It also only occurs when there are more than 50 rows, i.e. A.shape[0] > 50.
Passing just that column with the NaNs, i.e. passing it as 1D, operates as expected. For example, stats.wilcoxon(A[:50,:] or stats.wilcoxon(A[:,1]) after the code example below runs fine.
Reproducing Code Example
from scipy import stats
import numpy as np
rng = np.random.default_rng(123)
A = rng.normal(size=(51,2))
A[5,1] = np.nan
stats.wilcoxon(A)
Error message
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/isilon/LFMI/VMdrive/Jonathan/PriorWeightingMooney/Visual/ECoG/Code/.venv/lib/python3.11/site-packages/scipy/_lib/_util.py", line 794, in wrapper
return fun(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/isilon/LFMI/VMdrive/Jonathan/PriorWeightingMooney/Visual/ECoG/Code/.venv/lib/python3.11/site-packages/scipy/stats/_axis_nan_policy.py", line 603, in axis_nan_policy_wrapper
res = np.apply_along_axis(hypotest_fun, axis=0, arr=x)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/isilon/LFMI/VMdrive/Jonathan/PriorWeightingMooney/Visual/ECoG/Code/.venv/lib/python3.11/site-packages/numpy/lib/shape_base.py", line 402, in apply_along_axis
buff[ind] = asanyarray(func1d(inarr_view[ind], *args, **kwargs))
~~~~^^^^^
ValueError: could not broadcast input array from shape (2,) into shape (3,)
SciPy/NumPy/Python version and system information
>>> import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info); scipy.show_config()
1.13.0 1.26.4 sys.version_info(major=3, minor=11, micro=5, releaselevel='final', serial=0)
Build Dependencies:
blas:
detection method: pkgconfig
found: true
include directory: /usr/local/include
lib directory: /usr/local/lib
name: openblas
openblas configuration: USE_64BITINT=0 DYNAMIC_ARCH=1 DYNAMIC_OLDER= NO_CBLAS=
NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP= ZEN MAX_THREADS=64
pc file directory: /usr/local/lib/pkgconfig
version: 0.3.26.dev
lapack:
detection method: pkgconfig
found: true
include directory: /usr/local/include
lib directory: /usr/local/lib
name: openblas
openblas configuration: USE_64BITINT=0 DYNAMIC_ARCH=1 DYNAMIC_OLDER= NO_CBLAS=
NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP= ZEN MAX_THREADS=64
pc file directory: /usr/local/lib/pkgconfig
version: 0.3.26.dev
pybind11:
detection method: config-tool
include directory: unknown
name: pybind11
version: 2.12.0
Compilers:
c:
commands: cc
linker: ld.bfd
name: gcc
version: 10.2.1
c++:
commands: c++
linker: ld.bfd
name: gcc
version: 10.2.1
cython:
commands: cython
linker: cython
name: cython
version: 3.0.10
fortran:
commands: gfortran
linker: ld.bfd
name: gcc
version: 10.2.1
pythran:
include directory: ../../tmp/pip-build-env-ilw0s1wu/overlay/lib/python3.11/site-packages/pythran
version: 0.15.0
Machine Information:
build:
cpu: x86_64
endian: little
family: x86_64
system: linux
cross-compiled: false
host:
cpu: x86_64
endian: little
family: x86_64
system: linux
Python Information:
path: /opt/python/cp311-cp311/bin/python
version: '3.11'
Describe your issue.
A regression seemingly introduced in 1.13. A 2D array with NaNs in some columns ValueErrors out as soon as it reaches a column with a NaN. It must be truly 2D, i.e. A.shape[1] > 1 is True. It also only occurs when there are more than 50 rows, i.e. A.shape[0] > 50.
Passing just that column with the NaNs, i.e. passing it as 1D, operates as expected. For example,
stats.wilcoxon(A[:50,:]orstats.wilcoxon(A[:,1])after the code example below runs fine.Reproducing Code Example
Error message
SciPy/NumPy/Python version and system information