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

Skip to content

Commit 3d6c9c0

Browse files
committed
Allow unhashable keys in AxesStack.
They simply will compare unequal to anything else.
1 parent 2228b5e commit 3d6c9c0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/matplotlib/figure.py

Lines changed: 3 additions & 2 deletions
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,8 +124,7 @@ def add(self, key, a):
122124
try:
123125
hash(key)
124126
except TypeError:
125-
raise ValueError(
126-
"first argument, {!r}, is not a valid key".format(key))
127+
key = object()
127128

128129
a_existing = self.get(key)
129130
if a_existing is not None:

0 commit comments

Comments
 (0)