Skip to content

Commit

Permalink
New CI
Browse files Browse the repository at this point in the history
  • Loading branch information
gvonness committed Aug 13, 2023
1 parent 28e46d3 commit 41f7693
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ spaces {
}

project.git = true
runner.dialect = scala213
runner.dialect = scala3
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import cats.syntax.all.*
import org.apache.commons.math3.random.MersenneTwister

import scala.annotation.unused
import scala.{ Vector => ScalaVector }
import scala.Vector as ScalaVector

case class GaussianAnalyticPosterior[F[_]: Async](
override private[thylacine] val priors: Set[GaussianPrior[F]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ import cats.syntax.all.*
* stochastic quadratures Plasma Phys. Control Fusion 56 (2014) 114011
*/
private[thylacine] trait SlqEngine[F[_]] extends ModelParameterIntegrator[F] with ModelParameterSampler[F] {
this: StmImplicits[F] with Posterior[F, Prior[F, ?], ?] =>
this: StmImplicits[F] & Posterior[F, Prior[F, ?], ?] =>

import SlqEngine._
import SlqEngine.*

/*
* - - -- --- ----- -------- -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import cats.syntax.all.*
/** Implementation of the Hamiltonian MCMC sampling algorithm
*/
private[thylacine] trait HmcmcEngine[F[_]] extends ModelParameterSampler[F] {
this: AsyncImplicits[F] with Posterior[F, Prior[F, ?], ?] =>
this: AsyncImplicits[F] & Posterior[F, Prior[F, ?], ?] =>

/*
* - - -- --- ----- -------- -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import scala.util.Random
/** Leapfrog MCMC algorithm.
*/
private[thylacine] trait LeapfrogMcmcEngine[F[_]] extends ModelParameterSampler[F] {
this: StmImplicits[F] with Posterior[F, Prior[F, _], _] =>
this: StmImplicits[F] & Posterior[F, Prior[F, ?], ?] =>

/*
* - - -- --- ----- -------- -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class GaussianLikelihoodSpec extends AsyncFreeSpec with AsyncIOSpec with Matcher
"generate the a zero gradient at the likelihood maximum" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
likelihood <- fooNonAnalyticLikelihoodF
result <- likelihood.logPdfGradientAt(IndexedVectorCollection(Map("foo" -> Vector(1d, 2d))))
likelihood <- fooNonAnalyticLikelihoodF
result <- likelihood.logPdfGradientAt(IndexedVectorCollection(Map("foo" -> Vector(1d, 2d))))
} yield result.genericScalaRepresentation)
.asserting(_ shouldBe Map("foo" -> Vector(0d, 0d)))
}

"generate the correct gradient of the logPdf for a given point" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
likelihood <- fooNonAnalyticLikelihoodF
result <- likelihood.logPdfGradientAt(IndexedVectorCollection(Map("foo" -> Vector(3d, 2d))))
likelihood <- fooNonAnalyticLikelihoodF
result <- likelihood.logPdfGradientAt(IndexedVectorCollection(Map("foo" -> Vector(3d, 2d))))
} yield result.genericScalaRepresentation)
.asserting(result => maxIndexVectorDiff(result, Map("foo" -> Vector(-4e5, -88e4))) shouldBe (0d +- 1e-4))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ class GaussianLinearLikelihoodSpec extends AsyncFreeSpec with AsyncIOSpec with M
"generate the a zero gradient at the likelihood maximum" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
likelihood <- fooLikelihoodF
result <- likelihood.logPdfGradientAt(IndexedVectorCollection(Map("foo" -> Vector(1d, 2d))))
likelihood <- fooLikelihoodF
result <- likelihood.logPdfGradientAt(IndexedVectorCollection(Map("foo" -> Vector(1d, 2d))))
} yield result.genericScalaRepresentation)
.asserting(_ shouldBe Map("foo" -> Vector(0d, 0d)))
}

"generate the correct gradient of the logPdf for a given point" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
likelihood <- fooLikelihoodF
result <- likelihood.logPdfGradientAt(IndexedVectorCollection(Map("foo" -> Vector(3d, 2d))))
likelihood <- fooLikelihoodF
result <- likelihood.logPdfGradientAt(IndexedVectorCollection(Map("foo" -> Vector(3d, 2d))))
} yield result.genericScalaRepresentation)
.asserting(_ shouldBe Map("foo" -> Vector(-4e5, -88e4)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ConjugateGradientOptimisedPosteriorSpec extends AsyncFreeSpec with AsyncIO
"find the parameters that correspond to the posterior maximum" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
posterior <- conjugateGradientOptimisedPosteriorF
posterior <- conjugateGradientOptimisedPosteriorF
optimisationResult <-
posterior.findMaximumLogPdf(Map("fooniform" -> Vector(.5d, .5d), "barniform" -> Vector(3d)))
} yield maxIndexVectorDiff(optimisationResult._2, Map("fooniform" -> Vector(1, 2), "barniform" -> Vector(5))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class CoordinateSlideOptimisedPosteriorSpec extends AsyncFreeSpec with AsyncIOSp
"find the parameters that correspond to the posterior maximum" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
posterior <- coordinateSlideOptimisedPosteriorF
optimisationResult <- posterior.findMaximumLogPdf(Map())
posterior <- coordinateSlideOptimisedPosteriorF
optimisationResult <- posterior.findMaximumLogPdf(Map())
} yield maxIndexVectorDiff(optimisationResult._2, Map("fooniform" -> Vector(1, 2), "barniform" -> Vector(5))))
.asserting(_ shouldBe (0.0 +- 1e-5))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GaussianAnalyticPosteriorSpec extends AsyncFreeSpec with AsyncIOSpec with
"generate the correct mean for the inference" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
posterior <- analyticPosteriorF
posterior <- analyticPosteriorF
} yield maxIndexVectorDiff(posterior.mean, Map("foo" -> Vector(1, 2), "bar" -> Vector(5))))
.asserting(_ shouldBe (0d +- .1))
}
Expand All @@ -45,7 +45,7 @@ class GaussianAnalyticPosteriorSpec extends AsyncFreeSpec with AsyncIOSpec with
"generate the correct covariance" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
posterior <- analyticPosteriorF
posterior <- analyticPosteriorF
} yield maxVectorDiff(posterior.covarianceStridedVector, Vector.fill(9)(0d))).asserting(_ shouldBe (0.0 +- .01))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class HookeAndJeevesOptimisedPosteriorSpec extends AsyncFreeSpec with AsyncIOSpe
"find the parameters that correspond to the posterior maximum" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
posterior <- hookeAndJeevesOptimisedPosteriorF
optimisationResult <- posterior.findMaximumLogPdf(Map())
posterior <- hookeAndJeevesOptimisedPosteriorF
optimisationResult <- posterior.findMaximumLogPdf(Map())
} yield maxIndexVectorDiff(optimisationResult._2, Map("fooniform" -> Vector(1, 2), "barniform" -> Vector(5))))
.asserting(_ shouldBe (0.0 +- 1e-5))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class MdsOptimisedPosteriorSpec extends AsyncFreeSpec with AsyncIOSpec with Matc
"find the parameters that correspond to the posterior maximum" in {
(for {
case implicit0(stm: STM[IO]) <- STM.runtime[IO]
posterior <- mdsOptimisedPosteriorF
optimisationResult <- posterior.findMaximumLogPdf(Map())
posterior <- mdsOptimisedPosteriorF
optimisationResult <- posterior.findMaximumLogPdf(Map())
} yield maxIndexVectorDiff(optimisationResult._2, Map("fooniform" -> Vector(1, 2), "barniform" -> Vector(5))))
.asserting(_ shouldBe (0.0 +- 1e5))
}
Expand Down

0 comments on commit 41f7693

Please sign in to comment.