Skip to content

BUG : bbox with any nan points can not overlap #4311

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 2 commits into from
Apr 19, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG : bbox with any nan points can not overlap
Fixes #4309
  • Loading branch information
tacaswell committed Apr 5, 2015
commit 3ab6b24c676d51c88b962cc9067d0dd539733d17
8 changes: 7 additions & 1 deletion lib/matplotlib/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from nose.tools import assert_equal, assert_raises
import numpy.testing as np_test
from numpy.testing import assert_almost_equal, assert_array_equal
from matplotlib.transforms import Affine2D, BlendedGenericTransform
from matplotlib.transforms import Affine2D, BlendedGenericTransform, Bbox
from matplotlib.path import Path
from matplotlib.scale import LogScale
from matplotlib.testing.decorators import cleanup, image_comparison
Expand Down Expand Up @@ -501,6 +501,12 @@ def test_log_transform():
ax.set_yscale('log')
ax.transData.transform((1,1))

@cleanup
def test_nan_overlap():
a = Bbox([[0, 0], [1, 1]])
b = Bbox([[0, 0], [1, np.nan]])
assert not a.overlaps(b)


if __name__=='__main__':
import nose
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ def overlaps(self, other):
"""
ax1, ay1, ax2, ay2 = self._get_extents()
bx1, by1, bx2, by2 = other._get_extents()
if any(np.isnan(v) for v in [ax1, ay1, ax2, ay2, bx1, by1, bx2, by2]):
return False

if ax2 < ax1:
ax2, ax1 = ax1, ax2
Expand Down