8000 finish uncommenting setters/getters · rmorshea/matplotlib@c02566d · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit c02566d

Browse files
committed
finish uncommenting setters/getters
1 parent 5559b7c commit c02566d

File tree

8 files changed

+159
-204
lines changed

8 files changed

+159
-204
lines changed

lib/matplotlib/collections.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import matplotlib.path as mpath
2929
from matplotlib import _path
3030
import matplotlib.mlab as mlab
31-
from matplotlib.traitlets import validate
31+
from matplotlib.traitlets import validate, _traitlets_deprecation_msg
3232

3333

3434
CIRCLE_AREA_FACTOR = 1.0 / np.sqrt(np.pi)
@@ -685,31 +685,16 @@ def _alpha_validate(self, commit):
685685

686686
return value
687687

688-
#!DEPRECATED
689-
# def set_alpha(self, alpha):
690-
# """
691-
# Set the alpha tranparencies of the collection. *alpha* must be
< 8000 /code>
692-
# a float or *None*.
693-
694-
# ACCEPTS: float or None
695-
# """
696-
# if alpha is not None:
697-
# try:
698-
# float(alpha)
699-
# except TypeError:
700-
# raise TypeError('alpha must be a float or None')
701-
# artist.Artist.set_alpha(self, alpha)
702-
# try:
703-
# self._facecolors = mcolors.colorConverter.to_rgba_array(
704-
# self._facecolors_original, self._alpha)
705-
# except (AttributeError, TypeError, IndexError):
706-
# pass
707-
# try:
708-
# if self._edgecolors_original != str('face'):
709-
# self._edgecolors = mcolors.colorConverter.to_rgba_array(
710-
# self._edgecolors_original, self._alpha)
711-
# except (AttributeError, TypeError, IndexError):
712-
# pass
688+
def set_alpha(self, alpha):
689+
"""
690+
Set the alpha tranparencies of the collection. *alpha* must be
691+
a float or *None*.
692+
693+
ACCEPTS: float or None
694+
"""
695+
msg = _traitlets_deprecation_msg('alpha')
696+
warnings.warn(msg, mplDeprecation, stacklevel=1)
697+
self.alpha = alpha
713698

714699
def get_linewidths(self):
715700
return self._linewidths

lib/matplotlib/image.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
from matplotlib.transforms import BboxBase, Bbox, IdentityTransform
3535
import matplotlib.transforms as mtransforms
36-
from matplotlib.traitlets import validate
36+
from matplotlib.traitlets import validate, _traitlets_deprecation_msg
3737

