Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix twin remove #5682

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 5 commits into from
Dec 15, 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
Prev Previous commit
Next Next commit
ENH: add remove method to cbook.Grouper
 - also add tests
  • Loading branch information
tacaswell committed Dec 15, 2015
commit 2dfb60b852375df5a8b1421f06881db4c8ead3a4
8 changes: 8 additions & 0 deletions 8 lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,14 @@ def joined(self, a, b):
except KeyError:
return False

def remove(self, a):
self.clean()

mapping = self._mapping
seta = mapping.pop(ref(a), None)
if seta is not None:
seta.remove(ref(a))

def __iter__(self):
"""
Iterate over each of the disjoint sets as a list.
Expand Down
21 changes: 21 additions & 0 deletions 21 lib/matplotlib/tests/test_cbook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import itertools

from matplotlib.externals import six

Expand Down Expand Up @@ -376,3 +377,23 @@ def test_step_fails():
np.arange(12))
assert_raises(ValueError, cbook._step_validation,
np.arange(12), np.arange(3))


def test_grouper():
class dummy():
pass
a, b, c, d, e = objs = [dummy() for j in range(5)]
g = cbook.Grouper()
g.join(*objs)
assert set(list(g)[0]) == set(objs)
assert set(g.get_siblings(a)) == set(objs)

for other in objs[1:]:
assert g.joined(a, other)

g.remove(a)
for other in objs[1:]:
assert not g.joined(a, other)

for A, B in itertools.product(objs[1:], objs[1:]):
assert g.joined(A, B)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.