Skip to content

Commit 49a3e0a

Browse files
committed
CLN: do not piggyback idx size on table obj
1 parent 9e16a40 commit 49a3e0a

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

pandas/io/pytables.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,11 +1459,6 @@ def __init__(self, store, s, func, where, nrows, start=None, stop=None,
14591459
stop = nrows
14601460
stop = min(nrows, stop)
14611461

1462-
# Piggy-back normalized `nrows` (considering start and stop) onto
1463-
# PyTables tables object so that the GenericIndexCol constructor
1464-
# knows how large the index should be.
1465-
self.s.table._nrows_to_read = stop - start
1466-
14671462
self.nrows = nrows
14681463
self.start = start
14691464
self.stop = stop
@@ -1632,7 +1627,7 @@ def infer(self, handler):
16321627
new_self.read_metadata(handler)
16331628
return new_self
16341629

1635-
def convert(self, values, nan_rep, encoding, errors):
1630+
def convert(self, values, nan_rep, encoding, errors, **kwargs):
16361631
""" set the values from this selection: take = take ownership """
16371632

16381633
# values is a recarray
@@ -1821,18 +1816,13 @@ class GenericIndexCol(IndexCol):
18211816
def is_indexed(self):
18221817
return False
18231818

1824-
def convert(self, values, nan_rep, encoding, errors):
1819+
def convert(self, values, nan_rep, encoding, errors, **kwargs):
18251820
""" set the values from this selection: take = take ownership """
18261821

1827-
if hasattr(self.table, '_nrows_to_read'):
1828-
# The `_nrows_to_read` property is set on the table object by the
1829-
# code path invoked by the top-level `read_hdf()`, and calculated
1830-
# based on the start` and `stop` integer values. These values allow
1831-
# for a sub-selection and likewise the index size needs to be
1832-
# adjusted to the size of this sub-selection.
1833-
self.values = Int64Index(np.arange(self.table._nrows_to_read))
1834-
else:
1835-
self.values = Int64Index(np.arange(self.table.nrows))
1822+
start = kwargs.get('start', 0)
1823+
stop = kwargs.get('stop', self.table.nrows)
1824+
stop = min(stop, self.table.nrows)
1825+
self.values = Int64Index(np.arange(stop - start))
18361826

18371827
return self
18381828

@@ -2176,7 +2166,7 @@ def validate_attr(self, append):
21762166
raise ValueError("appended items dtype do not match existing "
21772167
"items dtype in table!")
21782168

2179-
def convert(self, values, nan_rep, encoding, errors):
2169+
def convert(self, values, nan_rep, encoding, errors, **kwargs):
21802170
"""set the data from this selection (and convert to the correct dtype
21812171
if we can)
21822172
"""
@@ -3448,8 +3438,10 @@ def read_axes(self, where, **kwargs):
34483438
# convert the data
34493439
for a in self.axes:
34503440
a.set_info(self.info)
3441+
# `kwargs` may contain `start` and `stop` arguments if passed to
3442+
# `store.select()`. If set they determine the index size.
34513443
a.convert(values, nan_rep=self.nan_rep, encoding=self.encoding,
3452-
errors=self.errors)
3444+
errors=self.errors, **kwargs)
34533445

34543446
return True
34553447

0 commit comments

Comments
 (0)