-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Implementation of the algorithm for the Koch snowflake #4207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implementation of the algorithm for the Koch snowflake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to 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.
other/koch_snowflake.py
Outdated
|
||
|
||
# initial triangle of Koch snowflake | ||
VECTOR1 = numpy.array([0, 0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: VECTOR1
other/koch_snowflake.py
Outdated
|
||
# initial triangle of Koch snowflake | ||
VECTOR1 = numpy.array([0, 0]) | ||
VECTOR2 = numpy.array([0.5, 0.8660254]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: VECTOR2
other/koch_snowflake.py
Outdated
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: VECTOR3
other/koch_snowflake.py
Outdated
return numpy.dot(rotation_matrix, vector) | ||
|
||
|
||
def plot(vectors: list[numpy.ndarray]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to 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.
other/koch_snowflake.py
Outdated
|
||
|
||
# initial triangle of Koch snowflake | ||
VECTOR_1 = numpy.array([0, 0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: VECTOR_1
other/koch_snowflake.py
Outdated
|
||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: VECTOR_2
other/koch_snowflake.py
Outdated
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: VECTOR_3
other/koch_snowflake.py
Outdated
return numpy.dot(rotation_matrix, vector) | ||
|
||
|
||
def plot(vectors: list[numpy.ndarray]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to 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.
other/koch_snowflake.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to 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.
other/koch_snowflake.py
Outdated
import numpy | ||
|
||
# initial triangle of Koch snowflake | ||
VECTOR_1 = numpy.array([0, 0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: VECTOR_1
other/koch_snowflake.py
Outdated
|
||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: VECTOR_2
other/koch_snowflake.py
Outdated
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: VECTOR_3
other/koch_snowflake.py
Outdated
return numpy.dot(rotation_matrix, vector) | ||
|
||
|
||
def plot(vectors: list[numpy.ndarray]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
other/koch_snowflake.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make these list comprehensions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe even slicker, use zip()
instead.
other/koch_snowflake.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
range(len())
is almost always a sign that enumerate()
could be used instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
…#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 <[email protected]>
…#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 <[email protected]>
Implementation of the algorithm for the Koch snowflake
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.