§
    ƒØj ã                  óV  — d dl mZ d dlmZ d dlmZ d dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZ d dlmZ d dl
mZ d d	l
mZ d d
l
mZ d dl
mZ d dl
mZ d dl
mZ d dl
mZ d dlmZ  ej        d¦  «        Z G d„ dej        ¦  «        Z G d„ d¦  «        Z G d„ d¦  «        Z G d„ d¦  «        Z G d„ d¦  «        Z  G d„ dej        ¦  «        Z! G d„ d¦  «        Z"d„ Z#d „ Z$d*d"„Z%d*d#„Z&d*d$„Z'd+d%„Z( G d&„ d'e	j)        ¦  «        Z*d(„ Z+e"eegZ,e-d)k    rd dl
Z
 e
j.        e*¦  «         dS dS ),é    )Úannotations©ÚCounter)ÚKeysViewN)Úcommon)ÚsafeToParallize)Ú
StreamType)Ú	converter)Úcorpus)Úenvironment)Úexceptions21)Únote)Ústream)Útext)ÚMetadataEntryzfeatures.basec                  ó   — e Zd ZdS )ÚFeatureExceptionN©Ú__name__Ú
__module__Ú__qualname__© ó    úŠ/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/features/base.pyr   r   %   ó   € € € € € Ø€Dr   r   c                  ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )ÚFeaturea7  
    An object representation of a feature, capable of presentation in a variety of formats,
    and returned from FeatureExtractor objects.

    Feature objects are simple. It is FeatureExtractors that store all metadata and processing
    routines for creating Feature objects.  Normally you wouldn't create one of these yourself.

    >>> myFeature = features.Feature()
    >>> myFeature.dimensions = 3
    >>> myFeature.name = 'Random arguments'
    >>> myFeature.isSequential = True

    This is a continuous Feature, so we will set discrete to false.

    >>> myFeature.discrete = False

    The .vector is the most important part of the feature, and it starts out as None.

    >>> myFeature.vector is None
    True

    Calling .prepareVector() gives it a list of Zeros of the length of dimensions.

    >>> myFeature.prepareVectors()

    >>> myFeature.vector
    [0, 0, 0]

    Now we can set the vector parts:

    >>> myFeature.vector[0] = 4
    >>> myFeature.vector[1] = 2
    >>> myFeature.vector[2] = 1

    It's okay just to assign a new list to .vector itself.

    There is a "normalize()" method which normalizes the values
    of a histogram to sum to 1.

    >>> myFeature.normalize()
    >>> myFeature.vector
    [0.571..., 0.285..., 0.142...]

    And that's it! FeatureExtractors are much more interesting.
    c                óZ   — d| _         d | _        d | _        d | _        d | _        d | _        d S )Né   )Ú
dimensionsÚvectorÚnameÚdescriptionÚisSequentialÚdiscrete©Úselfs    r   Ú__init__zFeature.__init__X   s4   € à ˆŒàˆŒð ˆŒ	ØˆÔØ ˆÔØˆŒˆˆr   c                ó   — dg| j         z  S )zA
        Prepare a vector of appropriate size and return
        r   )r    r&   s    r   Ú_getVectorszFeature._getVectorsd   s   € ð ˆs�T”_Ñ$Ð$r   c                ó8   — |                       ¦   «         | _        dS )z<
        Prepare the vector stored in this feature.
        N)r*   r!   r&   s    r   ÚprepareVectorszFeature.prepareVectorsj   s   € ð ×&Ò&Ñ(Ô(ˆŒˆˆr   c                óð   — t          | j        ¦  «        }	 d|z  }n# t          $ r t          d¦  «        ‚w xY w|                      ¦   «         }t          | j        ¦  «        D ]\  }}||z  ||<   Œ|| _        dS )zM
        Normalizes the vector so that the sum of its elements is 1.
        ç      ð?zcannot normalize zero vectorN)Úsumr!   ÚZeroDivisionErrorr   r*   Ú	enumerate)r'   ÚsÚscalarÚtempÚiÚvs         r   Ú	normalizezFeature.normalizep   sš   € õ �”ÑÔˆð	CØ˜1‘WˆFˆFøÝ ð 	Cð 	Cð 	CÝ"Ð#AÑBÔBÐBð	Cøøøà×ÒÑ!Ô!ˆÝ˜dœkÑ*Ô*ð 	!ð 	!‰DˆAˆqØ˜&‘jˆD�‰GˆGØˆŒˆˆs   – œ6N)r   r   r   Ú__doc__r(   r*   r,   r7   r   r   r   r   r   )   s[   € € € € € ð,ð ,ð\
ð 
ð 
ð%ð %ð %ð)ð )ð )ðð ð ð ð r   r   c                  óL   — e Zd ZdZ	 ddd„Zd„ Zd„ Zdd„Zd	„ Zd
„ Z	dd„Z
d„ ZdS )ÚFeatureExtractora   
    A model of process that extracts a feature from a Music21 Stream.
    The main public interface is the extract() method.

    The extractor can be passed a Stream or a reference to a DataInstance.
    All Streams are internally converted to a DataInstance if necessary.
    Usage of a DataInstance offers significant performance advantages, as common forms of
    the Stream are cached for easy processing.
    NÚreturnÚNonec                ór  — d | _         d | _        |                      |¦  «         d | _        t	          | d¦  «        sd | _        t	          | d¦  «        sd | _        t	          | d¦  «        sd | _        t	          | d¦  «        sd | _        t	          | d¦  «        sd| _	        t	          | d¦  «        s	d| _
        d S d S )	Nr"   r#   r$   r    r%   Tr7   F)r   ÚdataÚsetDataÚfeatureÚhasattrr"   r#   r$   r    r%   r7   )r'   ÚdataOrStreamÚkeywordss      r   r(   zFeatureExtractor.__init__Š   sÑ   € ð ˆŒØ'+ˆŒ	Ø�Š�\Ñ"Ô"Ð"àˆŒå�t˜VÑ$Ô$ð 	ØˆDŒIÝ�t˜]Ñ+Ô+ð 	$Ø#ˆDÔÝ�t˜^Ñ,Ô,ð 	%Ø $ˆDÔÝ�t˜\Ñ*Ô*ð 	#Ø"ˆDŒOÝ�t˜ZÑ(Ô(ð 	!Ø ˆDŒMÝ�t˜[Ñ)Ô)ð 	#Ø"ˆDŒNˆNˆNð	#ð 	#r   c                óÂ   — |�\t          |d¦  «        r<t          |t          j        ¦  «        r"|| _        t	          | j        ¦  «        | _        dS d| _        || _        dS dS )z‰
        Set the data that this FeatureExtractor will process.
        Either a Stream or a DataInstance object can be provided.
        NÚclasses)rA   Ú
isinstancer   ÚStreamÚDataInstancer>   )r'   rB   s     r   r?   zFeatureExtractor.setData¡   sj   € ð
 Ð#Ý˜ iÑ0Ô0ð )Ý" <µ´Ñ?Ô?ð)ð +�”Ý(¨¬Ñ5Ô5�”	�	�	ð #�”Ø(�”	�	�	ð $Ð#r   c                ó  — g }| j         dk    r/|                     | j                             dd¦  «        ¦  «         nJt	          | j         ¦  «        D ]5}|                     | j                             dd¦  «        › d|› �¦  «         Œ6|S )aÁ  
        Return a list of string in a form that is appropriate for data storage.

        >>> fe = features.jSymbolic.AmountOfArpeggiationFeature()
        >>> fe.getAttributeLabels()
        ['Amount_of_Arpeggiation']

        >>> fe = features.jSymbolic.FifthsPitchHistogramFeature()
        >>> fe.getAttributeLabels()
        ['Fifths_Pitch_Histogram_0', 'Fifths_Pitch_Histogram_1', 'Fifths_Pitch_Histogram_2',
         'Fifths_Pitch_Histogram_3', 'Fifths_Pitch_Histogram_4', 'Fifths_Pitch_Histogram_5',
         'Fifths_Pitch_Histogram_6', 'Fifths_Pitch_Histogram_7', 'Fifths_Pitch_Histogram_8',
         'Fifths_Pitch_Histogram_9', 'Fifths_Pitch_Histogram_10', 'Fifths_Pitch_Histogram_11']

        r   ú Ú_)r    Úappendr"   ÚreplaceÚrange)r'   Úpostr5   s      r   ÚgetAttributeLabelsz#FeatureExtractor.getAttributeLabels´   s’   € ð  ˆØŒ?˜aÒÐØ�KŠK˜œ	×)Ò)¨#¨sÑ3Ô3Ñ4Ô4Ð4Ð4å˜4œ?Ñ+Ô+ð Bð B�Ø—’˜tœy×0Ò0°°cÑ:Ô:Ð@Ð@¸QÐ@Ð@ÑAÔAÐAÐAØˆr   c                ó�   — |€| j         }| j        |_        | j        |_        | j        |_        | j        |_        | j        |_        |S )z`
        Fill the attributes of a Feature with the descriptors in the FeatureExtractor.
        )r@   r"   r#   r$   r    r%   )r'   r@   s     r   ÚfillFeatureAttributesz&FeatureExtractor.fillFeatureAttributesÌ   sH   € ð ˆ?Ø”lˆGØ”yˆŒØ"Ô.ˆÔØ#Ô0ˆÔØ!œ_ˆÔØœ=ˆÔØˆr   c                ó†   — t          ¦   «         | _        |                      ¦   «          | j                             ¦   «          dS )a^  
        Prepare a new Feature object for data acquisition.

        >>> s = stream.Stream()
        >>> fe = features.jSymbolic.InitialTimeSignatureFeature(s)
        >>> fe.prepareFeature()
        >>> fe.feature.name
        'Initial Time Signature'
        >>> fe.feature.dimensions
        2
        >>> fe.feature.vector
        [0, 0]
        N)r   r@   rR   r,   r&   s    r   ÚprepareFeaturezFeatureExtractor.prepareFeatureÛ   s;   € õ ‘y”yˆŒØ×"Ò"Ñ$Ô$Ð$ØŒ×#Ò#Ñ%Ô%Ð%Ð%Ð%r   c                ó   — dS )zF
        Do processing necessary, storing result in _feature.
        Nr   r&   s    r   ÚprocesszFeatureExtractor.processí   s	   € ð
 	ˆr   c                ó²   — |�|| _         |                      ¦   «          |                      ¦   «          | j        r| j                             ¦   «          | j        S )z<
        Extract the feature and return the result.
        )r   rT   rV   r7   r@   )r'   Úsources     r   ÚextractzFeatureExtractor.extractô   sV   € ð ÐØ ˆDŒKà×ÒÑÔÐØ�Š‰ŒˆØŒ>ð 	%ØŒL×"Ò"Ñ$Ô$Ð$ØŒ|Ðr   c                ót   — t          ¦   «         }|                      |¦  «         |                     ¦   «          |S )aR  
        Return a properly configured plain feature as a placeholder

        >>> fe = features.jSymbolic.InitialTimeSignatureFeature()
        >>> fe.name
        'Initial Time Signature'

        >>> blankF = fe.getBlankFeature()
        >>> blankF.vector
        [0, 0]
        >>> blankF.name
        'Initial Time Signature'
        )r   rR   r,   )r'   Úfs     r   ÚgetBlankFeaturez FeatureExtractor.getBlankFeature  s8   € õ ‰IŒIˆØ×"Ò" 1Ñ%Ô%Ð%Ø	×ÒÑÔÐØˆr   ©N)r;   r<   )r   r   r   r8   r(   r?   rP   rR   rT   rV   rY   r\   r   r   r   r:   r:   €   s¯   € € € € € ðð ð #ð#ð #ð #ð #ð #ð.)ð )ð )ð&ð ð ð0ð ð ð ð&ð &ð &ð$ð ð ðð ð ð ðð ð ð ð r   r:   c                  ó  — e Zd ZdZd:d;d„Zd<d„Zd=d
