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

Function test_round_to_integer

python/pyarrow/tests/test_compute.py:1965–1990  ·  view source on GitHub ↗
(ty)

Source from the content-addressed store, hash-verified

1963
1964@pytest.mark.parametrize("ty", ["round", "round_to_multiple"])
1965def test_round_to_integer(ty):
1966 if ty == "round":
1967 round = pc.round
1968 RoundOptions = partial(pc.RoundOptions, ndigits=0)
1969 elif ty == "round_to_multiple":
1970 round = pc.round_to_multiple
1971 RoundOptions = partial(pc.RoundToMultipleOptions, multiple=1)
1972
1973 values = [3.2, 3.5, 3.7, 4.5, -3.2, -3.5, -3.7, None]
1974 rmode_and_expected = {
1975 "down": [3, 3, 3, 4, -4, -4, -4, None],
1976 "up": [4, 4, 4, 5, -3, -3, -3, None],
1977 "towards_zero": [3, 3, 3, 4, -3, -3, -3, None],
1978 "towards_infinity": [4, 4, 4, 5, -4, -4, -4, None],
1979 "half_down": [3, 3, 4, 4, -3, -4, -4, None],
1980 "half_up": [3, 4, 4, 5, -3, -3, -4, None],
1981 "half_towards_zero": [3, 3, 4, 4, -3, -3, -4, None],
1982 "half_towards_infinity": [3, 4, 4, 5, -3, -4, -4, None],
1983 "half_to_even": [3, 4, 4, 4, -3, -4, -4, None],
1984 "half_to_odd": [3, 3, 4, 5, -3, -3, -4, None],
1985 }
1986 for round_mode, expected in rmode_and_expected.items():
1987 options = RoundOptions(round_mode=round_mode)
1988 result = round(values, options=options)
1989 expected_array = pa.array(expected, type=pa.float64())
1990 assert expected_array.equals(result)
1991
1992
1993@pytest.mark.numpy

Callers

nothing calls this directly

Calls 2

equalsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected