containertools.remove_empty_containers_in_expr

abjad.tools.containertools.remove_empty_containers_in_expr.remove_empty_containers_in_expr(expr)[source]

Remove empty containers in expr:

abjad> staff = Staff(Container(notetools.make_repeated_notes(2)) * 4)
abjad> pitchtools.set_ascending_named_diatonic_pitches_on_nontied_pitched_components_in_expr(staff.leaves)
abjad> spannertools.BeamSpanner(staff[:])
BeamSpanner({c'8, d'8}, {e'8, f'8}, {g'8, a'8}, {b'8, c''8})
abjad> containertools.delete_contents_of_container(staff[1])
[Note("e'8"), Note("f'8")]
abjad> containertools.delete_contents_of_container(staff[-1])
[Note("b'8"), Note("c''8")]
abjad> f(staff)
\new Staff {
    {
        c'8 [
        d'8
    }
    {
    }
    {
        g'8
        a'8 ]
    }
    {
    }
}
abjad> containertools.remove_empty_containers_in_expr(staff)
abjad> f(staff)
\new Staff {
    {
        c'8 [
        d'8
    }
    {
        g'8
        a'8 ]
    }
}

Return none.

Changed in version 2.0: renamed containertools.remove_empty() to containertools.remove_empty_containers_in_expr().

This Page