diff options
-rw-r--r-- | numpy/add_newdocs.py | 11 | ||||
-rw-r--r-- | numpy/core/src/multiarray/methods.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_api.py | 16 |
3 files changed, 15 insertions, 14 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index e596607fa..20ce6c378 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3001,7 +3001,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('argsort', add_newdoc('numpy.core.multiarray', 'ndarray', ('astype', """ - a.astype(dtype, order='K', casting='unsafe', subok=True, forcecopy=True) + a.astype(dtype, order='K', casting='unsafe', subok=True, copy=True) Copy of the array, cast to a specified type. @@ -3029,10 +3029,11 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('astype', 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. + copy : bool, optional + By default, astype always returns a newly allocated 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 ------ diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c index 748360bf1..2c4110afd 100644 --- a/numpy/core/src/multiarray/methods.c +++ b/numpy/core/src/multiarray/methods.c @@ -791,7 +791,7 @@ static PyObject * array_astype(PyArrayObject *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"dtype", "order", "casting", - "subok", "forcecopy", NULL}; + "subok", "copy", NULL}; PyArray_Descr *dtype = NULL; /* * TODO: UNSAFE default for compatibility, I think diff --git a/numpy/core/tests/test_api.py b/numpy/core/tests/test_api.py index 388e011bd..2c9b7d4d0 100644 --- a/numpy/core/tests/test_api.py +++ b/numpy/core/tests/test_api.py @@ -40,18 +40,18 @@ def test_array_astype(): assert_equal(a, b) assert_(not (a is b)) - # forcecopy=False parameter can sometimes skip a copy - b = a.astype('f4', forcecopy=False) + # copy=False parameter can sometimes skip a copy + b = a.astype('f4', copy=False) assert_(a is b) # order parameter allows overriding of the memory layout, # forcing a copy if the layout is wrong - b = a.astype('f4', order='F', forcecopy=False) + b = a.astype('f4', order='F', copy=False) assert_equal(a, b) assert_(not (a is b)) assert_(b.flags.f_contiguous) - b = a.astype('f4', order='C', forcecopy=False) + b = a.astype('f4', order='C', copy=False) assert_equal(a, b) assert_(a is b) assert_(b.flags.c_contiguous) @@ -64,22 +64,22 @@ def test_array_astype(): assert_raises(TypeError, a.astype, 'i4', casting='safe') # subok=False passes through a non-subclassed array - b = a.astype('f4', subok=0, forcecopy=False) + b = a.astype('f4', subok=0, copy=False) assert_(a is b) a = np.matrix([[0,1,2],[3,4,5]], dtype='f4') # subok=True passes through a matrix - b = a.astype('f4', subok=True, forcecopy=False) + b = a.astype('f4', subok=True, copy=False) assert_(a is b) # subok=True is default, and creates a subtype on a cast - b = a.astype('i4', forcecopy=False) + b = a.astype('i4', copy=False) assert_equal(a, b) assert_equal(type(b), np.matrix) # subok=False never returns a matrix - b = a.astype('f4', subok=False, forcecopy=False) + b = a.astype('f4', subok=False, copy=False) assert_equal(a, b) assert_(not (a is b)) assert_(type(b) != np.matrix) |