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

Function SparseCOOTensorToNdarray

python/pyarrow/src/arrow/python/numpy_convert.cc:308–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308Status SparseCOOTensorToNdarray(const std::shared_ptr<SparseCOOTensor>& sparse_tensor,
309 PyObject* base, PyObject** out_data,
310 PyObject** out_coords) {
311 const auto& sparse_index = arrow::internal::checked_cast<const SparseCOOIndex&>(
312 *sparse_tensor->sparse_index());
313
314 // Wrap tensor data
315 OwnedRef result_data;
316 RETURN_NOT_OK(SparseTensorDataToNdarray(
317 *sparse_tensor, {static_cast<npy_intp>(sparse_tensor->non_zero_length()), 1}, base,
318 result_data.ref()));
319
320 // Wrap indices
321 PyObject* result_coords;
322 RETURN_NOT_OK(TensorToNdarray(sparse_index.indices(), base, &result_coords));
323
324 *out_data = result_data.detach();
325 *out_coords = result_coords;
326 return Status::OK();
327}
328
329Status SparseCSXMatrixToNdarray(const std::shared_ptr<SparseTensor>& sparse_tensor,
330 PyObject* base, PyObject** out_data,

Callers

nothing calls this directly

Calls 6

TensorToNdarrayFunction · 0.85
sparse_indexMethod · 0.80
indicesMethod · 0.80
OKFunction · 0.50
non_zero_lengthMethod · 0.45

Tested by

no test coverage detected