11
11
#include "abstractdtypes.h"
12
12
#include "array_coercion.h"
13
13
#include "common.h"
14
+ #include "arraytypes.h"
14
15
15
16
16
- static NPY_INLINE PyArray_Descr *
17
- int_default_descriptor (PyArray_DTypeMeta * NPY_UNUSED (cls ))
17
+ //static NPY_INLINE PyArray_Descr *
18
+ //int_default_descriptor(PyArray_DTypeMeta* NPY_UNUSED(cls))
19
+ static NPY_INLINE HPy
20
+ int_default_descriptor (HPyContext * ctx , HPy NPY_UNUSED (cls ))
18
21
{
19
- return PyArray_DescrFromType ( NPY_LONG );
22
+ return HPyArray_DescrFromType ( ctx , NPY_LONG );
20
23
}
21
24
22
25
static PyArray_Descr *
@@ -51,10 +54,10 @@ discover_descriptor_from_pyint(
51
54
}
52
55
53
56
54
- static NPY_INLINE PyArray_Descr *
55
- float_default_descriptor (PyArray_DTypeMeta * NPY_UNUSED (cls ))
57
+ static NPY_INLINE HPy
58
+ float_default_descriptor (HPyContext * ctx , HPy NPY_UNUSED (cls ))
56
59
{
57
- return PyArray_DescrFromType ( NPY_DOUBLE );
60
+ return HPyArray_DescrFromType ( ctx , NPY_DOUBLE );
58
61
}
59
62
60
63
@@ -66,10 +69,10 @@ discover_descriptor_from_pyfloat(
66
69
return PyArray_DescrFromType (NPY_DOUBLE );
67
70
}
68
71
69
- static NPY_INLINE PyArray_Descr *
70
- complex_default_descriptor (PyArray_DTypeMeta * NPY_UNUSED (cls ))
72
+ static NPY_INLINE HPy
73
+ complex_default_descriptor (HPyContext * ctx , HPy NPY_UNUSED (cls ))
71
74
{
72
- return PyArray_DescrFromType ( NPY_CDOUBLE );
75
+ return HPyArray_DescrFromType ( ctx , NPY_CDOUBLE );
73
76
}
74
77
75
78
static PyArray_Descr *
@@ -128,7 +131,7 @@ initialize_and_map_pytypes_to_dtypes(HPyContext *ctx)
128
131
PyArray_DTypeMeta * int_abstract_dtype_data = PyArray_DTypeMeta_AsStruct (ctx , h_PyArray_PyIntAbstractDType );
129
132
int_abstract_dtype_data -> dt_slots = & pyintabstractdtype_slots ;
130
133
int_abstract_dtype_data -> flags = NPY_DT_ABSTRACT ;
131
- int_abstract_dtype_data -> scalar_type = & PyLong_Type ;
134
+ HPyField_Store ( ctx , h_PyArray_PyIntAbstractDType , & int_abstract_dtype_data -> scalar_type , ctx -> h_LongType ) ;
132
135
PyArray_PyIntAbstractDType = (PyArray_DTypeMeta * ) HPy_AsPyObject (ctx , h_PyArray_PyIntAbstractDType );
133
136
HPy_Close (ctx , h_PyArray_PyIntAbstractDType );
134
137
@@ -140,7 +143,7 @@ initialize_and_map_pytypes_to_dtypes(HPyContext *ctx)
140
143
PyArray_DTypeMeta * float_abstract_dtype_data = PyArray_DTypeMeta_AsStruct (ctx , h_PyArray_PyFloatAbstractDType );
141
144
float_abstract_dtype_data -> dt_slots = & pyfloatabstractdtype_slots ;
142
145
float_abstract_dtype_data -> flags = NPY_DT_ABSTRACT ;
143
- float_abstract_dtype_data -> scalar_type = & PyFloat_Type ;
146
+ HPyField_Store ( ctx , h_PyArray_PyFloatAbstractDType , & float_abstract_dtype_data -> scalar_type , ctx -> h_FloatType ) ;
144
147
PyArray_PyFloatAbstractDType = (PyArray_DTypeMeta * ) HPy_AsPyObject (ctx , h_PyArray_PyFloatAbstractDType );
145
148
HPy_Close (ctx , h_PyArray_PyFloatAbstractDType );
146
149
@@ -152,7 +155,7 @@ initialize_and_map_pytypes_to_dtypes(HPyContext *ctx)
152
155
PyArray_DTypeMeta * complex_abstract_dtype_data = PyArray_DTypeMeta_AsStruct (ctx , h_PyArray_PyComplexAbstractDType );
153
156
complex_abstract_dtype_data -> dt_slots = & pycomplexabstractdtype_slots ;
154
157
complex_abstract_dtype_data -> flags = NPY_DT_ABSTRACT ;
155
- complex_abstract_dtype_data -> scalar_type = & PyComplex_Type ;
158
+ HPyField_Store ( ctx , h_PyArray_PyComplexAbstractDType , & complex_abstract_dtype_data -> scalar_type , ctx -> h_ComplexType ) ;
156
159
PyArray_PyComplexAbstractDType = (PyArray_DTypeMeta * ) HPy_AsPyObject (ctx , h_PyArray_PyComplexAbstractDType );
157
160
HPy_Close (ctx , h_PyArray_PyComplexAbstractDType );
158
161
@@ -327,4 +330,4 @@ NPY_DType_Slots pycomplexabstractdtype_slots = {
327
330
.default_descr = complex_default_descriptor ,
328
331
.discover_descr_from_pyobject = discover_descriptor_from_pycomplex ,
329
332
.common_dtype = complex_common_dtype ,
330
- };
333
+ };
0 commit comments