def get_padded_composition(stoichiometry, elements):
    """ Return a list that contains how many of each species in
    elements exists in the given stoichiometry. e.g. for [['Li', 2], ['O', 1]]
    with elements ['O', 'Li', 'Ba'], this function will return [1, 2, 0].

    Parameters:
        stoichiometry (list): matador-style stoichiometry, as above.
        elements (list): order of element labels to pick out.

    """
    composition = []
    for element in elements:
        if not isinstance(element, str):
            raise RuntimeError('Found invalid element symbol {}'.format(element))
        for species in stoichiometry:
            if not isinstance(species, list):
                raise RuntimeError('Found invalid stoichiometry {}'.format(stoichiometry))
            if species[0] == element:
                composition.append(species[1])
                break
            elif species[0] not in elements:
                raise RuntimeError('Extra element {} in stoichiometry'.format(species[0]))
        else:
            composition.append(0)

    return composition