@@ -605,6 +605,32 @@ uint_to_string(unsigned long long in, char *out)
605
605
return pylong_to_string (pylong_val , out );
606
606
}
607
607
608
+ static NPY_CASTING
609
+ int_to_string_resolve_descriptors (PyObject * NPY_UNUSED (self ),
610
+ PyArray_DTypeMeta * dtypes [2 ],
611
+ PyArray_Descr * given_descrs [2 ],
612
+ PyArray_Descr * loop_descrs [2 ],
613
+ npy_intp * NPY_UNUSED (view_offset ))
614
+ {
615
+ if (given_descrs [1 ] == NULL ) {
616
+ PyArray_Descr * new = (PyArray_Descr * )new_stringdtype_instance (
617
+ (PyTypeObject * )dtypes [1 ]);
618
+ if (new == NULL ) {
619
+ return (NPY_CASTING )- 1 ;
620
+ }
621
+ loop_descrs [1 ] = new ;
622
+ }
623
+ else {
624
+ Py_INCREF (given_descrs [1 ]);
625
+ loop_descrs [1 ] = given_descrs [1 ];
626
+ }
627
+
628
+ Py_INCREF (given_descrs [0 ]);
629
+ loop_descrs [0 ] = given_descrs [0 ];
630
+
631
+ return NPY_UNSAFE_CASTING ;
632
+ }
633
+
608
634
// string to int8
609
635
610
636
static NPY_CASTING
@@ -668,32 +694,6 @@ static char *s2i8_name = "cast_StringDType_to_Int8";
668
694
669
695
// int8 to string
670
696
671
- static NPY_CASTING
672
- int8_to_string_resolve_descriptors (PyObject * NPY_UNUSED (self ),
673
- PyArray_DTypeMeta * dtypes [2 ],
674
- PyArray_Descr * given_descrs [2 ],
675
- PyArray_Descr * loop_descrs [2 ],
676
- npy_intp * NPY_UNUSED (view_offset ))
677
- {
678
- if (given_descrs [1 ] == NULL ) {
679
- PyArray_Descr * new = (PyArray_Descr * )new_stringdtype_instance (
680
- (PyTypeObject * )dtypes [1 ]);
681
- if (new == NULL ) {
682
- return (NPY_CASTING )- 1 ;
683
- }
684
- loop_descrs [1 ] = new ;
685
- }
686
- else {
687
- Py_INCREF (given_descrs [1 ]);
688
- loop_descrs [1 ] = given_descrs [1 ];
689
- }
690
-
691
- Py_INCREF (given_descrs [0 ]);
692
- loop_descrs [0 ] = given_descrs [0 ];
693
-
694
- return NPY_UNSAFE_CASTING ;
695
- }
696
-
697
697
static int
698
698
int8_to_string (PyArrayMethod_Context * NPY_UNUSED (context ), char * const data [],
699
699
npy_intp const dimensions [], npy_intp const strides [],
@@ -718,7 +718,7 @@ int8_to_string(PyArrayMethod_Context *NPY_UNUSED(context), char *const data[],
718
718
}
719
719
720
720
static PyType_Slot i82s_slots [] = {
721
- {NPY_METH_resolve_descriptors , & int8_to_string_resolve_descriptors },
721
+ {NPY_METH_resolve_descriptors , & int_to_string_resolve_descriptors },
722
722
{NPY_METH_strided_loop , & int8_to_string },
723
723
{0 , NULL }};
724
724
@@ -787,32 +787,6 @@ static char *s2i16_name = "cast_StringDType_to_Int16";
787
787
788
788
// int16 to string
789
789
790
- static NPY_CASTING
791
- int16_to_string_resolve_descriptors (PyObject * NPY_UNUSED (self ),
792
- PyArray_DTypeMeta * dtypes [2 ],
793
- PyArray_Descr * given_descrs [2 ],
794
- PyArray_Descr * loop_descrs [2 ],
795
- npy_intp * NPY_UNUSED (view_offset ))
796
- {
797
- if (given_descrs [1 ] == NULL ) {
798
- PyArray_Descr * new = (PyArray_Descr * )new_stringdtype_instance (
799
- (PyTypeObject * )dtypes [1 ]);
800
- if (new == NULL ) {
801
- return (NPY_CASTING )- 1 ;
802
- }
803
- loop_descrs [1 ] = new ;
804
- }
805
- else {
806
- Py_INCREF (given_descrs [1 ]);
807
- loop_descrs [1 ] = given_descrs [1 ];
808
- }
809
-
810
- Py_INCREF (given_descrs [0 ]);
811
- loop_descrs [0 ] = given_descrs [0 ];
812
-
813
- return NPY_UNSAFE_CASTING ;
814
- }
815
-
816
790
static int
817
791
int16_to_string (PyArrayMethod_Context * NPY_UNUSED (context ), char * const data [],
818
792
npy_intp const dimensions [], npy_intp const strides [],
@@ -837,7 +811,7 @@ int16_to_string(PyArrayMethod_Context *NPY_UNUSED(context), char *const data[],
837
811
}
838
812
839
813
static PyType_Slot i162s_slots [] = {
840
- {NPY_METH_resolve_descriptors , & int16_to_string_resolve_descriptors },
814
+ {NPY_METH_resolve_descriptors , & int_to_string_resolve_descriptors },
841
815
{NPY_METH_strided_loop , & int16_to_string },
842
816
{0 , NULL }};
843
817
@@ -906,32 +880,6 @@ static char *s2i32_name = "cast_StringDType_to_Int32";
906
880
907
881
// int32 to string
908
882
909
- static NPY_CASTING
910
- int32_to_string_resolve_descriptors (PyObject * NPY_UNUSED (self ),
911
- PyArray_DTypeMeta * dtypes [2 ],
912
- PyArray_Descr * given_descrs [2 ],
913
- PyArray_Descr * loop_descrs [2 ],
914
- npy_intp * NPY_UNUSED (view_offset ))
915
- {
916
- if (given_descrs [1 ] == NULL ) {
917
- PyArray_Descr * new = (PyArray_Descr * )new_stringdtype_instance (
918
- (PyTypeObject * )dtypes [1 ]);
919
- if (new == NULL ) {
920
- return (NPY_CASTING )- 1 ;
921
- }
922
- loop_descrs [1 ] = new ;
923
- }
924
- else {
925
- Py_INCREF (given_descrs [1 ]);
926
- loop_descrs [1 ] = given_descrs [1 ];
927
- }
928
-
929
- Py_INCREF (given_descrs [0 ]);
930
- loop_descrs [0 ] = given_descrs [0 ];
931
-
932
- return NPY_UNSAFE_CASTING ;
933
- }
934
-
935
883
static int
936
884
int32_to_string (PyArrayMethod_Context * NPY_UNUSED (context ), char * const data [],
937
885
npy_intp const dimensions [], npy_intp const strides [],
@@ -956,7 +904,7 @@ int32_to_string(PyArrayMethod_Context *NPY_UNUSED(context), char *const data[],
956
904
}
957
905
958
906
static PyType_Slot i322s_slots [] = {
959
- {NPY_METH_resolve_descriptors , & int32_to_string_resolve_descriptors },
907
+ {NPY_METH_resolve_descriptors , & int_to_string_resolve_descriptors },
960
908
{NPY_METH_strided_loop , & int32_to_string },
961
909
{0 , NULL }};
962
910
@@ -1025,32 +973,6 @@ static char *s2i64_name = "cast_StringDType_to_Int64";
1025
973
1026
974
// int64 to string
1027
975
1028
- static NPY_CASTING
1029
- int64_to_string_resolve_descriptors (PyObject * NPY_UNUSED (self ),
1030
- PyArray_DTypeMeta * dtypes [2 ],
1031
- PyArray_Descr * given_descrs [2 ],
1032
- PyArray_Descr * loop_descrs [2 ],
1033
- npy_intp * NPY_UNUSED (view_offset ))
1034
- {
1035
- if (given_descrs [1 ] == NULL ) {
1036
- PyArray_Descr * new = (PyArray_Descr * )new_stringdtype_instance (
1037
- (PyTypeObject * )dtypes [1 ]);
1038
- if (new == NULL ) {
1039
- return (NPY_CASTING )- 1 ;
1040
- }
1041
- loop_descrs [1 ] = new ;
1042
- }
1043
- else {
1044
- Py_INCREF (given_descrs [1 ]);
1045
- loop_descrs [1 ] = given_descrs [1 ];
1046
- }
1047
-
1048
- Py_INCREF (given_descrs [0 ]);
1049
- loop_descrs [0 ] = given_descrs [0 ];
1050
-
1051
- return NPY_UNSAFE_CASTING ;
1052
- }
1053
-
1054
976
static int
1055
977
int64_to_string (PyArrayMethod_Context * NPY_UNUSED (context ), char * const data [],
1056
978
npy_intp const dimensions [], npy_intp const strides [],
@@ -1075,7 +997,7 @@ int64_to_string(PyArrayMethod_Context *NPY_UNUSED(context), char *const data[],
1075
997
}
1076
998
1077
999
static PyType_Slot i642s_slots [] = {
1078
- {NPY_METH_resolve_descriptors , & int64_to_string_resolve_descriptors },
1000
+ {NPY_METH_resolve_descriptors , & int_to_string_resolve_descriptors },
1079
1001
{NPY_METH_strided_loop , & int64_to_string },
1080
1002
{0 , NULL }};
1081
1003
@@ -1144,32 +1066,6 @@ static char *s2ui8_name = "cast_StringDType_to_UInt8";
1144
1066
1145
1067
// uint8 to string
1146
1068
1147
- static NPY_CASTING
1148
- uint8_to_string_resolve_descriptors (PyObject * NPY_UNUSED (self ),
1149
- PyArray_DTypeMeta * dtypes [2 ],
1150
- PyArray_Descr * given_descrs [2 ],
1151
- PyArray_Descr * loop_descrs [2 ],
1152
- npy_intp * NPY_UNUSED (view_offset ))
1153
- {
1154
- if (given_descrs [1 ] == NULL ) {
1155
- PyArray_Descr * new = (PyArray_Descr * )new_stringdtype_instance (
1156
- (PyTypeObject * )dtypes [1 ]);
1157
- if (new == NULL ) {
1158
- return (NPY_CASTING )- 1 ;
1159
- }
1160
- loop_descrs [1 ] = new ;
1161
- }
1162
- else {
1163
- Py_INCREF (given_descrs [1 ]);
1164
- loop_descrs [1 ] = given_descrs [1 ];
1165
- }
1166
-
1167
- Py_INCREF (given_descrs [0 ]);
1168
- loop_descrs [0 ] = given_descrs [0 ];
1169
-
1170
- return NPY_UNSAFE_CASTING ;
1171
- }
1172
-
1173
1069
static int
1174
1070
uint8_to_string (PyArrayMethod_Context * NPY_UNUSED (context ), char * const data [],
1175
1071
npy_intp const dimensions [], npy_intp const strides [],
@@ -1194,7 +1090,7 @@ uint8_to_string(PyArrayMethod_Context *NPY_UNUSED(context), char *const data[],
1194
1090
}
1195
1091
1196
1092
static PyType_Slot ui82s_slots [] = {
1197
- {NPY_METH_resolve_descriptors , & uint8_to_string_resolve_descriptors },
1093
+ {NPY_METH_resolve_descriptors , & int_to_string_resolve_descriptors },
1198
1094
{NPY_METH_strided_loop , & uint8_to_string },
1199
1095
{0 , NULL }};
1200
1096
@@ -1263,32 +1159,6 @@ static char *s2ui16_name = "cast_StringDType_to_UInt16";
1263
1159
1264
1160
// uint16 to string
1265
1161
1266
- static NPY_CASTING
1267
- uint16_to_string_resolve_descriptors (PyObject * NPY_UNUSED (self ),
1268
- PyArray_DTypeMeta * dtypes [2 ],
1269
- PyArray_Descr * given_descrs [2 ],
1270
- PyArray_Descr * loop_descrs [2 ],
1271
- npy_intp * NPY_UNUSED (view_offset ))
1272
- {
1273
- if (given_descrs [1 ] == NULL ) {
1274
- PyArray_Descr * new = (PyArray_Descr * )new_stringdtype_instance (
1275
- (PyTypeObject * )dtypes [1 ]);
1276
- if (new == NULL ) {
1277
- return (NPY_CASTING )- 1 ;
1278
- }
1279
- loop_descrs [1 ] = new ;
1280
- }
1281
- else {
1282
- Py_INCREF (given_descrs [1 ]);
1283
- loop_descrs [1 ] = given_descrs [1 ];
1284
- }
1285
-
1286
- Py_INCREF (given_descrs [0 ]);
1287
- loop_descrs [0 ] = given_descrs [0 ];
1288
-
1289
- return NPY_UNSAFE_CASTING ;
1290
- }
1291
-
1292
1162
static int
1293
1163
uint16_to_string (PyArrayMethod_Context * NPY_UNUSED (context ),
1294
1164
char * const data [], npy_intp const dimensions [],
@@ -1313,7 +1183,7 @@ uint16_to_string(PyArrayMethod_Context *NPY_UNUSED(context),
1313
1183
}
1314
1184
1315
1185
static PyType_Slot ui162s_slots [] = {
1316
- {NPY_METH_resolve_descriptors , & uint16_to_string_resolve_descriptors },
1186
+ {NPY_METH_resolve_descriptors , & int_to_string_resolve_descriptors },
1317
1187
{NPY_METH_strided_loop , & uint16_to_string },
1318
1188
{0 , NULL }};
1319
1189
@@ -1382,32 +1252,6 @@ static char *s2ui32_name = "cast_StringDType_to_UInt32";
1382
1252
1383
1253
// uint32 to string
1384
1254
1385
- static NPY_CASTING
1386
- uint32_to_string_resolve_descriptors (PyObject * NPY_UNUSED (self ),
1387
- PyArray_DTypeMeta * dtypes [2 ],
1388
- PyArray_Descr * given_descrs [2 ],
1389
- PyArray_Descr * loop_descrs [2 ],
1390
- npy_intp * NPY_UNUSED (view_offset ))
1391
- {
1392
- if (given_descrs [1 ] == NULL ) {
1393
- PyArray_Descr * new = (PyArray_Descr * )new_stringdtype_instance (
1394
- (PyTypeObject * )dtypes [1 ]);
1395
- if (new == NULL ) {
1396
- return (NPY_CASTING )- 1 ;
1397
- }
1398
- loop_descrs [1 ] = new ;
1399
- }
1400
- else {
1401
- Py_INCREF (given_descrs [1 ]);
1402
- loop_descrs [1 ] = given_descrs [1 ];
1403
- }
1404
-
1405
- Py_INCREF (given_descrs [0 ]);
1406
- loop_descrs [0 ] = given_descrs [0 ];
1407
-
1408
- return NPY_UNSAFE_CASTING ;
1409
- }
1410
-
1411
1255
static int
1412
1256
uint32_to_string (PyArrayMethod_Context * NPY_UNUSED (context ),
1413
1257
char * const data [], npy_intp const dimensions [],
@@ -1432,7 +1276,7 @@ uint32_to_string(PyArrayMethod_Context *NPY_UNUSED(context),
1432
1276
}
1433
1277
1434
1278
static PyType_Slot ui322s_slots [] = {
1435
- {NPY_METH_resolve_descriptors , & uint32_to_string_resolve_descriptors },
1279
+ {NPY_METH_resolve_descriptors , & int_to_string_resolve_descriptors },
1436
1280
{NPY_METH_strided_loop , & uint32_to_string },
1437
1281
{0 , NULL }};
1438
1282
@@ -1501,32 +1345,6 @@ static char *s2ui64_name = "cast_StringDType_to_UInt64";
1501
1345
1502
1346
// uint64 to string
1503
1347
1504
- static NPY_CASTING
1505
- uint64_to_string_resolve_descriptors (PyObject * NPY_UNUSED (self ),
1506
- PyArray_DTypeMeta * dtypes [2 ],
1507
- PyArray_Descr * given_descrs [2 ],
1508
- PyArray_Descr * loop_descrs [2 ],
1509
- npy_intp * NPY_UNUSED (view_offset ))
1510
- {
1511
- if (given_descrs [1 ] == NULL ) {
1512
- PyArray_Descr * new = (PyArray_Descr * )new_stringdtype_instance (
1513
- (PyTypeObject * )dtypes [1 ]);
1514
- if (new == NULL ) {
1515
- return (NPY_CASTING )- 1 ;
1516
- }
1517
- loop_descrs [1 ] = new ;
1518
- }
1519
- else {
1520
- Py_INCREF (given_descrs [1 ]);
1521
- loop_descrs [1 ] = given_descrs [1 ];
1522
- }
1523
-
1524
- Py_INCREF (given_descrs [0 ]);
1525
- loop_descrs [0 ] = given_descrs [0 ];
1526
-
1527
- return NPY_UNSAFE_CASTING ;
1528
- }
1529
-
1530
1348
static int
1531
1349
uint64_to_string (PyArrayMethod_Context * NPY_UNUSED (context ),
1532
1350
char * const data [], npy_intp const dimensions [],
@@ -1551,7 +1369,7 @@ uint64_to_string(PyArrayMethod_Context *NPY_UNUSED(context),
1551
1369
}
1552
1370
1553
1371
static PyType_Slot ui642s_slots [] = {
1554
- {NPY_METH_resolve_descriptors , & uint64_to_string_resolve_descriptors },
1372
+ {NPY_METH_resolve_descriptors , & int_to_string_resolve_descriptors },
1555
1373
{NPY_METH_strided_loop , & uint64_to_string },
1556
1374
{0 , NULL }};
1557
1375
0 commit comments