Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove getset #567

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ 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: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ 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: 25 additions & 19 deletions src/stats/bayesian/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,7 @@ pub trait Posterior {
/// [here](https://github.com/varlociraptor/varlociraptor/blob/694e994547e8f523e5b0013fdf951b694f3870fa/src/model/modes/generic.rs#L200)
/// for an example.
#[derive(
Default,
Getters,
MutGetters,
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Hash,
Debug,
Serialize,
Deserialize,
Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize,
)]
pub struct Model<L, Pr, Po, Payload = ()>
where
Expand All @@ -75,14 +63,8 @@ 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 @@ -106,6 +88,30 @@ 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