-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
WIP: Fix matplotlib, etc. errors #4804
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
While the numpy test obviously fails without change. This should fix all or almost all indexing test failures in matplotlib and the like. |
Fixed it up to something that should pretty much work. There is one special case here I was not aware of. The boolean index into a 1-d array special case always was strict about shape mismatches (I mean when the |
Py_DECREF(err); | ||
|
||
if (DEPRECATE( | ||
"assignment will raise an error in the future, most likely " |
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.
The message needs some \n
, otherwise it prints as one really long line. I noted that in some of the error messages in the failing tests, so those messages should also be broken into lines
Looks pretty straight forward. I not clear on whether the |
I didn't ;). I don't think we will deprecate |
@seberg How does your time look? I confess, some of the code causing problems is doing strange things, and sometimes it looks like there are actual errors in the code. That said, it seems that the 1d vs 2d boolean array indexes are causing most of the remaining problems. |
Hey, doesn't look to well right now unfortunatly :/. If we only want to fix the 1d boolean case, this could also be done in the boolean special case index parsinig part, by just reshaping the array there. |
Too bad about the time, but everyone needs to make a living :0. Now I suppose I'll need to learn something about the indexing code... Unfortunately, not all projects are as easy to test as NumPy. |
@seberg @juliantaylor The remaining Matplotlib errors look to me to be Matplotlib bugs, as the 2-d arrays that cause the problem are returned by the overloaded |
@charris Are you testing against master of matplotlib? Is there a discussion else where of what failures you are fixing? @ianthomas23 is the matplotlib export on the triangulation code. |
@tacaswell I'm testing against 1.3.1 from Fedora 20, I didn't want to actually build that beast ;) |
@tacaaswell Christoph Gohlke reported the test failures. There is some discussion on the numpy mailing list in the 1.9.0b1 release thread, and the errors may be found at http://www.lfd.uci.edu/~gohlke/pythonlibs/tests/20140609-win-amd64-py2.7-numpy-1.9.0b1/, |
mpl isn't that bad to build on linux. I ask because the triangulation code got a major overhaul and we are very near (hopefully by/at scipy) to releasing mpl 1.4 |
@tacaswell Well, I read the INSTALL file and it discouraged me ;). I used to build it years ago... |
I am not sure that it actually matters much to us if you fixed this in matplotlib. I will probably have a bit more look at it today. But overall I think this is almost done/OK in the sense that the method is OK and only string formatting/error handling details need to be smoothed out (which is tedious in C...). One small annoying detail about the new errors is that badly shaped boolean arrays (single array case) currently have worse errors, because the boolean array is converted to an integer one early on (and the error is reported for that). But I think we can live without improving that for 1.9 certainly. |
@seberg I've done the spelling & grammar fixes, so you can skip those if you work on this. |
Quick question, since the ML thread is long and I am not quite sure. So even with this applied matplotlib still has failures? |
with matplotlib/matplotlib#3188 applied the errors that @charris reported are fixed. I am currently re-running the entire test mpl test suite using np 1.9.0.dev-7a2b14a. |
No, I mean applying this PR, it should already fix all those indexing errors, assuming you are ignoring the deprecation/future warnings (just error reporting isn't very good yet). |
On Sat, Jul 5, 2014 at 9:19 AM, seberg [email protected] wrote:
Yes. There were two types of errors, one involving a flattened rhs, which Most problems with other packages were of the 1-d size mismatch sort, with The scikit-learn errors are different and I'll be taking a closer look at Chuck |
I take that back, matplotlib segfaults. |
Yep, the scikits-learn failures remain, so they are unrelated to this. |
Any hint on the matplotlib segfault? I guess this code might have a refcount bug or so. |
I'll try for a backtrace. Looks like sklearn is fixed in master. |
An example would be neat. Frankly, I only got the ubuntu matplotlib right now and that does not include the testing stuff... |
You can clonee the matplotlib repository, cd into it, and do |
This looks like the relevant part of the backtrace.
|
Oops, crap, I mus thave screwed up editing back and forth. There should be an incref on the error there. |
OK, pushed that fix. At least I assume this, otherwise there would be no error set, but I don't think that can happen. It seems it just happened to work almost always because of how python does error stuff. |
That won't work, the declarations don't all precede statements. |
Ops, changed. |
Though I guess we need to go over all that error handling back and forth anyway, and improve the warnings. |
} | ||
|
||
Py_XDECREF((PyObject *)self_iter); | ||
Py_DECREF(err); |
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.
Will fail if err
is NULL.
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.
If this occurs, there would be a bug elsewhere. But I am not sure if such a bug could not be even outside numpy, so I suppose we should do the sanity check...
Matplotlib tests pass now. Thanks Sebastian, with this and maybe one other fix I think we can do the next beta release. |
the pyfits readonly failure looks similar to the scipy failure, I'll have a look |
minimal testcase:
|
would this be a fix? --- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -1058,6 +1058,9 @@ array_boolean_subscript(PyArrayObject *self,
Py_DECREF(ret);
return NULL;
}
+ if (_IsWriteable(ret)) {
+ PyArray_ENABLEFLAGS(ret, NPY_ARRAY_WRITEABLE);
+ }
}
return ret; |
The commit messages could use a bit of cleanup, but I'm going to put this in as is. Thanks again Sebastian. |
WIP: Fix matplotlib, etc. errors
This seems like the correct fix: --- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -1569,7 +1569,7 @@ array_subscript(PyArrayObject *self, PyObject *op)
PyArray_SHAPE(tmp_arr),
PyArray_STRIDES(tmp_arr),
PyArray_BYTES(tmp_arr),
- 0, /* TODO: Flags? */
+ PyArray_FLAGS(self),
(PyObject *)self); The result now does not own the data necessarily, which was the case before. If that is needed, we would have to change the logic a bit (not set the base, but instead override the owndata flag) |
Yeah, should have been better, didn't think you would put it in yet :) |
I guess the flags don't matter if we allocate new data, etc. but since this isn't the case here, they seem to matter. |
Maybe I was a bit hasty. |
I would like the deprecation warning to show the actual error message. It might also make sense to replace the error again with the original one if the fallback failed as well.