Skip to content

Commit

Permalink
fix: move __len__ to DataFrame only (#1053)
Browse files Browse the repository at this point in the history
  • Loading branch information
FBruzzesi authored Sep 23, 2024
1 parent 5281c40 commit 0e26ef6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions narwhals/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ class BaseFrame(Generic[FrameT]):
_compliant_frame: Any
_level: Literal["full", "interchange"]

def __len__(self) -> Any:
return self._compliant_frame.__len__()

def __native_namespace__(self) -> Any:
return self._compliant_frame.__native_namespace__()

Expand Down Expand Up @@ -316,6 +313,9 @@ def __init__(
msg = f"Expected an object which implements `__narwhals_dataframe__`, got: {type(df)}"
raise AssertionError(msg)

def __len__(self) -> Any:
return self._compliant_frame.__len__()

def __array__(self, dtype: Any = None, copy: bool | None = None) -> np.ndarray:
return self._compliant_frame.__array__(dtype, copy=copy)

Expand Down
2 changes: 1 addition & 1 deletion tests/frame/len_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@


def test_len(constructor_eager: Any) -> None:
result = len(nw.from_native(constructor_eager(data)))
result = len(nw.from_native(constructor_eager(data), eager_only=True))
assert result == 4

0 comments on commit 0e26ef6

Please sign in to comment.