-
-
Notifications
You must be signed in to change notification settings - Fork 11k
ENH: Allow reading from buffered stdout using np.fromfile #12324
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
Shippable failed with this test:
but I can't seem to find it when i search... |
cd63ae4
to
ac308ce
Compare
Is there a preference between
and
|
ac308ce
to
38d82ab
Compare
38d82ab
to
389505c
Compare
I'd probably opt for passing |
Ok. Any clue where the python 2.7 test is? Seems important... |
|
I've seen that failure on other PRs, but not all, or even all recent, so I don't know what is the cause. It seems inconsistent, only on shippable, and only on Python 2.7. Might try a rebase to see if that fixes it. |
389505c
to
0f3df44
Compare
Sorry my repo was out of sync. How is it even getting in that test? Path should be None..... I rebased, lets see what happens. |
The shippable CI uses |
Thanks @tylerjereddy. Is this considered a bugfix or feature? If it is a feature, then maybe we can just ignore 2.7? |
0f3df44
to
cbe2283
Compare
@charris didn't mean to ignore your comment. Thanks for chiming in. my webpage was out of sync. |
I opened another PR to try to fix the shippable 2.x issue. In that PR & here I see circleci now starting to fail for some reason! |
cbe2283
to
6d038b8
Compare
I can't see the old shippable output, as the link is discarded every time you rebase - so can't help you. Can you link to the failed output next time? Edit: https://app.shippable.com/github/numpy/numpy/runs/1301/1/tests, I assume |
@eric-wieser it seems that shippable is using a backport of pathlib, I didn't know that. Hence the discussion in #12330 |
@eric-wieser adding te comment here since that subthread is annoying. On the line: numpy/numpy/core/include/numpy/npy_3kcompat.h Line 220 in 619926d
It detects an error, but keeps going. Shouldn't it return in the if statement?
|
6d038b8
to
5814870
Compare
I would also like it if a |
5814870
to
1884fa7
Compare
Congrats, you found a bug |
73047f3
to
538f414
Compare
@eric-wieser It seems that the code that tries to guess how long a file is also uses seek, but doesn't check the Basically multiarraymodule.c should check the output of fp = npy_PyFile_Dup2(file, "rb", &orig_pos);
if (fp == NULL) {
Py_DECREF(file);
return NULL;
}
if (type == NULL) {
type = PyArray_DescrFromType(NPY_DEFAULT_TYPE);
}
ret = PyArray_FromFile(fp, type, (npy_intp) nin, sep); and return a resonable error message telling the user that they must specify In my mind, a patch would include a test that raises an exception when the count parameter isn't provided when trying to read from the stdout buffer. |
a2e78a1
to
482b315
Compare
Thanks eric, seems like there is a serious bug that was found due to the tests you requested. I'll have to keep looking into it. |
482b315
to
f488cc4
Compare
@eric-wieser i'm stumped. Basically, it works in pure python as shown by the tests https://travis-ci.org/numpy/numpy/jobs/453301883#L4540 only 2 "numpy-ic" fail, the two "pythonic" ones pass well. I split the tests so you can do it on your computer by checking out the commit before the mods to the implementation are done. My ultimate goal here would be to make a well tested I couldn't find many tests for |
1973034
to
912c9af
Compare
@hmaarrfk would you like to try to revive this? |
5088e2a
to
3a3a062
Compare
3a3a062
to
6bbdd65
Compare
Thanks mat. While I don't need this anymore, I think that it is a good addition. I'm not sure why the Honestly, if more tests are needed, I don't think I"ll be able to be in the right headspace to craft them. |
osx:
|
Unfortunately, these test failures are not ones I have an intention to debug anymore. This can be used as a reference in case anybody else wants to implement this feature in the future (perhaps even myself). |
Thanks for giving it a refresh, sorry it didn't pan out. |
Previously, np.fromfile would check if the object was an object of RawIO. If it was, then it wasn't seekable.
Unfortunately, (at least in python 3) this doesn't work for stdout as it is
buffered
but notseekable
(at least on linux).This fixes that by calling
file.seekable()
Tests are also added to ensure the behaviour lives on.
Fixes #12309
Patch from 2018, before rebase in 2022:
12324_before_rebase.patch.txt