From f53b8624910042d455ab0a345777f93417b65870 Mon Sep 17 00:00:00 2001 From: Mahmoud Khattab Date: Mon, 23 Apr 2018 20:11:41 -0400 Subject: [PATCH 1/3] New test --- haskell/Tests/RoundTrip.hs | 14 +++----------- tests/RoundTrip2/t_laplace_to_chiSq.0.hk | 10 ++++++++++ tests/RoundTrip2/t_laplace_to_chiSq.expected.hk | 3 +++ 3 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 tests/RoundTrip2/t_laplace_to_chiSq.0.hk create mode 100644 tests/RoundTrip2/t_laplace_to_chiSq.expected.hk diff --git a/haskell/Tests/RoundTrip.hs b/haskell/Tests/RoundTrip.hs index a18c1ba9..654f2d7c 100644 --- a/haskell/Tests/RoundTrip.hs +++ b/haskell/Tests/RoundTrip.hs @@ -208,7 +208,8 @@ testStdChiSqRelations :: Test testStdChiSqRelations = test [ "t_stdChiSq_to_gamma" ~: testConcreteFiles "tests/RoundTrip/t_stdChiSq_to_gamma.0.hk" "tests/RoundTrip/t_stdChiSq_to_gamma.expected.hk", "t_stdChiSq_to_exponential" ~: testConcreteFiles "tests/RoundTrip2/t_stdChiSq_to_exponential.0.hk" "tests/RoundTrip2/t_stdChiSq_to_exponential.expected.hk", - "t_rayleigh_to_stdChiSq" ~: testConcreteFiles "tests/RoundTrip2/t_rayleigh_to_stdChiSq.0.hk" "tests/RoundTrip2/t_rayleigh_to_stdChiSq.expected.hk" + "t_rayleigh_to_stdChiSq" ~: testConcreteFiles "tests/RoundTrip2/t_rayleigh_to_stdChiSq.0.hk" "tests/RoundTrip2/t_rayleigh_to_stdChiSq.expected.hk", + "t_laplace_to_stdChiSq" ~: testConcreteFiles "tests/RoundTrip2/t_laplace_to_chiSq.0.hk" "tests/RoundTrip2/t_laplace_to_chiSq.expected.hk" ] testExponentialRelations :: Test @@ -257,16 +258,7 @@ testOther = test [ allTests :: Test allTests = test - [ testMeasureUnit - , testMeasureProb - , testMeasureReal - , testMeasurePair - , testMeasureNat - , testMeasureInt - , testErlangRelations - , testStdChiSqRelations - , testExponentialRelations - , testOther + [ testStdChiSqRelations ] ---------------------------------------------------------------- diff --git a/tests/RoundTrip2/t_laplace_to_chiSq.0.hk b/tests/RoundTrip2/t_laplace_to_chiSq.0.hk new file mode 100644 index 00000000..d596bb4a --- /dev/null +++ b/tests/RoundTrip2/t_laplace_to_chiSq.0.hk @@ -0,0 +1,10 @@ +def exponential(alpha prob): + gamma(1/1, alpha) + +def Laplace(alpha prob, beta prob): + X <~ exponential(alpha) + Y <~ exponential(beta) + return X - Y + +X <~ Laplace (1,1) +return (2 * abs(X-1))/ 1 \ No newline at end of file diff --git a/tests/RoundTrip2/t_laplace_to_chiSq.expected.hk b/tests/RoundTrip2/t_laplace_to_chiSq.expected.hk new file mode 100644 index 00000000..de101f4d --- /dev/null +++ b/tests/RoundTrip2/t_laplace_to_chiSq.expected.hk @@ -0,0 +1,3 @@ +# stdChiSq(2) +q <~ plate _ of 2: normal(+0/1,1/1) +return real2prob(summate i from 0 to size(q): q[i]^2) \ No newline at end of file From 061668620ec96fbbf4d06025035374e4ee876143 Mon Sep 17 00:00:00 2001 From: Mahmoud Khattab Date: Mon, 23 Apr 2018 20:16:19 -0400 Subject: [PATCH 2/3] fix --- haskell/Tests/RoundTrip.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/haskell/Tests/RoundTrip.hs b/haskell/Tests/RoundTrip.hs index 654f2d7c..4a290689 100644 --- a/haskell/Tests/RoundTrip.hs +++ b/haskell/Tests/RoundTrip.hs @@ -258,7 +258,16 @@ testOther = test [ allTests :: Test allTests = test - [ testStdChiSqRelations + [ testMeasureUnit + , testMeasureProb + , testMeasureReal + , testMeasurePair + , testMeasureNat + , testMeasureInt + , testErlangRelations + , testStdChiSqRelations + , testExponentialRelations + , testOther ] ---------------------------------------------------------------- From b0bebaa3f1bb0edfb5b5f94a4333ce987dcc9eee Mon Sep 17 00:00:00 2001 From: Mahmoud Khattab Date: Mon, 23 Apr 2018 23:46:39 -0400 Subject: [PATCH 3/3] Fixed 0-test failure --- haskell/Tests/RoundTrip.hs | 2 +- tests/{RoundTrip2 => RoundTrip}/t_laplace_to_chiSq.0.hk | 0 tests/RoundTrip/t_laplace_to_chiSq.expected.hk | 4 ++++ tests/RoundTrip2/t_laplace_to_chiSq.expected.hk | 3 --- 4 files changed, 5 insertions(+), 4 deletions(-) rename tests/{RoundTrip2 => RoundTrip}/t_laplace_to_chiSq.0.hk (100%) create mode 100644 tests/RoundTrip/t_laplace_to_chiSq.expected.hk delete mode 100644 tests/RoundTrip2/t_laplace_to_chiSq.expected.hk diff --git a/haskell/Tests/RoundTrip.hs b/haskell/Tests/RoundTrip.hs index a0c0973a..905697d6 100644 --- a/haskell/Tests/RoundTrip.hs +++ b/haskell/Tests/RoundTrip.hs @@ -212,7 +212,7 @@ testStdChiSqRelations = test [ "t_stdChiSq_to_gamma" ~: testConcreteFiles "tests/RoundTrip/t_stdChiSq_to_gamma.0.hk" "tests/RoundTrip/t_stdChiSq_to_gamma.expected.hk", "t_stdChiSq_to_exponential" ~: testConcreteFiles "tests/RoundTrip2/t_stdChiSq_to_exponential.0.hk" "tests/RoundTrip2/t_stdChiSq_to_exponential.expected.hk", "t_rayleigh_to_stdChiSq" ~: testConcreteFiles "tests/RoundTrip2/t_rayleigh_to_stdChiSq.0.hk" "tests/RoundTrip2/t_rayleigh_to_stdChiSq.expected.hk", - "t_laplace_to_stdChiSq" ~: testConcreteFiles "tests/RoundTrip2/t_laplace_to_chiSq.0.hk" "tests/RoundTrip2/t_laplace_to_chiSq.expected.hk" + "t_laplace_to_stdChiSq" ~: testConcreteFiles "tests/RoundTrip/t_laplace_to_chiSq.0.hk" "tests/RoundTrip/t_laplace_to_chiSq.expected.hk" ] diff --git a/tests/RoundTrip2/t_laplace_to_chiSq.0.hk b/tests/RoundTrip/t_laplace_to_chiSq.0.hk similarity index 100% rename from tests/RoundTrip2/t_laplace_to_chiSq.0.hk rename to tests/RoundTrip/t_laplace_to_chiSq.0.hk diff --git a/tests/RoundTrip/t_laplace_to_chiSq.expected.hk b/tests/RoundTrip/t_laplace_to_chiSq.expected.hk new file mode 100644 index 00000000..461dc088 --- /dev/null +++ b/tests/RoundTrip/t_laplace_to_chiSq.expected.hk @@ -0,0 +1,4 @@ +# stdChiSq(2) +X1 <~ normal(+0/1, 1/1) +X2 <~ normal(+0/1, 1/1) +return real2prob(X1^2 + X2^2) \ No newline at end of file diff --git a/tests/RoundTrip2/t_laplace_to_chiSq.expected.hk b/tests/RoundTrip2/t_laplace_to_chiSq.expected.hk deleted file mode 100644 index de101f4d..00000000 --- a/tests/RoundTrip2/t_laplace_to_chiSq.expected.hk +++ /dev/null @@ -1,3 +0,0 @@ -# stdChiSq(2) -q <~ plate _ of 2: normal(+0/1,1/1) -return real2prob(summate i from 0 to size(q): q[i]^2) \ No newline at end of file