Skip to content

Commit 5bcdb6e

Browse files
fix: Allow modin[pyarrow] to use more dtypes (#2950)
Co-authored-by: Francesco Bruzzesi <[email protected]>
1 parent d367019 commit 5bcdb6e

File tree

5 files changed

+13
-28
lines changed

5 files changed

+13
-28
lines changed

narwhals/_pandas_like/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,10 @@ def narwhals_to_native_dtype( # noqa: C901, PLR0912, PLR0915
545545
if isinstance_or_issubclass(
546546
dtype, (dtypes.Struct, dtypes.Array, dtypes.List, dtypes.Time, dtypes.Binary)
547547
):
548-
if implementation is Implementation.PANDAS and backend_version >= (2, 2):
548+
if implementation in {
549+
Implementation.PANDAS,
550+
Implementation.MODIN,
551+
} and Implementation.PANDAS._backend_version() >= (2, 2):
549552
try:
550553
import pandas as pd
551554
import pyarrow as pa # ignore-banned-import # noqa: F401

tests/dtypes_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_2d_array(constructor: Constructor, request: pytest.FixtureRequest) -> N
143143
if condition:
144144
pytest.skip(reason)
145145

146-
if any(x in str(constructor) for x in ("dask", "modin", "cudf", "pyspark")):
146+
if any(x in str(constructor) for x in ("dask", "cudf", "pyspark")):
147147
request.applymarker(
148148
pytest.mark.xfail(
149149
reason="2D array operations not supported in these backends"

tests/expr_and_series/cast_test.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@ def test_cast_datetime_utc(
270270

271271

272272
def test_cast_struct(request: pytest.FixtureRequest, constructor: Constructor) -> None:
273-
if any(
274-
backend in str(constructor) for backend in ("dask", "modin", "cudf", "sqlframe")
275-
):
273+
if any(backend in str(constructor) for backend in ("dask", "cudf", "sqlframe")):
276274
request.applymarker(pytest.mark.xfail)
277275

278276
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):
@@ -328,9 +326,7 @@ def test_cast_time(request: pytest.FixtureRequest, constructor: Constructor) ->
328326
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):
329327
pytest.skip()
330328

331-
if any(
332-
backend in str(constructor) for backend in ("dask", "pyspark", "modin", "cudf")
333-
):
329+
if any(backend in str(constructor) for backend in ("dask", "pyspark", "cudf")):
334330
request.applymarker(pytest.mark.xfail)
335331

336332
data = {"a": [time(12, 0, 0), time(12, 0, 5)]}
@@ -343,7 +339,7 @@ def test_cast_binary(request: pytest.FixtureRequest, constructor: Constructor) -
343339
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):
344340
pytest.skip()
345341

346-
if any(backend in str(constructor) for backend in ("cudf", "dask", "modin")):
342+
if any(backend in str(constructor) for backend in ("cudf", "dask")):
347343
request.applymarker(pytest.mark.xfail)
348344

349345
data = {"a": ["test1", "test2"]}

tests/expr_and_series/list/len_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def test_len_expr(request: pytest.FixtureRequest, constructor: Constructor) -> None:
14-
if any(backend in str(constructor) for backend in ("dask", "modin", "cudf")):
14+
if any(backend in str(constructor) for backend in ("dask", "cudf")):
1515
request.applymarker(pytest.mark.xfail)
1616

1717
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):
@@ -27,7 +27,7 @@ def test_len_expr(request: pytest.FixtureRequest, constructor: Constructor) -> N
2727
def test_len_series(
2828
request: pytest.FixtureRequest, constructor_eager: ConstructorEager
2929
) -> None:
30-
if any(backend in str(constructor_eager) for backend in ("modin", "cudf")):
30+
if "cudf" in str(constructor_eager):
3131
request.applymarker(pytest.mark.xfail)
3232

3333
if "pandas" in str(constructor_eager) and PANDAS_VERSION < (2, 2):

tests/frame/explode_test.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ def test_explode_single_col(
3535
column: str,
3636
expected_values: list[int | None],
3737
) -> None:
38-
if any(
39-
backend in str(constructor)
40-
for backend in ("dask", "modin", "cudf", "pyarrow_table")
41-
):
38+
if any(backend in str(constructor) for backend in ("dask", "cudf", "pyarrow_table")):
4239
request.applymarker(pytest.mark.xfail)
4340

4441
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):
@@ -87,15 +84,7 @@ def test_explode_multiple_cols(
8784
) -> None:
8885
if any(
8986
backend in str(constructor)
90-
for backend in (
91-
"dask",
92-
"modin",
93-
"cudf",
94-
"pyarrow_table",
95-
"duckdb",
96-
"pyspark",
97-
"ibis",
98-
)
87+
for backend in ("dask", "cudf", "pyarrow_table", "duckdb", "pyspark", "ibis")
9988
):
10089
request.applymarker(pytest.mark.xfail)
10190

@@ -114,10 +103,7 @@ def test_explode_multiple_cols(
114103
def test_explode_shape_error(
115104
request: pytest.FixtureRequest, constructor: Constructor
116105
) -> None:
117-
if any(
118-
backend in str(constructor)
119-
for backend in ("dask", "modin", "cudf", "pyarrow_table")
120-
):
106+
if any(backend in str(constructor) for backend in ("dask", "cudf", "pyarrow_table")):
121107
request.applymarker(pytest.mark.xfail)
122108

123109
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):

0 commit comments

Comments
 (0)