def contraction_string(element):
    """
    Forms a string specifying the contractions for an element

    ie, (16s,10p) -> [4s,3p]
    """

    # Does not have electron shells (ECP only?)
    if 'electron_shells' not in element:
        return ""

    cont_map = dict()
    for sh in element['electron_shells']:
        nprim = len(sh['exponents'])
        ngeneral = len(sh['coefficients'])

        # is a combined general contraction (sp, spd, etc)
        is_spdf = len(sh['angular_momentum']) > 1

        for am in sh['angular_momentum']:
            # If this a general contraction (and not combined am), then use that
            ncont = ngeneral if not is_spdf else 1

            if am not in cont_map:
                cont_map[am] = (nprim, ncont)
            else:
                cont_map[am] = (cont_map[am][0] + nprim, cont_map[am][1] + ncont)

    primstr = ""
    contstr = ""
    for am in sorted(cont_map.keys()):
        nprim, ncont = cont_map[am]

        if am != 0:
            primstr += ','
            contstr += ','
        primstr += str(nprim) + lut.amint_to_char([am])
        contstr += str(ncont) + lut.amint_to_char([am])

    return "({}) -> [{}]".format(primstr, contstr)
def contraction_string ( element ) : if 'electron_shells' not in element : return "" cont_map = dict ( ) for sh in element [ 'electron_shells' ] : nprim = len ( sh [ 'exponents' ] ) ngeneral = len ( sh [ 'coefficients' ] ) is_spdf = len ( sh [ 'angular_momentum' ] ) > 1 for am in sh [ 'angular_momentum' ] : ncont = ngeneral if not is_spdf else 1 if am not in cont_map : cont_map [ am ] = ( nprim , ncont ) else : cont_map [ am ] = ( cont_map [ am ] [ 0 ] + nprim , cont_map [ am ] [ 1 ] + ncont ) primstr = "" contstr = "" for am in sorted ( cont_map . keys ( ) ) : nprim , ncont = cont_map [ am ] if am != 0 : primstr += ',' contstr += ',' primstr += str ( nprim ) + lut . amint_to_char ( [ am ] ) contstr += str ( ncont ) + lut . amint_to_char ( [ am ] ) return "({}) -> [{}]" . format ( primstr , contstr )
Forms a string specifying the contractions for an element

    ie, (16s,10p) -> [4s,3p]