diff options
author | Thomas Green <tomgreen66@hotmail.com> | 2021-12-08 11:57:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-08 11:57:10 +0000 |
commit | dc766fc1abb546ab883f76ef4e405e99e9287ab6 (patch) | |
tree | 9e7c7748ba8bfbb2ba5224633b0725909712d2fa /numpy/array_api/tests | |
parent | 1cfdac82ac793061d8ca4b07c046fc6b21ee7e54 (diff) | |
parent | ab7a1927353ab9dd52e3f2f7a1a889ae790667b9 (diff) | |
download | numpy-dc766fc1abb546ab883f76ef4e405e99e9287ab6.tar.gz |
Merge branch 'numpy:main' into armcompiler
Diffstat (limited to 'numpy/array_api/tests')
-rw-r--r-- | numpy/array_api/tests/test_array_object.py | 21 |
1 files changed, 21 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..b980bacca 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,23 @@ 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) + +def test___array__(): + a = ones((2, 3), dtype=int16) + assert np.asarray(a) is a._array + b = np.asarray(a, dtype=np.float64) + assert np.all(np.equal(b, np.ones((2, 3), dtype=np.float64))) + assert b.dtype == np.float64 |