packages feed

synthesizer-core-0.9: test/DocTest/Synthesizer/Causal/Analysis.hs

-- Do not edit! Automatically created with doctest-extract from src/Synthesizer/Causal/Analysis.hs
{-# LINE 19 "src/Synthesizer/Causal/Analysis.hs" #-}

module DocTest.Synthesizer.Causal.Analysis where

import qualified Test.DocTest.Driver as DocTest

{-# LINE 20 "src/Synthesizer/Causal/Analysis.hs" #-}
import     qualified Synthesizer.Causal.Analysis as AnaC
import     qualified Synthesizer.Causal.Process as Causal
import     qualified Synthesizer.Plain.Analysis as Ana

import     Control.Arrow ((<<<))

import     qualified Data.NonEmpty.Class as NonEmptyC
import     qualified Data.NonEmpty as NonEmpty
import     qualified Data.List.Match as Match
import     qualified Data.List as List

import     qualified Test.QuickCheck as QC

import     NumericPrelude.Numeric
import     NumericPrelude.Base
import     Prelude ()

test :: DocTest.T ()
test = do
 DocTest.printPrefix "Synthesizer.Causal.Analysis:44: "
{-# LINE 44 "src/Synthesizer/Causal/Analysis.hs" #-}
 DocTest.property(
{-# LINE 44 "src/Synthesizer/Causal/Analysis.hs" #-}
        
   \xs ->
      Match.take xs (Ana.deltaSigmaModulation xs)
      ==
      Causal.apply AnaC.deltaSigmaModulation (xs::[Rational])
  )
 DocTest.printPrefix "Synthesizer.Causal.Analysis:61: "
{-# LINE 61 "src/Synthesizer/Causal/Analysis.hs" #-}
 DocTest.property(
{-# LINE 61 "src/Synthesizer/Causal/Analysis.hs" #-}
        
   \threshold xs ->
      Match.take xs (Ana.deltaSigmaModulationPositive threshold xs)
      ==
      Causal.apply
         (AnaC.deltaSigmaModulationPositive <<<
          Causal.feedConstFst threshold)
         (xs::[Rational])
  )
 DocTest.printPrefix "Synthesizer.Causal.Analysis:86: "
{-# LINE 86 "src/Synthesizer/Causal/Analysis.hs" #-}
 DocTest.property(
{-# LINE 86 "src/Synthesizer/Causal/Analysis.hs" #-}
        
   let movingMedian :: (Ord a) => Int -> [a] -> [a]
       movingMedian n =
         map (\xs -> List.sort xs !! div (length xs) 2) . NonEmpty.tail .
         NonEmptyC.zipWith (drop . max 0) (NonEmptyC.iterate succ (negate n)) .
         NonEmpty.inits

   in QC.forAll (QC.choose (1,20)) $ \n xs ->
         movingMedian n xs
         ==
         Causal.apply (AnaC.movingMedian n) (xs::[Char])
  )