3636 update_path_extents )
3737from numpy .linalg import inv
3838
39- from weakref import WeakKeyDictionary
39+ from weakref import WeakValueDictionary
4040import warnings
4141try :
4242 set
4343except NameError :
4444 from sets import Set as set
4545
46- import cbook
4746from path import Path
4847
4948DEBUG = False
50- if DEBUG :
51- import warnings
5249
5350MaskedArray = ma .MaskedArray
5451
@@ -92,7 +89,7 @@ def __init__(self, shorthand_name=None):
9289 # Parents are stored in a WeakKeyDictionary, so that if the
9390 # parents are deleted, references from the children won't keep
9491 # them alive.
95- self ._parents = WeakKeyDictionary ()
92+ self ._parents = WeakValueDictionary ()
9693
9794 # TransformNodes start out as invalid until their values are
9895 # computed for the first time.
@@ -141,7 +138,7 @@ def _invalidate_internal(self, value, invalidating_node):
141138 if self .pass_through or status_changed :
142139 self ._invalid = value
143140
144- for parent in self ._parents .iterkeys ():
141+ for parent in self ._parents .itervalues ():
145142 parent ._invalidate_internal (value = value , invalidating_node = self )
146143
147144 def set_children (self , * children ):
@@ -152,7 +149,7 @@ def set_children(self, *children):
152149 depend on other transforms.
153150 """
154151 for child in children :
155- child ._parents [self ] = None
152+ child ._parents [id ( self ) ] = self
156153
157154 if DEBUG :
158155 _set_children = set_children
@@ -1410,7 +1407,7 @@ def __init__(self, child):
14101407
14111408 def __eq__ (self , other ):
14121409 return self ._child .__eq__ (other )
1413-
1410+
14141411 if DEBUG :
14151412 def __str__ (self ):
14161413 return str (self ._child )
@@ -1496,7 +1493,7 @@ def __eq__(self, other):
14961493 if other .is_affine :
14971494 return np .all (self .get_matrix () == other .get_matrix ())
14981495 return NotImplemented
1499-
1496+
15001497 def transform (self , values ):
15011498 return self .transform_affine (values )
15021499 transform .__doc__ = Transform .transform .__doc__
@@ -1642,12 +1639,12 @@ def __init__(self, matrix=None, **kwargs):
16421639 def __repr__ (self ):
16431640 return "Affine2D(%s)" % repr (self ._mtx )
16441641
1645- def __cmp__ (self , other ):
1646- # XXX redundant. this only tells us eq.
1647- if (isinstance (other , Affine2D ) and
1648- (self .get_matrix () == other .get_matrix ()).all ()):
1649- return 0
1650- return - 1
1642+ # def __cmp__(self, other):
1643+ # # XXX redundant. this only tells us eq.
1644+ # if (isinstance(other, Affine2D) and
1645+ # (self.get_matrix() == other.get_matrix()).all()):
1646+ # return 0
1647+ # return -1
16511648
16521649 @staticmethod
16531650 def from_values (a , b , c , d , e , f ):
@@ -1893,7 +1890,7 @@ def __eq__(self, other):
18931890 return self ._x == other
18941891 else :
18951892 return NotImplemented
1896-
1893+
18971894 def contains_branch_seperately (self , transform ):
18981895 # Note, this is an exact copy of BlendedAffine2D.contains_branch_seperately
18991896 return self ._x .contains_branch (transform ), self ._y .contains_branch (transform )
0 commit comments