@@ -42,7 +42,7 @@ def test_something(self, ts_fixture):
4242import pytest
4343from pytest import fixture
4444
45- import tskit
45+ from . import tsutil
4646
4747
4848def pytest_addoption (parser ):
@@ -108,74 +108,7 @@ def ts_fixture():
108108 """
109109 A tree sequence with data in all fields
110110 """
111- demography = msprime .Demography ()
112- demography .add_population (name = "A" , initial_size = 10_000 )
113- demography .add_population (name = "B" , initial_size = 5_000 )
114- demography .add_population (name = "C" , initial_size = 1_000 )
115- demography .add_population (name = "D" , initial_size = 500 )
116- demography .add_population (name = "E" , initial_size = 100 )
117- demography .add_population_split (time = 1000 , derived = ["A" , "B" ], ancestral = "C" )
118- ts = msprime .sim_ancestry (
119- samples = {"A" : 10 , "B" : 10 },
120- demography = demography ,
121- sequence_length = 5 ,
122- random_seed = 42 ,
123- recombination_rate = 1 ,
124- record_migrations = True ,
125- record_provenance = True ,
126- )
127- ts = msprime .sim_mutations (ts , rate = 0.001 , random_seed = 42 )
128- tables = ts .dump_tables ()
129- # Add locations to individuals
130- individuals_copy = tables .individuals .copy ()
131- tables .individuals .clear ()
132- for i , individual in enumerate (individuals_copy ):
133- tables .individuals .append (
134- individual .replace (flags = i , location = [i , i + 1 ], parents = [i - 1 , i - 1 ])
135- )
136- # Ensure all columns have unique values
137- nodes_copy = tables .nodes .copy ()
138- tables .nodes .clear ()
139- for i , node in enumerate (nodes_copy ):
140- tables .nodes .append (
141- node .replace (
142- flags = i ,
143- time = node .time + 0.00001 * i ,
144- individual = i % len (tables .individuals ),
145- population = i % len (tables .populations ),
146- )
147- )
148- tables .migrations .add_row (left = 0 , right = 1 , node = 21 , source = 1 , dest = 3 , time = 1001 )
149-
150- # Add metadata
151- for name , table in tables .name_map .items ():
152- if name != "provenances" :
153- table .metadata_schema = tskit .MetadataSchema .permissive_json ()
154- metadatas = [f'{{"foo":"n_{ name } _{ u } "}}' for u in range (len (table ))]
155- metadata , metadata_offset = tskit .pack_strings (metadatas )
156- table .set_columns (
157- ** {
158- ** table .asdict (),
159- "metadata" : metadata ,
160- "metadata_offset" : metadata_offset ,
161- }
162- )
163- tables .metadata_schema = tskit .MetadataSchema .permissive_json ()
164- tables .metadata = "Test metadata"
165- tables .time_units = "Test time units"
166-
167- tables .reference_sequence .metadata_schema = tskit .MetadataSchema .permissive_json ()
168- tables .reference_sequence .metadata = "Test reference metadata"
169- tables .reference_sequence .data = "A" * int (ts .sequence_length )
170- # NOTE: it's unclear whether we'll want to have this set at the same time as
171- # 'data', but it's useful to have something in all columns for now.
172- tables .reference_sequence .url = "http://example.com/a_reference"
173-
174- # Add some more rows to provenance to have enough for testing.
175- for _ in range (3 ):
176- tables .provenances .add_row (record = "A" )
177-
178- return tables .tree_sequence ()
111+ return tsutil .all_fields_ts ()
179112
180113
181114@fixture (scope = "session" )
0 commit comments