Пример #1
0
def promote_datashapes(a, b):
    """Promote two DataShapes"""
    from .unification import unify
    from .normalization import normalize_simple

    # Normalize to determine parameters (eliminate broadcasting, etc)
    a, b = normalize_simple(a, b)
    n = len(a.parameters[:-1])

    # Allocate dummy result type for unification
    dst = DataShape(*[TypeVar(gensym()) for i in range(n + 1)])

    # Unify
    [result1, result2], _ = unify([(a, dst), (b, dst)], [True, True])

    assert result1 == result2
    return result1
Пример #2
0
def dummy_signature(f):
    """Create a dummy signature for `f`"""
    from . import coretypes as T
    argspec = inspect.getargspec(f)
    n = len(argspec.args)
    return T.Function(*[T.TypeVar(gensym()) for i in range(n + 1)])