rok commented on a change in pull request #11818:
URL: https://github.com/apache/arrow/pull/11818#discussion_r778307918
##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -1899,6 +1900,71 @@ def test_assume_timezone():
result.equals(pa.array(expected))
+def _check_temporal_rounding(ts, values, unit):
+ unit_shorthand = {
+ "nanosecond": "ns",
+ "microsecond": "us",
+ "millisecond": "L",
+ "second": "s",
+ "minute": "min",
+ "hour": "H",
+ "day": "D"
+ }
+ ta = pa.array(ts)
+
+ for value in values:
+ frequency = str(value) + unit_shorthand[unit]
+ options = pc.RoundTemporalOptions(value, unit)
+
+ result = pc.ceil_temporal(ta, options=options).to_pandas()
+ expected = ts.dt.ceil(frequency)
+ if unit != "nanosecond":
+ np.testing.assert_array_equal(result, expected)
+
+ result = pc.floor_temporal(ta, options=options).to_pandas()
+ expected = ts.dt.floor(frequency)
+ np.testing.assert_array_equal(result, expected)
+
+ result = pc.round_temporal(ta, options=options).to_pandas()
+ expected = ts.dt.round(frequency)
+ np.testing.assert_array_equal(result, expected)
+
+
+# TODO: We should test on windows once ARROW-13168 is resolved.
[email protected](sys.platform == 'win32',
+ reason="Timezone database is not available on Windows yet")
[email protected]('unit', ("nanosecond", "microsecond", "millisecond",
+ "second", "minute", "hour", "day"))
[email protected]
+def test_round_temporal(unit):
+ values = (1, 2, 3, 4, 5, 6, 7, 10, 15, 24, 60, 250, 500, 750)
+ timestamps = [
+ # "1899-04-18 01:57:09.190202880",
+ # "1899-09-12 07:03:30.080325120",
+ # "1904-06-21 20:55:36.493869056",
Review comment:
I think it's that but I'm not 100% and I really want to be :))
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]