@@ -291,9 +291,16 @@ def test_irreg_hf(self):
291
291
_ , ax = self .plt .subplots ()
292
292
df2 = df .copy ()
293
293
df2 .index = df .index .astype (object )
294
- df2 .plot (ax = ax )
295
- diffs = Series (ax .get_lines ()[0 ].get_xydata ()[:, 0 ]).diff ()
296
- assert (np .fabs (diffs [1 :] - sec ) < 1e-8 ).all ()
294
+ with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
295
+ # This warning will be emitted
296
+ # pandas/core/frame.py:3216:
297
+ # FutureWarning: Automatically casting object-dtype Index of datetimes
298
+ # to DatetimeIndex is deprecated and will be removed in a future version.
299
+ # Explicitly cast to DatetimeIndex instead.
300
+ # return klass(values, index=self.index, name=name, fastpath=True)
301
+ df2 .plot (ax = ax )
302
+ diffs = Series (ax .get_lines ()[0 ].get_xydata ()[:, 0 ]).diff ()
303
+ assert (np .fabs (diffs [1 :] - sec ) < 1e-8 ).all ()
297
304
298
305
def test_irregular_datetime64_repr_bug (self ):
299
306
ser = tm .makeTimeSeries ()
@@ -1028,9 +1035,16 @@ def test_irreg_dtypes(self):
1028
1035
# np.datetime64
1029
1036
idx = date_range ("1/1/2000" , periods = 10 )
1030
1037
idx = idx [[0 , 2 , 5 , 9 ]].astype (object )
1031
- df = DataFrame (np .random .randn (len (idx ), 3 ), idx )
1032
- _ , ax = self .plt .subplots ()
1033
- _check_plot_works (df .plot , ax = ax )
1038
+ with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
1039
+ # This warning will be emitted
1040
+ # pandas/core/frame.py:3216:
1041
+ # FutureWarning: Automatically casting object-dtype Index of datetimes
1042
+ # to DatetimeIndex is deprecated and will be removed in a future version.
1043
+ # Explicitly cast to DatetimeIndex instead.
1044
+ # return klass(values, index=self.index, name=name, fastpath=True)
1045
+ df = DataFrame (np .random .randn (len (idx ), 3 ), idx )
1046
+ _ , ax = self .plt .subplots ()
1047
+ _check_plot_works (df .plot , ax = ax )
1034
1048
1035
1049
@pytest .mark .slow
1036
1050
def test_time (self ):
0 commit comments