You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Random test failures in Legent tests (1.5.0rc2) #5185
On my 10.11 OSX machine I am seeing random failures in legent tests such as
======================================================================
FAIL: matplotlib.tests.test_legend.test_various_labels.test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/usr/local/lib/python2.7/site-packages/matplotlib/testing/decorators.py", line 53, in failer
result = f(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/testing/decorators.py", line 220, in do_test
'(RMS %(rms).3f)'%err)
ImageComparisonFailure: images not close: /Users/jhn/src/python/matplotlib/result_images/test_legend/legend_various_labels.png vs. /Users/jhn/src/python/matplotlib/result_images/test_legend/legend_various_labels-expected.png (RMS 13.877)
This happens randomly for various of the tests with both python 2 and 3. I seem to be able to reproduce it outside the test suite so I don't think it is related to race conditions in the test code.
I see. This is really helpful investigation. I think it might make more sense to fix this on the C++ side (as there's still no guarantee we wouldn't hit this through some other code path).
Just going to give my braindump -- might not have a chance to work this into a proper PR until tomorrow. @tacaswell's suggestion is where I think it should be fixed, but not quite right. Part of the confusion is that it is the implementation of C++ size, which by convention in the C++ STL should be the size of the outermost dimension, and numpy.array.size means "the total number of elements in the array". I don't think we should change the definition of what size means on the C++ side. But it should do something like "if any element in shape is 0, return 0, else return shape[0]".
EDIT: I think we just posted at the same time. Anyway, I think what I'm suggesting should hopefully fix the bug without breaking everything.
Do you just want to check if the array is empty (any dimension is size zero) and bypass the counting loop or do you want to check that each bbox is correct size (1, 1) and incur the penalty on each iteration through the loop?
Special casing when there is a zero in one of the higher dims smells bad. I can not think of a use-case off the top of my head, but being able to iterate through the inner arrays of a (5, 0, 5) shaped array seems like something you should be allowed to do.
Yeah, you're probably right. I guess I'm coming around to fixes like #5245 being the right ones. But we should endeavor to fix those everywhere if we can.
I could try bounds checking in the inner loop like that, but I do fear it would be too slow (I can always check I suppose). The solution I'm working on now bounds checks the dimensions of the array once when wrapped in the C++ wrapper. It won't catch all cases where the array can be read out of bounds, but it will catch cases where the array doesn't match the expected shape (and in most cases, there is an expected shape).
Yes, bounds checking in the inner loops makes the code really slow. FWIW, I tried that and left the tests running, and all test failures it caused were from count_bboxes_overlapping_bbox.
Activity
jenshnielsen commentedon Oct 12, 2015
I still se this. No one else seeing it?
tacaswell commentedon Oct 12, 2015
is this single-process or multi-process testing? I have not seen this locally:
but have only been testing on 3.5
jenshnielsen commentedon Oct 12, 2015
Single process. Multiprocess is completely broken on OSX. It happens with both python 2.7 and 3.5 and I can reproduce it outside the test suite
mdboom commentedon Oct 12, 2015
Do you mean in general or just our test suite? Do we have an open issue for that? It would be good to fix.
tacaswell commentedon Oct 12, 2015
I can not reproduce this on linux + 3.5 (passed 100x times)
jenshnielsen commentedon Oct 12, 2015
Our test suite. I think there is an old issue somewhere
jenshnielsen commentedon Oct 12, 2015
Ok I will investigate again.
jenshnielsen commentedon Oct 12, 2015
It's not exactly #3314 but related to it.
jenshnielsen commentedon Oct 13, 2015
Running:
I see 15 failures as below (some repeated):
jenshnielsen commentedon Oct 13, 2015
This is on OSX 10.11 with Homebrew python 2.7 (I can also reproduce it with 3.5)
mdboom commentedon Oct 13, 2015
Indeed, this is more serious than I had thought. I should have some time to look at this tomorrow.
jenshnielsen commentedon Oct 13, 2015
Let me see if I can bisect it before doing anything else
tacaswell commentedon Oct 13, 2015
I can't reproduce on either 2.7 or 3.5 using up-to-date anaconda in linux.
7 remaining items
mdboom commentedon Oct 14, 2015
I see. This is really helpful investigation. I think it might make more sense to fix this on the C++ side (as there's still no guarantee we wouldn't hit this through some other code path).
tacaswell commentedon Oct 14, 2015
my fix breaks a whole bunch of things as where are a whole bunch of places where we use
size == a.shape[0]For expediency I think we should merge #5241 for 1.5 and fix the c++ layer for 2.1 unless I am over-estimating the effort to fix the c++ side.
mdboom commentedon Oct 14, 2015
Just going to give my braindump -- might not have a chance to work this into a proper PR until tomorrow. @tacaswell's suggestion is where I think it should be fixed, but not quite right. Part of the confusion is that it is the implementation of C++
size, which by convention in the C++ STL should be the size of the outermost dimension, andnumpy.array.sizemeans "the total number of elements in the array". I don't think we should change the definition of whatsizemeans on the C++ side. But it should do something like "if any element inshapeis 0, return 0, else returnshape[0]".EDIT: I think we just posted at the same time. Anyway, I think what I'm suggesting should hopefully fix the bug without breaking everything.
cimarronm commentedon Oct 14, 2015
Do you just want to check if the array is empty (any dimension is size zero) and bypass the counting loop or do you want to check that each bbox is correct size (1, 1) and incur the penalty on each iteration through the loop?
mdboom commentedon Oct 14, 2015
Each bbox should be the same size, so you'd only have to check once outside of the loop. But I do agree that would be better.
tacaswell commentedon Oct 14, 2015
ah, the numpy vs stl conventions make sense.
Special casing when there is a zero in one of the higher dims smells bad. I can not think of a use-case off the top of my head, but being able to iterate through the inner arrays of a
(5, 0, 5)shaped array seems like something you should be allowed to do.mdboom commentedon Oct 14, 2015
Yeah, you're probably right. I guess I'm coming around to fixes like #5245 being the right ones. But we should endeavor to fix those everywhere if we can.
jkseppan commentedon Oct 14, 2015
How about bounds checking in
array_view_accessors? If it turns out to be slow, make it optional and only turn it on for tests.mdboom commentedon Oct 14, 2015
I could try bounds checking in the inner loop like that, but I do fear it would be too slow (I can always check I suppose). The solution I'm working on now bounds checks the dimensions of the array once when wrapped in the C++ wrapper. It won't catch all cases where the array can be read out of bounds, but it will catch cases where the array doesn't match the expected shape (and in most cases, there is an expected shape).
Fix matplotlib#5185: Be more careful about array dims
jkseppan commentedon Oct 15, 2015
Yes, bounds checking in the inner loops makes the code really slow. FWIW, I tried that and left the tests running, and all test failures it caused were from
count_bboxes_overlapping_bbox.Throw errors when indexing into empty array_view objects
mdboom commentedon Oct 15, 2015
@jkseppan: Thanks for confirming my hunch about the slowness of bounds checking in the inner loop.
Fix matplotlib#5185: Be more careful about array dims