Struct demes::Proportion
source · #[repr(transparent)]pub struct Proportion(/* private fields */);
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
let t = demes::Proportion::try_from(0.5).unwrap();
assert_eq!(t, 0.5);
Trait Implementations§
source§impl Add<Proportion> for Proportion
impl Add<Proportion> for Proportion
source§impl Add<Proportion> for f64
impl Add<Proportion> for f64
§type Output = Option<Proportion>
type Output = Option<Proportion>
The resulting type after applying the
+
operator.source§impl Add<f64> for Proportion
impl Add<f64> for Proportion
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 Div<Proportion> for Proportion
impl Div<Proportion> for Proportion
source§impl Div<Proportion> for f64
impl Div<Proportion> for f64
§type Output = Option<Proportion>
type Output = Option<Proportion>
The resulting type after applying the
/
operator.source§impl Div<f64> for Proportion
impl Div<f64> 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 Mul<Proportion> for Proportion
impl Mul<Proportion> for Proportion
source§impl Mul<Proportion> for f64
impl Mul<Proportion> for f64
§type Output = Option<Proportion>
type Output = Option<Proportion>
The resulting type after applying the
*
operator.source§impl Mul<f64> for Proportion
impl Mul<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
source§impl Sub<Proportion> for Proportion
impl Sub<Proportion> for Proportion
source§impl Sub<Proportion> for f64
impl Sub<Proportion> for f64
§type Output = Option<Proportion>
type Output = Option<Proportion>
The resulting type after applying the
-
operator.source§impl Sub<f64> for Proportion
impl Sub<f64> for Proportion
source§impl TryFrom<InputProportion> for Proportion
impl TryFrom<InputProportion> for Proportion
§type Error = DemesError
type Error = DemesError
The type returned in the event of a conversion error.
source§impl TryFrom<f64> for Proportion
impl TryFrom<f64> 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<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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.