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

Appearance settings

Commit 41671e4

Browse filesBrowse files
committed
TST Added a test to check valid and invalid markers (#2)
1 parent 4b7ad54 commit 41671e4
Copy full SHA for 41671e4

File tree

2 files changed

+22
-1
lines changed
Filter options

2 files changed

+22
-1
lines changed

‎lib/matplotlib/markers.py

Copy file name to clipboardExpand all lines: lib/matplotlib/markers.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ def set_marker(self, marker):
255255
elif (isinstance(marker, Sized) and len(marker) in (2, 3) and
256256
marker[1] in (0, 1, 2, 3)):
257257
self._marker_function = self._set_tuple_marker
258-
elif not isinstance(marker, list) and marker in self.markers:
258+
elif (not isinstance(marker, (np.ndarray, list)) and
259+
marker in self.markers):
259260
self._marker_function = getattr(
260261
self, '_set_' + self.markers[marker])
261262
elif is_string_like(marker) and is_math_text(marker):

‎lib/matplotlib/tests/test_marker.py

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import numpy as np
2+
from matplotlib import markers
3+
4+
import pytest
5+
6+
7+
def test_markers_valid():
8+
marker_style = markers.MarkerStyle()
9+
mrk_array = np.array([[-0.5, 0],
10+
[0.5, 0]])
11+
# Checking this doesn't fail.
12+
marker_style.set_marker(mrk_array)
13+
14+
15+
def test_markers_invalid():
16+
marker_style = markers.MarkerStyle()
17+
mrk_array = np.array([[-0.5, 0, 1, 2, 3]])
18+
# Checking this doesn't fail.
19+
with pytest.raises(ValueError):
20+
marker_style.set_marker(mrk_array)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.