Skip to content
Snippets Groups Projects
Commit b2b82a49 authored by tuhe's avatar tuhe
Browse files

unitgrade private

parent 9e100df5
No related branches found
No related tags found
No related merge requests found
Showing
with 360 additions and 872 deletions
...@@ -5,17 +5,11 @@ def bacteriaGrowth(n0, alpha, K, N): ...@@ -5,17 +5,11 @@ def bacteriaGrowth(n0, alpha, K, N):
""" """
Calculate time until bacteria growth exceed N starting from a population of n0 bacteria. Calculate time until bacteria growth exceed N starting from a population of n0 bacteria.
hints: hints:
* consider n0 * You need to update the number of bacteria n0 within a loop
* alpha > 0
:param n0:
:param alpha:
:param K:
:param N:
:return:
""" """
# TODO: 6 lines missing. # TODO: 7 lines missing.
raise NotImplementedError("Implement function body") raise NotImplementedError("Implement function body")
return t+1 return t
def clusterAnalysis(reflectance): def clusterAnalysis(reflectance):
reflectance = np.asarray(reflectance) reflectance = np.asarray(reflectance)
...@@ -29,14 +23,16 @@ def clusterAnalysis(reflectance): ...@@ -29,14 +23,16 @@ def clusterAnalysis(reflectance):
return I1 + 1 return I1 + 1
def fermentationRate(measuredRate, lowerBound, upperBound): def fermentationRate(measuredRate, lowerBound, upperBound):
# Insert your code here """
return np.mean( [r for r in measuredRate if lowerBound < r < upperBound] ) Compute and return the mean value of the rates in 'measuredRate'
which falls within lowerBound and upperBound.
"""
mean_value = np.mean( [r for r in measuredRate if lowerBound < r < upperBound] )
return mean_value
def removeIncomplete(id): def removeIncomplete(id):
""" Hints: """
Hints:
* Take a look at the example in the exercise. * Take a look at the example in the exercise.
""" """
id = np.asarray(id) id = np.asarray(id)
...@@ -46,15 +42,10 @@ def removeIncomplete(id): ...@@ -46,15 +42,10 @@ def removeIncomplete(id):
id2.append(v) id2.append(v)
return np.asarray(id2) return np.asarray(id2)
if __name__ == "__main__": if __name__ == "__main__":
# I = clusterAnalysis([1.7, 1.6, 1.3, 1.3, 2.8, 1.4, 2.8, 2.6, 1.6, 2.7]) # I = clusterAnalysis([1.7, 1.6, 1.3, 1.3, 2.8, 1.4, 2.8, 2.6, 1.6, 2.7])
# print(I) # print(I)
print(fermentationRate(np.array([20.1, 19.3, 1.1, 18.2, 19.7, 121.1, 20.3, 20.0]), 15, 25)) print(fermentationRate(np.array([20.1, 19.3, 1.1, 18.2, 19.7, 121.1, 20.3, 20.0]), 15, 25))
# print(removeIncomplete(np.array([1.3, 2.2, 2.3, 4.2, 5.1, 3.2, 5.3, 3.3, 2.1, 1.1, 5.2, 3.1]))) # print(removeIncomplete(np.array([1.3, 2.2, 2.3, 4.2, 5.1, 3.2, 5.3, 3.3, 2.1, 1.1, 5.2, 3.1])))
# Problem 1: Write a function which add two numbers # Problem 1: Write a function which add two numbers
# clusterAnalysis([2, 1, 2, 4, 5]) # clusterAnalysis([2, 1, 2, 4, 5])
...@@ -130,7 +130,7 @@ class FermentationRate(UTestCase): ...@@ -130,7 +130,7 @@ class FermentationRate(UTestCase):
class Report1Flat(Report): class Report1Flat(Report):
title = "Week 4: Looping" title = "02531 week 5: Looping"
questions = [(ClusterAnalysis, 10), (RemoveIncomplete, 10), (Bacteria, 10), (FermentationRate, 10),] questions = [(ClusterAnalysis, 10), (RemoveIncomplete, 10), (Bacteria, 10), (FermentationRate, 10),]
pack_imports = [looping] pack_imports = [looping]
......
This diff is collapsed.
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
File deleted
File deleted
File deleted
File deleted
from cs102_autolab.report2_test import Report2
from unitgrade_private.hidden_create_files import setup_grade_file_report
from snipper.snip_dir import snip_dir
if __name__ == "__main__":
setup_grade_file_report(Report2)
snip_dir("./", "../../students/cs102", clean_destination_dir=True, exclude=['*.token', 'deploy.py'])
pass
\ No newline at end of file
...@@ -10,6 +10,7 @@ if __name__ == "__main__": ...@@ -10,6 +10,7 @@ if __name__ == "__main__":
from unitgrade import version from unitgrade import version
print("version", version.__version__) print("version", version.__version__)
# Set up the instructor _grade script and all files needed for the tests. # Set up the instructor _grade script and all files needed for the tests.
setup_grade_file_report(Report2, with_coverage=False, bzip=True) setup_grade_file_report(Report2, with_coverage=False, bzip=True)
snip_dir("./", "../../students/cs102_autolab", clean_destination_dir=True, exclude=['*.token', 'deploy*.py', '*_grade.py', 'tmp', '*.tar']) snip_dir("./", "../../students/cs102_autolab", clean_destination_dir=True, exclude=['*.token', 'deploy*.py', '*_grade.py', 'tmp', '*.tar'])
...@@ -26,13 +27,11 @@ if __name__ == "__main__": ...@@ -26,13 +27,11 @@ if __name__ == "__main__":
from report2_test import Report2 from report2_test import Report2
# INSTRUCTOR_GRADE_FILE = # INSTRUCTOR_GRADE_FILE =
output_tar = new_deploy_assignment("cs105h", # Autolab name of assignment (and name of .tar file) output_tar = new_deploy_assignment("cs105h", # Autolab name of assignment (and name of .tar file)
INSTRUCTOR_REPORT_CLASS=Report2,
INSTRUCTOR_BASE=instructor_base, INSTRUCTOR_BASE=instructor_base,
INSTRUCTOR_GRADE_FILE=f"{instructor_base}/report2_test_grade.py", INSTRUCTOR_GRADE_FILE=f"{instructor_base}/report2_test_grade.py",
STUDENT_BASE=student_base, STUDENT_BASE=student_base,
STUDENT_GRADE_FILE=f"{instructor_base}/report2_test.py", STUDENT_GRADE_FILE=f"{instructor_base}/report2_test.py",
autograde_image_tag=autograde_image, autograde_image_tag=autograde_image,
student_should_upload_token=False,
homework_file="homework1.py") #!s homework_file="homework1.py") #!s
# What can you do? Get a report class from the .token file? # What can you do? Get a report class from the .token file?
......
File deleted
...@@ -10,7 +10,6 @@ def add(a,b): #!f ...@@ -10,7 +10,6 @@ def add(a,b): #!f
> add(a,b) = a+b """ > add(a,b) = a+b """
return a+b*2 return a+b*2
if __name__ == "__main__": if __name__ == "__main__": # Example usage:
# Example usage:
print(f"Your result of 2 + 2 = {add(2,2)}") print(f"Your result of 2 + 2 = {add(2,2)}")
print(f"Reversing a small list", reverse_list([2,3,5,7])) #!s print(f"Reversing a small list", reverse_list([2,3,5,7])) #!s
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment