Repository: scipy/scipy
Issue category: Bug Report

Issue:
DOC: sparse: `sparse.eye_array` does not accept `tuple[int, int]` as the docs say that it should
### Describe your issue.

`scipy.sparse.eye_array` does not accept `m: tuple[int, int]` as the docs suggest is should:

https://github.com/scipy/scipy/blob/964f0bb6701dc17b51b842382ced0fa2ee318377/scipy/sparse/_construct.py#L350-L353

This is the case with at least `1.14.1` and `1.15.0rc1`

### Reproducing Code Example

```python
from scipy.sparse import eye_array
eye_array((1, 1))
```


### Error message

```shell
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    eye_array((1, 1))
    ~~~~~~~~~^^^^^^^^
  File "/home/joren/.pyenv/versions/3.13.1/lib/python3.13/site-packages/scipy/sparse/_construct.py", line 377, in eye_array
    return _eye(m, n, k, dtype, format)
  File "/home/joren/.pyenv/versions/3.13.1/lib/python3.13/site-packages/scipy/sparse/_construct.py", line 394, in _eye
    m, n = int(m), int(n)
           ~~~^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'tuple'
```


### SciPy/NumPy/Python version and system information

```shell
1.15.0rc1 2.2.0 sys.version_info(major=3, minor=13, micro=1, releaselevel='final', serial=0)
Build Dependencies:
  blas:
    detection method: pkgconfig
    found: true
    include directory: /opt/_internal/cpython-3.13.0/lib/python3.13/site-packages/scipy_openblas32/include
    lib directory: /opt/_internal/cpython-3.13.0/lib/python3.13/site-packages/scipy_openblas32/lib
    name: scipy-openblas
    openblas configuration: OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64
    pc file directory: /project
    version: 0.3.28
  lapack:
    detection method: pkgconfig
    found: true
    include directory: /opt/_internal/cpython-3.13.0/lib/python3.13/site-packages/scipy_openblas32/include
    lib directory: /opt/_internal/cpython-3.13.0/lib/python3.13/site-packages/scipy_openblas32/lib
    name: scipy-openblas
    openblas configuration: OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64
    pc file directory: /project
    version: 0.3.28
  pybind11:
    detection method: config-tool
    include directory: unknown
    name: pybind11
    version: 2.13.6
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.11
  fortran:
    commands: gfortran
    linker: ld.bfd
    name: gcc
    version: 10.2.1
  pythran:
    include directory: ../../tmp/pip-build-env-fa6gfmf0/overlay/lib/python3.13/site-packages/pythran
    version: 0.17.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/cp313-cp313/bin/python
  version: '3.13'
```

DOC: sparse: `sparse.eye_array` does not accept `tuple[int, int]` as the docs say that it should
### Describe your issue.

`scipy.sparse.eye_array` does not accept `m: tuple[int, int]` as the docs suggest is should:

https://github.com/scipy/scipy/blob/964f0bb6701dc17b51b842382ced0fa2ee318377/scipy/sparse/_construct.py#L350-L353

This is the case with at least `1.14.1` and `1.15.0rc1`

### Reproducing Code Example

```python
from scipy.sparse import eye_array
eye_array((1, 1))
```


### Error message

```shell
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    eye_array((1, 1))
    ~~~~~~~~~^^^^^^^^
  File "/home/joren/.pyenv/versions/3.13.1/lib/python3.13/site-packages/scipy/sparse/_construct.py", line 377, in eye_array
    return _eye(m, n, k, dtype, format)
  File "/home/joren/.pyenv/versions/3.13.1/lib/python3.13/site-packages/scipy/sparse/_construct.py", line 394, in _eye
    m, n = int(m), int(n)
           ~~~^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'tuple'
```


### SciPy/NumPy/Python version and system information

```shell
1.15.0rc1 2.2.0 sys.version_info(major=3, minor=13, micro=1, releaselevel='final', serial=0)
Build Dependencies:
  blas:
    detection method: pkgconfig
    found: true
    include directory: /opt/_internal/cpython-3.13.0/lib/python3.13/site-packages/scipy_openblas32/include
    lib directory: /opt/_internal/cpython-3.13.0/lib/python3.13/site-packages/scipy_openblas32/lib
    name: scipy-openblas
    openblas configuration: OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64
    pc file directory: /project
    version: 0.3.28
  lapack:
    detection method: pkgconfig
    found: true
    include directory: /opt/_internal/cpython-3.13.0/lib/python3.13/site-packages/scipy_openblas32/include
    lib directory: /opt/_internal/cpython-3.13.0/lib/python3.13/site-packages/scipy_openblas32/lib
    name: scipy-openblas
    openblas configuration: OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64
    pc file directory: /project
    version: 0.3.28
  pybind11:
    detection method: config-tool
    include directory: unknown
    name: pybind11
    version: 2.13.6
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.11
  fortran:
    commands: gfortran
    linker: ld.bfd
    name: gcc
    version: 10.2.1
  pythran:
    include directory: ../../tmp/pip-build-env-fa6gfmf0/overlay/lib/python3.13/site-packages/pythran
    version: 0.17.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/cp313-cp313/bin/python
  version: '3.13'
```



Hints:
Thank you for pointing this out!!
We should be using the [array_api specification](https://data-apis.org/array-api/latest/API_specification) for the [`eye` function](https://data-apis.org/array-api/latest/API_specification/generated/array_api.eye.html). That should also align us with the numpy interface.   The function name is not `eye`, but we intend to rename it after the spmatrix functions are deprecated and removed.

Luckily it looks like the code does the right thing. The docs are not what we want.  So we need to change the docs by removing ` or tuple of ints`.

And it would be good to backport the change to the maintenance branch (I believe it is far too late to update the 1.14.1 docs).
> Thank you for pointing this out!! We should be using the [array_api specification](https://data-apis.org/array-api/latest/API_specification) for the [`eye` function](https://data-apis.org/array-api/latest/API_specification/generated/array_api.eye.html). That should also align us with the numpy interface. The function name is not `eye`, but we intend to rename it after the spmatrix functions are deprecated and removed.
> 
> Luckily it looks like the code does the right thing. The docs are not what we want. So we need to change the docs by removing ` or tuple of ints`.
> 
> And it would be good to backport the change to the maintenance branch (I believe it is far too late to update the 1.14.1 docs).

I like that; it's easier to annotate that way :)
Thank you for pointing this out!!
We should be using the [array_api specification](https://data-apis.org/array-api/latest/API_specification) for the [`eye` function](https://data-apis.org/array-api/latest/API_specification/generated/array_api.eye.html). That should also align us with the numpy interface.   The function name is not `eye`, but we intend to rename it after the spmatrix functions are deprecated and removed.

Luckily it looks like the code does the right thing. The docs are not what we want.  So we need to change the docs by removing ` or tuple of ints`.

And it would be good to backport the change to the maintenance branch (I believe it is far too late to update the 1.14.1 docs).
> Thank you for pointing this out!! We should be using the [array_api specification](https://data-apis.org/array-api/latest/API_specification) for the [`eye` function](https://data-apis.org/array-api/latest/API_specification/generated/array_api.eye.html). That should also align us with the numpy interface. The function name is not `eye`, but we intend to rename it after the spmatrix functions are deprecated and removed.
> 
> Luckily it looks like the code does the right thing. The docs are not what we want. So we need to change the docs by removing ` or tuple of ints`.
> 
> And it would be good to backport the change to the maintenance branch (I believe it is far too late to update the 1.14.1 docs).

I like that; it's easier to annotate that way :)

Patch:
diff --git a/scipy/sparse/_construct.py b/scipy/sparse/_construct.py
index 0326c9963f0b..f483976badb7 100644
--- a/scipy/sparse/_construct.py
+++ b/scipy/sparse/_construct.py
@@ -349,7 +349,7 @@ def eye_array(m, n=None, *, k=0, dtype=float, format=None):
 
     Parameters
     ----------
-    m : int or tuple of ints
+    m : int
         Number of rows requested.
     n : int, optional
         Number of columns. Default: `m`.


Test patch: