Skip to content

Commit

Permalink
chore: rename _change_dtypes to _change_version (#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli authored Dec 3, 2024
1 parent 2c8a095 commit 2bab809
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion narwhals/_arrow/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion narwhals/_arrow/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion narwhals/_dask/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion narwhals/_duckdb/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion narwhals/_ibis/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion narwhals/_interchange/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion narwhals/_pandas_like/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion narwhals/_pandas_like/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions narwhals/_polars/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion narwhals/_polars/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
6 changes: 3 additions & 3 deletions narwhals/stable/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests/translate/from_native_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@


class MockDataFrame:
def _change_dtypes(self, _version: Version) -> MockDataFrame:
def _change_version(self, _version: Version) -> MockDataFrame:
return self

def __narwhals_dataframe__(self) -> Any:
return self


class MockLazyFrame:
def _change_dtypes(self, _version: Version) -> MockLazyFrame:
def _change_version(self, _version: Version) -> MockLazyFrame:
return self

def __narwhals_lazyframe__(self) -> Any:
return self


class MockSeries:
def _change_dtypes(self, _version: Version) -> MockSeries:
def _change_version(self, _version: Version) -> MockSeries:
return self

def __narwhals_series__(self) -> Any:
Expand Down

0 comments on commit 2bab809

Please sign in to comment.