File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -393,9 +393,9 @@ def __array__(
393393 # For NumPy 1.x compatibility we cannot use copy=None. And
394394 # `copy=False` has the meaning of `copy=None` here:
395395 if not copy :
396- return np .asarray (self , dtype = dtype )
396+ return np .asarray (self . asi8 , dtype = dtype )
397397 else :
398- return np .array (self , dtype = dtype )
398+ return np .array (self . asi8 , dtype = dtype )
399399
400400 if copy is False :
401401 raise ValueError (
Original file line number Diff line number Diff line change @@ -1152,9 +1152,17 @@ def test_array_interface(self, arr1d):
11521152 result = np .asarray (arr , dtype = object )
11531153 tm .assert_numpy_array_equal (result , expected )
11541154
1155+ # to int64 gives the underlying representation
11551156 result = np .asarray (arr , dtype = "int64" )
11561157 tm .assert_numpy_array_equal (result , arr .asi8 )
11571158
1159+ result2 = np .asarray (arr , dtype = "int64" )
1160+ assert np .may_share_memory (result , result2 )
1161+
1162+ result_copy1 = np .array (arr , dtype = "int64" , copy = True )
1163+ result_copy2 = np .array (arr , dtype = "int64" , copy = True )
1164+ assert not np .may_share_memory (result_copy1 , result_copy2 )
1165+
11581166 # to other dtypes
11591167 msg = r"float\(\) argument must be a string or a( real)? number, not 'Period'"
11601168 with pytest .raises (TypeError , match = msg ):
You can’t perform that action at this time.
0 commit comments