Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab6d338

Browse files
committed
TST: add test of bad pandas indexing
1 parent 2f73778 commit ab6d338

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io
88

99
from nose.tools import assert_equal, assert_raises, assert_false, assert_true
10+
from nose.plugins.skip import SkipTest
1011

1112
import datetime
1213

@@ -4183,6 +4184,23 @@ def test_broken_barh_empty():
41834184
ax.broken_barh([], (.1, .5))
41844185

41854186

4187+
@cleanup
4188+
def test_pandas_indexing_dates():
4189+
try:
4190+
import pandas as pd
4191+
except ImportError:
4192+
raise SkipTest("Pandas not installed")
4193+
4194+
dates = np.arange('2005-02', '2005-03', dtype='datetime64[D]')
4195+
values = np.sin(np.array(range(len(dates))))
4196+
df = pd.DataFrame({'dates': dates, 'values': values})
4197+
4198+
ax = plt.gca()
4199+
4200+
without_zero_index = df[np.array(df.index) % 2 == 1].copy()
4201+
ax.plot('dates', 'values', data=without_zero_index)
4202+
4203+
41864204
if __name__ == '__main__':
41874205
import nose
41884206
import sys

0 commit comments

Comments
 (0)