Skip to content

Commit a087bf9

Browse files
committed
-
1 parent fed9e5f commit a087bf9

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

source_py3/python_toolbox/math_tools/factorials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
def factorial(x, start=1):
1414
'''
15-
Calculate a factorial
15+
Calculate a factorial.
1616
1717
This differs from the built-in `math.factorial` in that it allows a `start`
1818
argument. If one is given, the function returns `(x!)/(start!)`.

source_py3/test_python_toolbox/test_combi/test_misc.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@
44
from python_toolbox import cute_testing
55
from python_toolbox import math_tools
66

7-
from python_toolbox.combi import *
7+
from python_toolbox import combi
88

99

1010
def test():
11-
assert misc.get_short_factorial_string(7) == str(math_tools.factorial(7))
12-
assert misc.get_short_factorial_string(7, minus_one=True) == \
11+
assert combi.misc.get_short_factorial_string(7) == \
12+
str(math_tools.factorial(7))
13+
assert combi.misc.get_short_factorial_string(7, minus_one=True) == \
1314
str(math_tools.factorial(7) - 1)
1415

15-
assert misc.get_short_factorial_string(17) == '17!'
16-
assert misc.get_short_factorial_string(17, minus_one=True) == '17! - 1'
16+
assert combi.misc.get_short_factorial_string(17) == '17!'
17+
assert combi.misc.get_short_factorial_string(17, minus_one=True) == \
18+
'17! - 1'
1719

18-
assert misc.get_short_factorial_string(float('inf')) == '''float('inf')'''
19-
assert misc.get_short_factorial_string(float('inf'),
20+
assert combi.misc.get_short_factorial_string(float('inf')) == \
21+
'''float('inf')'''
22+
assert combi.misc.get_short_factorial_string(float('inf'),
2023
minus_one=True) == '''float('inf')'''
24+
25+
def test_binomial_in_root_namespace():
26+
assert hasattr(combi, 'binomial')
27+
assert combi.binomial(7, 3) == 35
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2009-2015 Ram Rachum.
2+
# This program is distributed under the MIT license.
3+
4+
import sys
5+
6+
import nose
7+
8+
from python_toolbox.math_tools import binomial
9+
10+
11+
def test():
12+
assert binomial(7, 3) == 35
13+
assert binomial(0, 0) == 1
14+
assert binomial(1, 0) == 1
15+
assert binomial(0, 1) == 0
16+
assert binomial(1543, 634) == 127103521979248139661884595050302692072114625333816461647571438364482801578062268185939019831927710543644891679108093639691467979466411177318250931548804667267192030646116875003881007119966764992383016174407823444352165249728639847571592229832113238415348489512831060701471487834812550521403788703534654431344329462541634971732197170414906629071055802381322184009159362499960475076746698583466181504060523973736761406471112019069930703149760846502951040

0 commit comments

Comments
 (0)