Skip to content

Commit 8899e95

Browse files
committed
Use NPY_DEFAULT_INT rather than NPY_LONG
1 parent ab7202c commit 8899e95

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

numpy/_core/src/umath/string_ufuncs.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ adjust_offsets(npy_int64 *start, npy_int64 *end, npy_int64 len)
228228
}
229229

230230
template <ENCODING enc>
231-
static inline npy_long
231+
static inline npy_intp
232232
string_find(char *str1, int elsize1, char *str2, int elsize2,
233233
npy_int64 start, npy_int64 end)
234234
{
@@ -240,28 +240,28 @@ string_find(char *str1, int elsize1, char *str2, int elsize2,
240240

241241
adjust_offsets(&start, &end, len1);
242242
if (end - start < len2) {
243-
return (npy_long) -1;
243+
return (npy_intp) -1;
244244
}
245245

246246
if (len2 == 1) {
247247
npy_ucs4 ch = *buf2;
248-
npy_long result = (npy_long) findchar<enc>(buf1 + start, end - start, ch);
248+
npy_intp result = (npy_intp) findchar<enc>(buf1 + start, end - start, ch);
249249
if (result == -1) {
250-
return (npy_long) -1;
250+
return (npy_intp) -1;
251251
} else {
252-
return result + (npy_long) start;
252+
return result + (npy_intp) start;
253253
}
254254
}
255255

256-
return (npy_long) findslice<enc>(buf1 + start,
256+
return (npy_intp) findslice<enc>(buf1 + start,
257257
end - start,
258258
buf2,
259259
len2,
260260
start);
261261
}
262262

263263
template <ENCODING enc>
264-
static inline npy_long
264+
static inline npy_intp
265265
string_rfind(char *str1, int elsize1, char *str2, int elsize2,
266266
npy_int64 start, npy_int64 end)
267267
{
@@ -273,20 +273,20 @@ string_rfind(char *str1, int elsize1, char *str2, int elsize2,
273273

274274
adjust_offsets(&start, &end, len1);
275275
if (end - start < len2) {
276-
return (npy_long) -1;
276+
return (npy_intp) -1;
277277
}
278278

279279
if (len2 == 1) {
280280
npy_ucs4 ch = *buf2;
281-
npy_long result = (npy_long) rfindchar(buf1 + start, end - start, ch);
281+
npy_intp result = (npy_intp) rfindchar(buf1 + start, end - start, ch);
282282
if (result == -1) {
283-
return (npy_long) -1;
283+
return (npy_intp) -1;
284284
} else {
285-
return result + (npy_long) start;
285+
return result + (npy_intp) start;
286286
}
287287
}
288288

289-
return (npy_long) rfindslice(buf1 + start,
289+
return (npy_intp) rfindslice(buf1 + start,
290290
end - start,
291291
buf2,
292292
len2,
@@ -448,9 +448,9 @@ string_find_loop(PyArrayMethod_Context *context,
448448
npy_intp N = dimensions[0];
449449

450450
while (N--) {
451-
npy_long idx = string_find<enc>(in1, elsize1, in2, elsize2,
451+
npy_intp idx = string_find<enc>(in1, elsize1, in2, elsize2,
452452
*(npy_int64 *)in3, *(npy_int64 *)in4);
453-
*(npy_long *)out = idx;
453+
*(npy_intp *)out = idx;
454454

455455
in1 += strides[0];
456456
in2 += strides[1];
@@ -480,9 +480,9 @@ string_rfind_loop(PyArrayMethod_Context *context,
480480
npy_intp N = dimensions[0];
481481

482482
while (N--) {
483-
npy_long idx = string_rfind<enc>(in1, elsize1, in2, elsize2,
483+
npy_intp idx = string_rfind<enc>(in1, elsize1, in2, elsize2,
484484
*(npy_int64 *)in3, *(npy_int64 *)in4);
485-
*(npy_long *)out = idx;
485+
*(npy_intp *)out = idx;
486486

487487
in1 += strides[0];
488488
in2 += strides[1];
@@ -534,7 +534,7 @@ string_find_rfind_promoter(PyUFuncObject *NPY_UNUSED(ufunc),
534534
new_op_dtypes[1] = op_dtypes[1];
535535
new_op_dtypes[2] = PyArray_DTypeFromTypeNum(NPY_INT64);
536536
new_op_dtypes[3] = PyArray_DTypeFromTypeNum(NPY_INT64);
537-
new_op_dtypes[4] = PyArray_DTypeFromTypeNum(NPY_LONG);
537+
new_op_dtypes[4] = PyArray_DTypeFromTypeNum(NPY_DEFAULT_INT);
538538
return 0;
539539
}
540540

@@ -779,7 +779,7 @@ init_string_ufuncs(PyObject *umath)
779779

780780
dtypes[0] = dtypes[1] = NPY_STRING;
781781
dtypes[2] = dtypes[3] = NPY_INT64;
782-
dtypes[4] = NPY_LONG;
782+
dtypes[4] = NPY_DEFAULT_INT;
783783
if (init_ufunc(umath, "find", "templated_string_find", 4, 1, dtypes,
784784
string_find_loop<ENCODING::ASCII>, string_find_loop<ENCODING::UTF32>,
785785
NULL, string_find_rfind_promoter) < 0) {
@@ -788,7 +788,7 @@ init_string_ufuncs(PyObject *umath)
788788

789789
dtypes[0] = dtypes[1] = NPY_STRING;
790790
dtypes[2] = dtypes[3] = NPY_INT64;
791-
dtypes[4] = NPY_LONG;
791+
dtypes[4] = NPY_DEFAULT_INT;
792792
if (init_ufunc(umath, "rfind", "templated_string_rfind", 4, 1, dtypes,
793793
string_rfind_loop<ENCODING::ASCII>, string_rfind_loop<ENCODING::UTF32>,
794794
NULL, string_find_rfind_promoter) < 0) {

0 commit comments

Comments
 (0)