Skip to content

Commit a526d84

Browse files
committed
First pass
1 parent 74a8f16 commit a526d84

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

python/tests/test_tables.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,20 @@ def test_add_row_round_trip(self):
386386
t2.add_row(**attr.asdict(row))
387387
assert t1 == t2
388388

389+
def test_append_row(self):
390+
for num_rows in [0, 10, 100]:
391+
table = self.table_class()
392+
for j, row in enumerate(self.make_transposed_input_data(num_rows)):
393+
k = table.append(table.row_class(**row))
394+
assert k == j
395+
for colname, input_array in self.make_input_data(num_rows).items():
396+
output_array = getattr(table, colname)
397+
assert input_array.shape == output_array.shape
398+
assert np.all(input_array == output_array)
399+
table.clear()
400+
assert table.num_rows == 0
401+
assert len(table) == 0
402+
389403
def test_set_columns_data(self):
390404
for num_rows in [0, 10, 100, 1000]:
391405
input_data = {col.name: col.get_input(num_rows) for col in self.columns}

python/tskit/tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def __getitem__(self, index):
286286
return self.row_class(*row)
287287

288288
def append(self, row):
289-
return self.ll_table.add_row(**row)
289+
return self.add_row(**attr.asdict(row))
290290

291291
def clear(self):
292292
"""

0 commit comments

Comments
 (0)