From 4b7ad543e0f54f6473ccce5f7aab1f83d1f31405 Mon Sep 17 00:00:00 2001 From: Levi Kilcher Date: Thu, 12 Jan 2017 10:53:35 -0700 Subject: [PATCH 1/3] Fix for marker verts bug --- lib/matplotlib/markers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index d5b051709ef6..54203b7c0245 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -249,11 +249,12 @@ def get_marker(self): return self._marker def set_marker(self, marker): - if (isinstance(marker, Sized) and len(marker) in (2, 3) and + if (isinstance(marker, np.ndarray) and marker.ndim == 2 and + marker.shape[1] == 2): + self._marker_function = self._set_vertices + elif (isinstance(marker, Sized) and len(marker) in (2, 3) and marker[1] in (0, 1, 2, 3)): self._marker_function = self._set_tuple_marker - elif isinstance(marker, np.ndarray): - self._marker_function = self._set_vertices elif not isinstance(marker, list) and marker in self.markers: self._marker_function = getattr( self, '_set_' + self.markers[marker]) From 41671e459236cd9d149082abc841195c6d2613e9 Mon Sep 17 00:00:00 2001 From: Levi Kilcher Date: Sun, 29 Jan 2017 10:44:22 -0700 Subject: [PATCH 2/3] TST Added a test to check valid and invalid markers (#2) --- lib/matplotlib/markers.py | 3 ++- lib/matplotlib/tests/test_marker.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 lib/matplotlib/tests/test_marker.py diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index 54203b7c0245..366a17e4fceb 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -255,7 +255,8 @@ def set_marker(self, marker): elif (isinstance(marker, Sized) and len(marker) in (2, 3) and marker[1] in (0, 1, 2, 3)): self._marker_function = self._set_tuple_marker - elif not isinstance(marker, list) and marker in self.markers: + elif (not isinstance(marker, (np.ndarray, list)) and + marker in self.markers): self._marker_function = getattr( self, '_set_' + self.markers[marker]) elif is_string_like(marker) and is_math_text(marker): diff --git a/lib/matplotlib/tests/test_marker.py b/lib/matplotlib/tests/test_marker.py new file mode 100644 index 000000000000..f0ac1f4c19a8 --- /dev/null +++ b/lib/matplotlib/tests/test_marker.py @@ -0,0 +1,20 @@ +import numpy as np +from matplotlib import markers + +import pytest + + +def test_markers_valid(): + marker_style = markers.MarkerStyle() + mrk_array = np.array([[-0.5, 0], + [0.5, 0]]) + # Checking this doesn't fail. + marker_style.set_marker(mrk_array) + + +def test_markers_invalid(): + marker_style = markers.MarkerStyle() + mrk_array = np.array([[-0.5, 0, 1, 2, 3]]) + # Checking this doesn't fail. + with pytest.raises(ValueError): + marker_style.set_marker(mrk_array) From 019d651b91d7e37da5578e7b75ce4d014ec799cd Mon Sep 17 00:00:00 2001 From: Levi Kilcher Date: Sun, 29 Jan 2017 11:25:30 -0700 Subject: [PATCH 3/3] Correct test comment. --- lib/matplotlib/tests/test_marker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_marker.py b/lib/matplotlib/tests/test_marker.py index f0ac1f4c19a8..e2290f029dcc 100644 --- a/lib/matplotlib/tests/test_marker.py +++ b/lib/matplotlib/tests/test_marker.py @@ -15,6 +15,6 @@ def test_markers_valid(): def test_markers_invalid(): marker_style = markers.MarkerStyle() mrk_array = np.array([[-0.5, 0, 1, 2, 3]]) - # Checking this doesn't fail. + # Checking this does fail. with pytest.raises(ValueError): marker_style.set_marker(mrk_array) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy