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

Skip to content

Commit 768c583

Browse files
ericpreQuLogic
andauthored
Apply suggestions from code review: improve normalisation kwargs
Co-authored-by: Elliott Sales de Andrade <[email protected]>
1 parent a871ca6 commit 768c583

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

lib/matplotlib/widgets.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,9 +2022,7 @@ def set_props(self, **props):
20222022
in the selector docstring to know which properties are supported.
20232023
"""
20242024
artist = self._selection_artist
2025-
alias_map = getattr(artist, '_alias_map', None)
2026-
if alias_map:
2027-
props = cbook.normalize_kwargs(props, alias_map)
2025+
props = cbook.normalize_kwargs(props, artist)
20282026
artist.set(**props)
20292027
if self.useblit:
20302028
self.update()
@@ -2040,9 +2038,7 @@ def set_handle_props(self, **handle_props):
20402038
raise NotImplementedError("This selector doesn't have handles.")
20412039

20422040
artist = self._handles_artists[0]
2043-
alias_map = getattr(artist, '_alias_map', None)
2044-
if alias_map:
2045-
handle_props = cbook.normalize_kwargs(handle_props, alias_map)
2041+
handle_props = cbook.normalize_kwargs(handle_props, artist)
20462042
for handle in self._handles_artists:
20472043
handle.set(**handle_props)
20482044
if self.useblit:
@@ -2178,7 +2174,7 @@ def __init__(self, ax, onselect, direction, minspan=0, useblit=False,
21782174
# Setup handles
21792175
self._handle_props = {
21802176
'color': props.get('facecolor', 'r'),
2181-
**cbook.normalize_kwargs(handle_props, Line2D._alias_map)}
2177+
**cbook.normalize_kwargs(handle_props, Line2D)}
21822178

21832179
if self._interactive:
21842180
self._edge_order = ['min', 'max']
@@ -2824,7 +2820,7 @@ def __init__(self, ax, onselect, drawtype='box',
28242820
self._handle_props = {
28252821
'markeredgecolor': (self._props or {}).get(
28262822
'edgecolor', 'black'),
2827-
**cbook.normalize_kwargs(handle_props, Line2D._alias_map)}
2823+
**cbook.normalize_kwargs(handle_props, Line2D)}
28282824

28292825
self._corner_order = ['NW', 'NE', 'SE', 'SW']
28302826
xc, yc = self.corners
@@ -2863,8 +2859,8 @@ def __init__(self, ax, onselect, drawtype='box',
28632859

28642860
@property
28652861
def _handles_artists(self):
2866-
return (self._center_handle.artists + self._corner_handles.artists +
2867-
self._edge_handles.artists)
2862+
return (*self._center_handle.artists, *self._corner_handles.artists,
2863+
*self._edge_handles.artists)
28682864

28692865
def _press(self, event):
28702866
"""Button press event handler."""
@@ -3498,8 +3494,7 @@ def _onmove(self, event):
34983494
else:
34993495
# Calculate distance to the start vertex.
35003496
x0, y0 = self._selection_artist.get_transform().transform(
3501-
(self._xs[0],
3502-
self._ys[0])
3497+
(self._xs[0], self._ys[0])
35033498
)
35043499
v0_dist = np.hypot(x0 - event.x, y0 - event.y)
35053500
# Lock on to the start vertex if near it and ready to complete.

0 commit comments

Comments
 (0)