MCPcopy Create free account
hub / github.com/apache/arrow / PyFloat_AsHalf

Function PyFloat_AsHalf

python/pyarrow/src/arrow/python/helpers.cc:84–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84Result<uint16_t> PyFloat_AsHalf(PyObject* obj) {
85 if (PyFloat_Check(obj)) {
86 arrow::util::Float16 half_val =
87 arrow::util::Float16::FromDouble(PyFloat_AsDouble(obj));
88 return half_val.bits();
89 } else if (has_numpy() && PyArray_IsScalar(obj, Half)) {
90 return PyArrayScalar_VAL(obj, Half);
91 } else {
92 return Status::TypeError("conversion to float16 expects a `float` or ",
93 "`np.float16` object, got ", Py_TYPE(obj)->tp_name);
94 }
95}
96
97namespace internal {
98

Callers 1

ConvertMethod · 0.85

Calls 3

FromDoubleFunction · 0.85
has_numpyFunction · 0.85
TypeErrorFunction · 0.50

Tested by

no test coverage detected