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

Function CheckSliceApproxEquals

cpp/src/arrow/array/array_test.cc:2219–2247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2217
2218template <typename TYPE>
2219void CheckSliceApproxEquals() {
2220 using T = typename TYPE::c_type;
2221
2222 const int64_t kSize = 50;
2223 std::vector<T> draws1;
2224 std::vector<T> draws2;
2225
2226 const uint32_t kSeed = 0;
2227 random_real(kSize, kSeed, 0.0, 100.0, &draws1);
2228 random_real(kSize, kSeed + 1, 0.0, 100.0, &draws2);
2229
2230 // Make the draws equal in the sliced segment, but unequal elsewhere (to
2231 // catch not using the slice offset)
2232 for (int64_t i = 10; i < 30; ++i) {
2233 draws2[i] = draws1[i];
2234 }
2235
2236 std::vector<bool> is_valid;
2237 random_is_valid(kSize, 0.1, &is_valid);
2238
2239 std::shared_ptr<Array> array1, array2;
2240 ArrayFromVector<TYPE, T>(is_valid, draws1, &array1);
2241 ArrayFromVector<TYPE, T>(is_valid, draws2, &array2);
2242
2243 std::shared_ptr<Array> slice1 = array1->Slice(10, 20);
2244 std::shared_ptr<Array> slice2 = array2->Slice(10, 20);
2245
2246 ASSERT_TRUE(slice1->ApproxEquals(slice2));
2247}
2248
2249template <typename ArrowType>
2250using NumericArgType = std::conditional_t<is_half_float_type<ArrowType>::value, Float16,

Callers

nothing calls this directly

Calls 4

random_realFunction · 0.85
random_is_validFunction · 0.85
SliceMethod · 0.45
ApproxEqualsMethod · 0.45

Tested by

no test coverage detected