Skip to content

Commit

Permalink
test to be sure that allMovers and decayMovers produce distinct pertu…
Browse files Browse the repository at this point in the history
…rbatinos
  • Loading branch information
nrnrnr committed Jun 24, 2012
1 parent 2710f6c commit cd803a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion HMMProps.hs
Expand Up @@ -102,7 +102,7 @@ viterbiLocalPerturb rands states = vlp rands states

data Block a = Block { state :: a, number :: Int }
-- ^ invariant, number > 0
deriving (Eq, Show)
deriving (Eq, Ord, Show)

blockify :: Eq a => [a] -> [Block a]
blockify [] = []
Expand Down
9 changes: 9 additions & 0 deletions Perturb.hs
Expand Up @@ -9,6 +9,8 @@ import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
-- import qualified Data.Set.TernarySet as Set -- cabal troubles
import qualified Data.Set as Set
import Test.QuickCheck

import HMMProps
Expand Down Expand Up @@ -269,6 +271,11 @@ preservesInvariants f (Plan7 ss) = all (<==> ss) $ take 100000 $ f ss

isPlan7Prop (Plan7 states) = isPlan7 states

distinctPerturbations p1 p2 (Plan7 ss) =
disjoint (Set.fromList $ concat $ p1 bs) (Set.fromList $ concat $ p2 bs)
where bs = blockify ss
disjoint s s' = Set.null $ s `Set.intersection` s'

perturbProps :: [(String, Property)]
perturbProps = [ ("diagonal", property diagonalProp)
, ("diagonalCount", property diagonalsCount)
Expand All @@ -278,4 +285,6 @@ perturbProps = [ ("diagonal", property diagonalProp)
property $ preservesInvariants $ withStates allMovers)
, ("decayMoversInvariant",
property $ preservesInvariants $ withStates decayMovers)
, ("distinct-movers-decay",
property $ distinctPerturbations allMovers decayMovers)
]
1 change: 1 addition & 0 deletions mrfy.cabal
Expand Up @@ -53,6 +53,7 @@ Executable mrfy
Unixutils == 1.48.1,
-- Unixutils 1.50 fails to install
QuickCheck
-- TernaryTrees == 0.2.* -- incompatible with bio

-- cabal install --constraint="template-haskell == 2.5.0.0" haskell-src-meta

Expand Down

0 comments on commit cd803a7

Please sign in to comment.