Skip to content

Commit cdfbc62

Browse files
author
fengluo
committed
delete my modification in doc
1 parent 8487e5e commit cdfbc62

File tree

3 files changed

+95
-144
lines changed

3 files changed

+95
-144
lines changed

doc/source/reference/c-api/array.rst

Lines changed: 69 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -30,57 +30,6 @@ and its sub-types).
3030
3131
The number of dimensions in the array.
3232
33-
.. c:function:: void *PyArray_DATA(PyArrayObject *arr)
34-
35-
The pointer to the first element of the array.
36-
37-
.. c:function:: char *PyArray_BYTES(PyArrayObject *arr)
38-
39-
These two macros are similar and obtain the pointer to the
40-
data-buffer for the array. The first macro can (and should be)
41-
assigned to a particular pointer where the second is for generic
42-
processing. If you have not guaranteed a contiguous and/or aligned
43-
array then be sure you understand how to access the data in the
44-
array to avoid memory and/or alignment problems.
45-
46-
.. c:function:: npy_intp *PyArray_DIMS(PyArrayObject *arr)
47-
48-
Returns a pointer to the dimensions/shape of the array. The
49-
number of elements matches the number of dimensions
50-
of the array. Can return ``NULL`` for 0-dimensional arrays.
51-
52-
.. c:function:: npy_intp *PyArray_STRIDES(PyArrayObject* arr)
53-
54-
Returns a pointer to the strides of the array. The
55-
number of elements matches the number of dimensions
56-
of the array.
57-
58-
.. c:function:: npy_intp PyArray_DIM(PyArrayObject* arr, int n)
59-
60-
Return the shape in the *n* :math:`^{\textrm{th}}` dimension.
61-
62-
.. c:function:: npy_intp PyArray_STRIDE(PyArrayObject* arr, int n)
63-
64-
Return the stride in the *n* :math:`^{\textrm{th}}` dimension.
65-
66-
.. c:function:: PyObject *PyArray_BASE(PyArrayObject* arr)
67-
68-
This returns the base object of the array. In most cases, this
69-
means the object which owns the memory the array is pointing at.
70-
71-
If you are constructing an array using the C API, and specifying
72-
your own memory, you should use the function :c:func:`PyArray_SetBaseObject`
73-
to set the base to an object which owns the memory.
74-
75-
If the :c:data:`NPY_ARRAY_WRITEBACKIFCOPY` flag is set, it has a different
76-
meaning, namely base is the array into which the current array will
77-
be copied upon copy resolution. This overloading of the base property
78-
for two functions is likely to change in a future version of NumPy.
79-
80-
.. c:function:: PyArray_Descr *PyArray_DESCR(PyArrayObject* arr)
81-
82-
Returns a borrowed reference to the dtype property of the array.
83-
8433
.. c:function:: int PyArray_FLAGS(PyArrayObject* arr)
8534
8635
Returns an integer representing the :ref:`array-flags<array-flags>`.
@@ -89,32 +38,6 @@ and its sub-types).
8938
9039
Return the (builtin) typenumber for the elements of this array.
9140
92-
.. c:function:: PyArray_Descr *PyArray_DTYPE(PyArrayObject* arr)
93-
94-
A synonym for PyArray_DESCR, named to be consistent with the
95-
'dtype' usage within Python.
96-
97-
.. c:function:: npy_intp *PyArray_SHAPE(PyArrayObject *arr)
98-
99-
A synonym for :c:func:`PyArray_DIMS`, named to be consistent with the
100-
`shape <numpy.ndarray.shape>` usage within Python.
101-
102-
.. c:function:: void PyArray_ENABLEFLAGS(PyArrayObject* arr, int flags)
103-
104-
Enables the specified array flags. This function does no validation,
105-
and assumes that you know what you're doing.
106-
107-
.. c:function:: void PyArray_CLEARFLAGS(PyArrayObject* arr, int flags)
108-
109-
Clears the specified array flags. This function does no validation,
110-
and assumes that you know what you're doing.
111-
112-
.. c:function:: int PyArray_HANDLER(PyArrayObject *arr)
113-
114-
.. versionadded:: 1.22
115-
116-
Returns the memory handler associated with the given array.
117-
11841
.. c:function:: int PyArray_Pack( \
11942
const PyArray_Descr *descr, void *item, const PyObject *value)
12043
@@ -141,6 +64,52 @@ and its sub-types).
14164
handling arbitrary Python objects. Setitem is for example not able
14265
to handle arbitrary casts between different dtypes.
14366
67+
.. c:function:: void PyArray_ENABLEFLAGS(PyArrayObject* arr, int flags)
68+
69+
Enables the specified array flags. This function does no validation,
70+
and assumes that you know what you're doing.
71+
72+
.. c:function:: void PyArray_CLEARFLAGS(PyArrayObject* arr, int flags)
73+
74+
Clears the specified array flags. This function does no validation,
75+
and assumes that you know what you're doing.
76+
77+
.. c:function:: void *PyArray_DATA(PyArrayObject *arr)
78+
79+
.. c:function:: char *PyArray_BYTES(PyArrayObject *arr)
80+
81+
These two macros are similar and obtain the pointer to the
82+
data-buffer for the array. The first macro can (and should be)
83+
assigned to a particular pointer where the second is for generic
84+
processing. If you have not guaranteed a contiguous and/or aligned
85+
array then be sure you understand how to access the data in the
86+
array to avoid memory and/or alignment problems.
87+
88+
.. c:function:: npy_intp *PyArray_DIMS(PyArrayObject *arr)
89+
90+
Returns a pointer to the dimensions/shape of the array. The
91+
number of elements matches the number of dimensions
92+
of the array. Can return ``NULL`` for 0-dimensional arrays.
93+
94+
.. c:function:: npy_intp *PyArray_SHAPE(PyArrayObject *arr)
95+
96+
A synonym for :c:func:`PyArray_DIMS`, named to be consistent with the
97+
`shape <numpy.ndarray.shape>` usage within Python.
98+
99+
.. c:function:: npy_intp *PyArray_STRIDES(PyArrayObject* arr)
100+
101+
Returns a pointer to the strides of the array. The
102+
number of elements matches the number of dimensions
103+
of the array.
104+
105+
.. c:function:: npy_intp PyArray_DIM(PyArrayObject* arr, int n)
106+
107+
Return the shape in the *n* :math:`^{\textrm{th}}` dimension.
108+
109+
.. c:function:: npy_intp PyArray_STRIDE(PyArrayObject* arr, int n)
110+
111+
Return the stride in the *n* :math:`^{\textrm{th}}` dimension.
112+
144113
.. c:function:: npy_intp PyArray_ITEMSIZE(PyArrayObject* arr)
145114
146115
Return the itemsize for the elements of this array.
@@ -162,6 +131,29 @@ and its sub-types).
162131
163132
Returns the total number of bytes consumed by the array.
164133
134+
.. c:function:: PyObject *PyArray_BASE(PyArrayObject* arr)
135+
136+
This returns the base object of the array. In most cases, this
137+
means the object which owns the memory the array is pointing at.
138+
139+
If you are constructing an array using the C API, and specifying
140+
your own memory, you should use the function :c:func:`PyArray_SetBaseObject`
141+
to set the base to an object which owns the memory.
142+
143+
If the :c:data:`NPY_ARRAY_WRITEBACKIFCOPY` flag is set, it has a different
144+
meaning, namely base is the array into which the current array will
145+
be copied upon copy resolution. This overloading of the base property
146+
for two functions is likely to change in a future version of NumPy.
147+
148+
.. c:function:: PyArray_Descr *PyArray_DESCR(PyArrayObject* arr)
149+
150+
Returns a borrowed reference to the dtype property of the array.
151+
152+
.. c:function:: PyArray_Descr *PyArray_DTYPE(PyArrayObject* arr)
153+
154+
A synonym for PyArray_DESCR, named to be consistent with the
155+
'dtype' usage within Python.
156+
165157
.. c:function:: PyObject *PyArray_GETITEM(PyArrayObject* arr, void* itemptr)
166158
167159
Get a Python object of a builtin type from the ndarray, *arr*,

