Skip to content

test_reshape fails with copy= and numpy < 2 #446

Description

@ev-br

Caught several failures at

https://github.com/data-apis/array-api-compat/actions/runs/30433019201/job/90514326589?pr=394

FAILED array_api_tests/test_manipulation_functions.py::test_reshape - AttributeError: attribute 'shape' of 'numpy.generic' objects is not writable

========== FAILING CODE SNIPPET:
xp.reshape(False,(1,), **kw) with kw ={'copy': False}
====================

and

_________________________________ test_reshape _________________________________
[gw1] linux -- Python 3.13.14 /opt/hostedtoolcache/Python/3.13.14/x64/bin/python
  + Exception Group Traceback (most recent call last):
  |   File "/home/runner/work/array-api-compat/array-api-compat/array-api-tests/array_api_tests/test_manipulation_functions.py", line 428, in test_reshape
  |     @given(
  |     
  |   File "/opt/hostedtoolcache/Python/3.13.14/x64/lib/python3.13/site-packages/hypothesis/core.py", line 2297, in wrapped_test
  |     raise the_error_hypothesis_found
  | ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/home/runner/work/array-api-compat/array-api-compat/array-api-tests/array_api_tests/test_manipulation_functions.py", line 436, in test_reshape
    |     out = xp.reshape(x, shape, **kw)
    |   File "/opt/hostedtoolcache/Python/3.13.14/x64/lib/python3.13/site-packages/array_api_compat/_internal.py", line 35, in wrapped_f
    |     return f(*args, xp=xp, **kwargs)
    |   File "/opt/hostedtoolcache/Python/3.13.14/x64/lib/python3.13/site-packages/array_api_compat/common/_aliases.py", line 461, in reshape
    |     y.shape = shape
    |     ^^^^^^^
    |   File "/opt/hostedtoolcache/Python/3.13.14/x64/lib/python3.13/site-packages/dask/utils.py", line 2061, in __set__
    |     raise AttributeError("Can't set attribute")
    | AttributeError: Can't set attribute
    | 
    | ========== FAILING CODE SNIPPET:
    | xp.reshape(dask.array<zeros_like, shape=(0,), dtype=bool, chunksize=(0,), chunktype=numpy.ndarray>,(0,), **kw) with kw ={'copy': False}
    | ====================

Both kinds of failures seem to be coming from the "classic" version which sets the attribute. It's probably easiest to skip the test for numpy <2 and dask.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions