This module defines objects for tracking the derivation of one Stream from another.
A Derivation object keeps track of which Streams
>>> import copy
>>> s1 = stream.Stream()
>>> s2 = stream.Stream()
>>> d1 = derivation.Derivation(s1)
>>> d1.setAncestor(s2)
>>> d1.getAncestor() is s2
True
>>> d1.getContainer() is s1
True
>>> d2 = copy.deepcopy(d1)
>>> d2.getAncestor() is s2
True
>>> d1.setMethod('measure')
>>> d1.getMethod()
'measure'
Derivation bases
Derivation methods
Returns the string of the method that was used to generate this Stream. Note that it’s identical to the property derivationMethod on a Stream, so no need for any but the most advanced usages.
>>> s = stream.Stream()
>>> s.derivationMethod is s._derivation.getMethod()
True
>>> s.derivationMethod is None
True
>>> sNotes = s.notes
>>> sNotes.derivationMethod
'notes'
>>> sNotes._derivation.getMethod()
'notes'
Sets a string identifying how the object was derived.
Some examples are ‘getElementsByClass’ etc.
>>> s = stream.Stream()
>>> s.append(clef.TrebleClef())
>>> s.append(note.Note())
>>> sNotes = s.notes
>>> sNotes._derivation
<music21.derivation.Derivation object at 0x...>
>>> derived = sNotes._derivation
>>> derived.getMethod()
'notes'
>>> derived.setMethod('blah')
>>> derived.getMethod()
'blah'
>>> sNotes.derivationMethod
'blah'
Unwrap any and all weakrefs stored.
>>> s1 = stream.Stream()
>>> s2 = stream.Stream()
>>> d1 = derivation.Derivation(s1) # sets container
>>> d1.setAncestor(s2)
>>> common.isWeakref(d1._container)
True
>>> d1.unwrapWeakref()
>>> common.isWeakref(d1._container)
False
Wrap all stored objects with weakrefs.