Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91191ce

Browse files
authored
TST Added a test to check valid and invalid markers (#2)
1 parent 4b5d999 commit 91191ce

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/matplotlib/markers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ def set_marker(self, marker):
253253
elif (iterable(marker) and len(marker) in (2, 3) and
254254
marker[1] in (0, 1, 2, 3)):
255255
self._marker_function = self._set_tuple_marker
256-
elif not isinstance(marker, list) and marker in self.markers:
256+
elif (not isinstance(marker, (np.ndarray, list)) and
257+
marker in self.markers):
257258
self._marker_function = getattr(
258259
self, '_set_' + self.markers[marker])
259260
elif is_string_like(marker) and is_math_text(marker):

lib/matplotlib/tests/test_marker.py

Lines 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)