(f, u, K)
return dmp_strip(h, u)
Create a ``K[X]`` polynomial from a ``dict``.

    Examples
    ========

    >>> from sympy.polys.domains import ZZ
    >>> from sympy.polys.densebasic import dmp_from_dict

    >>> dmp_from_dict({(0, 0): ZZ(3), (0, 1): ZZ(2), (2, 1): ZZ(1)}, 1, ZZ)
    [[1, 0], [], [2, 3]]
    >>> dmp_from_dict({}, 0, ZZ)
    []
Create a ``K[X]`` polynomial from a ``dict``.
Create a K [ X ] polynomial from a dict .
def dmp_from_dict(f, u, K):
    """
    Create a ``K[X]`` polynomial from a ``dict``.

    Examples
    ========

    >>> from sympy.polys.domains import ZZ
    >>> from sympy.polys.densebasic import dmp_from_dict

    >>> dmp_from_dict({(0, 0): ZZ(3), (0, 1): ZZ(2), (2, 1): ZZ(1)}, 1, ZZ)
    [[1, 0], [], [2, 3]]
    >>> dmp_from_dict({}, 0, ZZ)
    []

    """
    if not u:
        return dup_from_dict(f, K)
    if not f:
        return dmp_zero(u)

    coeffs = {}

    for monom, coeff in f.items():
        head, tail = monom[0], monom[1:]

        if head in coeffs:
            coeffs[head][tail] = coeff
        else:
            coeffs[head] = { tail: coeff }

    n, v, h = max(coeffs.keys()), u - 1, []

    for k in xrange(n, -1, -1):
        coeff = coeffs.get(k)

        if coeff is not None:
            h.append(dmp_from_dict(coeff, v, K))
        else:
            h.append(dmp_zero(v))

    return dmp_strip(h, u)
def dmp_from_dict ( f , u , K ) : if not u : return dup_from_dict ( f , K ) if not f : return dmp_zero ( u ) coeffs = { } for monom , coeff in f . items ( ) : head , tail = monom [ 0 ] , monom [ 1 : ] if head in coeffs : coeffs [ head ] [ tail ] = coeff else : coeffs [ head ] = { tail : coeff } n , v , h = max ( coeffs . keys ( ) ) , u - 1 , [ ] for k in xrange ( n , - 1 , - 1 ) : coeff = coeffs . get ( k ) if coeff is not None : h . append ( dmp_from_dict ( coeff , v , K ) ) else : h . append ( dmp_zero ( v ) ) return dmp_strip ( h , u )