Skip to content

Commit

Permalink
BUG: record warnings related to DatetimeIndex (#37193)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanovmg committed Oct 23, 2020
1 parent 4f5e0e0 commit 23c41bd
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,16 @@ def test_irreg_hf(self):
_, ax = self.plt.subplots()
df2 = df.copy()
df2.index = df.index.astype(object)
df2.plot(ax=ax)
diffs = Series(ax.get_lines()[0].get_xydata()[:, 0]).diff()
assert (np.fabs(diffs[1:] - sec) < 1e-8).all()
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
# This warning will be emitted
# pandas/core/frame.py:3216:
# FutureWarning: Automatically casting object-dtype Index of datetimes
# to DatetimeIndex is deprecated and will be removed in a future version.
# Explicitly cast to DatetimeIndex instead.
# return klass(values, index=self.index, name=name, fastpath=True)
df2.plot(ax=ax)
diffs = Series(ax.get_lines()[0].get_xydata()[:, 0]).diff()
assert (np.fabs(diffs[1:] - sec) < 1e-8).all()

def test_irregular_datetime64_repr_bug(self):
ser = tm.makeTimeSeries()
Expand Down Expand Up @@ -1028,9 +1035,16 @@ def test_irreg_dtypes(self):
# np.datetime64
idx = date_range("1/1/2000", periods=10)
idx = idx[[0, 2, 5, 9]].astype(object)
df = DataFrame(np.random.randn(len(idx), 3), idx)
_, ax = self.plt.subplots()
_check_plot_works(df.plot, ax=ax)
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
# This warning will be emitted
# pandas/core/frame.py:3216:
# FutureWarning: Automatically casting object-dtype Index of datetimes
# to DatetimeIndex is deprecated and will be removed in a future version.
# Explicitly cast to DatetimeIndex instead.
# return klass(values, index=self.index, name=name, fastpath=True)
df = DataFrame(np.random.randn(len(idx), 3), idx)
_, ax = self.plt.subplots()
_check_plot_works(df.plot, ax=ax)

@pytest.mark.slow
def test_time(self):
Expand Down

0 comments on commit 23c41bd

Please sign in to comment.