„Zd>d„Zd?d@d„ZdAd„Z	d„ Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zi dd „ “d!d"„ “d#d$„ “d%e“d&d'„ “d(e“d)e	“d*e
“d+e“d,e“d-e“d.e“d/e“d0e“d1e“d2d3„ “d4d5„ “d6„ ed7„ ed8œ¥Zd9S )BÚStreamFormsa®  
    A dictionary-like wrapper of a Stream, providing
    numerous representations, generated on-demand, and cached.

    A single StreamForms object can be created for an
    entire Score, as well as one for each Part and/or Voice.

    A DataSet object manages one or more StreamForms
    objects, and exposes them to FeatureExtractors for usage.

    The streamObj is stored as self.stream and if "prepared" then
    the prepared form is stored as .prepared

    A dictionary `.forms` stores various intermediary representations
    of the stream which is the main power of this routine, making
    it simple to add additional feature extractors at low additional
    time cost.
    TÚ	streamObjústream.Streamc                óœ   — || _         | j         �/|r |                      | j         ¦  «        | _        n| j         | _        nd | _        i | _        d S r]   )r   Ú_prepareStreamÚpreparedÚforms)r'   r`   ÚprepareStreams      r   r(   zStreamForms.__init__)  sQ   € ØˆŒØŒ;Ð"Øð ,Ø $× 3Ò 3°D´KÑ @Ô @�”�à $¤�”�à ˆDŒMð 02ˆŒ
ˆ
ˆ
r   r;   úKeysView[str]c                ó4   — | j                              ¦   «         S r]   )re   Úkeysr&   s    r   ri   zStreamForms.keys6  s   € àŒz�ŠÑ Ô Ð r   r	   c                ó2   — |                      d¬¦  «        }|S )z
        Common routines done on Streams prior to processing. Returns a new Stream

        Currently: runs stripTies.
        F)ÚinPlace)Ú	stripTies)r'   r`   s     r   rc   zStreamForms._prepareStream:  s    € ð ×'Ò'°Ð'Ñ6Ô6ˆ	ØÐr   ÚkeyÚstrc                ó”  — || j         v r| j         |         S |                     d¦  «        }| j        }t          t	          |¦  «        ¦  «        D ]ø}d                     |d|dz   …         ¦  «        }|| j         v rŒ,|dk    r*d                     |d|…         ¦  «        }| j         |         }||         }|| j        v r | j        |         | |¦  «        }ni|                     d¦  «        r?|t	          d¦  «        d…         }|                     |¦  «         	                    ¦   «         }nt          d|› d|› �¦  «        ‚|| j         |<   Œù|S )	zQ
        Get a form of this Stream, using a cached version if available.
        ú.Nr   r   zgetElementsByClass(éÿÿÿÿzno such attribute: z in )re   Úsplitrd   rN   ÚlenÚjoinÚkeysToMethodsÚ
startswithÚgetElementsByClassr   ÚAttributeError)	r'   rm   Ú	splitKeysrd   r5   ÚsubKeyÚpreviousKeyÚlastKeyÚ
classToGets	            r   Ú__getitem__zStreamForms.__getitem__D  sb  € ð
 �$”*ÐÐØ”:˜c”?Ð"à—I’I˜c‘N”Nˆ	à”=ˆÝ•s˜9‘~”~Ñ&Ô&ð 	*ð 	*ˆAØ—X’X˜i¨¨¨Q©¨Ô/Ñ0Ô0ˆFØ˜œÐ#Ð#ØØ�1ŠuˆuØ!Ÿhšh y°°!°¤}Ñ5Ô5�àœ: kÔ2�à ”lˆGà˜$Ô,Ð,Ð,Ø6˜4Ô-¨gÔ6°t¸XÑFÔF��Ø×#Ò#Ð$9Ñ:Ô:ð OØ")­#Ð.CÑ*DÔ*DÀRÐ*GÔ"H�
Ø#×6Ò6°zÑBÔB×IÒIÑKÔK��å$Ð%M¸7Ð%MÐ%MÈÐ%MÐ%MÑNÔNÐNØ!)ˆDŒJ�vÑÐàˆr   Úmidiú	list[int]c                óø  — dgdz  }t          | j        t          j        ¦  «        rt	          | j        j        ¦  «        }n| j        g}|D ]¯}|                     dddd¬¦  «        }t          |¦  «        D ]„\  }}|t          |¦  «        dz
  k     ri|dz   }||         }	t          |j
        |¦  «        }
t          |	j
        |¦  «        }	 |t          |
|z
  ¦  «        xx         dz  cc<   Œt# t          $ r Y Œ€w xY wŒ…Œ°|S )Nr   é€   T©Ú	skipRestsÚ
skipChordsÚskipGapsÚnoNoner   )rF   rd   r   ÚScoreÚlistÚpartsÚfindConsecutiveNotesr1   rs   ÚgetattrÚpitchÚabsrx   )r'   Ú	algorithmÚhistorŠ   ÚprO   r5   ÚnÚiNextÚnNextÚnValueÚ	nextValues               r   Ú_getIntervalHistogramz!StreamForms._getIntervalHistograme  s>  € à��c‘	ˆõ �d”m¥V¤\Ñ2Ô2ð 	$Ý˜œÔ,Ñ-Ô-ˆEˆEà”]�OˆEØð 	ð 	ˆAð ×)Ò)°DØ59Ø37Ø15ð *ñ 7ô 7ˆDõ
 " $™œð 
ð 
‘��1Ø•s˜4‘y”y 1‘}Ò$Ð$Ø ™E�EØ  œK�EÝ$ Q¤W¨iÑ8Ô8�FÝ '¨¬°YÑ ?Ô ?�IðØ�c &¨9Ñ"4Ñ5Ô5Ð6Ð6Ô6¸!Ñ;Ð6Ð6Ñ6Ð6øÝ)ð ð ð Ø˜ðøøøð %ð
ð ˆs   Ã C(Ã(
C5Ã4C5rd   c                ó8   — ddl m} |                     |¦  «        S )Nr   )Ú
instrument)Úmusic21r™   ÚpartitionByInstrument)r'   rd   r™   s      r   ÚformPartitionByInstrumentz%StreamForms.formPartitionByInstrument…  s(   € Ø&Ð&Ð&Ð&Ð&Ð&Ø×/Ò/°Ñ9Ô9Ð9r   c                ó4   — t          d„ |D ¦   «         ¦  «        S )Nc                ó   — g | ]	}|j         ‘Œ
S r   )ÚforteClassTnI©Ú.0Úcs     r   ú
<listcomp>z5StreamForms.formSetClassHistogram.<locals>.<listcomp>Š  s   € Ð:Ð:Ð:¨A˜œÐ:Ð:Ð:r   r   ©r'   rd   s     r   ÚformSetClassHistogramz!StreamForms.formSetClassHistogram‰  s   € ÝÐ:Ð:°Ð:Ñ:Ô:Ñ;Ô;Ð;r   c                ó4   — t          d„ |D ¦   «         ¦  «        S )Nc                ó   — g | ]	}|j         ‘Œ
S r   )ÚorderedPitchClassesStringr    s     r   r£   z:StreamForms.formPitchClassSetHistogram.<locals>.<listcomp>�  s   € ÐFÐFÐF¸˜Ô3ÐFÐFÐFr   r   r¤   s     r   ÚformPitchClassSetHistogramz&StreamForms.formPitchClassSetHistogramŒ  s   € ÝÐFÐF¸XÐFÑFÔFÑGÔGÐGr   c                óˆ   — i }g d¢}|D ]8}|D ]3}||vrd||<    t          ||¦  «        ¦   «         r||xx         dz  cc<   Œ4Œ9|S )N)ÚisTriadÚ	isSeventhÚisMajorTriadÚisMinorTriadÚisIncompleteMajorTriadÚisIncompleteMinorTriadÚisDiminishedTriadÚisAugmentedTriadÚisDominantSeventhÚisDiminishedSeventhÚisHalfDiminishedSeventhr   r   )rŒ   )r'   rd   r�   ri   r¢   ÚthisKeys         r   ÚformTypesHistogramzStreamForms.formTypesHistogram�  s‰   € Øˆð+ð +ð +ˆð
 ð 	(ð 	(ˆAØð (ð (�Ø %Ð'Ð'Ø%&�E˜'‘Nà&•7˜1˜gÑ&Ô&Ñ(Ô(ð (Ø˜'�N�N”N aÑ'�N�N‘Nøð(ð ˆr   c                óJ  — t          |t          j        ¦  «        rit          j        ¦   «         }|j        D ]M}|                     t          j        ¦  «        D ]+}|                     |                     |¦  «        |¦  «         Œ,ŒNn|                     t          j        ¦  «        }|S r]   )	rF   r   rˆ   rG   rŠ   rw   ÚMeasureÚinsertÚgetOffsetBySite)r'   rd   rO   r‘   Úms        r   ÚformGetElementsByClassMeasurez)StreamForms.formGetElementsByClassMeasure¡  sœ   € Ý�h¥¤Ñ-Ô-ð 	?Ý”=‘?”?ˆDØ”^ð 9ð 9�à×-Ò-­f¬nÑ=Ô=ð 9ð 9�AØ—K’K × 1Ò 1°!Ñ 4Ô 4°aÑ8Ô8Ð8Ð8ð9ð9ð
 ×.Ò.­v¬~Ñ>Ô>ˆDØˆr   c                óh   — t          |t          j        ¦  «        r|                     dd¬¦  «        S |S )NTF)ÚaddPartIdAsGroupÚremoveRedundantPitches)rF   r   rˆ   Úchordifyr¤   s     r   ÚformChordifyzStreamForms.formChordify¬  sD   € Ý�h¥¤Ñ-Ô-ð 	ð ×$Ò$Ø!%¸eð %ñ Eô Eð Eð
 ˆOr   c                ó4   — t          d„ |D ¦   «         ¦  «        S )Nc                ó6   — g | ]}t          |j        ¦  «        ‘ŒS r   )ÚfloatÚquarterLength)r¡   r’   s     r   r£   z:StreamForms.formQuarterLengthHistogram.<locals>.<listcomp>¸  s"   € ÐAÐAÐA°1�˜aœoÑ.Ô.ÐAÐAÐAr   r   r¤   s     r   ÚformQuarterLengthHistogramz&StreamForms.formQuarterLengthHistogram·  s   € ÝÐAÐA¸ÐAÑAÔAÑBÔBÐBr   c                ó4   — t          d„ |D ¦   «         ¦  «        S )Nc                ó   — g | ]	}|j         ‘Œ
S r   ©r   ©r¡   r‘   s     r   r£   z6StreamForms.formMidiPitchHistogram.<locals>.<listcomp>»  s   € Ð0Ð0Ð0 1˜œÐ0Ð0Ð0r   r   )r'   Úpitchess     r   ÚformMidiPitchHistogramz"StreamForms.formMidiPitchHistogramº  s   € ÝÐ0Ð0¨Ð0Ñ0Ô0Ñ1Ô1Ð1r   c                ód   — t          d„ |D ¦   «         ¦  «        }dgdz  }|D ]}||         ||<   Œ|S )Nc                ó   — g | ]	}|j         ‘Œ
S r   )Ú
pitchClassrË   s     r   r£   z7StreamForms.formPitchClassHistogram.<locals>.<listcomp>¾  s   € Ð4Ð4Ð4 q�a”lÐ4Ð4Ð4r   r   é   r   )r'   rÌ   Úccr�   Úks        r   ÚformPitchClassHistogramz#StreamForms.formPitchClassHistogram½  sL   € ÝÐ4Ð4¨GÐ4Ñ4Ô4Ñ5Ô5ˆØ��b‘ˆØð 	ð 	ˆAØ˜!”uˆE�!‰HˆHØˆr   c                ó,   — |                       d¦  «        S )Nr   )r—   )r'   Úunuseds     r   ÚformMidiIntervalHistogramz%StreamForms.formMidiIntervalHistogramÄ  s   € Ø×)Ò)¨&Ñ1Ô1Ð1r   c                ó  — g }|                      ¦   «         r|j        }n|g}|D ]Û}|                     dddd¬¦  «        }t          |¦  «        D ]°\  }}|t	          |¦  «        dz
  k     r•|dz   }||         }	|j        r%|                     ¦   «         j        d         j        }
