Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jkanche committed Oct 26, 2023
1 parent df20757 commit b05c751
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/biocframe/BiocFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def __delitem__(self, name: str):

self._column_names.remove(name)
if self._mcols is not None:
self._mcols = self._mcols[:, _indices]
self._mcols = self._mcols[_indices, :]

def __len__(self) -> int:
"""Number of rows.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ def test_combine_with_extras():

merged = combine(obj1, obj2)
assert merged.metadata == obj1.metadata
assert merged.mcols.shape == obj1.mcols.shape
assert merged.mcols.shape == obj1.mcols.shape
28 changes: 28 additions & 0 deletions tests/test_initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,31 @@ def test_extra_bits():

bframe.metadata = {"FOO": "A"}
assert bframe.metadata["FOO"] == "A"


def test_with_add_deletions():
obj1 = BiocFrame(
{
"column1": [1, 2, 3],
"column2": [4, 5, 6],
},
mcols=BiocFrame({"foo": [-1, -2], "bar": ["A", "B"]}),
metadata={"YAY": 2},
)

assert isinstance(obj1.mcols, BiocFrame)

obj1["new_column"] = [10, 11, "12"]
assert obj1.shape == (3, 3)
assert len(obj1.mcols) == 3

# welp assume i made a mistake earlier
obj1["new_column"] = [10, 11, 12]
assert obj1.shape == (3, 3)
assert len(obj1.mcols) == 3

# lets delete
del obj1["new_column"]
assert obj1.shape == (3, 2)
print(obj1.mcols)
assert len(obj1.mcols) == 2

0 comments on commit b05c751

Please sign in to comment.