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

Function SparseCOOTensorToNdarray

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

Source from the content-addressed store, hash-verified

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