Skip to content

Commit 169f2ae

Browse files
committed
array test
1 parent dcd00c1 commit 169f2ae

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

python/tests/test_metadata.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,22 @@ def schema_with_blobs(self, num_blobs):
672672
}
673673
return tskit.MetadataSchema(schema)
674674

675+
def test_round_trip_with_struct_and_json(self):
676+
schema = dict(self.schema_with_blobs(2).schema)
677+
schema["struct"]["properties"]["numbers"] = {
678+
"type": "array",
679+
"arrayLengthFormat": "H",
680+
"items": {"type": "number", "binaryFormat": "i"},
681+
}
682+
ms = tskit.MetadataSchema(schema)
683+
for v in [[], [0, 2, 12], [5] * 1000]:
684+
row = {"label": "abcdef xyz", "count": 7, "b0": 123, "b1": 0, "numbers": v}
685+
encoded = ms.validate_and_encode_row(row)
686+
out = ms.decode_row(encoded)
687+
assert out == row
688+
675689
@pytest.mark.parametrize("k", (0, 1, 5, 1001))
676-
def test_round_trip_with_struct_and_json(self, k):
690+
def test_byte_alignment(self, k):
677691
ms = self.schema_with_blobs(k)
678692
ms0 = self.schema_with_blobs(0)
679693
bytes_per_blob = len(struct.pack("i", 0))

0 commit comments

Comments
 (0)