n|j	        j        }
|	j        r%|	                     ¦   «         j        d         j        }n|	j	        j        }| 
                    ||
z
  ¦  «         Œ±ŒÜ|S )NTFrƒ   r   rq   )ÚhasPartLikeStreamsrŠ   r‹   r1   rs   ÚisChordÚsortDiatonicAscendingrÌ   r   r�   rL   )r'   rd   ÚcListrŠ   r‘   rO   r5   r’   r“   r”   ÚpsÚpsNexts               r   ÚformContourListzStreamForms.formContourListÇ  s)  € àˆà×&Ò&Ñ(Ô(ð 	Ø”NˆEˆEà�JˆEàð 	.ð 	.ˆAð ×)Ò)°DØ5:Ø37Ø15ð *ñ 7ô 7ˆDõ " $™œð .ð .‘��1Ø�˜D™	œ	 A™Ò&Ð&Ø ™E�EØ  œK�Eà”yð *Ø×4Ò4Ñ6Ô6Ô>¸rÔBÔG˜˜àœWœ\˜Ø”}ð 2Ø!&×!<Ò!<Ñ!>Ô!>Ô!FÀrÔ!JÔ!O˜˜à!&¤Ô!1˜à—L’L ¨"¡Ñ-Ô-Ð-øð.ð  ˆr   c                óŒ   — g }|j         }|D ]7}t          |d         t          j        ¦  «        r|                     |¦  «         Œ8|S )NÚelement)Ú
secondsMaprF   r   ÚNotRestrL   )r'   rd   rO   râ   Úbundles        r   ÚformSecondsMapzStreamForms.formSecondsMapê  sO   € ØˆØÔ(ˆ
à ð 	$ð 	$ˆFÝ˜& Ô+­T¬\Ñ:Ô:ð $Ø—’˜FÑ#Ô#Ð#øØˆr   c                ó¤   — d„ |D ¦   «         }d„ |D ¦   «         }dgdz  }|D ].}|dk     s|dk    rŒt          |¦  «        }||xx         dz  cc<   Œ/|S )Nc                ó   — g | ]
}|d          ‘ŒS )ÚdurationSecondsr   ©r¡   Úds     r   r£   z1StreamForms.formBeatHistogram.<locals>.<listcomp>ô  s   € Ð@Ð@Ð@°�qÐ*Ô+Ð@Ð@Ð@r   c                ó2   — g | ]}t          d |z  ¦  «        ‘ŒS )g      N@)Úroundré   s     r   r£   z1StreamForms.formBeatHistogram.<locals>.<listcomp>õ  s"   € Ð8Ð8Ð8 q•5˜ ™‘?”?Ð8Ð8Ð8r   r   éÈ   é(   r   )Úint)r'   râ   ÚsecondsListÚbpmListÚ	histogramÚthisBPMÚhistogramIndexs          r   ÚformBeatHistogramzStreamForms.formBeatHistogramó  s†   € Ø@Ð@°ZÐ@Ñ@Ô@ˆØ8Ð8¨KÐ8Ñ8Ô8ˆØ�C˜#‘Iˆ	Øð 	+ð 	+ˆGØ˜Š|ˆ|˜w¨š}˜}ØÝ  ™\œ\ˆNØ�nÐ%Ð%Ô%¨Ñ*Ð%Ð%Ñ%Ð%ØÐr   Úflatc                ó*   — |                      ¦   «         S r]   )Úflatten©rÖ   r‘   s     r   ú<lambda>zStreamForms.<lambda>ÿ  s   €  !§)¢)¡+¤+€ r   rÌ   c                ó   — |j         S r]   )rÌ   rù   s     r   rú   zStreamForms.<lambda>   s   €  Q¤Y€ r   Únotesc                ó   — |j         S r]   )rü   rù   s     r   rú   zStreamForms.<lambda>  s   €  1¤7€ r   úgetElementsByClass(Measure)ÚmetronomeMarkBoundariesc                ó*   — |                      ¦   «         S r]   )rÿ   rù   s     r   rú   zStreamForms.<lambda>  s   € °Q×5NÒ5NÑ5PÔ5P€ r   rÁ   r›   ÚsetClassHistogramÚpitchClassHistogramÚtypesHistogramÚquarterLengthHistogramÚpitchClassSetHistogramÚmidiPitchHistogramÚmidiIntervalHistogramÚcontourListÚanalyzedKeyc                ó.   — |                      d¬¦  «        S )Nrm   )Úmethod)Úanalyze)rÖ   r[   s     r   rú   zStreamForms.<lambda>  s   € ¨¯ª¸%¨Ñ)@Ô)@€ r   ÚtonalCertaintyc                ó*   — |                      ¦   «         S r]   )r  )rÖ   ÚfoundKeys     r   rú   zStreamForms.<lambda>  s   € °8×3JÒ3JÑ3LÔ3L€ r   c                ó   — |j         S r]   )Úmetadatarù   s     r   rú   zStreamForms.<lambda>  s   €  a¤j€ r   c                ó*   — t          j        |¦  «        S r]   )r   ÚassembleLyricsrù   s     r   rú   zStreamForms.<lambda>  s   € ­TÔ-@ÀÑ-CÔ-C€ r   )r  râ   ÚassembledLyricsÚbeatHistogramN©T)r`   ra   )r;   rg   )r`   r	   r;   r	   )rm   rn   r;   ra   rÊ   )r;   r€   )rd   ra   )r   r   r   r8   r(   ri   rc   r~   r—   rœ   r¥   r©   r·   r½   rÂ   rÇ   rÍ   rÔ   r×   rß   rå   rõ   ru   r   r   r   r_   r_     sj  € € € € € ðð ð$2ð 2ð 2ð 2ð 2ð!ð !ð !ð !ðð ð ð ðð ð ð ðBð ð ð ð ð@:ð :ð :ð :ð<ð <ð <ðHð Hð Hðð ð ð$	ð 	ð 	ð	ð 	ð 	ðCð Cð Cð2ð 2ð 2ðð ð ð2ð 2ð 2ð!ð !ð !ðFð ð ð	ð 	ð 	ðØÐ-Ð-ðàÐ.Ð.ðð 	Ð*Ð*ðð 	&Ð'Dð	ð
 	"Ð#PÐ#Pðð 	�Lðð 	 Ð!:ðð 	Ð2ðð 	Ð6ðð 	Ð,ðð 	!Ð"<ðð 	!Ð"<ðð 	Ð4ðð 	 Ð!:ðð 	�ðð  	Ð@Ð@ð!ð" 	ÐLÐLð#ð$ 1Ð0Ø$ØCÐCØ*ð+ð ð €M€M€Mr   r_   c                  ó@   — e Zd ZdZd
d„Zd„ Zdd„Zd„ Zd„ Zd„ Z	d	„ Z
dS )rH   zÂ
    A data instance for analysis. This object prepares a Stream
    (by stripping ties, etc.) and stores
    multiple commonly-used stream representations once, providing rapid processing.
    Nc                ó¤  — t          |t          j        ¦  «        r|| _        d | _        nd | _        || _        |�|| _        nÀ| j        x}�-t          |d¦  «        r|j        x}�|j        �|j        | _        nŠ| j        �'t          | j        d¦  «        r| j        j        | _        n\| j        �Nt          | j        d¦  «        rt          | j        j        ¦  «        | _        n!t          | j        ¦  «        | _        nd| _        d | _
        d | _        d| _        d | _        g | _        g | _        g | _        | j        �|                      ¦   «          d S d S )Nr  Ú
sourcePathÚ r   )rF   r   rG   Ú
streamPathÚ_idrA   r  Útitler  rn   Ú
classLabelÚ_classValueÚ
partsCountre   ÚformsByVoiceÚformsByPartÚ)featureExtractorClassesForParallelRunningÚsetupPostStreamParse)r'   ÚstreamOrPathÚidr2   Úmds        r   r(   zDataInstance.__init__   sW  € Ý�l¥F¤MÑ2Ô2ð 	+Ø&ˆDŒKØ"ˆDŒOˆOàˆDŒKØ*ˆDŒOð ˆ>ØˆDŒHˆHØ”KÐˆqÐ,Ý˜!˜ZÑ(Ô(ð -àœÐ#�2Ð0Ø”(Ð&à”xˆDŒHˆHØŒ[Ð$­°´¸lÑ)KÔ)KÐ$Ø”{Ô-ˆDŒHˆHØŒ_Ð(Ý�t”¨Ñ5Ô5ð 0Ý˜tœÔ9Ñ:Ô:�”�å˜tœÑ/Ô/�”�àˆDŒHð ˆŒàˆÔàˆŒØˆŒ
ð ˆÔàˆÔà9;ˆÔ6àŒ;Ð"Ø×%Ò%Ñ'Ô'Ð'Ð'Ð'ð #Ð"r   c                óª  — t          | j        ¦  «        | _        g | _        t	          | j        d¦  «        rUt          | j        j        ¦  «        | _        | j        j        D ])}| j                             t          |¦  «        ¦  «         Œ*nd| _        | j        t          j	                 D ])}| j                             t          |¦  «        ¦  «         Œ*dS )zî
        Set up the StreamForms objects and other things that
        need to be done after a Stream is passed in but before
        feature extracting is run.

        Run automatically at instantiation if a Stream is passed in.
        rŠ   r   N)
r_   r   re   r"  rA   rs   rŠ   r   rL   ÚVoice)r'   r‘   r6   s      r   r$  z!DataInstance.setupPostStreamParseN  sË   € õ ! ¤Ñ-Ô-ˆŒ
ð ˆÔÝ�4”; Ñ(Ô(ð 	 Ý! $¤+Ô"3Ñ4Ô4ˆDŒOØ”[Ô&ð 8ð 8�àÔ ×'Ò'­°A©¬Ñ7Ô7Ð7Ð7ð8ð  ˆDŒOà”�Vœ\Ô*ð 	4ð 	4ˆAØÔ×#Ò#¥K°¡N¤NÑ3Ô3Ð3Ð3ð	4ð 	4r   c                ó"   — || _         || _        dS )ae  
        Set the class label, as well as the class value if known.
        The class label is the attribute name used to define the class of this data instance.

        >>> #_DOCS_SHOW s = corpus.parse('bwv66.6')
        >>> s = stream.Stream() #_DOCS_HIDE
        >>> di = features.DataInstance(s)
        >>> di.setClassLabel('Composer', 'Bach')
        N)r  r  )r'   r  Ú
classValues      r   ÚsetClassLabelzDataInstance.setClassLabeli  s   € ð %ˆŒØ%ˆÔÐÐr   c                óÌ   — | j         �t          | j         ¦  «        r	| j        €dS t          | j         ¦  «        r&| j        �|                       | j        ¦  «        | _         | j         S )Nr  )r  Úcallabler   r&   s    r   ÚgetClassValuezDataInstance.getClassValuev  sb   € ØÔÐ#¥x°Ô0@Ñ'AÔ'AÐ#ÀdÄkÐFYØ�2å�DÔ$Ñ%Ô%ð 	=¨$¬+Ð*AØ#×/Ò/°´Ñ<Ô<ˆDÔàÔÐr   c                ó^  — | j         �t          | j         ¦  «        r	| j        €dS t          | j         ¦  «        r&| j        �|                       | j        ¦  «        | _         	 | j                              dd¦  «        S # t          $ r'}t	          t          | j         ¦  «        ¦  «        |‚d }~ww xY w)Nr  rJ   rK   )r  r.  r   rM   rx   rn   )r'   Úes     r   ÚgetIdzDataInstance.getId  s§   € ØŒ8Ð�x¨¬Ñ1Ô1Ð°d´kÐ6IØ�2å�D”HÑÔð 	- $¤+Ð"9Ø—x’x ¤Ñ,Ô,ˆDŒHð	7Ø”8×#Ò# C¨Ñ-Ô-Ð-øÝð 	7ð 	7ð 	7Ý ¥ T¤X¡¤Ñ/Ô/°QÐ6øøøøð	7øøøs   Á A; Á;
B,Â"B'Â'B,c                óî  — | j         �dS t          | j        t          ¦  «        rrt          j                             | j        ¦  «        s| j                             d¦  «        rt          j	        | j        ¦  «        }nÞt          j	        | j        ¦  «        }nÄt          | j        t          j        ¦  «        rM| j                             ¦   «         rt          j	        | j        ¦  «        }nrt          j	        | j        ¦  «        }nXt          | j        t          ¦  «        r| j         	                    ¦   «         }n$t          dt          | j        ¦  «        › �¦  «        ‚|| _         |                      ¦   «          dS )zò
        If a path to a Stream has been passed in at creation,
        then this will parse it (whether it's a corpus string,
        a converter string (url or filepath), a pathlib.Path,
        or a metadata.bundles.MetadataEntry).
        NÚhttpzInvalid streamPath type: )r   rF   r  rn   ÚosÚpathÚexistsrv   r
   Úparser   ÚpathlibÚPathr   Ú
