1
1
#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API
2
2
#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API
3
- #define NPY_NO_DEPRECATED_API NPY_2_4_API_VERSION
4
- #define NPY_TARGET_VERSION NPY_2_4_API_VERSION
3
+ #define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
4
+ #ifndef NPY_TARGET_VERSION
5
+ #define NPY_TARGET_VERSION NPY_2_0_API_VERSION
6
+ #endif
5
7
#define NO_IMPORT_ARRAY
6
8
#define NO_IMPORT_UFUNC
7
9
@@ -419,7 +421,7 @@ numpy_to_quad_resolve_descriptors(PyObject *NPY_UNUSED(self), PyArray_DTypeMeta
419
421
}
420
422
421
423
loop_descrs[0 ] = PyArray_GetDefaultDescr (dtypes[0 ]);
422
- #if NPY_FEATURE_VERSION > NPY_2_3_API_VERSION
424
+ #if NPY_TARGET_VERSION > NPY_2_3_API_VERSION
423
425
return NPY_SAFE_CASTING | NPY_SAME_VALUE_CASTING_FLAG;
424
426
#else
425
427
return NPY_SAFE_CASTING;
@@ -692,7 +694,6 @@ from_quad_checked(quad_value x, QuadBackendType backend, typename NpyType<T>::TY
692
694
return -1 ;
693
695
}
694
696
695
- template <typename T>
696
697
static NPY_CASTING
697
698
quad_to_numpy_resolve_descriptors (PyObject *NPY_UNUSED (self), PyArray_DTypeMeta *dtypes[2],
698
699
PyArray_Descr *given_descrs[2], PyArray_Descr *loop_descrs[2],
@@ -711,9 +712,6 @@ quad_to_numpy_strided_loop_unaligned(PyArrayMethod_Context *context, char *const
711
712
npy_intp const dimensions[], npy_intp const strides[],
712
713
void *NPY_UNUSED (auxdata))
713
714
{
714
- #if NPY_FEATURE_VERSION > NPY_2_3_API_VERSION
715
- int same_value_casting = ((context->flags & NPY_SAME_VALUE_CONTEXT_FLAG) == NPY_SAME_VALUE_CONTEXT_FLAG);
716
- #endif
717
715
npy_intp N = dimensions[0 ];
718
716
char *in_ptr = data[0 ];
719
717
char *out_ptr = data[1 ];
@@ -723,7 +721,11 @@ quad_to_numpy_strided_loop_unaligned(PyArrayMethod_Context *context, char *const
723
721
724
722
size_t elem_size = (backend == BACKEND_SLEEF) ? sizeof (Sleef_quad) : sizeof (long double );
725
723
726
- #if NPY_FEATURE_VERSION > NPY_2_3_API_VERSION
724
+ #if NPY_TARGET_VERSION > NPY_2_3_API_VERSION
725
+ int same_value_casting = 0 ;
726
+ if (PyArray_GetNDArrayCFeatureVersion () > NPY_2_3_API_VERSION) {
727
+ same_value_casting = ((context->flags & NPY_SAME_VALUE_CONTEXT_FLAG) == NPY_SAME_VALUE_CONTEXT_FLAG);
728
+ }
727
729
if (same_value_casting) {
728
730
while (N--) {
729
731
quad_value in_val;
@@ -763,14 +765,15 @@ quad_to_numpy_strided_loop_aligned(PyArrayMethod_Context *context, char *const d
763
765
npy_intp N = dimensions[0 ];
764
766
char *in_ptr = data[0 ];
765
767
char *out_ptr = data[1 ];
766
- #if NPY_FEATURE_VERSION > NPY_2_3_API_VERSION
767
- int same_value_casting = ((context->flags & NPY_SAME_VALUE_CONTEXT_FLAG) == NPY_SAME_VALUE_CONTEXT_FLAG);
768
- #endif
769
768
770
769
QuadPrecDTypeObject *quad_descr = (QuadPrecDTypeObject *)context->descriptors [0 ];
771
770
QuadBackendType backend = quad_descr->backend ;
772
771
773
- #if NPY_FEATURE_VERSION > NPY_2_3_API_VERSION
772
+ #if NPY_TARGET_VERSION > NPY_2_3_API_VERSION
773
+ int same_value_casting = 0 ;
774
+ if (PyArray_GetNDArrayCFeatureVersion () > NPY_2_3_API_VERSION) {
775
+ same_value_casting = ((context->flags & NPY_SAME_VALUE_CONTEXT_FLAG) == NPY_SAME_VALUE_CONTEXT_FLAG);
776
+ }
774
777
if (same_value_casting) {
775
778
while (N--) {
776
779
quad_value in_val;
@@ -835,7 +838,7 @@ add_cast_from(PyArray_DTypeMeta *to)
835
838
PyArray_DTypeMeta **dtypes = new PyArray_DTypeMeta *[2 ]{&QuadPrecDType, to};
836
839
837
840
PyType_Slot *slots = new PyType_Slot[]{
838
- {NPY_METH_resolve_descriptors, (void *)&quad_to_numpy_resolve_descriptors<T> },
841
+ {NPY_METH_resolve_descriptors, (void *)&quad_to_numpy_resolve_descriptors},
839
842
{NPY_METH_strided_loop, (void *)&quad_to_numpy_strided_loop_aligned<T>},
840
843
{NPY_METH_unaligned_strided_loop, (void *)&quad_to_numpy_strided_loop_unaligned<T>},
841
844
{0 , nullptr }};
@@ -844,7 +847,7 @@ add_cast_from(PyArray_DTypeMeta *to)
844
847
.name = " cast_QuadPrec_to_NumPy" ,
845
848
.nin = 1 ,
846
849
.nout = 1 ,
847
- #if NPY_FEATURE_VERSION > NPY_2_3_API_VERSION
850
+ #if PyArray_RUNTIME_VERSION > NPY_2_3_API_VERSION
848
851
.casting = NPY_SAME_VALUE_CASTING,
849
852
#else
850
853
.casting = NPY_UNSAFE_CASTING,
0 commit comments