Skip to content

Commit

Permalink
broken to_duration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-b-miller committed Aug 11, 2024
1 parent 28ae041 commit b432495
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions python/cudf/cudf/pylibcudf_tests/test_string_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,49 @@ def timestamp_type(request):
pa.duration("s"),
],
)
def timedelta_type(request):
def duration_type(request):
return request.param


@pytest.fixture(scope="module")
def pa_col():
def pa_timestamp_col():
return pa.array(["2011-01-01", "2011-01-02", "2011-01-03"])


@pytest.fixture(scope="module")
def plc_col(pa_col):
return plc.interop.from_arrow(pa_col)
def pa_duration_col():
return pa.array(["17975 days 12:34:56"])


@pytest.fixture(scope="module")
def plc_timestamp_col(pa_timestamp_col):
return plc.interop.from_arrow(pa_timestamp_col)


@pytest.fixture(scope="module")
def plc_duration_col(pa_duration_col):
return plc.interop.from_arrow(pa_duration_col)


@pytest.mark.parametrize("format", ["%Y-%m-%d"])
def test_to_datetime(pa_col, plc_col, timestamp_type, format):
expect = pa.compute.strptime(pa_col, format, timestamp_type.unit)
def test_to_datetime(
pa_timestamp_col, plc_timestamp_col, timestamp_type, format
):
expect = pa.compute.strptime(pa_timestamp_col, format, timestamp_type.unit)
got = plc.strings.convert.convert_datetime.to_timestamps(
plc_col, plc.interop.from_arrow(timestamp_type), format.encode()
plc_timestamp_col,
plc.interop.from_arrow(timestamp_type),
format.encode(),
)
assert_column_eq(expect, got)


@pytest.mark.parametrize("format", ["%D days %H:%M:%S"])
def test_to_duration(pa_duration_col, plc_duration_col, duration_type, format):
expect = pa.compute.strptime(pa_duration_col, format, duration_type.unit)
got = plc.strings.convert.convert_datetime.to_durations(
plc_duration_col,
plc.interop.from_arrow(duration_type),
format.encode(),
)
assert_column_eq(expect, got)

0 comments on commit b432495

Please sign in to comment.