Skip to content

Traitlets #4762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c202812
supress ipynb files
rmorshea Aug 6, 2015
9d4092e
todo list
rmorshea Jul 20, 2015
0edf017
refactoring with new workflow
rmorshea Jul 21, 2015
f73f7b6
transform refactoring : see TODO
rmorshea Jul 23, 2015
8b91ade
transform refactoring : see TODO
rmorshea Jul 23, 2015
ff69573
revert .gitignore
rmorshea Jul 23, 2015
602ce41
remove ipynb_checkpoints
rmorshea Jul 23, 2015
97167ac
see TODO
rmorshea Jul 23, 2015
52fdc79
see TODO
rmorshea Jul 23, 2015
de152bc
see TODO
rmorshea Jul 23, 2015
ae5b5ba
transform implamented
rmorshea Jul 30, 2015
5f58d90
progress update
rmorshea Jul 30, 2015
a8a1f18
see TODO
rmorshea Aug 1, 2015
664c02a
last update of refactor
rmorshea Aug 1, 2015
0275157
ignore refactor
rmorshea Aug 1, 2015
e258cd2
last update to refactor
rmorshea Aug 1, 2015
a14f83b
comment change
rmorshea Aug 2, 2015
e238441
rebase with origin/master (up to date with upstream/master)
rmorshea Aug 2, 2015
97f0532
add figure traitlet
rmorshea Aug 5, 2015
e1d976d
shrink file
rmorshea Aug 5, 2015
d85e2c1
progress towards full test suite pass
rmorshea Aug 14, 2015
b6d3e45
errors reduced to pickling and ref counts
rmorshea Aug 14, 2015
be7f591
update rebase
rmorshea Aug 14, 2015
5609b44
fix memory leak in Artist
rmorshea Aug 14, 2015
871388d
fix memory leaks in test_quiver.py
rmorshea Aug 14, 2015
4030397
fix exdict inheritance
rmorshea Aug 15, 2015
5a2160f
fix pickling
rmorshea Aug 15, 2015
b436bee
update traitlets
rmorshea Aug 15, 2015
593e34c
remove print statement
rmorshea Aug 15, 2015
4b6195c
resolve pickling
rmorshea Aug 16, 2015
d11236c
update exdict
rmorshea Aug 16, 2015
1debbd0
simple performance test
rmorshea Aug 16, 2015
bbf1c89
update TODO progress report
rmorshea Aug 16, 2015
709bdac
refactor visible and animated
rmorshea Aug 17, 2015
867899c
shrink file
rmorshea Aug 17, 2015
cfb0713
refactor alpha, but failed alpha blending in agg
rmorshea Aug 17, 2015
e9c8489
refactor rasterize, pickable, evenston
rmorshea Aug 18, 2015
a2e6676
update rebase
rmorshea Aug 18, 2015
299ceb2
FIX: revert changes to gc calls
tacaswell Aug 18, 2015
93945ab
fix memory leak
rmorshea Aug 18, 2015
9934482
see TODO
rmorshea Aug 21, 2015
22e4b0c
change property updates via name
rmorshea Aug 23, 2015
9b65ee0
see TODO
rmorshea Aug 25, 2015
9528a83
base artist refactor complete: see TODO
rmorshea Aug 25, 2015
f69490b
fix sketch_params/path_effects default
rmorshea Aug 25, 2015
afddefe
fix setp/getp, change forced callbacks
rmorshea Aug 25, 2015
cd1d60a
reintroduce traitlets test
rmorshea Aug 26, 2015
89caa0f
fix typo
rmorshea Sep 8, 2015
7717e07
update rebased commits
rmorshea Sep 8, 2015
57131b2
add traitlets as test dep
rmorshea Sep 8, 2015
6aacb91
simplify old value store for forced callbacks
rmorshea Sep 9, 2015
4cf88ff
use new traitlets api (has quiver memory leaks)
rmorshea Sep 16, 2015
bb02b38
add @retrieve decorator
rmorshea Sep 18, 2015
a43cdf9
correct private get
rmorshea Oct 2, 2015
be3de2f
now requires most revent version of traitlets
rmorshea Oct 5, 2015
340df20
reintroduce mute context manager, and begin uncommenting legacy sette…
rmorshea Oct 6, 2015
84ac0ff
edit traitlets as test dep
rmorshea Oct 6, 2015
7dc256a
finish uncommenting setters/getters
rmorshea Oct 8, 2015
d895089
MNT: minor fixes
tacaswell Oct 8, 2015
6ba2c89
TST: use bleeding edge branch for traitlets
tacaswell Oct 8, 2015
0064153
pep8 fixes
rmorshea Oct 9, 2015
ffe9d09
final pep8 fixes
rmorshea Oct 9, 2015
bdf6622
traitlet warning supression
rmorshea Oct 9, 2015
08a6db7
fix pylab example
rmorshea Oct 12, 2015
0d936ed
supress more warnings
rmorshea Oct 14, 2015
9d76e5a
supress more warnings
rmorshea Oct 14, 2015
3826b49
correct impropper validate usage
rmorshea Nov 2, 2015
abba50b
correct after rebase
rmorshea Nov 20, 2015
d8f65db
setattr in SimpleChainedObjects
rmorshea Nov 22, 2015
1917a2d
fix travis.yml after rebase
rmorshea Nov 22, 2015
86a9b69
misc edits, mark as changed only if setter is used
rmorshea Nov 23, 2015
40d5b49
change traitlets warn message
rmorshea Dec 2, 2015
0d1eb25
COMPRESS
rmorshea Mar 9, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pep8 fixes
  • Loading branch information
rmorshea committed Nov 27, 2015
commit 0064153e6cb44b49b3400834ba13a86949e906ed
46 changes: 25 additions & 21 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
TransformedPatchPath, TransformedPath, Transform)
from .path import Path

from .traitlets import (Instance, Configurable, TransformInstance, Bool, Undefined, Union,
BaseDescriptor, getargspec, PrivateMethodMixin, Float, TraitError,
Unicode, Stringlike, Callable, Tuple, List, observe, validate, default,
retrieve, _traitlets_deprecation_msg)
from .traitlets import (Instance, Configurable, TransformInstance, Bool,
Undefined, Union, BaseDescriptor, getargspec,
PrivateMethodMixin, Float, TraitError, Unicode,
Stringlike, Callable, Tuple, List, observe, validate,
default, retrieve, _traitlets_deprecation_msg)


# Note, matplotlib artists use the doc strings for set and get
Expand Down Expand Up @@ -126,13 +127,13 @@ def _stale_changed(self, change):
@observe('axes')
def _axes_changed(self, change):
new, old = change['new'], change['old']
if new and old not in (Undefined,None):
if new and old not in (Undefined, None):
raise ValueError("Can not reset the axes. You are "
"probably trying to re-use an artist "
"in more than one Axes which is not "
"supported")

if new not in (Undefined,None) and new is not self:
if new not in (Undefined, None) and new is not self:
self.stale_callback = _stale_axes_callback

figure = Instance(str('matplotlib.figure.FigureBase'), allow_none=True)
Expand Down Expand Up @@ -166,7 +167,7 @@ def _animated_changed(self, change):

@validate('alpha')
def _alpha_validate(self, commit):
if 0>commit['value']>1:
if 0 > commit['value'] > 1:
msg = ("The '%s' trait of %s instance can only be"
" transparent (0.0) through opaque (1.0)")
repl = (commit['trait'].name, self.__class__.__name__)
Expand Down Expand Up @@ -242,7 +243,7 @@ def _clipon_changed(self, change):
def _label_changed(self, change):
self.pchanged()

picker = Union((Bool(),Float(),Callable()), allow_none=True)
picker = Union((Bool(), Float(), Callable()), allow_none=True)

@default('picker')
def _picker_default(self): pass
Expand Down Expand Up @@ -795,12 +796,14 @@ def get_sketch_params(self):

May return `None` if no sketch parameters were set.
"""
msg = ("This has been deprecated to make way for IPython's Traitlets. Please"
" use the 'sketch_params' property or the TraitTypes it references.")
msg = ("This has been deprecated to make way for IPython's"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove the IPython's here (and elsewhere similar messages appear). This is not to avoid giving credit where credit is due, just that this could imply that we are growing a dependency on IPython, which we aren't.

" Traitlets. Please use the 'sketch_params' property"
" or the TraitTypes it references.")
warnings.warn(msg, mplDeprecation, stacklevel=1)
return self.sketch_params

def set_sketch_params(self, scale=None, length=None, randomness=None, all=None):
def set_sketch_params(self, scale=None, length=None,
randomness=None, all=None):
"""
Sets the sketch parameters.

