From e21f96a891a09ca42b4aac1f5ed6c95cb12ba50f Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Tue, 3 Dec 2024 07:50:48 +0000 Subject: [PATCH] chore: rename _change_dtypes to _change_version --- narwhals/_arrow/dataframe.py | 2 +- narwhals/_arrow/series.py | 2 +- narwhals/_dask/dataframe.py | 2 +- narwhals/_duckdb/dataframe.py | 2 +- narwhals/_ibis/dataframe.py | 2 +- narwhals/_interchange/dataframe.py | 2 +- narwhals/_pandas_like/dataframe.py | 2 +- narwhals/_pandas_like/series.py | 2 +- narwhals/_polars/dataframe.py | 4 ++-- narwhals/_polars/series.py | 2 +- narwhals/stable/v1/__init__.py | 6 +++--- tests/translate/from_native_test.py | 6 +++--- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/narwhals/_arrow/dataframe.py b/narwhals/_arrow/dataframe.py index 3f8f96be8..139a865b5 100644 --- a/narwhals/_arrow/dataframe.py +++ b/narwhals/_arrow/dataframe.py @@ -72,7 +72,7 @@ def __narwhals_dataframe__(self: Self) -> Self: def __narwhals_lazyframe__(self: Self) -> Self: return self - def _change_dtypes(self: Self, version: Version) -> Self: + def _change_version(self: Self, version: Version) -> Self: return self.__class__( self._native_frame, backend_version=self._backend_version, version=version ) diff --git a/narwhals/_arrow/series.py b/narwhals/_arrow/series.py index 336a7b1f2..021cc0753 100644 --- a/narwhals/_arrow/series.py +++ b/narwhals/_arrow/series.py @@ -53,7 +53,7 @@ def __init__( self._backend_version = backend_version self._version = version - def _change_dtypes(self: Self, version: Version) -> Self: + def _change_version(self: Self, version: Version) -> Self: return self.__class__( self._native_series, name=self._name, diff --git a/narwhals/_dask/dataframe.py b/narwhals/_dask/dataframe.py index ccdb735a6..98f7745ad 100644 --- a/narwhals/_dask/dataframe.py +++ b/narwhals/_dask/dataframe.py @@ -59,7 +59,7 @@ def __narwhals_namespace__(self) -> DaskNamespace: def __narwhals_lazyframe__(self) -> Self: return self - def _change_dtypes(self, version: Version) -> Self: + def _change_version(self, version: Version) -> Self: return self.__class__( self._native_frame, backend_version=self._backend_version, version=version ) diff --git a/narwhals/_duckdb/dataframe.py b/narwhals/_duckdb/dataframe.py index 59329c737..fd1c436e8 100644 --- a/narwhals/_duckdb/dataframe.py +++ b/narwhals/_duckdb/dataframe.py @@ -141,7 +141,7 @@ def to_pandas(self: Self) -> pd.DataFrame: def to_arrow(self: Self) -> pa.Table: return self._native_frame.arrow() - def _change_dtypes(self: Self, version: Version) -> Self: + def _change_version(self: Self, version: Version) -> Self: return self.__class__(self._native_frame, version=version) def _from_native_frame(self: Self, df: Any) -> Self: diff --git a/narwhals/_ibis/dataframe.py b/narwhals/_ibis/dataframe.py index 0c679f183..454354a7e 100644 --- a/narwhals/_ibis/dataframe.py +++ b/narwhals/_ibis/dataframe.py @@ -121,7 +121,7 @@ def __getattr__(self, attr: str) -> Any: ) raise NotImplementedError(msg) - def _change_dtypes(self: Self, version: Version) -> Self: + def _change_version(self: Self, version: Version) -> Self: return self.__class__(self._native_frame, version=version) def _from_native_frame(self: Self, df: Any) -> Self: diff --git a/narwhals/_interchange/dataframe.py b/narwhals/_interchange/dataframe.py index d1fccf0a4..562ee0749 100644 --- a/narwhals/_interchange/dataframe.py +++ b/narwhals/_interchange/dataframe.py @@ -88,7 +88,7 @@ def __init__(self, df: Any, version: Version) -> None: self._interchange_frame = df.__dataframe__() self._version = version - def _change_dtypes(self: Self, version: Version) -> Self: + def _change_version(self: Self, version: Version) -> Self: return self.__class__( WrapInterchangeFrame(self._interchange_frame), version=version ) diff --git a/narwhals/_pandas_like/dataframe.py b/narwhals/_pandas_like/dataframe.py index f365e9c37..d9c47a184 100644 --- a/narwhals/_pandas_like/dataframe.py +++ b/narwhals/_pandas_like/dataframe.py @@ -101,7 +101,7 @@ def _validate_columns(self, columns: pd.Index) -> None: msg = f"Expected unique column names, got:{msg}" raise ValueError(msg) - def _change_dtypes(self, version: Version) -> Self: + def _change_version(self, version: Version) -> Self: return self.__class__( self._native_frame, implementation=self._implementation, diff --git a/narwhals/_pandas_like/series.py b/narwhals/_pandas_like/series.py index 9c95c146b..e6d4b91e7 100644 --- a/narwhals/_pandas_like/series.py +++ b/narwhals/_pandas_like/series.py @@ -116,7 +116,7 @@ def __getitem__(self, idx: int | slice | Sequence[int]) -> Any | Self: return self._native_series.iloc[idx] return self._from_native_series(self._native_series.iloc[idx]) - def _change_dtypes(self, version: Version) -> Self: + def _change_version(self, version: Version) -> Self: return self.__class__( self._native_series, implementation=self._implementation, diff --git a/narwhals/_polars/dataframe.py b/narwhals/_polars/dataframe.py index d2e2657ce..bf3e1cc29 100644 --- a/narwhals/_polars/dataframe.py +++ b/narwhals/_polars/dataframe.py @@ -64,7 +64,7 @@ def __native_namespace__(self: Self) -> ModuleType: msg = f"Expected polars, got: {type(self._implementation)}" # pragma: no cover raise AssertionError(msg) - def _change_dtypes(self: Self, version: Version) -> Self: + def _change_version(self: Self, version: Version) -> Self: return self.__class__( self._native_frame, backend_version=self._backend_version, version=version ) @@ -369,7 +369,7 @@ def _from_native_frame(self: Self, df: pl.LazyFrame) -> Self: df, backend_version=self._backend_version, version=self._version ) - def _change_dtypes(self: Self, version: Version) -> Self: + def _change_version(self: Self, version: Version) -> Self: return self.__class__( self._native_frame, backend_version=self._backend_version, version=version ) diff --git a/narwhals/_polars/series.py b/narwhals/_polars/series.py index e546f0311..9ba18e2ff 100644 --- a/narwhals/_polars/series.py +++ b/narwhals/_polars/series.py @@ -52,7 +52,7 @@ def __native_namespace__(self: Self) -> ModuleType: msg = f"Expected polars, got: {type(self._implementation)}" # pragma: no cover raise AssertionError(msg) - def _change_dtypes(self: Self, version: Version) -> Self: + def _change_version(self: Self, version: Version) -> Self: return self.__class__( self._native_series, backend_version=self._backend_version, version=version ) diff --git a/narwhals/stable/v1/__init__.py b/narwhals/stable/v1/__init__.py index 39dab17a2..80b3cc753 100644 --- a/narwhals/stable/v1/__init__.py +++ b/narwhals/stable/v1/__init__.py @@ -1166,17 +1166,17 @@ def _stableify( ) -> DataFrame[IntoFrameT] | LazyFrame[IntoFrameT] | Series | Expr | Any: if isinstance(obj, NwDataFrame): return DataFrame( - obj._compliant_frame._change_dtypes(Version.V1), + obj._compliant_frame._change_version(Version.V1), level=obj._level, ) if isinstance(obj, NwLazyFrame): return LazyFrame( - obj._compliant_frame._change_dtypes(Version.V1), + obj._compliant_frame._change_version(Version.V1), level=obj._level, ) if isinstance(obj, NwSeries): return Series( - obj._compliant_series._change_dtypes(Version.V1), + obj._compliant_series._change_version(Version.V1), level=obj._level, ) if isinstance(obj, NwExpr): diff --git a/tests/translate/from_native_test.py b/tests/translate/from_native_test.py index 307589f98..7092ca7cd 100644 --- a/tests/translate/from_native_test.py +++ b/tests/translate/from_native_test.py @@ -32,7 +32,7 @@ class MockDataFrame: - def _change_dtypes(self, _version: Version) -> MockDataFrame: + def _change_version(self, _version: Version) -> MockDataFrame: return self def __narwhals_dataframe__(self) -> Any: @@ -40,7 +40,7 @@ def __narwhals_dataframe__(self) -> Any: class MockLazyFrame: - def _change_dtypes(self, _version: Version) -> MockLazyFrame: + def _change_version(self, _version: Version) -> MockLazyFrame: return self def __narwhals_lazyframe__(self) -> Any: @@ -48,7 +48,7 @@ def __narwhals_lazyframe__(self) -> Any: class MockSeries: - def _change_dtypes(self, _version: Version) -> MockSeries: + def _change_version(self, _version: Version) -> MockSeries: return self def __narwhals_series__(self) -> Any: