You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/07/27 02:05:58 UTC

[GitHub] [arrow] liyafan82 commented on a change in pull request #7826: ARROW-9495: [C++] Equality assertions don't handle Inf / -Inf properly

liyafan82 commented on a change in pull request #7826:
URL: https://github.com/apache/arrow/pull/7826#discussion_r460610939



##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -1520,6 +1520,72 @@ void CheckFloatingNanEquality() {
   ASSERT_TRUE(b->RangeEquals(a, 0, 1, 0));
 }
 
+template <typename TYPE>
+void CheckFloatingInfinityEquality() {
+  std::shared_ptr<Array> a, b;
+  std::shared_ptr<DataType> type = TypeTraits<TYPE>::type_singleton();
+
+  const auto infinity = std::numeric_limits<typename TYPE::c_type>::infinity();
+
+  // Infinity in a null entry
+  ArrayFromVector<TYPE>(type, {true, false}, {0.5, infinity}, &a);
+  ArrayFromVector<TYPE>(type, {true, false}, {0.5, -infinity}, &b);
+  ASSERT_TRUE(a->Equals(b));
+  ASSERT_TRUE(b->Equals(a));
+  ASSERT_TRUE(a->ApproxEquals(b));
+  ASSERT_TRUE(b->ApproxEquals(a));
+  ASSERT_TRUE(a->RangeEquals(b, 0, 2, 0));
+  ASSERT_TRUE(b->RangeEquals(a, 0, 2, 0));
+  ASSERT_TRUE(a->RangeEquals(b, 1, 2, 1));
+  ASSERT_TRUE(b->RangeEquals(a, 1, 2, 1));
+
+  // Infinity in a valid entry
+  ArrayFromVector<TYPE>(type, {false, true}, {0.5, infinity}, &a);
+  ArrayFromVector<TYPE>(type, {false, true}, {0.5, infinity}, &b);
+  std::cout << a->ToString() << std::endl;

Review comment:
       Removed. Thanks for your kind reminder. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org