lidavidm commented on a change in pull request #11818:
URL: https://github.com/apache/arrow/pull/11818#discussion_r778306321
##########
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:
Oh boy. So, if I'm reading this right, it's rounding using the "modern"
TZ definition instead of the "contemporary" one? Maybe we should just not test
this case then, since this is down to whatever the timezone database for a
system contains…? Or am I misunderstanding.
--
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]