From b5c8480bd6005f60740e05224f16b34a8f796da6 Mon Sep 17 00:00:00 2001 From: Mahmoud Khattab Date: Tue, 24 Apr 2018 02:21:25 -0400 Subject: [PATCH 1/2] Fix rayleigh tests --- haskell/Tests/RoundTrip.hs | 12 ++---------- tests/RoundTrip/t_exponential_to_rayleigh.0.hk | 5 +++++ .../RoundTrip/t_exponential_to_rayleigh.expected.hk | 3 +++ .../t_exponential_to_rayleigh.proof.mpl | 0 .../t_rayleigh_to_gamma.0.hk} | 0 tests/RoundTrip/t_rayleigh_to_gamma.expected.hk | 1 + .../t_rayleigh_to_gamma.proof.mpl} | 0 .../t_weibull_to_rayleigh.0.hk | 0 tests/RoundTrip/t_weibull_to_rayleigh.expected.hk | 3 +++ .../t_weibull_to_rayleigh.proof.mpl | 0 tests/RoundTrip2/t_exponential_to_rayleigh.0.hk | 6 ------ .../RoundTrip2/t_exponential_to_rayleigh.expected.hk | 9 --------- tests/RoundTrip2/t_gamma_to_rayleigh.0.hk | 1 - tests/RoundTrip2/t_weibull_to_rayleigh.expected.hk | 9 --------- 14 files changed, 14 insertions(+), 35 deletions(-) create mode 100644 tests/RoundTrip/t_exponential_to_rayleigh.0.hk create mode 100644 tests/RoundTrip/t_exponential_to_rayleigh.expected.hk rename tests/{RoundTrip2 => RoundTrip}/t_exponential_to_rayleigh.proof.mpl (100%) rename tests/{RoundTrip2/t_gamma_to_rayleigh.expected.hk => RoundTrip/t_rayleigh_to_gamma.0.hk} (100%) create mode 100644 tests/RoundTrip/t_rayleigh_to_gamma.expected.hk rename tests/{RoundTrip2/t_gamma_to_rayleigh.proof.mpl => RoundTrip/t_rayleigh_to_gamma.proof.mpl} (100%) rename tests/{RoundTrip2 => RoundTrip}/t_weibull_to_rayleigh.0.hk (100%) create mode 100644 tests/RoundTrip/t_weibull_to_rayleigh.expected.hk rename tests/{RoundTrip2 => RoundTrip}/t_weibull_to_rayleigh.proof.mpl (100%) delete mode 100644 tests/RoundTrip2/t_exponential_to_rayleigh.0.hk delete mode 100644 tests/RoundTrip2/t_exponential_to_rayleigh.expected.hk delete mode 100644 tests/RoundTrip2/t_gamma_to_rayleigh.0.hk delete mode 100644 tests/RoundTrip2/t_weibull_to_rayleigh.expected.hk diff --git a/haskell/Tests/RoundTrip.hs b/haskell/Tests/RoundTrip.hs index aa34117f..be1543cf 100644 --- a/haskell/Tests/RoundTrip.hs +++ b/haskell/Tests/RoundTrip.hs @@ -247,16 +247,8 @@ testErlangRelations = test [ testRayleighRelations :: Test testRayleighRelations = test [ - "t_exponential_to_rayleigh" ~: testConcreteFiles "tests/RoundTrip2/t_exponential_to_rayleigh.0.hk" "tests/RoundTrip2/t_exponential_to_rayleigh.expected.hk" - ] - -testRayleighRelations :: Test -testRayleighRelations = test [ - "t_gamma_to_rayleigh" ~: testConcreteFiles "tests/RoundTrip2/t_gamma_to_rayleigh.0.hk" "tests/RoundTrip2/t_gamma_to_rayleigh.expected.hk" - ] - -testRayleighRelations :: Test -testRayleighRelations = test [ + "t_exponential_to_rayleigh" ~: testConcreteFiles "tests/RoundTrip2/t_exponential_to_rayleigh.0.hk" "tests/RoundTrip2/t_exponential_to_rayleigh.expected.hk", + "t_rayleigh_to_gamma" ~: testConcreteFiles "tests/RoundTrip2/t_rayleigh_to_gamma.0.hk" "tests/RoundTrip2/t_rayleigh_to_gamma.expected.hk", "t_weibull_to_rayleigh" ~: testConcreteFiles "tests/RoundTrip2/t_weibull_to_rayleigh.0.hk" "tests/RoundTrip2/t_weibull_to_rayleigh.expected.hk" ] diff --git a/tests/RoundTrip/t_exponential_to_rayleigh.0.hk b/tests/RoundTrip/t_exponential_to_rayleigh.0.hk new file mode 100644 index 00000000..bdebcaed --- /dev/null +++ b/tests/RoundTrip/t_exponential_to_rayleigh.0.hk @@ -0,0 +1,5 @@ +def exponential(alpha prob): + gamma(1/1,alpha) + +X <~ exponential(1) +return sqrt(X) \ No newline at end of file diff --git a/tests/RoundTrip/t_exponential_to_rayleigh.expected.hk b/tests/RoundTrip/t_exponential_to_rayleigh.expected.hk new file mode 100644 index 00000000..a8757033 --- /dev/null +++ b/tests/RoundTrip/t_exponential_to_rayleigh.expected.hk @@ -0,0 +1,3 @@ +#rayleigh(1) +X3 <~ uniform(+0/1, +1/1) +return sqrt(real2prob(log(real2prob(X3)) * (-1/1))) \ No newline at end of file diff --git a/tests/RoundTrip2/t_exponential_to_rayleigh.proof.mpl b/tests/RoundTrip/t_exponential_to_rayleigh.proof.mpl similarity index 100% rename from tests/RoundTrip2/t_exponential_to_rayleigh.proof.mpl rename to tests/RoundTrip/t_exponential_to_rayleigh.proof.mpl diff --git a/tests/RoundTrip2/t_gamma_to_rayleigh.expected.hk b/tests/RoundTrip/t_rayleigh_to_gamma.0.hk similarity index 100% rename from tests/RoundTrip2/t_gamma_to_rayleigh.expected.hk rename to tests/RoundTrip/t_rayleigh_to_gamma.0.hk diff --git a/tests/RoundTrip/t_rayleigh_to_gamma.expected.hk b/tests/RoundTrip/t_rayleigh_to_gamma.expected.hk new file mode 100644 index 00000000..d9074f12 --- /dev/null +++ b/tests/RoundTrip/t_rayleigh_to_gamma.expected.hk @@ -0,0 +1 @@ +gamma(1/1,2/1) \ No newline at end of file diff --git a/tests/RoundTrip2/t_gamma_to_rayleigh.proof.mpl b/tests/RoundTrip/t_rayleigh_to_gamma.proof.mpl similarity index 100% rename from tests/RoundTrip2/t_gamma_to_rayleigh.proof.mpl rename to tests/RoundTrip/t_rayleigh_to_gamma.proof.mpl diff --git a/tests/RoundTrip2/t_weibull_to_rayleigh.0.hk b/tests/RoundTrip/t_weibull_to_rayleigh.0.hk similarity index 100% rename from tests/RoundTrip2/t_weibull_to_rayleigh.0.hk rename to tests/RoundTrip/t_weibull_to_rayleigh.0.hk diff --git a/tests/RoundTrip/t_weibull_to_rayleigh.expected.hk b/tests/RoundTrip/t_weibull_to_rayleigh.expected.hk new file mode 100644 index 00000000..b17311c2 --- /dev/null +++ b/tests/RoundTrip/t_weibull_to_rayleigh.expected.hk @@ -0,0 +1,3 @@ +#rayleigh(1) +X <~ uniform(+0/1, +1/1) +return sqrt(real2prob(log(real2prob(X)) * (-1/1))) \ No newline at end of file diff --git a/tests/RoundTrip2/t_weibull_to_rayleigh.proof.mpl b/tests/RoundTrip/t_weibull_to_rayleigh.proof.mpl similarity index 100% rename from tests/RoundTrip2/t_weibull_to_rayleigh.proof.mpl rename to tests/RoundTrip/t_weibull_to_rayleigh.proof.mpl diff --git a/tests/RoundTrip2/t_exponential_to_rayleigh.0.hk b/tests/RoundTrip2/t_exponential_to_rayleigh.0.hk deleted file mode 100644 index a2225e48..00000000 --- a/tests/RoundTrip2/t_exponential_to_rayleigh.0.hk +++ /dev/null @@ -1,6 +0,0 @@ -def exponential(alpha prob): - X <~ uniform(0,1) - return -1 * alpha * log(real2prob(X)) - -X <~ exponential(1) -return sqrt(real2prob(X)) \ No newline at end of file diff --git a/tests/RoundTrip2/t_exponential_to_rayleigh.expected.hk b/tests/RoundTrip2/t_exponential_to_rayleigh.expected.hk deleted file mode 100644 index 41058c9d..00000000 --- a/tests/RoundTrip2/t_exponential_to_rayleigh.expected.hk +++ /dev/null @@ -1,9 +0,0 @@ -def exponential(alpha prob): - X <~ uniform(0,1) - return -1 * alpha * log(real2prob(X)) - -def rayleigh(alpha prob): - X <~ exponential(alpha) - return sqrt(real2prob(X)) - -rayleigh(1) \ No newline at end of file diff --git a/tests/RoundTrip2/t_gamma_to_rayleigh.0.hk b/tests/RoundTrip2/t_gamma_to_rayleigh.0.hk deleted file mode 100644 index 39c3e45b..00000000 --- a/tests/RoundTrip2/t_gamma_to_rayleigh.0.hk +++ /dev/null @@ -1 +0,0 @@ -gamma(1,2) \ No newline at end of file diff --git a/tests/RoundTrip2/t_weibull_to_rayleigh.expected.hk b/tests/RoundTrip2/t_weibull_to_rayleigh.expected.hk deleted file mode 100644 index 41058c9d..00000000 --- a/tests/RoundTrip2/t_weibull_to_rayleigh.expected.hk +++ /dev/null @@ -1,9 +0,0 @@ -def exponential(alpha prob): - X <~ uniform(0,1) - return -1 * alpha * log(real2prob(X)) - -def rayleigh(alpha prob): - X <~ exponential(alpha) - return sqrt(real2prob(X)) - -rayleigh(1) \ No newline at end of file From 1dec053be03feca9c6c5b199b747a0e9c743ce41 Mon Sep 17 00:00:00 2001 From: Mahmoud Khattab Date: Tue, 24 Apr 2018 04:24:43 -0400 Subject: [PATCH 2/2] Fix RoundTrip --- haskell/Tests/RoundTrip.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/haskell/Tests/RoundTrip.hs b/haskell/Tests/RoundTrip.hs index be1543cf..e6fb4917 100644 --- a/haskell/Tests/RoundTrip.hs +++ b/haskell/Tests/RoundTrip.hs @@ -247,9 +247,9 @@ testErlangRelations = test [ testRayleighRelations :: Test testRayleighRelations = test [ - "t_exponential_to_rayleigh" ~: testConcreteFiles "tests/RoundTrip2/t_exponential_to_rayleigh.0.hk" "tests/RoundTrip2/t_exponential_to_rayleigh.expected.hk", - "t_rayleigh_to_gamma" ~: testConcreteFiles "tests/RoundTrip2/t_rayleigh_to_gamma.0.hk" "tests/RoundTrip2/t_rayleigh_to_gamma.expected.hk", - "t_weibull_to_rayleigh" ~: testConcreteFiles "tests/RoundTrip2/t_weibull_to_rayleigh.0.hk" "tests/RoundTrip2/t_weibull_to_rayleigh.expected.hk" + "t_exponential_to_rayleigh" ~: testConcreteFiles "tests/RoundTrip/t_exponential_to_rayleigh.0.hk" "tests/RoundTrip/t_exponential_to_rayleigh.expected.hk", + "t_rayleigh_to_gamma" ~: testConcreteFiles "tests/RoundTrip/t_rayleigh_to_gamma.0.hk" "tests/RoundTrip/t_rayleigh_to_gamma.expected.hk", + "t_weibull_to_rayleigh" ~: testConcreteFiles "tests/RoundTrip/t_weibull_to_rayleigh.0.hk" "tests/RoundTrip/t_weibull_to_rayleigh.expected.hk" ] testOther :: Test