experimenters Package¶
experimenters Package¶
aggregator Module¶
Aggregating experimenters.
-
class
vis.analyzers.experimenters.aggregator.ColumnAggregator(index, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.Experimenter(Arguments for the constructor are listed below).
Experiment that aggregates data from columns of a
DataFrame, or a list ofDataFrameobjects, by summing each row. Values from columns named'all'will not be included in the aggregated results. You may provide a'column'setting to guide the experimenter to include only certain results.Example 1
Inputting single
DataFramelike this:Index piece_1 piece_2 M3 12 24 m3 NaN 36 P5 3 9 Yields this
DataFrame:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 Example 2
Inputting two
DataFrameobjects is similar.Index piece_1 M3 12 P5 3 Index piece_2 M3 24 m3 36 P5 9 The result is the same
DataFrame:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 Example 3
You may also give a
DataFrame(or a list ofDataFrameobjects) that have apandas.MultiIndexas produced by subclasses ofIndexer. In this case, use the'column'setting to indicate which indexer’s results you wish to aggregate.Index ‘frequency.FrequencyExperimenter’ ‘feelings.FeelingsExperimenter’ ‘0,1’ ‘1,2’ ‘Christopher’ ‘Alex’ M3 12 24 ‘delight’ ‘exuberance’ m3 NaN 36 ‘sheer joy’ ‘nonchalance’ P5 3 9 ‘emptiness’ ‘serenity’ If
'column'is'frequency.FrequencyExperimenter', yet again you will have thisDataFrame:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 -
default_settings= {'column': None}¶
-
possible_settings= ['column']¶ Parameters: 'column' (str) – The column name to use for aggregation. The default is None, which aggregates across all columns. If you set this to'all', it will override the default behaviour of not including columns called'all'.
-
run()[source]¶ Run the
ColumnAggregatorexperiment.Returns: A Serieswith an index that is the combination of all indices of the provided pandas objects, and the value is the sum of all values in the pandas objects.Return type: pandas.Series
-
frequency Module¶
Experimenters that deal with the frequencies (number of occurrences) of events.
-
class
vis.analyzers.experimenters.frequency.FrequencyExperimenter(index, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.ExperimenterCalculate the number of occurrences of objects in an index.
Use the
'column'setting to choose only the results of one previous analyzer. For example, if you wanted to calculate the frequency of vertical intervals, you would specify'interval.IntervalIndexer'. This would avoid counting, for example, the horizontal intervals if they were also present.-
default_settings= {'column': None}¶
-
possible_settings= ['column']¶ Parameters: 'column' (str) – The column name to use for counting frequency. The default is None, which counts all columns. Use this to count only the frequency of one previous analyzer.
-
run()[source]¶ Run the
FrequencyExperimenter.Returns: The result of the experiment. Data is stored such that column labels correspond to the part (combinations) totalled in the column, and row labels correspond to a type of the kind of objects found in the given index. Note that all columns are totalled in the “all” column, and that not every part combination will have every interval; in case an interval does not appear in a part combination, the value is numpy.NaN.Return type: list of pandas.DataFrame
-
lilypond Module¶
Experimenters related to producing LilyPond-format output from the VIS Framework. Also refer to the
vis.analyzers.indexers.lilypond module.
The LilyPondExperimenter uses the outputlilypond module to produce a LilyPond file
corresponding to the score.
-
class
vis.analyzers.experimenters.lilypond.AnnotateTheNoteExperimenter(index, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.ExperimenterMake a new
Noteobject with the input set to thelily_markupproperty, thelily_invisibleproperty set toTrue, and everything else as a defaultNote.-
possible_settings= ['column']¶ Use the
'column'setting to determine which column of theDataFramewill be used as the annotations for the notes in the outputted list ofSeries.
-
run()[source]¶ Make a new index of the piece.
Returns: A list of the new indices. The index of each Seriescorresponds to the index of thePartused to generate it, in the order specified to the constructor. Each element in theSeriesis abasestring.Return type: list of pandas.Series
-
-
class
vis.analyzers.experimenters.lilypond.LilyPondExperimenter(index, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.ExperimenterUse the
outputlilypondmodule to produce the LilyPond file that should produce a score of the input.Note
Perhaps contrary to expectation, you must provide a
music21.stream.Scoreto theLilyPondExperimenter, and any part with annotations belong in the settings.-
default_settings= {'annotation_part': None, 'run_lilypond': False, 'output_pathname': None}¶
-
possible_settings= ['run_lilypond', 'output_pathname', 'annotation part']¶ Possible settings for the
LilyPondExperimenterinclude:Parameters: - 'run_lilypond' (boolean) – Whether to run LilyPond; if
Falseor omitted, simply produce the input file LilyPond requires. - 'output_pathname' (basestring) – Pathname for the resulting LilyPond output file. If
'run_lilypond'isTrue, you must include this setting. If'run_lilypond'isFalseand you do not provide'output_pathname'then the output file is returned byrun()as aunicode. - 'annotation_part' (
music21.stream.Partor list ofPart) – APartor list ofPartobjects with annotation instructions foroutputlilypond. ThisPartwill be appended as last in theScore.
- 'run_lilypond' (boolean) – Whether to run LilyPond; if
-
required_score_type= 'stream.Score'¶ This attribute allows
IndexedPieceto automatically import and provide theScoreforLilyPondExperimenter. Otherwise you would have to do this manually.
-
run()[source]¶ Make a string with the LilyPond representation of each score. Run LilyPond, if we’re supposed to.
Returns: A string holding the LilyPond-format representation of the score and its annotation parts. Return type: basestring
-
-
class
vis.analyzers.experimenters.lilypond.PartNotesExperimenter(score, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.ExperimenterFrom a
Seriesfull ofNoteobjects, craft amusic21.stream.Part. The offset of eachNotein the output matches its index in the inputSeries, and eachdurationproperty is set to match.To print a “name” along with the first item in a part, for example to indicate to which part or part combinations the annotations belong, use the optional
part_namessetting.-
default_settings= {}¶
-
possible_settings= ['part_names']¶ Parameters: part_names (list of basestring) – Names for the annotation parts, in order. If there are more part names than parts, extra names will be ignored. If there are fewer part names than parts, some parts will not be named.
-
required_score_type¶ alias of
Series
-
run()[source]¶ Make a new index of the piece.
Returns: A list of the new indices. The index of each Partcorresponds to the index of theSeriesused to generate it, in the order specified to the constructor. Each element in thePartis aNote.Return type: list of music21.stream.Part
-
-
vis.analyzers.experimenters.lilypond.annotate_the_note(obj)[source]¶ Used by
AnnotateTheNoteExperimenterto make aNoteobject with the annotation passed in. Take note (hahaha): thelily_invisibleproperty is set toTrue!Parameters: obj (basestring) – A string to put as the lily_markupproperty of a newNote.Returns: An annotated note. Return type: music21.note.Note
template Module¶
Template for writing a new experimenter. Use this class to help write a new :class`Experimenter` subclass. The TemplateExperimenter does nothing, and should only be used by programmers.
-
class
vis.analyzers.experimenters.template.TemplateExperimenter(index, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.ExperimenterTemplate for an
Experimentersubclass.-
default_settings= {}¶ The default values for settings named in
possible_settings. If a setting doesn’t have a value in this constant, then it must be specified to the constructor at runtime, or the constructor should raise aRuntimeException.
-
possible_settings= ['fake_setting']¶ This is a list of basestrings that are the names of the settings used in this experimenter. Specify the types and reasons for each setting as though it were an argument list, like this:
Parameters: 'fake_setting' (boolean) – This is a fake setting.
-
run()[source]¶ Run an experiment on a piece.
Returns: The result of the experiment. Each experiment should describe its data storage. Return type: pandas.Seriesorpandas.DataFrame
-