Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Deprecate support for no-args MarkerStyle().#21056

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 1 commit intomatplotlib:masterfromanntzer:msn
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes fromall 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
3 changes: 3 additions & 0 deletionsdoc/api/next_api_changes/deprecations/21056-AL.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
Calling ``MarkerStyle()`` with no arguments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... is deprecated; use ``MarkerStyle("")`` to construct an empty marker style.
26 changes: 20 additions & 6 deletionslib/matplotlib/markers.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,9 +63,9 @@
rotated by ``angle``.
============================== ====== =========================================

``None``is the default whichmeans 'nothing', however this table is
referred to fromotherdocs for the valid inputs frommarker inputs and in
those cases ``None`` still means 'default'.
``None``alsomeans 'nothing' when directly constructing a `.MarkerStyle`, but
note that there areothercontexts where ``marker=None`` instead means "the
default marker" (e.g. :rc:`scatter.marker` for `.Axes.scatter`).

Note that special symbols can be defined via the
:doc:`STIX math font </tutorials/text/mathtext>`,
Expand DownExpand Up@@ -127,6 +127,7 @@
"""

from collections.abc import Sized
import inspect

import numpy as np

Expand DownExpand Up@@ -216,14 +217,16 @@ class MarkerStyle:
# TODO: Is this ever used as a non-constant?
_point_size_reduction = 0.5

def __init__(self, marker=None, fillstyle=None):
_unset = object() # For deprecation of MarkerStyle(<noargs>).

def __init__(self, marker=_unset, fillstyle=None):
"""
Parameters
----------
marker : str, array-like, Path, MarkerStyle, or None, default: None
marker : str, array-like, Path, MarkerStyle, or None
- Another instance of *MarkerStyle* copies the details of that
``marker``.
- *None* means no marker.
- *None* means no marker. This is the deprecated default.
- For other possible marker values see the module docstring
`matplotlib.markers`.

Expand All@@ -232,8 +235,19 @@ def __init__(self, marker=None, fillstyle=None):
"""
self._marker_function = None
self._set_fillstyle(fillstyle)
# Remove _unset and signature rewriting after deprecation elapses.
if marker is self._unset:
marker = ""
_api.warn_deprecated(
"3.6", message="Calling MarkerStyle() with no parameters is "
"deprecated since %(since)s; support will be removed "
"%(removal)s. Use MarkerStyle('') to construct an empty "
"MarkerStyle.")
self._set_marker(marker)

__init__.__signature__ = inspect.signature( # Only for deprecation period.
lambda self, marker, fillstyle=None: None)

def _recache(self):
if self._marker_function is None:
return
Expand Down
8 changes: 7 additions & 1 deletionlib/matplotlib/tests/test_marker.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import markers
from matplotlib._api.deprecation import MatplotlibDeprecationWarning
from matplotlib.path import Path
from matplotlib.testing.decorators import check_figures_equal

Expand DownExpand Up@@ -32,14 +33,19 @@ def test_marker_fillstyle():
(5, 0, 10), # a pentagon, rotated by 10 degrees
(7, 1, 10), # a 7-pointed star, rotated by 10 degrees
(5, 2, 10), # asterisk, rotated by 10 degrees
markers.MarkerStyle(),
markers.MarkerStyle('o'),
])
def test_markers_valid(marker):
# Checking this doesn't fail.
markers.MarkerStyle(marker)


def test_deprecated_marker_noargs():
with pytest.warns(MatplotlibDeprecationWarning):
ms = markers.MarkerStyle()
markers.MarkerStyle(ms) # No warning on copy.


@pytest.mark.parametrize('marker', [
'square', # arbitrary string
np.array([[-0.5, 0, 1, 2, 3]]), # 1D array
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp