-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
masked arrays broken in py3k + gcc 5.1 on arch linux #4525
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
Comments
but one of my co-workers can not reproduce this |
I am not seeing the same bug. I am running current master
with python 3
and gcc 4.9.2
and numpy 1.9.2
|
Oh, right. And the output from running # use masked arrays to plot a line with different colors by y-value
from numpy import logical_or, arange, sin, pi
from numpy import ma
from matplotlib.pyplot import plot, show
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
upper = 0.77
lower = -0.77
supper = ma.masked_where(s < upper, s)
slower = ma.masked_where(s > lower, s)
smiddle = ma.masked_where(logical_or(s < lower, s > upper), s)
plot(t, slower, 'r', t, smiddle, 'b', t, supper, 'g')
show() is: |
I'm seeing the same thing as @ericdill. |
I get this behavior with two diffenent Arch Linux boxes with both numpy 1.9.2 and 1.8.2 On a ubuntu box I get the expected behavior (gcc 4.9.2). It does not work with system python + pip-installed almost everything on arch. |
The other fun thing about this is that as I pan what ever the left-most line segment is, is what is shown. I am seeing warnings like:
but I see them on the ubuntu box too |
This is almost certianly a complier/optimization if I throw in some couts in the nan-removal loop it works, remove them and it does not 22:55 $ git diff
diff --git a/src/path_converters.h b/src/path_converters.h
index 7755772..1db4f21 100644
--- a/src/path_converters.h
+++ b/src/path_converters.h
@@ -2,7 +2,7 @@
#ifndef __PATH_CONVERTERS_H__
#define __PATH_CONVERTERS_H__
-
+#include <iostream>
#include "agg_path_storage.h"
#include "agg_clip_liang_barsky.h"
#include "MPL_isnan.h"
@@ -213,15 +213,18 @@ class PathNanRemover : protected EmbeddedQueue<4>
{
/* This is the fast path for when we know we have no curves */
code = m_source->vertex(x, y);
+ std::cout << "in fast path" << std::endl;
if (code == agg::path_cmd_stop ||
code == (agg::path_cmd_end_poly | agg::path_flags_close)) {
+ std::cout << "found end" << std::endl;
return code;
}
-
+ std::cout << "x: " << *x << "y: "<< *y << std::endl;
if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)) {
do {
code = m_source->vertex(x, y);
+ std::cout << "** x: " << *x << "y: "<< *y << std::endl;
if (code == agg::path_cmd_stop ||
code == (agg::path_cmd_end_poly | agg::path_flags_close)) {
return code;
I will have a PR in soon that fixes this is a quieter way. |
With gcc 5.1.0 it seems that the inner loop of the fast-path in PathNanRemover gets optimized out of existence and the first non-finite entry in the path prevents any further drawing. This PR (rather hackishly) adds explicit de-references to x and y to the loop to make sure the compiler does not decide it is unneeded. Closes matplotlib#4525
Thanks for doing all of the legwork/research on this. A possible fix is in #4527. |
The fix in #4527 makes sense to me. However, perhaps a test based on the example should be added since this seems not to be covered by any tests presently |
It is covered by tests -- in fact, building with a gcc 5.1.0 compiler results in test failures on master. We don't have gcc 5.1.0 on Travis, of course. |
Ok great! |
This demo http://matplotlib.org/devdocs/examples/pylab_examples/color_by_yvalue.html is broken on python 3.
Only the left most plotted region is shown and happens either with ma arrays or
np.nan
filled arrays (have not started digging yet, I assume the eventually follow the same code path). Filling with 0 works as expected.I think bisect on this goes back to the cxx removal but many of the commits in there don't compile on python3 due to a numpy related gcc error so that isn't very helpful.
This smells like a subtle clipping bug.
attn @mdboom @efiring
The most common compilation error is:
Going to try rolling back to older versions of numpy te see if that fixes it.
For future reference, the output of bisect:
The first bad commit could be any of:
4a56cda
cfbf8d5
339537d
8dae818
6e19dac
a225968
697b3ef
c5ab747
5204635
af578f5
0624664
6d07179
ba40160
d862c47
d8c1d0d
We cannot bisect more!
Bisect Log:
git bisect start 'master' 'v1.4.3'
a165735 bad Merge pull request #4521 from jkseppan/issue-4475
21f46ff good REL : version 1.4.3
git bisect bad 056ba7a
056ba7a bad MNT : Remove
NavigationToolbar2QTAgg
git bisect bad 112f199
112f199 bad Merge pull request #3752 from astrofrog/rc_context_exceptions
git bisect good 34ed45a
34ed45a good Merge pull request #3291 from joferkington/lightsource-enhancements
git bisect bad c6f24d3
c6f24d3 bad Merge pull request #3665 from jkseppan/fix-gdk-strides
git bisect good 0f4a68d
0f4a68d good Merge pull request #3547 from jkseppan/numpy-deprecation
git bisect bad 7891790
7891790 bad Remove reference to PyCXX
git bisect skip 697b3ef
697b3ef skip Restore parallel testing
git bisect skip 6d07179
6d07179 skip Change how array converter functions are defined
git bisect good 7b206eb
7b206eb good Skip shading of masked array test on numpy 1.6
git bisect skip 8dae818
8dae818 skip Remove some obsolete TODOs
git bisect skip af578f5
af578f5 skip Add .clang-format to repository
git bisect good ea8617d
ea8617d good fix E201 and E202 pep8 errors
git bisect skip 4a56cda
4a56cda skip Fix compilation
git bisect skip d862c47
d862c47 skip Fix Mac compile again
git bisect skip cfbf8d5
cfbf8d5 skip Remove debugging prints
git bisect skip ba40160
ba40160 skip Remove use of PyCXX in core C++ extensions
git bisect skip 339537d
339537d skip Fix curve simplification
git bisect good dbeed94
dbeed94 good Merge pull request #3661 from jenshnielsen/numpy_16_fixes
git bisect skip 6e19dac
6e19dac skip Fix segfault on Python 3
git bisect skip 0624664
0624664 skip Fix test_hexbin_pickable test
git bisect skip c5ab747
c5ab747 skip More Python 3 fixes
git bisect skip a225968
a225968 skip Documentation
git bisect skip 5204635
5204635 skip Windows-related fixes, thanks to @cgohlke
git bisect bad d8c1d0d
d8c1d0d bad Remove usage of old Numpy API
The text was updated successfully, but these errors were encountered: