@@ -75,7 +75,6 @@ def draw_wrapper(artist, renderer, *args, **kwargs):
75
75
def _stale_figure_callback (self ):
76
76
self .figure .stale = True
77
77
78
-
79
78
def _stale_axes_callback (self ):
80
79
self .axes .stale = True
81
80
@@ -91,37 +90,38 @@ class Artist(Configurable):
91
90
# warn on all : check whether serialize is/isn't required.
92
91
93
92
# perishable=True ==> set stale = True
94
- _transformSet = Bool (False , serialize = True )
93
+ _transformSet = Bool (False , serialize = True , config = True )
95
94
# warn : oInstance used, new TraitType?
96
- transform = oInstance ('matplotlib.transforms.Transform' , allow_none = True ,
97
- serialize = True , perishable = True )
95
+ transform = oInstance ('matplotlib.transforms.Transform' ,
96
+ serialize = True , perishable = True , config = True )
98
97
axes = Instance ('matplotlib.axes._axes.Axes' ,allow_none = True ,
99
- serialize = True )
100
- contains = Callable (allow_none = True )
98
+ serialize = True , config = True )
99
+ contains = Callable (allow_none = True , config = True )
101
100
figure = Instance ('matplotlib.figure.Figure' , allow_none = True ,
102
- serialize = True , perishable = True )
103
- visible = Bool (True , perishable = True , serialize = True )
104
- animated = Bool (False , perishable = True , serialize = True )
105
- alpha = Float (None , allow_none = True , perishable = True , serialize = True )
106
- url = Unicode (allow_none = True , serialize = True )
107
- gid = Unicode (allow_none = True , serialize = True )
101
+ serialize = True , perishable = True , config = True )
102
+ visible = Bool (True , perishable = True , serialize = True , config = True )
103
+ animated = Bool (False , perishable = True , serialize = True , config = True )
104
+ alpha = Float (None , allow_none = True , perishable = True , serialize = True , config = True )
105
+ url = Unicode (allow_none = True , serialize = True , config = True )
106
+ gid = Unicode (allow_none = True , serialize = True , config = True )
108
107
clipbox = Instance ('matplotlib.transforms.BboxBase' , allow_none = True ,
109
- perishable = True , serialize = True )
110
- snap = Bool (allow_none = True , perishable = True )
111
- clipon = Bool (True , perishable = True )
108
+ perishable = True , serialize = True , config = True )
109
+ snap = Bool (allow_none = True , perishable = True , config = True )
110
+ clipon = Bool (True , perishable = True , config = True )
112
111
# * setter and getter methods for `self._clippath` could be refactored
113
112
# using TraitTypes potentially ==> clippath = ?
114
- label = Union ([Unicode ('' ),Instance ('matplotlib.text.Text' ),Int ()],allow_none = True , perishable = True )
115
- rasterized = Bool (allow_none = True )
116
- _agg_filter = Callable (None ,allow_none = True , perishable = True )
117
- eventson = Bool (False )
113
+ label = Union ([Unicode ('' ),Instance ('matplotlib.text.Text' ),Int ()],
114
+ allow_none = True , perishable = True , config = True )
115
+ rasterized = Bool (allow_none = True , config = True )
116
+ _agg_filter = Callable (None ,allow_none = True , perishable = True , config = True )
117
+ eventson = Bool (True , config = True )
118
118
_sketch = Tuple (rcParams ['path.sketch' ], allow_none = True ,
119
- perishable = True ,serialize = True )
119
+ perishable = True ,serialize = True , config = True )
120
120
_path_effects = List (trait = Instance ('matplotlib.patheffects.AbstractPathEffect' ),
121
- allow_none = True , perishable = True , serialize = True )
122
- _propobservers = Dict ({}) # a dict from oids to funcs
123
- _oid = Int (0 ) # an observer id
124
-
121
+ allow_none = True , perishable = True , serialize = True , config = True )
122
+ _propobservers = Dict ({}, config = True ) # a dict from oids to funcs
123
+ _oid = Int (0 , config = True ) # an observer id
124
+
125
125
# sketch = mpltr.Tuple(allow_none=True)
126
126
# path_effects = mpltr.
127
127
@@ -135,12 +135,12 @@ def __init__(self, config=None, parent=None):
135
135
self .stale = True
136
136
self ._pickable = False
137
137
self ._clippath = None
138
- self ._picker = None
138
+ self ._picker = None
139
139
self ._remove_method = None
140
140
141
141
self ._sketch = rcParams ['path.sketch' ]
142
142
self ._path_effects = rcParams ['path.effects' ]
143
-
143
+
144
144
def __getstate__ (self ):
145
145
d = self .__dict__ .copy ()
146
146
# remove the unpicklable remove method, this will get re-added on load
@@ -197,18 +197,16 @@ def remove_callback(self, oid):
197
197
def _transform_changed (self , name , new ):
198
198
self ._transformSet = True
199
199
200
- def _transform_default (self ):
201
- return IdentityTransform ()
202
-
203
200
def _transform_overload (self , trait , value ):
204
- if (not isinstance (value , Transform )
201
+ if value is None :
202
+ return IdentityTransform ()
203
+ elif (not isinstance (value , Transform )
205
204
and hasattr (value , '_as_mpl_transform' )):
206
205
return value ._as_mpl_transform (self .axes )
207
- else :
208
- trait .error (self , value )
206
+ trait .error (self , value )
209
207
210
208
def _axes_changed (self , name , old , new ):
211
- if old is not Undefined :
209
+ if old not in [ Undefined , None ] :
212
210
# old != true already checked in `TraitType._validate`
213
211
raise ValueError ("Can not reset the axes. You are "
214
212
"probably trying to re-use an artist "
@@ -248,7 +246,7 @@ def _picker_changed(self, name, new):
248
246
if new is None :
249
247
self ._pickable = False
250
248
self ._pickable = True
251
-
249
+
252
250
# - - - - - - - - - - - - - - -
253
251
# warned setters and getters
254
252
# - - - - - - - - - - - - - - -
@@ -992,27 +990,23 @@ def update(self, props):
992
990
Update the properties of this :class:`Artist` from the
993
991
dictionary *prop*.
994
992
"""
995
- # add warn
996
- # all handled by configurable
997
- self .update_config (props )
998
-
999
- # store = self.eventson
1000
- # self.eventson = False
1001
- # changed = False
1002
-
1003
- # for k, v in six.iteritems(props):
1004
- # if k in ['axes']:
1005
- # setattr(self, k, v)
1006
- # else:
1007
- # func = getattr(self, 'set_' + k, None)
1008
- # if func is None or not six.callable(func):
1009
- # raise AttributeError('Unknown property %s' % k)
1010
- # func(v)
1011
- # changed = True
1012
- # self.eventson = store
1013
- # if changed:
1014
- # self.pchanged()
1015
- # self.stale = True
993
+ # all can be handleded by configurable
994
+ # self.update_config(config)
995
+
996
+ store = self .eventson
997
+ self .eventson = False
998
+ changed = False
999
+
1000
+ for k , v in six .iteritems (props ):
1001
+ if k in ['axes' ]:
1002
+ setattr (self , k , v )
1003
+ else :
1004
+ func = getattr (self , 'set_' + k , None )
1005
+ if func is None or not six .callable (func ):
1006
+ raise AttributeError ('Unknown property %s' % k )
1007
+ func (v )
1008
+ changed = True
1009
+ self .eventson = store
1016
1010
1017
1011
def get_zorder (self ):
1018
1012
"""
0 commit comments