Skip to content

Commit

Permalink
BUG : don't use mutable objects as dictionary keys
Browse files Browse the repository at this point in the history
Base key on the id of the transform.  This maintains
the old behavior and does not break the python hashable
object model.

changed the variable id -> pid so as to not shadow the
method `id`

Closes matplotlib#2828
  • Loading branch information
tacaswell committed Jun 9, 2014
1 parent c73d9e6 commit 9b9c0c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
2014-06-07 Fixed bug so radial plots can be saved as ps in py3k.

2014-06-01 Changed the fmt kwarg of errorbar to support the
the mpl convention that "none" means "don't draw it",
and to default to the empty string, so that plotting
Expand Down
11 changes: 6 additions & 5 deletions lib/matplotlib/backends/backend_ps.py
Expand Up @@ -554,15 +554,16 @@ def _convert_path(self, path, transform, clip=False, simplify=None):
return ps

def _get_clip_path(self, clippath, clippath_transform):
id = self._clip_paths.get((clippath, clippath_transform))
if id is None:
id = 'c%x' % len(self._clip_paths)
ps_cmd = ['/%s {' % id]
key = (clippath, id(clippath_transform))
pid = self._clip_paths.get(key)
if pid is None:
pid = 'c%x' % len(self._clip_paths)
ps_cmd = ['/%s {' % pid]
ps_cmd.append(self._convert_path(clippath, clippath_transform,
simplify=False))
ps_cmd.extend(['clip', 'newpath', '} bind def\n'])
self._pswriter.write('\n'.join(ps_cmd))
self._clip_paths[(clippath, clippath_transform)] = id
self._clip_paths[key] = pid
return id

def draw_path(self, gc, path, transform, rgbFace=None):
Expand Down

0 comments on commit 9b9c0c6

Please sign in to comment.