ValueErrorÚtyper$  )r'   r2   s     r   ÚparseStreamzDataInstance.parseStreamŒ  s8  € ð Œ;Ð"ØˆFå�d”o¥sÑ+Ô+ð 	RåŒw�~Š~˜dœoÑ.Ô.ð 2°$´/×2LÒ2LÈVÑ2TÔ2Tð 2Ý”O D¤OÑ4Ô4��å”L ¤Ñ1Ô1��Ý˜œ­¬Ñ6Ô6ð 		RàŒ×%Ò%Ñ'Ô'ð 2Ý”O D¤OÑ4Ô4��å”L ¤Ñ1Ô1��Ý˜œ­Ñ7Ô7ð 	RØ”×%Ò%Ñ'Ô'ˆAˆAåÐP½¸d¼oÑ9NÔ9NÐPÐPÑQÔQÐQàˆŒØ×!Ò!Ñ#Ô#Ð#Ð#Ð#r   c                óp   — |                       ¦   «          |dv r| j        S |dv r| j        S | j        |         S )a•  
        Get a form of this Stream, using a cached version if available.

        >>> di = features.DataInstance('bach/bwv66.6')
        >>> len(di['flat'])
        197
        >>> len(di['flat.pitches'])
        163
        >>> len(di['flat.notes'])
        163
        >>> len(di['getElementsByClass(Measure)'])
        40
        >>> len(di['flat.getElementsByClass(TimeSignature)'])
        4
        )rŠ   )Úvoices)r=  r"  r!  re   )r'   rm   s     r   r~   zDataInstance.__getitem__ª  sL   € ð  	×ÒÑÔÐØ�)ÐÐàÔ#Ð#Ø�JÐÐàÔ$Ð$ð Œz˜#ŒÐr   ©NNr]   )r   r   r   r8   r(   r$  r,  r/  r2  r=  r~   r   r   r   rH   rH     s’   € € € € € ðð ð,(ð ,(ð ,(ð ,(ð\4ð 4ð 4ð6&ð &ð &ð &ð ð  ð  ð7ð 7ð 7ð$ð $ð $ð<ð ð ð ð r   rH   c                  ó   — e Zd ZdS )ÚDataSetExceptionNr   r   r   r   rB  rB  Ç  r   r   rB  c                  óŽ   — e Zd ZdZdd„Zd„ Zd„ Z	 	 dd„Zdd	„Zdd
„Z	dd„Z
dd„Zd„ Zd„ Zd„ Zdd„Zd„ Zd„ Zd„ Zdd„Zdd„ZdS )ÚDataSetad  
    A set of features, as well as a collection of data to operate on.

    Comprises multiple DataInstance objects, a FeatureSet, and an OutputFormat.

    >>> ds = features.DataSet(classLabel='Composer')
    >>> f = [features.jSymbolic.PitchClassDistributionFeature,
    ...      features.jSymbolic.ChangesOfMeterFeature,
    ...      features.jSymbolic.InitialTimeSignatureFeature]
    >>> ds.addFeatureExtractors(f)
    >>> ds.addData('bwv66.6', classValue='Bach')
    >>> ds.addData('bach/bwv324.xml', classValue='Bach')
    >>> ds.process()
    >>> ds.getFeaturesAsList()[0]
    ['bwv66.6', 0.196..., 0.0736..., 0.006..., 0.098..., 0.0368..., 0.177..., 0.0,
     0.085..., 0.134..., 0.018..., 0.171..., 0.0, 0, 4, 4, 'Bach']
    >>> ds.getFeaturesAsList()[1]
    ['bach/bwv324.xml', 0.25, 0.0288..., 0.125, 0.0, 0.144..., 0.125, 0.0, 0.163..., 0.0, 0.134...,
    0.0288..., 0.0, 0, 4, 4, 'Bach']

    >>> ds = ds.getString()

    By default, all exceptions are caught and printed if debug mode is on.

    Set ds.failFast = True to not catch them.

    Set ds.quiet = False to print them regardless of debug mode.
    Nr   c                ó    — g | _         g | _        g | _        || _        g | _        d| _        d| _        d| _        |                      |¦  «         d S )NFT)	ÚdataInstancesÚ_featureExtractorsÚ_instantiatedFeatureExtractorsÚ_classLabelÚfeaturesÚfailFastÚquietÚrunParallelÚaddFeatureExtractors)r'   r  ÚfeatureExtractorss      r   r(   zDataSet.__init__é  s\   € àˆÔð #%ˆÔØ.0ˆÔ+à%ˆÔàˆŒàˆŒØˆŒ
àˆÔà×!Ò!Ð"3Ñ4Ô4Ð4Ð4Ð4r   c                ó   — | j         S r]   )rI  r&   s    r   ÚgetClassLabelzDataSet.getClassLabelü  s   € ØÔÐr   c                ó¶   — t          j        |¦  «        s|g}|D ]>}| j                             |¦  «         | j                              |¦   «         ¦  «         Œ?dS )zh
        Add one or more FeatureExtractor objects, either as a list or as an individual object.
        N)r   Ú
isIterablerG  rL   rH  )r'   ÚvaluesÚsubs      r   rN  zDataSet.addFeatureExtractorsÿ  sn   € õ Ô  Ñ(Ô(ð 	Ø�XˆFàð 	>ð 	>ˆCØÔ#×*Ò*¨3Ñ/Ô/Ð/ØÔ/×6Ò6°s°s±u´uÑ=Ô=Ð=Ð=ð	>ð 	>r   Tc                óè   — g }|r|                      d¦  «         | j        D ]}||                     ¦   «         z  }Œ| j        �0|r.|                      | j                             dd¦  «        ¦  «         |S )a9  
        Return a list of all attribute labels. Optionally add a class
        label field and/or an id field.

        >>> f = [features.jSymbolic.PitchClassDistributionFeature,
        ...      features.jSymbolic.ChangesOfMeterFeature]
        >>> ds = features.DataSet(classLabel='Composer', featureExtractors=f)
        >>> ds.getAttributeLabels(includeId=False)
        ['Pitch_Class_Distribution_0',
         'Pitch_Class_Distribution_1',
         ...
         ...
         'Pitch_Class_Distribution_11',
         'Changes_of_Meter',
         'Composer']
        Ú
IdentifierNrJ   rK   )rL   rH  rP   rI  rM   ©r'   ÚincludeClassLabelÚ	includeIdrO   Úfes        r   rP   zDataSet.getAttributeLabels  s†   € ð$ ˆàð 	&Ø�KŠK˜Ñ%Ô%Ð%ØÔ5ð 	,ð 	,ˆBØ�B×)Ò)Ñ+Ô+Ñ+ˆDˆDØÔÐ'Ð,=Ð'Ø�KŠK˜Ô(×0Ò0°°cÑ:Ô:Ñ;Ô;Ð;Øˆr   c                ó®   — g }|r|                      d¦  «         | j        D ]}||j        g|j        z  z  }Œ| j        �|r|                      d¦  «         |S )a£  
        Return column labels for discrete status.

        >>> f = [features.jSymbolic.PitchClassDistributionFeature,
        ...      features.jSymbolic.ChangesOfMeterFeature]
        >>> ds = features.DataSet(classLabel='Composer', featureExtractors=f)
        >>> ds.getDiscreteLabels()
        [None, False, False, False, False, False, False, False, False, False,
         False, False, False, True, True]
        NT)rL   rH  r%   r    rI  rX  s        r   ÚgetDiscreteLabelszDataSet.getDiscreteLabels(  sr   € ð ˆØð 	Ø�KŠK˜ÑÔÐØÔ5ð 	2ð 	2ˆBà�R”[�M B¤MÑ1Ñ1ˆDˆDàÔÐ'Ð,=Ð'Ø�KŠK˜ÑÔÐØˆr   c                ó    — g }|r|                      d¦  «         | j        D ]}|dg|j        z  z  }Œ| j        �|                      d¦  «         |S )a»  
        Return column labels for the presence of a class definition

        >>> f = [features.jSymbolic.PitchClassDistributionFeature,
        ...      features.jSymbolic.ChangesOfMeterFeature]
        >>> ds = features.DataSet(classLabel='Composer', featureExtractors=f)
        >>> ds.getClassPositionLabels()
        [None, False, False, False, False, False, False, False, False,
         False, False, False, False, False, True]
        NFT)rL   rH  r    rI  )r'   rZ  rO   r[  s       r   ÚgetClassPositionLabelszDataSet.getClassPositionLabels>  sj   € ð ˆØð 	Ø�KŠK˜ÑÔÐØÔ5ð 	,ð 	,ˆBà�U�G˜bœmÑ+Ñ+ˆDˆDàÔÐ'Ø�KŠK˜ÑÔÐØˆr   c                ó2  — t          |¦  «        s/t          |¦  «        t          |¦  «        k    rt          d¦  «        ‚|�>t          |¦  «        s/t          |¦  «        t          |¦  «        k    rt          d¦  «        ‚t          |¦  «        rK	 t          j        |¦  «         n"# t          j        $ r t          d¦  «        ‚w xY w|gt          |¦  «        z  }t          |¦  «        rL	 t          j        |¦  «         n"# t          j        $ r t          d¦  «        ‚w xY w|gt          |¦  «        z  }n|€dgt          |¦  «        z  }t          t          |¦  «        ¦  «        D ]1}||         }||         }||         }|                      |||¦  «         Œ2dS )a‘  
        add multiple data points at the same time.

        Requires an iterable (including MetadataBundle) for dataList holding
        types that can be passed to addData, and an equally sized list of dataValues
        and an equally sized list of ids (or None)

        classValues can also be a pickleable function that will be called on
        each instance after parsing, as can ids.
        zJIf classValues is not a function, it must have the same length as dataListNzJIf ids is not a function or None, it must have the same length as dataListzVclassValues if a function must be pickleable. Lambda and some other functions are not.zNids if a function must be pickleable. Lambda and some other functions are not.)r.  rs   rB  ÚpickleÚdumpsÚPicklingErrorrN   ÚaddData)r'   ÚdataListÚclassValuesÚidsr5   rê   ÚcvÚthisIds           r   ÚaddMultipleDatazDataSet.addMultipleDataT  sð  € õ ˜Ñ%Ô%ð 	^Ý˜‘M”M¥S¨Ñ%5Ô%5Ò5Ð5Ý"Ø\ñ^ô ^ð ^àˆOÝ  ™œð å˜‘M”M¥S¨¡X¤XÒ-Ð-Ý"Ø\ñ^ô ^ð ^õ �KÑ Ô ð 	8ðUÝ”˜[Ñ)Ô)Ð)Ð)øÝÔ'ð Uð Uð UÝ&ð (Tñ Uô Uð UðUøøøð '˜-­#¨h©-¬-Ñ7ˆKå�C‰=Œ=ð 		)ðUÝ”˜SÑ!Ô!Ð!Ð!øÝÔ'ð Uð Uð UÝ&ð (Tñ Uô Uð UðUøøøð �%�#˜h™-œ-Ñ'ˆCˆCØˆ[Ø�&�3˜x™=œ=Ñ(ˆCå•s˜8‘}”}Ñ%Ô%ð 	(ð 	(ˆAØ˜”ˆAØ˜Q”ˆBØ˜”VˆFØ�LŠL˜˜B Ñ'Ô'Ð'Ð'ð		(ð 	(s   ÂB$ Â$CÃ)C> Ã>Dc                ó  — | j         €t          d¦  «        ‚d}t          |t          ¦  «        r|}|j        }|€|j        }n|}t          ||¬¦  «        }|                     | j         |¦  «         | j                             |¦  «         dS )zõ
        Add a Stream, DataInstance, MetadataEntry, or path (Posix or str)
        to a corpus or local file to this data set.

        The class value passed here is assumed to be the same as
        the classLabel assigned at startup.
        NzCcannot add data unless a class label for this DataSet has been set.)r&  )	rI  rB  rF   rH   r   r  r,  rF  rL   )r'   ÚdataOrStreamOrPathr+  r&  r2   Údis         r   rd  zDataSet.addData…  s¨   € ð ÔÐ#Ý"ØUñWô Wð Wð ˆÝÐ(­,Ñ7Ô7ð 	9Ø#ˆBØ”	ˆAØˆyØ”M�øð #ˆAÝÐ0°RÐ8Ñ8Ô8ˆBà
