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

Function CheckSliceApproxEquals

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

Source from the content-addressed store, hash-verified

2279
2280template <typename TYPE>
2281void CheckSliceApproxEquals() {
2282 using T = typename TYPE::c_type;
2283
2284 const int64_t kSize = 50;
2285 std::vector<T> draws1;
2286 std::vector<T> draws2;
2287
2288 const uint32_t kSeed = 0;
2289 random_real(kSize, kSeed, 0.0, 100.0, &draws1);
2290 random_real(kSize, kSeed + 1, 0.0, 100.0, &draws2);
2291
2292 // Make the draws equal in the sliced segment, but unequal elsewhere (to
2293 // catch not using the slice offset)
2294 for (int64_t i = 10; i < 30; ++i) {
2295 draws2[i] = draws1[i];
2296 }
2297
2298 std::vector<bool> is_valid;
2299 random_is_valid(kSize, 0.1, &is_valid);
2300
2301 std::shared_ptr<Array> array1, array2;
2302 ArrayFromVector<TYPE, T>(is_valid, draws1, &array1);
2303 ArrayFromVector<TYPE, T>(is_valid, draws2, &array2);
2304
2305 std::shared_ptr<Array> slice1 = array1->Slice(10, 20);
2306 std::shared_ptr<Array> slice2 = array2->Slice(10, 20);
2307
2308 ASSERT_TRUE(slice1->ApproxEquals(slice2));
2309}
2310
2311template <typename ArrowType>
2312using 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