diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-05-31 15:36:59 -0500 |
---|---|---|
committer | Mark Wiebe <mwiebe@enthought.com> | 2011-05-31 15:36:59 -0500 |
commit | a17a4996e4ed63d1b855a0917fb5fcdd5855a7d0 (patch) | |
tree | adf9fcdc2293e33a9d1369e05a593706f82003db /numpy/add_newdocs.py | |
parent | 6441c2a788d0cc2a45c5e8a3ef0891ca4e42d96e (diff) | |
download | numpy-a17a4996e4ed63d1b855a0917fb5fcdd5855a7d0.tar.gz |
ENH: core: Generalize ndarray.astype to take new standard keyword arguments
These include order=, casting=, subok=. Also added a forcecopy=
parameter to allow skipping of the copy when possible.
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r-- | numpy/add_newdocs.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 37f326867..e596607fa 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3001,14 +3001,38 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('argsort', add_newdoc('numpy.core.multiarray', 'ndarray', ('astype', """ - a.astype(t) + a.astype(dtype, order='K', casting='unsafe', subok=True, forcecopy=True) Copy of the array, cast to a specified type. Parameters ---------- - t : str or dtype + dtype : str or dtype Typecode or data-type to which the array is cast. + order : {'C', 'F', 'A', or 'K'}, optional + Controls the memory layout order of the result. + 'C' means C order, 'F' means Fortran order, 'A' + means 'F' order if all the arrays are Fortran contiguous, + 'C' order otherwise, and 'K' means as close to the + order the array elements appear in memory as possible. + Default is 'K'. + casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional + Controls what kind of data casting may occur. Defaults to 'unsafe' + for backwards compatibility. + + * 'no' means the data types should not be cast at all. + * 'equiv' means only byte-order changes are allowed. + * 'safe' means only casts which can preserve values are allowed. + * 'same_kind' means only safe casts or casts within a kind, + like float64 to float32, are allowed. + * 'unsafe' means any data conversions may be done. + subok : bool, optional + If True, then sub-classes will be passed-through (default), otherwise + the returned array will be forced to be a base-class array. + forcecopy : bool, optional + By default, astype always returns a new array. If this is set to + false, and the `dtype`, `order`, and `subok` requirements are + satisfied, the input array is returned instead of a copy. Raises ------ |