File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed
Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ pub struct TableCollection(TskBox<tsk_table_collection_t>);
1616
1717impl TableCollection {
1818 pub fn new ( sequence_length : f64 ) -> Result < Self , TskitError > {
19+ if !sequence_length. is_finite ( ) || sequence_length <= 0.0 {
20+ return Err ( TskitError :: ValueError {
21+ got : sequence_length. to_string ( ) ,
22+ expected : "sequence_length >= 0.0" . to_string ( ) ,
23+ } ) ;
24+ }
1925 let mut tsk = TskBox :: new ( |tc : * mut tsk_table_collection_t | unsafe {
2026 tsk_table_collection_init ( tc, 0 )
2127 } ) ?;
Original file line number Diff line number Diff line change @@ -87,14 +87,7 @@ impl TableCollection {
8787 /// let tables = tskit::TableCollection::new(-55.0).unwrap();
8888 /// ```
8989 pub fn new < P : Into < Position > > ( sequence_length : P ) -> Result < Self , TskitError > {
90- let sequence_length = sequence_length. into ( ) ;
91- if sequence_length <= 0. {
92- return Err ( TskitError :: ValueError {
93- got : f64:: from ( sequence_length) . to_string ( ) ,
94- expected : "sequence_length >= 0.0" . to_string ( ) ,
95- } ) ;
96- }
97- let mut inner = LLTableCollection :: new ( sequence_length. into ( ) ) ?;
90+ let mut inner = LLTableCollection :: new ( sequence_length. into ( ) . into ( ) ) ?;
9891 let views = crate :: table_views:: TableViews :: new_from_ll_table_collection ( & mut inner) ?;
9992 Ok ( Self {
10093 inner,
You can’t perform that action at this time.
0 commit comments