E5EB Fix MarkerStyle types by QuLogic · Pull Request #25825 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ class MarkerStyle:

Attributes
----------
markers : list
markers : dict
All known markers.
filled_markers : list
filled_markers : tuple
All known filled markers. This is a subset of *markers*.
fillstyles : list
fillstyles : tuple
The supported fillstyles.
"""

Expand Down Expand Up @@ -241,16 +241,16 @@ def __init__(self, marker,
Transform that will be combined with the native transform of the
marker.

capstyle : CapStyle, default: None
capstyle : `.CapStyle` or %(CapStyle)s, default: None
Cap style that will override the default cap style of the marker.

joinstyle : JoinStyle, default: None
joinstyle : `.JoinStyle` or %(JoinStyle)s, default: None
Join style that will override the default join style of the marker.
"""
self._marker_function = None
self._user_transform = transform
self._user_capstyle = capstyle
self._user_joinstyle = joinstyle
self._user_capstyle = CapStyle(capstyle) if capstyle is not None else None
self._user_joinstyle = JoinStyle(joinstyle) if joinstyle is not None else None
self._set_fillstyle(fillstyle)
self._set_marker(marker)

Expand Down
21 changes: 10 additions & 11 deletions lib/matplotlib/markers.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from ._enums import CapStyle, JoinStyle
from typing import Literal

from .path import Path
from .transforms import Affine2D, Transform

from numpy.typing import ArrayLike
from .typing import FillStyleType
from .typing import CapStyleType, FillStyleType, JoinStyleType

TICKLEFT: int
TICKRIGHT: int
Expand All @@ -28,20 +29,18 @@ class MarkerStyle:
marker: str | ArrayLike | Path | MarkerStyle | None,
fillstyle: FillStyleType | None = ...,
transform: Transform | None = ...,
capstyle: CapStyle | None = ...,
joinstyle: JoinStyle | None = ...,
capstyle: CapStyleType | None = ...,
joinstyle: JoinStyleType | None = ...,
) -> None: ...
def __bool__(self) -> bool: ...
def is_filled(self) -> bool: ...
def get_fillstyle(
self,
) -> FillStyleType: ...
def get_joinstyle(self) -> JoinStyle: ...
def get_capstyle(self) -> CapStyle: ...
def get_marker(self) -> str | ArrayLike | Path | MarkerStyle | None: ...
def get_fillstyle(self) -> FillStyleType: ...
def get_joinstyle(self) -> Literal["miter", "round", "bevel"]: ...
def get_capstyle(self) -> Literal["butt", "projecting", "round"]: ...
def get_marker(self) -> str | ArrayLike | Path | None: ...
def get_path(self) -> Path: ...
def get_transform(self) -> Transform: ...
def get_alt_path(self) -> Path: ...
def get_alt_path(self) -> Path | None: ...
def get_alt_transform(self) -> Transform: ...
def get_snap_threshold(self) -> float | None: ...
def get_user_transform(self) -> Transform | None: ...
Expand Down
14 changes: 6 additions & 8 deletions lib/matplotlib/tests/test_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,16 @@ def test_marker_init_transforms():

def test_marker_init_joinstyle():
marker = markers.MarkerStyle("*")
jstl = markers.JoinStyle.round
styled_marker = markers.MarkerStyle("*", joinstyle=jstl)
assert styled_marker.get_joinstyle() == jstl
assert marker.get_joinstyle() != jstl
styled_marker = markers.MarkerStyle("*", joinstyle="round")
assert styled_marker.get_joinstyle() == "round"
assert marker.get_joinstyle() != "round"


def test_marker_init_captyle():
marker = markers.MarkerStyle("*")
capstl = markers.CapStyle.round
styled_marker = markers.MarkerStyle("*", capstyle=capstl)
assert styled_marker.get_capstyle() == capstl
assert marker.get_capstyle() != capstl
styled_marker = markers.MarkerStyle("*", capstyle="round")
assert styled_marker.get_capstyle() == "round"
assert marker.get_capstyle() != "round"


@pytest.mark.parametrize("marker,transform,expected", [
Expand Down
0