init cntd.

This commit is contained in:
Filip Gralinski 2015-08-19 22:14:34 +02:00 committed by Filip Gralinski
parent e923db54f1
commit 17844b5921
3 changed files with 33 additions and 2 deletions

View File

@ -17,6 +17,11 @@ library
hs-source-dirs: src
exposed-modules: Lib
build-depends: base >= 4.7 && < 5
, conduit
, conduit-combinators
, conduit-extra
, resourcet
, text
default-language: Haskell2010
executable geval-exe
@ -33,6 +38,7 @@ test-suite geval-test
main-is: Spec.hs
build-depends: base
, geval
, hspec
ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010

View File

@ -2,6 +2,24 @@ module Lib
( geval
) where
import Data.Conduit
import Data.Conduit.Combinators as CC
import qualified Data.Conduit.Binary as CB
import qualified Data.Conduit.Text as CT
import Control.Monad.Trans.Resource
import qualified Data.Conduit.List as CL
import Data.Text
import Data.Text.Read as TR
geval :: String -> String -> IO (Double)
geval expectedFilePath outFilePath = do
return $ 3.14
runResourceT $
CB.sourceFile expectedFilePath
$$ CT.decode CT.utf8
=$= CT.lines
=$= CL.map TR.double
=$= CC.map getValue
=$ CC.sum
getValue :: Either String (Double, Text) -> Double
getValue (Right (x, _)) = x

View File

@ -1,2 +1,9 @@
import Test.Hspec
import Lib
main :: IO ()
main = putStrLn "Test suite not yet implemented"
main = hspec $ do
describe "mean square error" $ do
it "simple test" $ do
geval "test/mse-simple/mse-simple/test-A/expected.tsv" "test/mse-simple/mse-simple-solution/test-A/out.tsv" `shouldReturn` 1.118033988749