8000 ENH: pathlib support for fromfile(), .tofile() and .dump() by sorenrasmussenai · Pull Request #12915 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 9 commits into from
Jun 4, 2019

Conversation

sorenrasmussenai
Copy link
Contributor

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!

  • Soren

@charris
Copy link
Member
charris commented Feb 4, 2019

Needs an entry in the 1.17.0 release notes.

@charris charris added 01 - Enhancement component: numpy._core 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes labels Feb 4, 2019
@sorenrasmussenai
Copy link
Contributor Author

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.
Am I overlooking something? @eric-wieser

@tylerjereddy
Copy link
Contributor

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.

@sorenrasmussenai
Copy link
Contributor Author

reopen to trigger re-test

@charris
Copy link
Member
charris commented Feb 12, 2019

Needs a release note.

@charris
Copy link
Member
charris commented Feb 19, 2019

Those matmul test failures are likely unrelated since we see them from time to time.

Hmm, they seem to occur for complex64, same as for the wheels test failures. The wheels tests are checking pinv, but the tests also involve complex multiplication on stacked arrays.

@sorenrasmussenai
Copy link
Contributor Author

Needs a release note.

Is this something that I need to do?
Sorry for my ignorance :)

@mattip
Copy link
Member
mattip commented Mar 1, 2019

You need to add an appropriate text description of the change to one of the sections in doc/release/1.17.0-notes.rst

@charris
Copy link
Member
charris commented Mar 11, 2019

@sorenrasmussenai Ping. Take a look at doc/release/1.17.0-notes.rst and add something to the New Features section.

Copy link
Member
@eric-wieser eric-wieser left a 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
Copy link
Member

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.

def test_roundtrip_dump_pathlib(self):
p = pathlib.Path(self.filename)
self.x.dump(p)
if sys.version_info[:2] >= (3, 6):
Copy link
Member

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?

@eric-wieser eric-wieser removed the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label May 31, 2019
@eric-wieser eric-wieser added this to the 1.17.0 release milestone May 31, 2019
@eric-wieser
Copy link
Member

Needed a fix now that np.load cannot be used directly on pickle files any more. Added some docstrings while I was there

@mattip
Copy link
Member
mattip commented May 31, 2019

The windows failure looks like the occasional heisenbug in np.dot. The PyPy one seems more serious - not clear what is going on there, maybe a PyPy bug?

@eric-wieser
Copy link
Member
eric-wieser commented May 31, 2019

What version of python is the failing pypy? Failure looks like we're failing to detect a pathlike object in np.compat.

@mattip
Copy link
Member
mattip commented May 31, 2019

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)

Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

Good catch, #13684.

@mattip
Copy link
Member
mattip commented Jun 3, 2019

#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.

@eric-wieser
Copy link
Member

@mattip: Merged master into this branch, but probably worth squash-merging the PR as a whole

@mattip mattip merged commit afc6981 into numpy:master Jun 4, 2019
@mattip
Copy link
Member
mattip commented Jun 4, 2019

Thanks @sorenrasmussenai and the reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0