MCPcopy Create free account
hub / github.com/numpy/numpy / npy_to_cfloat

Function npy_to_cfloat

numpy/core/src/multiarray/textreading/conversions.c:230–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228
229
230NPY_NO_EXPORT int
231npy_to_cfloat(PyArray_Descr *descr,
232 const Py_UCS4 *str, const Py_UCS4 *end, char *dataptr,
233 parser_config *pconfig)
234{
235 double real;
236 double imag;
237
238 bool success = to_complex_int(
239 str, end, &real, &imag,
240 pconfig->imaginary_unit, true);
241
242 if (!success) {
243 return -1;
244 }
245 npy_complex64 val = {(float)real, (float)imag};
246 memcpy(dataptr, &val, sizeof(npy_complex64));
247 if (!PyArray_ISNBO(descr->byteorder)) {
248 npy_bswap4_unaligned(dataptr);
249 npy_bswap4_unaligned(dataptr + 4);
250 }
251 return 0;
252}
253
254
255NPY_NO_EXPORT int

Callers

nothing calls this directly

Calls 2

to_complex_intFunction · 0.85
npy_bswap4_unalignedFunction · 0.85

Tested by

no test coverage detected