-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Physics new code #4709
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
Physics new code #4709
Conversation
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
Wait for me do list is endless
…On Sat, Sep 4, 2021, 5:27 AM algorithms-keeper[bot] < ***@***.***> wrote:
***@***.***[bot]* commented on this pull request.
*Click here to look at the relevant links ⬇️*
🔗 Relevant Links Repository:
- Contributing guidelines
<https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md>
- Project Euler solution guidelines
<https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md>
Python:
- Formatted string literals (f-strings)
<https://docs.python.org/3/tutorial/inputoutput.html#tut-f-strings>
- Type hints <https://docs.python.org/3/library/typing.html>
- doctest <https://docs.python.org/3/library/doctest.html>
- unittest <https://docs.python.org/3/library/unittest.html>
- pytest <https://docs.pytest.org/en/stable/>
Automated review generated by algorithms-keeper
<https://github.com/dhruvmanila/algorithms-keeper>. If there's any
problem regarding this review, please open an issue about it.
<https://github.com/dhruvmanila/algorithms-keeper/issues>
------------------------------
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
- @algorithms-keeper review to trigger the checks for only added pull
request files
- @algorithms-keeper review-all to trigger the checks for all the pull
request files, including the modified files. As we cannot post review
comments on lines not part of the diff, this command will post all the
messages in one comment.
NOTE: Commands are in beta and so this feature is restricted only to a
member or owner of the organization.
------------------------------
In physics/gamma_function.py
<#4709 (comment)>:
> + raise ValueError
+ # Ensure print an error message
+ except ValueError:
+ print("Invalid input: Must be an integer or an half-integer!")
+ number = False
+ finally:
+ # Ensure input is a valid number
+ if number:
+ # Ensure input is an integer
+ if (isinstance(gamma(num), int)):
+ # Print result
+ print(gamma(num))
+ # Otherwise print results with √π (gamma of 0.5 is √π)
+ # Therefore all results will be a number times √π
+ else:
+ results = "{result:.4f}".format(result=gamma(num) / sqrt(pi))
As mentioned in the Contributing Guidelines
<https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md>,
please do not use printf style formatting or str.format(). Use f-string
<https://realpython.com/python-f-strings/> instead to be more readable
and efficient.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4709 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQQ66J4HJLBIATHBQNMFVX3UAFOGPANCNFSM5DMUVRRA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
And also changed output to math notation
One last request. Good Work.👍 👍 👍 |
Done. Thank You. |
@cclauss have a look at this. |
It is working |
And comments
Replicate the exceptions of https://docs.python.org/3/library/math.html#math.gamma
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.
Nice work. I modified the exceptions to more closely mimic the Python's Standard Library math.gamma()
function.
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.
@Dummy59 Can you please explain what was done here? |
* added gamma_function * Add files via upload * Resolved issue with str.format And also changed output to math notation * Update gamma_function.py * Rename physics/gamma_function.py to maths/gamma_recursive.py * Fixes: TheAlgorithms#4709 Fixed issues for pre-commit test * Fixes: TheAlgorithms#4709 solved issues with doctests And comments * Fixes: TheAlgorithms#4709 Added failed tests to doctest * Align with Python's Standard Library math.gamma() Replicate the exceptions of https://docs.python.org/3/library/math.html#math.gamma * Update gamma_recursive.py * Update gamma_recursive.py * Update gamma_recursive.py * Update gamma_recursive.py Co-authored-by: Christian Clauss <[email protected]>
Describe your change:
Added new file to Physics folder. This file contain a function to calculate gamma function which is a common tool used in physics.
Checklist:
Fixes: #{$ISSUE_NO}
.