@@ -148,24 +148,20 @@ def tearDown(self):
148
148
def test_select_iterator_8014 (self ):
149
149
150
150
# single table
151
- chunksize = 1e4
152
151
with ensure_clean_store (self .path ) as store :
153
152
154
- df = tm .makeTimeDataFrame (100064 , 'S' )
153
+ chunksize = 1e4
154
+ expected = tm .makeTimeDataFrame (100064 , 'S' )
155
155
_maybe_remove (store , 'df' )
156
- i = 0 ; ln = 58689
157
- store .append ('df' , df [i :i + ln ])
158
- i = i + ln ; ln = 41375
159
- store .append ('df' , df [i :i + ln ])
160
- expected = df
156
+ store .append ('df' ,expected )
161
157
162
158
beg_dt = expected .index [0 ]
163
159
end_dt = expected .index [- 1 ]
164
160
165
161
#
166
162
# w/o iterator
167
163
#
168
-
164
+
169
165
# select w/o iteration and no where clause works
170
166
result = store .select ('df' )
171
167
tm .assert_frame_equal (expected , result )
@@ -193,35 +189,80 @@ def test_select_iterator_8014(self):
193
189
#
194
190
195
191
# select w/iterator and no where clause works
196
- results = []
197
- for s in store .select ('df' ,iterator = True , chunksize = chunksize ):
198
- results .append (s )
192
+ results = [ s for s in store .select ('df' ,chunksize = chunksize ) ]
193
+ result = concat (results )
194
+ tm .assert_frame_equal (expected , result )
195
+
196
+ # select w/iterator and where clause, single term, begin of range
197
+ where = "index >= '%s'" % beg_dt
198
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
199
+ result = concat (results )
200
+ tm .assert_frame_equal (expected , result )
201
+
202
+ # select w/iterator and where clause, single term, end of range
203
+ where = "index <= '%s'" % end_dt
204
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
205
+ result = concat (results )
206
+ tm .assert_frame_equal (expected , result )
207
+
208
+ # select w/iterator and where clause, inclusive range
209
+ where = "index >= '%s' & index <= '%s'" % (beg_dt , end_dt )
210
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
199
211
result = concat (results )
200
212
tm .assert_frame_equal (expected , result )
201
213
202
- # select w/iterator and where clause, single term, begin
203
- # of range, fails
214
+ #
215
+ # retrieve subset
216
+ #
217
+
218
+ l_expected = expected [1 :]
219
+ r_expected = expected [:- 1 ]
220
+ b_expected = expected [1 :- 1 ]
221
+ beg_dt = expected .index [1 ]
222
+ end_dt = expected .index [- 2 ]
223
+
224
+ #
225
+ # w/o iterator
226
+ #
227
+
228
+ # select w/o iterator and where clause, single term, begin
229
+ # of range, works
230
+ where = "index >= '%s'" % beg_dt
231
+ result = store .select ('df' ,where = where )
232
+ tm .assert_frame_equal (l_expected , result )
233
+
234
+ # select w/o iterator and where clause, single term, end
235
+ # of range, works
236
+ where = "index <= '%s'" % end_dt
237
+ result = store .select ('df' ,where = where )
238
+ tm .assert_frame_equal (r_expected , result )
239
+
240
+ # select w/o iterator and where clause, inclusive range,
241
+ # works
242
+ where = "index >= '%s' & index <= '%s'" % (beg_dt , end_dt )
243
+ result = store .select ('df' ,where = where )
244
+ tm .assert_frame_equal (b_expected , result )
245
+
246
+ #
247
+ # with iterator
248
+ #
249
+
250
+ # select w/iterator and where clause, single term, begin of range
251
+ # hang in the list comprehension
204
252
where = "index >= '%s'" % beg_dt
205
- results = []
206
- for s in store .select ('df' ,where = where ,iterator = True , chunksize = chunksize ):
207
- results .append (s )
253
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
208
254
result = concat (results )
209
255
tm .assert_frame_equal (expected , result )
210
256
211
- # select w/iterator and where clause, single term, end of
212
- # range, fails
257
+ # select w/iterator and where clause, single term, end of range
213
258
where = "index <= '%s'" % end_dt
214
- results = []
215
- for s in store .select ('df' ,where = where ,iterator = True , chunksize = chunksize ):
216
- results .append (s )
259
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
217
260
result = concat (results )
218
261
tm .assert_frame_equal (expected , result )
219
262
220
- # select w/iterator and where clause, inclusive range, fails
263
+ # select w/iterator and where clause, inclusive range
221
264
where = "index >= '%s' & index <= '%s'" % (beg_dt , end_dt )
222
- results = []
223
- for s in store .select ('df' ,where = where ,iterator = True , chunksize = chunksize ):
224
- results .append (s )
265
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
225
266
result = concat (results )
226
267
tm .assert_frame_equal (expected , result )
227
268
0 commit comments