pitrou commented on code in PR #14378:
URL: https://github.com/apache/arrow/pull/14378#discussion_r994666789
##########
cpp/src/arrow/sparse_tensor_test.cc:
##########
@@ -1676,4 +1676,55 @@ TEST(TestSparseCSFMatrixForUInt64Index, Make) {
ASSERT_RAISES(Invalid, SparseCSFTensor::Make(dense_tensor, uint64()));
}
+//-----------------------------------------------------------------------------
+// Create SparseTensors from a dense Tensor with only zeros
+
+template <typename SparseTensorType>
+class TestSparseTensorFromDenseBase : public ::testing::Test {
+ public:
+ void SetUp() {
+ shape_ = {2, 12};
+ dim_names_ = {"foo", "bar"};
+ dense_values_ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ dense_data_ = Buffer::Wrap(dense_values_);
+ }
+
+ protected:
+ std::vector<int64_t> shape_;
+ std::vector<std::string> dim_names_;
+ std::vector<int64_t> dense_values_;
+ std::shared_ptr<Buffer> dense_data_;
+};
+
+template <typename SparseTensorType>
+class TestSparseTensorFromDense : public
TestSparseTensorFromDenseBase<SparseTensorType> {
+};
+
+TYPED_TEST_SUITE_P(TestSparseTensorFromDense);
+
+TYPED_TEST_P(TestSparseTensorFromDense, TestNonZeroLength) {
Review Comment:
Ok, but is it the situation that the PR is meant to be fixing?
AFAIU, the problem was not when there were no non-zero values, but when the
logical tensor was empty (one of the dimensions in the shape being zero).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]