Deprecate MarkerStyle(None).#21074
Conversation
dc1e568 to
4df79be
Compare
lib/matplotlib/tests/test_axes.py
Outdated
| for y, marker in enumerate([ | ||
| "none", | ||
| *sorted({*matplotlib.markers.MarkerStyle.markers} - {"none"}, | ||
| key=lambda x: str(type(x))+str(x))]): |
There was a problem hiding this comment.
I tried but struggled to work out what's going on here with the change?
There was a problem hiding this comment.
The test simply draws all markers in a single figure, ordered by str(type(x))+str(x) (not all x have same type: markers can be str (most of them), but also int or, previously, None, hence the need to convert to str). A previous PR introduced MarkerStyle("none"), i.e. "none" was added into the MarkerStyle.markers dict; in order to not change the baseline image, I had to remove it from the list of entries. With this PR, I additionally removed None from the dict; again, in order to not change the baseline image, I had to put it back (using its synonym "none") into the list of entries (at the position where it was previously, i.e. in from of everything else).
There was a problem hiding this comment.
I would write this as
markers = sorted(matplotlib.markers.MarkerStyle.markers,
key=lambda x: str(type(x))+str(x))
# Since generation of the test image, None was removed but 'none' was
# added. By moving 'none' to the front (=former sorted place of None)
# we can avoid regenerating the test image. This can be removed if the
# test image has to be regenerated for other reasons.
markers.remove('none')
markers = ['none', *markers]
for y, marker in enumerate(markers):
See docstring change for the confusion that this resolves. We can normalize None inputs on the caller side (and note that directly constructing MarkerStyles is not something that most users need to do).
Deprecate MarkerStyle(None).
Fix two cases of the following deprecation:
MatplotlibDeprecationWarning: MarkerStyle(None) is deprecated since 3.6; support will be removed two minor releases later. Use MarkerStyle('') to construct an empty MarkerStyle.
See matplotlib/matplotlib#21074
Fix two cases of the following deprecation:
MatplotlibDeprecationWarning: MarkerStyle(None) is deprecated since 3.6; support will be removed two minor releases later. Use MarkerStyle('') to construct an empty MarkerStyle.
See matplotlib/matplotlib#21074
Fix two cases of the following deprecation:
MatplotlibDeprecationWarning: MarkerStyle(None) is deprecated since 3.6; support will be removed two minor releases later. Use MarkerStyle('') to construct an empty MarkerStyle.
See matplotlib/matplotlib#21074
Fix two cases of the following deprecation:
MatplotlibDeprecationWarning: MarkerStyle(None) is deprecated since 3.6; support will be removed two minor releases later. Use MarkerStyle('') to construct an empty MarkerStyle.
See matplotlib/matplotlib#21074
See docstring change for the confusion that this resolves.
We can normalize None inputs on the caller side (and note that directly
constructing MarkerStyles is not something that most users need to do).
PR Summary
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).