×Ò˜Ô)¨:Ñ6Ô6Ð6ØÔ×!Ò! "Ñ%Ô%Ð%Ð%Ð%r   c                ó|   — | j         r"t          ¦   «         r|                      ¦   «         S |                      ¦   «         S )z‡
        Process all Data with all FeatureExtractors.
        Processed data is stored internally as numerous Feature objects.
        )rM  r   Ú_processParallelÚ_processNonParallelr&   s    r   rV   zDataSet.processŸ  s@   € ð
 Ôð 	.¥Ñ 1Ô 1ð 	.Ø×(Ò(Ñ*Ô*Ð*à×+Ò+Ñ-Ô-Ð-r   c                ó2  ‡ — ‰ j         D ]}‰ j        |_        Œ‰ j         }t	          j        ˆ fd„‰ j         D ¦   «         t          |dd¬¦  «        }t          |Ž \  }}}}t	          j        |¦  «        }|D ]@}‰ j        du rt           
                    |¦  «         Œ&t                               |¦  «         ŒA|‰ _        t          ‰ j         ¦  «        D ]G\  }	}t          |j        ¦  «        r||	         |_        t          |j        ¦  «        r||	         |_        ŒHdS )z5
        Run a set of processes in parallel.
        c                ó"   •— g | ]}|‰j         f‘ŒS r   )rK  )r¡   rm  r'   s     €r   r£   z,DataSet._processParallel.<locals>.<listcomp>³  s    ø€ Ð(ZÐ(ZÐ(ZÀ¨"¨d¬mÐ)<Ð(ZÐ(ZÐ(Zr   r   T)ÚupdateFunctionÚupdateMultiplyÚunpackIterableN)rF  rG  r#  rL  r   rM  Ú_dataSetParallelSubprocessÚzipÚflattenListÚenvironLocalÚ
printDebugÚwarnrJ  r1   r.  r  r  )
r'   rm  ÚshouldUpdateÚ
outputDataÚfeatureDataÚerrorsrf  rg  r1  r5   s
   `         r   ro  zDataSet._processParallel©  sH  ø€ ð Ô$ð 	Sð 	SˆBØ;?Ô;RˆBÔ8Ð8àœ:�~ˆõ Ô'Ð(ZÐ(ZÐ(ZÐ(ZÀtÔGYÐ(ZÑ(ZÔ(ZÝ(BØ7CØ78Ø7;ð	*ñ *ô *ˆ
õ 14°ZÐ0@Ñ-ˆ�V˜[¨#ÝÔ# FÑ+Ô+ˆØð 	%ð 	%ˆAØŒz˜TÐ!Ð!Ý×'Ò'¨Ñ*Ô*Ð*Ð*å×!Ò! !Ñ$Ô$Ð$Ð$Ø#ˆŒå˜tÔ1Ñ2Ô2ð 	 ð 	 ‰EˆAˆrÝ˜œÑ'Ô'ð 0Ø!,¨Q¤�”Ý˜œÑÔð  Ø˜Qœ�”øð		 ð 	 r   c                ó   — g | _         | j        D ]î}g }| j        D ]È}|                     |¦  «         	 |                     ¦   «         }n†# t
          $ ry}d|t          |¦  «        g}| j        du rt           	                    |¦  «         nt           
                    |¦  «         | j        du r|‚|                     ¦   «         }Y d}~nd}~ww xY w|                     |¦  «         ŒÉ| j                              |¦  «         ŒïdS )z7
        The traditional way: run non-parallel
        úfailed feature extractor:TN)rJ  rF  rH  r?   rY   Ú	Exceptionrn   rL  ry  rz  r{  rK  r\   rL   )r'   r>   Úrowr[  Ú	fReturnedr1  ÚfLists          r   rp  zDataSet._processNonParallelÈ  s*  € ð
 ˆŒØÔ&ð 	&ð 	&ˆDØˆCØÔ9ð &ð &�Ø—
’
˜4Ñ Ô Ð ð5Ø "§
¢
¡¤�I�IøÝ ð 
5ð 
5ð 
5à8¸"½cÀ!¹f¼fÐE�EØ”z TÐ)Ð)Ý$×/Ò/°Ñ6Ô6Ð6Ð6å$×)Ò)¨%Ñ0Ô0Ð0Ø”}¨Ð,Ð,Ø˜à "× 2Ò 2Ñ 4Ô 4�I�I�I�I�I�Iøøøøð
5øøøð —
’
˜9Ñ%Ô%Ð%Ð%àŒM× Ò  Ñ%Ô%Ð%Ð%ð+	&ð 	&s   ²AÁ
C
ÁA/CÃC
c                óš  — g }t          | j        ¦  «        D ]§\  }}g }| j        |         }|r'|                     |                     ¦   «         ¦  «         |D ])}	|r||	j        z  }Œ|                     |	j        ¦  «         Œ*|r'|                     |                     ¦   «         ¦  «         |                     |¦  «         Œ¨|s
|s|d         S |S )zt
        Get processed data as a list of lists, merging any sub-lists
        in multidimensional features.
        r   )r1   rJ  rF  rL   r2  r!   r/  )
r'   rY  rZ  ÚconcatenateListsrO   r5   rƒ  r6   rm  r[   s
             r   ÚgetFeaturesAsListzDataSet.getFeaturesAsListå  sé   € ð
 ˆÝ ¤Ñ.Ô.ð 	ð 	‰FˆAˆsØˆAØÔ# AÔ&ˆBàð %Ø—’˜Ÿš™œÑ$Ô$Ð$àð 'ð '�Ø#ð 'Ø˜œ‘M�A�Aà—H’H˜QœXÑ&Ô&Ð&Ð&Ø ð -Ø—’˜×)Ò)Ñ+Ô+Ñ,Ô,Ð,Ø�KŠK˜‰NŒNˆNˆNØ ð 	¨ð 	Ø˜”7ˆNàˆKr   c                óx   — g }| j         D ]/}|                     ¦   «         }||vr|                     |¦  «         Œ0|S )z7
        Return a list of unique class values.
        )rF  r/  rL   )r'   rO   rm  r6   s       r   ÚgetUniqueClassValueszDataSet.getUniqueClassValuesÿ  sJ   € ð ˆØÔ$ð 	ð 	ˆBØ× Ò Ñ"Ô"ˆAØ˜ˆ}ˆ}Ø—’˜A‘”�øØˆr   c                ó$  — ddl m} |                     ¦   «         dv r|                     | ¬¦  «        }n\|                     ¦   «         dv r|                     | ¬¦  «        }n/|                     ¦   «         dv r|                     | ¬¦  «        }nd S |S )Nr   ©ÚoutputFormats)ÚtabÚorangeÚ	taborangeN)ÚdataSet)ÚcsvÚcomma)ÚarffÚ	attribute)Úmusic21.featuresr�  ÚlowerÚOutputTabOrangeÚ	OutputCSVÚ
OutputARFF)r'   ÚfeatureFormatr�  ÚoutputFormats       r   Ú_getOutputFormatzDataSet._getOutputFormat
  s¯   € Ø2Ð2Ð2Ð2Ð2Ð2Ø×ÒÑ Ô Ð$HÐHÐHØ(×8Ò8ÀÐ8ÑFÔFˆLˆLØ× Ò Ñ"Ô"Ð&6Ð6Ð6Ø(×2Ò2¸4Ð2Ñ@Ô@ˆLˆLØ× Ò Ñ"Ô"Ð&;Ð;Ð;Ø(×3Ò3¸DÐ3ÑAÔAˆLˆLà�4ØÐr   c                óÊ   — d}d|v r\|                       |                     d¦  «        d         ¦  «        �.|                       |                     d¦  «        d         ¦  «        }|S )aÁ  
        Get an output format from a file path if possible, otherwise return None.

        >>> ds = features.DataSet()
        >>> ds._getOutputFormatFromFilePath('test.tab')
        <music21.features.outputFormats.OutputTabOrange object at ...>
        >>> ds._getOutputFormatFromFilePath('test.csv')
        <music21.features.outputFormats.OutputCSV object at ...>
        >>> ds._getOutputFormatFromFilePath('junk') is None
        True
        Nrp   rq   )r�  rr   )r'   ÚfpÚofs      r   Ú_getOutputFormatFromFilePathz$DataSet._getOutputFormatFromFilePath  s\   € ð ˆØ�"ˆ9ˆ9Ø×$Ò$ R§X¢X¨c¡]¤]°2Ô%6Ñ7Ô7ÐCØ×*Ò*¨2¯8ª8°C©=¬=¸Ô+<Ñ=Ô=�Øˆ	r   rŽ  c                óT   — |                       |¦  «        }|                     ¦   «         S )zS
        Get a string representation of the data set in a specific format.
        )r�  Ú	getString)r'   Ú	outputFmtrœ  s      r   r£  zDataSet.getString)  s)   € ð
 ×,Ò,¨YÑ7Ô7ˆØ×%Ò%Ñ'Ô'Ð'r   c                óÞ   — |€|�|                       |¦  «        }n&|€t          d¦  «        ‚|                      |¦  «        }|€t          d|› d|› �¦  «        ‚|                     ||¬¦  «        S )z/
        Set the output format object.
        NzSpecify a format or a file pathz1no output format could be defined from file path z or format )rŸ  rY  )r¡  r;  r�  rB  Úwrite)r'   rŸ  ÚformatrY  rœ  s        r   r¦  zDataSet.write2  sœ   € ð ˆ>˜b˜nØ×<Ò<¸RÑ@Ô@ˆLˆLØˆ^ÝÐ>Ñ?Ô?Ð?à×0Ò0°Ñ8Ô8ˆLàÐÝ"ð $>Ø&(ð$>ð $>Ø5;ð$>ð $>ñ ?ô ?ð ?ð ×!Ò! RÐ;LÐ!ÑMÔMÐMr   )Nr   )TTr  r]   r@  )TTT)rŽ  )NNT)r   r   r   r8   r(   rQ  rN  rP   r]  r_  rj  rd  rV   ro  rp  rˆ  rŠ  r�  r¡  r£  r¦  r   r   r   rD  rD  Ë  sY  € € € € € ðð ð:5ð 5ð 5ð 5ð& ð  ð  ð>ð >ð >ð 48Ø%)ðð ð ð ð8ð ð ð ð,ð ð ð ð,-(ð -(ð -(ð -(ðb&ð &ð &ð &ð4.ð .ð .ð ð  ð  ð>&ð &ð &ð:ð ð ð ð4	ð 	ð 	ð
ð 
ð 
ðð ð ð&(ð (ð (ð (ðNð Nð Nð Nð Nð Nr   rD  c                óÔ  — g }g }| j         D ]³} |¦   «         }|                     | ¦  «         	 |                     ¦   «         }ng# t          $ rZ}|                     dt          |¦  «        z   dz   t          |¦  «        z   ¦  «         |r|‚|                     ¦   «         }Y d }~nd }~ww xY w|                     |¦  «         Œ´|||                      ¦   «         |                      ¦   «         fS )Nr�  z: )	r#  r?   rY   r‚  rL   rn   r\   r/  r2  )ÚdataInstancerK  rƒ  r  ÚfeClassr[  r„  r1  s           r   rv  rv  D  s  € Ø
€CØ€Fð  ÔIð ð ˆØˆW‰YŒYˆØ
�
Š
�<Ñ Ô Ð ð	-ØŸ
š
™œˆIˆIøÝð 	-ð 	-ð 	-à�MŠMÐ5½¸B¹¼Ñ?À$ÑFÍÈQÉÌÑOÑPÔPÐPØð Ø�à×*Ò*Ñ,Ô,ˆIˆIˆIˆIˆIˆIøøøøð	-øøøð 	�
Š
�9ÑÔÐÐà�˜×2Ò2Ñ4Ô4°l×6HÒ6HÑ6JÔ6JÐJÐJs   ®AÁ
B'ÁAB"Â"B'c                ó4  — ddl m}m} t          d¬¦  «        }t	          |j        ¦  «        t	          |j        ¦  «        z   }|                     |¦  «         |                     | ¦  «         |                     ¦   «          | 	                    ddd¬¦  «        }|S )a^  
    returns a list containing ALL currently implemented feature extractors

    streamInput can be a Stream, DataInstance, or path to a corpus or local
    file to this data set.

    >>> s = converter.parse('tinynotation: 4/4 c4 d e2')
    >>> f = features.allFeaturesAsList(s)
    >>> f[2:5]
    [[2], [2], [1.0]]
    >>> len(f) > 85
    True
    r   ©Ú	jSymbolicÚnativer  ©r  F)rY  rZ  r‡  )
r–  r­  r®  rD  r‰   rO  rN  rd  rV   rˆ  )ÚstreamInputr­  r®  Údsr[   ÚallDatas         r   ÚallFeaturesAsListr³  \  s¨   € ð 3Ð2Ð2Ð2Ð2Ð2Ð2Ð2Ý	˜BÐ	Ñ	Ô	€BÝˆYÔ(Ñ)Ô)­D°Ô1IÑ,JÔ,JÑJ€AØ×Ò˜AÑÔÐØ‡J‚Jˆ{ÑÔÐØ‡J‚J�L„L€LØ×"Ò"°UØ-2Ø49ð #ñ ;ô ;€Gð €Nr   r¬  c                ó˜  — ddl m} ddl m} t          j        |¦  «        s|g}g }|D ]C}|                     ¦   «         dv r||j        z  }Œ#|                     ¦   «         dv r
||j        z  }ŒDt          j        | ¦  «        s| g} g }| D ]i}|                     ¦   «                              ¦   «         }|                     dd¦  «         |                     dd¦  «         | 	                    |¦  «         Œjg }|s|S |D ]P}	|	j
                             ¦   «         |v s|d                              ¦   «         d	k    r| 	                    |	¦  «         ŒQ|S )
aT  
    Given one or more :class:`~music21.features.FeatureExtractor` ids, return the
    appropriate  subclass. An optional `library` argument can be added to define which
    module is used. Current options are jSymbolic and native.

    >>> features.extractorsById('p20')
    [<class 'music21.features.jSymbolic.PitchClassDistributionFeature'>]

    >>> [x.id for x in features.extractorsById('p20')]
    ['P20']
    >>> [x.id for x in features.extractorsById(['p19', 'p20'])]
    ['P19', 'P20']

    Normalizes case:

    >>> [x.id for x in features.extractorsById(['r31', 'r32', 'r33', 'r34', 'r35', 'p1', 'p2'])]
    ['R31', 'R32', 'R33', 'R34', 'R35', 'P1', 'P2']

    Get all feature extractors from all libraries:

    >>> y = [x.id for x in features.extractorsById('all')]
    >>> y[0:3], y[-3:-1]
    (['M1', 'M2', 'M3'], ['CS12', 'MC1'])

    r   )r­  )r®  )Ú	jsymbolicÚall)r®  r¶  ú-r  rJ   r¶  )r–  r­  r®  r   rS  r—  rO  ÚstriprM   rL   r&  )
ÚidOrListÚlibraryr­  r®  rO  ÚlibÚflatIdsÚ	featureIdrO   r[  s
             r   ÚextractorsByIdr¾  y  sŽ  € ð4 +Ð*Ð*Ð*Ð*Ð*Ø'Ð'Ð'Ð'Ð'Ð'åÔ˜WÑ%Ô%ð Ø�)ˆàÐØð :ð :ˆØ�9Š9‰;Œ;Ð.Ð.Ð.Ø Ô!<Ñ<ÐÐØ�YŠY‰[Œ[Ð-Ð-Ð-Ø Ô!9Ñ9ÐøåÔ˜XÑ&Ô&ð Ø�:ˆà€GØð "ð "ˆ	Ø—O’OÑ%Ô%×+Ò+Ñ-Ô-ˆ	Ø×Ò˜#˜rÑ"Ô"Ð"Ø×Ò˜#˜rÑ"Ô"Ð"Ø�Š�yÑ!Ô!Ð!Ð!à€DØð Øˆàð ð ˆØŒ5�;Š;‰=Œ=˜GÐ#Ð# w¨q¤z×'7Ò'7Ñ'9Ô'9¸UÒ'BÐ'BØ�KŠK˜‰OŒOˆOøØ€Kr   c                ó<   — t          | |¬¦  «        }|r|d         S dS )a  
    Get the first feature matched by extractorsById().

    >>> s = stream.Stream()
    >>> s.append(note.Note('A4'))
    >>> fe = features.extractorById('p20')(s)  # call class
    >>> fe.extract().vector
    [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

    )r¹  rº  r   N)r¾  )r¹  rº  Úebis      r   ÚextractorByIdrÁ  ´  s,   € õ  (°GÐ
<Ñ
<Ô
<€CØ
ð Ø�1ŒvˆØˆ4r   c                ón   —  t          ||¦  «        | ¦  «        }|€dS |                     ¦   «         j        S )zâ
    Utility function to get a vector from an extractor

    >>> s = stream.Stream()
    >>> s.append(note.Note('A4'))
    >>> features.vectorById(s, 'p20')
    [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
    N)rÁ  rY   r!   )r`   ÚvectorIdrº  r[  s       r   Ú
vectorByIdrÄ  Å  s8   € ð 
*��x Ñ	)Ô	)¨)Ñ	4Ô	4€BØ	€zØˆtØ�:Š:‰<Œ<ÔÐr   c                óâ   — ddl m}m} |�|dk    r*d}|j        D ] } |¦   «         j        | k    r|dfc S |dz  }Œ!|�|dk    r,d}|j        D ] } |¦   «         j        | k    r|dfc S |dz  }Œ!dS dS )aÊ  
    Returns the list index of the given feature extractor and the feature extractor
    category (jsymbolic or native). If feature extractor string is not in either
    jsymbolic or native feature extractors, returns None

    optionally include the extractorType ('jsymbolic' or 'native') if known
    and searching will be made more efficient

    >>> features.getIndex('Range')
    (61, 'jsymbolic')
    >>> features.getIndex('Ends With Landini Melodic Contour')
    (18, 'native')
    >>> features.getIndex('aBrandNewFeature!') is None
    True
    >>> features.getIndex('Fifths Pitch Histogram', 'jsymbolic')
    (70, 'jsymbolic')
    >>> features.getIndex('Tonal Certainty', 'native')
    (1, 'native')
    r   r¬  Nrµ  r   r®  )r–  r­  r®  rO  r"   )ÚfeatureStringÚextractorTyper­  r®  Ú
