Skip to content

Commit cc5df2c

Browse files
committed
progress
1 parent 4a2cdcf commit cc5df2c

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

src/data/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ mod tests {
578578
&self,
579579
_x: &crate::data::GaussianData<f64>,
580580
) -> Self::PpCache {
581-
()
582581
}
583582

584583
fn ln_pp_with_cache(

src/dist/scaled_prior.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::data::extract_stat_then;
12
use crate::data::{DataOrSuffStat, ScaledSuffStat};
23
use crate::dist::Scaled;
34
use crate::traits::*;
@@ -200,15 +201,10 @@ where
200201
&self,
201202
x: &DataOrSuffStat<f64, Scaled<Fx>>,
202203
) -> Self::PpCache {
203-
// For now, we'll just compute from data
204-
let data: Vec<f64> = match x {
205-
DataOrSuffStat::Data(xs) => {
206-
xs.iter().map(|&x| x * self.rate).collect()
207-
}
208-
DataOrSuffStat::SuffStat(_) => vec![], // Not handling suffstat for now
209-
};
210-
211-
self.parent.ln_pp_cache(&DataOrSuffStat::Data(&data))
204+
extract_stat_then(self, x, |stat| {
205+
self.parent
206+
.ln_pp_cache(&DataOrSuffStat::SuffStat(stat.parent()))
207+
})
212208
}
213209

214210
fn ln_pp_with_cache(&self, cache: &Self::PpCache, y: &f64) -> f64 {
@@ -224,8 +220,7 @@ where
224220
mod tests {
225221
use super::*;
226222
use crate::data::DataOrSuffStat;
227-
use crate::dist::{Gaussian, NormalInvChiSquared, Scaled};
228-
use crate::traits::*;
223+
use crate::dist::{NormalInvChiSquared};
229224
use rand::SeedableRng;
230225
use rand_xoshiro::Xoshiro256Plus;
231226

src/dist/shifted_prior.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ where
207207
mod tests {
208208
use super::*;
209209
use crate::data::DataOrSuffStat;
210-
use crate::dist::{Gaussian, NormalInvChiSquared, Shifted};
211-
use crate::traits::*;
210+
use crate::dist::{NormalInvChiSquared};
212211
use rand::SeedableRng;
213212
use rand_xoshiro::Xoshiro256Plus;
214213

src/dist/vonmises.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ mod tests {
641641

642642
#[test]
643643
fn slice_step_vs_draw_test() {
644-
let n_samples = 1000000;
644+
let n_samples = 1_000_000;
645645
let mut rng = rand::thread_rng();
646646
let mu = 1.5;
647647
let k = 2.0;

src/test.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ macro_rules! test_serde_params {
1010
($fx: expr, $fx_ty: ty, $x_ty: ty) => {
1111
#[test]
1212
fn test_serde_ln_f() {
13-
use ::serde::Deserialize;
14-
use ::serde::Serialize;
13+
// use ::serde::Deserialize;
14+
// use ::serde::Serialize;
1515
use $crate::traits::HasDensity;
1616
use $crate::traits::Sampleable;
1717

@@ -636,17 +636,17 @@ where
636636
Ok(p_value)
637637
}
638638

639-
mod tests {
640-
use crate::prelude::Exponential;
641-
use crate::prelude::Gaussian;
642-
use crate::test::density_histogram_test;
643-
use crate::traits::HasDensity;
644-
use crate::traits::Sampleable;
645-
use rand::SeedableRng;
646-
use rand_xoshiro::Xoshiro256Plus;
639+
mod tests {
647640

648641
#[test]
649642
fn test_density_histogram_gaussian() {
643+
use crate::prelude::Gaussian;
644+
use crate::test::density_histogram_test;
645+
use crate::traits::HasDensity;
646+
use crate::traits::Sampleable;
647+
use rand_xoshiro::Xoshiro256Plus;
648+
use rand::SeedableRng;
649+
650650
let mut rng = Xoshiro256Plus::seed_from_u64(1);
651651
let dist = Gaussian::default();
652652

@@ -670,6 +670,13 @@ mod tests {
670670

671671
#[test]
672672
fn test_density_histogram_exponential() {
673+
use crate::prelude::Exponential;
674+
use crate::traits::Sampleable;
675+
use crate::traits::HasDensity;
676+
use crate::test::density_histogram_test;
677+
use rand_xoshiro::Xoshiro256Plus;
678+
use rand::SeedableRng;
679+
673680
let mut rng = Xoshiro256Plus::seed_from_u64(1);
674681
let dist = Exponential::default();
675682

0 commit comments

Comments
 (0)