Skip to content

Commit

Permalink
Revert "Remove getset (#567)"
Browse files Browse the repository at this point in the history
This reverts commit 6b3c367.
  • Loading branch information
dcroote committed Dec 27, 2023
1 parent 6b3c367 commit ecc11ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pest = { version = "2", optional = true }
pest_derive = { version = "2", optional = true }
strum = ">= 0.16, < 0.26"
strum_macros = ">= 0.16, < 0.26"
getset = ">=0.0.9, <0.2"
enum-map = ">=0.6.4, <3"
triple_accel = ">=0.3, <0.5"
thiserror = "1"
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ extern crate serde_derive;
#[macro_use]
extern crate strum_macros;

#[macro_use]
extern crate getset;

#[cfg(feature = "phylogeny")]
#[macro_use]
extern crate pest_derive;
Expand Down
44 changes: 19 additions & 25 deletions src/stats/bayesian/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@ pub trait Posterior {
/// [here](https://github.com/varlociraptor/varlociraptor/blob/694e994547e8f523e5b0013fdf951b694f3870fa/src/model/modes/generic.rs#L200)
/// for an example.
#[derive(
Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize,
Default,
Getters,
MutGetters,
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Hash,
Debug,
Serialize,
Deserialize,
)]
pub struct Model<L, Pr, Po, Payload = ()>
where
Expand All @@ -63,8 +75,14 @@ where
Po: Posterior,
Payload: Default,
{
#[get = "pub"]
#[get_mut = "pub"]
likelihood: L,
#[get = "pub"]
#[get_mut = "pub"]
prior: Pr,
#[get = "pub"]
#[get_mut = "pub"]
posterior: Po,
payload: PhantomData<Payload>,
}
Expand All @@ -88,30 +106,6 @@ where
}
}

pub fn likelihood(&self) -> &L {
&self.likelihood
}

pub fn likelihood_mut(&mut self) -> &mut L {
&mut self.likelihood
}

pub fn prior(&self) -> &Pr {
&self.prior
}

pub fn prior_mut(&mut self) -> &mut Pr {
&mut self.prior
}

pub fn posterior(&self) -> &Po {
&self.posterior
}

pub fn posterior_mut(&mut self) -> &mut Po {
&mut self.posterior
}

/// Calculate joint probability, i.e. `Pr(event) * Pr(data | event)`.
fn joint_prob(&self, event: &Event, data: &Data, payload: &mut Payload) -> LogProb {
self.prior.compute(event) + self.likelihood.compute(event, data, payload)
Expand Down

0 comments on commit ecc11ca

Please sign in to comment.