From 17e6747eedbd834e4053affd0fdf6096c3647226 Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Thu, 10 Oct 2024 15:31:05 -0400 Subject: [PATCH] Still skip cudf tests --- tests/test_cudf.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/tests/test_cudf.py b/tests/test_cudf.py index e573df4..c1ef680 100644 --- a/tests/test_cudf.py +++ b/tests/test_cudf.py @@ -1,14 +1,13 @@ import datetime -import pytest - -import pyarrow as pa import awkward as ak +import pyarrow as pa +import pytest -pytest.importorskip("akimbo.cudf") - +import akimbo.cudf import akimbo.io -import cudf + +cudf = pytest.importorskip("cudf") def test_operator_overload(): @@ -40,20 +39,31 @@ def test_inner_slicing(): def test_string_methods(): - s = pa.array([{"s": ["hey", "Ho"], "i": [0]}, {"s": ["Gar", "go"], "i": [2]}], - type=pa.struct([("s", pa.list_(pa.string())), ("i", pa.list_(pa.int32()))])) + s = pa.array( + [{"s": ["hey", "Ho"], "i": [0]}, {"s": ["Gar", "go"], "i": [2]}], + type=pa.struct([("s", pa.list_(pa.string())), ("i", pa.list_(pa.int32()))]), + ) series = cudf.Series(s) s2 = series.ak.str.upper() - assert s2.ak.to_list() == [{"s": ["HEY", "HO"], "i": [0]}, {"s": ["GAR", "GO"], "i": [2]}] + assert s2.ak.to_list() == [ + {"s": ["HEY", "HO"], "i": [0]}, + {"s": ["GAR", "GO"], "i": [2]}, + ] assert series.ak.str.upper.__doc__ # kwargs s2 = series.ak.str.replace(pat="h", repl="B") - assert s2.ak.to_list() == [{"s": ["Bey", "Ho"], "i": [0]}, {"s": ["Gar", "go"], "i": [2]}] + assert s2.ak.to_list() == [ + {"s": ["Bey", "Ho"], "i": [0]}, + {"s": ["Gar", "go"], "i": [2]}, + ] # positional args s2 = series.ak.str.replace("h", "B") - assert s2.ak.to_list() == [{"s": ["Bey", "Ho"], "i": [0]}, {"s": ["Gar", "go"], "i": [2]}] + assert s2.ak.to_list() == [ + {"s": ["Bey", "Ho"], "i": [0]}, + {"s": ["Gar", "go"], "i": [2]}, + ] # non-str output s2 = series.ak.str.len() @@ -63,12 +73,12 @@ def test_string_methods(): def test_cast(): s = cudf.Series([0, 1, 2]) # shows that cast to timestamp needs to be two-step in cudf - s2 = s.ak.cast('m8[s]').ak.cast('M8[s]') + s2 = s.ak.cast("m8[s]").ak.cast("M8[s]") out = s2.ak.to_list() assert out == [ datetime.datetime(1970, 1, 1, 0, 0), datetime.datetime(1970, 1, 1, 0, 0, 1), - datetime.datetime(1970, 1, 1, 0, 0, 2) + datetime.datetime(1970, 1, 1, 0, 0, 2), ] @@ -77,7 +87,7 @@ def test_times(): datetime.datetime(1970, 1, 1, 0, 0), datetime.datetime(1970, 1, 1, 0, 0, 1), None, - datetime.datetime(1970, 1, 1, 0, 0, 2) + datetime.datetime(1970, 1, 1, 0, 0, 2), ] arr = ak.Array([[data], [], [data]]) s = akimbo.io.ak_to_series(arr, "cudf")