andishgar commented on PR #47586:
URL: https://github.com/apache/arrow/pull/47586#issuecomment-3378462933
@rok
Here is the complete version of the test.
```c++
TYPED_TEST_P(TestFloatingSparseCOOTensorEquality, TestEquality) {
using ValueType = TypeParam;
using c_value_type = typename ValueType::c_type;
static_assert(is_floating_type<ValueType>::value, "Float type is
required");
std::shared_ptr<SparseCOOTensor> st1, st2, st3;
ASSERT_OK_AND_ASSIGN(st1, SparseCOOTensor::Make(*this->tensor1_));
ASSERT_OK_AND_ASSIGN(st2, SparseCOOTensor::Make(*this->tensor2_));
ASSERT_OK_AND_ASSIGN(st3, SparseCOOTensor::Make(*this->tensor1_));
ASSERT_TRUE(st1->Equals(*st1));
ASSERT_FALSE(st1->Equals(*st2));
ASSERT_TRUE(st1->Equals(*st3));
// sparse tensors with NaNs
const c_value_type nan_value = static_cast<c_value_type>(NAN);
this->values2_[13] = nan_value;
EXPECT_TRUE(std::isnan(this->tensor2_->Value({1, 0, 1})));
std::shared_ptr<SparseCOOTensor> st4;
ASSERT_OK_AND_ASSIGN(st4, SparseCOOTensor::Make(*this->tensor2_));
EXPECT_FALSE(st4->Equals(*st4)); // same
object
EXPECT_TRUE(st4->Equals(*st4, EqualOptions().nans_equal(true))); // same
object
ASSERT_OK_AND_ASSIGN(auto my_tensor,st4->ToTensor());
ASSERT_TRUE(my_tensor->Equals(*this->tensor2_));
std::vector<c_value_type> values5 = this->values2_;
std::shared_ptr<SparseCOOTensor> st5;
std::shared_ptr<Buffer> buffer5 = Buffer::Wrap(values5);
NumericTensor<ValueType> tensor5(buffer5, this->shape_);
ASSERT_OK_AND_ASSIGN(st5, SparseCOOTensor::Make(tensor5));
EXPECT_FALSE(st4->Equals(*st5)); //
different memory
EXPECT_TRUE(st4->Equals(*st5, EqualOptions().nans_equal(true))); //
different memory
}
```
--
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]