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

Function AssertRankQuantileNumeric

cpp/src/arrow/compute/kernels/vector_sort_test.cc:2768–2795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2766 }
2767
2768 void AssertRankQuantileNumeric(std::shared_ptr<DataType> type) {
2769 ARROW_SCOPED_TRACE("type = ", type->ToString());
2770 AssertRankQuantileEmpty(type);
2771
2772 // Reproduce the example from https://en.wikipedia.org/wiki/Percentile_rank
2773 SetInput(ArrayFromJSON(type, "[7, 5, 5, 4, 4, 3, 3, 3, 2, 1]"));
2774 for (auto null_placement : AllNullPlacements()) {
2775 AssertRankQuantile(SortOrder::Ascending, null_placement,
2776 "[0.95, 0.8, 0.8, 0.6, 0.6, 0.35, 0.35, 0.35, 0.15, 0.05]");
2777 AssertRankQuantile(SortOrder::Descending, null_placement,
2778 "[0.05, 0.2, 0.2, 0.4, 0.4, 0.65, 0.65, 0.65, 0.85, 0.95]");
2779
2780 AssertRankNormal(SortOrder::Ascending, null_placement,
2781 "[1.6448536269514722, 0.8416212335729143, 0.8416212335729143, "
2782 "0.2533471031357997, 0.2533471031357997, -0.38532046640756773, "
2783 "-0.38532046640756773, -0.38532046640756773, -1.0364333894937898, "
2784 "-1.6448536269514729]");
2785 AssertRankNormal(SortOrder::Descending, null_placement,
2786 "[-1.6448536269514729, -0.8416212335729142, -0.8416212335729142, "
2787 "-0.2533471031357997, -0.2533471031357997, 0.38532046640756773, "
2788 "0.38532046640756773, 0.38532046640756773, 1.0364333894937898, "
2789 "1.6448536269514722]");
2790 }
2791
2792 // With nulls
2793 SetInput(ArrayFromJSON(type, "[null, 1, null, 2, null]"));
2794 AssertRankQuantile_N1N2N();
2795 }
2796
2797 void AssertRankQuantileBinaryLike(std::shared_ptr<DataType> type) {
2798 ARROW_SCOPED_TRACE("type = ", type->ToString());

Callers

nothing calls this directly

Calls 4

ArrayFromJSONFunction · 0.85
AllNullPlacementsFunction · 0.85
AssertRankQuantile_N1N2NFunction · 0.85
ToStringMethod · 0.45

Tested by

no test coverage detected