Skip to content

Commit ad1dd48

Browse files
committed
GaussianKDE, silence Unicode warning
Ensure that bw_method is a string before comparing to strings
1 parent a73cd6e commit ad1dd48

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/matplotlib/mlab.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,15 +3825,15 @@ def __init__(self, dataset, bw_method=None):
38253825
raise ValueError("`dataset` input should have multiple elements.")
38263826

38273827
self.dim, self.num_dp = np.array(self.dataset).shape
3828+
isString = isinstance(bw_method, six.string_types)
38283829

38293830
if bw_method is None:
38303831
pass
3831-
elif bw_method == 'scott':
3832+
elif (isString and bw_method == 'scott'):
38323833
self.covariance_factor = self.scotts_factor
3833-
elif bw_method == 'silverman':
3834+
elif (isString and bw_method == 'silverman'):
38343835
self.covariance_factor = self.silverman_factor
3835-
elif (np.isscalar(bw_method) and not
3836-
isinstance(bw_method, six.string_types)):
3836+
elif (np.isscalar(bw_method) and not isString):
38373837
self._bw_method = 'use constant'
38383838
self.covariance_factor = lambda: bw_method
38393839
elif callable(bw_method):

0 commit comments

Comments
 (0)