Skip to content

Commit 2535f35

Browse files
committed
Merge remote-tracking branch 'upstream/main' into compliant-package
2 parents d509fc9 + 0c9c6d8 commit 2535f35

File tree

7 files changed

+56
-11
lines changed

7 files changed

+56
-11
lines changed

.github/workflows/downstream_tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,43 @@ jobs:
493493
touch tests/utils/__init__.py
494494
pytest tests
495495
timeout-minutes: 15
496+
497+
darts:
498+
strategy:
499+
matrix:
500+
python-version: ["3.11"]
501+
os: ["ubuntu-latest"]
502+
runs-on: ${{ matrix.os }}
503+
steps:
504+
- uses: actions/checkout@v4
505+
- uses: actions/setup-python@v5
506+
with:
507+
python-version: ${{ matrix.python-version }}
508+
- name: Install uv
509+
uses: astral-sh/setup-uv@v5
510+
with:
511+
enable-cache: "true"
512+
cache-suffix: ${{ matrix.python-version }}
513+
cache-dependency-glob: "pyproject.toml"
514+
- name: clone-darts
515+
run: |
516+
git clone https://github.com/unit8co/darts.git --depth=1
517+
cd darts
518+
git log
519+
- name: install-deps
520+
run: |
521+
cd darts
522+
uv pip install -r requirements/core.txt -r requirements/dev.txt --system
523+
- name: install-narwhals-dev
524+
run: |
525+
uv pip uninstall narwhals --system
526+
# TODO(FBruzzesi): Install polars from darts requirements when they introcude it
527+
uv pip install -e ".[polars]" --system
528+
- name: show-deps
529+
run: uv pip freeze
530+
- name: Run tests
531+
run: |
532+
cd darts
533+
pytest darts/tests/test_timeseries.py
534+
pytest darts/tests/test_timeseries_multivariate.py
535+
pytest darts/tests/test_timeseries_static_covariates.py

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ for an up-to-date plan of future work.
110110
Join the party!
111111

112112
- [altair](https://github.com/vega/altair/)
113+
- [darts](https://github.com/unit8co/darts)
113114
- [hierarchicalforecast](https://github.com/Nixtla/hierarchicalforecast)
114115
- [marimo](https://github.com/marimo-team/marimo)
115116
- [panel-graphic-walker](https://github.com/panel-extensions/panel-graphic-walker)

docs/ecosystem.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The following is a non-exhaustive list of libraries and tools that choose to use
66
for their dataframe interoperability needs:
77

88
* [altair](https://github.com/vega/altair/)
9+
* [darts](https://github.com/unit8co/darts)
910
* [hierarchicalforecast](https://github.com/Nixtla/hierarchicalforecast)
1011
* [marimo](https://github.com/marimo-team/marimo)
1112
* [panel-graphic-walker](https://github.com/panel-extensions/panel-graphic-walker)

narwhals/_pandas_like/series.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,8 @@ def ewm_mean(
227227

228228
def scatter(self: Self, indices: int | Sequence[int], values: Any) -> Self:
229229
if isinstance(values, self.__class__):
230-
# .copy() is necessary in some pre-2.2 versions of pandas to avoid
231-
# `values` also getting modified (!)
232-
_, values = align_and_extract_native(self, values)
233230
values = set_index(
234-
values.copy(),
231+
values._native_series,
235232
self._native_series.index[indices],
236233
implementation=self._implementation,
237234
backend_version=self._backend_version,

narwhals/typing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
if TYPE_CHECKING:
1515
from types import ModuleType
16+
from typing import Iterable
17+
from typing import Sized
1618

1719
import numpy as np
1820
from typing_extensions import TypeAlias
@@ -32,8 +34,8 @@ def columns(self) -> Any: ...
3234

3335
def join(self, *args: Any, **kwargs: Any) -> Any: ...
3436

35-
class NativeSeries(Protocol):
36-
def __len__(self) -> int: ...
37+
class NativeSeries(Sized, Iterable[Any], Protocol):
38+
def filter(self, *args: Any, **kwargs: Any) -> Any: ...
3739

3840
class DataFrameLike(Protocol):
3941
def __dataframe__(self, *args: Any, **kwargs: Any) -> Any: ...

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from narwhals.typing import IntoDataFrame
2323
from narwhals.typing import IntoFrame
2424

25-
MIN_PANDAS_NULLABLE_VERSION = (1, 5)
25+
MIN_PANDAS_NULLABLE_VERSION = (2,)
2626

2727
# When testing cudf.pandas in Kaggle, we get an error if we try to run
2828
# python -m cudf.pandas -m pytest --constructors=pandas. This gives us

tests/translate/from_native_test.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,20 @@ def __dataframe__(self) -> None: # pragma: no cover
292292
assert result is mockdf
293293

294294

295-
def test_from_native_altair_array_like() -> None:
295+
def test_from_native_strict_native_series() -> None:
296296
obj: list[int] = [1, 2, 3, 4]
297297
array_like = cast("Iterable[Any]", obj)
298298
not_array_like: Literal[1] = 1
299+
np_array = pl.Series(obj).to_numpy()
299300

300301
with pytest.raises(TypeError, match="got.+list"):
301-
false_positive_native_series = nw.from_native(obj, series_only=True) # noqa: F841
302+
nw.from_native(obj, series_only=True) # type: ignore[call-overload]
302303

303304
with pytest.raises(TypeError, match="got.+list"):
304-
true_negative_iterable = nw.from_native(array_like, series_only=True) # type: ignore[call-overload] # noqa: F841
305+
nw.from_native(array_like, series_only=True) # type: ignore[call-overload]
305306

306307
with pytest.raises(TypeError, match="got.+int"):
307-
true_negative_not_native_series = nw.from_native(not_array_like, series_only=True) # type: ignore[call-overload] # noqa: F841
308+
nw.from_native(not_array_like, series_only=True) # type: ignore[call-overload]
309+
310+
with pytest.raises(TypeError, match="got.+numpy.ndarray"):
311+
nw.from_native(np_array, series_only=True) # type: ignore[call-overload]

0 commit comments

Comments
 (0)