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

Function test_round_temporal_duration

python/pyarrow/tests/test_compute.py:3008–3034  ·  view source on GitHub ↗
(unit, base_frequency, round_frequency)

Source from the content-addressed store, hash-verified

3006)
3007@pytest.mark.pandas
3008def test_round_temporal_duration(unit, base_frequency, round_frequency):
3009 base = pd.Timedelta(base_frequency)
3010 values = pd.Series([
3011 -7 * base,
3012 -4 * base,
3013 -1 * base,
3014 0 * base,
3015 1 * base,
3016 4 * base,
3017 7 * base,
3018 pd.NaT,
3019 ])
3020 arrow_values = pa.array(values)
3021 assert pa.types.is_duration(arrow_values.type)
3022
3023 options = pc.RoundTemporalOptions(4, unit)
3024
3025 for arrow_round, pandas_round in (
3026 (pc.ceil_temporal, values.dt.ceil),
3027 (pc.floor_temporal, values.dt.floor),
3028 (pc.round_temporal, values.dt.round),
3029 ):
3030 result = arrow_round(
3031 arrow_values, options=options
3032 ).to_pandas()
3033 expected = pandas_round(round_frequency)
3034 np.testing.assert_array_equal(result, expected)
3035
3036
3037def test_count():

Callers

nothing calls this directly

Calls 2

RoundTemporalOptionsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected