@@ -226,11 +226,17 @@ def test_asarray_copy(library):
226226 all = xp .all if library != 'dask.array' else lambda x : xp .all (x ).compute ()
227227
228228 if library == 'numpy' and xp .__version__ [0 ] < '2' and not hasattr (xp , '_CopyMode' ) :
229- supports_copy_false = False
230- elif library in ['cupy' , 'dask.array' ]:
231- supports_copy_false = False
229+ supports_copy_false_other_ns = False
230+ supports_copy_false_same_ns = False
231+ elif library == 'cupy' :
232+ supports_copy_false_other_ns = False
233+ supports_copy_false_same_ns = False
234+ elif library == 'dask.array' :
235+ supports_copy_false_other_ns = False
236+ supports_copy_false_same_ns = True
232237 else :
233- supports_copy_false = True
238+ supports_copy_false_other_ns = True
239+ supports_copy_false_same_ns = True
234240
235241 a = asarray ([1 ])
236242 b = asarray (a , copy = True )
@@ -240,7 +246,7 @@ def test_asarray_copy(library):
240246 assert all (a [0 ] == 0 )
241247
242248 a = asarray ([1 ])
243- if supports_copy_false :
249+ if supports_copy_false_same_ns :
244250 b = asarray (a , copy = False )
245251 assert is_lib_func (b )
246252 a [0 ] = 0
@@ -249,7 +255,7 @@ def test_asarray_copy(library):
249255 pytest .raises (NotImplementedError , lambda : asarray (a , copy = False ))
250256
251257 a = asarray ([1 ])
252- if supports_copy_false :
258+ if supports_copy_false_same_ns :
253259 pytest .raises (ValueError , lambda : asarray (a , copy = False ,
254260 dtype = xp .float64 ))
255261 else :
@@ -281,7 +287,7 @@ def test_asarray_copy(library):
281287 for obj in [True , 0 , 0.0 , 0j , [0 ], [[0 ]]]:
282288 asarray (obj , copy = True ) # No error
283289 asarray (obj , copy = None ) # No error
284- if supports_copy_false :
290+ if supports_copy_false_other_ns :
285291 pytest .raises (ValueError , lambda : asarray (obj , copy = False ))
286292 else :
287293 pytest .raises (NotImplementedError , lambda : asarray (obj , copy = False ))
@@ -294,7 +300,7 @@ def test_asarray_copy(library):
294300 assert all (b [0 ] == 1.0 )
295301
296302 a = array .array ('f' , [1.0 ])
297- if supports_copy_false :
303+ if supports_copy_false_other_ns :
298304 b = asarray (a , copy = False )
299305 assert is_lib_func (b )
300306 a [0 ] = 0.0
0 commit comments