Thanks to visit codestin.com
Credit goes to github.com

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
transform refactoring : see TODO
  • Loading branch information
rmorshea committed Nov 27, 2015
commit f73f7b60ed3bb7c62565d25235c2f7278032612c
11 changes: 5 additions & 6 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@
1.2) write relevant imports
1.3) make the method changes


# in TextMate
# using custom script
2.0) locate method references
2.1) changed the method references

3.0) locate underscored attr references
3.1) change the underscored attrs

4.0) if property find normal references
4.1) change the underscored attrs
4.0) run test suite
4.1) rework for passing

5.0) complete
5.0) compelete

-- STATUS --

1.3 : transform
2.1 : transform
0.2 : transform_set
0.2 : stale
0.0 : visible
Expand Down
57 changes: 33 additions & 24 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
TransformedPatchPath, TransformedPath, Transform)
from .path import Path

from .traitlets import Configurable, TransformInstance, Bool

# Note, matplotlib artists use the doc strings for set and get
# methods to enable the introspection methods of setp and getp. Every
# set_* method should have a docstring containing the line
Expand All @@ -31,6 +33,8 @@
# as far as I can see - see
# http://groups.google.com/groups?hl=en&lr=&threadm=mailman.5090.1098044946.5135.python-list%40python.org&rnum=1&prev=/groups%3Fq%3D__doc__%2Bauthor%253Ajdhunter%2540ace.bsd.uchicago.edu%26hl%3Den%26btnG%3DGoogle%2BSearch

class Undefined(object): pass
Undefined = Undefined()

def allow_rasterization(draw):
"""
Expand Down Expand Up @@ -77,7 +81,7 @@ def _stale_axes_callback(self):
self.axes.stale = True


class Artist(object):
class Artist(Configurable):
"""
Abstract base class for someone who renders into a
:class:`FigureCanvas`.
Expand All @@ -88,7 +92,7 @@ class Artist(object):

transform = TransformInstance(IdentityTransform())

def _tranform_changed(self):
def _transform_changed(self):
self.transform_set = True
self.pchanged()
self.stale = True
Expand Down Expand Up @@ -260,25 +264,27 @@ def axes(self, new_axes):

return new_axes

@property
def stale(self):
"""
If the artist is 'stale' and needs to be re-drawn for the output to
match the internal state of the artist.
"""
return self._stale
#!DEPRECATED
# @property
# def stale(self):
# """
# If the artist is 'stale' and needs to be re-drawn for the output to
# match the internal state of the artist.
# """
# return self._stale

@stale.setter
def stale(self, val):
# only trigger call-back stack on being marked as 'stale'
# when not already stale
# the draw process will take care of propagating the cleaning
# process
if not (self._stale == val):
self._stale = val
# only trigger propagation if marking as stale
if self._stale:
self.pchanged()
#!DEPRECATED
# @stale.setter
# def stale(self, val):
# # only trigger call-back stack on being marked as 'stale'
# # when not already stale
# # the draw process will take care of propagating the cleaning
# # process
# if not (self._stale == val):
# self._stale = val
# # only trigger propagation if marking as stale
# if self._stale:
# self.pchanged()

