# Path: gelato/_compile.py
# def define(name, template, namespace, frame_offset=1):
#     try:
#         exec_(template, namespace)
#     except SyntaxError as e:
#         raise SyntaxError(str(e) + ':\n' + template)
#     result = namespace[name]
#     frm = inspect.stack()[frame_offset]
#     mod = inspect.getmodule(frm[0])
#     result.__name__ = name
#     if mod is None:
#         result.__module__ = '__main__'
#     else:
#         result.__module__ = mod.__name__
#     return result


import six
import copy
import itertools
import functools
import inspect
import pymc3 as pm
from theano import theano
from theano.tensor.basic import _tensor_py_operators
from lasagne import init
from gelato._compile import define
exclude = {
    '__iter__'
}
mth_template = """\
    def {0}{signature}:
        '''{doc}'''
        return SpecVar{inner_signature}
"""
meths = []
globs = dict(BaseSpec=BaseSpec, copy=copy)
for key, mth in _tensor_py_operators.__dict__.items():
    if callable(mth):
        if six.PY3:
            argspec = inspect.getfullargspec(mth)
            keywords = argspec.varkw
        else:
            argspec = inspect.getargspec(mth)
            keywords = argspec.keywords
        signature = inspect.formatargspec(*argspec)
        inner_signature = inspect.formatargspec(
            args=['mth{0}'.format(key)] + argspec.args,
            varargs=argspec.varargs,
            varkw=keywords,
            defaults=argspec.args[1:],
            formatvalue=lambda value: '=' + str(value)
        )
        meths.append(mth_template.format(
            key, signature=signature, inner_signature=inner_signature, doc=mth.__doc__))
        globs['mth{0}'.format(key)] = mth


# Path: gelato/_compile.py
# def define(name, template, namespace, frame_offset=1):
#     try:
#         exec_(template, namespace)
#     except SyntaxError as e:
#         raise SyntaxError(str(e) + ':\n' + template)
#     result = namespace[name]
#     frm = inspect.stack()[frame_offset]
#     mod = inspect.getmodule(frm[0])
#     result.__name__ = name
#     if mod is None:
#         result.__module__ = '__main__'
#     else:
#         result.__module__ = mod.__name__
#     return result


# Path: gelato/specs/base.py
import six
import copy
import itertools
import functools
import inspect
import pymc3 as pm
from theano import theano
from theano.tensor.basic import _tensor_py_operators
from lasagne import init
from gelato._compile import define

exclude = {
    '__iter__'
}
mth_template = """\
    def {0}{signature}:
        '''{doc}'''
        return SpecVar{inner_signature}
"""
meths = []
globs = dict(BaseSpec=BaseSpec, copy=copy)
for key, mth in _tensor_py_operators.__dict__.items():
    if callable(mth):
        if six.PY3:
            argspec = inspect.getfullargspec(mth)
            keywords = argspec.varkw
        else:
            argspec = inspect.getargspec(mth)
            keywords = argspec.keywords
        signature = inspect.formatargspec(*argspec)
        inner_signature = inspect.formatargspec(
            args=['mth{0}'.format(key)] + argspec.args,
            varargs=argspec.varargs,
            varkw=keywords,
            defaults=argspec.args[1:],
            formatvalue=lambda value: '=' + str(value)
        )
        meths.append(mth_template.format(
            key, signature=signature, inner_signature=inner_signature, doc=mth.__doc__))
        globs['mth{0}'.format(key)] = mth


SpecVar = define('SpecVar', head + '\n'.join(meths), globs, 1)