Skip to content

Commit 0d4b6f7

Browse files
authored
Merge branch 'main' into native-dataframe-sized
2 parents 13ab677 + 5bcdb6e commit 0d4b6f7

File tree

7 files changed

+27
-37
lines changed

7 files changed

+27
-37
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/expr_and_series/list/unique_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
def test_unique_expr(request: pytest.FixtureRequest, constructor: Constructor) -> None:
1717
if any(
1818
backend in str(constructor)
19-
for backend in ("dask", "modin", "cudf", "pyarrow", "pandas", "sqlframe")
19+
for backend in ("dask", "modin", "cudf", "pyarrow", "pandas")
2020
):
21-
# sqlframe issue: https://github.com/eakmanrq/sqlframe/issues/460
2221
request.applymarker(pytest.mark.xfail)
2322
result = (
2423
nw.from_native(constructor(data))

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):

tests/frame/getitem_test.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010
import narwhals as nw
11-
from tests.utils import ConstructorEager, assert_equal_data
11+
from tests.utils import PANDAS_VERSION, ConstructorEager, assert_equal_data
1212

1313
if TYPE_CHECKING:
1414
from narwhals.typing import _1DArray
@@ -301,9 +301,12 @@ def test_triple_tuple(constructor_eager: ConstructorEager) -> None:
301301
def test_slice_with_series(
302302
constructor_eager: ConstructorEager, request: pytest.FixtureRequest
303303
) -> None:
304-
if "pandas_pyarrow" in str(constructor_eager):
305-
# https://github.com/pandas-dev/pandas/issues/61311
306-
request.applymarker(pytest.mark.xfail)
304+
request.applymarker(
305+
pytest.mark.xfail(
306+
"pandas_pyarrow" in str(constructor_eager) and PANDAS_VERSION < (3,),
307+
reason="https://github.com/pandas-dev/pandas/issues/61311",
308+
)
309+
)
307310
data = {"a": [1, 2, 3], "c": [0, 2, 1]}
308311
nw_df = nw.from_native(constructor_eager(data), eager_only=True)
309312
result = nw_df[nw_df["c"]]
@@ -325,9 +328,12 @@ def test_horizontal_slice_with_series(constructor_eager: ConstructorEager) -> No
325328
def test_horizontal_slice_with_series_2(
326329
constructor_eager: ConstructorEager, request: pytest.FixtureRequest
327330
) -> None:
328-
if "pandas_pyarrow" in str(constructor_eager):
329-
# https://github.com/pandas-dev/pandas/issues/61311
330-
request.applymarker(pytest.mark.xfail)
331+
request.applymarker(
332+
pytest.mark.xfail(
333+
"pandas_pyarrow" in str(constructor_eager) and PANDAS_VERSION < (3,),
334+
reason="https://github.com/pandas-dev/pandas/issues/61311",
335+
)
336+
)
331337
data = {"a": [1, 2], "c": [0, 2], "d": ["c", "a"]}
332338
nw_df = nw.from_native(constructor_eager(data), eager_only=True)
333339
result = nw_df[:, nw_df["c"]]

0 commit comments

Comments
 (0)