def get_window_extent(self, renderer):
"""
Expand Down Expand Up @@ -680,7 +686,7 @@ def set_clip_path(self, path, transform=None):
if transform is None:
if isinstance(path, Rectangle):
self.clipbox = TransformedBbox(Bbox.unit(),
path.get_transform())
path.transform)
self._clippath = None
success = True
elif isinstance(path, Patch):
Expand Down Expand Up @@ -852,9 +858,12 @@ def update(self, props):
setattr(self, k, v)
else:
func = getattr(self, 'set_' + k, None)
if func is None or not six.callable(func):
if func is not None and six.callable(func):
func(v)
elif getattr(self, k, Undefined) is not Undefined:
setattr(self, k, v)
else:
raise AttributeError('Unknown property %s' % k)
func(v)
changed = True
self.eventson = store
if changed:
Expand Down Expand Up @@ -899,7 +908,7 @@ def set_zorder(self, level):

def update_from(self, other):
'Copy properties from *other* to *self*.'
self._transform = other._transform
self.transform = other.transform
self._transformSet = other._transformSet
self._visible = other._visible
self._alpha = other._alpha
Expand Down
13 changes: 6 additions & 7 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,8 @@ def get_yaxis_text2_transform(self, pad_points):
"center", "left")

def _update_transScale(self):
self.transScale.set(
mtransforms.blended_transform_factory(
self.xaxis.get_transform(), self.yaxis.get_transform()))
self.transScale.set(mtransforms.blended_transform_factory(
self.xaxis.transform, self.yaxis.transform))
if hasattr(self, "lines"):
for line in self.lines:
try:
Expand Down Expand Up @@ -864,7 +863,7 @@ def get_axes_locator(self):
def _set_artist_props(self, a):
"""set the boilerplate props for artists added to axes"""
a.set_figure(self.figure)
if not a.transform_set):
if not a.transform_set:
a.transform = self.transData

a.axes = self
Expand Down Expand Up @@ -1724,7 +1723,7 @@ def _update_line_limits(self, line):
if path.vertices.size == 0:
return

line_trans = line.get_transform()
line_trans = line.transform

if line_trans == self.transData:
data_path = path
Expand Down Expand Up @@ -1799,7 +1798,7 @@ def _update_patch_limits(self, patch):
self.transData)
xys = patch_to_data.transform(xys)

updatex, updatey = patch.get_transform().\
updatex, updatey = patch.transform.\
contains_branch_seperately(self.transData)
self.update_datalim(xys, updatex=updatex,
updatey=updatey)
Expand Down Expand Up @@ -2303,7 +2302,7 @@ def draw(self, renderer=None, inframe=False):
gc.set_clip_rectangle(self.bbox)
gc.set_clip_path(mtransforms.TransformedPath(
self.patch.get_path(),
self.patch.get_transform()))
self.patch.transform))

renderer.draw_image(gc, round(l), round(b), im)
gc.restore()
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ def _update_label_position(self, bboxes, bboxes2):
if self.label_position == 'bottom':
try:
spine = self.axes.spines['bottom']
spinebbox = spine.get_transform().transform_path(
spinebbox = spine.transform.transform_path(
spine.get_path()).get_extents()
except KeyError:
# use axes if spine doesn't exist
Expand All @@ -1816,7 +1816,7 @@ def _update_label_position(self, bboxes, bboxes2):
else:
try:
spine = self.axes.spines['top']
spinebbox = spine.get_transform().transform_path(
spinebbox = spine.transform.transform_path(
spine.get_path()).get_extents()
except KeyError:
# use axes if spine doesn't exist
Expand Down Expand Up @@ -2123,7 +2123,7 @@ def _update_label_position(self, bboxes, bboxes2):
if self.label_position == 'left':
try:
spine = self.axes.spines['left']
spinebbox = spine.get_transform().transform_path(
spinebbox = spine.transform.transform_path(
spine.get_path()).get_extents()
except KeyError:
# use axes if spine doesn't exist
Expand All @@ -2138,7 +2138,7 @@ def _update_label_position(self, bboxes, bboxes2):
else:
try:
spine = self.axes.spines['right']
spinebbox = spine.get_transform().transform_path(
spinebbox = spine.transform.transform_path(
spine.get_path()).get_extents()
except KeyError:
# use axes if spine doesn't exist
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
if mtext and (angle == 0 or mtext.get_rotation_mode() == "anchor"):
# if text anchoring can be supported, get the original coordinates
# and add alignment information
x, y = mtext.get_transform().transform_point(mtext.get_position())
x, y = mtext.transform.transform_point(mtext.get_position())
text_args.append("x=%fin" % (x * f))
text_args.append("y=%fin" % (y * f))

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
# coordinates and add alignment information.

# Get anchor coordinates.
transform = mtext.get_transform()
transform = mtext.transform
ax, ay = transform.transform_point(mtext.get_position())
ay = self.height - ay

Expand Down
12 changes: 6 additions & 6 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def get_offset_transform(self):
return t

def get_datalim(self, transData):
transform = self.get_transform()
transform = self.transform
transOffset = self.get_offset_transform()
offsets = self._offsets
paths = self.get_paths()
Expand Down Expand Up @@ -217,7 +217,7 @@ def get_window_extent(self, renderer):
def _prepare_points(self):
"""Point prep for drawing and hit testing"""

transform = self.get_transform()
transform = self.transform
transOffset = self.get_offset_transform()
offsets = self._offsets
paths = self.get_paths()
Expand Down Expand Up @@ -1622,7 +1622,7 @@ def determine_facecolor(patch):
self.set_paths(patches)

def set_paths(self, patches):
paths = [p.get_transform().transform_path(p.get_path())
paths = [p.transform.transform_path(p.get_path())
for p in patches]
self._paths = paths

Expand Down Expand Up @@ -1677,7 +1677,7 @@ def draw(self, renderer):
if not self.get_visible():
return
renderer.open_group(self.__class__.__name__)
transform = self.get_transform()
transform = self.transform

# Get a list of triangles and the color at each vertex.
tri = self._triangulation
Expand Down Expand Up @@ -1757,7 +1757,7 @@ def set_paths(self):
self.stale = True

def get_datalim(self, transData):
return (self.get_transform() - transData).transform_bbox(self._bbox)
return (self.transform - transData).transform_bbox(self._bbox)

@staticmethod
def convert_mesh_to_paths(meshWidth, meshHeight, coordinates):
Expand Down Expand Up @@ -1832,7 +1832,7 @@ def draw(self, renderer):
if not self.get_visible():
return
renderer.open_group(self.__class__.__name__, self.get_gid())
transform = self.get_transform()
transform = self.transform
transOffset = self.get_offset_transform()
offsets = self._offsets

Expand Down
8 changes: 3 additions & 5 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import matplotlib.transforms as mtrans
from matplotlib.cbook import mplDeprecation

from .traitlest import TransformInstance

# Import needed for adding manual selection capability to clabel
from matplotlib.blocking_input import BlockingContourLabeler

Expand All @@ -50,7 +48,7 @@ class ClabelText(text.Text):
"""
def get_rotation(self):
angle = text.Text.get_rotation(self)
trans = self.get_transform()
trans = self.transform
x, y = self.get_position()
new_angles = trans.transform_angles(np.array([angle]),
np.array([[x, y]]))
Expand Down Expand Up @@ -651,7 +649,7 @@ def labels(self, inline, inline_spacing):
self.labelFontSizeList, self.labelCValueList):

