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

Skip to content

Commit 04d1bcd

Browse files
authored
Merge pull request #7771 from anntzer/more-code-removal
MNT: More code removal
2 parents 83f9741 + cd54509 commit 04d1bcd

File tree

9 files changed

+27
-61
lines changed

9 files changed

+27
-61
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Deprecation of `GraphicsContextBase`\'s ``linestyle`` property.
2+
```````````````````````````````````````````````````````````````
3+
4+
The ``GraphicsContextBase.get_linestyle`` and
5+
``GraphicsContextBase.set_linestyle`` methods, which effectively had no effect,
6+
have been deprecated.

doc/api/api_changes/code_removal.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ removed.
2222
The ``ArtistInspector.findobj`` method, which was never working due to the lack
2323
of a ``get_children`` method, has been removed.
2424

25+
The deprecated ``point_in_path``, ``get_path_extents``,
26+
``point_in_path_collection``, ``path_intersects_path``,
27+
``convert_path_to_polygons``, ``cleanup_path`` and ``clip_path_to_rect``
28+
functions in the ``matplotlib.path`` module have been removed. Their
29+
functionality remains exposed as methods on the ``Path`` class.
30+
2531

2632
`Axes.set_aspect("normal")`
2733
---------------------------

lib/matplotlib/backend_bases.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import matplotlib.colors as colors
5353
import matplotlib.transforms as transforms
5454
import matplotlib.widgets as widgets
55-
#import matplotlib.path as path
5655
from matplotlib import rcParams
5756
from matplotlib import is_interactive
5857
from matplotlib import get_backend
@@ -311,8 +310,8 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
311310
path_ids.append((path, transforms.Affine2D(transform)))
312311

313312
for xo, yo, path_id, gc0, rgbFace in self._iter_collection(
314-
gc, master_transform, all_transforms, path_ids, offsets,
315-
offsetTrans, facecolors, edgecolors, linewidths, linestyles,
313+
gc, master_transform, all_transforms, path_ids, offsets,
314+
offsetTrans, facecolors, edgecolors, linewidths, linestyles,
316315
antialiaseds, urls, offset_position):
317316
path, transform = path_id
318317
transform = transforms.Affine2D(
@@ -918,6 +917,7 @@ def get_joinstyle(self):
918917
"""
919918
return self._joinstyle
920919

920+
@cbook.deprecated("2.1")
921921
def get_linestyle(self):
922922
"""
923923
Return the linestyle: one of ('solid', 'dashed', 'dashdot',
@@ -1068,6 +1068,7 @@ def set_linewidth(self, w):
10681068
"""
10691069
self._linewidth = float(w)
10701070

1071+
@cbook.deprecated("2.1")
10711072
def set_linestyle(self, style):
10721073
"""
10731074
Set the linestyle to be one of ('solid', 'dashed', 'dashdot',

lib/matplotlib/backends/backend_pdf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,8 +2352,6 @@ def clip_cmd(self, cliprect, clippath):
23522352
(('_hatch', '_hatch_color'), hatch_cmd),
23532353
)
23542354

2355-
# TODO: _linestyle
2356-
23572355
def delta(self, other):
23582356
"""
23592357
Copy properties of other into self and return PDF commands

lib/matplotlib/backends/backend_wx.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import numpy as np
2929

3030
import matplotlib
31+
from matplotlib import cbook
3132
from matplotlib.backend_bases import (RendererBase, GraphicsContextBase,
3233
FigureCanvasBase, FigureManagerBase, NavigationToolbar2,
3334
cursors, TimerBase)
@@ -408,8 +409,6 @@ class GraphicsContextWx(GraphicsContextBase):
408409
'miter': wx.JOIN_MITER,
409410
'round': wx.JOIN_ROUND}
410411

411-
_dashd_wx = wxc.dashd_wx
412-
413412
_cache = weakref.WeakKeyDictionary()
414413

415414
def __init__(self, bitmap, renderer):
@@ -509,6 +508,7 @@ def set_joinstyle(self, js):
509508
self.gfx_ctx.SetPen(self._pen)
510509
self.unselect()
511510

511+
@cbook.deprecated("2.1")
512512
def set_linestyle(self, ls):
513513
"""
514514
Set the line style to be one of
@@ -517,7 +517,7 @@ def set_linestyle(self, ls):
517517
self.select()
518518
GraphicsContextBase.set_linestyle(self, ls)
519519
try:
520-
self._style = GraphicsContextWx._dashd_wx[ls]
520+
self._style = wxc.dashd_wx[ls]
521521
except KeyError:
522522
self._style = wx.LONG_DASH # Style not used elsewhere...
523523

lib/matplotlib/lines.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -771,11 +771,9 @@ def draw(self, renderer):
771771
renderer = PathEffectRenderer(self.get_path_effects(), renderer)
772772

773773
renderer.open_group('line2d', self.get_gid())
774-
funcname = self._lineStyles.get(self._linestyle, '_draw_nothing')
775-
if funcname != '_draw_nothing':
774+
if self._lineStyles[self._linestyle] != '_draw_nothing':
776775
tpath, affine = transf_path.get_transformed_path_and_affine()
777776
if len(tpath.vertices):
778-
line_func = getattr(self, funcname)
779777
gc = renderer.new_gc()
780778
self._set_gc_clip(gc)
781779

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

801-
line_func(renderer, gc, tpath, affine.frozen())
799+
gc.set_dashes(self._dashOffset, self._dashSeq)
800+
renderer.draw_path(gc, tpath, affine.frozen())
802801
gc.restore()
803802

804803
if self._marker and self._markersize > 0:
@@ -1245,26 +1244,6 @@ def set_dashes(self, seq):
12451244
else:
12461245
self.set_linestyle((0, seq))
12471246

1248-
def _draw_solid(self, renderer, gc, path, trans):
1249-
gc.set_linestyle('solid')
1250-
gc.set_dashes(self._dashOffset, self._dashSeq)
1251-
renderer.draw_path(gc, path, trans)
1252-
1253-
def _draw_dashed(self, renderer, gc, path, trans):
1254-
gc.set_linestyle('dashed')
1255-
gc.set_dashes(self._dashOffset, self._dashSeq)
1256-
renderer.draw_path(gc, path, trans)
1257-
1258-
def _draw_dash_dot(self, renderer, gc, path, trans):
1259-
gc.set_linestyle('dashdot')
1260-
gc.set_dashes(self._dashOffset, self._dashSeq)
1261-
renderer.draw_path(gc, path, trans)
1262-
1263-
def _draw_dotted(self, renderer, gc, path, trans):
1264-
gc.set_linestyle('dotted')
1265-
gc.set_dashes(self._dashOffset, self._dashSeq)
1266-
renderer.draw_path(gc, path, trans)
1267-
12681247
def update_from(self, other):
12691248
"""copy properties from other to self"""
12701249
Artist.update_from(self, other)

lib/matplotlib/path.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,26 +1025,3 @@ def get_paths_extents(paths, transforms=[]):
10251025
raise ValueError("No paths provided")
10261026
return Bbox.from_extents(*_path.get_path_collection_extents(
10271027
Affine2D(), paths, transforms, [], Affine2D()))
1028-
1029-
1030-
def _define_deprecated_functions(ns):
1031-
from .cbook import deprecated
1032-
1033-
# The C++ functions are not meant to be used directly.
1034-
# Users should use the more pythonic wrappers in the Path
1035-
# class instead.
1036-
for func, alternative in [
1037-
('point_in_path', 'path.Path.contains_point'),
1038-
('get_path_extents', 'path.Path.get_extents'),
1039-
('point_in_path_collection', 'collection.Collection.contains'),
1040-
('path_in_path', 'path.Path.contains_path'),
1041-
('path_intersects_path', 'path.Path.intersects_path'),
1042-
('convert_path_to_polygons', 'path.Path.to_polygons'),
1043-
('cleanup_path', 'path.Path.cleaned'),
1044-
('points_in_path', 'path.Path.contains_points'),
1045-
('clip_path_to_rect', 'path.Path.clip_to_bbox')]:
1046-
ns[func] = deprecated(
1047-
since='1.3', alternative=alternative)(getattr(_path, func))
1048-
1049-
1050-
_define_deprecated_functions(locals())

lib/matplotlib/patheffects.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
355355

356356
gc0.set_foreground(shadow_rgbFace)
357357
gc0.set_alpha(self._alpha)
358-
gc0.set_linestyle("solid")
359358

360359
gc0 = self._update_gc(gc0, self._gc)
361360
renderer.draw_path(gc0, tpath, affine0, fill_color)

lib/mpl_toolkits/axisartist/axis_artist.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ def draw(self, renderer):
156156
join = self._solidjoinstyle
157157
gc.set_joinstyle(join)
158158
gc.set_capstyle(cap)
159+
gc.set_dashes(self._dashOffset, self._dashSeq)
159160

160-
funcname = self._lineStyles.get(self._linestyle, '_draw_nothing')
161-
if funcname != '_draw_nothing':
162-
tpath, affine = self._transformed_path.get_transformed_path_and_affine()
163-
lineFunc = getattr(self, funcname)
164-
lineFunc(renderer, gc, tpath, affine.frozen())
161+
if self._lineStyles[self._linestyle] != '_draw_nothing':
162+
tpath, affine = (
163+
self._transformed_path.get_transformed_path_and_affine())
164+
renderer.draw_path(gc, tpath, affine.frozen())
165165

166166
gc.restore()
167167
renderer.close_group('line2d')

0 commit comments

Comments
 (0)