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

Backport PR #13602 on branch v3.1.x (Deprecate cbook.is_hashable.) #13608

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
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
5 changes: 5 additions & 0 deletions 5 doc/api/next_api_changes/2019-03-06-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deprecations
````````````

``cbook.is_hashable`` is deprecated (use
``isinstance(..., collections.abc.Hashable)`` instead).
1 change: 1 addition & 0 deletions 1 lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def iterable(obj):
return True


@deprecated("3.1", alternative="isinstance(..., collections.abc.Hashable)")
def is_hashable(obj):
"""Returns true if *obj* can be hashed"""
try:
Expand Down
11 changes: 4 additions & 7 deletions 11 lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,18 +754,15 @@ def get_legend_handler(legend_handler_map, orig_handle):
method-resolution-order. If no matching key is found, it
returns ``None``.
"""
if is_hashable(orig_handle):
try:
return legend_handler_map[orig_handle]
except KeyError:
pass

try:
return legend_handler_map[orig_handle]
except (TypeError, KeyError): # TypeError if unhashable.
pass
for handle_type in type(orig_handle).mro():
try:
return legend_handler_map[handle_type]
except KeyError:
pass

return None

def _init_legend_box(self, handles, labels, markerfirst=True):
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.