foundations-of-applied-mathematics / labs Goto Github PK
View Code? Open in Web Editor NEWLabs for the Foundations of Applied Mathematics curriculum.
Home Page: https://foundations-of-applied-mathematics.github.io/
Labs for the Foundations of Applied Mathematics curriculum.
Home Page: https://foundations-of-applied-mathematics.github.io/
I had two students who returned valid shortest path lists that did not match what the auto grader was expecting. Below you will find their code and feedback.
----------Student 1----------
CODE:
if source not in self.d.keys():
raise KeyError("source node not in graph")
# initialize list
V = []
# initialize deque
Q = deque(source)
# initialize set
M = set(source)
#traverse through graph step
while set(V) != set(self.d.keys()): # until traversed graph
diff = self.d[source].difference(M)
M = M.union(self.d[source]) # update
for x in diff:
Q.append(x)
source = Q.popleft()
V.append(source) #append visited nodes
return V
FEEDBACK:
Problem 2 (10 points):
Graph.traverse('A') failed
Graph: {'A': {'C', 'B'}, 'B': {'D', 'E', 'A'}, 'C': {'F', 'G', 'A'}, 'D': {'H', 'I', 'B'}, 'E': {'K', 'J', 'B'}, 'F': {'M', 'L', 'C'}, 'G': {'N', 'O', 'C'}, 'H': {'D'}, 'I': {'D'}, 'J': {'E'}, 'K': {'E'}, 'L': {'F'}, 'M': {'F'}, 'N': {'G'}, 'O': {'G'}}
Correct response: "['A', 'C', 'B', 'F', 'G', 'D', 'E', 'M', 'L', 'N', 'O', 'H', 'I', 'K', 'J']"
Student response: "['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'J', 'M', 'L', 'N', 'O']"
Score += 8
----------Student 2----------
CODE:
#raise NotImplementedError("Problem 2 Incomplete")
V = [] # .append
Q = deque() #.append #pop(0)
M = set() #use .add
M.add(source) #append the fist one
Q.append(source)
while len(Q) != 0:
current_node = Q.popleft() #pop the first one and call it current node
V.append(current_node) #append it to V
for x in self.d[current_node]-M: #for loop so we add each individually, and subtract M so we dont re-add stuff
M.add(x) #self.d[current_node] is the neighbors
Q.append(x)
return V
FEEDBACK:
Problem 2 (10 points):
Graph.traverse('A') failed
Graph: {'A': {'C', 'B'}, 'B': {'D', 'E', 'A'}, 'C': {'F', 'G', 'A'}, 'D': {'H', 'I', 'B'}, 'E': {'K', 'J', 'B'}, 'F': {'M', 'L', 'C'}, 'G': {'N', 'O', 'C'}, 'H': {'D'}, 'I': {'D'}, 'J': {'E'}, 'K': {'E'}, 'L': {'F'}, 'M': {'F'}, 'N': {'G'}, 'O': {'G'}}
Correct response: "['A', 'C', 'B', 'F', 'G', 'D', 'E', 'M', 'L', 'N', 'O', 'H', 'I', 'K', 'J']"
Student response: "['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'J', 'M', 'L', 'N', 'O']"
Score += 8
There appears to be a typo in exercise 7 of Lab 08. In particular, there is a snippet of code which reads:
def matrix_power(A, n):
"""Compute A^n, the n-th power of the matrix A."""
product = A.copy()
temporary_array = np.empty_like(A[0])
m = A.shape[0]
for power in range(1, power):
#...
I think that the for loop should be changed to:
for power in range(1, n):
This can also be found on line 757 in the profiling.tex
file
There is a typo in the Additional Material section regarding complex QR decomposition. As I was working to apply the changes, I think I found that the defined sign(x) function might be incorrect. I believe it should be sign = lambda x: x/np.abs(x) if x!=0 else 1
instead of sign = lambda x: 1 if np.real(x) >= 0 else -1
.
On the first page of the Breadth First Search Lab, the D row of this adjacency dictionary should be D : {A, B, C}.
In the test_driver.py file for breadth first search, two of the test graphs are directed, where students can only make undirected graphs on problem 2.
(see pictures file for more details)
This paragraph is incorrect.
https://github.com/Foundations-of-Applied-Mathematics/Labs/blob/master/PythonEssentials/StandardLibrary/StandardLibrary.tex#L151
Assigning a new name to an immutable object does not create a copy. Both names simply point to the same object in memory. IIRC, assignments in Python never create copies.
a = (1, 2, 3) # immutable tuple
b = a # b now references the same object as a
id(a) == id(a) # True
For the string magic method of ComplexNumber there's a "# Or, more likely," after the return statement with a way that students would probably code it. For the case where the complex part is negative it returns sign + str(self.imag) but a negative number cast as a string already has a negative sign. So this would print two negative signs.
Clarify in the problem where you add "hunter" to the last element of the string that they know it should read "bearhunter" not "bear hunter"
On page 8 of Python Essentials you are using the words "named arguments" without ever defining them.
The ContentFilter class (problems 3 and 4), the doc string for the class is in the wrong place. It is written before the class definition.
Suggestion for @jhumpherys @tylerjarvis. I wanted to make a suggestion for the labs that would really give them more legs and accessibility. The Jupyter people have now come up with a format (Jupyter Book) that really marries the PDF concept with the html concept with the executable code concept in a way that can be version controlled. Here is the workflow.
I think this is the sweet spot. We've moved all the documentation for a number of our open source projects over to Jupyter Books. The two following examples are still under development, but they are far enough along to show a lot of the functionality of the medium.
It has come to my attention that the Exceptions and File IO lab has a section on string manipulation. It mentions format strings, but never mentions f strings. These are a more readable, more concise, and less prone to error than other ways of formatting, and they are also faster.
Example: In the third-to-last code block of the lab, you have the following code:
print("Is today {} {}, {}?".format(day, month, year))
Which could be simplified to the following using an f-string:
print(f"Is today {day} {month}, {year}?")
ADD F STRINGS WHERE NEEDED!!!
The statement " The comma after the print command suppresses the automatic newline character, keeping the output of each individual print statement on the same line" is no longer correct, and does not reflect the code as it is in the lab currently.
The transforms problem (#1) should say "return a transformation of the data" not "return the transformed data" because at least one student actually made his code transform the original data array, so that the data input for the next method was corrupted by the previous method. It's a subtle change in wording, but an important point for the students to learn.
It has come to my attention that the Exceptions and File IO lab has a section on string manipulation. It mentions format strings, but never mentions f strings. These are a more readable, more concise, and less prone to error than other ways of formatting, and they are also faster.
Example: In the third-to-last code block of the lab, you have the following code:
print("Is today {} {}, {}?".format(day, month, year))
Which could be simplified to the following using an f-string:
print(f"Is today {day} {month}, {year}?")
In addition, the statement " The comma after the print command suppresses the automatic newline character, keeping the output of each individual print statement on the same line" is no longer correct, and does not reflect the code as it is in the lab currently.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.