summaryrefslogtreecommitdiff
path: root/numpy/core/function_base.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2019-07-08 20:36:12 -0700
committerGitHub <noreply@github.com>2019-07-08 20:36:12 -0700
commit42a086d93a256bd8df371d7f62a5b23592a25f60 (patch)
tree96a1282c56f27ddc2703bec86014d96e08d66c39 /numpy/core/function_base.py
parentaf5a108475fe1969f2b5ee2e0ec81ddc278f6437 (diff)
downloadnumpy-42a086d93a256bd8df371d7f62a5b23592a25f60.tar.gz
Revert "MAINT/BUG/DOC: Fix errors in _add_newdocs (#13876)"revert-13876-forbid-_add_newdocs-python
This reverts commit 7ac7fa9a4621f7392f534b20f0cdd64967e9c7eb.
Diffstat (limited to 'numpy/core/function_base.py')
-rw-r--r--numpy/core/function_base.py29
1 files changed, 12 insertions, 17 deletions
diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py
index c1067299d..296213823 100644
--- a/numpy/core/function_base.py
+++ b/numpy/core/function_base.py
@@ -431,13 +431,6 @@ def geomspace(start, stop, num=50, endpoint=True, dtype=None, axis=0):
#always succeed
-def _add_docstring(obj, doc):
- try:
- add_docstring(obj, doc)
- except Exception:
- pass
-
-
def add_newdoc(place, obj, doc):
"""
Adds documentation to obj which is in module place.
@@ -452,19 +445,21 @@ def add_newdoc(place, obj, doc):
sequence of length two --> [(method1, docstring1),
(method2, docstring2), ...]
- This routine never raises an error if the docstring can't be written, but
- will raise an error if the object being documented does not exist.
+ This routine never raises an error.
This routine cannot modify read-only docstrings, as appear
in new-style classes or built-in functions. Because this
routine never raises an error the caller must check manually
that the docstrings were changed.
"""
- new = getattr(__import__(place, globals(), {}, [obj]), obj)
- if isinstance(doc, str):
- _add_docstring(new, doc.strip())
- elif isinstance(doc, tuple):
- _add_docstring(getattr(new, doc[0]), doc[1].strip())
- elif isinstance(doc, list):
- for val in doc:
- _add_docstring(getattr(new, val[0]), val[1].strip())
+ try:
+ new = getattr(__import__(place, globals(), {}, [obj]), obj)
+ if isinstance(doc, str):
+ add_docstring(new, doc.strip())
+ elif isinstance(doc, tuple):
+ add_docstring(getattr(new, doc[0]), doc[1].strip())
+ elif isinstance(doc, list):
+ for val in doc:
+ add_docstring(getattr(new, val[0]), val[1].strip())
+ except Exception:
+ pass