-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ unfinished ] Add a relative weight distribution test
- Loading branch information
Showing
8 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
examples/sorted-tree-indexed/tests/gens/_common/DistrCheckCommon.idr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module DistrCheckCommon | ||
|
||
import Data.List.Lazy | ||
|
||
import public Test.DepTyCheck.Gen | ||
|
||
import public Statistics.Norm.Precise | ||
import public Statistics.Confidence | ||
|
||
import System.Random.Pure.StdGen | ||
|
||
%default total | ||
|
||
find : LazyList (Vect n SignificantBounds) -> Maybe $ Vect n SignificantBounds | ||
find [] = Nothing | ||
find (x::xs) = case force xs of | ||
[] => Just x | ||
xs => if all isOk x then Just x else assert_total $ find xs | ||
|
||
verdict : Vect n (CoverageTest a) -> Gen em a -> Maybe $ Vect n SignificantBounds | ||
verdict conds = find . mapMaybe sequence . | ||
checkCoverageConditions conds . unGenTryN 10000000 someStdGen | ||
|
||
Show SignificantBounds where show = interpolate | ||
|
||
export | ||
printVerdict : HasIO m => Gen em a -> Vect n (CoverageTest a) -> m () | ||
printVerdict = putStrLn .: show .: flip verdict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
rm -rf build | ||
|
||
flock "$1" pack -q install-deps test.ipkg && \ | ||
pack exec CheckDistribution.idr | ||
|
||
rm -rf build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package test | ||
|
||
main = CheckDistribution | ||
|
||
depends = deptycheck, summary-stat |
24 changes: 24 additions & 0 deletions
24
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/CheckDistribution.idr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module CheckDistribution | ||
|
||
import Data.SortedBinTree.Gen | ||
|
||
import Deriving.DepTyCheck.Gen | ||
|
||
import DistrCheckCommon | ||
|
||
%default total | ||
|
||
%language ElabReflection | ||
|
||
-- Check how weights of subtrees are related between left and right subtree of a root | ||
|
||
mainFor : (depth : Nat) -> IO () | ||
mainFor depth = printVerdict (genSortedBinTree1 $ limit depth) $ fromList | ||
$ [ coverWith (ratio 1 $ S depth) ((== n) . length) | n <- [0 .. depth] ] | ||
|
||
main : IO () | ||
main = do | ||
mainFor 0 | ||
mainFor 1 | ||
mainFor 2 | ||
mainFor 7 |
1 change: 1 addition & 0 deletions
1
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/DistrCheckCommon.idr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../_common/DistrCheckCommon.idr |
4 changes: 4 additions & 0 deletions
4
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Just [ok] | ||
Just [ok, ok] | ||
Just [ok, ok, ok] | ||
Just [ok, ok, ok, ok, ok, ok, ok, ok] |
1 change: 1 addition & 0 deletions
1
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../_common/run |
5 changes: 5 additions & 0 deletions
5
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/test.ipkg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package test | ||
|
||
main = CheckDistribution | ||
|
||
depends = deptycheck, sorted-tree-indexed, summary-stat |