-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: Add support for file like objects to np.core.records.fromfile #16675
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the addition of the isfilelikeobj
necessary? The comment from 2504 indicates that the current implementation of isfileobj
can be replaced with the hasattr
check. Did you try this approach?
cf1f5bc
to
ccb84ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sticking with this through that conversation about compat
/isfileobj
, and thanks @anirudh2290 for helping to scope this out!
This LGTM. My only remaining comments would be
- Consider adding a comment similar to that added on L914-915 to the corresponding place in the
array
function (~L1003) - I also like @eric-wieser 's suggestion of using
isinstance(f, (io.RawIOBase, io.BufferedIOBase))
, which I think could be used in place of thehasattr
check and is a little easier to understand.
@sidhant007 besides the two small fixes, this needs a release note since we are enhancing behaviour. |
32f71e8
to
c2727d0
Compare
ppc64le CI build failure unrelated. I added a release note. Could one of the reviewers take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks @mattip for the release note
Thanks @sidhant007 |
This PR closes #2504
Now
np.core.records.fromfile
will support file like objects following the implementation advice mentioned hereExample: