codecov[bot]: # [Codecov](https://codecov.io/gh/pydata/sparse/pull/309?src=pr&el=h1) Report
> Merging [#309](https://codecov.io/gh/pydata/sparse/pull/309?src=pr&el=desc) into [master](https://codecov.io/gh/pydata/sparse/commit/9e1213aa34f1e4bcf1994b0be6a895060b9fce6f?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `75%`.


```diff
@@            Coverage Diff             @@
##           master     #309      +/-   ##
==========================================
- Coverage    93.5%   93.47%   -0.03%     
==========================================
  Files          17       17              
  Lines        2140     2146       +6     
==========================================
+ Hits         2001     2006       +5     
- Misses        139      140       +1
```



diff --git a/sparse/_sparse_array.py b/sparse/_sparse_array.py
index 4418b2e..0737fe4 100644
--- a/sparse/_sparse_array.py
+++ b/sparse/_sparse_array.py
@@ -229,6 +229,7 @@ class SparseArray:
     def __array_function__(self, func, types, args, kwargs):
         import sparse as module
 
+        sparse_func = None
         try:
             submodules = getattr(func, "__module__", "numpy").split(".")[1:]
             for submodule in submodules:
@@ -242,9 +243,19 @@ class SparseArray:
         try:
             sparse_func = getattr(type(self), func.__name__)
         except AttributeError:
-            return NotImplemented
+            pass
 
-        if not isinstance(sparse_func, Callable):
-            return getattr(self, func.__name__)
+        if (
+            not isinstance(sparse_func, Callable)
+            and len(args) == 1
+            and len(kwargs) == 0
+        ):
+            try:
+                return getattr(self, func.__name__)
+            except AttributeError:
+                pass
+
+        if sparse_func is None:
+            return NotImplemented
 
         return sparse_func(*args, **kwargs)

sparse.COO does not support np.shape
scipy.sparse array support np.shape, but sparse.COO does not.

```python
In [1]: import sparse                                                           

In [2]: import numpy as np                                                      

In [3]: import scipy.sparse                                                     

In [4]: x = sparse.random((3, 4, 5))                                            

In [5]: x.shape                                                                 
Out[5]: (3, 4, 5)

In [6]: np.shape(x)                                                             
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-b17f5597101a> in <module>
----> 1 np.shape(x)

<__array_function__ internals> in shape(*args, **kwargs)

TypeError: no implementation found for 'numpy.shape' on types that implement __array_function__: [<class 'sparse._coo.core.COO'>]

In [7]: y = scipy.sparse.random(3, 4)                                           

In [8]: np.shape(y)                                                             
Out[8]: (3, 4)

```
diff --git a/sparse/tests/test_array_function.py b/sparse/tests/test_array_function.py
index a0ee724..b31d4fa 100644
--- a/sparse/tests/test_array_function.py
+++ b/sparse/tests/test_array_function.py
@@ -66,3 +66,12 @@ def test_ternary(func, arg_order):
     args = [(x, y)[i] for i in arg_order]
     yy = func(*args)
     assert_eq(xx, yy)
+
+
+@pytest.mark.parametrize("func", [np.shape, np.size, np.ndim])
+def test_property(func):
+    y = sparse.random((50, 50), density=0.25)
+    x = y.todense()
+    xx = func(x)
+    yy = func(y)
+    assert xx == yy

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-flake8
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
Babel==2.14.0
black==23.3.0
cachetools==5.5.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
coverage==7.2.7
distlib==0.3.9
docutils==0.19
exceptiongroup==1.2.2
filelock==3.12.2
flake8==5.0.4
idna==3.10
imagesize==1.4.1
importlib-metadata==6.7.0
iniconfig==2.0.0
Jinja2==3.1.6
llvmlite==0.39.1
MarkupSafe==2.1.5
mccabe==0.7.0
mypy-extensions==1.0.0
numba==0.56.4
numpy==1.21.6
packaging==24.0
pathspec==0.11.2
platformdirs==4.0.0
pluggy==1.2.0
pycodestyle==2.9.1
pyflakes==2.5.0
Pygments==2.17.2
pyproject-api==1.5.3
pytest==7.4.4
pytest-black==0.6.0
pytest-cov==4.1.0
pytest-flake8==1.1.3
pytz==2025.2
requests==2.31.0
scipy==1.7.3
snowballstemmer==2.2.0
-e git+https://github.com/pydata/sparse.git@9e1213aa34f1e4bcf1994b0be6a895060b9fce6f#egg=sparse
Sphinx==5.3.0
sphinx-rtd-theme==2.0.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
toml==0.10.2
tomli==2.0.1
tox==4.8.0
typed-ast==1.5.5
typing_extensions==4.7.1
urllib3==2.0.7
virtualenv==20.26.6
zipp==3.15.0

name: sparse
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - babel==2.14.0
      - black==23.3.0
      - cachetools==5.5.2
      - chardet==5.2.0
      - charset-normalizer==3.4.1
      - click==8.1.8
      - colorama==0.4.6
      - coverage==7.2.7
      - distlib==0.3.9
      - docutils==0.19
      - exceptiongroup==1.2.2
      - filelock==3.12.2
      - flake8==5.0.4
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - jinja2==3.1.6
      - llvmlite==0.39.1
      - markupsafe==2.1.5
      - mccabe==0.7.0
      - mypy-extensions==1.0.0
      - numba==0.56.4
      - numpy==1.21.6
      - packaging==24.0
      - pathspec==0.11.2
      - platformdirs==4.0.0
      - pluggy==1.2.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pygments==2.17.2
      - pyproject-api==1.5.3
      - pytest==7.4.4
      - pytest-black==0.6.0
      - pytest-cov==4.1.0
      - pytest-flake8==1.1.3
      - pytz==2025.2
      - requests==2.31.0
      - scipy==1.7.3
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinx-rtd-theme==2.0.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jquery==4.1
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - toml==0.10.2
      - tomli==2.0.1
      - tox==4.8.0
      - typed-ast==1.5.5
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - virtualenv==20.26.6
      - zipp==3.15.0
prefix: /opt/conda/envs/sparse

sparse/tests/test_array_function.py::test_property[shape]
sparse/tests/test_array_function.py::black sparse/tests/test_array_function.py::test_binary[dot-arg_order2] sparse/tests/test_array_function.py::test_binary[tensordot-arg_order2] sparse/tests/test_array_function.py::test_binary[matmul-arg_order2]
sparse/tests/test_array_function.py::test_unary[mean] sparse/tests/test_array_function.py::test_unary[std] sparse/tests/test_array_function.py::test_unary[var] sparse/tests/test_array_function.py::test_unary[sum] sparse/tests/test_array_function.py::test_unary[<lambda>0] sparse/tests/test_array_function.py::test_unary[<lambda>1] sparse/tests/test_array_function.py::test_binary[dot-arg_order0] sparse/tests/test_array_function.py::test_binary[dot-arg_order1] sparse/tests/test_array_function.py::test_binary[result_type-arg_order0] sparse/tests/test_array_function.py::test_binary[result_type-arg_order1] sparse/tests/test_array_function.py::test_binary[result_type-arg_order2] sparse/tests/test_array_function.py::test_binary[tensordot-arg_order0] sparse/tests/test_array_function.py::test_binary[tensordot-arg_order1] sparse/tests/test_array_function.py::test_binary[matmul-arg_order0] sparse/tests/test_array_function.py::test_binary[matmul-arg_order1] sparse/tests/test_array_function.py::test_stack sparse/tests/test_array_function.py::test_ternary[<lambda>-arg_order0] sparse/tests/test_array_function.py::test_ternary[<lambda>-arg_order1] sparse/tests/test_array_function.py::test_ternary[<lambda>-arg_order2] sparse/tests/test_array_function.py::test_ternary[<lambda>-arg_order3] sparse/tests/test_array_function.py::test_ternary[<lambda>-arg_order4] sparse/tests/test_array_function.py::test_ternary[<lambda>-arg_order5] sparse/tests/test_array_function.py::test_ternary[<lambda>-arg_order6] sparse/tests/test_array_function.py::test_property[size] sparse/tests/test_array_function.py::test_property[ndim]
sparse/_sparse_array.py
sparse/_sparse_array.py