Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4e83b4

Browse files
committed
Allow unhashable keys in AxesStack.
They simply will compare unequal to anything else.
1 parent 102b4a5 commit c4e83b4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/figure.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def add(self, key, a):
112112
"""
113113
Add Axes *a*, with key *key*, to the stack, and return the stack.
114114
115+
If *key* is unhashable, replace it by a unique, arbitrary object.
116+
115117
If *a* is already on the stack, don't add it again, but
116118
return *None*.
117119
"""
@@ -122,7 +124,7 @@ def add(self, key, a):
122124
try:
123125
hash(key)
124126
except TypeError:
125-
raise ValueError("first argument, %s, is not a valid key" % key)
127+
key = object()
126128

127129
a_existing = self.get(key)
128130
if a_existing is not None:

0 commit comments

Comments
 (0)