-
-
Couldn't load subscription status.
- Fork 49k
Add comprehensive doctests to arc_length.py #13702
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
base: master
Are you sure you want to change the base?
Conversation
- Improved type hints (int -> float) - Added edge case tests (angle=0, 360, 180) - Added float value tests - Added error handling for negative values - Enhanced docstring with formula and Wikipedia link - Added proper error messages Contributes to TheAlgorithms#9943
for more information, see https://pre-commit.ci
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.
Great improvements to the arc_length.py file! Here's my review:
Strengths:
-
Comprehensive Doctests: Excellent addition of edge case tests (angle=0, 360, 180) and error handling tests for negative values.
-
Improved Type Hints: Changing from
inttofloatin the function signature is correct since arc length calculations typically work with floating-point numbers. -
Better Documentation: The enhanced docstring with formula, Wikipedia link, and clear parameter descriptions makes the function much more understandable.
-
Proper Error Handling: Adding ValueError for negative inputs with descriptive messages is a solid improvement.
Suggestions for Improvement:
-
Doctest Import Location: Consider moving
import doctestto the top of the file with other imports rather than at the bottom, following PEP 8 conventions. -
Float Value Tests: Some of the doctest examples use float inputs (e.g.,
arc_length(45.5, 10.5)), which is great for testing, but the expected output values should be verified for accuracy. -
Consider Testing Larger Angles: While you test 0, 180, and 360, it might be worth noting in the docstring whether angles > 360 are expected or should also raise an error.
Overall, this is a quality PR that significantly improves the code quality and testing coverage. Nice work!
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Contributes to #9943
Describe your change:
Checklist: