# Path: stationary/utils/math_helpers.py
# def simplex_generator(N, d=2):
#     """
#     Generates a discretation of the simplex.
# 
#     Parameters
#     ----------
#     N: int
#         The number of subdivsions in each dimension
#     d: int, 2
#         The dimension of the simplex (the number of population types is d+1
# 
#     Yields
#     ------
#     (d+1)-tuples of numbers summing to N. The total number of yielded tuples is
#     equal to the simplicial polytopic number corresponding to N and d,
#     binom{N + d - 1}{d} (see https://en.wikipedia.org/wiki/Figurate_number )
#     """
# 
#     if d == 1:
#         for i in range(N+1):
#             yield (i, N - i)
#     if d > 1:
#         for j in range(N+1):
#             for s in simplex_generator(N - j, d - 1):
#                 t = [j]
#                 t.extend(s)
#                 yield tuple(t)


from scipy.misc import comb
from nose.tools import assert_almost_equal, assert_equal, assert_raises, assert_true, assert_less_equal, assert_greater_equal, assert_greater
from stationary.utils.math_helpers import simplex_generator
    d = 1
    N = 1
    states = set(simplex_generator(N, d))
    expected = set([(0, 1), (1, 0)])
    assert_equal(states, expected)

    N = 2
    states = set(simplex_generator(N, d))
    expected = set([(0, 2), (1, 1), (2, 0)])
    assert_equal(states, expected)

    N = 3
    states = set(simplex_generator(N, d))
    expected = set([(0, 3), (1, 2), (2, 1), (3, 0)])
    assert_equal(states, expected)

    d = 2
    N = 1
    states = set(simplex_generator(N, d))
    expected = set([(1, 0, 0), (0, 1, 0), (0, 0, 1)])
    assert_equal(states, expected)

    N = 2
    states = set(simplex_generator(N, d))
    expected = set([(1, 1, 0), (0, 1, 1), (1, 0, 1), (0, 2, 0), (0, 0, 2), 
                    (2, 0, 0)])
    assert_equal(states, expected)

    for d in range(1, 5):
        for N in range(1, 20):

# Path: stationary/utils/math_helpers.py
# def simplex_generator(N, d=2):
#     """
#     Generates a discretation of the simplex.
# 
#     Parameters
#     ----------
#     N: int
#         The number of subdivsions in each dimension
#     d: int, 2
#         The dimension of the simplex (the number of population types is d+1
# 
#     Yields
#     ------
#     (d+1)-tuples of numbers summing to N. The total number of yielded tuples is
#     equal to the simplicial polytopic number corresponding to N and d,
#     binom{N + d - 1}{d} (see https://en.wikipedia.org/wiki/Figurate_number )
#     """
# 
#     if d == 1:
#         for i in range(N+1):
#             yield (i, N - i)
#     if d > 1:
#         for j in range(N+1):
#             for s in simplex_generator(N - j, d - 1):
#                 t = [j]
#                 t.extend(s)
#                 yield tuple(t)


# Path: tests/test_math_helpers.py
from scipy.misc import comb
from nose.tools import assert_almost_equal, assert_equal, assert_raises, assert_true, assert_less_equal, assert_greater_equal, assert_greater
from stationary.utils.math_helpers import simplex_generator

    d = 1
    N = 1
    states = set(simplex_generator(N, d))
    expected = set([(0, 1), (1, 0)])
    assert_equal(states, expected)

    N = 2
    states = set(simplex_generator(N, d))
    expected = set([(0, 2), (1, 1), (2, 0)])
    assert_equal(states, expected)

    N = 3
    states = set(simplex_generator(N, d))
    expected = set([(0, 3), (1, 2), (2, 1), (3, 0)])
    assert_equal(states, expected)

    d = 2
    N = 1
    states = set(simplex_generator(N, d))
    expected = set([(1, 0, 0), (0, 1, 0), (0, 0, 1)])
    assert_equal(states, expected)

    N = 2
    states = set(simplex_generator(N, d))
    expected = set([(1, 1, 0), (0, 1, 1), (1, 0, 1), (0, 2, 0), (0, 0, 2), 
                    (2, 0, 0)])
    assert_equal(states, expected)

    for d in range(1, 5):
        for N in range(1, 20):

            states = set(simplex_generator(N, d))