The Wayback Machine - https://web.archive.org/web/20211019020851/https://github.com/TheAlgorithms/Python/pull/5044
Skip to content
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

Re-organize math/series #5044

Merged
merged 6 commits into from Oct 18, 2021
Merged

Re-organize math/series #5044

merged 6 commits into from Oct 18, 2021

Conversation

@atharva01903
Copy link
Contributor

@atharva01903 atharva01903 commented Oct 5, 2021

Describe your change:

Added the implementation of harmonic mean.

  • 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}.
@atharva01903
Copy link
Contributor Author

@atharva01903 atharva01903 commented Oct 5, 2021

@poyea @dhruvmanila Hello, can anyone of you please review my contribution to this repository? I'll be glad to get some suggestions and learn from them,

Thanks.

maths/series/harmonic_mean.py Outdated Show resolved Hide resolved
Updated the write-up of reference given in the code.

Co-authored-by: John Law <johnlaw.po@gmail.com>
@atharva01903
Copy link
Contributor Author

@atharva01903 atharva01903 commented Oct 7, 2021

Thanks @poyea for the suggestion and reviewing my code :) I've made the change. Also, I checked other implementations in the the /maths/series folder. In the implementation of arithmetic mean and geometric mean, the code first checks if a series is an arithmetic or a geometric series respectively. But arithmetic and geometric mean can be computed without the series actually being an arithmetic and a geometric series respectively. So the condition that requires a series to follow arithmetic or geometric progression should be removed. Should I proceed to make that change?

@atharva01903 atharva01903 requested a review from poyea Oct 11, 2021
@poyea
Copy link
Member

@poyea poyea commented Oct 11, 2021

Yes, you may make those changes on this branch.

poyea
poyea approved these changes Oct 11, 2021
@atharva01903
Copy link
Contributor Author

@atharva01903 atharva01903 commented Oct 12, 2021

Thank you so much @poyea for the approval. I have incorporated the changes to the branch. 😊👍🏼

@atharva01903
Copy link
Contributor Author

@atharva01903 atharva01903 commented Oct 15, 2021

@poyea Ah yes, we can do that as well! I think it is better to add the methods is_arithmetic_series and is_geometric_series to a new file arithmetic_series.py (as it isn't available in the repository) and geometric_series.py respectively. So along with the implementation we can also check if the series is arithmetic/geometric. With that we can add one more method is_harmonic_series to the file harmonic_series.py. Do tell me if you need those changes.

@poyea
Copy link
Member

@poyea poyea commented Oct 16, 2021

@poyea Ah yes, we can do that as well! I think it is better to add the methods is_arithmetic_series and is_geometric_series to a new file arithmetic_series.py (as it isn't available in the repository) and geometric_series.py respectively. So along with the implementation we can also check if the series is arithmetic/geometric. With that we can add one more method is_harmonic_series to the file harmonic_series.py. Do tell me if you need those changes.

@atharva01903 Let's do it this way:
In maths/series/, we make 3 files: arithmetic.py, geometric.py and harmonic.py. Then add the mean and is_series functions is each of the files.

@poyea poyea changed the title added harmonic mean Oct 16, 2021
@atharva01903
Copy link
Contributor Author

@atharva01903 atharva01903 commented Oct 17, 2021

Alright @poyea, I did that. Now the mean and is_series functions lie in a single file. 👍🏼

poyea
poyea approved these changes Oct 18, 2021
Copy link
Member

@poyea poyea left a comment

Thank you for your pull request!🤩

@poyea poyea changed the title add harmonic mean Oct 18, 2021
@poyea poyea merged commit 1e64bf4 into TheAlgorithms:master Oct 18, 2021
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants