Skip to content

Commit dea4055

Browse files
committed
MAINT: Rename allow_copy to never_copy in never-copy machinery
The first name was `do_copy`, which was confusing because it sounds like a copy is forced (opposite is the case!) `allow_copy` would have been better, but corrects it into the wrong direction. `never_copy` is correct, and aligns with the Python side names
1 parent f31c4a6 commit dea4055

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

numpy/core/src/multiarray/array_coercion.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ PyArray_AdaptDescriptorToArray(PyArrayObject *arr, PyObject *dtype)
858858
* (Initially it is a pointer to the user-provided head pointer).
859859
* @param fixed_DType User provided fixed DType class
860860
* @param flags Discovery flags (reporting and behaviour flags, see def.)
861-
* @param allow_copy Specifies if a copy is allowed during array creation.
861+
* @param never_copy Specifies if a copy is allowed during array creation.
862862
* @return The updated number of maximum dimensions (i.e. scalars will set
863863
* this to the current dimensions).
864864
*/
@@ -868,7 +868,7 @@ PyArray_DiscoverDTypeAndShape_Recursive(
868868
npy_intp out_shape[NPY_MAXDIMS],
869869
coercion_cache_obj ***coercion_cache_tail_ptr,
870870
PyArray_DTypeMeta *fixed_DType, enum _dtype_discovery_flags *flags,
871-
int allow_copy)
871+
int never_copy)
872872
{
873873
PyArrayObject *arr = NULL;
874874
PyObject *seq;
@@ -926,7 +926,7 @@ PyArray_DiscoverDTypeAndShape_Recursive(
926926
requested_descr = *out_descr;
927927
}
928928
arr = (PyArrayObject *)_array_from_array_like(obj,
929-
requested_descr, 0, NULL, allow_copy);
929+
requested_descr, 0, NULL, never_copy);
930930
if (arr == NULL) {
931931
return -1;
932932
}
@@ -1120,7 +1120,7 @@ PyArray_DiscoverDTypeAndShape_Recursive(
11201120
max_dims = PyArray_DiscoverDTypeAndShape_Recursive(
11211121
objects[i], curr_dims + 1, max_dims,
11221122
out_descr, out_shape, coercion_cache_tail_ptr, fixed_DType,
1123-
flags, allow_copy);
1123+
flags, never_copy);
11241124

11251125
if (max_dims < 0) {
11261126
return -1;
@@ -1160,7 +1160,7 @@ PyArray_DiscoverDTypeAndShape_Recursive(
11601160
* The result may be unchanged (remain NULL) when converting a
11611161
* sequence with no elements. In this case it is callers responsibility
11621162
* to choose a default.
1163-
* @param allow_copy Specifies if a copy is allowed during array creation.
1163+
* @param never_copy Specifies that a copy is not allowed.
11641164
* @return dimensions of the discovered object or -1 on error.
11651165
* WARNING: If (and only if) the output is a single array, the ndim
11661166
* returned _can_ exceed the maximum allowed number of dimensions.
@@ -1173,7 +1173,7 @@ PyArray_DiscoverDTypeAndShape(
11731173
npy_intp out_shape[NPY_MAXDIMS],
11741174
coercion_cache_obj **coercion_cache,
11751175
PyArray_DTypeMeta *fixed_DType, PyArray_Descr *requested_descr,
1176-
PyArray_Descr **out_descr, int allow_copy)
1176+
PyArray_Descr **out_descr, int never_copy)
11771177
{
11781178
coercion_cache_obj **coercion_cache_head = coercion_cache;
11791179
*coercion_cache = NULL;
@@ -1218,7 +1218,7 @@ PyArray_DiscoverDTypeAndShape(
12181218

12191219
int ndim = PyArray_DiscoverDTypeAndShape_Recursive(
12201220
obj, 0, max_dims, out_descr, out_shape, &coercion_cache,
1221-
fixed_DType, &flags, allow_copy);
1221+
fixed_DType, &flags, never_copy);
12221222
if (ndim < 0) {
12231223
goto fail;
12241224
}

numpy/core/src/multiarray/array_coercion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ PyArray_DiscoverDTypeAndShape(
3131
npy_intp out_shape[NPY_MAXDIMS],
3232
coercion_cache_obj **coercion_cache,
3333
PyArray_DTypeMeta *fixed_DType, PyArray_Descr *requested_descr,
34-
PyArray_Descr **out_descr, int allow_copy);
34+
PyArray_Descr **out_descr, int never_copy);
3535

3636
NPY_NO_EXPORT int
3737
PyArray_ExtractDTypeAndDescriptor(PyObject *dtype,

numpy/core/src/multiarray/ctors.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ _array_from_buffer_3118(PyObject *memoryview)
12841284
* DType may be used, but is not enforced.
12851285
* @param writeable whether the result must be writeable.
12861286
* @param context Unused parameter, must be NULL (should be removed later).
1287-
* @param allow_copy Specifies if a copy is allowed during array creation.
1287+
* @param never_copy Specifies that a copy is not allowed.
12881288
*
12891289
* @returns The array object, Py_NotImplemented if op is not array-like,
12901290
* or NULL with an error set. (A new reference to Py_NotImplemented
@@ -1293,7 +1293,7 @@ _array_from_buffer_3118(PyObject *memoryview)
12931293
NPY_NO_EXPORT PyObject *
12941294
_array_from_array_like(PyObject *op,
12951295
PyArray_Descr *requested_dtype, npy_bool writeable, PyObject *context,
1296-
int allow_copy) {
1296+
int never_copy) {
12971297
PyObject* tmp;
12981298

12991299
/*
@@ -1349,7 +1349,7 @@ _array_from_array_like(PyObject *op,
13491349
* this should be changed!
13501350
*/
13511351
if (!writeable && tmp == Py_NotImplemented) {
1352-
tmp = PyArray_FromArrayAttr_int(op, requested_dtype, allow_copy);
1352+
tmp = PyArray_FromArrayAttr_int(op, requested_dtype, never_copy);
13531353
if (tmp == NULL) {
13541354
return NULL;
13551355
}
@@ -2467,7 +2467,7 @@ PyArray_FromInterface(PyObject *origin)
24672467
* @param op The Python object to convert to an array.
24682468
* @param descr The desired `arr.dtype`, passed into the `__array__` call,
24692469
* as information but is not checked/enforced!
2470-
* @param never_copy Indicator that a copy is not allowed.
2470+
* @param never_copy Specifies that a copy is not allowed.
24712471
* NOTE: Currently, this means an error is raised instead of calling
24722472
* `op.__array__()`. In the future we could call for example call
24732473
* `op.__array__(never_copy=True)` instead.

numpy/core/src/multiarray/ctors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PyArray_New(
3333
NPY_NO_EXPORT PyObject *
3434
_array_from_array_like(PyObject *op,
3535
PyArray_Descr *requested_dtype, npy_bool writeable, PyObject *context,
36-
int allow_copy);
36+
int never_copy);
3737

3838
NPY_NO_EXPORT PyObject *
3939
PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int min_depth,

0 commit comments

Comments
 (0)