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

Commit2f4f08e

Browse files
committed
Fix default return of Collection.get_{cap,join}style
If neither are specified at object creation, the default is to be`None`. This broke `get_{cap,join}style` when the enum wrappers werecreated as they assume the internal value is always an enum value.
1 parent5a89bdb commit2f4f08e

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

‎lib/matplotlib/collections.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,16 @@ def set_capstyle(self, cs):
639639
"""
640640
self._capstyle=CapStyle(cs)
641641

642+
@_docstring.interpd
642643
defget_capstyle(self):
643-
returnself._capstyle.name
644+
"""
645+
Return the cap style for the collection (for all its elements).
646+
647+
Returns
648+
-------
649+
%(CapStyle)s or None
650+
"""
651+
returnself._capstyle.nameifself._capstyleelseNone
644652

645653
@_docstring.interpd
646654
defset_joinstyle(self,js):
@@ -653,8 +661,16 @@ def set_joinstyle(self, js):
653661
"""
654662
self._joinstyle=JoinStyle(js)
655663

664+
@_docstring.interpd
656665
defget_joinstyle(self):
657-
returnself._joinstyle.name
666+
"""
667+
Return the join style for the collection (for all its elements).
668+
669+
Returns
670+
-------
671+
%(JoinStyle)s or None
672+
"""
673+
returnself._joinstyle.nameifself._joinstyleelseNone
658674

659675
@staticmethod
660676
def_bcast_lwls(linewidths,dashes):

‎lib/matplotlib/collections.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class Collection(artist.Artist, cm.ScalarMappable):
5252
defset_linewidth(self,lw:float|Sequence[float])->None: ...
5353
defset_linestyle(self,ls:LineStyleType|Sequence[LineStyleType])->None: ...
5454
defset_capstyle(self,cs:CapStyleType)->None: ...
55-
defget_capstyle(self)->Literal["butt","projecting","round"]: ...
55+
defget_capstyle(self)->Literal["butt","projecting","round"]|None: ...
5656
defset_joinstyle(self,js:JoinStyleType)->None: ...
57-
defget_joinstyle(self)->Literal["miter","round","bevel"]: ...
57+
defget_joinstyle(self)->Literal["miter","round","bevel"]|None: ...
5858
defset_antialiased(self,aa:bool|Sequence[bool])->None: ...
5959
defset_color(self,c:ColorType|Sequence[ColorType])->None: ...
6060
defset_facecolor(self,c:ColorType|Sequence[ColorType])->None: ...

‎lib/matplotlib/tests/test_collections.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ def test_set_wrong_linestyle():
620620

621621
@mpl.style.context('default')
622622
deftest_capstyle():
623+
col=mcollections.PathCollection([])
624+
assertcol.get_capstyle()isNone
623625
col=mcollections.PathCollection([],capstyle='round')
624626
assertcol.get_capstyle()=='round'
625627
col.set_capstyle('butt')
@@ -628,6 +630,8 @@ def test_capstyle():
628630

629631
@mpl.style.context('default')
630632
deftest_joinstyle():
633+
col=mcollections.PathCollection([])
634+
assertcol.get_joinstyle()isNone
631635
col=mcollections.PathCollection([],joinstyle='round')
632636
assertcol.get_joinstyle()=='round'
633637
col.set_joinstyle('miter')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp