-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Support fspath protocol #16301
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
ENH: Support fspath protocol #16301
Conversation
Wait till 0.21 on this? Technically this could be an API change for if people using This will cause one error in the pytables tests, since closed HDFStore objects don't allow object access, so I can't check Also, any feedback on the testing method? Typically we have the tests split by the kind of reader / writer. But for things like these protocols, it's nice to test the interface against every reader / writer that should support it, so I put in in |
@@ -89,6 +107,68 @@ def test_iterator(self): | |||
tm.assert_frame_equal(first, expected.iloc[[0]]) | |||
tm.assert_frame_equal(concat(it), expected.iloc[1:]) | |||
|
|||
@pytest.mark.parametrize('reader, module, path', [ |
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.
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.
though not sure whether I like better in each module, or centralized.
I like both :) Per-module for things specific to that, and centralized for "interface"-type things like this. The importskips are kind of annoying though. Happy to split this if you want.
I guess one alternative would be some kind of abstract base class for this set of tests, that would require methods to "implement" tests for test_fspath
, test_compression
, etc. That seems like a bit much to me though.
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.
yeah, I think this is fine actually, though #16292 would need to change (you can rebase on top maybe)?
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.
Yeah, going to do it on top #16292. We'll still need it for pathlib on 3.5, which doesn't implement fspath.
8c10784 has the API changes required on HDFStore. Relatively minor, so I'm ok with just changing it in 0.21, but we can do a deprecation if you want, or I can just code around it in |
ok to just change this |
Codecov Report
@@ Coverage Diff @@
## master #16301 +/- ##
==========================================
+ Coverage 90.39% 90.39% +<.01%
==========================================
Files 161 161
Lines 50863 50877 +14
==========================================
+ Hits 45977 45990 +13
- Misses 4886 4887 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #16301 +/- ##
=========================================
Coverage ? 90.4%
=========================================
Files ? 161
Lines ? 50987
Branches ? 0
=========================================
Hits ? 46096
Misses ? 4891
Partials ? 0
Continue to review full report at Codecov.
|
Rebased on top of #16292 I also added a third commit adding |
We also have |
pytest.raises(NotImplementedError, read_hdf, store, 'df') | ||
|
||
def test_read_hdf_generic_buffer_errors(self): | ||
pytest.raises(NotImplementedError, read_hdf, BytesIO(b''), 'df') |
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.
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.
sure
we DO include things, but should only be smallish test files. Don't work around things like that. |
I think your file is not included, because its not in the filter for package_data (for |
Previously, we called _check_if_open, which would raise a ClosedFileError whenever the desired attribute wasn't found. This prevented the check required for PEP519 to work properly, since hasattr shouldn't raise that error.
Ensures that most of pandas readers and writers will honor the fspath protocol, if an object defines it. TST: remove old xfails
- HDFStore - ExcelFile (cherry picked from commit f9baec385e2513234a69a05031d2753899290d38)
Completely forgot that I added the messagepack file :/ Fixed now. All green, other than that matplotlib test, which I'm going to debug now. |
@TomAugspurger lgtm. plotting occasional failures are unrelated and I think you have an issue for that anyhow. |
Thanks. I'm (trying to) debug the plotting stuff on my Travis branch, where it's currently not failing :/ |
* ENH: Support fspath protocol Ensures that most of pandas readers and writers will honor the fspath protocol, if an object defines it. TST: remove old xfails * API: Raise AttributeError on closed HDFStore Previously, we called _check_if_open, which would raise a ClosedFileError whenever the desired attribute wasn't found. This prevented the check required for PEP519 to work properly, since hasattr shouldn't raise that error. * ENH: add __fspath__ to pandas own file-like objects - HDFStore - ExcelFile
* ENH: Support fspath protocol Ensures that most of pandas readers and writers will honor the fspath protocol, if an object defines it. TST: remove old xfails * API: Raise AttributeError on closed HDFStore Previously, we called _check_if_open, which would raise a ClosedFileError whenever the desired attribute wasn't found. This prevented the check required for PEP519 to work properly, since hasattr shouldn't raise that error. * ENH: add __fspath__ to pandas own file-like objects - HDFStore - ExcelFile
Supports the fspath protocol in most readers and writers.
closes #13823
xref #14123