pub struct ForwardGraph { /* private fields */ }Expand description
Forward-time representation of a demes::Graph.
Implementations§
Source§impl ForwardGraph
impl ForwardGraph
Sourcepub fn new_discrete_time<F: Into<ForwardTime> + Debug + Copy>(
graph: Graph,
burnin_time: F,
) -> Result<Self, DemesForwardError>
pub fn new_discrete_time<F: Into<ForwardTime> + Debug + Copy>( graph: Graph, burnin_time: F, ) -> Result<Self, DemesForwardError>
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn update_state<F: Into<ForwardTime> + Debug + Copy>(
&mut self,
parental_generation_time: F,
) -> Result<(), DemesForwardError>
pub fn update_state<F: Into<ForwardTime> + Debug + Copy>( &mut self, parental_generation_time: F, ) -> Result<(), DemesForwardError>
Update the internal state of the graph to the parental
generation time parental_generation_time.
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn num_demes_in_model(&self) -> usize
pub fn num_demes_in_model(&self) -> usize
The total number of demes in the graph.
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn ancestry_proportions(&self, offspring_deme: usize) -> Option<&[f64]>
pub fn ancestry_proportions(&self, offspring_deme: usize) -> Option<&[f64]>
The ancestry proporitions for a given offspring deme at the current time.
§Parameters
- offspring_deme: the index of an offspring deme.
§Returns
Some(&[f64])ifoffspring_demeis a valid index and extant offspring demes exist.Noneotherwise.
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn cloning_rates(&self) -> Option<&[CloningRate]>
pub fn cloning_rates(&self) -> Option<&[CloningRate]>
Get cloning rates of all offspring demes.
Returns None if there are no extant offspring
demes.
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn selfing_rates(&self) -> Option<&[SelfingRate]>
pub fn selfing_rates(&self) -> Option<&[SelfingRate]>
Get selfing rates of all offspring demes.
Returns None if there are no extant offspring
demes.
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn last_time_updated(&self) -> Option<ForwardTime>
pub fn last_time_updated(&self) -> Option<ForwardTime>
Obtain the time corresponding to the last
call of ForwardGraph::update_state.
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn end_time(&self) -> ForwardTime
pub fn end_time(&self) -> ForwardTime
Obtain the end time of the model.
Sourcepub fn time_iterator(&self) -> impl Iterator<Item = ForwardTime>
pub fn time_iterator(&self) -> impl Iterator<Item = ForwardTime>
Return an iterator over time values.
The iterator starts at the last updated time and continues until the end time.
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn parental_deme_sizes(&self) -> Option<&[CurrentSize]>
pub fn parental_deme_sizes(&self) -> Option<&[CurrentSize]>
Obtain the sizes of each parental deme.
The length of the slice is equal to the number of demes
in the graph (see ForwardGraph::num_demes_in_model).
Returns None if there are no parental demes at the current time.
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn offspring_deme_sizes(&self) -> Option<&[CurrentSize]>
pub fn offspring_deme_sizes(&self) -> Option<&[CurrentSize]>
Obtain the sizes of each offspring deme.
The length of the slice is equal to the number of demes
in the graph (see ForwardGraph::num_demes_in_model).
Returns None if there are no offspring demes at the current time.
Examples found in repository?
25fn iterate_model(
26 graph: demes::Graph,
27 burnin: i32,
28) -> Result<demes_forward::ForwardTime, Box<dyn std::error::Error>> {
29 // Convert the backwards time model
30 // to a forward-time representation with
31 // some generations of burn-in.
32 //
33 // The forward graph is mutable because
34 // we will update its internal state
35 // during iteration.
36 //
37 // The final argument, None, means to apply
38 // no rounding when converting times into generations.
39 // None is safe for this model, but may not be so generally.
40 // See the demes-rs docs at https://docs.rs/demes for details on rounding methods.
41 //
42 // NOTE: the implementation of rounding in demes is currently an enum.
43 // In the future, it may become a trait, which would break API here
44 // but allow for more flexibility in client code.
45 let mut forward_graph = demes_forward::ForwardGraph::new_discrete_time(graph, burnin)?;
46
47 // Update the internal model state
48 // to parental generation 0, meaning
49 // that the first offspring will have
50 // birth times of generation 1.
51 forward_graph.update_state(0)?;
52
53 for time in forward_graph.time_iterator() {
54 // time refers to a parental generation.
55 // Therefore, when we have iterated to the time point
56 // where the final generation are now parents, there
57 // are no offspring and forward_graph.offspring_deme_sizes()
58 // returns None.
59 if let Some(offspring_deme_sizes) = forward_graph.offspring_deme_sizes() {
60 // Get the parent deme sizes.
61 // Given our previous "if let ...", this statement cannot/should not
62 // return None, and we will panic! if it does.
63 let parental_deme_sizes = forward_graph
64 .parental_deme_sizes()
65 .unwrap_or_else(|| panic!("expected parental deme sizes at time {time}"));
66
67 // The deme size slices have lengths equal to the total
68 // number of demes in the graph.
69 assert_eq!(
70 offspring_deme_sizes.len(),
71 forward_graph.num_demes_in_model()
72 );
73 assert_eq!(
74 parental_deme_sizes.len(),
75 forward_graph.num_demes_in_model()
76 );
77
78 // Get the selfing and cloning rates for each deme.
79 // The order is the same as the order of demes in the graph.
80 // This model has no selfing/cloning, but we include the accesses
81 // for completeness.
82 let selfing_rates = forward_graph
83 .selfing_rates()
84 .unwrap_or_else(|| panic!("expected selfing rates"));
85 let cloning_rates = forward_graph
86 .cloning_rates()
87 .unwrap_or_else(|| panic!("expected cloning rates"));
88
89 assert_eq!(selfing_rates.len(), forward_graph.num_demes_in_model());
90 assert_eq!(cloning_rates.len(), forward_graph.num_demes_in_model());
91
92 // Iterate over offspring deme indexes
93 for (offspring_deme_index, offspring_deme_size) in
94 offspring_deme_sizes.iter().enumerate()
95 {
96 let ancestry_proportions = forward_graph
97 .ancestry_proportions(offspring_deme_index)
98 .unwrap_or_else(|| {
99 panic!(
100 "expected ancestry proportions for offspring deme {offspring_deme_index} at time {time}",
101 )
102 });
103 if offspring_deme_size > &0.0 {
104 // If an the offspring deme is extant (size > 0),
105 // then any ancestral deme with a proportion > 0 must
106 // have size > 0.
107 // Further, the sum of all ancestry proportions into
108 // the offspring deme must sum to ~1.0.
109 assert!((ancestry_proportions.iter().sum::<f64>() - 1.0).abs() <= f64::EPSILON);
110 for (ancestor, proportion) in ancestry_proportions.iter().enumerate() {
111 if proportion > &0.0 {
112 assert!(parental_deme_sizes[ancestor] > 0.0);
113 }
114 // NOTE: is incorrect to assert that the ancestor
115 // size is 0 if the ancestry proportion of that ancestor
116 // into offspring_deme is 0!
117 // The ancestor deme could exist but only as an ancestor
118 // of another offspring deme in the graph.
119 }
120 } else {
121 // An offspring deme with size 0 has no ancestry.
122 assert_eq!(ancestry_proportions.iter().sum::<f64>(), 0.0);
123 }
124 }
125 }
126
127 // Update the internal state to the next time point.
128 forward_graph.update_state(time + 1.into())?;
129 }
130
131 Ok(forward_graph
132 .last_time_updated()
133 .expect("expected Some(ForwardTime)"))
134}Sourcepub fn any_extant_parental_demes(&self) -> bool
pub fn any_extant_parental_demes(&self) -> bool
Return true if there are any extant parental
demes at the current time.
Sourcepub fn any_extant_offspring_demes(&self) -> bool
pub fn any_extant_offspring_demes(&self) -> bool
Return true if there are any extant offspring
demes at the current time.
Sourcepub fn num_extant_parental_demes(&self) -> usize
pub fn num_extant_parental_demes(&self) -> usize
Return the number of extant parental demes at the current time.
Sourcepub fn num_extant_offspring_demes(&self) -> usize
pub fn num_extant_offspring_demes(&self) -> usize
Return the number of extant offspring demes at the current time.
Sourcepub fn size_at<'a, I: Into<DemeId<'a>>, T: Into<BackwardTimeWrapper>>(
&self,
deme: I,
time: T,
) -> Result<Option<CurrentSize>, DemesForwardError>
pub fn size_at<'a, I: Into<DemeId<'a>>, T: Into<BackwardTimeWrapper>>( &self, deme: I, time: T, ) -> Result<Option<CurrentSize>, DemesForwardError>
Obtain the size (number of parental individuals) of a given deme at a given time.
§Parameters
deme: a deme identifiertime: a time
§Returns
Some(DemeSize)if there are parents at the given time.Noneifdemedoes not exist or the deme exists but is not in existence attime.
§Errors
DemesForwardError if the calculation of deme size returns an
invalid demes::DemeSize or if time is not a valid value.
§Notes
- Time is measured backwards in time from 0.0 (inclusive of zero). The reason is that it is usually easier to reason about time in this way.
- Unlike a
demes::Graph, time does not go back in the past to “infinity”. The first parental generation is considered to exist at a time one generation prior to the start of events in the graph plus the burn-in time.
Sourcepub fn deme_size_history<'a, I>(
&self,
deme: I,
) -> Result<impl Iterator<Item = DemeSizeAt>, DemesForwardError>
pub fn deme_size_history<'a, I>( &self, deme: I, ) -> Result<impl Iterator<Item = DemeSizeAt>, DemesForwardError>
Generate an iterator over the size history of a deme.
§Parameters
deme: the index or name of the deme
§Returns
An iterator over instances of DemeSizeAt.
§Errors
This function will return an error if:
demedoes not exist in the graph
§Note
The iterated values are lazily evaluated.
First self is cloned.
Then, the entire model history is iterated over,
and the output data is returned during iteration.
§Panics
- Cloning the graph requires allocations which will panic if the system runs out of memory
Sourcepub fn backwards_start_time(&self) -> Time
pub fn backwards_start_time(&self) -> Time
Return the time in the past when the first generation of the model exists. This time point represents the individuals alive at time zero (forwards in time) who are the ancestors of those individuals born at time 1 of the model.
Sourcepub fn backwards_burn_in_time(&self) -> Time
pub fn backwards_burn_in_time(&self) -> Time
Return the time in the model at the end of any “burn-in”.
§Note
This value is distinct from the burn-in duration.
Instead, this value represents the time when all alive
individuals are the ancestors of the first finite
time in the demes::Graph.
Sourcepub fn time_to_backward<T: Into<ForwardTimeWrapper>>(
&self,
time: T,
) -> Result<Option<Time>, DemesForwardError>
pub fn time_to_backward<T: Into<ForwardTimeWrapper>>( &self, time: T, ) -> Result<Option<Time>, DemesForwardError>
Convert a forward time value (ForwardTime) into a backwards time value
(demes::Time)
§Returns
Noneiftimeis ancestral to the start of the model or more recent than the model’s end.
Sourcepub fn time_to_forward<T: Into<BackwardTimeWrapper>>(
&self,
time: T,
) -> Result<Option<ForwardTime>, DemesForwardError>
pub fn time_to_forward<T: Into<BackwardTimeWrapper>>( &self, time: T, ) -> Result<Option<ForwardTime>, DemesForwardError>
Convert a backwards time value (demes::Time) into a forward time value
(ForwardTime)
§Returns
Noneiftimeis ancestral to the start of the model or more recent than the model’s end.
Sourcepub fn deme_names(&self) -> Box<[&str]>
pub fn deme_names(&self) -> Box<[&str]>
Sourcepub fn demes_graph(&self) -> &Graph
pub fn demes_graph(&self) -> &Graph
Access to the underlying demes::Graph
Trait Implementations§
Source§impl Clone for ForwardGraph
impl Clone for ForwardGraph
Source§fn clone(&self) -> ForwardGraph
fn clone(&self) -> ForwardGraph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more