Struct demes::Proportion
source · [−]#[repr(transparent)]pub struct Proportion(_);
Expand description
An ancestry proportion.
This is a newtype wrapper for f64
.
Interpretation
With respect to a deme in an offspring time step, a proportion is the fraction of ancsestry from a given parental deme.
Examples
In YAML
input
Ancestral proportions of demes
let yaml = "
time_units: generations
description:
An admixed deme appears 100 generations ago.
Its initial ancestry is 90% from ancestor1
and 10% from ancestor2.
demes:
- name: ancestor1
epochs:
- start_size: 50
end_time: 100
- name: ancestor2
epochs:
- start_size: 50
end_time: 100
- name: admixed
ancestors: [ancestor1, ancestor2]
proportions: [0.9, 0.1]
start_time: 100
epochs:
- start_size: 200
";
demes::loads(yaml).unwrap();
Pulse proportions
let yaml = "
time_units: generations
description:
Two demes coexist without migration.
Sixty three (63) generations ago,
deme1 contributes 50% of ancestry
to all individuals born in deme2.
demes:
- name: deme1
epochs:
- start_size: 50
- name: deme2
epochs:
- start_size: 50
pulses:
- sources: [deme1]
dest: deme2
proportions: [0.5]
time: 63
";
demes::loads(yaml).unwrap();
Using rust code
Normally, one only needs to create a Proportion
when
working with GraphBuilder
.
let t = demes::Proportion::from(0.5);
assert_eq!(t, 0.5);
Trait Implementations
sourceimpl Clone for Proportion
impl Clone for Proportion
sourcefn clone(&self) -> Proportion
fn clone(&self) -> Proportion
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Proportion
impl Debug for Proportion
sourceimpl<'de> Deserialize<'de> for Proportion
impl<'de> Deserialize<'de> for Proportion
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for Proportion
impl Display for Proportion
sourceimpl From<Proportion> for f64
impl From<Proportion> for f64
sourcefn from(value: Proportion) -> f64
fn from(value: Proportion) -> f64
Converts to this type from the input type.
sourceimpl From<f64> for Proportion
impl From<f64> for Proportion
sourceimpl Ord for Proportion
impl Ord for Proportion
sourceimpl PartialEq<Proportion> for Proportion
impl PartialEq<Proportion> for Proportion
sourceimpl PartialEq<Proportion> for f64
impl PartialEq<Proportion> for f64
sourceimpl PartialEq<f64> for Proportion
impl PartialEq<f64> for Proportion
sourceimpl PartialOrd<Proportion> for Proportion
impl PartialOrd<Proportion> for Proportion
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<Proportion> for f64
impl PartialOrd<Proportion> for f64
sourcefn partial_cmp(&self, other: &Proportion) -> Option<Ordering>
fn partial_cmp(&self, other: &Proportion) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PartialOrd<f64> for Proportion
impl PartialOrd<f64> for Proportion
sourcefn partial_cmp(&self, other: &f64) -> Option<Ordering>
fn partial_cmp(&self, other: &f64) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for Proportion
impl Serialize for Proportion
impl Copy for Proportion
impl Eq for Proportion
Auto Trait Implementations
impl RefUnwindSafe for Proportion
impl Send for Proportion
impl Sync for Proportion
impl Unpin for Proportion
impl UnwindSafe for Proportion
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.