Expand Down Expand Up @@ -1078,7 +1081,7 @@ def update(self, props):
else:
#!DEPRICATED set_name access should eventually be removed
klass = self.__class__
if isinstance(getattr(klass, k, None),BaseDescriptor):
if isinstance(getattr(klass, k, None), BaseDescriptor):
setattr(self, k, v)
else:
func = getattr(self, 'set_' + k, None)
Expand Down Expand Up @@ -1164,7 +1167,7 @@ def set(self, **kwargs):
ret.extend([func(v)])
else:
klass = self.__class__
if isinstance(getattr(klass, k, None),BaseDescriptor):
if isinstance(getattr(klass, k, None), BaseDescriptor):
ret.extend([setattr(self, k, v)])
else:
raise TypeError('There is no %s property "%s"' %
Expand Down Expand Up @@ -1600,15 +1603,16 @@ def getp(obj, property=None):
print('\n'.join(ret))
return

func = getattr(obj, 'get_' + property, None)
if func is not None and six.callable(func):
return func()
klass = obj.__class__
if isinstance(getattr(klass, property, None), BaseDescriptor):
return getattr(obj, property)
else:
klass = obj.__class__
if isinstance(getattr(klass, property, None),BaseDescriptor):
return getattr(obj, property)
func = getattr(obj, 'get_' + property, None)
if func is not None and six.callable(func):
return func()
else:
raise AttributeError('Unknown property %s for %s' % (property,str(obj)))
msg = 'Unknown property %s for %s'
raise AttributeError(msg % (property, str(obj)))

# alias
get = getp
Expand Down Expand Up @@ -1691,7 +1695,7 @@ def setp(obj, *args, **kwargs):
ret.extend([func(val)])
else:
klass = o.__class__
if isinstance(getattr(klass, s, None),BaseDescriptor):
if isinstance(getattr(klass, s, None), BaseDescriptor):
ret.extend([setattr(o, s, val)])
else:
raise TypeError('There is no %s property "%s"' %
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _get_legend_handles(self, legend_handler_map=None):
has_handler = mlegend.Legend.get_legend_handler

for handle in handles_original:
label = handle.label if hasattr(handle,'label') else handle.get_label()
label = handle.label if hasattr(handle, 'label') else handle.get_label()
if label != '_nolegend_' and has_handler(handler_map, handle):
yield handle

Expand All @@ -274,10 +274,10 @@ def get_legend_handles_labels(self, legend_handler_map=None):
"""
handles = []
labels = []
for handle in self._get_legend_handles(legend_handler_map):
label = handle.label if hasattr(handle,'label') else handle.get_label()
for h in self._get_legend_handles(legend_handler_map):
label = h.label if hasattr(h, 'label') else h.get_label()
if label and not label.startswith('_'):
handles.append(handle)
handles.append(h)
labels.append(label)

return handles, labels
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ def __init__(self, fig, rect,
else:
self.figure = fig


self.set_axes_locator(kwargs.get("axes_locator", None))

self.spines = self._gen_axes_spines()
Expand Down Expand Up @@ -599,7 +598,7 @@ def _figure_changed(self, change):
martist.Artist._figure_changed(self, change)

tbox = mtransforms.TransformedBbox
self.bbox = tbox(self._position,change['new'].transFigure)
self.bbox = tbox(self._position, change['new'].transFigure)

# these will be updated later as data is added
self.dataLim = mtransforms.Bbox.null()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def get_scale(self):
def _set_scale(self, value, **kwargs):
self._scale = mscale.scale_factory(value, self, **kwargs)
self._scale.set_default_locators_and_formatters(self)

self.isDefault_majloc = True
self.isDefault_minloc = True
self.isDefault_majfmt = True
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ def _find_closest_point_on_path(lc, point):

return (dmin, xcmin, legmin)


class ContourSet(cm.ScalarMappable, ContourLabeler):
"""
Store a set of contour lines or filled regions.
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,9 @@ def __init__(self, base=1, month=1, day=1, tz=None):
"""
DateLocator.__init__(self, tz)
self.base = ticker.Base(base)
self.replaced = {'month': month,
'day': day,
'hour': 0,
self.replaced = {'month': month,
'day': day,
'hour': 0,
'minute': 0,
'second': 0,
'tzinfo': tz
Expand Down Expand Up @@ -1531,7 +1531,7 @@ def axisinfo(unit, axis):
The *axis* argument is required but not used.
"""
tz = unit

majloc = AutoDateLocator(tz=tz)
majfmt = AutoDateFormatter(majloc, tz=tz)
datemin = datetime.date(2000, 1, 1)
Expand Down
10 changes: 6 additions & 4 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,12 @@ def _update_this(self, s, val):

setattr(self, s, val)

# used solely for passing an empty figure class to
# the "figure" attribute of an artist which will pass
# a boolean test (e.g `True if figure else False`)
class FigureBase(object): pass
# used solely for giving an empty figure class to
# the "figure" attribute of an artist which performs
# a type check (e.g `True if figure else False`)
class FigureBase(object):
pass


class Figure(FigureBase, Artist):

Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ def draw_frame(self, renderer):
if self._drawFrame:
self.patch.draw(renderer)


class DrawingArea(OffsetBox):
"""
The DrawingArea can contain any Artist as a child. The DrawingArea
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/quiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ def __init__(self, ax, *args, **kw):
# that can be easily warned because defining a property to raise it
# will override the traittype defined at the class level.
self.quiver_transform = kw.pop('transform', ax.transData)

kw.setdefault('facecolors', self.color)
kw.setdefault('linewidths', (0,))
kw.setdefault('linewidths', (0, ))
mcollections.PolyCollection.__init__(self, [], offsets=self.XY,
transOffset=self.quiver_transform,
closed=False,
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def add_cell(self, row, col, *args, **kwargs):
cell = CustomCell(xy, visible_edges=self.edges, *args, **kwargs)
cell.figure = self.figure
cell.transform = self.transform

self._cells[(row, col)] = cell
self.stale = True

Expand Down
Loading