indexCountr@   s         r   ÚgetIndexrÉ  Ô  sÕ   € ð( 3Ð2Ð2Ð2Ð2Ð2Ð2Ð2àÐ °Ò <Ð <Øˆ
Ø Ô2ð 	ð 	ˆGàˆw‰yŒyŒ~ Ò.Ð.Ø" KÐ0Ð0Ð0Ð0Ø˜!‰OˆJˆJØÐ °Ò 9Ð 9Øˆ
ØÔ/ð 	ð 	ˆGØˆw‰yŒyŒ~ Ò.Ð.Ø" HÐ-Ð-Ð-Ð-Ø˜!‰OˆJˆJàˆtð !:Ð 9r   c                  óJ   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ ZdS )ÚTestc                ó:  — ddl m} d | _        t          j        d¦  «        }|                     |¦  «        }|                      t          |d         ¦  «        d¦  «         |                      t          |d         ¦  «        d¦  «         |                      t          |d         ¦  «        d	¦  «         |d
         }|                      t          |¦  «        d¦  «         |d         }|                      |ddddddddddddddœ¦  «         |                      |d         ddddddddddddœ¦  «         |                      |d         ddd	dddddd œ¦  «         |                      t          |d!         ¦  «        d¦  «         |                      t          |d!         d         d         ¦  «        d"¦  «         |                      t          |d!         d#         d         ¦  «        d$¦  «         |                      t          |d!         d         d%         ¦  «        d&¦  «         |                      t          |d!         d#         d%         ¦  «        d&¦  «         |                      |d!         d         d'         g d(¢¦  «         |                      |d'         g d)¢¦  «         d S )*Nr   ©rJ  úcorelli/opus3no1/1graverö   i$  z
