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

Function test_rank_quantile_options

python/pyarrow/tests/test_compute.py:4025–4052  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4023
4024
4025def test_rank_quantile_options():
4026 arr = pa.array([None, 1, None, 2, None])
4027 expected = pa.array([0.7, 0.1, 0.7, 0.3, 0.7], type=pa.float64())
4028
4029 # Ensure rank_quantile can be called without specifying options
4030 result = pc.rank_quantile(arr)
4031 assert result.equals(expected)
4032
4033 # Ensure default RankOptions
4034 result = pc.rank_quantile(arr, options=pc.RankQuantileOptions())
4035 assert result.equals(expected)
4036
4037 # Ensure sort_keys tuple usage
4038 result = pc.rank_quantile(arr, options=pc.RankQuantileOptions(
4039 sort_keys=[("b", "ascending")])
4040 )
4041 assert result.equals(expected)
4042
4043 result = pc.rank_quantile(arr, sort_keys=[("", "ascending", "at_start")])
4044 expected_at_start = pa.array([0.3, 0.7, 0.3, 0.9, 0.3], type=pa.float64())
4045 assert result.equals(expected_at_start)
4046
4047 result = pc.rank_quantile(arr, sort_keys="descending")
4048 expected_descending = pa.array([0.7, 0.3, 0.7, 0.1, 0.7], type=pa.float64())
4049 assert result.equals(expected_descending)
4050
4051 with pytest.raises(ValueError, match="not a valid sort order"):
4052 pc.rank_quantile(arr, sort_keys="XXX")
4053
4054
4055def test_rank_normal_options():

Callers

nothing calls this directly

Calls 3

equalsMethod · 0.80
RankQuantileOptionsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected