WellformednessManager

class systemtools.WellformednessManager

Wellformedness manager.

Example.

>>> systemtools.WellformednessManager()
WellformednessManager()

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_systemtools { graph [label=systemtools]; "abjad.tools.systemtools.WellformednessManager.WellformednessManager" [color=black, fontcolor=white, group=2, label=<<B>WellformednessManager</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.systemtools.WellformednessManager.WellformednessManager"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

check_beamed_quarter_notes([expr]) Checks to make sure there are no beamed quarter notes.
check_conflicting_clefs([expr]) Checks for conflicting clefs.
check_discontiguous_spanners([expr]) Checks for discontiguous spanners.
check_duplicate_ids([expr]) Checks to make sure there are no components with duplicated IDs.
check_empty_containers([expr]) Checks to make sure there are no empty containers in score.
check_intermarked_hairpins([expr]) Checks to make sure there are no hairpins in score with intervening dynamic marks.
check_misdurated_measures([expr]) Checks to make sure there are no misdurated measures in score.
check_misfilled_measures([expr]) Checks that time signature duration equals measure contents duration for every measure.
check_mismatched_enchained_hairpins([expr]) Checks mismatched enchained hairpins.
check_mispitched_ties([expr]) Checks for mispitched notes.
check_misrepresented_flags([expr]) Checks to make sure there are no misrepresented flags in score.
check_missing_parents([expr]) Checks to make sure there are no components in score with missing parent.
check_nested_measures([expr]) Checks to make sure there are no nested measures in score.
check_overlapping_beams([expr]) Checks to make sure there are no overlapping beams in score.
check_overlapping_glissandi([expr]) Checks to make sure there are no overlapping glissandi in score.
check_overlapping_hairpins([expr]) Checks to make sure there are no overlapping hairpins in score.
check_overlapping_octavation_spanners([expr]) Checks to make sure there are no overlapping octavation spanners in score.
check_overlapping_ties([expr]) Checks to make sure there are no overlapping ties in score.
check_short_hairpins([expr]) Checks to make sure that hairpins span at least two leaves.
check_tied_rests([expr]) Checks to make sure there are no tied rests.
__call__([expr]) Calls all wellformedness checks on expr.
__eq__(expr) Is true when ID of expr equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad object.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of Abjad object.

Class & static methods

static WellformednessManager.check_beamed_quarter_notes(expr=None)

Checks to make sure there are no beamed quarter notes.

Returns violators and total.

static WellformednessManager.check_conflicting_clefs(expr=None)

Checks for conflicting clefs.

Conflicting clefs defined equal to the situation in which a first clef is attached to a container and a second clef is attached to a child of the container that starts at the same time as the container.

Situation does not usually arise because an exception raises on attempt to attach a clef to any component that starts at the same time as some other component in the score tree.

But advanced users can stumble into this situation as described in the following examples.

Example 1. Conflicting clefs result from attaching clefs to separate containers and then appending one container to the other:

>>> staff = Staff()
>>> attach(Clef('bass'), staff)
>>> voice = Voice()
>>> attach(Clef('treble'), voice)
>>> staff.append(voice)
>>> f(staff)
\new Staff {
    \clef "bass"
    \new Voice {
        \clef "treble"
    }
}
>>> inspect_(staff).is_well_formed()
False

This is bad.

Example 2. Conflicting clefs result from attaching clefs to free-standing leaves, then to a container and then extending the cleffed-container with the cleffed-leaves:

>>> staff = Staff()
>>> attach(Clef('bass'), staff)
>>> leaves = scoretools.make_leaves([0, 2, 4, 5], [(1, 4)])
>>> attach(Clef('treble'), leaves[0])
>>> staff.extend(leaves)
>>> f(staff)
\new Staff {
    \clef "bass"
    \clef "treble"
    c'4
    d'4
    e'4
    f'4
}
>>> inspect_(staff).is_well_formed()
False

This is also bad.

Todo

Raise an exception on append or extend to prohibit these cases.

Returns violators and total.

static WellformednessManager.check_discontiguous_spanners(expr=None)

Checks for discontiguous spanners.

There are now two different types of spanner. Most spanners demand that spanner components be logical-voice-contiguous. But a few special spanners (like Tempo) do not make such a demand. The check here consults the experimental _contiguity_constraint.

Returns violators and total.

static WellformednessManager.check_duplicate_ids(expr=None)

Checks to make sure there are no components with duplicated IDs.

Returns violators and total.

static WellformednessManager.check_empty_containers(expr=None)

Checks to make sure there are no empty containers in score.

Returns violators and total.

static WellformednessManager.check_intermarked_hairpins(expr=None)

Checks to make sure there are no hairpins in score with intervening dynamic marks.

Returns violators and total.

static WellformednessManager.check_misdurated_measures(expr=None)

Checks to make sure there are no misdurated measures in score.

Returns violators and total.

static WellformednessManager.check_misfilled_measures(expr=None)

Checks that time signature duration equals measure contents duration for every measure.

Returns violators and total.

static WellformednessManager.check_mismatched_enchained_hairpins(expr=None)

Checks mismatched enchained hairpins.

Example 1. Checks mismatched enchained hairpins:

>>> staff = Staff("c'4 d' e' f'")
>>> attach(Hairpin('p < f'), staff[:2])
>>> attach(Hairpin('p > pp'), staff[1:])
>>> print(inspect_(staff).tabulate_well_formedness_violations())
0 /     4 beamed quarter notes
0 /     1 conflicting clefs
0 /     2 discontiguous spanners
0 /     5 duplicate ids
0 /     1 empty containers
0 /     2 intermarked hairpins
0 /     0 misdurated measures
0 /     0 misfilled measures
2 /     2 mismatched enchained hairpins
0 /     0 mispitched ties
0 /     4 misrepresented flags
0 /     5 missing parents
0 /     0 nested measures
0 /     0 overlapping beams
0 /     0 overlapping glissandi
0 /     2 overlapping hairpins
0 /     0 overlapping octavation spanners
0 /     0 overlapping ties
0 /     2 short hairpins
0 /     0 tied rests

Enchained hairpins are fine so long as hairpin ends match.

Returns violators and total.

static WellformednessManager.check_mispitched_ties(expr=None)

Checks for mispitched notes.

Example 1. Checks for mispitched ties attached to notes:

>>> staff = Staff("c'4 ~ c'")
>>> staff[1].written_pitch = NamedPitch("d'")
>>> inspector = inspect_(staff)
>>> print(inspector.tabulate_well_formedness_violations())
0 /     2 beamed quarter notes
0 /     1 conflicting clefs
0 /     1 discontiguous spanners
0 /     3 duplicate ids
0 /     1 empty containers
0 /     0 intermarked hairpins
0 /     0 misdurated measures
0 /     0 misfilled measures
0 /     0 mismatched enchained hairpins
1 /     1 mispitched ties
0 /     2 misrepresented flags
0 /     3 missing parents
0 /     0 nested measures
0 /     0 overlapping beams
0 /     0 overlapping glissandi
0 /     0 overlapping hairpins
0 /     0 overlapping octavation spanners
0 /     1 overlapping ties
0 /     0 short hairpins
0 /     0 tied rests

Example 2. Checks for mispitched ties attached to chords:

>>> staff = Staff("<c' d' bf'>4 ~ <c' d' bf'>")
>>> staff[1].written_pitches = [6, 9, 10]
>>> inspector = inspect_(staff)
>>> print(inspector.tabulate_well_formedness_violations())
0 /     2 beamed quarter notes
0 /     1 conflicting clefs
0 /     1 discontiguous spanners
0 /     3 duplicate ids
0 /     1 empty containers
0 /     0 intermarked hairpins
0 /     0 misdurated measures
0 /     0 misfilled measures
0 /     0 mismatched enchained hairpins
1 /     1 mispitched ties
0 /     2 misrepresented flags
0 /     3 missing parents
0 /     0 nested measures
0 /     0 overlapping beams
0 /     0 overlapping glissandi
0 /     0 overlapping hairpins
0 /     0 overlapping octavation spanners
0 /     1 overlapping ties
0 /     0 short hairpins
0 /     0 tied rests

Does not check tied rests, chords or skips.

Returns violator ties together with total number of ties.

static WellformednessManager.check_misrepresented_flags(expr=None)

Checks to make sure there are no misrepresented flags in score.

Returns violators and total.

static WellformednessManager.check_missing_parents(expr=None)

Checks to make sure there are no components in score with missing parent.

Returns violators and total.

static WellformednessManager.check_nested_measures(expr=None)

Checks to make sure there are no nested measures in score.

Returns violators and total.

static WellformednessManager.check_overlapping_beams(expr=None)

Checks to make sure there are no overlapping beams in score.

Returns violators and total.

static WellformednessManager.check_overlapping_glissandi(expr=None)

Checks to make sure there are no overlapping glissandi in score.

Returns violators and total.

static WellformednessManager.check_overlapping_hairpins(expr=None)

Checks to make sure there are no overlapping hairpins in score.

Example 1. Checks overlapping hairpins:

>>> staff = Staff("c'4 d' e' f'")
>>> attach(Crescendo(), staff[:])
>>> attach(Decrescendo(), staff[:])
>>> print(inspect_(staff).tabulate_well_formedness_violations())
0 /     4 beamed quarter notes
0 /     1 conflicting clefs
0 /     2 discontiguous spanners
0 /     5 duplicate ids
0 /     1 empty containers
0 /     2 intermarked hairpins
0 /     0 misdurated measures
0 /     0 misfilled measures
0 /     2 mismatched enchained hairpins
0 /     0 mispitched ties
0 /     4 misrepresented flags
0 /     5 missing parents
0 /     0 nested measures
0 /     0 overlapping beams
0 /     0 overlapping glissandi
2 /     2 overlapping hairpins
0 /     0 overlapping octavation spanners
0 /     0 overlapping ties
0 /     2 short hairpins
0 /     0 tied rests

Enchained hairpins are fine so long as hairpin ends match.

Returns violators and total.

static WellformednessManager.check_overlapping_octavation_spanners(expr=None)

Checks to make sure there are no overlapping octavation spanners in score.

Returns violators and total.

static WellformednessManager.check_overlapping_ties(expr=None)

Checks to make sure there are no overlapping ties in score.

Example 1. Checks overlapping ties:

>>> staff = Staff("c'4 c' c' c''")
>>> attach(Tie(), staff[:2])
>>> attach(Tie(), staff[1:3])
>>> print(inspect_(staff).tabulate_well_formedness_violations())
0 /     4 beamed quarter notes
0 /     1 conflicting clefs
0 /     2 discontiguous spanners
0 /     5 duplicate ids
0 /     1 empty containers
0 /     0 intermarked hairpins
0 /     0 misdurated measures
0 /     0 misfilled measures
0 /     0 mismatched enchained hairpins
0 /     2 mispitched ties
0 /     4 misrepresented flags
0 /     5 missing parents
0 /     0 nested measures
0 /     0 overlapping beams
0 /     0 overlapping glissandi
0 /     0 overlapping hairpins
0 /     0 overlapping octavation spanners
2 /     2 overlapping ties
0 /     0 short hairpins
0 /     0 tied rests

Returns violators and count of total ties.

static WellformednessManager.check_short_hairpins(expr=None)

Checks to make sure that hairpins span at least two leaves.

Returns violators and total.

static WellformednessManager.check_tied_rests(expr=None)

Checks to make sure there are no tied rests.

Returns violators and total.

Special methods

WellformednessManager.__call__(expr=None)

Calls all wellformedness checks on expr.

Returns triples.

(AbjadObject).__eq__(expr)

Is true when ID of expr equals ID of Abjad object. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(AbjadObject).__ne__(expr)

Is true when Abjad object does not equal expr. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.