Conversation
…re functionally equivalent to functional passing grade function
clair3st
left a comment
There was a problem hiding this comment.
Good work on the implementation, I've provided comments on how some of your code could be improve. Also where are your tests?
| branch: queue | ||
|
|
||
| Deque in deque.py, test in test_deque.py | ||
| branch: deque |
| author="David Lim, Ronel Rustia, Erik Enderlein", | ||
| author_email="armydavidlim@gmail.com", | ||
| license="MIT", | ||
| py_modules=['linked_list', 'stack', 'doubly_linked'], |
| @@ -0,0 +1,178 @@ | |||
| """Graphy mcgraphface""" | |||
There was a problem hiding this comment.
My PEP 8 linter is not happy with this entire file, you need to follow pep 8 styles. Docstrings are needed for all functions, and a space between function definitions!
| def neighbors(self, val): | ||
| """Return all nodes connected to given node.""" | ||
| try: | ||
| to_return = [] |
There was a problem hiding this comment.
This is really unpythonic. Why don't you just return the value of the key given. ie return self.graph_dict[val] in the try except block
| raise KeyError("No such node exists.") | ||
| def adjacent(self, val1, val2): | ||
| """Return True if edge exists, else return false.""" | ||
| try: |
There was a problem hiding this comment.
This also is very unpythonic. In python we can check for membership using the in keyword which will return a boolean. Lines 78-82 could be cut down to 1.
There was a problem hiding this comment.
In this case, we had to be a bit more interesting, since we're looking at a list of lists, the first value of which we are comparing against val2. The earlier iteration of the function used the in keyword, but that proved to not work in this scenario. We did, however, trim it down to a one liner with a lambda function. So there's that.
|
|
||
| def nodes(self): | ||
| """Return a list of all keys in dictionary.""" | ||
| to_return = [] |
There was a problem hiding this comment.
There is an inbuilt dictionary method which would allow you to do this one line.
|
|
||
|
|
||
|
|
||
| if __name__ == '__main__': |
No description provided.