Skip to content

Commit 4655bb9

Browse files
committed
update
1 parent 6812453 commit 4655bb9

File tree

1 file changed

+49
-55
lines changed

1 file changed

+49
-55
lines changed

lib/matplotlib/artist.py

Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def draw_wrapper(artist, renderer, *args, **kwargs):
7575
def _stale_figure_callback(self):
7676
self.figure.stale = True
7777

78-
7978
def _stale_axes_callback(self):
8079
self.axes.stale = True
8180

@@ -91,37 +90,38 @@ class Artist(Configurable):
9190
# warn on all : check whether serialize is/isn't required.
9291

9392
# perishable=True ==> set stale = True
94-
_transformSet = Bool(False, serialize=True)
93+
_transformSet = Bool(False, serialize=True, config=True)
9594
# 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)
9897
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)
101100
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)
108107
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)
112111
# * setter and getter methods for `self._clippath` could be refactored
113112
# 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)
118118
_sketch = Tuple(rcParams['path.sketch'], allow_none=True,
119-
perishable=True,serialize=True)
119+
perishable=True,serialize=True, config=True)
120120
_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+
125125
# sketch = mpltr.Tuple(allow_none=True)
126126
# path_effects = mpltr.
127127

@@ -135,12 +135,12 @@ def __init__(self, config=None, parent=None):
135135
self.stale = True
136136
self._pickable = False
137137
self._clippath = None
138-
self._picker = None
138+
self._picker = None
139139
self._remove_method = None
140140

141141
self._sketch = rcParams['path.sketch']
142142
self._path_effects = rcParams['path.effects']
143-
143+
144144
def __getstate__(self):
145145
d = self.__dict__.copy()
146146
# remove the unpicklable remove method, this will get re-added on load
@@ -197,18 +197,16 @@ def remove_callback(self, oid):
197197
def _transform_changed(self, name, new):
198198
self._transformSet = True
199199

200-
def _transform_default(self):
201-
return IdentityTransform()
202-
203200
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)
205204
and hasattr(value, '_as_mpl_transform')):
206205
return value._as_mpl_transform(self.axes)
207-
else:
208-
trait.error(self, value)
206+
trait.error(self, value)
209207

210208
def _axes_changed(self, name, old, new):
211-
if old is not Undefined:
209+
if old not in [Undefined, None]:
212210
# old != true already checked in `TraitType._validate`
213211
raise ValueError("Can not reset the axes. You are "
214212
"probably trying to re-use an artist "
@@ -248,7 +246,7 @@ def _picker_changed(self, name, new):
248246
if new is None:
249247
self._pickable = False
250248
self._pickable = True
251-
249+
252250
# - - - - - - - - - - - - - - -
253251
# warned setters and getters
254252
# - - - - - - - - - - - - - - -
@@ -992,27 +990,23 @@ def update(self, props):
992990
Update the properties of this :class:`Artist` from the
993991
dictionary *prop*.
994992
"""
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
10161010

10171011
def get_zorder(self):
10181012
"""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy