MCPcopy Create free account
hub / github.com/numpy/numpy / test_asarray_copy

Function test_asarray_copy

numpy/array_api/tests/test_creation_functions.py:40–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38
39
40def test_asarray_copy():
41 a = asarray([1])
42 b = asarray(a, copy=True)
43 a[0] = 0
44 assert all(b[0] == 1)
45 assert all(a[0] == 0)
46 a = asarray([1])
47 b = asarray(a, copy=np._CopyMode.ALWAYS)
48 a[0] = 0
49 assert all(b[0] == 1)
50 assert all(a[0] == 0)
51 a = asarray([1])
52 b = asarray(a, copy=np._CopyMode.NEVER)
53 a[0] = 0
54 assert all(b[0] == 0)
55 assert_raises(NotImplementedError, lambda: asarray(a, copy=False))
56 assert_raises(NotImplementedError,
57 lambda: asarray(a, copy=np._CopyMode.IF_NEEDED))
58
59
60def test_arange_errors():

Callers

nothing calls this directly

Calls 3

assert_raisesFunction · 0.90
asarrayFunction · 0.50
allFunction · 0.50

Tested by

no test coverage detected