@@ -177,25 +177,35 @@ quadprec_default_descr(PyArray_DTypeMeta *cls)
177
177
}
178
178
179
179
static PyObject *
180
- quad_finfo (PyArray_Descr * descr )
180
+ quad_finfo (PyArray_Descr * descr , NPY_DTYPE_INFO_TYPE info_type )
181
181
{
182
182
183
- PyObject * finfo_dict = PyDict_New ();
184
- if (!finfo_dict ) return NULL ;
185
-
186
- PyDict_SetItemString (finfo_dict , "precision" , PyLong_FromLong (34 ));
187
- PyDict_SetItemString (finfo_dict , "bits" , PyLong_FromLong (128 ));
188
-
189
- PyDict_SetItemString (finfo_dict , "eps" , PyLong_FromLong (34 ));
190
-
191
- PyDict_SetItemString (finfo_dict , "max" , PyLong_FromLong (34 ));
192
-
193
- PyDict_SetItemString (finfo_dict , "tiny" , PyLong_FromLong (34 ));
194
-
195
- PyDict_SetItemString (finfo_dict , "epsneg" , PyLong_FromLong (34 ));
196
- PyDict_SetItemString (finfo_dict , "resolution" , PyLong_FromLong (34 ));
197
-
198
- return finfo_dict ;
183
+ // Handle the different info types
184
+ switch (info_type ) {
185
+ case NPY_DTYPE_INFO_FLOAT :
186
+ {
187
+ PyObject * finfo_dict = PyDict_New ();
188
+ if (!finfo_dict ) return NULL ;
189
+
190
+ PyDict_SetItemString (finfo_dict , "precision" , PyLong_FromLong (34 ));
191
+ PyDict_SetItemString (finfo_dict , "bits" , PyLong_FromLong (128 ));
192
+ // more fields
193
+ return finfo_dict ;
194
+ }
195
+ case NPY_DTYPE_INFO_INTEGER :
196
+ // Not implemented yet, could add iinfo support later
197
+ PyErr_SetString (PyExc_NotImplementedError ,
198
+ "Integer info not implemented for this dtype" );
199
+ return NULL ;
200
+ case NPY_DTYPE_INFO_GENERIC :
201
+ // Not implemented yet, could add generic info later
202
+ PyErr_SetString (PyExc_NotImplementedError ,
203
+ "Generic info not implemented for this dtype" );
204
+ return NULL ;
205
+ default :
206
+ PyErr_SetString (PyExc_ValueError , "Unknown dtype info type" );
207
+ return NULL ;
208
+ }
199
209
}
200
210
201
211
static PyType_Slot QuadPrecDType_Slots [] = {
@@ -207,7 +217,7 @@ static PyType_Slot QuadPrecDType_Slots[] = {
207
217
{NPY_DT_getitem , & quadprec_getitem },
208
218
{NPY_DT_default_descr , & quadprec_default_descr },
209
219
{NPY_DT_PyArray_ArrFuncs_dotfunc , NULL },
210
- {NPY_DT_get_finfo , & quad_finfo },
220
+ {NPY_DT_get_dtype_info , & quad_finfo },
211
221
{0 , NULL }};
212
222
213
223
static PyObject *
0 commit comments