8000 Add test for patches setter and getter · matplotlib/matplotlib@03fb397 · GitHub
[go: up one dir, main page]

Skip to content
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

Appearance settings

Commit 03fb397

Browse files
committed
Add test for patches setter and getter
1 parent 52e5723 commit 03fb397

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/matplotlib/collections.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Collection(artist.Artist, cm.ScalarMappable):
4848
def get_urls(self) -> Sequence[str | None]: ...
4949
def set_hatch(self, hatch: str) -> None: ...
5050
def get_hatch(self) -> str: ...
51-
def set_hatch_linewidth(self, hatch_linewidth: float) -> None: ...
51+
def set_hatch_linewidth(self, lw: float) -> None: ...
5252
def get_hatch_linewidth(self) -> float: ...
5353
def set_offsets(self, offsets: ArrayLike) -> None: ...
5454
def get_offsets(self) -> ArrayLike: ...

lib/matplotlib/tests/test_patches.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,3 +960,20 @@ def test_arrow_set_data():
960960
)
961961
arrow.set_data(x=.5, dx=3, dy=8, width=1.2)
962962
assert np.allclose(expected2, np.round(arrow.get_verts(), 2))
963+
964+
965+
@check_figures_equal(extensions=["png", "pdf", "svg", "eps"])
966+
def test_set_and_get_hatch_linewidth(fig_test, fig_ref):
967+
ax_test = fig_test.add_subplot()
968+
ax_ref = fig_ref.add_subplot()
969+
970+
lw = 2.0
971+
972+
with plt.rc_context({"hatch.linewidth": lw}):
973+
ax_ref.add_patch(mpatches.Rectangle((0, 0), 1, 1, hatch="x"))
974+
975+
ax_test.add_patch(mpatches.Rectangle((0, 0), 1, 1, hatch="x"))
976+
ax_test.patches[0].set_hatch_linewidth(lw)
977+
978+
assert (ax_ref.patches[0].get_hatch_linewidth() == lw)
979+
assert (ax_test.patches[0].get_hatch_linewidth() == lw)

0 commit comments

Comments
 (0)
0