From aeb23741b1186e6ae525c4dd7f46ce9e1378e670 Mon Sep 17 00:00:00 2001 From: Steve Joachim Date: Sat, 10 Oct 2020 05:47:20 -0400 Subject: 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. --- numpy/lib/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'numpy/lib/utils.py') 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( -- cgit v1.2.1