diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-12-01 19:52:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-01 19:52:12 -0700 |
commit | 742f13f7ee6ff8ed56fc468c9ef57b3853141768 (patch) | |
tree | 3eed2beabeeabf6c7261f2a44fc2c2723f65883a /numpy/array_api/tests/test_array_object.py | |
parent | 4194a94f08763599014e92713be8a63446cd76d4 (diff) | |
parent | 18fe695dbc66df660039aca9f76a949de8b9348e (diff) | |
download | numpy-742f13f7ee6ff8ed56fc468c9ef57b3853141768.tar.gz |
Merge pull request #20499 from asmeurer/array_api_T
BUG: Fix the .T attribute in the array_api namespace
Diffstat (limited to 'numpy/array_api/tests/test_array_object.py')
-rw-r--r-- | numpy/array_api/tests/test_array_object.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/array_api/tests/test_array_object.py b/numpy/array_api/tests/test_array_object.py index 12479d765..deab50693 100644 --- a/numpy/array_api/tests/test_array_object.py +++ b/numpy/array_api/tests/test_array_object.py @@ -4,6 +4,7 @@ from numpy.testing import assert_raises import numpy as np from .. import ones, asarray, result_type, all, equal +from .._array_object import Array from .._dtypes import ( _all_dtypes, _boolean_dtypes, @@ -301,3 +302,16 @@ def test_device_property(): assert all(equal(asarray(a, device='cpu'), a)) assert_raises(ValueError, lambda: asarray(a, device='gpu')) + +def test_array_properties(): + a = ones((1, 2, 3)) + b = ones((2, 3)) + assert_raises(ValueError, lambda: a.T) + + assert isinstance(b.T, Array) + assert b.T.shape == (3, 2) + + assert isinstance(a.mT, Array) + assert a.mT.shape == (1, 3, 2) + assert isinstance(b.mT, Array) + assert b.mT.shape == (3, 2) |