Skip to content

Commit 18507bb

Browse files
eagunnseberg
andauthored
DOC: Correct selected C docstrings to eliminate warnings (numpy#27497)
Addresses numpy#27377, eliminating all C docstring warning messages. This is a minimal set of changes, simply eliminating the observed warning messages, with no attempt to improve C docstring content overall, per advice of @mattip. Reviewers, Some changes were straightforward: -- The name of the @param variable to be documented was missing. I inserted it. -- The name of the @param variable was misspelled. I corrected it. -- An @param line documented a variable that no longer existed or had been split into two. I made the obvious fix. -- In one case, I removed a docstring from an .h file that simply duplicated the docstring in the corresponding .c file. The changes to pay more attention to are those where I had to supply missing Description text. For those, I simply took my best shot and used as few words as I could, figuring the less I wrote, the fewer things would be said incorrectly. To verify the error messages were being eliminated, I used the same commands as were documented in the original issue but piped the sorted, unique warnings to a file which I diffed against the original list as I worked. $ CC=clang CXX=clang++ CFLAGS=-Wdocumentation pip install --log PIP.log . $ grep -- -Wdocumentation PIP.log | sed -E -e 's/^\S+\s+//' | sort -n | uniq > warnings.list Some fixup/suggestions contributed by Sebastian Co-authored-by: Sebastian Berg <[email protected]>
1 parent 6f5dd58 commit 18507bb

19 files changed

+83
-88
lines changed

numpy/_core/include/numpy/dtype_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ typedef int (PyArrayMethod_TranslateGivenDescriptors)(int nin, int nout,
268268
*
269269
* The function must clean up on error.
270270
*
271-
* @param nargs Number of arguments
271+
* @param nin Number of input arguments
272+
* @param nout Number of output arguments
272273
* @param new_dtypes The DTypes of the output (usually probably not needed)
273274
* @param given_descrs Original given_descrs to the resolver, necessary to
274275
* fetch any information related to the new dtypes from the original.

numpy/_core/src/common/npy_argparse.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,11 @@ raise_missing_argument(const char *funcname,
280280
*
281281
* See macro version for an example pattern of how to use this function.
282282
*
283-
* @param funcname
284-
* @param cache
283+
* @param funcname Function name
284+
* @param cache a NULL initialized persistent storage for data
285285
* @param args Python passed args (METH_FASTCALL)
286-
* @param len_args
287-
* @param kwnames
286+
* @param len_args Number of arguments (not flagged)
287+
* @param kwnames Tuple as passed by METH_FASTCALL or NULL.
288288
* @param ... List of arguments (see macro version).
289289
*
290290
* @return Returns 0 on success and -1 on failure.

numpy/_core/src/common/npy_argparse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ NPY_NO_EXPORT int init_argparse_mutex(void);
6969
* used in cunjunction with the macro defined in the same scope.
7070
* (No two `npy_parse_arguments` may share a single `NPY_PREPARE_ARGPARSER`.)
7171
*
72-
* @param funcname
72+
* @param funcname Function name
7373
* @param args Python passed args (METH_FASTCALL)
7474
* @param len_args Number of arguments (not flagged)
7575
* @param kwnames Tuple as passed by METH_FASTCALL or NULL.

numpy/_core/src/common/npy_import.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ npy_import(const char *module, const char *attr)
8181
*
8282
* @param module Absolute module name.
8383
* @param attr module attribute to cache.
84-
* @param cache Storage location for imported function.
84+
* @param obj Storage location for imported function.
8585
*/
8686
static inline int
8787
npy_cache_import_runtime(const char *module, const char *attr, PyObject **obj) {

numpy/_core/src/multiarray/array_coercion.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,8 @@ npy_new_coercion_cache(
660660
/**
661661
* Unlink coercion cache item.
662662
*
663-
* @param current
664-
* @return next coercion cache object (or NULL)
663+
* @param current This coercion cache object
664+
* @return next Next coercion cache object (or NULL)
665665
*/
666666
NPY_NO_EXPORT coercion_cache_obj *
667667
npy_unlink_coercion_cache(coercion_cache_obj *current)
@@ -905,7 +905,7 @@ find_descriptor_from_array(
905905
* it supports inspecting the elements when the array has object dtype
906906
* (and the given datatype describes a parametric DType class).
907907
*
908-
* @param arr
908+
* @param arr The array object.
909909
* @param dtype NULL or a dtype class
910910
* @param descr A dtype instance, if the dtype is NULL the dtype class is
911911
* found and e.g. "S0" is converted to denote only String.

numpy/_core/src/multiarray/array_method.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,16 @@ is_contiguous(
123123
* true, i.e., for cast safety "no-cast". It will not recognize view as an
124124
* option for other casts (e.g., viewing '>i8' as '>i4' with an offset of 4).
125125
*
126-
* @param context
127-
* @param aligned
128-
* @param move_references UNUSED.
129-
* @param strides
130-
* @param descriptors
131-
* @param out_loop
132-
* @param out_transferdata
133-
* @param flags
134-
* @return 0 on success -1 on failure.
126+
* @param context The arraymethod context
127+
* @param aligned Flag indicating data is aligned (1) or not (0)
128+
* param move_references UNUSED -- listed below but doxygen doesn't see as a parameter
129+
* @param strides Array of step sizes for each dimension of the arrays involved
130+
* @param out_loop Output pointer to the function that will perform the strided loop.
131+
* @param out_transferdata Output pointer to auxiliary data (if any)
132+
* needed by the out_loop function.
133+
* @param flags Output pointer to additional flags (if any)
134+
* needed by the out_loop function
135+
* @returns 0 on success -1 on failure.
135136
*/
136137
NPY_NO_EXPORT int
137138
npy_default_get_strided_loop(
@@ -169,7 +170,7 @@ npy_default_get_strided_loop(
169170
/**
170171
* Validate that the input is usable to create a new ArrayMethod.
171172
*
172-
* @param spec
173+
* @param spec Array method specification to be validated
173174
* @return 0 on success -1 on error.
174175
*/
175176
static int

numpy/_core/src/multiarray/common.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ _IsWriteable(PyArrayObject *ap)
188188
/**
189189
* Convert an array shape to a string such as "(1, 2)".
190190
*
191-
* @param Dimensionality of the shape
192-
* @param npy_intp pointer to shape array
193-
* @param String to append after the shape `(1, 2)%s`.
191+
* @param n Dimensionality of the shape
192+
* @param vals npy_intp pointer to shape array
193+
* @param ending String to append after the shape `(1, 2)%s`.
194194
*
195195
* @return Python unicode string
196196
*/
@@ -299,12 +299,11 @@ dot_alignment_error(PyArrayObject *a, int i, PyArrayObject *b, int j)
299299
/**
300300
* unpack tuple of PyDataType_FIELDS(dtype) (descr, offset, title[not-needed])
301301
*
302-
* @param "value" should be the tuple.
302+
* @param value should be the tuple.
303+
* @param descr will be set to the field's dtype
304+
* @param offset will be set to the field's offset
303305
*
304-
* @return "descr" will be set to the field's dtype
305-
* @return "offset" will be set to the field's offset
306-
*
307-
* returns -1 on failure, 0 on success.
306+
* @return -1 on failure, 0 on success.
308307
*/
309308
NPY_NO_EXPORT int
310309
_unpack_field(PyObject *value, PyArray_Descr **descr, npy_intp *offset)

numpy/_core/src/multiarray/common.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ dot_alignment_error(PyArrayObject *a, int i, PyArrayObject *b, int j);
7171

7272
/**
7373
* unpack tuple of PyDataType_FIELDS(dtype) (descr, offset, title[not-needed])
74-
*
75-
* @param "value" should be the tuple.
76-
*
77-
* @return "descr" will be set to the field's dtype
78-
* @return "offset" will be set to the field's offset
79-
*
80-
* returns -1 on failure, 0 on success.
8174
*/
8275
NPY_NO_EXPORT int
8376
_unpack_field(PyObject *value, PyArray_Descr **descr, npy_intp *offset);

numpy/_core/src/multiarray/common_dtype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ PyArray_CommonDType(PyArray_DTypeMeta *dtype1, PyArray_DTypeMeta *dtype2)
106106
* default_builtin_common_dtype
107107
*
108108
* @param length Number of DTypes
109-
* @param dtypes
109+
* @param dtypes List of DTypes to be reduced
110110
*/
111111
static PyArray_DTypeMeta *
112112
reduce_dtypes_to_most_knowledgeable(

numpy/_core/src/multiarray/conversion_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ PyArray_IntpFromPyIntConverter(PyObject *o, npy_intp *val)
11231123
* @param seq A sequence created using `PySequence_Fast`.
11241124
* @param vals Array used to store dimensions (must be large enough to
11251125
* hold `maxvals` values).
1126-
* @param max_vals Maximum number of dimensions that can be written into `vals`.
1126+
* @param maxvals Maximum number of dimensions that can be written into `vals`.
11271127
* @return Number of dimensions or -1 if an error occurred.
11281128
*
11291129
* .. note::

0 commit comments

Comments
 (0)