Skip to content

Commit

Permalink
Do not add unnecessary row names (#37)
Browse files Browse the repository at this point in the history
update tests as well
  • Loading branch information
jkanche authored Sep 21, 2023
1 parent a499ca2 commit daca714
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/biocframe/BiocFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def column(self, index_or_name: Union[str, int]) -> Any:
"`index_or_name` must be either an integer index or column name."
)

return self[:, index_or_name]
return self[None, index_or_name]

def row(self, index_or_name: Union[str, int]) -> dict:
"""Access a row by integer position or row name.
Expand All @@ -374,7 +374,7 @@ def row(self, index_or_name: Union[str, int]) -> dict:
"`index_or_name` must be either an integer index or row name."
)

return self[index_or_name, :]
return self[index_or_name, None]

def _slice(
self,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,9 @@ def test_nested_biocFrame():

bframe = BiocFrame(obj)
assert bframe is not None

nested_col = bframe.column("nested")
assert nested_col is not None
assert isinstance(nested_col, BiocFrame)
assert nested_col.row_names is None
assert len(nested_col.column_names) == 3

0 comments on commit daca714

Please sign in to comment.