flat.noteséî   rÁ   é   z'chordify.flat.getElementsByClass(Chord)é‘   z9chordify.flat.getElementsByClass(Chord).setClassHistogramé   é   é   é   rÑ   é   é   é   é   )z3-11z2-4z1-1z2-3z3-9z2-2z3-7z2-5z3-4z3-6z3-10z3-8z3-2z6chordify.flat.getElementsByClass(Chord).typesHistogramé"   é   )r®   r²   r«   r¬   r±   r´   r¯   rµ   r­   r³   r°   z!flat.notes.quarterLengthHistogramét   é'   é   é   )g      à?r.   g      ø?g       @g      @g      @g      è?g      Ð?rŠ   éG   r   éB   rþ   é   zpitches.pitchClassHistogram)é	   r   é   r   rã  é   r   rä  r   rÑ   r×  r   )é/   rÙ  rÔ  r   rÔ  é*   r   é!   r   é&   é   rØ  )rš   rJ  ÚmaxDiffr   r8  rH   ÚassertEqualrs   )r'   rJ  r2   rm  ÚchordifiedChordsr�   s         r   ÚtestStreamFormsAzTest.testStreamFormsAþ  sí  € Ø$Ð$Ð$Ð$Ð$Ð$ØˆŒåŒLÐ2Ñ3Ô3ˆà×"Ò" 1Ñ%Ô%ˆØ×Ò�˜R œZ™œ¨#Ñ.Ô.Ð.Ø×Ò�˜R Ô-Ñ.Ô.°Ñ4Ô4Ð4ð 	×Ò�˜R 
œ^Ñ,Ô,¨bÑ1Ô1Ð1ØÐGÔHÐØ×Ò�Ð-Ñ.Ô.°Ñ4Ô4Ð4ØÐNÔOˆð 	×Ò˜Ø"$¨R¸À2ÈbÐYZØ!"¨1°Q¸qÈ!Ø!"¨1ð.ð .ñ	/ô 	/ð 	/ð
 	×Ò˜ÐTÔUØ,-À1Ø')¸ÐPQØ34ÐPRØ78È"Ø12Èbð	Rð Rñ	Sô 	Sð 	Sð 	×Ò˜Ð?Ô@Ø"¨°"¸2ÀAÈAØ !¨ð-ð -ñ	.ô 	.ð 	.ð
 	×Ò�˜R œ[Ñ)Ô)¨1Ñ-Ô-Ð-à×Ò�˜R œ[¨œ^¨LÔ9Ñ:Ô:¸BÑ?Ô?Ð?Ø×Ò�˜R œ[¨œ^¨LÔ9Ñ:Ô:¸BÑ?Ô?Ð?ð 	×Ò�˜R œ[¨œ^Ð,IÔJÑKÔKÈRÑPÔPÐPØ×Ò�˜R œ[¨œ^Ð,IÔJÑKÔKÈRÑPÔPÐPà×Ò˜˜Gœ QœÐ(EÔFØAÐAÐAñ	Cô 	Cð 	Cð 	×Ò˜Ð9Ô:ØDÐDÐDñ	Fô 	Fð 	Fð 	Fð 	Fr   c                óö   — ddl m} t          j        ¦   «         }dD ])}|                     t          j        |¦  «        ¦  «         Œ*|                     |¦  «        }|                      |d         g d¢¦  «         d S )Nr   rÍ  )	Úc4rð  úd-4úd#4úf#4úa#4úd#5Úa5rö  zpitches.midiIntervalHistogram)€rÙ  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )	rš   rJ  r   rG   rL   r   ÚNoterH   rì  )r'   rJ  r2   r‘   rm  s        r   ÚtestStreamFormsBzTest.testStreamFormsB0  sŸ   € Ø$Ð$Ð$Ð$Ð$Ð$åŒM‰OŒOˆØLð 	#ð 	#ˆAØ�HŠH•T”Y˜q‘\”\Ñ"Ô"Ð"Ð"Ø×"Ò" 1Ñ%Ô%ˆØ×Ò˜Ð;Ô<ðDð Dð Dñ	Eô 	Eð 	Eð 	Eð 	Er   c                ó0  — ddl m} ddlm} t	          j        ¦   «         }dD ])}|                     t          j        |¦  «        ¦  «         Œ*| 	                    |¦  «        }|  
                     ||d         ¦  «        d ||d         ¦  «        ¦  «         d S )Nr   )ÚpformatrÍ  )rð  rð  rñ  rò  ró  rô  rõ  rö  zflat.secondsMapa4  [{'durationSeconds': 0.5,
  'element': <music21.note.Note C>,
  'endTimeSeconds': 0.5,
  'offsetSeconds': 0.0,
  'voiceIndex': None},
 {'durationSeconds': 0.5,
  'element': <music21.note.Note C>,
  'endTimeSeconds': 1.0,
  'offsetSeconds': 0.5,
  'voiceIndex': None},
 {'durationSeconds': 0.5,
  'element': <music21.note.Note D->,
  'endTimeSeconds': 1.5,
  'offsetSeconds': 1.0,
  'voiceIndex': None},
 {'durationSeconds': 0.5,
  'element': <music21.note.Note D#>,
  'endTimeSeconds': 2.0,
  'offsetSeconds': 1.5,
  'voiceIndex': None},
 {'durationSeconds': 0.5,
  'element': <music21.note.Note F#>,
  'endTimeSeconds': 2.5,
  'offsetSeconds': 2.0,
  'voiceIndex': None},
 {'durationSeconds': 0.5,
  'element': <music21.note.Note A#>,
  'endTimeSeconds': 3.0,
  'offsetSeconds': 2.5,
  'voiceIndex': None},
 {'durationSeconds': 0.5,
  'element': <music21.note.Note D#>,
  'endTimeSeconds': 3.5,
  'offsetSeconds': 3.0,
  'voiceIndex': None},
 {'durationSeconds': 0.5,
  'element': <music21.note.Note A>,
  'endTimeSeconds': 4.0,
  'offsetSeconds': 3.5,
  'voiceIndex': None}]râ   )Úpprintrú  rš   rJ  r   rG   rL   r   r÷  rH   rì  )r'   rú  rJ  r2   r‘   rm  s         r   ÚtestStreamFormsCzTest.testStreamFormsC@  s¿   € Ø"Ð"Ð"Ð"Ð"Ð"Ø$Ð$Ð$Ð$Ð$Ð$åŒM‰OŒOˆØFð 	#ð 	#ˆAØ�HŠH•T”Y˜q‘\”\Ñ"Ô"Ð"Ð"Ø×"Ò" 1Ñ%Ô%ˆà×Ò˜˜ Ð$5Ô!6Ñ7Ô7ð ':ðN #˜7 2 lÔ#3Ñ4Ô4ñO'	6ô '	6ð '	6ð '	6ð '	6r   c                ó  — ddl m} ddlm} |                     g d¢d¦  «        }|                     d¬¦  «        }d|_        |                     |¦  «         |                     d	d
¬¦  «         |                     dd¬¦  «         | 	                    ¦   «          | 
                    |¦  «        }|                     d¬¦  «        }|                      |d¦  «         |                     dd¬¦  «        }|                      |d¦  «         |                     d¬¦  «        }|                     d¬¦  «        }t                               d¬¦  «        }	|                     |	d¬¦  «         |||	fD ]}
t!          j        |
¦  «         Œd S )Nr   rÍ  rŒ  ©Úql1Úql2Úql4r®  ÚComposerr¯  Fúbwv66.6ÚBach©r+  rÎ  ÚCorelliz//)Ú	lineBreakz±Identifier,Unique_Note_Quarter_Lengths,Most_Common_Note_Quarter_Length,Range_of_Note_Quarter_Lengths,Composer//bwv66.6,3,1.0,1.5,Bach//corelli/opus3no1/1grave,8,0.5,3.75,Corelli)r  rZ  z†Unique_Note_Quarter_Lengths,Most_Common_Note_Quarter_Length,Range_of_Note_Quarter_Lengths,Composer//3,1.0,1.5,Bach//8,0.5,3.75,CorellirŽ  ©r§  r’  z.arff)Úsuffixr”  )rŸ  r§  )rš   rJ  r–  r�  r¾  rD  rM  rN  rd  rV   r™  r£  rì  r¦  ry  ÚgetTempFiler5  Úremove)r'   rJ  r�  rO  r±  r   rO   Úfp1Úfp2Úfp3rŸ  s              r   ÚtestDataSetOutputzTest.testDataSetOutputr  s¼  € Ø$Ð$Ð$Ð$Ð$Ð$Ø2Ð2Ð2Ð2Ð2Ð2à$×3Ò3Ð4IÐ4IÐ4IÈ8ÑTÔTÐð ×Ò¨ÐÑ4Ô4ˆØˆŒØ
×ÒÐ 1Ñ2Ô2Ð2ð 	�
Š
�9¨ˆ
Ñ0Ô0Ð0Ø
�
Š
Ð,¸ˆ
ÑCÔCÐCà
�
Š
‰Œˆð ×$Ò$ RÑ(Ô(ˆØ�|Š| dˆ|Ñ+Ô+ˆØ×ÒØð[ñ	\ô 	\ð 	\ð �|Š| d°eˆ|Ñ<Ô<ˆØ×ÒØðYñ	Zô 	Zð 	Zð
 �hŠh˜eˆhÑ$Ô$ˆØ�hŠh˜eˆhÑ$Ô$ˆå×&Ò&¨gÐ&Ñ6Ô6ˆØ
�Š�C ˆÑ'Ô'Ð'à˜˜S�/ð 	ð 	ˆBÝŒI�b‰MŒMˆMˆMð	ð 	r   c                ó  — ddl m} ddl m} g d¢}|                     |d¦  «        }|                     d¬¦  «        }|                     |¦  «         t          j        ¦   «         }|                     | 	                    d ¦  «        ¦  «         | 
                    |d¬	¦  «         | 
                    |d
¬	¦  «         d|_        |                      |j        ¦  «        5  |                     ¦   «          d d d ¦  «         d S # 1 swxY w Y   d S )Nr   rÍ  )Úbase)Úp10Úp11Úp12Úp13r­  r  r¯  Ú
Monteverdir  ÚHandelT)rš   rJ  r  r¾  rD  rN  r   rG   rL   ÚElementWrapperrd  rK  ÚassertRaisesr   rV   )r'   rJ  r  rO  r±  r2   s         r   ÚtestFeatureFailzTest.testFeatureFailœ  sg  € Ø$Ð$Ð$Ð$Ð$Ð$Ø Ð Ð Ð Ð Ð à8Ð8Ð8Ðà$×3Ò3Ð4EØ4?ñAô AÐð ×Ò¨ÐÑ4Ô4ˆØ
×ÒÐ 1Ñ2Ô2Ð2õ ŒM‰OŒOˆà	�Š�×$Ò$ TÑ*Ô*Ñ+Ô+Ð+Ø
�
Š
�1 ˆ
Ñ.Ô.Ð.Ø
�
Š
�1 ˆ
Ñ*Ô*Ð*ð ˆŒà×Ò˜xÔ8Ñ9Ô9ð 	ð 	Ø�JŠJ‰LŒLˆLð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s   ÃC>Ã>DÄDc                ó¾  — ddl m} ddl m} ddlm}m} t          d¬¦  «        }t          |j        ¦  «        t          |j        ¦  «        z   }t          j
        ¦   «         }t          j        ¦   «         }t          j        ¦   «         }	t          j        ¦   «         }
|	                     |
¦  «         |                     |	¦  «         |                     |¦  «         |                     |¦  «         |                     |¦  «         |j        D ]R}|j        D ]H}|                     |¦  «         	 |                     ¦   «          Œ-# |j        |j        j        f$ r Y ŒEw xY wŒSd S )Nr   )ÚanalysisrÍ  r¬  r  r¯  )rš   r  rJ  r–  r­  r®  rD  r‰   rO  r   rG   rˆ   ÚPartr¹   rL   rº   rd  rN  rF  rH  r?   rY   r   r%   ÚDiscreteAnalysisException)r'   r  rJ  r­  r®  r±  r[   Ú
bareStreamÚ	bareScoreÚ
singlePartÚsingleMeasurer>   r[  s                r   ÚtestEmptyStreamCustomErrorsz Test.testEmptyStreamCustomErrorsµ  s‡  € Ø$Ð$Ð$Ð$Ð$Ð$Ø$Ð$Ð$Ð$Ð$Ð$Ø6Ð6Ð6Ð6Ð6Ð6Ð6Ð6å Ð#Ñ#Ô#ˆÝ�Ô,Ñ-Ô-µ°VÔ5MÑ0NÔ0NÑNˆå”]‘_”_ˆ
Ý”L‘N”Nˆ	å”[‘]”]ˆ
ÝœÑ(Ô(ˆØ×Ò˜-Ñ(Ô(Ð(Ø×Ò˜Ñ$Ô$Ð$à
�
Š
�:ÑÔÐØ
�
Š
�9ÑÔÐØ
×Ò Ñ"Ô"Ð"àÔ$ð 	ð 	ˆDØÔ7ð ð �Ø—
’
˜4Ñ Ô Ð ðØ—J’J‘L”L�L�Løà Ô1Ø Ô)ÔCðEð ð ð à�Dðøøøðð	ð 	s   Ä+E Å EÅEc                óv  — ddl m} g d¢}|                     |d¦  «        }t          j        d¦  «                             d¦  «        dd…         }t          j        d	¦  «                             d
¬¦  «        dd…         }|                     d¬¦  «        }|                     |¦  «         |D ]}|                     |d¬¦  «         Œ|D ]}|                     |d¬¦  «         Œ|                     ¦   «          | 	                    d¬¦  «         | 	                    d¬¦  «         | 	                    d¬¦  «         dS )úŠ
        Demonstrating writing out data files for feature extraction. Here,
        features are used from the jSymbolic library.
        r   rÍ  ©Úr31Úr32Úr33Úr34Úr35Úp1Úp2Úp3Úp4Úp5Úp6Úp7Úp8Úp9r  r  r  r  Úp14Úp15Úp16Úp19Úp20Úp21r­  Ú
