@@ -3129,31 +3129,6 @@ class TestTableCollection:
3129
3129
Tests for the convenience wrapper around a collection of related tables.
3130
3130
"""
3131
3131
3132
- def add_metadata (self , tc ):
3133
- tc .metadata_schema = tskit .MetadataSchema (
3134
- {
3135
- "codec" : "struct" ,
3136
- "type" : "object" ,
3137
- "properties" : {"top-level" : {"type" : "string" , "binaryFormat" : "50p" }},
3138
- }
3139
- )
3140
- tc .metadata = {"top-level" : "top-level-metadata" }
3141
- for table in tskit .TABLE_NAMES :
3142
- t = getattr (tc , table )
3143
- if hasattr (t , "metadata_schema" ):
3144
- t .packset_metadata (
3145
- [f"{ table } -{ i :10} " .encode () for i in range (t .num_rows )]
3146
- )
3147
- t .metadata_schema = tskit .MetadataSchema (
3148
- {
3149
- "codec" : "struct" ,
3150
- "type" : "object" ,
3151
- "properties" : {
3152
- table : {"type" : "string" , "binaryFormat" : "16p" }
3153
- },
3154
- }
3155
- )
3156
-
3157
3132
def test_table_references (self ):
3158
3133
ts = msprime .simulate (10 , mutation_rate = 2 , random_seed = 1 )
3159
3134
tables = ts .tables
@@ -3965,13 +3940,35 @@ def test_bad_metadata(self):
3965
3940
assert tc ._ll_tables .metadata == b""
3966
3941
3967
3942
3968
- class TestTableCollectionPickle (TestTableCollection ):
3943
+ def add_table_collection_metadata (tc ):
3944
+ tc .metadata_schema = tskit .MetadataSchema (
3945
+ {
3946
+ "codec" : "struct" ,
3947
+ "type" : "object" ,
3948
+ "properties" : {"top-level" : {"type" : "string" , "binaryFormat" : "50p" }},
3949
+ }
3950
+ )
3951
+ tc .metadata = {"top-level" : "top-level-metadata" }
3952
+ for table in tskit .TABLE_NAMES :
3953
+ t = getattr (tc , table )
3954
+ if hasattr (t , "metadata_schema" ):
3955
+ t .packset_metadata ([f"{ table } -{ i :10} " .encode () for i in range (t .num_rows )])
3956
+ t .metadata_schema = tskit .MetadataSchema (
3957
+ {
3958
+ "codec" : "struct" ,
3959
+ "type" : "object" ,
3960
+ "properties" : {table : {"type" : "string" , "binaryFormat" : "16p" }},
3961
+ }
3962
+ )
3963
+
3964
+
3965
+ class TestTableCollectionPickle :
3969
3966
"""
3970
3967
Tests that we can round-trip table collections through pickle.
3971
3968
"""
3972
3969
3973
3970
def verify (self , tables ):
3974
- self . add_metadata (tables )
3971
+ add_table_collection_metadata (tables )
3975
3972
other_tables = pickle .loads (pickle .dumps (tables ))
3976
3973
tables .assert_equals (other_tables )
3977
3974
0 commit comments