Skip to content

Commit

Permalink
test: fixup test suite for cudf.pandas (#1837)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli authored Jan 20, 2025
1 parent 7e6c086 commit 04274b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions narwhals/_pandas_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,11 @@ def native_to_narwhals_dtype(
dtypes = import_dtypes_module(version)

if dtype.startswith(("large_list", "list", "struct", "fixed_size_list")):
if implementation is Implementation.CUDF:
return arrow_native_to_narwhals_dtype(native_column.dtype.to_arrow(), version)
return arrow_native_to_narwhals_dtype(native_column.dtype.pyarrow_dtype, version)
native_dtype = native_column.dtype
if hasattr(native_dtype, "to_arrow"): # pragma: no cover
# cudf, cudf.pandas
return arrow_native_to_narwhals_dtype(native_dtype.to_arrow(), version)
return arrow_native_to_narwhals_dtype(native_dtype.pyarrow_dtype, version)
if dtype != "object":
return non_object_native_to_narwhals_dtype(dtype, version, implementation)
if implementation is Implementation.DASK:
Expand Down
4 changes: 3 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ def assert_equal_data(result: Any, expected: dict[str, Any]) -> None:
result_value = result[key]
for i, (lhs, rhs) in enumerate(zip_strict(result_value, expected_value)):
if isinstance(lhs, float) and not math.isnan(lhs):
are_equivalent_values = math.isclose(lhs, rhs, rel_tol=0, abs_tol=1e-6)
are_equivalent_values = rhs is not None and math.isclose(
lhs, rhs, rel_tol=0, abs_tol=1e-6
)
elif isinstance(lhs, float) and math.isnan(lhs):
are_equivalent_values = rhs is None or math.isnan(rhs)
elif isinstance(rhs, float) and math.isnan(rhs):
Expand Down

0 comments on commit 04274b3

Please sign in to comment.