Skip to content

Commit 9ba1cb3

Browse files
committed
close
1 parent 460670c commit 9ba1cb3

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

src/sys/flags.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ macro_rules! bits {
4242
};
4343
}
4444

45+
macro_rules! all {
46+
() => {
47+
pub fn all() -> Self {
48+
Self(RawFlags::MAX)
49+
}
50+
};
51+
}
52+
4553
macro_rules! contains {
4654
() => {
4755
pub fn contains<I>(&self, bit: I) -> bool
@@ -199,6 +207,7 @@ impl SimplificationOptions {
199207
=> filter_individuals, FILTER_INDIVIDUALS);
200208

201209
bits!();
210+
all!();
202211
contains!();
203212
}
204213

@@ -263,6 +272,7 @@ impl TableClearOptions {
263272
/// Set [`CLEAR_PROVENANCE`](crate::TableClearOptions::CLEAR_PROVENANCE)
264273
=> clear_provenance, CLEAR_PROVENANCE);
265274
bits!();
275+
all!();
266276
contains!();
267277
}
268278

@@ -339,6 +349,7 @@ impl TableEqualityOptions {
339349
/// Set [`IGNORE_TIMESTAMPS`](crate::TableEqualityOptions::IGNORE_TIMESTAMPS)
340350
=> ignore_timestamps, IGNORE_TIMESTAMPS);
341351
bits!();
352+
all!();
342353
contains!();
343354
}
344355

@@ -376,6 +387,7 @@ impl TableSortOptions {
376387
/// Set [`NO_CHECK_INTEGRITY`](crate::TableSortOptions::NO_CHECK_INTEGRITY)
377388
=> no_check_integrity, NO_CHECK_INTEGRITY);
378389
bits!();
390+
all!();
379391
contains!();
380392
}
381393

@@ -398,6 +410,7 @@ impl IndividualTableSortOptions {
398410
/// Default behavior.
399411
pub const NONE: RawFlags = 0;
400412
bits!();
413+
all!();
401414
contains!();
402415
}
403416

@@ -449,6 +462,7 @@ impl TreeFlags {
449462
/// Set [`NO_SAMPLE_COUNTS`](crate::TreeFlags::NO_SAMPLE_COUNTS)
450463
=> no_sample_counts, NO_SAMPLE_COUNTS);
451464
bits!();
465+
all!();
452466
contains!();
453467
}
454468

@@ -478,6 +492,7 @@ pub struct TableOutputOptions(RawFlags);
478492

479493
impl TableOutputOptions {
480494
bits!();
495+
all!();
481496
contains!();
482497
}
483498

@@ -517,6 +532,7 @@ impl TreeSequenceFlags {
517532
/// Set [`BUILD_INDEXES`](crate::TreeSequenceFlags::BUILD_INDEXES)
518533
=> build_indexes, BUILD_INDEXES);
519534
bits!();
535+
all!();
520536
contains!();
521537
}
522538

@@ -632,6 +648,7 @@ impl TableIntegrityCheckFlags {
632648
/// Set [`CHECK_TREES`](crate::TableIntegrityCheckFlags::CHECK_TREES)
633649
=> check_trees, CHECK_TREES);
634650
bits!();
651+
all!();
635652
contains!();
636653
}
637654

@@ -673,6 +690,7 @@ impl NodeFlags {
673690
}
674691

675692
bits!();
693+
all!();
676694
contains!();
677695

678696
pub fn toggle(&mut self, bit: tsk_flags_t) {
@@ -708,6 +726,7 @@ impl IndividualFlags {
708726
true
709727
}
710728
bits!();
729+
all!();
711730
contains!();
712731
}
713732

src/table_views.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ mod table_views_tests {
266266
tables.add_node(0, 1.0, -1, -1).unwrap(); // parent
267267
tables.add_edge(0., 100., 1, 0).unwrap();
268268
let ts = tables
269-
.tree_sequence(crate::TreeSequenceFlags::BUILD_INDEXES)
269+
.tree_sequence(crate::TreeSequenceFlags::BUILD_INDEXES.into())
270270
.unwrap();
271271
assert_eq!(ts.edges().num_rows(), 1);
272272
assert_eq!(ts.nodes().num_rows(), 2);

tests/example_flags.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@ fn clip_invalid_flags() {
66
// tskit::SimplificationFlags
77
let f: RawFlags = 1000000;
88

9-
// Creating flags from this value will unset invalid
10-
// bits, meaning the final value != the input value.
9+
// Creating flags from this value will retain invalid
10+
// bits, meaning the final value == the input value.
1111
let simplification_flags = SimplificationOptions::from(f);
1212

13-
assert_ne!(f, simplification_flags.bits());
13+
assert_eq!(f, simplification_flags.bits());
1414
assert!(simplification_flags.is_valid());
15-
16-
// You can skip the unsetting of invalid bits...
17-
let simplification_flags = SimplificationOptions::from_bits_retain(f);
18-
19-
// ... and use this function to check.
20-
assert!(!simplification_flags.is_valid());
2115
}
2216

2317
fn example_node_flags() {

0 commit comments

Comments
 (0)