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

Skip to content

More code removal #7771

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

Merged
merged 2 commits into from
Jun 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Deprecation of `GraphicsContextBase`\'s ``linestyle`` property.
```````````````````````````````````````````````````````````````

The ``GraphicsContextBase.get_linestyle`` and
``GraphicsContextBase.set_linestyle`` methods, which effectively had no effect,
have been deprecated.
6 changes: 6 additions & 0 deletions doc/api/api_changes/code_removal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ removed.
The ``ArtistInspector.findobj`` method, which was never working due to the lack
of a ``get_children`` method, has been removed.

The deprecated ``point_in_path``, ``get_path_extents``,
``point_in_path_collection``, ``path_intersects_path``,
``convert_path_to_polygons``, ``cleanup_path`` and ``clip_path_to_rect``
functions in the ``matplotlib.path`` module have been removed. Their
functionality remains exposed as methods on the ``Path`` class.


`Axes.set_aspect("normal")`
---------------------------
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import matplotlib.colors as colors
import matplotlib.transforms as transforms
import matplotlib.widgets as widgets
#import matplotlib.path as path
from matplotlib import rcParams
from matplotlib import is_interactive
from matplotlib import get_backend
Expand Down Expand Up @@ -300,8 +299,8 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
path_ids.append((path, transforms.Affine2D(transform)))

for xo, yo, path_id, gc0, rgbFace in self._iter_collection(
gc, master_transform, all_transforms, path_ids, offsets,
offsetTrans, facecolors, edgecolors, linewidths, linestyles,
gc, master_transform, all_transforms, path_ids, offsets,
offsetTrans, facecolors, edgecolors, linewidths, linestyles,
antialiaseds, urls, offset_position):
path, transform = path_id
transform = transforms.Affine2D(
Expand Down Expand Up @@ -907,6 +906,7 @@ def get_joinstyle(self):
"""
return self._joinstyle

@cbook.deprecated("2.1")
def get_linestyle(self):
"""
Return the linestyle: one of ('solid', 'dashed', 'dashdot',
Expand Down Expand Up @@ -1057,6 +1057,7 @@ def set_linewidth(self, w):
"""
self._linewidth = float(w)

@cbook.deprecated("2.1")
def set_linestyle(self, style):
"""
Set the linestyle to be one of ('solid', 'dashed', 'dashdot',
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2352,8 +2352,6 @@ def clip_cmd(self, cliprect, clippath):
(('_hatch', '_hatch_color'), hatch_cmd),
)

# TODO: _linestyle

def delta(self, other):
"""
Copy properties of other into self and return PDF commands
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import numpy as np

import matplotlib
from matplotlib import cbook
from matplotlib.backend_bases import (RendererBase, GraphicsContextBase,
FigureCanvasBase, FigureManagerBase, NavigationToolbar2,
cursors, TimerBase)
Expand Down Expand Up @@ -408,8 +409,6 @@ class GraphicsContextWx(GraphicsContextBase):
'miter': wx.JOIN_MITER,
'round': wx.JOIN_ROUND}

_dashd_wx = wxc.dashd_wx
Copy link
Member

Choose a reason for hiding this comment

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

Should we deprecate dashd_wx as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a bunch of other entries in wx_compat.py which are not used (e.g. StockCursor) so I think that would belong to a (separate) cleanup of wx_compat.


_cache = weakref.WeakKeyDictionary()

def __init__(self, bitmap, renderer):
Expand Down Expand Up @@ -509,6 +508,7 @@ def set_joinstyle(self, js):
self.gfx_ctx.SetPen(self._pen)
self.unselect()

@cbook.deprecated("2.1")
def set_linestyle(self, ls):
"""
Set the line style to be one of
Expand All @@ -517,7 +517,7 @@ def set_linestyle(self, ls):
self.select()
GraphicsContextBase.set_linestyle(self, ls)
try:
self._style = GraphicsContextWx._dashd_wx[ls]
self._style = wxc.dashd_wx[ls]
except KeyError:
self._style = wx.LONG_DASH # Style not used elsewhere...

Expand Down
27 changes: 3 additions & 24 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,11 +771,9 @@ def draw(self, renderer):
renderer = PathEffectRenderer(self.get_path_effects(), renderer)

renderer.open_group('line2d', self.get_gid())
funcname = self._lineStyles.get(self._linestyle, '_draw_nothing')
if funcname != '_draw_nothing':
if self._lineStyles[self._linestyle] != '_draw_nothing':
tpath, affine = transf_path.get_transformed_path_and_affine()
if len(tpath.vertices):
line_func = getattr(self, funcname)
gc = renderer.new_gc()
self._set_gc_clip(gc)

Expand All @@ -798,7 +796,8 @@ def draw(self, renderer):
if self.get_sketch_params() is not None:
gc.set_sketch_params(*self.get_sketch_params())

line_func(renderer, gc, tpath, affine.frozen())
gc.set_dashes(self._dashOffset, self._dashSeq)
renderer.draw_path(gc, tpath, affine.frozen())
gc.restore()

if self._marker and self._markersize > 0:
Expand Down Expand Up @@ -1244,26 +1243,6 @@ def set_dashes(self, seq):
else:
self.set_linestyle((0, seq))

def _draw_solid(self, renderer, gc, path, trans):
gc.set_linestyle('solid')
gc.set_dashes(self._dashOffset, self._dashSeq)
renderer.draw_path(gc, path, trans)

def _draw_dashed(self, renderer, gc, path, trans):
gc.set_linestyle('dashed')
gc.set_dashes(self._dashOffset, self._dashSeq)
renderer.draw_path(gc, path, trans)

def _draw_dash_dot(self, renderer, gc, path, trans):
gc.set_linestyle('dashdot')
gc.set_dashes(self._dashOffset, self._dashSeq)
renderer.draw_path(gc, path, trans)

def _draw_dotted(self, renderer, gc, path, trans):
gc.set_linestyle('dotted')
gc.set_dashes(self._dashOffset, self._dashSeq)
renderer.draw_path(gc, path, trans)

def update_from(self, other):
"""copy properties from other to self"""
Copy link
Member

Choose a reason for hiding this comment

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

I do not think we want to remove setting these with out a deprecation cycle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

butbutbut they're private :/

Copy link
Member

Choose a reason for hiding this comment

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

I do not mind removing the methods, it the inner call to gc.set_linestyle that I am worried about.

Copy link
Member

Choose a reason for hiding this comment

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

(I meant to click on the line below and apparently missed).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole point is that graphics contexts don't have that property anymore.

Artist.update_from(self, other)
Expand Down
23 changes: 0 additions & 23 deletions lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,26 +1025,3 @@ def get_paths_extents(paths, transforms=[]):
raise ValueError("No paths provided")
return Bbox.from_extents(*_path.get_path_collection_extents(
Affine2D(), paths, transforms, [], Affine2D()))


def _define_deprecated_functions(ns):
from .cbook import deprecated

# The C++ functions are not meant to be used directly.
# Users should use the more pythonic wrappers in the Path
# class instead.
for func, alternative in [
('point_in_path', 'path.Path.contains_point'),
('get_path_extents', 'path.Path.get_extents'),
('point_in_path_collection', 'collection.Collection.contains'),
('path_in_path', 'path.Path.contains_path'),
('path_intersects_path', 'path.Path.intersects_path'),
('convert_path_to_polygons', 'path.Path.to_polygons'),
('cleanup_path', 'path.Path.cleaned'),
('points_in_path', 'path.Path.contains_points'),
('clip_path_to_rect', 'path.Path.clip_to_bbox')]:
ns[func] = deprecated(
since='1.3', alternative=alternative)(getattr(_path, func))


_define_deprecated_functions(locals())
1 change: 0 additions & 1 deletion lib/matplotlib/patheffects.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):

gc0.set_foreground(shadow_rgbFace)
gc0.set_alpha(self._alpha)
gc0.set_linestyle("solid")

gc0 = self._update_gc(gc0, self._gc)
renderer.draw_path(gc0, tpath, affine0, fill_color)
Expand Down
10 changes: 5 additions & 5 deletions lib/mpl_toolkits/axisartist/axis_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ def draw(self, renderer):
join = self._solidjoinstyle
gc.set_joinstyle(join)
gc.set_capstyle(cap)
gc.set_dashes(self._dashOffset, self._dashSeq)

Copy link
Member

Choose a reason for hiding this comment

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

This will now raise on non-valid self._linestyle. Do the git logs provide any clue why was this coded this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

set_linestyle (the class here inherits it from lines.Line2D) now has extensive validation before setting _linestyle, which means invalid _linestyle should never happen. The same code in lines was committed by jdh as far back as 2004, whereas the history of set_linestyle is a bit difficult to unwind but I'd guess the checking came later.

Copy link
Member

Choose a reason for hiding this comment

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

👍

funcname = self._lineStyles.get(self._linestyle, '_draw_nothing')
if funcname != '_draw_nothing':
tpath, affine = self._transformed_path.get_transformed_path_and_affine()
lineFunc = getattr(self, funcname)
lineFunc(renderer, gc, tpath, affine.frozen())
if self._lineStyles[self._linestyle] != '_draw_nothing':
tpath, affine = (
self._transformed_path.get_transformed_path_and_affine())
renderer.draw_path(gc, tpath, affine.frozen())

gc.restore()
renderer.close_group('line2d')
Expand Down