summaryrefslogtreecommitdiff
path: root/numpy/lib/recfunctions.py
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2019-09-15 08:20:50 +0300
committerGitHub <noreply@github.com>2019-09-15 08:20:50 +0300
commit96103d769301f9c915e23b2a233aa5634008db81 (patch)
tree90df2ab24d0931ed0f8cdf75a7171782d762d546 /numpy/lib/recfunctions.py
parent53adf81bc503d749b13160a27e49160c5bbe48d7 (diff)
parent49916f66479d7a6b14087f39e06290941e07596d (diff)
downloadnumpy-96103d769301f9c915e23b2a233aa5634008db81.tar.gz
Merge pull request #14510 from eric-wieser/fix-drop_fields
API: Do not return None from recfunctions.drop_fields
Diffstat (limited to 'numpy/lib/recfunctions.py')
-rw-r--r--numpy/lib/recfunctions.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py
index 40060b41a..8011f5363 100644
--- a/numpy/lib/recfunctions.py
+++ b/numpy/lib/recfunctions.py
@@ -527,6 +527,10 @@ def drop_fields(base, drop_names, usemask=True, asrecarray=False):
Nested fields are supported.
+ ..versionchanged: 1.18.0
+ `drop_fields` returns an array with 0 fields if all fields are dropped,
+ rather than returning ``None`` as it did previously.
+
Parameters
----------
base : array
@@ -566,7 +570,7 @@ def drop_fields(base, drop_names, usemask=True, asrecarray=False):
current = ndtype[name]
if name in drop_names:
continue
- if current.names:
+ if current.names is not None:
descr = _drop_descr(current, drop_names)
if descr:
newdtype.append((name, descr))
@@ -575,8 +579,6 @@ def drop_fields(base, drop_names, usemask=True, asrecarray=False):
return newdtype
newdtype = _drop_descr(base.dtype, drop_names)
- if not newdtype:
- return None
output = np.empty(base.shape, dtype=newdtype)
output = recursive_fill_fields(base, output)