-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: pathlib support for fromfile(), .tofile() and .dump() #12915
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
Needs an entry in the 1.17.0 release notes. |
I must admit, I have no clue why this commit (3c060d5) would cause one particular build (Windows Python37-32bit-fast) to fail, while all the others pass.. As far as I can tell, the failing tests should be unaffected by the changes. I don't have access to a Windows machine, and I cannot reproduce on Linux Python37 32bit. |
Those matmul test failures are likely unrelated since we see them from time to time. Although they are only sporadic, it would be good to have them fixed. |
reopen to trigger re-test |
Needs a release note. |
Hmm, they seem to occur for complex64, same as for the wheels test failures. The wheels tests are checking |
Is this something that I need to do? |
You need to add an appropriate text description of the change to one of the sections in |
@sorenrasmussenai Ping. Take a look at |
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.
Looks good - I assume np.load
does not yet support path-likes, which is why the version-check is there?
import pathlib | ||
except ImportError: | ||
try: | ||
import pathlib2 as pathlib |
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.
I'm not actually sure our stuff works on pathlib2, or whether our CI exercises this code path.
Either way, if it turns out this test fails on systems using pathlib2, at least with the test present we'll likely get a bug report.
numpy/core/tests/test_multiarray.py
Outdated
def test_roundtrip_dump_pathlib(self): | ||
p = pathlib.Path(self.filename) | ||
self.x.dump(p) | ||
if sys.version_info[:2] >= (3, 6): |
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.
This shouldn't be necessary, numpy emulates the 3.6 behavior internally?
Needed a fix now that |
The windows failure looks like the occasional heisenbug in |
What version of python is the failing pypy? Failure looks like we're failing to detect a pathlike object in np.compat. |
3.6.3, latest nightly build, which recently fixed some pathlib issues but maybe not all of them |
self.x.dump(p) | ||
y = np.load(p, allow_pickle=True) | ||
assert_array_equal(y, self.x) | ||
|
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.
self.x.dump(p)
is failing to write to the file on PyPy, while self.x.tofile(p)
is working fine. Is there a call to flush
missing somewhere, or a missing close
to trigger the write?
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.
Good catch, #13684.
#13684 has been merged, now this has conflicts. Rebasing this off the new master HEAD (and resolving the conflicst) will give a linear history, merging master into the branch may work too. |
308940d
to
3c618a3
Compare
@mattip: Merged master into this branch, but probably worth squash-merging the PR as a whole |
Thanks @sorenrasmussenai and the reviewers |
See #8576
This is my first time messing with the Python C API, so I hope I didn't mess up too bad. I appreciate any feedback!