[Numpy-svn] r8126 - in trunk/numpy: core distutils

numpy-svn@scip... numpy-svn@scip...
Wed Feb 17 17:42:43 CST 2010


Author: jarrod.millman
Date: 2010-02-17 17:42:42 -0600 (Wed, 17 Feb 2010)
New Revision: 8126

Modified:
   trunk/numpy/core/defchararray.py
   trunk/numpy/core/fromnumeric.py
   trunk/numpy/core/numeric.py
   trunk/numpy/core/numerictypes.py
   trunk/numpy/core/shape_base.py
   trunk/numpy/distutils/misc_util.py
Log:
updated docstrings from pydoc website (thanks to everyone who contributed!)


Modified: trunk/numpy/core/defchararray.py
===================================================================
--- trunk/numpy/core/defchararray.py	2010-02-17 16:49:17 UTC (rev 8125)
+++ trunk/numpy/core/defchararray.py	2010-02-17 23:42:42 UTC (rev 8126)
@@ -4,12 +4,12 @@
 
 .. note::
    The `chararray` class exists for backwards compatibility with
-   Numarray, it is not recommended for new development. If one needs
-   arrays of strings, use arrays of `dtype` `object_`, `string_` or
-   `unicode_`, and use the free functions in the `numpy.char` module
-   for fast vectorized string operations.
+   Numarray, it is not recommended for new development. Starting from numpy
+   1.4, if one needs arrays of strings, it is recommended to use arrays of
+   `dtype` `object_`, `string_` or `unicode_`, and use the free functions
+   in the `numpy.char` module for fast vectorized string operations.
 
-Some methods will only be available if the corresponding str method is
+Some methods will only be available if the corresponding string method is
 available in your version of Python.
 
 The preferred alias for `defchararray` is `numpy.char`.
@@ -1692,10 +1692,10 @@
 
     .. note::
        The `chararray` class exists for backwards compatibility with
-       Numarray, it is not recommended for new development. If one needs
-       arrays of strings, use arrays of `dtype` `object_`, `string_` or
-       `unicode_`, and use the free functions in the `numpy.char` module
-       for fast vectorized string operations.
+       Numarray, it is not recommended for new development. Starting from numpy
+       1.4, if one needs arrays of strings, it is recommended to use arrays of
+       `dtype` `object_`, `string_` or `unicode_`, and use the free functions
+       in the `numpy.char` module for fast vectorized string operations.
 
     Versus a regular Numpy array of type `str` or `unicode`, this
     class adds the following functionality:
@@ -1718,6 +1718,71 @@
     ``len(shape) >= 2`` and ``order='Fortran'``, in which case `strides`
     is in "Fortran order".
 
+    Methods
+    -------
+    astype
+    argsort
+    copy
+    count
+    decode
+    dump
+    dumps
+    encode
+    endswith
+    expandtabs
+    fill
+    find
+    flatten
+    getfield
+    index
+    isalnum
+    isalpha
+    isdecimal
+    isdigit
+    islower
+    isnumeric
+    isspace
+    istitle
+    isupper
+    item
+    join
+    ljust
+    lower
+    lstrip
+    nonzero
+    put
+    ravel
+    repeat
+    replace
+    reshape
+    resize
+    rfind
+    rindex
+    rjust
+    rsplit
+    rstrip
+    searchsorted
+    setfield
+    setflags
+    sort
+    split
+    splitlines
+    squeeze
+    startswith
+    strip
+    swapaxes
+    swapcase
+    take
+    title
+    tofile
+    tolist
+    tostring
+    translate
+    transpose
+    upper
+    view
+    zfill
+
     Parameters
     ----------
     shape : tuple

Modified: trunk/numpy/core/fromnumeric.py
===================================================================
--- trunk/numpy/core/fromnumeric.py	2010-02-17 16:49:17 UTC (rev 8125)
+++ trunk/numpy/core/fromnumeric.py	2010-02-17 23:42:42 UTC (rev 8126)
@@ -127,10 +127,28 @@
         This will be a new view object if possible; otherwise, it will
         be a copy.
 
+
     See Also
     --------
     ndarray.reshape : Equivalent method.
 
+    Notes
+    -----
+
+    It is not always possible to change the shape of an array without
+    copying the data. If you want an error to be raise if the data is copied,
+    you should assign the new shape to the shape attribute of the array::
+
+     >>> a = np.zeros((10, 2))
+     # A transpose make the array non-contiguous
+     >>> b = a.T
+     # Taking a view makes it possible to modify the shape without modiying the
+     # initial object.
+     >>> c = b.view()
+     >>> c.shape = (20)
+     AttributeError: incompatible shape for a non-contiguous array
+
+
     Examples
     --------
     >>> a = np.array([[1,2,3], [4,5,6]])
@@ -1708,7 +1726,7 @@
 
 def amax(a, axis=None, out=None):
     """
-    Return the maximum along an axis.
+    Return the maximum of an array or maximum along an axis.
 
     Parameters
     ----------
@@ -1724,8 +1742,7 @@
     Returns
     -------
     amax : ndarray
-        A new array or a scalar with the result, or a reference to `out`
-        if it was specified.
+        A new array or a scalar array with the result.
 
     See Also
     --------
@@ -1769,7 +1786,7 @@
 
 def amin(a, axis=None, out=None):
     """
-    Return the minimum along an axis.
+    Return the minimum of an array or minimum along an axis.
 
     Parameters
     ----------
@@ -1785,8 +1802,7 @@
     Returns
     -------
     amin : ndarray
-        A new array or a scalar with the result, or a reference to `out` if it
-        was specified.
+        A new array or a scalar array with the result.
 
     See Also
     --------

Modified: trunk/numpy/core/numeric.py
===================================================================
--- trunk/numpy/core/numeric.py	2010-02-17 16:49:17 UTC (rev 8125)
+++ trunk/numpy/core/numeric.py	2010-02-17 23:42:42 UTC (rev 8126)
@@ -262,6 +262,14 @@
     >>> np.asarray(a) is a
     True
 
+    If `dtype` is set, array is copied only if dtype does not match:
+
+    >>> a = np.array([1, 2], dtype=np.float32)
+    >>> np.asarray(a, dtype=np.float32) is a
+    True
+    >>> np.asarray(a, dtype=np.float64) is a
+    False
+
     Contrary to `asanyarray`, ndarray subclasses are not passed through:
 
     >>> issubclass(np.matrix, np.ndarray)
@@ -2090,25 +2098,6 @@
     Warning: overflow encountered in short_scalars
     30464
 
-    Calling `seterr` with no arguments resets treatment for all floating-point
-    errors to the defaults. XXX: lies!!! code doesn't do that
-    >>> np.geterr()
-    {'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}
-    >>> np.seterr(all='warn')
-    {'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}
-    >>> np.geterr()
-    {'over': 'warn', 'divide': 'warn', 'invalid': 'warn', 'under': 'warn'}
-    >>> np.seterr() # XXX: this should reset to defaults according to docstring above
-    {'over': 'warn', 'divide': 'warn', 'invalid': 'warn', 'under': 'warn'}
-    >>> np.geterr() # XXX: but clearly it doesn't
-    {'over': 'warn', 'divide': 'warn', 'invalid': 'warn', 'under': 'warn'}
-
-    >>> old_settings = np.seterr()
-    >>> old_settings = np.seterr(all='ignore')
-    >>> np.geterr()
-    {'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore',
-    'under': 'ignore'}
-
     """
 
     pyvals = umath.geterrobj()

Modified: trunk/numpy/core/numerictypes.py
===================================================================
--- trunk/numpy/core/numerictypes.py	2010-02-17 16:49:17 UTC (rev 8125)
+++ trunk/numpy/core/numerictypes.py	2010-02-17 23:42:42 UTC (rev 8126)
@@ -1,6 +1,7 @@
-"""numerictypes: Define the numeric type objects
+"""
+numerictypes: Define the numeric type objects
 
-This module is designed so 'from numerictypes import *' is safe.
+This module is designed so "from numerictypes import \\*" is safe.
 Exported symbols include:
 
   Dictionary with all registered number types (including aliases):
@@ -37,9 +38,11 @@
     float_, complex_,
     longfloat, clongfloat,
 
-    datetime_, timedelta_,  (these inherit from timeinteger which inherits from signedinteger)
-    
 
+    datetime_, timedelta_,  (these inherit from timeinteger which inherits
+    from signedinteger)
+
+
    As part of the type-hierarchy:    xx -- is bit-width
 
    generic
@@ -65,7 +68,7 @@
      |   |     single
      |   |     float_  (double)
      |   |     longfloat
-     |   \-> complexfloating    (complexxx)     (kind=c)
+     |   \\-> complexfloating    (complexxx)     (kind=c)
      |         csingle  (singlecomplex)
      |         complex_ (cfloat, cdouble)
      |         clongfloat (longcomplex)
@@ -75,7 +78,8 @@
      |     unicode_                             (kind=U)
      |     void                                 (kind=V)
      |
-     \-> object_ (not used much)                (kind=O)
+     \\-> object_ (not used much)                (kind=O)
+
 """
 
 # we add more at the bottom

Modified: trunk/numpy/core/shape_base.py
===================================================================
--- trunk/numpy/core/shape_base.py	2010-02-17 16:49:17 UTC (rev 8125)
+++ trunk/numpy/core/shape_base.py	2010-02-17 23:42:42 UTC (rev 8126)
@@ -218,7 +218,7 @@
     Stack arrays in sequence horizontally (column wise).
 
     Take a sequence of arrays and stack them horizontally to make
-    a single array. Rebuild arrays divided by ``hsplit``.
+    a single array. Rebuild arrays divided by `hsplit`.
 
     Parameters
     ----------

Modified: trunk/numpy/distutils/misc_util.py
===================================================================
--- trunk/numpy/distutils/misc_util.py	2010-02-17 16:49:17 UTC (rev 8125)
+++ trunk/numpy/distutils/misc_util.py	2010-02-17 23:42:42 UTC (rev 8126)
@@ -795,13 +795,15 @@
         sys.stderr.write('Warning: %s' % (message,))
 
     def set_options(self, **options):
-        """Configure Configuration instance.
+        """
+        Configure Configuration instance.
 
         The following options are available:
-        - ignore_setup_xxx_py
-        - assume_default_configuration
-        - delegate_options_to_subpackages
-        - quiet
+         - ignore_setup_xxx_py
+         - assume_default_configuration
+         - delegate_options_to_subpackages
+         - quiet
+
         """
         for key, value in options.items():
             if key in self.options:



More information about the Numpy-svn mailing list