@@ -19,7 +19,7 @@ use crate::TableSortOptions;
19
19
use crate :: TreeSequenceFlags ;
20
20
use crate :: TskReturnValue ;
21
21
use crate :: TskitTypeAccess ;
22
- use crate :: { tsk_flags_t, tsk_id_t, tsk_size_t, TSK_NULL } ;
22
+ use crate :: { tsk_flags_t, tsk_id_t, tsk_size_t} ;
23
23
use crate :: { EdgeId , IndividualId , MigrationId , MutationId , NodeId , PopulationId , SiteId } ;
24
24
use ll_bindings:: tsk_table_collection_free;
25
25
@@ -42,7 +42,7 @@ use ll_bindings::tsk_table_collection_free;
42
42
///
43
43
/// // Add node:
44
44
///
45
- /// let rv = tables.add_node(0, 3.2, tskit::TSK_NULL , tskit::TSK_NULL ).unwrap();
45
+ /// let rv = tables.add_node(0, 3.2, tskit::PopulationId::NULL , tskit::IndividualId::NULL ).unwrap();
46
46
///
47
47
/// // Get immutable reference to edge table
48
48
/// let edges = tables.edges();
@@ -656,7 +656,7 @@ impl TableCollection {
656
656
/// the behavior of simplification.
657
657
/// * `idmap`: if `true`, the return value contains a vector equal
658
658
/// in length to the input node table. For each input node,
659
- /// this vector either contains the node's new index or [`TSK_NULL `]
659
+ /// this vector either contains the node's new index or [`NodeId::NULL `]
660
660
/// if the input node is not part of the simplified history.
661
661
pub fn simplify < N : Into < NodeId > > (
662
662
& mut self ,
@@ -666,7 +666,7 @@ impl TableCollection {
666
666
) -> Result < Option < Vec < NodeId > > , TskitError > {
667
667
let mut output_node_map: Vec < NodeId > = vec ! [ ] ;
668
668
if idmap {
669
- output_node_map. resize ( self . nodes ( ) . num_rows ( ) as usize , TSK_NULL . into ( ) ) ;
669
+ output_node_map. resize ( self . nodes ( ) . num_rows ( ) as usize , NodeId :: NULL ) ;
670
670
}
671
671
let rv = unsafe {
672
672
ll_bindings:: tsk_table_collection_simplify (
@@ -746,13 +746,18 @@ impl crate::provenance::Provenance for TableCollection {
746
746
#[ cfg( test) ]
747
747
mod test {
748
748
use super :: * ;
749
- use crate :: TSK_NULL ;
750
749
751
750
fn make_small_table_collection ( ) -> TableCollection {
752
751
let mut tables = TableCollection :: new ( 1000. ) . unwrap ( ) ;
753
- tables. add_node ( 0 , 1.0 , TSK_NULL , TSK_NULL ) . unwrap ( ) ;
754
- tables. add_node ( 0 , 0.0 , TSK_NULL , TSK_NULL ) . unwrap ( ) ;
755
- tables. add_node ( 0 , 0.0 , TSK_NULL , TSK_NULL ) . unwrap ( ) ;
752
+ tables
753
+ . add_node ( 0 , 1.0 , PopulationId :: NULL , IndividualId :: NULL )
754
+ . unwrap ( ) ;
755
+ tables
756
+ . add_node ( 0 , 0.0 , PopulationId :: NULL , IndividualId :: NULL )
757
+ . unwrap ( ) ;
758
+ tables
759
+ . add_node ( 0 , 0.0 , PopulationId :: NULL , IndividualId :: NULL )
760
+ . unwrap ( ) ;
756
761
tables. add_edge ( 0. , 1000. , 0 , 1 ) . unwrap ( ) ;
757
762
tables. add_edge ( 0. , 1000. , 0 , 2 ) . unwrap ( ) ;
758
763
tables. build_index ( ) . unwrap ( ) ;
@@ -997,13 +1002,13 @@ mod test {
997
1002
let mut tables = TableCollection :: new ( 1000. ) . unwrap ( ) ;
998
1003
999
1004
tables
1000
- . add_mutation ( 0 , 0 , crate :: TSK_NULL , 1.123 , Some ( b"pajamas" ) )
1005
+ . add_mutation ( 0 , 0 , MutationId :: NULL , 1.123 , Some ( b"pajamas" ) )
1001
1006
. unwrap ( ) ;
1002
1007
tables
1003
- . add_mutation ( 1 , 1 , crate :: TSK_NULL , 2.123 , None )
1008
+ . add_mutation ( 1 , 1 , MutationId :: NULL , 2.123 , None )
1004
1009
. unwrap ( ) ;
1005
1010
tables
1006
- . add_mutation ( 2 , 2 , crate :: TSK_NULL , 3.123 , Some ( b"more pajamas" ) )
1011
+ . add_mutation ( 2 , 2 , MutationId :: NULL , 3.123 , Some ( b"more pajamas" ) )
1007
1012
. unwrap ( ) ;
1008
1013
let mutations = tables. mutations ( ) ;
1009
1014
assert ! ( close_enough( mutations. time( 0 ) . unwrap( ) , 1.123 ) ) ;
@@ -1012,9 +1017,9 @@ mod test {
1012
1017
assert_eq ! ( mutations. node( 0 ) . unwrap( ) , 0 ) ;
1013
1018
assert_eq ! ( mutations. node( 1 ) . unwrap( ) , 1 ) ;
1014
1019
assert_eq ! ( mutations. node( 2 ) . unwrap( ) , 2 ) ;
1015
- assert_eq ! ( mutations. parent( 0 ) . unwrap( ) , crate :: TSK_NULL ) ;
1016
- assert_eq ! ( mutations. parent( 1 ) . unwrap( ) , crate :: TSK_NULL ) ;
1017
- assert_eq ! ( mutations. parent( 2 ) . unwrap( ) , crate :: TSK_NULL ) ;
1020
+ assert_eq ! ( mutations. parent( 0 ) . unwrap( ) , MutationId :: NULL ) ;
1021
+ assert_eq ! ( mutations. parent( 1 ) . unwrap( ) , MutationId :: NULL ) ;
1022
+ assert_eq ! ( mutations. parent( 2 ) . unwrap( ) , MutationId :: NULL ) ;
1018
1023
assert_eq ! ( mutations. derived_state( 0 ) . unwrap( ) . unwrap( ) , b"pajamas" ) ;
1019
1024
1020
1025
if mutations. derived_state ( 1 ) . unwrap ( ) . is_some ( ) {
@@ -1099,7 +1104,7 @@ mod test {
1099
1104
. add_mutation_with_metadata (
1100
1105
0 ,
1101
1106
0 ,
1102
- crate :: TSK_NULL ,
1107
+ MutationId :: NULL ,
1103
1108
1.123 ,
1104
1109
None ,
1105
1110
Some ( & F { x : -3 , y : 666 } ) ,
@@ -1126,15 +1131,15 @@ mod test {
1126
1131
. add_mutation_with_metadata (
1127
1132
0 ,
1128
1133
0 ,
1129
- crate :: TSK_NULL ,
1134
+ MutationId :: NULL ,
1130
1135
1.123 ,
1131
1136
None ,
1132
1137
Some ( & F { x : -3 , y : 666 } ) ,
1133
1138
)
1134
1139
. unwrap ( ) ;
1135
1140
1136
1141
tables
1137
- . add_mutation_with_metadata ( 1 , 2 , crate :: TSK_NULL , 2.0 , None , None )
1142
+ . add_mutation_with_metadata ( 1 , 2 , MutationId :: NULL , 2.0 , None , None )
1138
1143
. unwrap ( ) ;
1139
1144
1140
1145
let mut num_with_metadata = 0 ;
@@ -1167,7 +1172,7 @@ mod test {
1167
1172
assert_eq ! ( tables. populations( ) . num_rows( ) , 1 ) ;
1168
1173
1169
1174
tables
1170
- . add_node ( crate :: TSK_NODE_IS_SAMPLE , 0.0 , pop_id, crate :: TSK_NULL )
1175
+ . add_node ( crate :: TSK_NODE_IS_SAMPLE , 0.0 , pop_id, IndividualId :: NULL )
1171
1176
. unwrap ( ) ;
1172
1177
1173
1178
match tables. nodes ( ) . row ( NodeId :: from ( 0 ) ) {
@@ -1185,10 +1190,10 @@ mod test {
1185
1190
let mut tables = TableCollection :: new ( 1000. ) . unwrap ( ) ;
1186
1191
let pop_id = tables. add_population ( ) . unwrap ( ) ;
1187
1192
tables
1188
- . add_node ( crate :: TSK_NODE_IS_SAMPLE , 0.0 , pop_id, crate :: TSK_NULL )
1193
+ . add_node ( crate :: TSK_NODE_IS_SAMPLE , 0.0 , pop_id, IndividualId :: NULL )
1189
1194
. unwrap ( ) ;
1190
1195
tables
1191
- . add_node ( crate :: TSK_NODE_IS_SAMPLE , 1.0 , pop_id, crate :: TSK_NULL )
1196
+ . add_node ( crate :: TSK_NODE_IS_SAMPLE , 1.0 , pop_id, IndividualId :: NULL )
1192
1197
. unwrap ( ) ;
1193
1198
tables. add_edge ( 0. , tables. sequence_length ( ) , 1 , 0 ) . unwrap ( ) ;
1194
1199
tables
@@ -1286,7 +1291,7 @@ mod test_bad_metadata {
1286
1291
let mut tables = TableCollection :: new ( 1. ) . unwrap ( ) ;
1287
1292
let md = F { x : 1 , y : 11 } ;
1288
1293
tables
1289
- . add_mutation_with_metadata ( 0 , 0 , crate :: TSK_NULL , 0.0 , None , Some ( & md) )
1294
+ . add_mutation_with_metadata ( 0 , 0 , MutationId :: NULL , 0.0 , None , Some ( & md) )
1290
1295
. unwrap ( ) ;
1291
1296
if tables. mutations ( ) . metadata :: < Ff > ( 0 . into ( ) ) . is_ok ( ) {
1292
1297
panic ! ( "expected an error!!" ) ;
@@ -1307,26 +1312,26 @@ mod test_adding_node {
1307
1312
fn test_adding_node_without_metadata ( ) {
1308
1313
let mut tables = make_empty_table_collection ( 10. ) ;
1309
1314
1310
- match tables. add_node ( 0 , 0.0 , TSK_NULL , TSK_NULL ) {
1315
+ match tables. add_node ( 0 , 0.0 , PopulationId :: NULL , IndividualId :: NULL ) {
1311
1316
Ok ( NodeId ( 0 ) ) => ( ) ,
1312
1317
_ => panic ! ( "Expected NodeId(0)" ) ,
1313
1318
} ;
1314
1319
1315
1320
let row = tables. nodes ( ) . row ( NodeId :: from ( 0 ) ) . unwrap ( ) ;
1316
1321
1317
1322
assert_eq ! ( row. id, NodeId :: from( 0 ) ) ;
1318
- assert_eq ! ( row. population, PopulationId :: from ( TSK_NULL ) ) ;
1319
- assert_eq ! ( row. individual, IndividualId :: from ( TSK_NULL ) ) ;
1323
+ assert_eq ! ( row. population, PopulationId :: NULL ) ;
1324
+ assert_eq ! ( row. individual, IndividualId :: NULL ) ;
1320
1325
assert ! ( row. metadata. is_none( ) ) ;
1321
1326
1322
1327
let row_id = tables
1323
- . add_node ( 0 , 0.0 , PopulationId :: from ( 2 ) , TSK_NULL )
1328
+ . add_node ( 0 , 0.0 , PopulationId :: from ( 2 ) , IndividualId :: NULL )
1324
1329
. unwrap ( ) ;
1325
1330
1326
1331
assert_eq ! ( tables. nodes( ) . population( row_id) . unwrap( ) , PopulationId ( 2 ) ) ;
1327
1332
assert_eq ! (
1328
1333
tables. nodes( ) . individual( row_id) . unwrap( ) ,
1329
- IndividualId ( TSK_NULL )
1334
+ IndividualId :: NULL ,
1330
1335
) ;
1331
1336
assert ! ( tables
1332
1337
. nodes( )
@@ -1343,12 +1348,12 @@ mod test_adding_node {
1343
1348
. is_ok( ) ) ;
1344
1349
1345
1350
let row_id = tables
1346
- . add_node ( 0 , 0.0 , TSK_NULL , IndividualId :: from ( 17 ) )
1351
+ . add_node ( 0 , 0.0 , PopulationId :: NULL , IndividualId :: from ( 17 ) )
1347
1352
. unwrap ( ) ;
1348
1353
1349
1354
assert_eq ! (
1350
1355
tables. nodes( ) . population( row_id) . unwrap( ) ,
1351
- PopulationId ( TSK_NULL )
1356
+ PopulationId :: NULL ,
1352
1357
) ;
1353
1358
assert_eq ! ( tables. nodes( ) . individual( row_id) . unwrap( ) , IndividualId ( 17 ) ) ;
1354
1359
@@ -1391,7 +1396,7 @@ mod test_adding_individual {
1391
1396
#[ test]
1392
1397
fn test_adding_individual_without_metadata ( ) {
1393
1398
let mut tables = make_empty_table_collection ( 10. ) ;
1394
- match tables. add_individual ( 0 , & [ 0. , 0. , 0. ] , & [ TSK_NULL , TSK_NULL ] ) {
1399
+ match tables. add_individual ( 0 , & [ 0. , 0. , 0. ] , & [ IndividualId :: NULL , IndividualId :: NULL ] ) {
1395
1400
Ok ( IndividualId ( 0 ) ) => ( ) ,
1396
1401
_ => panic ! ( "Expected NodeId(0)" ) ,
1397
1402
} ;
@@ -1403,7 +1408,7 @@ mod test_adding_individual {
1403
1408
1404
1409
assert_eq ! (
1405
1410
row. parents,
1406
- Some ( vec![ IndividualId ( TSK_NULL ) , IndividualId ( TSK_NULL ) , ] )
1411
+ Some ( vec![ IndividualId :: NULL , IndividualId :: NULL , ] )
1407
1412
) ;
1408
1413
1409
1414
// Empty slices are a thing, causing None to be in the rows.
0 commit comments