@@ -1241,17 +1241,7 @@ def verify_mutations(self, ts):
1241
1241
assert ts .num_mutations == len (other_mutations )
1242
1242
assert ts .num_mutations == len (mutations )
1243
1243
for mut , other_mut in zip (mutations , other_mutations ):
1244
- # We cannot compare these directly as the mutations obtained
1245
- # from the mutations iterator will have extra deprecated
1246
- # attributes.
1247
- assert mut .id == other_mut .id
1248
- assert mut .site == other_mut .site
1249
- assert mut .parent == other_mut .parent
1250
- assert mut .node == other_mut .node
1251
- assert mut .metadata == other_mut .metadata
1252
- # Check the deprecated attrs.
1253
- assert mut .position == ts .site (mut .site ).position
1254
- assert mut .index == mut .site
1244
+ assert mut == other_mut
1255
1245
1256
1246
def test_sites_mutations (self ):
1257
1247
# Check that the mutations iterator returns the correct values.
@@ -2103,17 +2093,7 @@ def verify_mutations(self, tree):
2103
2093
assert tree .num_mutations == len (other_mutations )
2104
2094
assert tree .num_mutations == len (mutations )
2105
2095
for mut , other_mut in zip (mutations , other_mutations ):
2106
- # We cannot compare these directly as the mutations obtained
2107
- # from the mutations iterator will have extra deprecated
2108
- # attributes.
2109
- assert mut .id == other_mut .id
2110
- assert mut .site == other_mut .site
2111
- assert mut .parent == other_mut .parent
2112
- assert mut .node == other_mut .node
2113
- assert mut .metadata == other_mut .metadata
2114
- # Check the deprecated attrs.
2115
- assert mut .position == tree .tree_sequence .site (mut .site ).position
2116
- assert mut .index == mut .site
2096
+ assert mut == other_mut
2117
2097
2118
2098
def test_simple_mutations (self ):
2119
2099
tree = self .get_tree ()
@@ -2991,17 +2971,18 @@ def test_metadata(self):
2991
2971
(inst ,) = self .get_instances (1 )
2992
2972
(inst2 ,) = self .get_instances (1 )
2993
2973
assert inst == inst2
2994
- inst ._metadata_decoder = lambda m : "different decoder"
2974
+ inst .metadata
2995
2975
assert inst == inst2
2996
- inst ._encoded_metadata = b "different"
2997
- assert not ( inst == inst2 )
2976
+ inst ._metadata = "different"
2977
+ assert inst != inst2
2998
2978
2999
2979
def test_decoder_run_once (self ):
3000
2980
# For a given instance, the decoded metadata should be cached, with the decoder
3001
2981
# called once
3002
2982
(inst ,) = self .get_instances (1 )
3003
2983
times_run = 0
3004
2984
2985
+ # Hack in a tracing decoder
3005
2986
def decoder (m ):
3006
2987
nonlocal times_run
3007
2988
times_run += 1
@@ -3019,12 +3000,12 @@ class TestIndividualContainer(SimpleContainersMixin, SimpleContainersWithMetadat
3019
3000
def get_instances (self , n ):
3020
3001
return [
3021
3002
tskit .Individual (
3022
- id_ = j ,
3003
+ id = j ,
3023
3004
flags = j ,
3024
3005
location = [j ],
3025
3006
parents = [j ],
3026
3007
nodes = [j ],
3027
- encoded_metadata = b"x" * j ,
3008
+ metadata = b"x" * j ,
3028
3009
metadata_decoder = lambda m : m .decode () + "decoded" ,
3029
3010
)
3030
3011
for j in range (n )
@@ -3035,12 +3016,12 @@ class TestNodeContainer(SimpleContainersMixin, SimpleContainersWithMetadataMixin
3035
3016
def get_instances (self , n ):
3036
3017
return [
3037
3018
tskit .Node (
3038
- id_ = j ,
3019
+ id = j ,
3039
3020
flags = j ,
3040
3021
time = j ,
3041
3022
population = j ,
3042
3023
individual = j ,
3043
- encoded_metadata = b"x" * j ,
3024
+ metadata = b"x" * j ,
3044
3025
metadata_decoder = lambda m : m .decode () + "decoded" ,
3045
3026
)
3046
3027
for j in range (n )
@@ -3055,9 +3036,9 @@ def get_instances(self, n):
3055
3036
right = j ,
3056
3037
parent = j ,
3057
3038
child = j ,
3058
- encoded_metadata = b"x" * j ,
3039
+ metadata = b"x" * j ,
3059
3040
metadata_decoder = lambda m : m .decode () + "decoded" ,
3060
- id_ = j ,
3041
+ id = j ,
3061
3042
)
3062
3043
for j in range (n )
3063
3044
]
@@ -3067,11 +3048,11 @@ class TestSiteContainer(SimpleContainersMixin, SimpleContainersWithMetadataMixin
3067
3048
def get_instances (self , n ):
3068
3049
return [
3069
3050
tskit .Site (
3070
- id_ = j ,
3051
+ id = j ,
3071
3052
position = j ,
3072
3053
ancestral_state = "A" * j ,
3073
3054
mutations = TestMutationContainer ().get_instances (j ),
3074
- encoded_metadata = b"x" * j ,
3055
+ metadata = b"x" * j ,
3075
3056
metadata_decoder = lambda m : m .decode () + "decoded" ,
3076
3057
)
3077
3058
for j in range (n )
@@ -3082,46 +3063,46 @@ class TestMutationContainer(SimpleContainersMixin, SimpleContainersWithMetadataM
3082
3063
def get_instances (self , n ):
3083
3064
return [
3084
3065
tskit .Mutation (
3085
- id_ = j ,
3066
+ id = j ,
3086
3067
site = j ,
3087
3068
node = j ,
3088
3069
time = j ,
3089
3070
derived_state = "A" * j ,
3090
3071
parent = j ,
3091
- encoded_metadata = b"x" * j ,
3072
+ metadata = b"x" * j ,
3092
3073
metadata_decoder = lambda m : m .decode () + "decoded" ,
3093
3074
)
3094
3075
for j in range (n )
3095
3076
]
3096
3077
3097
3078
def test_nan_equality (self ):
3098
3079
a = tskit .Mutation (
3099
- id_ = 42 ,
3080
+ id = 42 ,
3100
3081
site = 42 ,
3101
3082
node = 42 ,
3102
3083
time = UNKNOWN_TIME ,
3103
3084
derived_state = "A" * 42 ,
3104
3085
parent = 42 ,
3105
- encoded_metadata = b"x" * 42 ,
3086
+ metadata = b"x" * 42 ,
3106
3087
metadata_decoder = lambda m : m .decode () + "decoded" ,
3107
3088
)
3108
3089
b = tskit .Mutation (
3109
- id_ = 42 ,
3090
+ id = 42 ,
3110
3091
site = 42 ,
3111
3092
node = 42 ,
3112
3093
derived_state = "A" * 42 ,
3113
3094
parent = 42 ,
3114
- encoded_metadata = b"x" * 42 ,
3095
+ metadata = b"x" * 42 ,
3115
3096
metadata_decoder = lambda m : m .decode () + "decoded" ,
3116
3097
)
3117
3098
c = tskit .Mutation (
3118
- id_ = 42 ,
3099
+ id = 42 ,
3119
3100
site = 42 ,
3120
3101
node = 42 ,
3121
3102
time = math .nan ,
3122
3103
derived_state = "A" * 42 ,
3123
3104
parent = 42 ,
3124
- encoded_metadata = b"x" * 42 ,
3105
+ metadata = b"x" * 42 ,
3125
3106
metadata_decoder = lambda m : m .decode () + "decoded" ,
3126
3107
)
3127
3108
assert a == a
@@ -3139,13 +3120,14 @@ class TestMigrationContainer(SimpleContainersMixin, SimpleContainersWithMetadata
3139
3120
def get_instances (self , n ):
3140
3121
return [
3141
3122
tskit .Migration (
3123
+ id = j ,
3142
3124
left = j ,
3143
3125
right = j ,
3144
3126
node = j ,
3145
3127
source = j ,
3146
3128
dest = j ,
3147
3129
time = j ,
3148
- encoded_metadata = b"x" * j ,
3130
+ metadata = b"x" * j ,
3149
3131
metadata_decoder = lambda m : m .decode () + "decoded" ,
3150
3132
)
3151
3133
for j in range (n )
@@ -3156,8 +3138,8 @@ class TestPopulationContainer(SimpleContainersMixin, SimpleContainersWithMetadat
3156
3138
def get_instances (self , n ):
3157
3139
return [
3158
3140
tskit .Population (
3159
- id_ = j ,
3160
- encoded_metadata = b"x" * j ,
3141
+ id = j ,
3142
+ metadata = b"x" * j ,
3161
3143
metadata_decoder = lambda m : m .decode () + "decoded" ,
3162
3144
)
3163
3145
for j in range (n )
@@ -3167,7 +3149,7 @@ def get_instances(self, n):
3167
3149
class TestProvenanceContainer (SimpleContainersMixin ):
3168
3150
def get_instances (self , n ):
3169
3151
return [
3170
- tskit .Provenance (id_ = j , timestamp = "x" * j , record = "y" * j ) for j in range (n )
3152
+ tskit .Provenance (id = j , timestamp = "x" * j , record = "y" * j ) for j in range (n )
3171
3153
]
3172
3154
3173
3155
0 commit comments