Skip to content

Commit 46283e0

Browse files
author
hugo
committed
added test by taking test_term_compat, and removing all Term calls
1 parent 2cda89d commit 46283e0

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

pandas/io/tests/test_pytables.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,48 @@ def test_term_compat(self):
24742474
expected = wp.loc[:,:,['A','B']]
24752475
assert_panel_equal(result, expected)
24762476

2477+
def test_backwards_compat_without_term_object(self):
2478+
with ensure_clean_store(self.path) as store:
2479+
2480+
wp = Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
2481+
major_axis=date_range('1/1/2000', periods=5),
2482+
minor_axis=['A', 'B', 'C', 'D'])
2483+
store.append('wp',wp)
2484+
2485+
result = store.select('wp', [('major_axis>20000102'),
2486+
('minor_axis', '=', ['A','B']) ])
2487+
expected = wp.loc[:,wp.major_axis>Timestamp('20000102'),['A','B']]
2488+
assert_panel_equal(result, expected)
2489+
2490+
store.remove('wp', ('major_axis>20000103'))
2491+
result = store.select('wp')
2492+
expected = wp.loc[:,wp.major_axis<=Timestamp('20000103'),:]
2493+
assert_panel_equal(result, expected)
2494+
2495+
with ensure_clean_store(self.path) as store:
2496+
2497+
wp = Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
2498+
major_axis=date_range('1/1/2000', periods=5),
2499+
minor_axis=['A', 'B', 'C', 'D'])
2500+
store.append('wp',wp)
2501+
2502+
# stringified datetimes
2503+
result = store.select('wp', [('major_axis','>',datetime.datetime(2000,1,2))])
2504+
expected = wp.loc[:,wp.major_axis>Timestamp('20000102')]
2505+
assert_panel_equal(result, expected)
2506+
2507+
result = store.select('wp', [('major_axis','>',datetime.datetime(2000,1,2,0,0))])
2508+
expected = wp.loc[:,wp.major_axis>Timestamp('20000102')]
2509+
assert_panel_equal(result, expected)
2510+
2511+
result = store.select('wp', [('major_axis','=',[datetime.datetime(2000,1,2,0,0),datetime.datetime(2000,1,3,0,0)])])
2512+
expected = wp.loc[:,[Timestamp('20000102'),Timestamp('20000103')]]
2513+
assert_panel_equal(result, expected)
2514+
2515+
result = store.select('wp', [('minor_axis','=',['A','B'])])
2516+
expected = wp.loc[:,:,['A','B']]
2517+
assert_panel_equal(result, expected)
2518+
24772519
def test_same_name_scoping(self):
24782520

24792521
with ensure_clean_store(self.path) as store:

0 commit comments

Comments
 (0)