From e5493e1018cf2929e03437c3928f8ca1e969c260 Mon Sep 17 00:00:00 2001 From: FBruzzesi Date: Sat, 18 Jan 2025 11:26:56 +0100 Subject: [PATCH] fail pyarrow on windows, use replace_time_zone --- narwhals/translate.py | 3 +-- tests/selectors_test.py | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/narwhals/translate.py b/narwhals/translate.py index 6ed82326d..0e49eb204 100644 --- a/narwhals/translate.py +++ b/narwhals/translate.py @@ -687,8 +687,7 @@ def _from_native_impl( # noqa: PLR0915 raise TypeError(msg) return native_object if ( - parse_version(get_dask().__version__) <= (2024, 12, 1) - and get_dask_expr() is None + parse_version(get_dask().__version__) < (2025, 1) and get_dask_expr() is None ): # pragma: no cover msg = "Please install dask-expr" raise ImportError(msg) diff --git a/tests/selectors_test.py b/tests/selectors_test.py index 7286ae563..5066a8bd6 100644 --- a/tests/selectors_test.py +++ b/tests/selectors_test.py @@ -12,6 +12,7 @@ from tests.utils import PYARROW_VERSION from tests.utils import Constructor from tests.utils import assert_equal_data +from tests.utils import is_windows data = { "a": [1, 1, 2], @@ -79,12 +80,11 @@ def test_datetime(constructor: Constructor, request: pytest.FixtureRequest) -> N "pyspark" in str(constructor) or "duckdb" in str(constructor) or "dask" in str(constructor) + or ("pyarrow_table" in str(constructor) and PYARROW_VERSION < (12,)) + or ("pyarrow" in str(constructor) and is_windows()) ): request.applymarker(pytest.mark.xfail) - if "pyarrow_table" in str(constructor) and PYARROW_VERSION < (12,): - request.applymarker(pytest.mark.xfail) - ts1 = datetime(2000, 11, 20, 18, 12, 16, 600000) ts2 = datetime(2020, 10, 30, 10, 20, 25, 123000) @@ -102,14 +102,14 @@ def test_datetime(constructor: Constructor, request: pytest.FixtureRequest) -> N ], *[ nw.col("ts") - .dt.convert_time_zone("Europe/Lisbon") + .dt.replace_time_zone("Europe/Lisbon") .cast(nw.Datetime(time_zone="Europe/Lisbon", time_unit=tu)) .alias(f"ts_lisbon_{tu}") for tu in time_units ], *[ nw.col("ts") - .dt.convert_time_zone("Europe/Berlin") + .dt.replace_time_zone("Europe/Berlin") .cast(nw.Datetime(time_zone="Europe/Berlin", time_unit=tu)) .alias(f"ts_berlin_{tu}") for tu in time_units