8000 FIX: account for None in Line2D.axes setter by tacaswell · Pull Request #4969 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: account for None in Line2D.axes setter #4969

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 1 commit into from
Aug 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
FIX: account for None in Line2D.axes setter
closes #4966
  • Loading branch information
tacaswell committed Aug 20, 2015
commit 344abbf230c21982bb66f11b04fca16db540f778
15 changes: 8 additions & 7 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,14 @@ def get_window_extent(self, renderer):
def axes(self, ax):
# call the set method from the base-class property
Artist.axes.fset(self, ax)
# connect unit-related callbacks
if ax.xaxis is not None:
self._xcid = ax.xaxis.callbacks.connect('units',
self.recache_always)
if ax.yaxis is not None:
self._ycid = ax.yaxis.callbacks.connect('units',
self.recache_always)
if ax is not None:
# connect unit-related callbacks
if ax.xaxis is not None:
self._xcid = ax.xaxis.callbacks.connect('units',
self.recache_always)
if ax.yaxis is not None:
self._ycid = ax.yaxis.callbacks.connect('units',
self.recache_always)

def set_data(self, *args):
"""
Expand Down
10 changes: 8 additions & 2 deletions lib/matplotlib/tests/test_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,27 @@ def test_cull_markers():
def test_remove():
fig, ax = plt.subplots()
im = ax.imshow(np.arange(36).reshape(6, 6))
ln, = ax.plot(range(5))

assert_true(fig.stale)
assert_true(ax.stale)

fig.canvas.draw()
assert_false(fig.stale)
assert_false(ax.stale)
assert_false(ln.stale)

assert_true(im in ax.mouseover_set)
assert_true(ln not in ax.mouseover_set)
assert_true(im.axes is ax)

im.remove()
ln.remove()

for art in [im, ln]:
assert_true(art.axes is None)
assert_true(art.figure is None)

assert_true(im.axes is None)
assert_true(im.figure is None)
assert_true(im not in ax.mouseover_set)
assert_true(fig.stale)
assert_true(ax.stale)
Expand Down
0