doc/source/reference/c-api/dtype.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,6 @@ to the front of the integer name.
421421
422422
The C ``size_t``/``Py_size_t``.
423423

424-
.. c:type:: npy_hash_t
425-
426-
The C ``Py_hash_t`` (a signed integer type used for hashing).
427-
This type is utilized in NumPy to represent hash values for objects.
428-
429424

430425
(Complex) Floating point
431426
~~~~~~~~~~~~~~~~~~~~~~~~

doc/source/reference/c-api/types-and-structures.rst

Lines changed: 26 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,19 @@ PyArray_Type and PyArrayObject
7171
member of this structure contains a pointer to the :c:data:`PyArray_Type`
7272
typeobject.
7373

74-
.. c:type:: PyArrayObject_fields
75-
76-
The :c:type:`PyArrayObject_fields` C-structure contains all of the
77-
required information for an array. All instances of an ndarray (and
78-
its subclasses) will have this structure. For future compatibility,
79-
these structure members should normally be accessed using the provided
80-
functions and macros. Direct access to the members of :c:type:`PyArrayObject_fields`
81-
should be avoided. Instead, users should interact with :c:type:`PyArrayObject`,
82-
which provides a stable interface for accessing array data and metadata.
83-
This struct may be moved to a private header in a future release,
84-
further emphasizing the importance of using the defined macros for access.
74+
.. c:type:: PyArrayObject
75+
NPY_AO
76+
77+
The :c:type:`PyArrayObject` C-structure contains all of the required
78+
information for an array. All instances of an ndarray (and its
79+
subclasses) will have this structure. For future compatibility,
80+
these structure members should normally be accessed using the
81+
provided macros. If you need a shorter name, then you can make use
82+
of :c:type:`NPY_AO` (deprecated) which is defined to be equivalent to
83+
:c:type:`PyArrayObject`. Direct access to the struct fields are
84+
deprecated. Use the ``PyArray_*(arr)`` form instead.
85+
As of NumPy 1.20, the size of this struct is not considered part of
86+
the NumPy ABI (see note at the end of the member list).
8587

8688
.. code-block:: c
8789
@@ -95,17 +97,17 @@ PyArray_Type and PyArrayObject
9597
PyArray_Descr *descr;
9698
int flags;
9799
PyObject *weakreflist;
98-
void *_buffer_info;
99-
PyObject *mem_handler;
100+
/* version dependent private members */
100101
} PyArrayObject;
101102
102103
:c:macro:`PyObject_HEAD`
103104
This is needed by all Python objects. It consists of (at least)
104105
a reference count member ( ``ob_refcnt`` ) and a pointer to the
105106
typeobject ( ``ob_type`` ). (Other elements may also be present
106-
if Python was compiled with special options see Include/object.h
107-
in the Python source tree for more information). The ``ob_type``
108-
member points to a Python type object.
107+
if Python was compiled with special options see
108+
Include/object.h in the Python source tree for more
109+
information). The ob_type member points to a Python type
110+
object.
109111

110112
.. c:member:: char *data
111113
@@ -120,7 +122,7 @@ PyArray_Type and PyArrayObject
120122
array. Such arrays have undefined dimensions and strides and
121123
cannot be accessed. Macro :c:data:`PyArray_NDIM` defined in
122124
``ndarraytypes.h`` points to this data member.
123-
:c:macro:`NPY_MAXDIMS` is defined as a compile time constant limiting the
125+
``NPY_MAXDIMS`` is defined as a compile time constant limiting the
124126
number of dimensions. This number is 64 since NumPy 2 and was 32
125127
before. However, we may wish to remove this limitations in the future
126128
so that it is best to explicitly check dimensionality for code
@@ -179,43 +181,6 @@ PyArray_Type and PyArrayObject
179181
This member allows array objects to have weak references (using the
180182
weakref module).
181183

182-
.. c:member:: void *_buffer_info
183-
184-
.. versionadded:: 1.20
185-
186-
Private buffer information, tagged for warning purposes. Direct
187-
access is discouraged to ensure API stability.
188-
189-
.. c:member:: PyObject *mem_handler
190-
191-
.. versionadded:: 1.22
192-
193-
A pointer to a ``PyObject`` that serves as a :c:data:`PyDataMem_Handler`.
194-
This allows custom memory management policies for each array object,
195-
enabling the use of user-defined memory allocation and deallocation routines
196-
instead of the standard `malloc`, `calloc`, `realloc`, and `free` functions.
197-
198-
Accessed through the macro :c:data:`PyArray_HANDLER`.
199-
200-
.. note::
201-
202-
For setting or retrieving the current memory management policy,
203-
see the `PyDataMem_SetHandler` and `PyDataMem_GetHandler` functions.
204-
205-
.. c:type:: PyArrayObject
206-
207-
.. deprecated:: 1.7
208-
Use ``NPY_AO`` for a shorter name.
209-
210-
Represents a NumPy array object in the C API.
211-
212-
To hide the implementation details, only the Python struct HEAD is exposed.
213-
Direct access to the struct fields is deprecated;
214-
instead, use the ``PyArray_*(*arr)`` functions (such as :c:func:`PyArray_NDIM`).
215-
216-
As of NumPy 1.20, the size of this struct is not considered part of the NumPy ABI
217-
(see the note below).
218-
219184
.. note::
220185

221186
Further members are considered private and version dependent. If the size
@@ -322,7 +287,7 @@ PyArrayDescr_Type and PyArray_Descr
322287
npy_uint64 flags;
323288
npy_intp elsize;
324289
npy_intp alignment;
325-
PyObject *metadata;
290+
NpyAuxData *c_metadata;
326291
npy_hash_t hash;
327292
void *reserved_null[2]; // unused field, must be NULLed.
328293
} PyArray_Descr;
@@ -412,6 +377,7 @@ PyArrayDescr_Type and PyArray_Descr
412377
Metadata specific to the C implementation
413378
of the particular dtype. Added for NumPy 1.7.0.
414379

380+
.. c:type:: npy_hash_t
415381
.. c:member:: npy_hash_t *hash
416382
417383
Used for caching hash values.
@@ -515,7 +481,7 @@ PyArray_ArrFuncs
515481
.. code-block:: c
516482
517483
typedef struct {
518-
PyArray_VectorUnaryFunc *cast[NPY_NTYPES_ABI_COMPATIBLE];
484+
PyArray_VectorUnaryFunc *cast[NPY_NTYPES_LEGACY];
519485
PyArray_GetItemFunc *getitem;
520486
PyArray_SetItemFunc *setitem;
521487
PyArray_CopySwapNFunc *copyswapn;
@@ -562,10 +528,8 @@ PyArray_ArrFuncs
562528
void *from, void *to, npy_intp n, void *fromarr, void *toarr)
563529
564530
An array of function pointers to cast from the current type to
565-
most of the other builtin types. The types
566-
:c:type:`NPY_DATETIME`, :c:type:`NPY_TIMEDELTA`, and :c:type:`NPY_HALF`
567-
go into the castdict even though they are built-in. Each function
568-
casts a contiguous, aligned, and notswapped buffer pointed at by
531+
all of the other builtin types. Each function casts a
532+
contiguous, aligned, and notswapped buffer pointed at by
569533
*from* to a contiguous, aligned, and notswapped buffer pointed
570534
at by *to* The number of items to cast is given by *n*, and
571535
the arguments *fromarr* and *toarr* are interpreted as
@@ -1009,11 +973,11 @@ PyUFunc_Type and PyUFuncObject
1009973
int nargs;
1010974
int identity;
1011975
PyUFuncGenericFunction *functions;
1012-
void *const *data;
976+
void **data;
1013977
int ntypes;
1014978
int reserved1;
1015979
const char *name;
1016-
const char *types;
980+
char *types;
1017981
const char *doc;
1018982
void *ptr;
1019983
PyObject *obj;

0 commit comments

Comments
 (0)