Skip to content

Commit b8447d7

Browse files
author
Brendan Boerner
committed
test case for pandas-dev#8014
1 parent 3fcb774 commit b8447d7

File tree

1 file changed

+6
-234
lines changed

1 file changed

+6
-234
lines changed

pandas/io/tests/test_pytables2.py

+6-234
Original file line numberDiff line numberDiff line change
@@ -145,84 +145,10 @@ def setUp(self):
145145
def tearDown(self):
146146
pass
147147

148-
def xtest_select_iterator_8014_0(self):
149-
150-
# single table
151-
with ensure_clean_store(self.path) as store:
152-
153-
df = tm.makeTimeDataFrame(10064, 'S')
154-
_maybe_remove(store, 'df')
155-
i = 0; ln = 5927
156-
store.append('df', df[i:i+ln])
157-
i = i+ln; ln = 4137
158-
store.append('df', df[i:i+ln])
159-
expected = df
160-
161-
beg_dt = expected.index[0]
162-
end_dt = expected.index[-1]
163-
164-
# select w/o iteration and no where clause works
165-
result = store.select('df')
166-
tm.assert_frame_equal(expected, result)
167-
168-
# select w/iterator and no where clause works
169-
results = []
170-
for s in store.select('df',iterator=True):
171-
results.append(s)
172-
result = concat(results)
173-
tm.assert_frame_equal(expected, result)
174-
175-
# select w/o iterator and where clause, single term, begin
176-
# of range, works
177-
where = "index >= '%s'" % beg_dt
178-
result = store.select('df',where=where)
179-
tm.assert_frame_equal(expected, result)
180-
181-
# select w/o iterator and where clause, single term, end
182-
# of range, fails
183-
where = "index <= '%s'" % end_dt
184-
result = store.select('df',where=where)
185-
#tm.assert_frame_equal(expected, result)
186-
187-
# select w/o iterator and where clause, inclusive range,
188-
# fails
189-
where = "index >= '%s' & index <= '%s'" % (beg_dt, end_dt)
190-
result = store.select('df',where=where)
191-
#tm.assert_frame_equal(expected, result)
192-
193-
#
194-
# with iterator
195-
#
196-
197-
# select w/iterator and where clause, single term, begin
198-
# of range, fails
199-
where = "index >= '%s'" % beg_dt
200-
results = []
201-
for s in store.select('df',where=where,iterator=True, chunksize=1e2):
202-
results.append(s)
203-
result = concat(results)
204-
tm.assert_frame_equal(expected, result)
205-
206-
# select w/iterator and where clause, single term, end of
207-
# range, fails
208-
where = "index <= '%s'" % end_dt
209-
results = []
210-
for s in store.select('df',where=where,iterator=True, chunksize=1e2):
211-
results.append(s)
212-
result = concat(results)
213-
#tm.assert_frame_equal(expected, result)
214-
215-
# select w/iterator and where clause, inclusive range, fails
216-
where = "index >= '%s' & index <= '%s'" % (beg_dt, end_dt)
217-
results = []
218-
for s in store.select('df',where=where,iterator=True, chunksize=1e2):
219-
results.append(s)
220-
result = concat(results)
221-
#tm.assert_frame_equal(expected, result)
222-
223-
def test_select_iterator_8014_1(self):
148+
def test_select_iterator_8014(self):
224149

225150
# single table
151+
chunksize=1e4
226152
with ensure_clean_store(self.path) as store:
227153

228154
df = tm.makeTimeDataFrame(100064, 'S')
@@ -268,7 +194,7 @@ def test_select_iterator_8014_1(self):
268194

269195
# select w/iterator and no where clause works
270196
results = []
271-
for s in store.select('df',iterator=True):
197+
for s in store.select('df',iterator=True, chunksize=chunksize):
272198
results.append(s)
273199
result = concat(results)
274200
tm.assert_frame_equal(expected, result)
@@ -277,7 +203,7 @@ def test_select_iterator_8014_1(self):
277203
# of range, fails
278204
where = "index >= '%s'" % beg_dt
279205
results = []
280-
for s in store.select('df',where=where,iterator=True, chunksize=1e4):
206+
for s in store.select('df',where=where,iterator=True, chunksize=chunksize):
281207
results.append(s)
282208
result = concat(results)
283209
tm.assert_frame_equal(expected, result)
@@ -286,173 +212,19 @@ def test_select_iterator_8014_1(self):
286212
# range, fails
287213
where = "index <= '%s'" % end_dt
288214
results = []
289-
for s in store.select('df',where=where,iterator=True, chunksize=1e4):
290-
results.append(s)
291-
result = concat(results)
292-
tm.assert_frame_equal(expected, result)
293-
294-
# select w/iterator and where clause, inclusive range, fails
295-
where = "index >= '%s' & index <= '%s'" % (beg_dt, end_dt)
296-
results = []
297-
for s in store.select('df',where=where,iterator=True, chunksize=1e4):
298-
results.append(s)
299-
result = concat(results)
300-
tm.assert_frame_equal(expected, result)
301-
302-
def xtest_select_iterator_8014_2(self):
303-
304-
# single table
305-
with ensure_clean_store(self.path) as store:
306-
307-
df = tm.makeTimeDataFrame(200064, 'S')
308-
_maybe_remove(store, 'df')
309-
i = 0; ln = 100000
310-
store.append('df', df[i:i+ln])
311-
i = i+ln; ln = 58689
312-
store.append('df', df[i:i+ln])
313-
i = i+ln; ln = 41375
314-
store.append('df', df[i:i+ln])
315-
expected = df
316-
317-
beg_dt = expected.index[0]
318-
end_dt = expected.index[-1]
319-
320-
# select w/o iteration and no where clause works
321-
result = store.select('df')
322-
tm.assert_frame_equal(expected, result)
323-
324-
# select w/iterator and no where clause works
325-
results = []
326-
for s in store.select('df',iterator=True):
327-
results.append(s)
328-
result = concat(results)
329-
tm.assert_frame_equal(expected, result)
330-
331-
# select w/o iterator and where clause, single term, begin
332-
# of range, works
333-
where = "index >= '%s'" % beg_dt
334-
result = store.select('df',where=where)
335-
tm.assert_frame_equal(expected, result)
336-
337-
# select w/o iterator and where clause, single term, end
338-
# of range, works
339-
where = "index <= '%s'" % end_dt
340-
result = store.select('df',where=where)
341-
tm.assert_frame_equal(expected, result)
342-
343-
# select w/o iterator and where clause, inclusive range,
344-
# fails
345-
where = "index >= '%s' & index <= '%s'" % (beg_dt, end_dt)
346-
result = store.select('df',where=where)
347-
tm.assert_frame_equal(expected, result)
348-
349-
#
350-
# with iterator
351-
#
352-
353-
# select w/iterator and where clause, single term, begin
354-
# of range, works
355-
where = "index >= '%s'" % beg_dt
356-
results = []
357-
for s in store.select('df',where=where,iterator=True, chunksize=1e4):
215+
for s in store.select('df',where=where,iterator=True, chunksize=chunksize):
358216
results.append(s)
359217
result = concat(results)
360218
tm.assert_frame_equal(expected, result)
361219