con = self.collections[icon]
trans = con.get_transform()
trans = con.transform
lw = self.get_label_width(lev, self.labelFmt, fsize)
lw *= self.ax.figure.dpi / 72.0 # scale to screen coordinates
additions = []
Expand Down Expand Up @@ -1396,7 +1394,7 @@ def find_nearest_contour(self, x, y, indices=None, pixel=True):

for icon in indices:
con = self.collections[icon]
trans = con.get_transform()
trans = con.transform
paths = con.get_paths()

for segNum, linepath in enumerate(paths):
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _draw_unsampled_image(self, renderer, gc):
draw unsampled image. The renderer should support a draw_image method
with scale parameter.
"""
trans = self.get_transform() # axes.transData
trans = self.transform # axes.transData

# convert the coordinates to the intermediate coordinate (ic).
# The transformation from the ic to the canvas is a pure
Expand Down Expand Up @@ -609,7 +609,7 @@ def make_image(self, magnification=1.0):

# image is created in the canvas coordinate.
x1, x2, y1, y2 = self.get_extent()
trans = self.get_transform()
trans = self.transform
xy = trans.transform(np.array([(x1, y1),
(x2, y2),
]))
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ def _auto_legend_data(self):
for handle in ax.lines:
assert isinstance(handle, Line2D)
path = handle.get_path()
trans = handle.get_transform()
trans = handle.transform
tpath = trans.transform_path(path)
lines.append(tpath)

Expand All @@ -752,7 +752,7 @@ def _auto_legend_data(self):
transform = handle.get_data_transform()
bboxes.append(handle.get_bbox().transformed(transform))
else:
transform = handle.get_transform()
transform = handle.transform
bboxes.append(handle.get_path().get_extents(transform))

try:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/legend_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def legend_artist(self, legend, orig_handle,
fontsize)
artists = self.create_artists(legend, orig_handle,
xdescent, ydescent, width, height,
fontsize, handlebox.get_transform())
fontsize, handlebox.transform)

# create_artists will return a list of artists.
for a in artists:
Expand Down
Loading