Skip to content

Commit 072a1ab

Browse files
committed
test w/o schema
1 parent 15c393c commit 072a1ab

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

python/test_json_metadata.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
import numpy as np
33

44

5-
def setup_ts():
5+
def setup_ts_without_schema():
66
ts = tskit.TreeSequence.load("with_json_metadata.trees")
7+
return ts
8+
9+
10+
def setup_ts_with_schema():
11+
ts = setup_ts_without_schema()
712
tables = ts.tables
813
tables.individuals.metadata_schema = tskit.metadata.MetadataSchema(
914
{
@@ -30,17 +35,37 @@ def test_individual_metadata():
3035
# NOTE: the assertions here rely on knowing
3136
# what examples/json_metadata.rs put into the
3237
# metadata!
33-
ts = setup_ts()
38+
ts = setup_ts_with_schema()
3439
md = ts.individual(0).metadata
3540
assert md["name"] == "Jerome"
3641
assert md["phenotypes"] == [0, 1, 2, 0]
3742

3843

44+
def test_individual_metadata_without_schema():
45+
# NOTE: the assertions here rely on knowing
46+
# what examples/json_metadata.rs put into the
47+
# metadata!
48+
ts = setup_ts_without_schema()
49+
md = eval(ts.individual(0).metadata)
50+
assert md["name"] == "Jerome"
51+
assert md["phenotypes"] == [0, 1, 2, 0]
52+
53+
3954
def test_mutation_metadata():
4055
# NOTE: the assertions here rely on knowing
4156
# what examples/json_metadata.rs put into the
4257
# metadata!
43-
ts = setup_ts()
58+
ts = setup_ts_with_schema()
4459
md = ts.mutation(0).metadata
4560
assert np.isclose(md["effect_size"], -1e-3)
4661
assert np.isclose(md["dominance"], 0.1)
62+
63+
64+
def test_mutation_metadata_without_schema():
65+
# NOTE: the assertions here rely on knowing
66+
# what examples/json_metadata.rs put into the
67+
# metadata!
68+
ts = setup_ts_without_schema()
69+
md = eval(ts.mutation(0).metadata)
70+
assert np.isclose(md["effect_size"], -1e-3)
71+
assert np.isclose(md["dominance"], 0.1)

0 commit comments

Comments
 (0)