pymc.generator(gen, default=None)[source]#

Generator variable with possibility to set default value and new generator. If generator is exhausted variable will produce default value if it is not None, else raises StopIteration exception that can be caught on runtime.

gen: generator that implements __next__ (py3) or next (py2) method

and yields np.arrays with same types

default: np.array with the same type as generator produces

It has 2 new methods - var.set_gen(gen): sets new generator - var.set_default(value): sets new default value (None erases default value)