summaryrefslogtreecommitdiff
path: root/numpy/lib/utils.py
diff options
context:
space:
mode:
authorSteve Joachim <sgjoachim@gmail.com>2020-10-10 05:47:20 -0400
committerGitHub <noreply@github.com>2020-10-10 10:47:20 +0100
commitaeb23741b1186e6ae525c4dd7f46ce9e1378e670 (patch)
treeedf2f49844fce7e4b78cd5573f8ac9c2985afd67 /numpy/lib/utils.py
parentdbb8e993da05b4f12f41cdbc68dbd9733cdd65ab (diff)
downloadnumpy-aeb23741b1186e6ae525c4dd7f46ce9e1378e670.tar.gz
MAINT: Do not emit empty Methods heading in np.info (#17498)
Fixes the incompatible type comparison found in #17490. This also corrects the logic to not print the heading when only private/magic methods are present.
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r--numpy/lib/utils.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index d511c2a40..5447608bf 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -587,11 +587,11 @@ def info(object=None, maxwidth=76, output=sys.stdout, toplevel='numpy'):
print(inspect.getdoc(object), file=output)
methods = pydoc.allmethods(object)
- if methods != []:
+
+ public_methods = [meth for meth in methods if meth[0] != '_']
+ if public_methods:
print("\n\nMethods:\n", file=output)
- for meth in methods:
- if meth[0] == '_':
- continue
+ for meth in public_methods:
thisobj = getattr(object, meth, None)
if thisobj is not None:
methstr, other = pydoc.splitdoc(