8000 Figure property by Mrngilles · Pull Request #4842 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Figure property #4842

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 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
getters and setters deprecated
  • Loading branch information
Mrngilles committed Jul 31, 2015
commit be32a08135580f3182146cfdea868c3b496bdd23
8 changes: 5 additions & 3 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,19 +1503,21 @@ def test(verbosity=1):

return success

def deprecated_get_set(function, to_use):
def deprecated_get_set(fclass, function, to_use):
"""Fuction to deprecate the getters and setter for a class
argument.

Parameter
---------
- fclass: class
The class of the function to deprecate
- function: function
The function to deprecate.
- to_use: string
The argument to use instead of the deprecated function
"""
msg = "{} is deprecated, please use the `{}` argument"
msg = msg.format(function.__name__, to_use)
msg = "{}.{} is deprecated, please use the `{}` argument"
msg = msg.format(fclass.__name__, function.__name__, to_use)
warnings.warn(msg, mplDeprecation, stacklevel=1)

test.__test__ = False # nose: this function is not a test
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ def get_figure(self):
Return the :class:`~matplotlib.figure.Figure` instance the
artist belongs to.
"""
deprecated_get_set(self.get_figure, "figure")
deprecated_get_set(self.__class__, self.get_figure, "figure")
return self.figure

def set_figure(self, fig):
Expand All @@ -624,7 +624,7 @@ def set_figure(self, fig):

ACCEPTS: a :class:`matplotlib.figure.Figure` instance
"""
deprecated_get_set(self.set_figure, "figure")
deprecated_get_set(self.__class__, self.set_figure, "figure")
self.figure = fig

def set_clip_box(self, clipbox):
Expand Down
6 changes: 1 addition & 5 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,9 @@ def set_figure(self, fig):

10000
accepts a class:`~matplotlib.figure.Figure` instance
"""
# import ipdb; ipdb.set_trace()
deprecated_get_set(self.__class__, self.set_figure, "figure")
self.figure = fig

@martist.Artist.figure.getter
def figure(self):
return self._figure

@martist.Artist.figure.setter
def figure(self, fig):
martist.Artist.figure.__set__(self, fig)
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def set_figure(self, fig):

accepts a class:`~matplotlib.figure.Figure` instance
"""
deprecated_get_set(self.__class__, self.set_figure, "figure")
self.figure = fig

@martist.Artist.figure.setter
Expand Down Expand Up @@ -1464,6 +1465,7 @@ def get_children(self):
return children

def set_figure(self, fig):
deprecated_get_set(self.__class__, self.set_figure, "figure")
self.figure = fig

@martist.Artist.figure.setter
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/quiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ def _set_transform(self):
raise ValueError('unrecognized coordinates')

def set_figure(self, fig):
deprecated_get_set(self.__class__, self.set_figure, "figure")
self.figure = fig

@martist.Artist.figure.setter
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def set_transform(self, trans):
self.stale = True

def set_figure(self, fig):
deprecated_get_set(self.__class__, self.set_figure, "figure")
self.figure = fig

@Rectangle.figure.setter
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,7 @@ def set_figure(self, fig):

ACCEPTS: a :class:`matplotlib.figure.Figure` instance
"""
deprecated_get_set(self.__class__, self.set_figure, "figure")
self.figure = fig

@Text.figure.setter
Expand Down Expand Up @@ -2084,6 +2085,7 @@ def anncoords(self, coords):
self._textcoords = coords

def set_figure(self, fig):
deprecated_get_set(self.__class__, self.set_figure, "figure")
self.figure = fig

@Text.figure.setter
Expand Down
0