6
6
7
7
from pandas ._libs .tslibs import (
8
8
OutOfBoundsTimedelta ,
9
+ astype_overflowsafe ,
9
10
conversion ,
10
11
iNaT ,
11
12
timezones ,
@@ -106,7 +107,7 @@ def test_tz_convert_readonly():
106
107
@pytest .mark .parametrize ("dtype" , ["M8[ns]" , "M8[s]" ])
107
108
def test_length_zero_copy (dtype , copy ):
108
109
arr = np .array ([], dtype = dtype )
109
- result = conversion . ensure_datetime64ns (arr , copy = copy )
110
+ result = astype_overflowsafe (arr , copy = copy , dtype = np . dtype ( "M8[ns]" ) )
110
111
if copy :
111
112
assert not np .shares_memory (result , arr )
112
113
else :
@@ -119,7 +120,7 @@ def test_length_zero_copy(dtype, copy):
119
120
def test_ensure_datetime64ns_bigendian ():
120
121
# GH#29684
121
122
arr = np .array ([np .datetime64 (1 , "ms" )], dtype = ">M8[ms]" )
122
- result = conversion . ensure_datetime64ns (arr )
123
+ result = astype_overflowsafe (arr , dtype = np . dtype ( "M8[ns]" ) )
123
124
124
125
expected = np .array ([np .datetime64 (1 , "ms" )], dtype = "M8[ns]" )
125
126
tm .assert_numpy_array_equal (result , expected )
@@ -129,7 +130,7 @@ def test_ensure_timedelta64ns_overflows():
129
130
arr = np .arange (10 ).astype ("m8[Y]" ) * 100
130
131
msg = r"Cannot convert 300 years to timedelta64\[ns\] without overflow"
131
132
with pytest .raises (OutOfBoundsTimedelta , match = msg ):
132
- conversion . ensure_timedelta64ns (arr )
133
+ astype_overflowsafe (arr , dtype = np . dtype ( "m8[ns]" ) )
133
134
134
135
135
136
class SubDatetime (datetime ):
0 commit comments