monteverdiz.xmlNé+   ÚbachrØ  )ÚnumberOfPartsr×  r  r¯  r  r  r  rŽ  r  r’  r”  )
rš   rJ  r¾  r   ÚsearchrD  rN  rd  rV   r¦  )r'   rJ  rO  ÚworksMonteverdiÚ	worksBachr±  Úws          r   Ú%x_testComposerClassificationJSymbolicz*Test.x_testComposerClassificationJSymbolicã  sl  € ð
 	%Ð$Ð$Ð$Ð$Ð$ðNð Nð NÐð
 %×3Ò3Ð4EØ4?ñAô AÐõ !œ-¨Ñ5Ô5×<Ò<¸VÑDÔDÀSÀbÀSÔIˆå”M &Ñ)Ô)×0Ò0¸qÐ0ÑAÔAÀ"À1À"ÔEˆ	ð ×Ò¨ÐÑ4Ô4ˆØ
×ÒÐ 1Ñ2Ô2Ð2ð
 !ð 	3ð 	3ˆAØ�JŠJ�q \ˆJÑ2Ô2Ð2Ð2Øð 	-ð 	-ˆAØ�JŠJ�q VˆJÑ,Ô,Ð,Ð,ð 	�
Š
‰ŒˆØ
�Š˜ˆÑÔÐØ
�Š˜ˆÑÔÐØ
�Š˜ˆÑÔÐÐÐr   c                óì  — ddl m} |                     g d¢d¦  «        }t          j        d¦  «        }t          j        d¦  «        }t          j        d¦  «        }t          j        d¦  «        }|                     d	¬
¦  «        }|                     |¦  «         |df|dffD ]9\  }}	|j        D ],}
d|	› d|
j        j	        › �}| 
                    |
d|¬¦  «         Œ-Œ:|df|dffD ]9\  }}	|j        D ],}
d|	› d|
j        j	        › �}| 
                    |
d|¬¦  «         Œ-Œ:|                     ¦   «          |                     d¬¦  «         |                     d¬¦  «         |                     d¬¦  «         dS )r%  r   rÍ  r&  r­  úessenFolksong/han1úessenFolksong/han2úessenFolksong/boehme10úessenFolksong/boehme20ÚRegionr¯  Úhan1Úhan2úessenFolksong/r·  ÚChina©r+  r&  Úboehme10Úboehme20ÚMitteleuroparŽ  )r¤  r’  r”  N)rš   rJ  r¾  r   r8  rD  rN  Úscoresr  Únumberrd  rV   r£  )r'   rJ  rO  ÚoChina1ÚoChina2ÚoMitteleuropa1ÚoMitteleuropa2r±  Úor"   rB  ÚsongIds               r   Ú$x_testRegionClassificationJSymbolicAz)Test.x_testRegionClassificationJSymbolicA	  sî  € ð
 	%Ð$Ð$Ð$Ð$Ð$à$×3Ò3ð 5Cð 5Cð 5Cð EPñ	Qô QÐõ ”,Ð3Ñ4Ô4ˆÝ”,Ð3Ñ4Ô4ˆåœÐ&>Ñ?Ô?ˆÝœÐ&>Ñ?Ô?ˆà×Ò¨ÐÑ2Ô2ˆØ
×ÒÐ 1Ñ2Ô2Ð2ð ! &Ð)Ø  &Ð)ð+ð 	=ð 	=‰GˆAˆtà”Xð =ð =�ØD¨$ÐDÐD°´Ô1BÐDÐD�Ø—
’
˜1¨°V�
Ñ<Ô<Ð<Ð<ð=ð (¨Ð4Ø'¨Ð4ð6ð 	Dð 	D‰GˆAˆtà”Xð Dð D�ØD¨$ÐDÐD°´Ô1BÐDÐD�Ø—
’
˜1¨¸F�
ÑCÔCÐCÐCðDð
 	�
Š
‰ŒˆØ
�Š˜uˆÑ%Ô%Ð%Ø
�Š˜uˆÑ%Ô%Ð%Ø
�Š˜vˆÑ&Ô&Ð&Ð&Ð&r   c                óÒ  — ddl m} |                     g d¢d¦  «        }|                     d¬¦  «        }|                     |¦  «         t          j        d¦  «        }t          j        d¦  «        }|d	ffD ]9\  }}|j        D ],}d
|› d|j        j	        › �}	| 
                    |d|	¬¦  «         Œ-Œ:|dffD ]9\  }}|j        D ],}d
|› d|j        j	        › �}	| 
                    |d|	¬¦  «         Œ-Œ:|                     ¦   «          |                     d¦  «         |                     d¦  «         |                     d¦  «         |                     d¬¦  «        }|                     |¦  «         t          j        d¦  «        }
t          j        d¦  «        }|
dffD ]9\  }}|j        D ],}d
|› d|j        j	        › �}	| 
                    |d|	¬¦  «         Œ-Œ:|dffD ]9\  }}|j        D ],}d
|› d|j        j	        › �}	| 
                    |d|	¬¦  «         Œ-Œ:|                     ¦   «          |                     d¦  «         |                     d¦  «         |                     d¦  «         dS )zŠ
        Demonstrating writing out data files for feature extraction.
        Here, features are used from the jSymbolic library.
        r   rÍ  r&  r­  rI  r¯  rE  rG  rJ  rL  r·  rM  rN  rO  rQ  z&/_scratch/chinaMitteleuropaSplit-a.tabz&/_scratch/chinaMitteleuropaSplit-a.csvz'/_scratch/chinaMitteleuropaSplit-a.arffrF  rH  rK  rP  z&/_scratch/chinaMitteleuropaSplit-b.tabz&/_scratch/chinaMitteleuropaSplit-b.csvz'/_scratch/chinaMitteleuropaSplit-b.arffN)rš   rJ  r¾  rD  rN  r   r8  rR  r  rS  rd  rV   r¦  )r'   rJ  rO  r±  rT  rV  rX  r"   rB  rY  rU  rW  s               r   Ú$x_testRegionClassificationJSymbolicBz)Test.x_testRegionClassificationJSymbolicB2  s  € ð
 	%Ð$Ð$Ð$Ð$Ð$ð %×3Ò3ðGð Gð GàHSñUô UÐð ×Ò¨ÐÑ2Ô2ˆØ
×ÒÐ 1Ñ2Ô2Ð2å”,Ð3Ñ4Ô4ˆÝœÐ&>Ñ?Ô?ˆð ! &Ð)Ð*ð 	=ð 	=‰GˆAˆtØ”Xð =ð =�ØD¨$ÐDÐD°´Ô1BÐDÐD�Ø—
’
˜1¨°V�
Ñ<Ô<Ð<Ð<ð=ð (¨Ð4Ð5ð 	Dð 	D‰GˆAˆtØ”Xð Dð D�ØD¨$ÐDÐD°´Ô1BÐDÐD�Ø—
’
˜1¨¸F�
ÑCÔCÐCÐCðDð
 	�
Š
‰ŒˆØ
�ŠÐ9Ñ:Ô:Ð:Ø
�ŠÐ9Ñ:Ô:Ð:Ø
�ŠÐ:Ñ;Ô;Ð;ð ×Ò¨ÐÑ2Ô2ˆØ
×ÒÐ 1Ñ2Ô2Ð2å”,Ð3Ñ4Ô4ˆÝœÐ&>Ñ?Ô?ˆà  &Ð)Ð*ð 	=ð 	=‰GˆAˆtØ”Xð =ð =�ØD¨$ÐDÐD°´Ô1BÐDÐD�Ø—
’
˜1¨°V�
Ñ<Ô<Ð<Ð<ð=ð (¨Ð4Ð5ð 	Dð 	D‰GˆAˆtØ”Xð Dð D�ØD¨$ÐDÐD°´Ô1BÐDÐD�Ø—
’
˜1¨¸F�
ÑCÔCÐCÐCðDð
 	�
Š
‰ŒˆØ
�ŠÐ9Ñ:Ô:Ð:Ø
�ŠÐ9Ñ:Ô:Ð:Ø
�ŠÐ:Ñ;Ô;Ð;Ð;Ð;r   c                óB  — ddl m} |                     g d¢d¦  «        }|                     d¬¦  «        }|                     |¦  «         |                     dd¬	¦  «         |                     d
d¬	¦  «         d|_        d|_        |                     ¦   «          |  	                    t          |j        ¦  «        d¦  «         |  	                    t          |j        d         ¦  «        d¦  «         |j        d         d         }|  	                    |j        dg¦  «         d S )Nr   rÍ  rþ  r®  r  r¯  r  r  r  rÎ  r  TrÙ  rß  )rš   rJ  r¾  rD  rN  rd  rM  rL  rV   rì  rs   r!   )r'   rJ  rO  r±  Úfe00s        r   ÚtestParallelRunzTest.testParallelRun
  s  € Ø$Ð$Ð$Ð$Ð$Ð$à$×3Ò3Ð4IÐ4IÐ4IÈ8ÑTÔTÐð ×Ò¨ÐÑ4Ô4ˆØ
×ÒÐ 1Ñ2Ô2Ð2ð 	�
Š
�9¨ˆ
Ñ0Ô0Ð0Ø
�
Š
Ð,¸ˆ
ÑCÔCÐCØˆŒØˆŒØ
�
Š
‰ŒˆØ×Ò�˜Rœ[Ñ)Ô)¨1Ñ-Ô-Ð-Ø×Ò�˜Rœ[¨œ^Ñ,Ô,¨aÑ0Ô0Ð0ØŒ{˜1Œ~˜aÔ ˆØ×Ò˜œ q cÑ*Ô*Ð*Ð*Ð*r   N)r   r   r   rî  rø  rü  r  r  r#  rC  rZ  r\  r_  r   r   r   rË  rË  ü  s·   € € € € € ð0Fð 0Fð 0FðdEð Eð Eð 06ð 06ð 06ðd(ð (ð (ðTð ð ð2ð ð ð\$ ð $ ð $ ðL''ð ''ð ''ðR:<ð :<ð :<ðp+ð +ð +ð +ð +r   rË  c                ó*   — t          | j        ¦  «        S )zG
    A function for documentation testing of a pickleable function
    )rs   rÌ   )Ú
bachStreams    r   Ú_pickleFunctionNumPitchesrb  G  s   € õ ˆzÔ!Ñ"Ô"Ð"r   Ú__main__)r¬  r]   )/Ú
__future__r   Úcollectionsr   Úcollections.abcr   r5  r9  ra  Úunittestrš   r   Úmusic21.common.parallelr   Úmusic21.common.typesr	   r
   r   r   r   r   r   r   Úmusic21.metadata.bundlesr   ÚEnvironmentry  ÚMusic21Exceptionr   r   r:   r_   rH   rB  rD  rv  r³  r¾  rÁ  rÄ  rÉ  ÚTestCaserË  rb  Ú
_DOC_ORDERr   ÚmainTestr   r   r   ú<module>rp     sŽ  ðð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $Ø 	€	€	€	Ø €€€Ø €€€Ø €€€à Ð Ð Ð Ð Ð Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø +Ð +Ð +Ð +Ð +Ð +Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à 2Ð 2Ð 2Ð 2Ð 2Ð 2à&ˆ{Ô& Ñ7Ô7€ð	ð 	ð 	ð 	ð 	�|Ô4ñ 	ô 	ð 	ðSð Sð Sð Sð Sñ Sô Sð SðnRð Rð Rð Rð Rñ Rô Rð Rðl~ð ~ð ~ð ~ð ~ñ ~ô ~ð ~ðDkð kð kð kð kñ kô kð kð^	ð 	ð 	ð 	ð 	�|Ô4ñ 	ô 	ð 	ðvNð vNð vNð vNð vNñ vNô vNð vNðrKð Kð Kð0ð ð ð:8ð 8ð 8ð 8ðvð ð ð ð"ð ð ð ð$ð $ð $ð $ðP`+ð `+ð `+ð `+ð `+ˆ8Ôñ `+ô `+ð `+ðV#ð #ð #ð �wÐ 0Ð1€
ð ˆzÒÐØ€N€N€NØ€GÔ�TÑÔÐÐÐð Ðr   