362-
# select w/iterator and where clause, single term, end of
363-
# range, fails
364-
where = "index <= '%s'" % end_dt
365-
results = []
366-
for s in store.select('df',where=where,iterator=True, chunksize=1e4):
367-
results.append(s)
368-
result = concat(results)
369-
#tm.assert_frame_equal(expected, result)
370-
371220
# select w/iterator and where clause, inclusive range, fails
372221
where = "index >= '%s' & index <= '%s'" % (beg_dt, end_dt)
373222
results = []
374-
for s in store.select('df',where=where,iterator=True, chunksize=1e4):
223+
for s in store.select('df',where=where,iterator=True, chunksize=chunksize):
375224
results.append(s)
376225
result = concat(results)
377-
#tm.assert_frame_equal(expected, result)
378-
379-
def xtest_select_iterator_8014_3(self):
380-
381-
# single table
382-
with ensure_clean_store(self.path) as store:
383-
384-
df = tm.makeTimeDataFrame(300064, 'S')
385-
_maybe_remove(store, 'df')
386-
i = 0; ln = 200000
387-
store.append('df', df[i:i+ln])
388-
i = i+ln; ln = 58689
389-
store.append('df', df[i:i+ln])
390-
i = i+ln; ln = 41375
391-
store.append('df', df[i:i+ln])
392-
expected = df
393-
394-
beg_dt = expected.index[0]
395-
end_dt = expected.index[-1]
396-
397-
# select w/o iteration and no where clause works
398-
result = store.select('df')
399226
tm.assert_frame_equal(expected, result)
400227

401-
# select w/iterator and no where clause works
402-
results = []
403-
for s in store.select('df',iterator=True):
404-
results.append(s)
405-
result = concat(results)
406-
tm.assert_frame_equal(expected, result)
407-
408-
# select w/o iterator and where clause, single term, begin
409-
# of range, works
410-
where = "index >= '%s'" % beg_dt
411-
result = store.select('df',where=where)
412-
tm.assert_frame_equal(expected, result)
413-
414-
# select w/o iterator and where clause, single term, end
415-
# of range, works
416-
where = "index <= '%s'" % end_dt
417-
result = store.select('df',where=where)
418-
tm.assert_frame_equal(expected, result)
419-
420-
# select w/o iterator and where clause, inclusive range,
421-
# works
422-
where = "index >= '%s' & index <= '%s'" % (beg_dt, end_dt)
423-
result = store.select('df',where=where)
424-
tm.assert_frame_equal(expected, result)
425-
426-
#
427-
# with iterator
428-
#
429-
430-
# select w/iterator and where clause, single term, begin
431-
# of range, fails
432-
where = "index >= '%s'" % beg_dt
433-
results = []
434-
for s in store.select('df',where=where,iterator=True):
435-
results.append(s)
436-
result = concat(results)
437-
#tm.assert_frame_equal(expected, result)
438-
439-
# select w/iterator and where clause, single term, end of
440-
# range, fails
441-
where = "index <= '%s'" % end_dt
442-
results = []
443-
for s in store.select('df',where=where,iterator=True):
444-
results.append(s)
445-
result = concat(results)
446-
#tm.assert_frame_equal(expected, result)
447-
448-
# select w/iterator and where clause, inclusive range, fails
449-
where = "index >= '%s' & index <= '%s'" % (beg_dt, end_dt)
450-
results = []
451-
for s in store.select('df',where=where,iterator=True):
452-
results.append(s)
453-
result = concat(results)
454-
#tm.assert_frame_equal(expected, result)
455-
456228

457229
def _test_sort(obj):
458230
if isinstance(obj, DataFrame):

0 commit comments

Comments
 (0)