def test_method_docstring(self): import numpy as np doc = int.bit_length.__doc__ try: np.set_docstring(np.ndarray.shape, 'foo') assert np.ndarray.shape.__doc__ == 'foo' finally: np.set_docstring(np.ndarray.shape, doc)
def test_property_docstring(self): import numpy as np doc = np.flatiter.base.__doc__ try: np.set_docstring(np.flatiter.base, 'foo') assert np.flatiter.base.__doc__ == 'foo' finally: np.set_docstring(np.flatiter.base, doc)
def test_method_docstring(self): import numpy as np doc = int.bit_length.__doc__ try: np.set_docstring(int.bit_length, 'foo') assert int.bit_length.__doc__ == 'foo' finally: np.set_docstring(int.bit_length, doc)
def test_type_docstring(self): import numpy as np import types obj = types.ModuleType doc = obj.__doc__ try: np.set_docstring(obj, 'foo') assert obj.__doc__ == 'foo' finally: np.set_docstring(obj, doc) raises(RuntimeError, np.add_docstring, obj, 'foo')
def test_add_doc(self): import sys if "__pypy__" not in sys.builtin_module_names: skip("") try: from numpy import set_docstring except ImportError: from _numpypy.multiarray import set_docstring import numpy as np assert np.add.__doc__ is None add_doc = np.add.__doc__ ufunc_doc = np.ufunc.__doc__ try: np.add.__doc__ = "np.add" assert np.add.__doc__ == "np.add" # Test for interferences between ufunc objects and their class set_docstring(np.ufunc, "np.ufunc") assert np.ufunc.__doc__ == "np.ufunc" assert np.add.__doc__ == "np.add" finally: set_docstring(np.ufunc, ufunc_doc) np.add.__doc__ = add_doc