Skip to content

REF: make coordinates not a state variable in io.pytables #29805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

jbrockmendel
Copy link
Member

orthogonal to #29804.

@@ -1644,14 +1643,12 @@ def __init__(

self.auto_close = auto_close

def __iter__(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm on board with the goal, but is this really what we want to do? Wouldn't this mean that the TableIterator class is actually no longer an iterator by definition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess. In the case that doesn't go through 1674-1675 below TableIterator is already not really an iterator, so in that sense this makes the name consistently inaccuraet

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha sounds good. I'll defer to others more familiar with this code

@WillAyd WillAyd added the Clean label Nov 23, 2019
@@ -1644,14 +1643,12 @@ def __init__(

self.auto_close = auto_close

def __iter__(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so there is an open issue to have this just subclass BaseIterator which should preserve the correct iterator behavior. I would rather fix it that way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the issue you're referring to, but before long I'll do a dedicated look through the HDF5 issues to see what can be closed.

It isn't clear that subclassing BaseIterator would affect the statefulness that this PR is addressing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe #12953 or #10310

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm, not those. but in any event i think if you subclass BaseIterator this will just work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean collections.abc.Iterator? that would mean we'd have to define __next__ and __iter__ would return self. But for __next__ to work, it the relevant coordinates variable would have to be stateful, which is exactly what this PR is try to avoid

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a non-standard way of doing things, it needs to inheirt from https://github.com/pandas-dev/pandas/blob/master/pandas/io/common.py#L81

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the link.

If I'm reading you right, you are adamant that TableIterator itself should be an iterator. Is that accurate?

@jreback jreback added the IO HDF5 read_hdf, HDFStore label Nov 25, 2019
indirect = next(iterator.__iter__())
tm.assert_frame_equal(direct, indirect)
iterator.store.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its a problem not closing the iterator; the fact that you had to change this is suspicious

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iter_result does close the store

@jbrockmendel
Copy link
Member Author

This particular statefulness is turning out to not be that bothersome. Closing.

@jbrockmendel jbrockmendel deleted the cln-pytables12 branch December 16, 2019 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean IO HDF5 read_hdf, HDFStore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants