Physics new code#4709
Physics new code#4709cclauss merged 13 commits intoTheAlgorithms:masterfrom avivfaraj:physics_new_code
Conversation
ghost
left a comment
There was a problem hiding this comment.
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 reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto 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.
Nice work. I modified the exceptions to more closely mimic the Python's Standard Library math.gamma() function.
|
@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 <cclauss@me.com>
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}.