Skip to content

Commit

Permalink
replicating the tests from bioc.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jkanche committed Sep 30, 2023
1 parent a3a8a46 commit 70ef05a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/biocframe/BiocFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,26 +770,29 @@ def combine(self, *other: "BiocFrame") -> "BiocFrame":

all_row_names = []
all_num_rows = sum([len(x) for x in all_objects])
all_data = OrderedDict()
for obj in all_objects:
all_data = self.data.copy()
for obj in other:
for ocol in all_unique_columns:
if ocol not in all_data:
all_data[ocol] = [None] * len(obj)

if ocol not in obj.column_names:
all_data[ocol] = [None] * len(obj)
else:
all_data[ocol] = combine(obj.column(ocol), all_data[ocol])
all_data[ocol] = combine(all_data[ocol], obj.column(ocol))

rnames = obj.row_names
if rnames is None:
rnames = [None] * all_num_rows

all_row_names.extend(rnames)

if all(all_row_names) is False:
if all(all_row_names) is False or len(all_row_names) == 0:
all_row_names = None

print("allrownames", all_row_names)
print(all_data)

current_class_const = type(self)
return current_class_const(
all_data,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_method_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ def test_basic_combine_empty():
print(merged)

assert isinstance(merged, BiocFrame)
assert merged.shape[0] == obj1.shape[0] + obj2.shape[0]
assert merged.shape[0] ==15
assert merged.shape[1] == 0

0 comments on commit 70ef05a

Please sign in to comment.