diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2020-01-23 14:44:36 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2020-01-23 14:56:57 -0700 |
commit | b4e3a4227e3a9cfe28717db458e67d79e916a418 (patch) | |
tree | f8e78724985f104bb6302d5a36d4e9a0799f0ca1 /numpy/ma | |
parent | 11654979194d7d17b78cee08f4a26877acd5071b (diff) | |
download | numpy-b4e3a4227e3a9cfe28717db458e67d79e916a418.tar.gz |
MAINT: Replace basestring with str.
This replaces basestring with str except in
- tools/npy_tempita/
- numpy/compat/py3k.py
Diffstat (limited to 'numpy/ma')
-rw-r--r-- | numpy/ma/core.py | 10 | ||||
-rw-r--r-- | numpy/ma/mrecords.py | 5 |
2 files changed, 7 insertions, 8 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 41c35026d..6fe442c69 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -35,7 +35,7 @@ from numpy import ndarray, amax, amin, iscomplexobj, bool_, _NoValue from numpy import array as narray from numpy.lib.function_base import angle from numpy.compat import ( - getargspec, formatargspec, long, basestring, unicode, bytes + getargspec, formatargspec, long, unicode, bytes ) from numpy import expand_dims from numpy.core.numeric import normalize_axis_tuple @@ -456,7 +456,7 @@ def _check_fill_value(fill_value, ndtype): fill_value = np.array(_recursive_set_fill_value(fill_value, ndtype), dtype=ndtype) else: - if isinstance(fill_value, basestring) and (ndtype.char not in 'OSVU'): + if isinstance(fill_value, str) and (ndtype.char not in 'OSVU'): # Note this check doesn't work if fill_value is not a scalar err_msg = "Cannot set fill value of string with array of dtype %s" raise TypeError(err_msg % ndtype) @@ -781,9 +781,9 @@ def fix_invalid(a, mask=nomask, copy=True, fill_value=None): return a def is_string_or_list_of_strings(val): - return (isinstance(val, basestring) or + return (isinstance(val, str) or (isinstance(val, list) and val and - builtins.all(isinstance(s, basestring) for s in val))) + builtins.all(isinstance(s, str) for s in val))) ############################################################################### # Ufuncs # @@ -3300,7 +3300,7 @@ class MaskedArray(ndarray): raise MaskError('Cannot alter the masked element.') _data = self._data _mask = self._mask - if isinstance(indx, basestring): + if isinstance(indx, str): _data[indx] = value if _mask is nomask: self._mask = _mask = make_mask_none(self.shape, self.dtype) diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index 4ff7866ab..a154cbbc8 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -17,7 +17,6 @@ import sys import warnings import numpy as np -from numpy.compat import basestring from numpy import ( bool_, dtype, ndarray, recarray, array as narray ) @@ -303,7 +302,7 @@ class MaskedRecords(MaskedArray): _mask = ndarray.__getattribute__(self, '_mask') _data = ndarray.view(self, _localdict['_baseclass']) # We want a field - if isinstance(indx, basestring): + if isinstance(indx, str): # Make sure _sharedmask is True to propagate back to _fieldmask # Don't use _set_mask, there are some copies being made that # break propagation Don't force the mask to nomask, that wreaks @@ -330,7 +329,7 @@ class MaskedRecords(MaskedArray): """ MaskedArray.__setitem__(self, indx, value) - if isinstance(indx, basestring): + if isinstance(indx, str): self._mask[indx] = ma.getmaskarray(value) def __str__(self): |