()
| 3991 | |
| 3992 | |
| 3993 | def test_rank_options(): |
| 3994 | arr = pa.array([1.2, 0.0, 5.3, None, 5.3, None, 0.0]) |
| 3995 | expected = pa.array([3, 1, 4, 6, 5, 7, 2], type=pa.uint64()) |
| 3996 | |
| 3997 | # Ensure rank can be called without specifying options |
| 3998 | result = pc.rank(arr) |
| 3999 | assert result.equals(expected) |
| 4000 | |
| 4001 | # Ensure default RankOptions |
| 4002 | result = pc.rank(arr, options=pc.RankOptions()) |
| 4003 | assert result.equals(expected) |
| 4004 | |
| 4005 | # Ensure sort_keys tuple usage |
| 4006 | result = pc.rank(arr, options=pc.RankOptions( |
| 4007 | sort_keys=[("b", "ascending", "at_end")]) |
| 4008 | ) |
| 4009 | assert result.equals(expected) |
| 4010 | |
| 4011 | result = pc.rank(arr, sort_keys=[("", "ascending", "at_start")]) |
| 4012 | expected_at_start = pa.array([5, 3, 6, 1, 7, 2, 4], type=pa.uint64()) |
| 4013 | assert result.equals(expected_at_start) |
| 4014 | |
| 4015 | result = pc.rank(arr, sort_keys="descending") |
| 4016 | expected_descending = pa.array([3, 4, 1, 6, 2, 7, 5], type=pa.uint64()) |
| 4017 | assert result.equals(expected_descending) |
| 4018 | |
| 4019 | with pytest.raises(ValueError, |
| 4020 | match=r'"NonExisting" is not a valid tiebreaker'): |
| 4021 | pc.RankOptions(sort_keys=[("", "descending", "at_end")], |
| 4022 | tiebreaker="NonExisting") |
| 4023 | |
| 4024 | |
| 4025 | def test_rank_quantile_options(): |
nothing calls this directly
no test coverage detected