Skip to content

Commit

Permalink
Value of data is Any. (#30)
Browse files Browse the repository at this point in the history
* Value of `data` is `Any`.

* Update tests
  • Loading branch information
jkanche authored Sep 19, 2023
1 parent a817d93 commit 0e9fd41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/biocframe/BiocFrame.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import OrderedDict
from typing import List, MutableMapping, Optional, Sequence, Tuple, Union
from typing import Any, List, MutableMapping, Optional, Sequence, Tuple, Union

from pandas.api.types import is_numeric_dtype
from prettytable import PrettyTable
Expand Down Expand Up @@ -88,7 +88,7 @@ class BiocFrame:
sliced_bframe = bframe[1:2, [True, False, False]]
Attributes:
data (MutableMapping[str, Union[Sequence, MutableMapping]], optional):
data (MutableMapping[str, Any], optional):
Dictionary of column names as `keys` and their values. all columns must have
the same length. Defaults to None.
number_of_rows (int, optional): Number of rows. Defaults to None.
Expand All @@ -103,7 +103,7 @@ class BiocFrame:

def __init__(
self,
data: Optional[MutableMapping[str, Union[Sequence, MutableMapping]]] = None,
data: Optional[MutableMapping[str, Any]] = None,
number_of_rows: Optional[int] = None,
row_names: Optional[Sequence[str]] = None,
column_names: Optional[Sequence[str]] = None,
Expand Down Expand Up @@ -222,11 +222,11 @@ def row_names(self, names: Optional[Sequence]):
self._row_names = names

@property
def data(self) -> MutableMapping[str, Union[Sequence, MutableMapping]]:
def data(self) -> MutableMapping[str, Any]:
"""Access data as :py:class:`dict`.
Returns:
MutableMapping[str, Union[Sequence, MutableMapping]]:
MutableMapping[str, Any]:
Dictionary of columns and their values.
"""
return self._data
Expand Down Expand Up @@ -306,7 +306,7 @@ def has_column(self, name: str) -> bool:
"""
return name in self.column_names

def column(self, index_or_name: Union[str, int]) -> Union[Sequence, MutableMapping]:
def column(self, index_or_name: Union[str, int]) -> Any:
"""Access a column by integer position or column label.
Args:
Expand All @@ -322,7 +322,7 @@ def column(self, index_or_name: Union[str, int]) -> Union[Sequence, MutableMappi
TypeError: if ``index_or_name`` is neither a string nor an integer.
Returns:
Union[Sequence, MutableMapping]: Column with its original type preserved.
Any: Column with its original type preserved.
"""

return self[:, index_or_name]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_bframe_basic_ops():
assert bframe.column_names is not None
assert len(bframe.column_names) == 3

assert bframe.metadata is None
assert bframe.metadata == {}

assert len(bframe.dims) == 2
assert bframe.dims == (3, 3)
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_bframe_setters():
assert bframe.column_names is not None
assert len(bframe.column_names) == 3

assert bframe.metadata is None
assert bframe.metadata == {}

bframe.metadata = {"a": "b"}
assert bframe.metadata is not None
Expand Down

0 comments on commit 0e9fd41

Please sign in to comment.