Implementation of the algorithm for the Koch snowflake - #4207
Conversation
Implementation of the algorithm for the Koch snowflake
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: VECTOR1
|
|
||
| # initial triangle of Koch snowflake | ||
| VECTOR1 = numpy.array([0, 0]) | ||
| VECTOR2 = numpy.array([0.5, 0.8660254]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: VECTOR2
| # initial triangle of Koch snowflake | ||
| VECTOR1 = numpy.array([0, 0]) | ||
| VECTOR2 = numpy.array([0.5, 0.8660254]) | ||
| VECTOR3 = numpy.array([1, 0]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: VECTOR3
| return numpy.dot(rotation_matrix, vector) | ||
|
|
||
|
|
||
| def plot(vectors: list[numpy.ndarray]) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file other/koch_snowflake.py, please provide doctest for the function plot
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
|
|
||
|
|
||
| # initial triangle of Koch snowflake | ||
| VECTOR_1 = numpy.array([0, 0]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: VECTOR_1
|
|
||
| # initial triangle of Koch snowflake | ||
| VECTOR_1 = numpy.array([0, 0]) | ||
| VECTOR_2 = numpy.array([0.5, 0.8660254]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: VECTOR_2
| # initial triangle of Koch snowflake | ||
| VECTOR_1 = numpy.array([0, 0]) | ||
| VECTOR_2 = numpy.array([0.5, 0.8660254]) | ||
| VECTOR_3 = numpy.array([1, 0]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: VECTOR_3
| return numpy.dot(rotation_matrix, vector) | ||
|
|
||
|
|
||
| def plot(vectors: list[numpy.ndarray]) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file other/koch_snowflake.py, please provide doctest for the function plot
|
Hello, it would be great if I could get some feedback on how to respond to the failed tests. |
|
The bot just gives guidance. Tests failed because you didn't run isort. Here's the isort diff: As you can see, a newline was added between |
I fixed the sorting of the imports and I added a comment to the plot-function to explain what it does and why it doesn't use a doctest. Thank you to user mrmaxguns for suggesting these changes.
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| Utility function to plot the vectors using matplotlib.pyplot | ||
| No doctest was implemented since this function does not have a return value | ||
| """ | ||
| import matplotlib.pyplot. |
There was a problem hiding this comment.
An error occured while parsing the file: other/koch_snowflake.py
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.8/site-packages/libcst/_parser/base_parser.py", line 152, in _add_token
plan = stack[-1].dfa.transitions[transition]
KeyError: TokenType(NEWLINE)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/algorithms_keeper/parser/python_parser.py", line 145, in parse
reports = lint_file(
libcst._exceptions.ParserSyntaxError: Syntax Error @ 99:30.
Incomplete input. Encountered '\r\n', but expected 'NAME'.
import matplotlib.pyplot.
^
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| import numpy | ||
|
|
||
| # initial triangle of Koch snowflake | ||
| VECTOR_1 = numpy.array([0, 0]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: VECTOR_1
|
|
||
| # initial triangle of Koch snowflake | ||
| VECTOR_1 = numpy.array([0, 0]) | ||
| VECTOR_2 = numpy.array([0.5, 0.8660254]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: VECTOR_2
| # initial triangle of Koch snowflake | ||
| VECTOR_1 = numpy.array([0, 0]) | ||
| VECTOR_2 = numpy.array([0.5, 0.8660254]) | ||
| VECTOR_3 = numpy.array([1, 0]) |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: VECTOR_3
| return numpy.dot(rotation_matrix, vector) | ||
|
|
||
|
|
||
| def plot(vectors: list[numpy.ndarray]) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file other/koch_snowflake.py, please provide doctest for the function plot
|
Dear mrmaxguns, thank you for the feedback, I have implemented the changes you suggested. |
|
This looks good. Nice work. I am not a fan of uncategorized algorithms in the |
| x_coordinates = [] | ||
| for vector in vectors: | ||
| x_coordinates.append(vector[0]) | ||
| y_coordinates = [] | ||
| for vector in vectors: | ||
| y_coordinates.append(vector[1]) |
There was a problem hiding this comment.
Please make these list comprehensions.
There was a problem hiding this comment.
Or maybe even slicker, use zip() instead.
| 0.28867513]), array([0.66666667, 0. ]), array([1, 0])] | ||
| """ | ||
| new_vectors = [] | ||
| for i in range(len(vectors) - 1): |
There was a problem hiding this comment.
range(len()) is almost always a sign that enumerate() could be used instead.
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| return numpy.dot(rotation_matrix, vector) | ||
|
|
||
|
|
||
| def plot(vectors: list[numpy.ndarray]) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file graphics/koch_snowflake.py, please provide doctest for the function plot
|
I have implemented the changes, thanks for the advice on better looping. I think |
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file graphics/koch_snowflake.py, please provide doctest for the function plot
…#4207) * Add files via upload Implementation of the algorithm for the Koch snowflake * added underscore to variable names * added newline and comment I fixed the sorting of the imports and I added a comment to the plot-function to explain what it does and why it doesn't use a doctest. Thank you to user mrmaxguns for suggesting these changes. * fixed accidental newline in the middle of expression * improved looping * moved "koch_snowflake.py" from "other" to "graphics" * Update koch_snowflake.py Co-authored-by: Christian Clauss <cclauss@me.com>
…#4207) * Add files via upload Implementation of the algorithm for the Koch snowflake * added underscore to variable names * added newline and comment I fixed the sorting of the imports and I added a comment to the plot-function to explain what it does and why it doesn't use a doctest. Thank you to user mrmaxguns for suggesting these changes. * fixed accidental newline in the middle of expression * improved looping * moved "koch_snowflake.py" from "other" to "graphics" * Update koch_snowflake.py Co-authored-by: Christian Clauss <cclauss@me.com>
…#4207) * Add files via upload Implementation of the algorithm for the Koch snowflake * added underscore to variable names * added newline and comment I fixed the sorting of the imports and I added a comment to the plot-function to explain what it does and why it doesn't use a doctest. Thank you to user mrmaxguns for suggesting these changes. * fixed accidental newline in the middle of expression * improved looping * moved "koch_snowflake.py" from "other" to "graphics" * Update koch_snowflake.py Co-authored-by: Christian Clauss <cclauss@me.com>

Implementation of the algorithm for the Koch snowflake
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.