summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/reference/routines.char.rst1
-rw-r--r--doc/source/reference/routines.other.rst18
-rw-r--r--numpy/core/_add_newdocs.py160
3 files changed, 179 insertions, 0 deletions
diff --git a/doc/source/reference/routines.char.rst b/doc/source/reference/routines.char.rst
index 3f4efdfc5..b58dd60b3 100644
--- a/doc/source/reference/routines.char.rst
+++ b/doc/source/reference/routines.char.rst
@@ -56,6 +56,7 @@ comparison.
less_equal
greater
less
+ compare_chararrays
String information
------------------
diff --git a/doc/source/reference/routines.other.rst b/doc/source/reference/routines.other.rst
index 0a3677904..5bd5835f6 100644
--- a/doc/source/reference/routines.other.rst
+++ b/doc/source/reference/routines.other.rst
@@ -21,6 +21,7 @@ Memory ranges
shares_memory
may_share_memory
+ byte_bounds
Array mixins
------------
@@ -35,3 +36,20 @@ NumPy version comparison
:toctree: generated/
lib.NumpyVersion
+
+Utility
+-------
+
+.. autosummary::
+ :toctree: generated/
+
+ get_include
+ deprecate
+ deprecate_with_doc
+
+Matlab-like Functions
+---------------------
+.. autosummary::
+ :toctree: generated/
+
+ who \ No newline at end of file
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index 84339ef23..39974bb0b 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -3336,6 +3336,41 @@ add_newdoc('numpy.core.multiarray', 'may_share_memory',
""")
+add_newdoc('numpy.lib.utils', 'byte_bounds',
+ """
+ byte_bounds(a)
+
+ Returns pointers to the end-points of an array in the form of tuple
+ of two integers. The first integer is the first byte of the array,
+ the second integer is just past the last byte of the array.
+
+ If `a` is not contiguous it will not use every byte between the
+ returned integer values.
+
+ Parameters
+ ----------
+ a : ndarray
+ Input array. It must conform to the Python-side of the array
+ interface.
+
+ Returns
+ -------
+ (low, high) : tuple of 2 integers
+
+ Examples
+ --------
+ >>> x = np.array([1,2,4])
+ >>> np.byte_bounds(x)
+ (32030368, 32030392)
+ >>> I = np.eye(2, dtype='f'); I.dtype
+ dtype('float32')
+ >>> low, high = np.byte_bounds(I)
+ >>> high - low == I.size*I.itemsize
+ True
+
+ """)
+
+
add_newdoc('numpy.core.multiarray', 'ndarray', ('newbyteorder',
"""
arr.newbyteorder(new_order='S')
@@ -4348,6 +4383,53 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('view',
[(4, 5)]], dtype=[('width', '<i2'), ('length', '<i2')])
"""))
+add_newdoc('numpy.lib.utils', 'who',
+ """
+ who(verdict=None)
+
+ Print the NumPy arrays in the given dictionary.
+
+ If there is no dictionary passed in or `vardict` is None then returns
+ NumPy arrays in the globals() dictionary (all NumPy arrays in the
+ namespace).
+
+ Parameters
+ ----------
+ vardict : dict, optional
+ A dictionary possibly containing ndarrays. Default is globals().
+
+ Returns
+ -------
+ out : None
+ Returns 'None'.
+
+ Notes
+ -----
+ Prints out the name, shape, bytes and type of all of the ndarrays
+ present in `vardict`.
+
+ Examples
+ --------
+ >>> a = np.arange(10)
+ >>> b = np.ones(20)
+ >>> np.who()
+ Name Shape Bytes Type
+ ===========================================================
+ a 10 80 int64
+ b 20 160 float64
+ Upper bound on total bytes = 240
+
+ >>> d = {'x': np.arange(2.0), 'y': np.arange(3.0), 'txt': 'Some str',
+ ... 'idx':5}
+ >>> np.who(d)
+ Name Shape Bytes Type
+ ===========================================================
+ x 2 16 float64
+ y 3 24 float64
+ Upper bound on total bytes = 40
+
+ """)
+
##############################################################################
#
@@ -6997,3 +7079,81 @@ for float_name in ('half', 'single', 'double', 'longdouble'):
>>> np.{ftype}(-.25).as_integer_ratio()
(-1, 4)
""".format(ftype=float_name)))
+
+##############################################################################
+#
+# Miscellaneous utility routines
+#
+##############################################################################
+
+add_newdoc('numpy.lib.utils', 'get_include',
+ """
+
+ Parameters
+ ----------
+ None
+
+ Returns
+ -------
+ Directory that contains the NumPy \\*.h header files.
+
+ Extension modules that need to compile against NumPy should use this
+ function to locate the appropriate include directory.
+
+ """)
+
+add_newdoc('numpy.lib.utils', 'deprecate',
+ """
+
+ deprecate(func, old_name, new_name, message)
+
+ Parameters
+ ----------
+ func : function
+ The function to be deprecated.
+ old_name : str, optional
+ The name of the function to be deprecated. Default is None, in
+ which case the name of `func` is used.
+ new_name : str, optional
+ The new name for the function. Default is None, in which case the
+ deprecation message is that `old_name` is deprecated. If given, the
+ deprecation message is that `old_name` is deprecated and `new_name`
+ should be used instead.
+ message : str, optional
+ Additional explanation of the deprecation. Displayed in the
+ docstring after the warning.
+
+ Returns
+ -------
+ old_func : function
+ The deprecated function.
+
+ Examples
+ --------
+ Note that ``olduint`` returns a value after printing Deprecation
+ Warning:
+
+ >>> olduint = np.deprecate(np.uint)
+ DeprecationWarning: `uint64` is deprecated! # may vary
+ >>> olduint(6)
+ 6
+
+ Notes
+ -----
+ Deprecate may be run as a function or as a decorator
+ If run as a function, we initialise the decorator class
+ and execute its __call__ method.
+
+ """)
+
+add_newdoc('numpy.lib.utils', 'deprecate_with_doc',
+ """
+
+ Lambda function which calls the ``_Deprecate`` with a predefined
+ message.
+
+ Parameters
+ ----------
+ message : str
+
+ """)