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

Function SparseCOOTensorToNdarray

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

Source from the content-addressed store, hash-verified

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