Skip to content

Remove extra imports in gamma.py doctests #8060

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 29 commits into from
Dec 29, 2022
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
afd78da
Refactor bottom-up function to be class method
tianyizheng02 Oct 17, 2022
f4eeecc
Add type hints
tianyizheng02 Oct 17, 2022
ceea9e5
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 17, 2022
167e5ab
Update convolve function namespace
tianyizheng02 Oct 17, 2022
fc87168
Merge branch 'TheAlgorithms:master' into horn-schunck
tianyizheng02 Oct 17, 2022
b705de4
Merge branch 'TheAlgorithms:master' into horn-schunck
tianyizheng02 Oct 18, 2022
6bd4c52
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 18, 2022
ca7d15b
Merge pull request #1 from tianyizheng02/horn-schunck
tianyizheng02 Oct 18, 2022
5386e57
Remove depreciated np.float
tianyizheng02 Oct 18, 2022
05ba8b4
Merge branch 'TheAlgorithms:master' into decision-tree
tianyizheng02 Oct 18, 2022
67cabe3
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 18, 2022
43004d4
Merge pull request #2 from tianyizheng02/decision-tree
tianyizheng02 Oct 18, 2022
0f91598
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 18, 2022
3a4d643
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 19, 2022
cdb6991
updating DIRECTORY.md
Oct 19, 2022
9f43720
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 19, 2022
c1a8506
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 20, 2022
7876108
updating DIRECTORY.md
Oct 20, 2022
6fb21e9
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 21, 2022
15594ff
updating DIRECTORY.md
Oct 21, 2022
42b4b0f
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 22, 2022
46b7978
updating DIRECTORY.md
Oct 22, 2022
466dc4e
Renamed function for consistency
ChrisO345 Oct 31, 2022
bda43b3
Merge branch 'master' into master
ChrisO345 Oct 31, 2022
eed1195
updating DIRECTORY.md
Oct 31, 2022
9dcdd06
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Oct 31, 2022
22467e6
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Dec 25, 2022
9b38be5
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 Dec 27, 2022
e73523e
Remove extra imports in gamma.py doctests
tianyizheng02 Dec 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions maths/gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,27 @@ def gamma(num: float) -> float:
used extension of the factorial function to complex numbers.
The gamma function is defined for all complex numbers except the non-positive
integers


>>> gamma(-1)
Traceback (most recent call last):
...
ValueError: math domain error



>>> gamma(0)
Traceback (most recent call last):
...
ValueError: math domain error


>>> gamma(9)
40320.0

>>> from math import gamma as math_gamma
>>> all(.99999999 < gamma(i) / math_gamma(i) <= 1.000000001
... for i in range(1, 50))
True


>>> from math import gamma as math_gamma
>>> gamma(-1)/math_gamma(-1) <= 1.000000001
Traceback (most recent call last):
...
ValueError: math domain error


>>> from math import gamma as math_gamma
>>> gamma(3.3) - math_gamma(3.3) <= 0.00000001
True
"""

if num <= 0:
raise ValueError("math domain error")

Expand Down