Skip to content

Commit b22d092

Browse files
committed
MAINT: Fixup compiler warnings/errors based on const changes
1 parent c42e350 commit b22d092

17 files changed

+141
-131
lines changed

numpy/_core/src/multiarray/convert_datatype.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,8 +2440,8 @@ PyArray_AddCastingImplementation_FromSpec(PyArrayMethod_Spec *spec, int private)
24402440
NPY_NO_EXPORT NPY_CASTING
24412441
legacy_same_dtype_resolve_descriptors(
24422442
PyArrayMethodObject *NPY_UNUSED(self),
2443-
PyArray_DTypeMeta *NPY_UNUSED(dtypes[2]),
2444-
PyArray_Descr *given_descrs[2],
2443+
PyArray_DTypeMeta *const NPY_UNUSED(dtypes[2]),
2444+
PyArray_Descr *const given_descrs[2],
24452445
PyArray_Descr *loop_descrs[2],
24462446
npy_intp *view_offset)
24472447
{
@@ -2483,7 +2483,7 @@ legacy_cast_get_strided_loop(
24832483
PyArrayMethod_StridedLoop **out_loop, NpyAuxData **out_transferdata,
24842484
NPY_ARRAYMETHOD_FLAGS *flags)
24852485
{
2486-
PyArray_Descr **descrs = context->descriptors;
2486+
PyArray_Descr *const *descrs = context->descriptors;
24872487
int out_needs_api = 0;
24882488

24892489
*flags = context->method->flags & NPY_METH_RUNTIME_FLAGS;
@@ -2507,8 +2507,8 @@ legacy_cast_get_strided_loop(
25072507
NPY_NO_EXPORT NPY_CASTING
25082508
simple_cast_resolve_descriptors(
25092509
PyArrayMethodObject *self,
2510-
PyArray_DTypeMeta *dtypes[2],
2511-
PyArray_Descr *given_descrs[2],
2510+
PyArray_DTypeMeta *const dtypes[2],
2511+
PyArray_Descr *const given_descrs[2],
25122512
PyArray_Descr *loop_descrs[2],
25132513
npy_intp *view_offset)
25142514
{
@@ -2548,7 +2548,7 @@ get_byteswap_loop(
25482548
PyArrayMethod_StridedLoop **out_loop, NpyAuxData **out_transferdata,
25492549
NPY_ARRAYMETHOD_FLAGS *flags)
25502550
{
2551-
PyArray_Descr **descrs = context->descriptors;
2551+
PyArray_Descr *const *descrs = context->descriptors;
25522552
assert(descrs[0]->kind == descrs[1]->kind);
25532553
assert(descrs[0]->elsize == descrs[1]->elsize);
25542554
int itemsize = descrs[0]->elsize;
@@ -2727,8 +2727,8 @@ PyArray_InitializeNumericCasts(void)
27272727
static int
27282728
cast_to_string_resolve_descriptors(
27292729
PyArrayMethodObject *self,
2730-
PyArray_DTypeMeta *dtypes[2],
2731-
PyArray_Descr *given_descrs[2],
2730+
PyArray_DTypeMeta *const dtypes[2],
2731+
PyArray_Descr *const given_descrs[2],
27322732
PyArray_Descr *loop_descrs[2],
27332733
npy_intp *NPY_UNUSED(view_offset))
27342734
{
@@ -2879,8 +2879,8 @@ add_other_to_and_from_string_cast(
28792879
NPY_NO_EXPORT NPY_CASTING
28802880
string_to_string_resolve_descriptors(
28812881
PyArrayMethodObject *NPY_UNUSED(self),
2882-
PyArray_DTypeMeta *NPY_UNUSED(dtypes[2]),
2883-
PyArray_Descr *given_descrs[2],
2882+
PyArray_DTypeMeta *const NPY_UNUSED(dtypes[2]),
2883+
PyArray_Descr *const given_descrs[2],
28842884
PyArray_Descr *loop_descrs[2],
28852885
npy_intp *view_offset)
28862886
{
@@ -2932,7 +2932,7 @@ string_to_string_get_loop(
29322932
NPY_ARRAYMETHOD_FLAGS *flags)
29332933
{
29342934
int unicode_swap = 0;
2935-
PyArray_Descr **descrs = context->descriptors;
2935+
PyArray_Descr *const *descrs = context->descriptors;
29362936

29372937
assert(NPY_DTYPE(descrs[0]) == NPY_DTYPE(descrs[1]));
29382938
*flags = context->method->flags & NPY_METH_RUNTIME_FLAGS;
@@ -3033,7 +3033,7 @@ PyArray_InitializeStringCasts(void)
30333033
*/
30343034
static NPY_CASTING
30353035
cast_to_void_dtype_class(
3036-
PyArray_Descr **given_descrs, PyArray_Descr **loop_descrs,
3036+
PyArray_Descr *const *given_descrs, PyArray_Descr **loop_descrs,
30373037
npy_intp *view_offset)
30383038
{
30393039
/* `dtype="V"` means unstructured currently (compare final path) */
@@ -3058,8 +3058,8 @@ cast_to_void_dtype_class(
30583058
static NPY_CASTING
30593059
nonstructured_to_structured_resolve_descriptors(
30603060
PyArrayMethodObject *NPY_UNUSED(self),
3061-
PyArray_DTypeMeta *NPY_UNUSED(dtypes[2]),
3062-
PyArray_Descr *given_descrs[2],
3061+
PyArray_DTypeMeta *const NPY_UNUSED(dtypes[2]),
3062+
PyArray_Descr *const given_descrs[2],
30633063
PyArray_Descr *loop_descrs[2],
30643064
npy_intp *view_offset)
30653065
{
@@ -3251,8 +3251,8 @@ PyArray_GetGenericToVoidCastingImpl(void)
32513251
static NPY_CASTING
32523252
structured_to_nonstructured_resolve_descriptors(
32533253
PyArrayMethodObject *NPY_UNUSED(self),
3254-
PyArray_DTypeMeta *dtypes[2],
3255-
PyArray_Descr *given_descrs[2],
3254+
PyArray_DTypeMeta *const dtypes[2],
3255+
PyArray_Descr *const given_descrs[2],
32563256
PyArray_Descr *loop_descrs[2],
32573257
npy_intp *view_offset)
32583258
{
@@ -3521,8 +3521,8 @@ can_cast_fields_safety(
35213521
static NPY_CASTING
35223522
void_to_void_resolve_descriptors(
35233523
PyArrayMethodObject *self,
3524-
PyArray_DTypeMeta *dtypes[2],
3525-
PyArray_Descr *given_descrs[2],
3524+
PyArray_DTypeMeta *const dtypes[2],
3525+
PyArray_Descr *const given_descrs[2],
35263526
PyArray_Descr *loop_descrs[2],
35273527
npy_intp *view_offset)
35283528
{
@@ -3720,8 +3720,8 @@ PyArray_InitializeVoidToVoidCast(void)
37203720
static NPY_CASTING
37213721
object_to_any_resolve_descriptors(
37223722
PyArrayMethodObject *NPY_UNUSED(self),
3723-
PyArray_DTypeMeta *dtypes[2],
3724-
PyArray_Descr *given_descrs[2],
3723+
PyArray_DTypeMeta *const dtypes[2],
3724+
PyArray_Descr *const given_descrs[2],
37253725
PyArray_Descr *loop_descrs[2],
37263726
npy_intp *NPY_UNUSED(view_offset))
37273727
{
@@ -3794,8 +3794,8 @@ PyArray_GetObjectToGenericCastingImpl(void)
37943794
static NPY_CASTING
37953795
any_to_object_resolve_descriptors(
37963796
PyArrayMethodObject *NPY_UNUSED(self),
3797-
PyArray_DTypeMeta *dtypes[2],
3798-
PyArray_Descr *given_descrs[2],
3797+
PyArray_DTypeMeta *const dtypes[2],
3798+
PyArray_Descr *const given_descrs[2],
37993799
PyArray_Descr *loop_descrs[2],
38003800
npy_intp *NPY_UNUSED(view_offset))
38013801
{

numpy/_core/src/multiarray/convert_datatype.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ PyArray_CheckCastSafety(NPY_CASTING casting,
109109
NPY_NO_EXPORT NPY_CASTING
110110
legacy_same_dtype_resolve_descriptors(
111111
PyArrayMethodObject *self,
112-
PyArray_DTypeMeta *dtypes[2],
113-
PyArray_Descr *given_descrs[2],
112+
PyArray_DTypeMeta *const dtypes[2],
113+
PyArray_Descr *const given_descrs[2],
114114
PyArray_Descr *loop_descrs[2],
115115
npy_intp *view_offset);
116116

@@ -124,8 +124,8 @@ legacy_cast_get_strided_loop(
124124
NPY_NO_EXPORT NPY_CASTING
125125
simple_cast_resolve_descriptors(
126126
PyArrayMethodObject *self,
127-
PyArray_DTypeMeta *dtypes[2],
128-
PyArray_Descr *input_descrs[2],
127+
PyArray_DTypeMeta *const dtypes[2],
128+
PyArray_Descr *const input_descrs[2],
129129
PyArray_Descr *loop_descrs[2],
130130
npy_intp *view_offset);
131131

numpy/_core/src/multiarray/datetime.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3780,7 +3780,7 @@ time_to_time_get_loop(
37803780
{
37813781
int requires_wrap = 0;
37823782
int inner_aligned = aligned;
3783-
PyArray_Descr **descrs = context->descriptors;
3783+
PyArray_Descr *const *descrs = context->descriptors;
37843784
*flags = NPY_METH_NO_FLOATINGPOINT_ERRORS;
37853785

37863786
PyArray_DatetimeMetaData *meta1 = get_datetime_metadata_from_dtype(descrs[0]);
@@ -3929,7 +3929,7 @@ datetime_to_string_get_loop(
39293929
PyArrayMethod_StridedLoop **out_loop, NpyAuxData **out_transferdata,
39303930
NPY_ARRAYMETHOD_FLAGS *flags)
39313931
{
3932-
PyArray_Descr **descrs = context->descriptors;
3932+
PyArray_Descr *const *descrs = context->descriptors;
39333933
*flags = context->method->flags & NPY_METH_RUNTIME_FLAGS;
39343934

39353935
if (descrs[1]->type_num == NPY_STRING) {
@@ -3989,7 +3989,7 @@ string_to_datetime_cast_get_loop(
39893989
PyArrayMethod_StridedLoop **out_loop, NpyAuxData **out_transferdata,
39903990
NPY_ARRAYMETHOD_FLAGS *flags)
39913991
{
3992-
PyArray_Descr **descrs = context->descriptors;
3992+
PyArray_Descr *const *descrs = context->descriptors;
39933993
*flags = context->method->flags & NPY_METH_RUNTIME_FLAGS;
39943994

39953995
if (descrs[0]->type_num == NPY_STRING) {

numpy/_core/src/multiarray/dtype_traversal.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
typedef int get_traverse_func_function(
35-
void *traverse_context, PyArray_Descr *dtype, int aligned,
35+
void *traverse_context, const PyArray_Descr *dtype, int aligned,
3636
npy_intp stride, NPY_traverse_info *clear_info,
3737
NPY_ARRAYMETHOD_FLAGS *flags);
3838

@@ -42,7 +42,7 @@ typedef int get_traverse_func_function(
4242

4343
static int
4444
get_clear_function(
45-
void *traverse_context, PyArray_Descr *dtype, int aligned,
45+
void *traverse_context, const PyArray_Descr *dtype, int aligned,
4646
npy_intp stride, NPY_traverse_info *clear_info,
4747
NPY_ARRAYMETHOD_FLAGS *flags)
4848
{
@@ -99,7 +99,7 @@ PyArray_GetClearFunction(
9999

100100
static int
101101
get_zerofill_function(
102-
void *traverse_context, PyArray_Descr *dtype, int aligned,
102+
void *traverse_context, const PyArray_Descr *dtype, int aligned,
103103
npy_intp stride, NPY_traverse_info *zerofill_info,
104104
NPY_ARRAYMETHOD_FLAGS *flags)
105105
{
@@ -136,7 +136,7 @@ get_zerofill_function(
136136

137137
static int
138138
clear_object_strided_loop(
139-
void *NPY_UNUSED(traverse_context), PyArray_Descr *NPY_UNUSED(descr),
139+
void *NPY_UNUSED(traverse_context), const PyArray_Descr *NPY_UNUSED(descr),
140140
char *data, npy_intp size, npy_intp stride,
141141
NpyAuxData *NPY_UNUSED(auxdata))
142142
{
@@ -156,7 +156,7 @@ clear_object_strided_loop(
156156

157157
NPY_NO_EXPORT int
158158
npy_get_clear_object_strided_loop(
159-
void *NPY_UNUSED(traverse_context), PyArray_Descr *NPY_UNUSED(descr),
159+
void *NPY_UNUSED(traverse_context), const PyArray_Descr *NPY_UNUSED(descr),
160160
int NPY_UNUSED(aligned), npy_intp NPY_UNUSED(fixed_stride),
161161
PyArrayMethod_TraverseLoop **out_loop, NpyAuxData **out_auxdata,
162162
NPY_ARRAYMETHOD_FLAGS *flags)
@@ -171,7 +171,7 @@ npy_get_clear_object_strided_loop(
171171

172172
static int
173173
fill_zero_object_strided_loop(
174-
void *NPY_UNUSED(traverse_context), PyArray_Descr *NPY_UNUSED(descr),
174+
void *NPY_UNUSED(traverse_context), const PyArray_Descr *NPY_UNUSED(descr),
175175
char *data, npy_intp size, npy_intp stride,
176176
NpyAuxData *NPY_UNUSED(auxdata))
177177
{
@@ -188,7 +188,7 @@ fill_zero_object_strided_loop(
188188

189189
NPY_NO_EXPORT int
190190
npy_object_get_fill_zero_loop(void *NPY_UNUSED(traverse_context),
191-
PyArray_Descr *NPY_UNUSED(descr),
191+
const PyArray_Descr *NPY_UNUSED(descr),
192192
int NPY_UNUSED(aligned),
193193
npy_intp NPY_UNUSED(fixed_stride),
194194
PyArrayMethod_TraverseLoop **out_loop,
@@ -275,7 +275,7 @@ fields_traverse_data_clone(NpyAuxData *data)
275275

276276
static int
277277
traverse_fields_function(
278-
void *traverse_context, _PyArray_LegacyDescr *NPY_UNUSED(descr),
278+
void *traverse_context, const _PyArray_LegacyDescr *NPY_UNUSED(descr),
279279
char *data, npy_intp N, npy_intp stride,
280280
NpyAuxData *auxdata)
281281
{
@@ -315,7 +315,7 @@ traverse_fields_function(
315315

316316
static int
317317
get_fields_traverse_function(
318-
void *traverse_context, _PyArray_LegacyDescr *dtype, int NPY_UNUSED(aligned),
318+
void *traverse_context, const _PyArray_LegacyDescr *dtype, int NPY_UNUSED(aligned),
319319
npy_intp stride, PyArrayMethod_TraverseLoop **out_func,
320320
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *flags,
321321
get_traverse_func_function *get_traverse_func)
@@ -431,14 +431,14 @@ subarray_traverse_data_clone(NpyAuxData *data)
431431

432432
static int
433433
traverse_subarray_func(
434-
void *traverse_context, PyArray_Descr *NPY_UNUSED(descr),
434+
void *traverse_context, const PyArray_Descr *NPY_UNUSED(descr),
435435
char *data, npy_intp N, npy_intp stride,
436436
NpyAuxData *auxdata)
437437
{
438438
subarray_traverse_data *subarr_data = (subarray_traverse_data *)auxdata;
439439

440440
PyArrayMethod_TraverseLoop *func = subarr_data->info.func;
441-
PyArray_Descr *sub_descr = subarr_data->info.descr;
441+
const PyArray_Descr *sub_descr = subarr_data->info.descr;
442442
npy_intp sub_N = subarr_data->count;
443443
NpyAuxData *sub_auxdata = subarr_data->info.auxdata;
444444
npy_intp sub_stride = sub_descr->elsize;
@@ -456,7 +456,7 @@ traverse_subarray_func(
456456

457457
static int
458458
get_subarray_traverse_func(
459-
void *traverse_context, PyArray_Descr *dtype, int aligned,
459+
void *traverse_context, const PyArray_Descr *dtype, int aligned,
460460
npy_intp size, npy_intp stride, PyArrayMethod_TraverseLoop **out_func,
461461
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *flags,
462462
get_traverse_func_function *get_traverse_func)
@@ -493,7 +493,7 @@ get_subarray_traverse_func(
493493

494494
static int
495495
clear_no_op(
496-
void *NPY_UNUSED(traverse_context), PyArray_Descr *NPY_UNUSED(descr),
496+
void *NPY_UNUSED(traverse_context), const PyArray_Descr *NPY_UNUSED(descr),
497497
char *NPY_UNUSED(data), npy_intp NPY_UNUSED(size),
498498
npy_intp NPY_UNUSED(stride), NpyAuxData *NPY_UNUSED(auxdata))
499499
{
@@ -502,7 +502,7 @@ clear_no_op(
502502

503503
NPY_NO_EXPORT int
504504
npy_get_clear_void_and_legacy_user_dtype_loop(
505-
void *traverse_context, _PyArray_LegacyDescr *dtype, int aligned,
505+
void *traverse_context, const _PyArray_LegacyDescr *dtype, int aligned,
506506
npy_intp stride, PyArrayMethod_TraverseLoop **out_func,
507507
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *flags)
508508
{
@@ -569,7 +569,7 @@ npy_get_clear_void_and_legacy_user_dtype_loop(
569569

570570
static int
571571
zerofill_fields_function(
572-
void *traverse_context, _PyArray_LegacyDescr *descr,
572+
void *traverse_context, const _PyArray_LegacyDescr *descr,
573573
char *data, npy_intp N, npy_intp stride,
574574
NpyAuxData *auxdata)
575575
{
@@ -598,7 +598,7 @@ zerofill_fields_function(
598598
*/
599599
NPY_NO_EXPORT int
600600
npy_get_zerofill_void_and_legacy_user_dtype_loop(
601-
void *traverse_context, _PyArray_LegacyDescr *dtype, int aligned,
601+
void *traverse_context, const _PyArray_LegacyDescr *dtype, int aligned,
602602
npy_intp stride, PyArrayMethod_TraverseLoop **out_func,
603603
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *flags)
604604
{

numpy/_core/src/multiarray/dtype_traversal.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
NPY_NO_EXPORT int
99
npy_get_clear_object_strided_loop(
10-
void *traverse_context, PyArray_Descr *descr, int aligned,
10+
void *traverse_context, const PyArray_Descr *descr, int aligned,
1111
npy_intp fixed_stride,
1212
PyArrayMethod_TraverseLoop **out_loop, NpyAuxData **out_traversedata,
1313
NPY_ARRAYMETHOD_FLAGS *flags);
1414

1515
NPY_NO_EXPORT int
1616
npy_get_clear_void_and_legacy_user_dtype_loop(
17-
void *traverse_context, _PyArray_LegacyDescr *descr, int aligned,
17+
void *traverse_context, const _PyArray_LegacyDescr *descr, int aligned,
1818
npy_intp fixed_stride,
1919
PyArrayMethod_TraverseLoop **out_loop, NpyAuxData **out_traversedata,
2020
NPY_ARRAYMETHOD_FLAGS *flags);
@@ -23,14 +23,14 @@ npy_get_clear_void_and_legacy_user_dtype_loop(
2323

2424
NPY_NO_EXPORT int
2525
npy_object_get_fill_zero_loop(
26-
void *NPY_UNUSED(traverse_context), PyArray_Descr *NPY_UNUSED(descr),
26+
void *NPY_UNUSED(traverse_context), const PyArray_Descr *NPY_UNUSED(descr),
2727
int NPY_UNUSED(aligned), npy_intp NPY_UNUSED(fixed_stride),
2828
PyArrayMethod_TraverseLoop **out_loop, NpyAuxData **NPY_UNUSED(out_auxdata),
2929
NPY_ARRAYMETHOD_FLAGS *flags);
3030

3131
NPY_NO_EXPORT int
3232
npy_get_zerofill_void_and_legacy_user_dtype_loop(
33-
void *traverse_context, _PyArray_LegacyDescr *dtype, int aligned,
33+
void *traverse_context, const _PyArray_LegacyDescr *dtype, int aligned,
3434
npy_intp stride, PyArrayMethod_TraverseLoop **out_func,
3535
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *flags);
3636

@@ -40,7 +40,7 @@ npy_get_zerofill_void_and_legacy_user_dtype_loop(
4040
typedef struct {
4141
PyArrayMethod_TraverseLoop *func;
4242
NpyAuxData *auxdata;
43-
PyArray_Descr *descr;
43+
const PyArray_Descr *descr;
4444
} NPY_traverse_info;
4545

4646

numpy/_core/src/multiarray/stringdtype/casts.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ unicode_to_string(PyArrayMethod_Context *context, char *const data[],
156156
npy_intp const dimensions[], npy_intp const strides[],
157157
NpyAuxData *NPY_UNUSED(auxdata))
158158
{
159-
PyArray_Descr **descrs = context->descriptors;
159+
PyArray_Descr *const *descrs = context->descriptors;
160160
PyArray_StringDTypeObject *sdescr = (PyArray_StringDTypeObject *)descrs[1];
161161

162162
npy_string_allocator *allocator = NpyString_acquire_allocator(sdescr);
@@ -1672,7 +1672,7 @@ void_to_string(PyArrayMethod_Context *context, char *const data[],
16721672
npy_intp const dimensions[], npy_intp const strides[],
16731673
NpyAuxData *NPY_UNUSED(auxdata))
16741674
{
1675-
PyArray_Descr **descrs = context->descriptors;
1675+
PyArray_Descr *const *descrs = context->descriptors;
16761676
PyArray_StringDTypeObject *descr = (PyArray_StringDTypeObject *)descrs[1];
16771677

16781678
npy_string_allocator *allocator = NpyString_acquire_allocator(descr);
@@ -1802,7 +1802,7 @@ bytes_to_string(PyArrayMethod_Context *context, char *const data[],
18021802
npy_intp const dimensions[], npy_intp const strides[],
18031803
NpyAuxData *NPY_UNUSED(auxdata))
18041804
{
1805-
PyArray_Descr **descrs = context->descriptors;
1805+
PyArray_Descr *const *descrs = context->descriptors;
18061806
PyArray_StringDTypeObject *descr = (PyArray_StringDTypeObject *)descrs[1];
18071807

18081808
npy_string_allocator *allocator = NpyString_acquire_allocator(descr);

0 commit comments

Comments
 (0)