Added some more comments to volume.py in maths folder - #7080
Conversation
added some more comments (to formulas which need it) which make the code more readable and understandable. might make a list of all the formulas on the top, later
for more information, see https://pre-commit.ci
cclauss
left a comment
There was a problem hiding this comment.
I have moved the comments down to be just above the calculations. I have changed the order of the terms to be the same in both the comments and the calculations. I have changed Volume - to Volume is because - has a special meaning in calculations. ;-)
Please fix the line that is failing our tests because it has more than 88 characters.
There was a problem hiding this comment.
| # Volume - 4/3 * pi * radius cubed | |
| if radius < 0: | |
| raise ValueError("vol_hemisphere() only accepts non-negative values") | |
| return 2 / 3 * pi * pow(radius, 3) | |
| if radius < 0: | |
| raise ValueError("vol_hemisphere() only accepts non-negative values") | |
| # Volume is radius cubed * pi * 2/3 | |
| return pow(radius, 3) * pi * 2 / 3 |
| # Volume - radius squared * height * pi | ||
| if height < 0 or radius < 0: | ||
| raise ValueError("vol_circular_cylinder() only accepts non-negative values") | ||
| return pi * pow(radius, 2) * height |
There was a problem hiding this comment.
| # Volume - radius squared * height * pi | |
| if height < 0 or radius < 0: | |
| raise ValueError("vol_circular_cylinder() only accepts non-negative values") | |
| return pi * pow(radius, 2) * height | |
| if height < 0 or radius < 0: | |
| raise ValueError("vol_circular_cylinder() only accepts non-negative values") | |
| # Volume is radius squared * height * pi | |
| return pow(radius, 2) * height * pi |
| ... | ||
| ValueError: vol_conical_frustum() only accepts non-negative values | ||
| """ | ||
| # Volume - 1/3 * pi * height * (radius_1 squared + radius_2 squared + radius_1 * radius_2) |
There was a problem hiding this comment.
Tests are failing on:
- maths/volume.py:388:89: E501 line too long (94 > 88 characters)
Also, please move this line down to be just above the calculation. Make sure that the order of the values in the comment and in the calculation are the same.
for more information, see https://pre-commit.ci
Aadi077
left a comment
There was a problem hiding this comment.
Change "volume -" to "volume is" because - has another meaning which would not apply.
jpyces
left a comment
There was a problem hiding this comment.
thank u for the changes!
|
how do i commit your changes? |
for more information, see https://pre-commit.ci

added some more comments (to formulas which need it) which make the code more readable and understandable. might make a list of all the formulas on the top, later
Checklist:
Fixes: #{$ISSUE_NO}.