Skip to content

Commit f662d77

Browse files
benjefferymergify[bot]
authored andcommitted
Fix obsure error if structured metadata is fetched from a NullCodec schema
1 parent f9ce53c commit f662d77

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

python/tests/test_highlevel.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5485,3 +5485,9 @@ def test_array_contents(self, struct_metadata_ts, table_name):
54855485
assert row["name"] == b"name"
54865486
assert row["value"] == 1.0
54875487
assert row["active"]
5488+
5489+
@pytest.mark.parametrize("table_name", metadata_tables)
5490+
def test_error_if_no_schema(self, table_name):
5491+
ts = msprime.simulate(10)
5492+
with pytest.raises(NotImplementedError):
5493+
getattr(ts, f"{table_name}_metadata")

python/tskit/metadata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ def __init__(self, schema: Mapping[str, Any] | None) -> None:
787787
self.encode_row = NOOPCodec({}).encode
788788
self.decode_row = NOOPCodec({}).decode
789789
self.empty_value = b""
790+
self.codec_instance = NOOPCodec({})
790791
else:
791792
try:
792793
TSKITMetadataSchemaValidator.check_schema(schema)

0 commit comments

Comments
 (0)