Added some more comments to volume.py in maths folder by jpyces · Pull Request #7080 · TheAlgorithms/Python · GitHub
Skip to content

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

Merged
cclauss merged 7 commits into
TheAlgorithms:masterfrom
jpyces:patch-3
Oct 16, 2022
Merged

cclauss merged 7 commits into
TheAlgorithms:masterfrom
jpyces:patch-3

Conversation

@jpyces

@jpyces jpyces commented Oct 13, 2022

Copy link
Copy Markdown
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
@jpyces
jpyces requested a review from Kush1101 as a code owner October 13, 2022 03:14
@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

@cclauss cclauss left a comment

Copy link
Copy Markdown
Member

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.

Comment thread maths/volume.py Outdated
Comment thread maths/volume.py Outdated
Comment thread maths/volume.py Outdated
Comment thread maths/volume.py Outdated
Comment thread maths/volume.py Outdated
Comment thread maths/volume.py Outdated
Comment thread maths/volume.py Outdated
Comment on lines 291 to 294

Copy link
Copy Markdown
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

Comment thread 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
Copy Markdown
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

Comment thread maths/volume.py Outdated
...
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
Copy Markdown
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
Comment thread maths/volume.py
@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
Comment thread maths/volume.py Outdated

@Aadi077 Aadi077 left a comment

Copy link
Copy Markdown

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.

@jpyces jpyces left a comment

Copy link
Copy Markdown
Contributor Author

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!

@jpyces

jpyces commented Oct 16, 2022

Copy link
Copy Markdown
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
Copy Markdown

@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