Skip to content

Commit

Permalink
Fix bug in docstring and inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
sycai committed Sep 4, 2024
1 parent 399a137 commit a7442f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions bigframes/operations/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from __future__ import annotations

import inspect
from typing import Union

import bigframes_vendored.pandas.core.arrays.arrow.accessors as vendoracessors
Expand Down Expand Up @@ -41,3 +42,5 @@ def __getitem__(self, key: Union[int, slice]) -> series.Series:
return self._apply_unary_op(convert_slice(key))
else:
raise ValueError(f"key must be an int or slice, got {type(key).__name__}")

__getitem__.__doc__ = inspect.getdoc(vendoracessors.ListAccessor.__getitem__)
4 changes: 3 additions & 1 deletion bigframes/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
" Try converting it to a remote function."
)

_list = list # Type alias to escape Series.list property


@log_adapter.class_logger
class Series(bigframes.operations.base.SeriesMethods, vendored_pandas_series.Series):
Expand Down Expand Up @@ -1713,7 +1715,7 @@ def to_latex(
buf, columns=columns, header=header, index=index, **kwargs
)

def tolist(self) -> list:
def tolist(self) -> _list:
return self.to_pandas().to_list()

to_list = tolist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ def len(self):
... [1, 2, 3],
... [3],
... ],
... dtype=pd.ArrowDtype(pa.list_(pa.int64())),
... dtype=bpd.ArrowDtype(pa.list_(pa.int64())),
... )
>>> s.list.len()
0 3
1 1
dtype: int32[pyarrow]
dtype: Int64
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

Expand Down Expand Up @@ -69,12 +69,12 @@ def __getitem__(self, key: int | slice):
... [1, 2, 3],
... [3],
... ],
... dtype=pd.ArrowDtype(pa.list_(pa.int64())),
... dtype=bpd.ArrowDtype(pa.list_(pa.int64())),
... )
>>> s.list[0]
0 1
1 3
dtype: int64[pyarrow]
dtype: Int64
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

Expand Down

0 comments on commit a7442f3

Please sign in to comment.