summaryrefslogtreecommitdiff
path: root/numpy/array_api/tests/test_creation_functions.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/array_api/tests/test_creation_functions.py')
-rw-r--r--numpy/array_api/tests/test_creation_functions.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/numpy/array_api/tests/test_creation_functions.py b/numpy/array_api/tests/test_creation_functions.py
index 3cb8865cd..be9eaa383 100644
--- a/numpy/array_api/tests/test_creation_functions.py
+++ b/numpy/array_api/tests/test_creation_functions.py
@@ -8,7 +8,6 @@ from .._creation_functions import (
empty,
empty_like,
eye,
- from_dlpack,
full,
full_like,
linspace,
@@ -18,20 +17,8 @@ from .._creation_functions import (
zeros,
zeros_like,
)
+from .._dtypes import float32, float64
from .._array_object import Array
-from .._dtypes import (
- _all_dtypes,
- _boolean_dtypes,
- _floating_dtypes,
- _integer_dtypes,
- _integer_or_boolean_dtypes,
- _numeric_dtypes,
- int8,
- int16,
- int32,
- int64,
- uint64,
-)
def test_asarray_errors():
@@ -56,12 +43,18 @@ def test_asarray_copy():
a[0] = 0
assert all(b[0] == 1)
assert all(a[0] == 0)
- # Once copy=False is implemented, replace this with
- # a = asarray([1])
- # b = asarray(a, copy=False)
- # a[0] = 0
- # assert all(b[0] == 0)
+ a = asarray([1])
+ b = asarray(a, copy=np._CopyMode.ALWAYS)
+ a[0] = 0
+ assert all(b[0] == 1)
+ assert all(a[0] == 0)
+ a = asarray([1])
+ b = asarray(a, copy=np._CopyMode.NEVER)
+ a[0] = 0
+ assert all(b[0] == 0)
assert_raises(NotImplementedError, lambda: asarray(a, copy=False))
+ assert_raises(NotImplementedError,
+ lambda: asarray(a, copy=np._CopyMode.IF_NEEDED))
def test_arange_errors():
@@ -139,3 +132,11 @@ def test_zeros_like_errors():
assert_raises(ValueError, lambda: zeros_like(asarray(1), device="gpu"))
assert_raises(ValueError, lambda: zeros_like(asarray(1), dtype=int))
assert_raises(ValueError, lambda: zeros_like(asarray(1), dtype="i"))
+
+def test_meshgrid_dtype_errors():
+ # Doesn't raise
+ meshgrid()
+ meshgrid(asarray([1.], dtype=float32))
+ meshgrid(asarray([1.], dtype=float32), asarray([1.], dtype=float32))
+
+ assert_raises(ValueError, lambda: meshgrid(asarray([1.], dtype=float32), asarray([1.], dtype=float64)))