@contextlib.contextmanager
def numpy_seed(seed, *addl_seeds):
    'Context manager which seeds the NumPy PRNG with the specified seed and\n    restores the state afterward'
    if (seed is None):
        (yield)
        return
    if (len(addl_seeds) > 0):
        seed = int((hash((seed, *addl_seeds)) % 1000000.0))
    state = np.random.get_state()
    np.random.seed(seed)
    try:
        (yield)
    finally:
        np.random.set_state(state)
Context manager which seeds the NumPy PRNG with the specified seed and
restores the state afterward
@contextlib.contextmanager
def numpy_seed(seed, *addl_seeds):
    'Context manager which seeds the NumPy PRNG with the specified seed and\n    restores the state afterward'
    if (seed is None):
        (yield)
        return
    if (len(addl_seeds) > 0):
        seed = int((hash((seed, *addl_seeds)) % 1000000.0))
    state = np.random.get_state()
    np.random.seed(seed)
    try:
        (yield)
    finally:
        np.random.set_state(state)