36
36
update_path_extents )
37
37
from numpy .linalg import inv
38
38
39
- from weakref import WeakKeyDictionary
39
+ from weakref import WeakValueDictionary
40
40
import warnings
41
41
try :
42
42
set
43
43
except NameError :
44
44
from sets import Set as set
45
45
46
- import cbook
47
46
from path import Path
48
47
49
48
DEBUG = False
50
- if DEBUG :
51
- import warnings
52
49
53
50
MaskedArray = ma .MaskedArray
54
51
@@ -92,7 +89,7 @@ def __init__(self, shorthand_name=None):
92
89
# Parents are stored in a WeakKeyDictionary, so that if the
93
90
# parents are deleted, references from the children won't keep
94
91
# them alive.
95
- self ._parents = WeakKeyDictionary ()
92
+ self ._parents = WeakValueDictionary ()
96
93
97
94
# TransformNodes start out as invalid until their values are
98
95
# computed for the first time.
@@ -141,7 +138,7 @@ def _invalidate_internal(self, value, invalidating_node):
141
138
if self .pass_through or status_changed :
142
139
self ._invalid = value
143
140
144
- for parent in self ._parents .iterkeys ():
141
+ for parent in self ._parents .itervalues ():
145
142
parent ._invalidate_internal (value = value , invalidating_node = self )
146
143
147
144
def set_children (self , * children ):
@@ -152,7 +149,7 @@ def set_children(self, *children):
152
149
depend on other transforms.
153
150
"""
154
151
for child in children :
155
- child ._parents [self ] = None
152
+ child ._parents [id ( self ) ] = self
156
153
157
154
if DEBUG :
158
155
_set_children = set_children
@@ -1410,7 +1407,7 @@ def __init__(self, child):
1410
1407
1411
1408
def __eq__ (self , other ):
1412
1409
return self ._child .__eq__ (other )
1413
-
1410
+
1414
1411
if DEBUG :
1415
1412
def __str__ (self ):
1416
1413
return str (self ._child )
@@ -1496,7 +1493,7 @@ def __eq__(self, other):
1496
1493
if other .is_affine :
1497
1494
return np .all (self .get_matrix () == other .get_matrix ())
1498
1495
return NotImplemented
1499
-
1496
+
1500
1497
def transform (self , values ):
1501
1498
return self .transform_affine (values )
1502
1499
transform .__doc__ = Transform .transform .__doc__
@@ -1642,12 +1639,12 @@ def __init__(self, matrix=None, **kwargs):
1642
1639
def __repr__ (self ):
1643
1640
return "Affine2D(%s)" % repr (self ._mtx )
1644
1641
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
1651
1648
1652
1649
@staticmethod
1653
1650
def from_values (a , b , c , d , e , f ):
@@ -1893,7 +1890,7 @@ def __eq__(self, other):
1893
1890
return self ._x == other
1894
1891
else :
1895
1892
return NotImplemented
1896
-
1893
+
1897
1894
def contains_branch_seperately (self , transform ):
1898
1895
# Note, this is an exact copy of BlendedAffine2D.contains_branch_seperately
1899
1896
return self ._x .contains_branch (transform ), self ._y .contains_branch (transform )
0 commit comments