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 ofDataFrame
objects, 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
DataFrame
like 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
DataFrame
objects 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 ofDataFrame
objects) that have apandas.MultiIndex
as 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
ColumnAggregator
experiment.Returns: A Series
with 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.Experimenter
Calculate 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.Experimenter
Make a new
Note
object with the input set to thelily_markup
property, thelily_invisible
property set toTrue
, and everything else as a defaultNote
.-
possible_settings
= ['column']¶ Use the
'column'
setting to determine which column of theDataFrame
will 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 Series
corresponds to the index of thePart
used to generate it, in the order specified to the constructor. Each element in theSeries
is abasestring
.Return type: list of pandas.Series
-
-
class
vis.analyzers.experimenters.lilypond.
LilyPondExperimenter
(index, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.Experimenter
Use the
outputlilypond
module to produce the LilyPond file that should produce a score of the input.Note
Perhaps contrary to expectation, you must provide a
music21.stream.Score
to 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
LilyPondExperimenter
include:Parameters: - 'run_lilypond' (boolean) – Whether to run LilyPond; if
False
or 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'
isFalse
and you do not provide'output_pathname'
then the output file is returned byrun()
as aunicode
. - 'annotation_part' (
music21.stream.Part
or list ofPart
) – APart
or list ofPart
objects with annotation instructions foroutputlilypond
. ThisPart
will be appended as last in theScore
.
- 'run_lilypond' (boolean) – Whether to run LilyPond; if
-
required_score_type
= 'stream.Score'¶ This attribute allows
IndexedPiece
to automatically import and provide theScore
forLilyPondExperimenter
. 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.Experimenter
From a
Series
full ofNote
objects, craft amusic21.stream.Part
. The offset of eachNote
in the output matches its index in the inputSeries
, and eachduration
property 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_names
setting.-
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 Part
corresponds to the index of theSeries
used to generate it, in the order specified to the constructor. Each element in thePart
is aNote
.Return type: list of music21.stream.Part
-
-
vis.analyzers.experimenters.lilypond.
annotate_the_note
(obj)[source]¶ Used by
AnnotateTheNoteExperimenter
to make aNote
object with the annotation passed in. Take note (hahaha): thelily_invisible
property is set toTrue
!Parameters: obj (basestring) – A string to put as the lily_markup
property 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.Experimenter
Template for an
Experimenter
subclass.-
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.Series
orpandas.DataFrame
-