From 7a2fb4ebd8c02035eb3f7fec81f402e066b94d41 Mon Sep 17 00:00:00 2001 From: apodemus Date: Wed, 27 Sep 2017 16:29:25 +0200 Subject: [PATCH 1/3] add filter to cbook.safe_first_element to avoid returning masked values --- lib/matplotlib/cbook/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index bf33e5fe65cc..42f6455598c9 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -2311,7 +2311,7 @@ def safe_first_element(obj): pass raise RuntimeError("matplotlib does not support generators " "as input") - return next(iter(obj)) + return next(filter(None, iter(obj))) def sanitize_sequence(data): From 91f967063e38be234eb9f4e17ba195b1bfeeafd8 Mon Sep 17 00:00:00 2001 From: apodemus Date: Wed, 27 Sep 2017 16:51:13 +0200 Subject: [PATCH 2/3] add filter to cbook.safe_first_element to avoid returning masked values --- lib/matplotlib/cbook/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 42f6455598c9..f89ce1294b17 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -2311,7 +2311,7 @@ def safe_first_element(obj): pass raise RuntimeError("matplotlib does not support generators " "as input") - return next(filter(None, iter(obj))) + return next(filter(lambda e: not np.ma.is_masked(e), iter(obj))) def sanitize_sequence(data): From d0c5321a30ebd87213f4fea4d39c580f98742f3f Mon Sep 17 00:00:00 2001 From: apodemus Date: Thu, 28 Sep 2017 01:06:35 +0200 Subject: [PATCH 3/3] replace collections.Sized check with np.size to better handle masked elements in errorbar --- lib/matplotlib/axes/_axes.py | 4 +--- lib/matplotlib/cbook/__init__.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 8111eaeee303..c56407b1a7c1 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4,7 +4,6 @@ import six from six.moves import xrange, zip, zip_longest -from collections import Sized import functools import itertools import math @@ -3020,8 +3019,7 @@ def extract_err(err, data): # special case for empty lists if len(err) > 1: fe = safe_first_element(err) - if (len(err) != len(data) - or isinstance(fe, Sized) and len(fe) > 1): + if (len(err) != len(data) or np.size(fe) > 1): raise ValueError("err must be [ scalar | N, Nx1 " "or 2xN array-like ]") # using list comps rather than arrays to preserve units diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index f89ce1294b17..bf33e5fe65cc 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -2311,7 +2311,7 @@ def safe_first_element(obj): pass raise RuntimeError("matplotlib does not support generators " "as input") - return next(filter(lambda e: not np.ma.is_masked(e), iter(obj))) + return next(iter(obj)) def sanitize_sequence(data): 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