Skip to content

Added some more comments to volume.py in maths folder #7080

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

Merged
merged 7 commits into from
Oct 16, 2022

Conversation

advik-student-dev
Copy link
Contributor

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

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

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
@algorithms-keeper algorithms-keeper bot added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed labels Oct 13, 2022
Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

maths/volume.py Outdated
Comment on lines 291 to 294
# 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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

maths/volume.py Outdated
Comment on lines 318 to 321
# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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

maths/volume.py Outdated
@@ -378,6 +385,7 @@ def vol_conical_frustum(height: float, radius_1: float, radius_2: float) -> floa
...
ValueError: vol_conical_frustum() only accepts non-negative values
"""
# Volume - 1/3 * pi * height * (radius_1 squared + radius_2 squared + radius_1 * radius_2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@algorithms-keeper algorithms-keeper bot added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Oct 13, 2022
@algorithms-keeper algorithms-keeper bot added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Oct 13, 2022
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 13, 2022
@cclauss cclauss added hacktoberfest hacktoberfest-accepted Accepted to be counted towards Hacktoberfest labels Oct 13, 2022
Copy link

@Aadi077 Aadi077 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change "volume -" to "volume is" because - has another meaning which would not apply.

Copy link
Contributor Author

@advik-student-dev advik-student-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank u for the changes!

@advik-student-dev
Copy link
Contributor Author

how do i commit your changes?

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 16, 2022
@raghavasrujan
Copy link

Hello Sir, Can you assign this to me?

@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 16, 2022
@cclauss cclauss merged commit d728f5a into TheAlgorithms:master Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This PR modified some existing files hacktoberfest hacktoberfest-accepted Accepted to be counted towards Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants