Skip to content

Commit

Permalink
Unit test compatibility with new linear package.
Browse files Browse the repository at this point in the history
  • Loading branch information
acowley committed Nov 19, 2015
1 parent 3e28c7a commit 23e0093
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RANSAC.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: RANSAC
version: 0.1.0.1
version: 0.1.0.2
synopsis: The RANSAC algorithm for parameter estimation.
description: The RANdom SAmple Consensus (RANSAC) algorithm for
estimating the parameters of a mathematical model
Expand Down
8 changes: 5 additions & 3 deletions tests/SmokeTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ sq x = x * x

-- | Fit a 2D line to a collection of 'Point's.
fitLine :: Vector Point -> Maybe (V2 Float)
fitLine pts = (!* b) <$> inv22 a
fitLine pts = (!* b) <$> inv22' a
where sx = V.sum $ V.map (view _x) pts
a = V2 (V2 (V.sum (V.map (sq . view _x) pts)) sx)
(V2 sx (fromIntegral (V.length pts)))
b = V2 (V.sum (V.map F.product pts))
(V.sum (V.map (view _y) pts))

inv22' m = let m' = inv22 m
in if F.any (F.any isNaN) m' then Nothing else Just m'

-- | Compute the error of a 'Point' with respect to a hypothesized
-- linear model.
ptError :: V2 Float -> Point -> Float
Expand All @@ -44,4 +46,4 @@ test1 = tst ~? "noise-free linear fit"
Just (m,_) -> qd (V2 3 1) m < 0.1

main :: IO ()
main = defaultMain $ hUnitTestToTests test1
main = defaultMain $ hUnitTestToTests test1

0 comments on commit 23e0093

Please sign in to comment.