Exemple #1
0
def test__from_data():
    """ test zmat.from_data
    """
    zma1 = zmat.from_data(
        symbs=zmat.symbols(CH4O2_ZMA),
        key_mat=zmat.key_matrix(CH4O2_ZMA),
        val_mat=zmat.value_matrix(CH4O2_ZMA),
        name_mat=zmat.name_matrix(CH4O2_ZMA),
    )
    assert zma1 == CH4O2_ZMA

    zma2 = zmat.from_data(
        symbs=zmat.symbols(CH4O2_ZMA_NO_NONES),
        key_mat=zmat.key_matrix(CH4O2_ZMA_NO_NONES),
        val_mat=zmat.value_matrix(CH4O2_ZMA_NO_NONES),
        name_mat=zmat.name_matrix(CH4O2_ZMA_NO_NONES),
    )
    assert zma2 == CH4O2_ZMA

    zma1 = list(map(list, zma1))
    zma2 = list(map(list, zma2))

    assert zmat.is_valid(zma1)
    assert zmat.is_valid(zma2)

    zma1[0] += [None]
    zma2[0][1] = zma2[0][1] + (None, )

    assert not zmat.is_valid(zma1)
    assert not zmat.is_valid(zma2)
Exemple #2
0
def _is_methyl_rotor(tors):
    """ Identify if the rotor
    """

    symbs = symbols(tors.zma)
    axis = list(tors.axis)
    grps = tors.groups
    rgrp1 = [axis[0]] + list(grps[0])
    rgrp2 = [axis[1]] + list(grps[1])
    rgrp1_symbs = sorted(list(symbs[idx] for idx in rgrp1))
    rgrp2_symbs = sorted(list(symbs[idx] for idx in rgrp2))

    return bool(
        any(grp == ['C', 'H', 'H', 'H'] for grp in (rgrp1_symbs, rgrp2_symbs)))