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

Function PyFloat_AsHalf

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

Source from the content-addressed store, hash-verified

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

Callers 1

ConvertMethod · 0.85

Calls 3

FromDoubleFunction · 0.85
has_numpyFunction · 0.85
TypeErrorFunction · 0.50

Tested by

no test coverage detected