@@ -183,12 +183,12 @@ def test_array_astype():
183183
184184 # order parameter allows overriding of the memory layout,
185185 # forcing a copy if the layout is wrong
186- b = a .astype ('f4' , order = 'F' , copy = None )
186+ b = a .astype ('f4' , order = 'F' , copy = False )
187187 assert_equal (a , b )
188188 assert_ (not (a is b ))
189189 assert_ (b .flags .f_contiguous )
190190
191- b = a .astype ('f4' , order = 'C' , copy = None )
191+ b = a .astype ('f4' , order = 'C' , copy = False )
192192 assert_equal (a , b )
193193 assert_ (a is b )
194194 assert_ (b .flags .c_contiguous )
@@ -214,12 +214,12 @@ class MyNDArray(np.ndarray):
214214 assert_ (a is b )
215215
216216 # subok=True is default, and creates a subtype on a cast
217- b = a .astype ('i4' , copy = None )
217+ b = a .astype ('i4' , copy = False )
218218 assert_equal (a , b )
219219 assert_equal (type (b ), MyNDArray )
220220
221221 # subok=False never returns a subclass
222- b = a .astype ('f4' , subok = False , copy = None )
222+ b = a .astype ('f4' , subok = False , copy = False )
223223 assert_equal (a , b )
224224 assert_ (not (a is b ))
225225 assert_ (type (b ) is not MyNDArray )
@@ -570,22 +570,14 @@ def test_astype_copyflag():
570570 arr = np .arange (10 , dtype = np .intp )
571571
572572 res_true = arr .astype (np .intp , copy = True )
573- assert not np .may_share_memory (arr , res_true )
574- res_always = arr .astype (np .intp , copy = np ._CopyMode .ALWAYS )
575- assert not np .may_share_memory (arr , res_always )
573+ assert not np .shares_memory (arr , res_true )
576574
577575 res_false = arr .astype (np .intp , copy = False )
578- # `res_false is arr` currently, but check `may_share_memory`.
579- assert np .may_share_memory (arr , res_false )
580- res_if_needed = arr .astype (np .intp , copy = None )
581- # `res_if_needed is arr` currently, but check `may_share_memory`.
582- assert np .may_share_memory (arr , res_if_needed )
583-
584- res_never = arr .astype (np .intp , copy = np ._CopyMode .NEVER )
585- assert np .may_share_memory (arr , res_never )
586-
587- # Simple tests for when a copy is necessary:
588- res_if_needed = arr .astype (np .float64 , copy = None )
589- assert_array_equal (res_if_needed , arr )
576+ assert np .shares_memory (arr , res_false )
577+
578+ res_false_float = arr .astype (np .float64 , copy = False )
579+ assert not np .shares_memory (arr , res_false_float )
580+
581+ # _CopyMode enum isn't allowed
590582 assert_raises (ValueError , arr .astype , np .float64 ,
591- copy = False )
583+ copy = np . _CopyMode . NEVER )
0 commit comments