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§
source§impl Clone for Proportion
impl Clone for Proportion
source§fn clone(&self) -> Proportion
fn clone(&self) -> Proportion
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for Proportion
impl Debug for Proportion
source§impl<'de> Deserialize<'de> for Proportion
impl<'de> Deserialize<'de> for Proportion
source§fn 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
source§impl Display for Proportion
impl Display for Proportion
source§impl From<Proportion> for f64
impl From<Proportion> for f64
source§fn from(value: Proportion) -> f64
fn from(value: Proportion) -> f64
Converts to this type from the input type.
source§impl From<f64> for Proportion
impl From<f64> for Proportion
source§impl Ord for Proportion
impl Ord for Proportion
source§impl PartialEq<Proportion> for Proportion
impl PartialEq<Proportion> for Proportion
source§impl PartialEq<Proportion> for f64
impl PartialEq<Proportion> for f64
source§fn eq(&self, other: &Proportion) -> bool
fn eq(&self, other: &Proportion) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl PartialEq<f64> for Proportion
impl PartialEq<f64> for Proportion
source§impl PartialOrd<Proportion> for Proportion
impl PartialOrd<Proportion> for Proportion
1.0.0 · source§fn 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 moresource§impl PartialOrd<Proportion> for f64
impl PartialOrd<Proportion> for f64
source§fn partial_cmp(&self, other: &Proportion) -> Option<Ordering>
fn partial_cmp(&self, other: &Proportion) -> Option<Ordering>
1.0.0 · source§fn 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 moresource§impl PartialOrd<f64> for Proportion
impl PartialOrd<f64> for Proportion
1.0.0 · source§fn 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 moresource§impl 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§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.