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

Skip to content

Commit 56fb1c6

Browse files
jklymakMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #12037: Fix ArtistInspector.get_aliases.
1 parent 68845f8 commit 56fb1c6

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
:orphan:
2+
3+
Return type of ArtistInspector.get_aliases changed
4+
``````````````````````````````````````````````````
5+
6+
`ArtistInspector.get_aliases` previously returned the set of aliases as
7+
``{fullname: {alias1: None, alias2: None, ...}}``. The dict-to-None mapping
8+
was used to simulate a set in earlier versions of Python. It has now been
9+
replaced by a set, i.e. ``{fullname: {alias1, alias2, ...}}``.
10+
11+
This value is also stored in `ArtistInspector.aliasd`, which has likewise
12+
changed.

lib/matplotlib/artist.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,15 +1113,14 @@ def __init__(self, o):
11131113

11141114
def get_aliases(self):
11151115
"""
1116-
Get a dict mapping *fullname* -> *alias* for each *alias* in
1117-
the :class:`~matplotlib.artist.ArtistInspector`.
1116+
Get a dict mapping property fullnames to sets of aliases for each alias
1117+
in the :class:`~matplotlib.artist.ArtistInspector`.
11181118
11191119
e.g., for lines::
11201120
1121-
{'markerfacecolor': 'mfc',
1122-
'linewidth' : 'lw',
1121+
{'markerfacecolor': {'mfc'},
1122+
'linewidth' : {'lw'},
11231123
}
1124-
11251124
"""
11261125
names = [name for name in dir(self.o)
11271126
if name.startswith(('set_', 'get_'))
@@ -1131,9 +1130,9 @@ def get_aliases(self):
11311130
func = getattr(self.o, name)
11321131
if not self.is_alias(func):
11331132
continue
1134-
docstring = func.__doc__
1135-
fullname = docstring.replace('`', '')[10:]
1136-
aliases.setdefault(fullname[4:], {})[name[4:]] = None
1133+
propname = re.search("`({}.*)`".format(name[:4]), # get_.*/set_.*
1134+
func.__doc__).group(1)
1135+
aliases.setdefault(propname, set()).add(name[4:])
11371136
return aliases
11381137

11391138
_get_valid_values_regex = re.compile(

lib/matplotlib/axis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# allows all Line2D kwargs.
3131
_line_AI = artist.ArtistInspector(mlines.Line2D)
3232
_line_param_names = _line_AI.get_setters()
33-
_line_param_aliases = [list(d.keys())[0] for d in _line_AI.aliasd.values()]
33+
_line_param_aliases = [list(d)[0] for d in _line_AI.aliasd.values()]
3434
_gridline_param_names = ['grid_' + name
3535
for name in _line_param_names + _line_param_aliases]
3636

0 commit comments

Comments
 (0)