diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-12-07 08:56:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-07 08:56:26 -0700 |
commit | b5331ea9ece515d45e5a5adcb8e06117c9d33569 (patch) | |
tree | b4664d6e82ece902843a7b3862be12b127a2e906 /numpy/array_api/tests | |
parent | 7ca1d1ad0dc86f0d20414c946eb2b6e8dc19c367 (diff) | |
parent | 5f21063cc317d92a866c7259a9509f5e5d6189c2 (diff) | |
download | numpy-b5331ea9ece515d45e5a5adcb8e06117c9d33569.tar.gz |
Merge pull request #20527 from asmeurer/array_api-__array__
ENH: Add __array__ to the array_api Array object
Diffstat (limited to 'numpy/array_api/tests')
-rw-r--r-- | numpy/array_api/tests/test_array_object.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/numpy/array_api/tests/test_array_object.py b/numpy/array_api/tests/test_array_object.py index deab50693..b980bacca 100644 --- a/numpy/array_api/tests/test_array_object.py +++ b/numpy/array_api/tests/test_array_object.py @@ -315,3 +315,10 @@ def test_array_properties(): 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 |