-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
Mypy check polygon and corrections #5419
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
maths/check_polygon.py
Outdated
@@ -14,15 +14,27 @@ def check_polygon(nums: List) -> bool: | |||
True | |||
>>> check_polygon([3, 7, 13, 2]) | |||
False | |||
>>> check_polygon([1, 4.3, 5.2, 12.2]) | |||
False | |||
>>> nums = [3, 7, 13, 2];check_polygon(nums); nums |
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.
I think we can separate this into 3 lines
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.
I will see how this is done
maths/check_polygon.py
Outdated
nums.sort() | ||
return nums.pop() < sum(nums) | ||
if len(nums) < 2: | ||
raise ValueError("List must have at least two values") |
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.
A digon is not a polygon in the Euclidean space I guess?
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.
That is quite interesting,
However I think that a message with errors like
"Monogons and Digons are not polygons in the Euclidean space" could be confusing
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.
Thank you for your pull request!🤩
* Update annotations to Python 3.10 TheAlgorithms#4052 * Add floats doctest * Copy list to avoid changing input unpredictably * Refactor code to make it readable * updating DIRECTORY.md * Improve raised ValueErrors and add doctest * Split doctest in multiples lines * Change ValueError to Monogons and Digons are not poly * Correct doctest refering number of sides Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.