packages feed

monad-bayes 1.3.0 → 1.3.0.1

raw patch · 6 files changed

+31/−21 lines, 6 filesdep +vty-unixdep ~basedep ~brickdep ~freePVP ok

version bump matches the API change (PVP)

Dependencies added: vty-unix

Dependency ranges changed: base, brick, free, text, vty

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+# 1.3.0.1++- Support for GHC 9.8+ # 1.3.0  - Support for GHC 9.6
benchmark/Speed.hs view
@@ -22,6 +22,7 @@   ) import Criterion.Types (Config (csvFile, rawDataFile)) import Data.Functor (void)+import Data.Maybe (listToMaybe) import Data.Text qualified as T import HMM qualified import LDA qualified@@ -38,7 +39,7 @@ instance Show Model where   show (LR xs) = "LR" ++ show (length xs)   show (HMM xs) = "HMM" ++ show (length xs)-  show (LDA xs) = "LDA" ++ show (length $ head xs)+  show (LDA xs) = "LDA" ++ show (maybe 0 length $ listToMaybe xs)  buildModel :: (MonadMeasure m) => Model -> m String buildModel (LR dataset) = show <$> LogReg.logisticRegression dataset
models/LDA.hs view
@@ -81,4 +81,4 @@ runLDA :: IO () runLDA = do   s <- sampleIOfixed $ unweighted $ mh 1000 $ lda documents-  pPrint (head s)+  pPrint $ take 1 s
monad-bayes.cabal view
@@ -1,13 +1,13 @@ cabal-version:   2.2 name:            monad-bayes-version:         1.3.0+version:         1.3.0.1 license:         MIT license-file:    LICENSE.md copyright:       2015-2020 Adam Scibior maintainer:      dominic.steinitz@tweag.io author:          Adam Scibior <adscib@gmail.com> stability:       experimental-tested-with:     GHC ==9.0.2 || ==9.2.7 || ==9.4.5 || ==9.6.4+tested-with:     GHC ==9.0.2 || ==9.2.7 || ==9.4.5 || ==9.6.4 || ==9.8.2 homepage:        http://github.com/tweag/monad-bayes#readme bug-reports:     https://github.com/tweag/monad-bayes/issues synopsis:        A library for probabilistic programming.@@ -38,34 +38,35 @@  common deps   build-depends:-    , base             >=4.15    && <4.19-    , brick            >=1.0     && <2.0-    , containers       >=0.5.10  && <0.7+    , base             >=4.15     && <4.20+    , brick            ^>=2.3.1+    , containers       >=0.5.10   && <0.7     , foldl            ^>=1.4-    , free             >=5.0.2   && <5.2+    , free             ^>=5.2     , histogram-fill   ^>=0.9     , ieee754          ^>=0.8.0     , integration      ^>=0.2     , lens             ^>=5.2     , linear           ^>=1.22-    , log-domain       >=0.12    && <0.14-    , math-functions   >=0.2.1   && <0.4+    , log-domain       >=0.12     && <0.14+    , math-functions   >=0.2.1    && <0.4     , matrix           ^>=0.3     , monad-coroutine  ^>=0.9.0     , monad-extras     ^>=0.6-    , mtl              >=2.2.2   && <2.4-    , mwc-random       >=0.13.6  && <0.16+    , mtl              >=2.2.2    && <2.4+    , mwc-random       >=0.13.6   && <0.16     , pipes            ^>=4.3     , pretty-simple    ^>=4.1-    , primitive        >=0.7     && <0.9+    , primitive        >=0.7      && <0.9     , random           ^>=1.2     , safe             ^>=0.3.17     , scientific       ^>=0.3-    , statistics       >=0.14.0  && <0.17-    , text             >=1.2     && <2.1-    , transformers     >=0.5.6   && <0.7-    , vector           >=0.12.0  && <0.14-    , vty              ^>=5.38+    , statistics       >=0.14.0   && <0.17+    , text             >=1.2      && <2.2+    , transformers     >=0.5.6    && <0.7+    , vector           >=0.12.0   && <0.14+    , vty              ^>=6.1+    , vty-unix         ^>=0.2.0.0  common test-deps   build-depends:
src/Control/Monad/Bayes/Inference/Lazy/WIS.hs view
@@ -1,7 +1,9 @@ module Control.Monad.Bayes.Inference.Lazy.WIS where +import Control.Monad (guard) import Control.Monad.Bayes.Sampler.Lazy (SamplerT, weightedSamples) import Control.Monad.Bayes.Weighted (WeightedT)+import Data.Maybe (mapMaybe) import Numeric.Log (Log (Exp)) import System.Random (Random (randoms), getStdGen, newStdGen) @@ -16,7 +18,7 @@   let max' = snd $ last xws'   _ <- newStdGen   rs <- randoms <$> getStdGen-  return $ fmap (\r -> fst $ head $ filter ((>= Exp (log r) * max') . snd) xws') rs+  return $ take 1 =<< fmap (\r -> mapMaybe (\(a, p) -> guard (p >= Exp (log r) * max') >> Just a) xws') rs   where     accumulate :: (Num t) => [(a, t)] -> t -> [(a, t)]     accumulate ((x, w) : xws) a = (x, w + a) : (x, w + a) : accumulate xws (w + a)
src/Control/Monad/Bayes/Inference/TUI.hs view
@@ -21,6 +21,7 @@ import Control.Monad.Bayes.Traced (TracedT) import Control.Monad.Bayes.Traced.Common hiding (burnIn) import Control.Monad.Bayes.Weighted+import Data.Maybe (listToMaybe) import Data.Scientific (FPFormat (Exponent), formatScientific, fromFloatDigits) import Data.Text qualified as T import Data.Text.Lazy qualified as TL@@ -28,6 +29,7 @@ import GHC.Float (double2Float) import Graphics.Vty import Graphics.Vty qualified as V+import Graphics.Vty.Platform.Unix qualified as V import Numeric.Log (Log (ln)) import Pipes (runEffect, (>->)) import Pipes qualified as P@@ -69,7 +71,7 @@             ]         )         $ B.progressBar-          (Just $ "Mean likelihood for last 1000 samples: " <> take 10 (show (head $ lk state <> [0])))+          (Just $ "Mean likelihood for last 1000 samples: " <> take 10 (maybe "(error)" show (listToMaybe $ lk state <> [0])))           (double2Float (Fold.fold Fold.mean $ take 1000 $ lk state) / double2Float (maximum $ 0 : lk state))      displayStep c = Just $ "Step " <> show c@@ -107,7 +109,7 @@     . toEmpirical  showVal :: (Show a) => [a] -> Widget n-showVal = txt . T.pack . (\case [] -> ""; a -> show $ head a)+showVal = txt . T.pack . (\case [] -> ""; a -> maybe "(error)" show $ listToMaybe a)  -- | handler for events received by the TUI appEvent :: B.BrickEvent n s -> B.EventM n s ()