# HG changeset patch # User Christian Urban # Date 1549070503 0 # Node ID b4812c877b059e53d63661b09677e5f9e78cfe15 # Parent 43995ea34fe7055f115de00b8e4036358d9f5505 updated diff -r 43995ea34fe7 -r b4812c877b05 marking1/drumb.scala --- a/marking1/drumb.scala Mon Jan 28 12:49:19 2019 +0000 +++ b/marking1/drumb.scala Sat Feb 02 01:21:43 2019 +0000 @@ -1,7 +1,7 @@ // Advanvced Part 3 about a really dumb investment strategy //========================================================== -object CW6c { +//object CW6c { //two test portfolios @@ -148,4 +148,4 @@ */ //1984 //1992 -} +//} diff -r 43995ea34fe7 -r b4812c877b05 marking1/drumb_test2.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/marking1/drumb_test2.sh Sat Feb 02 01:21:43 2019 +0000 @@ -0,0 +1,155 @@ +#!/bin/bash +set -euo pipefail + + +out=${1:-output} + +echo "Below is the feedback and provisional marks for your submission" >> $out +echo "for assignment 6 Advanced Part 3. Please note all marks are provisional until" >> $out +echo "ratified by the assessment board -- this is not an official" >> $out +echo "results transcript." >> $out +echo "" >> $out + +# marks for CW6 part 3 +marks=$(( 0 )) + + +# compilation tests + +function scala_compile { + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2> /dev/null 1> /dev/null) +} + +# functional tests + +function scala_assert { + (ulimit -t 30; JAVA_OPTS="-Xmx4g" scala -i -nc "$1" "$2" -e "" 2> /dev/null 1> /dev/null) +} + + +# purity test + +function scala_vars { + (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null) +} + + + +# var, .par return, ListBuffer test +# +echo "drumb.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out + +if (scala_vars drumb.scala) +then + echo " --> test failed" | tee -a $out + tsts0=$(( 1 )) +else + echo " --> success" | tee -a $out + tsts0=$(( 0 )) +fi + + +# compilation test +if [ $tsts0 -eq 0 ] +then + echo "drumb.scala runs?" | tee -a $out + + if (scala_compile drumb.scala) + then + echo " --> success" | tee -a $out + tsts=$(( 0 )) + else + echo " --> scala drumb.scala did not run successfully" | tee -a $out + tsts=$(( 1 )) + fi +else + tsts=$(( 1 )) +fi + + +### get_delta test + +if [ $tsts -eq 0 ] +then + echo " get_delta(None, None) == None" | tee -a $out + echo " get_delta(Some(100.0), None) == None" | tee -a $out + echo " get_delta(None, Some(50.0)) == None" | tee -a $out + echo " get_delta(Some(100.0), Some(50.0)) == Some(1.0)" | tee -a $out + + if (scala_assert "drumb.scala" "drumb_test4.scala") + then + echo " --> success" | tee -a $out + marks=$(( marks + 1 )) + else + echo " --> test failed" | tee -a $out + fi +fi + + +### get_deltas_test + +if [ $tsts -eq 0 ] +then + echo -e " get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)) == " | tee -a $out + echo -e " List(List(Some(-0.03573992567129673), Some(0.539975124774038)), " | tee -a $out + echo -e " List(Some(0.10103412653643493), Some(0.24777709700099845)))" | tee -a $out + echo -e "" | tee -a $out + echo -e " get_deltas(get_prices(List(\"BIDU\"), 2004 to 2008)) == " | tee -a $out + echo -e " List(List(None), List(None), " | tee -a $out + echo -e " List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) " | tee -a $out + + if (scala_assert "drumb.scala" "drumb_test5.scala") + then + echo -e " --> success" | tee -a $out + marks=$(( marks + 1 )) + else + echo " --> test failed" | tee -a $out + fi +fi + + +### yield_tests + +if [ $tsts -eq 0 ] +then + echo -e " val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" | tee -a $out + echo -e " yearly_yield(get_deltas(ds, 100, 0) == 125" | tee -a $out + echo -e " yearly_yield(get_deltas(ds, 100, 1) == 117" | tee -a $out + + if (scala_assert "drumb.scala" "drumb_test6.scala") + then + echo -e " --> success" | tee -a $out + marks=$(( marks + 1 )) + else + echo " --> test failed" | tee -a $out + fi +fi + + +### investment_test + +if [ $tsts -eq 0 ] +then + echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2000, 100) == 100" | tee -a $out + echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2001, 100) == 27 " | tee -a $out + echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2002, 100) == 42 " | tee -a $out + echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2003, 100) == 27 " | tee -a $out + echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2004, 100) == 38 " | tee -a $out + echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2005, 100) == 113" | tee -a $out + echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2006, 100) == 254" | tee -a $out + echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2007, 100) == 349" | tee -a $out + + if (scala_assert "drumb.scala" "drumb_test7.scala") + then + echo -e " --> success" | tee -a $out + marks=$(( marks + 1 )) + else + echo " --> test failed" | tee -a $out + fi +fi + + + +## final marks +echo "Overall mark for CW 6, Part 3" | tee -a $out +echo "$marks" | tee -a $out diff -r 43995ea34fe7 -r b4812c877b05 marking1/drumb_test4.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/marking1/drumb_test4.scala Sat Feb 02 01:21:43 2019 +0000 @@ -0,0 +1,6 @@ + + +assert(get_delta(None, None) == None) +assert(get_delta(Some(100.0), None) == None) +assert(get_delta(None, Some(50.0)) == None) +assert(get_delta(Some(100.0), Some(50.0)) == Some(1.0)) diff -r 43995ea34fe7 -r b4812c877b05 marking1/drumb_test5.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/marking1/drumb_test5.scala Sat Feb 02 01:21:43 2019 +0000 @@ -0,0 +1,20 @@ + +// get_prices(List("GOOG", "AAPL"), 2010 to 2012) +val urban_prices = List(List(Some(311.349976), Some(20.544939)), + List(Some(300.222351), Some(31.638695)), + List(Some(330.555054), Some(39.478039))) + + +assert(get_deltas(urban_prices) == List(List(Some(-0.03573992567129673), Some(0.539975124774038)), + List(Some(0.10103412653643493), Some(0.24777709700099845)))) + + +//get_prices(List("BIDU"), 2004 to 2008) +val urban_prices2 = List(List(None), List(None), + List(Some(6.35)), List(Some(12.241)), + List(Some(38.188))) + + +assert(get_deltas(urban_prices2) == List(List(None), List(None), + List(Some(0.9277165354330709)), + List(Some(2.119679764725104)))) diff -r 43995ea34fe7 -r b4812c877b05 marking1/drumb_test6.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/marking1/drumb_test6.scala Sat Feb 02 01:21:43 2019 +0000 @@ -0,0 +1,9 @@ +//val urban_deltas = get_deltas(get_prices(List("GOOG", "AAPL"), 2010 to 2012)) + +val ds_urban = List(List(Some(-0.03573992567129673), Some(0.539975124774038)), + List(Some(0.10103412653643493), Some(0.24777709700099845))) + + + +assert(yearly_yield(ds_urban, 100, 0) == 125) +assert(yearly_yield(ds_urban, 100, 1) == 117) diff -r 43995ea34fe7 -r b4812c877b05 marking1/drumb_test7.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/marking1/drumb_test7.scala Sat Feb 02 01:21:43 2019 +0000 @@ -0,0 +1,9 @@ + +assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2000, 100) == 100) +assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2001, 100) == 27) +assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2002, 100) == 42) +assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2003, 100) == 27) +assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2004, 100) == 38) +assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2005, 100) == 113) +assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2006, 100) == 254) +assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2007, 100) == 349) diff -r 43995ea34fe7 -r b4812c877b05 marking1/mk-advanced --- a/marking1/mk-advanced Mon Jan 28 12:49:19 2019 +0000 +++ b/marking1/mk-advanced Sat Feb 02 01:21:43 2019 +0000 @@ -3,22 +3,24 @@ trap "exit" INT -files=${1:-assignment20176-*} +files=${1:-assignment20186A-*} for sd in $files; do cd $sd echo $sd touch . - cp ../../../marking1/drumb_test.sh . - cp ../../../marking1/drumb_test1.scala . - cp ../../../marking1/drumb_test2.scala . - cp ../../../marking1/drumb_test3.scala . + cp ../../../marking1/*.sh . + cp ../../../marking1/drumb_test4.scala . + cp ../../../marking1/drumb_test5.scala . + cp ../../../marking1/drumb_test6.scala . + cp ../../../marking1/drumb_test7.scala . cp ../../../marking1/*.csv . - ./drumb_test.sh output - rm drumb_test.sh - rm drumb_test1.scala - rm drumb_test2.scala - rm drumb_test3.scala + ./drumb_test2.sh output + rm *.sh + rm drumb_test4.scala + rm drumb_test5.scala + rm drumb_test6.scala + rm drumb_test7.scala rm *.csv cd .. done diff -r 43995ea34fe7 -r b4812c877b05 marking1/output --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/marking1/output Sat Feb 02 01:21:43 2019 +0000 @@ -0,0 +1,143 @@ +Below is the feedback and provisional marks for your submission +for assignment 6 Advanced Part 3. Please note all marks are provisional until +ratified by the assessment board -- this is not an official +results transcript. + +drumb.scala does not contain vars, returns, Arrays, ListBuffers etc? + --> success +drumb.scala runs? + --> success + get_january_data("GOOG", 1980) == List() + get_january_data("GOOG", 2010).head == "2010-01-04,311.349976" + --> success + get_first_price("GOOG", 1980) == None + get_first_price("GOOG", 2010) == Some(311.349976) + --> success + get_prices(List("BIDU"), 2004 to 2008) == + List(List(None), List(None), List(Some(6.35)), + List(Some(12.241)), List(Some(38.188))) + + get_prices(List("GOOG", "AAPL"), 2010 to 2012) == + List(List(Some(311.349976), Some(20.544939)), + List(Some(300.222351), Some(31.638695)), + List(Some(330.555054), Some(39.478039))) + --> success +Below is the feedback and provisional marks for your submission +for assignment 6 Advanced Part 3. Please note all marks are provisional until +ratified by the assessment board -- this is not an official +results transcript. + +drumb.scala does not contain vars, returns, Arrays, ListBuffers etc? + --> success +drumb.scala runs? + --> success + get_january_data("GOOG", 1980) == List() + get_january_data("GOOG", 2010).head == "2010-01-04,311.349976" + --> success +Below is the feedback and provisional marks for your submission +for assignment 6 Advanced Part 3. Please note all marks are provisional until +ratified by the assessment board -- this is not an official +results transcript. + +drumb.scala does not contain vars, returns, Arrays, ListBuffers etc? + --> success +drumb.scala runs? + --> success + get_january_data("GOOG", 1980) == List() + get_january_data("GOOG", 2010).head == "2010-01-04,311.349976" + --> success + get_deltas(get_prices(List("GOOG", "AAPL"), 2010 to 2012)) == + List(List(Some(-0.03573992567129673), Some(0.539975124774038)), + List(Some(0.10103412653643493), Some(0.24777709700099845))) + + get_deltas(get_prices(List("BIDU"), 2004 to 2008)) == + List(List(None), List(None), + List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) + --> success +Overall mark for CW 6, Part 3 +2 +Below is the feedback and provisional marks for your submission +for assignment 6 Advanced Part 3. Please note all marks are provisional until +ratified by the assessment board -- this is not an official +results transcript. + +drumb.scala does not contain vars, returns, Arrays, ListBuffers etc? + --> success +drumb.scala runs? + --> success + get_delta(None, None) == None + get_delta(Some(100.0), None) == None + get_delta(None, Some(50.0)) == None + get_delta(Some(100.0), Some(50.0)) == Some(1.0) + --> success + get_deltas(get_prices(List("GOOG", "AAPL"), 2010 to 2012)) == + List(List(Some(-0.03573992567129673), Some(0.539975124774038)), + List(Some(0.10103412653643493), Some(0.24777709700099845))) + + get_deltas(get_prices(List("BIDU"), 2004 to 2008)) == + List(List(None), List(None), + List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) + --> success +Overall mark for CW 6, Part 3 +2 +Below is the feedback and provisional marks for your submission +for assignment 6 Advanced Part 3. Please note all marks are provisional until +ratified by the assessment board -- this is not an official +results transcript. + +drumb.scala does not contain vars, returns, Arrays, ListBuffers etc? + --> success +drumb.scala runs? + --> success + get_delta(None, None) == None + get_delta(Some(100.0), None) == None + get_delta(None, Some(50.0)) == None + get_delta(Some(100.0), Some(50.0)) == Some(1.0) + --> success + get_deltas(get_prices(List("GOOG", "AAPL"), 2010 to 2012)) == + List(List(Some(-0.03573992567129673), Some(0.539975124774038)), + List(Some(0.10103412653643493), Some(0.24777709700099845))) + + get_deltas(get_prices(List("BIDU"), 2004 to 2008)) == + List(List(None), List(None), + List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) + --> success +Overall mark for CW 6, Part 3 +2 +Below is the feedback and provisional marks for your submission +for assignment 6 Advanced Part 3. Please note all marks are provisional until +ratified by the assessment board -- this is not an official +results transcript. + +drumb.scala does not contain vars, returns, Arrays, ListBuffers etc? + --> success +drumb.scala runs? + --> success + get_delta(None, None) == None + get_delta(Some(100.0), None) == None + get_delta(None, Some(50.0)) == None + get_delta(Some(100.0), Some(50.0)) == Some(1.0) + --> success + get_deltas(get_prices(List("GOOG", "AAPL"), 2010 to 2012)) == + List(List(Some(-0.03573992567129673), Some(0.539975124774038)), + List(Some(0.10103412653643493), Some(0.24777709700099845))) + + get_deltas(get_prices(List("BIDU"), 2004 to 2008)) == + List(List(None), List(None), + List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) + --> success + val ds = get_deltas(get_prices(List("GOOG", "AAPL"), 2010 to 2012)) + yearly_yield(get_deltas(ds, 100, 0) == 125 + yearly_yield(get_deltas(ds, 100, 1) == 117 + --> success + investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2000, 100) == 100 + investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2001, 100) == 27 + investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2002, 100) == 42 + investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2003, 100) == 27 + investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2004, 100) == 38 + investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2005, 100) == 113 + investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2006, 100) == 254 + investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2007, 100) == 349 + --> success +Overall mark for CW 6, Part 3 +4 diff -r 43995ea34fe7 -r b4812c877b05 marking2/danube_test2.sh --- a/marking2/danube_test2.sh Mon Jan 28 12:49:19 2019 +0000 +++ b/marking2/danube_test2.sh Sat Feb 02 01:21:43 2019 +0000 @@ -27,7 +27,7 @@ # functional tests function scala_assert { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "") #2> /dev/null 1> /dev/null) + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null) } # purity test @@ -50,6 +50,7 @@ tsts0=$(( 0 )) fi + ### compilation test diff -r 43995ea34fe7 -r b4812c877b05 marking2/mk-advanced --- a/marking2/mk-advanced Mon Jan 28 12:49:19 2019 +0000 +++ b/marking2/mk-advanced Sat Feb 02 01:21:43 2019 +0000 @@ -9,24 +9,19 @@ cd $sd echo $sd touch . - cp ../../../marking2/*.sh . - cp ../../../marking2/danube_test1.scala . - cp ../../../marking2/danube_test2.scala . - cp ../../../marking2/docdiff_test1.scala . - cp ../../../marking2/docdiff_test2.scala . - cp ../../../marking2/docdiff_test3.scala . - cp ../../../marking2/docdiff_test4.scala . + cp ../../../marking2/danube_test2.sh . + cp ../../../marking2/danube_test3.scala . + cp ../../../marking2/danube_test4.scala . + cp ../../../marking2/danube_test5.scala . + cp ../../../marking2/danube_test6.scala . cp ../../../marking2/movies.csv . cp ../../../marking2/ratings.csv . - ./docdiff_test.sh output - ./danube_test.sh output - rm *.sh - rm danube_test1.scala - rm danube_test2.scala - rm docdiff_test1.scala - rm docdiff_test2.scala - rm docdiff_test3.scala - rm docdiff_test4.scala + ./danube_test2.sh output + rm danube_test2.sh + rm danube_test3.scala + rm danube_test4.scala + rm danube_test5.scala + rm danube_test6.scala rm ratings.csv rm movies.csv cd ..