3838
# map interpolation strings to module constants
3939
_interpd_ = {
@@ -149,16 +149,16 @@ def _alpha_validate(self, commit):
149149
self._imcache = None
150150
return value
151151

152-
#!DEPRECATED
153-
# def set_alpha(self, alpha):
154-
# """
155-
# Set the alpha value used for blending - not supported on
156-
# all backends
152+
def set_alpha(self, alpha):
153+
"""
154+
Set the alpha value used for blending - not supported on
155+
all backends
157156
158-
# ACCEPTS: float
159-
# """
160-
# martist.Artist.set_alpha(self, alpha)
161-
# self._imcache = None
157+
ACCEPTS: float
158+
"""
159+
msg = _traitlets_deprecation_msg('alpha')
160+
warnings.warn(msg, mplDeprecation, stacklevel=1)
161+
self.alpha = alpha
162162

163163
def changed(self):
164164
"""
@@ -989,16 +989,16 @@ def _alpha_validate(self, commit):
989989
self.update_dict['array'] = True
990990
return value
991991

992-
#!DEPRECATED
993-
# def set_alpha(self, alpha):
994-
# """
995-
# Set the alpha value used for blending - not supported on
996-
# all backends
992+
def set_alpha(self, alpha):
993+
"""
994+
Set the alpha value used for blending - not supported on
995+
all backends
997996
998-
# ACCEPTS: float
999-
# """
1000-
# martist.Artist.set_alpha(self, alpha)
1001-
# self.update_dict['array'] = True
997+
ACCEPTS: float
998+
"""
999+
msg = _traitlets_deprecation_msg('alpha')
1000+
warnings.warn(msg, mplDeprecation, stacklevel=1)
1001+
self.alpha = alpha
10021002

10031003

10041004
class FigureImage(martist.Artist, cm.ScalarMappable):

lib/matplotlib/lines.py

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from matplotlib.markers import TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN
3333
from matplotlib.markers import CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN
3434

35-
from .traitlets import observe
35+
from .traitlets import observe, _traitlets_deprecation_msg
3636

3737

3838
def segment_hits(cx, cy, x, y, radius):
@@ -559,18 +559,15 @@ def _picker_changed(self, change):
559559
else:
560560
self.pickradius = change['new']
561561

562-
#!DEPRECATED
563-
# def set_picker(self, p):
564-
# """Sets the event picker details for the line.
562+
def set_picker(self, p):
563+
"""Sets the event picker details for the line.
565564
566-
# ACCEPTS: float distance in points or callable pick function
567-
# ``fn(artist, event)``
568-
# """
569-
# if six.callable(p):
570-
# self._contains = p
571-
# else:
572-
# self.pickradius = p
573-
# self._picker = p
565+
ACCEPTS: float distance in points or callable pick function
566+
``fn(artist, event)``
567+
"""
568+
msg = _traitlets_deprecation_msg('picker')
569+
warnings.warn(msg, mplDeprecation, stacklevel=1)
570+
self.picker = p
574571

575572
def get_window_extent(self, renderer):
576573
bbox = Bbox([[0, 0], [0, 0]])
@@ -595,19 +592,6 @@ def _axes_changed(self, change):
595592
self._ycid = new.yaxis.callbacks.connect('units',
596593
self.recache_always)
597594

598-
#!DEPRECATED
599-
# @Artist.axes.setter
600-
# def axes(self, ax):
601-
# # call the set method from the base-class property
602-
# Artist.axes.fset(self, ax)
603-
# # connect unit-related callbacks
604-
# if ax.xaxis is not None:
605-
# self._xcid = ax.xaxis.callbacks.connect('units',
606-
# self.recache_always)
607-
# if ax.yaxis is not None:
608-
# self._ycid = ax.yaxis.callbacks.connect('units',
609-
# self.recache_always)
610-
611595
def set_data(self, *args):
612596
"""
613597
Set the x and y data
@@ -715,14 +699,15 @@ def _transform_changed(self, change):
715699
self._invalidy = True
716700
self.stale = True
717701

718-
#!DEPRECATED
719-
# def set_transform(self, t):
720-
# """
721-
# set the Transformation instance used by this artist
702+
def set_transform(self, t):
703+
"""
704+
set the Transformation instance used by this artist
722705
723-
# ACCEPTS: a :class:`matplotlib.transforms.Transform` instance
724-
# """
725-
# self.transform = t
706+
ACCEPTS: a :class:`matplotlib.transforms.Transform` instance
707+
"""
708+
msg = _traitlets_deprecation_msg('transform')
709+
warnings.warn(msg, mplDeprecation, stacklevel=1)
710+
self.transform = t
726711

727712
def _is_sorted(self, x):
728713
"""return True if x is sorted in ascending order"""

lib/matplotlib/offsetbox.py

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from matplotlib.patches import bbox_artist as mbbox_artist
4141
from matplotlib.text import _AnnotationBase
4242

43-
from .traitlets import observe, retrieve
43+
from .traitlets import observe, retrieve, _traitlets_deprecation_msg
4444

4545
DEBUG = False
4646

@@ -189,16 +189,15 @@ def _figure_changed(self, change):
189189
for c in self.get_children():
190190
c.figure = change['new']
191191

192-
#!DEPRICATED
193-
# def set_figure(self, fig):
194-
# """
195-
# Set the figure
192+
def set_figure(self, fig):
193+
"""
194+
Set the figure
196195
197-
# accepts a class:`~matplotlib.figure.Figure` instance
198-
# """
199-
# martist.Artist.set_figure(self, fig)
200-
# for c in self.get_children():
201-
# c.set_figure(fig)
196+
accepts a class:`~matplotlib.figure.Figure` instance
197+
"""
198+
msg = _traitlets_deprecation_msg('figure')
199+
warnings.warn(msg, mplDeprecation, stacklevel=1)
200+
self.figure = fig
202201

203202
@observe('axes')
204203
def _axes_changed(self, change):
@@ -644,20 +643,21 @@ def _transform_changed(self, change):
644643
name = change['name']
645644
self._trait_values[name] = None
646645

647-
#!DEPRECATED
648-
# def get_transform(self):
649-
# """
650-
# Return the :class:`~matplotlib.transforms.Transform` applied
651-
# to the children
652-
# """
653-
# return self.transform
654-
655-
#!DEPRECATED
656-
# def set_transform(self, t):
657-
# """
658-
# set_transform is ignored.
659-
# """
660-
# pass
646+
def get_transform(self):
647+
"""
648+
Return the :class:`~matplotlib.transforms.Transform` applied
649+
to the children
650+
"""
651+
msg = _traitlets_deprecation_msg('transform')
652+
warnings.warn(msg, mplDeprecation, stacklevel=1)
653+
return self.transform
654+
655+
def set_transform(self, t):
656+
"""
657+
set_transform is ignored.
658+
"""
659+
msg = _traitlets_deprecation_msg('transform')
660+
warnings.warn(msg, mplDeprecation, stacklevel=1)
661661

662662
def set_offset(self, xy):
663663
"""
@@ -942,23 +942,23 @@ def _transform_getter(self, pull):
942942

943943
@observe('transform')
944944
def _transform_changed(self, change):
945-
name = change['name']
946-
self._trait_values[name] = None
945+
self._trait_values[change['name']] = None
946+
947+
def get_transform(self):
948+
"""
949+
Return the :class:`~matplotlib.transforms.Transform` applied
950+
to the children
951+
"""
952+
msg = _traitlets_deprecation_msg('transform')
953+
warnings.warn(msg, mplDeprecation, stacklevel=1)
954+
return self.transform
947955

948-
# !DEPRECATED
949-
# def get_transform(self):
950-
# """
951-
# Return the :class:`~matplotlib.transforms.Transform` applied
952-
# to the children
953-
# """
954-
# return
955-
956-
#!DEPRECATED
957-
# def set_transform(self, t):
958-
# """
959-
# set_transform is ignored.
960-
# """
961-
# pass
956+
def set_transform(self, t):
957+
"""
958+
set_transform is ignored.
959+
"""
960+
msg = _traitlets_deprecation_msg('transform')
961+
warnings.warn(msg, mplDeprecation, stacklevel=1)
962962

963963
def set_offset(self, xy):
964964
"""
@@ -1523,13 +1523,10 @@ def _figure_changed(self, change):
15231523
self.offsetbox.figure = new
15241524
martist.Artist._figure_changed(self, change)
15251525

1526-
#!DEPRICATED
1527-
# def set_figure(self, fig):
1528-
1529-
# if self.arrow_patch is not None:
1530-
# self.arrow_patch.set_figure(fig)
1531-
# self.offsetbox.set_figure(fig)
1532-
# martist.Artist.set_figure(self, fig)
1526+
def set_figure(self, fig):
1527+
msg = _traitlets_deprecation_msg('figure')
1528+
warnings.warn(msg, mplDeprecation, stacklevel=1)
1529+
self.figure = figure
15331530

15341531
def set_fontsize(self, s=None):
15351532
"""

lib/matplotlib/patches.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from matplotlib.bezier import split_path_inout, get_cos_sin
2525
from matplotlib.bezier import make_path_regular, concatenate_paths
2626

27-
from .traitlets import validate, retrieve
27+
from .traitlets import validate, retrieve, _traitlets_deprecation_msg
2828

2929

3030
# these are not available for the object inspector until after the
@@ -331,23 +331,15 @@ def _alpha_validate(self, commit):
331331
self.stale = True
332332
return value
333333

334-
#!DEPRECATED
335-
# def set_alpha(self, alpha):
336-
# """
337-
# Set the alpha tranparency of the patch.
334+
def set_alpha(self, alpha):
335+
"""
336+
Set the alpha tranparency of the patch.
338337
339-
# ACCEPTS: float or None
340-
# """
341-
# if alpha is not None:
342-
# try:
343-
# float(alpha)
344-
# except TypeError:
345-
# raise TypeError('alpha must be a float or None')
346-
# artist.Artist.set_alpha(self, alpha)
347-
# # using self._fill and self._alpha
348-
# self.set_facecolor(self._original_facecolor)
349-
# self.set_edgecolor(self._original_edgecolor)
350-
# self.stale = True
338+
ACCEPTS: float or None
339+
"""
340+
msg = _traitlets_deprecation_msg('alpha')
341+
warnings.warn(msg, mplDeprecation, stacklevel=1)
342+
self.alpha = alpha
351343

352344
def set_linewidth(self, w):
353345
"""

lib/matplotlib/table.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from .text import Text
3636
from .transforms import Bbox
3737
from matplotlib.path import Path
38-
from .traitlets import Instance, observe
38+
from .traitlets import Instance, observe, _traitlets_deprecation_msg
3939

4040

4141
class Cell(Rectangle):
@@ -70,21 +70,20 @@ def _transform_set(self):
7070
Rectangle._transform_changed(self)
7171
self.stale = True
7272

73-
#!DEPRECATED
74-
# def set_transform(self, trans):
75-
# Rectangle.set_transform(self, trans)
76-
# # the text does not get the transform!
77-
# self.stale = True
73+
def set_transform(self, trans):
74+
msg = _traitlets_deprecation_msg('transform')
75+
warnings.warn(msg, mplDeprecation, stacklevel=1)
76+
self.transform = trans
7877

7978
@observe('figure')
8079
def _figure_changed(self, change):
8180
Rectangle._figure_changed(self, change)
8281
self._text.figure = change['new']
8382

84-
#!DEPRICATED
85-
# def set_figure(self, fig):
86-
# Rectangle.set_figure(self, fig)
87-
# self._text.set_figure(fig)
83+
def set_figure(self, fig):
84+
msg = _traitlets_deprecation_msg('figure')
85+
warnings.warn(msg, mplDeprecation, stacklevel=1)
86+
self.figure = fig
8887

8988
def get_text(self):
9089
'Return the cell Text intance'

0 commit comments

Comments
 (0)
0