@@ -1239,17 +1239,7 @@ def verify_mutations(self, ts):
1239
1239
assert ts .num_mutations == len (other_mutations )
1240
1240
assert ts .num_mutations == len (mutations )
1241
1241
for mut , other_mut in zip (mutations , other_mutations ):
1242
- # We cannot compare these directly as the mutations obtained
1243
- # from the mutations iterator will have extra deprecated
1244
- # attributes.
1245
- assert mut .id == other_mut .id
1246
- assert mut .site == other_mut .site
1247
- assert mut .parent == other_mut .parent
1248
- assert mut .node == other_mut .node
1249
- assert mut .metadata == other_mut .metadata
1250
- # Check the deprecated attrs.
1251
- assert mut .position == ts .site (mut .site ).position
1252
- assert mut .index == mut .site
1242
+ assert mut == other_mut
1253
1243
1254
1244
def test_sites_mutations (self ):
1255
1245
# Check that the mutations iterator returns the correct values.
@@ -2084,17 +2074,7 @@ def verify_mutations(self, tree):
2084
2074
assert tree .num_mutations == len (other_mutations )
2085
2075
assert tree .num_mutations == len (mutations )
2086
2076
for mut , other_mut in zip (mutations , other_mutations ):
2087
- # We cannot compare these directly as the mutations obtained
2088
- # from the mutations iterator will have extra deprecated
2089
- # attributes.
2090
- assert mut .id == other_mut .id
2091
- assert mut .site == other_mut .site
2092
- assert mut .parent == other_mut .parent
2093
- assert mut .node == other_mut .node
2094
- assert mut .metadata == other_mut .metadata
2095
- # Check the deprecated attrs.
2096
- assert mut .position == tree .tree_sequence .site (mut .site ).position
2097
- assert mut .index == mut .site
2077
+ assert mut == other_mut
2098
2078
2099
2079
def test_simple_mutations (self ):
2100
2080
tree = self .get_tree ()
@@ -2948,17 +2928,18 @@ def test_metadata(self):
2948
2928
(inst ,) = self .get_instances (1 )
2949
2929
(inst2 ,) = self .get_instances (1 )
2950
2930
assert inst == inst2
2951
- inst ._metadata_decoder = lambda m : "different decoder"
2931
+ inst .metadata
2952
2932
assert inst == inst2
2953
- inst ._encoded_metadata = b "different"
2954
- assert not ( inst == inst2 )
2933
+ inst ._metadata = "different"
2934
+ assert inst != inst2
2955
2935
2956
2936
def test_decoder_run_once (self ):
2957
2937
# For a given instance, the decoded metadata should be cached, with the decoder
2958
2938
# called once
2959
2939
(inst ,) = self .get_instances (1 )
2960
2940
times_run = 0
2961
2941
2942
+ # Hack in a tracing decoder
2962
2943
def decoder (m ):
2963
2944
nonlocal times_run
2964
2945
times_run += 1
@@ -2976,12 +2957,12 @@ class TestIndividualContainer(SimpleContainersMixin, SimpleContainersWithMetadat
2976
2957
def get_instances (self , n ):
2977
2958
return [
2978
2959
tskit .Individual (
2979
- id_ = j ,
2960
+ id = j ,
2980
2961
flags = j ,
2981
2962
location = [j ],
2982
2963
parents = [j ],
2983
2964
nodes = [j ],
2984
- encoded_metadata = b"x" * j ,
2965
+ metadata = b"x" * j ,
2985
2966
metadata_decoder = lambda m : m .decode () + "decoded" ,
2986
2967
)
2987
2968
for j in range (n )
@@ -2992,12 +2973,12 @@ class TestNodeContainer(SimpleContainersMixin, SimpleContainersWithMetadataMixin
2992
2973
def get_instances (self , n ):
2993
2974
return [
2994
2975
tskit .Node (
2995
- id_ = j ,
2976
+ id = j ,
2996
2977
flags = j ,
2997
2978
time = j ,
2998
2979
population = j ,
2999
2980
individual = j ,
3000
- encoded_metadata = b"x" * j ,
2981
+ metadata = b"x" * j ,
3001
2982
metadata_decoder = lambda m : m .decode () + "decoded" ,
3002
2983
)
3003
2984
for j in range (n )
@@ -3012,9 +2993,9 @@ def get_instances(self, n):
3012
2993
right = j ,
3013
2994
parent = j ,
3014
2995
child = j ,
3015
- encoded_metadata = b"x" * j ,
2996
+ metadata = b"x" * j ,
3016
2997
metadata_decoder = lambda m : m .decode () + "decoded" ,
3017
- id_ = j ,
2998
+ id = j ,
3018
2999
)
3019
3000
for j in range (n )
3020
3001
]
@@ -3024,11 +3005,11 @@ class TestSiteContainer(SimpleContainersMixin, SimpleContainersWithMetadataMixin
3024
3005
def get_instances (self , n ):
3025
3006
return [
3026
3007
tskit .Site (
3027
- id_ = j ,
3008
+ id = j ,
3028
3009
position = j ,
3029
3010
ancestral_state = "A" * j ,
3030
3011
mutations = TestMutationContainer ().get_instances (j ),
3031
- encoded_metadata = b"x" * j ,
3012
+ metadata = b"x" * j ,
3032
3013
metadata_decoder = lambda m : m .decode () + "decoded" ,
3033
3014
)
3034
3015
for j in range (n )
@@ -3039,46 +3020,46 @@ class TestMutationContainer(SimpleContainersMixin, SimpleContainersWithMetadataM
3039
3020
def get_instances (self , n ):
3040
3021
return [
3041
3022
tskit .Mutation (
3042
- id_ = j ,
3023
+ id = j ,
3043
3024
site = j ,
3044
3025
node = j ,
3045
3026
time = j ,
3046
3027
derived_state = "A" * j ,
3047
3028
parent = j ,
3048
- encoded_metadata = b"x" * j ,
3029
+ metadata = b"x" * j ,
3049
3030
metadata_decoder = lambda m : m .decode () + "decoded" ,
3050
3031
)
3051
3032
for j in range (n )
3052
3033
]
3053
3034
3054
3035
def test_nan_equality (self ):
3055
3036
a = tskit .Mutation (
3056
- id_ = 42 ,
3037
+ id = 42 ,
3057
3038
site = 42 ,
3058
3039
node = 42 ,
3059
3040
time = UNKNOWN_TIME ,
3060
3041
derived_state = "A" * 42 ,
3061
3042
parent = 42 ,
3062
- encoded_metadata = b"x" * 42 ,
3043
+ metadata = b"x" * 42 ,
3063
3044
metadata_decoder = lambda m : m .decode () + "decoded" ,
3064
3045
)
3065
3046
b = tskit .Mutation (
3066
- id_ = 42 ,
3047
+ id = 42 ,
3067
3048
site = 42 ,
3068
3049
node = 42 ,
3069
3050
derived_state = "A" * 42 ,
3070
3051
parent = 42 ,
3071
- encoded_metadata = b"x" * 42 ,
3052
+ metadata = b"x" * 42 ,
3072
3053
metadata_decoder = lambda m : m .decode () + "decoded" ,
3073
3054
)
3074
3055
c = tskit .Mutation (
3075
- id_ = 42 ,
3056
+ id = 42 ,
3076
3057
site = 42 ,
3077
3058
node = 42 ,
3078
3059
time = math .nan ,
3079
3060
derived_state = "A" * 42 ,
3080
3061
parent = 42 ,
3081
- encoded_metadata = b"x" * 42 ,
3062
+ metadata = b"x" * 42 ,
3082
3063
metadata_decoder = lambda m : m .decode () + "decoded" ,
3083
3064
)
3084
3065
assert a == a
@@ -3096,13 +3077,14 @@ class TestMigrationContainer(SimpleContainersMixin, SimpleContainersWithMetadata
3096
3077
def get_instances (self , n ):
3097
3078
return [
3098
3079
tskit .Migration (
3080
+ id = j ,
3099
3081
left = j ,
3100
3082
right = j ,
3101
3083
node = j ,
3102
3084
source = j ,
3103
3085
dest = j ,
3104
3086
time = j ,
3105
- encoded_metadata = b"x" * j ,
3087
+ metadata = b"x" * j ,
3106
3088
metadata_decoder = lambda m : m .decode () + "decoded" ,
3107
3089
)
3108
3090
for j in range (n )
@@ -3113,8 +3095,8 @@ class TestPopulationContainer(SimpleContainersMixin, SimpleContainersWithMetadat
3113
3095
def get_instances (self , n ):
3114
3096
return [
3115
3097
tskit .Population (
3116
- id_ = j ,
3117
- encoded_metadata = b"x" * j ,
3098
+ id = j ,
3099
+ metadata = b"x" * j ,
3118
3100
metadata_decoder = lambda m : m .decode () + "decoded" ,
3119
3101
)
3120
3102
for j in range (n )
@@ -3124,7 +3106,7 @@ def get_instances(self, n):
3124
3106
class TestProvenanceContainer (SimpleContainersMixin ):
3125
3107
def get_instances (self , n ):
3126
3108
return [
3127
- tskit .Provenance (id_ = j , timestamp = "x" * j , record = "y" * j ) for j in range (n )
3109
+ tskit .Provenance (id = j , timestamp = "x" * j , record = "y" * j ) for j in range (n )
3128
3110
]
3129
3111
3130
3112
0 commit comments