Skip to content

Commit

Permalink
velinized docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcfee committed Mar 20, 2024
1 parent 6a54024 commit b400143
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 157 deletions.
2 changes: 1 addition & 1 deletion mir_eval/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def evaluate(reference_timestamps, estimated_timestamps, **kwargs):
reference timestamp locations, in seconds
estimated_timestamps : np.ndarray
estimated timestamp locations, in seconds
kwargs
**kwargs
Additional keyword arguments which will be passed to the
appropriate metric or preprocessing functions.
Expand Down
2 changes: 1 addition & 1 deletion mir_eval/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def evaluate(reference_beats, estimated_beats, **kwargs):
Reference beat times, in seconds
estimated_beats : np.ndarray
Query beat times, in seconds
kwargs
**kwargs
Additional keyword arguments which will be passed to the
appropriate metric or preprocessing functions.
Expand Down
10 changes: 3 additions & 7 deletions mir_eval/chord.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def scale_degree_to_semitone(scale_degree):
Parameters
----------
scale degree : str
scale_degree : str
Spelling of a relative scale degree, e.g. 'b3', '7', '#5'
Returns
Expand Down Expand Up @@ -345,7 +345,7 @@ def validate_chord_label(chord_label):
Parameters
----------
chord : str
chord_label : str
Chord label to validate.
"""
Expand Down Expand Up @@ -1551,20 +1551,16 @@ def evaluate(ref_intervals, ref_labels, est_intervals, est_labels, **kwargs):
ref_intervals : np.ndarray, shape=(n, 2)
Reference chord intervals, in the format returned by
:func:`mir_eval.io.load_labeled_intervals`.
ref_labels : list, shape=(n,)
reference chord labels, in the format returned by
:func:`mir_eval.io.load_labeled_intervals`.
est_intervals : np.ndarray, shape=(m, 2)
estimated chord intervals, in the format returned by
:func:`mir_eval.io.load_labeled_intervals`.
est_labels : list, shape=(m,)
estimated chord labels, in the format returned by
:func:`mir_eval.io.load_labeled_intervals`.
kwargs
**kwargs
Additional keyword arguments which will be passed to the
appropriate metric or preprocessing functions.
Expand Down
38 changes: 8 additions & 30 deletions mir_eval/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def __get_axes(ax=None, fig=None):
ax : matplotlib.pyplot.axes
An axis handle on which to draw the segmentation.
If none is provided, a new set of axes is created.
new_axes : bool
If `True`, the axis object was newly constructed.
If `False`, the axis object already existed.
Expand Down Expand Up @@ -98,33 +97,26 @@ def segments(
segment intervals, in the format returned by
:func:`mir_eval.io.load_intervals` or
:func:`mir_eval.io.load_labeled_intervals`.
labels : list, shape=(n,)
reference segment labels, in the format returned by
:func:`mir_eval.io.load_labeled_intervals`.
base : number
The vertical position of the base of the rectangles.
By default, this will be the bottom of the plot.
height : number
The height of the rectangles.
By default, this will be the top of the plot (minus ``base``).
text : bool
If true, each segment's label is displayed in its
upper-left corner
text_kw : dict
If ``text == True``, the properties of the text
object can be specified here.
See ``matplotlib.pyplot.Text`` for valid parameters
ax : matplotlib.pyplot.axes
An axis handle on which to draw the segmentation.
If none is provided, a new set of axes is created.
kwargs
**kwargs
Additional keyword arguments to pass to
``matplotlib.patches.Rectangle``.
Expand Down Expand Up @@ -255,7 +247,7 @@ def labeled_intervals(
tick : bool
If ``True``, sets tick positions and labels on the y-axis.
kwargs
**kwargs
Additional keyword arguments to pass to
`matplotlib.collection.BrokenBarHCollection`.
Expand Down Expand Up @@ -369,17 +361,14 @@ def hierarchy(intervals_hier, labels_hier, levels=None, ax=None, **kwargs):
:func:`mir_eval.io.load_intervals` or
:func:`mir_eval.io.load_labeled_intervals`.
Segmentations should be ordered by increasing specificity.
labels_hier : list of list-like
A list of segmentation labels. Each element should
be a list of labels for the corresponding element in
`intervals_hier`.
levels : list of string
Each element ``levels[i]`` is a label for the ```i`` th segmentation.
This is used in the legend to denote the levels in a segment hierarchy.
kwargs
**kwargs
Additional keyword arguments to `labeled_intervals`.
Returns
Expand Down Expand Up @@ -416,29 +405,23 @@ def events(times, labels=None, base=None, height=None, ax=None, text_kw=None, **
event times, in the format returned by
:func:`mir_eval.io.load_events` or
:func:`mir_eval.io.load_labeled_events`.
labels : list, shape=(n,), optional
event labels, in the format returned by
:func:`mir_eval.io.load_labeled_events`.
base : number
The vertical position of the base of the line.
By default, this will be the bottom of the plot.
height : number
The height of the lines.
By default, this will be the top of the plot (minus `base`).
ax : matplotlib.pyplot.axes
An axis handle on which to draw the segmentation.
If none is provided, a new set of axes is created.
text_kw : dict
If `labels` is provided, the properties of the text
objects can be specified here.
See `matplotlib.pyplot.Text` for valid parameters
kwargs
**kwargs
Additional keyword arguments to pass to
`matplotlib.pyplot.vlines`.
Expand Down Expand Up @@ -535,7 +518,7 @@ def pitch(times, frequencies, midi=False, unvoiced=False, ax=None, **kwargs):
An axis handle on which to draw the pitch contours.
If none is provided, a new set of axes is created.
kwargs
**kwargs
Additional keyword arguments to `matplotlib.pyplot.plot`.
Returns
Expand Down Expand Up @@ -622,7 +605,7 @@ def multipitch(times, frequencies, midi=False, unvoiced=False, ax=None, **kwargs
An axis handle on which to draw the pitch contours.
If none is provided, a new set of axes is created.
kwargs
**kwargs
Additional keyword arguments to `plt.scatter`.
Returns
Expand Down Expand Up @@ -703,7 +686,7 @@ def piano_roll(intervals, pitches=None, midi=None, ax=None, **kwargs):
An axis handle on which to draw the intervals.
If none is provided, a new set of axes is created.
kwargs
**kwargs
Additional keyword arguments to :func:`labeled_intervals`.
Returns
Expand Down Expand Up @@ -742,21 +725,16 @@ def separation(sources, fs=22050, labels=None, alpha=0.75, ax=None, **kwargs):
----------
sources : np.ndarray, shape=(nsrc, nsampl)
A list of waveform buffers corresponding to each source
fs : number > 0
The sampling rate
labels : list of strings
An optional list of descriptors corresponding to each source
alpha : float in [0, 1]
Maximum alpha (opacity) of spectrogram values.
ax : matplotlib.pyplot.axes
An axis handle on which to draw the spectrograms.
If none is provided, a new set of axes is created.
kwargs
**kwargs
Additional keyword arguments to ``scipy.signal.spectrogram``
Returns
Expand Down
28 changes: 3 additions & 25 deletions mir_eval/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def _round(t, frame_size):
----------
t : number or ndarray
The time-stamp to round
frame_size : number > 0
The resolution to round to
Expand Down Expand Up @@ -110,10 +109,8 @@ def _align_intervals(int_hier, lab_hier, t_min=0.0, t_max=None):
Hierarchical segment annotations, encoded as a
list of list of intervals (int_hier) and list of
list of strings (lab_hier)
t_min : None or number >= 0
The minimum time value for the segmentation
t_max : None or number >= t_min
The maximum time value for the segmentation
Expand Down Expand Up @@ -149,7 +146,6 @@ def _lca(intervals_hier, frame_size):
intervals_hier : list of ndarray
An ordered list of segment interval arrays.
The list is assumed to be ordered by increasing specificity (depth).
frame_size : number
The length of the sample frames (in seconds)
Expand Down Expand Up @@ -194,11 +190,9 @@ def _meet(intervals_hier, labels_hier, frame_size):
intervals_hier : list of ndarray
An ordered list of segment interval arrays.
The list is assumed to be ordered by increasing specificity (depth).
labels_hier : list of list of str
``labels_hier[i]`` contains the segment labels for the
``i``th layer of the annotations
frame_size : number
The length of the sample frames (in seconds)
Expand Down Expand Up @@ -251,6 +245,7 @@ def _gauc(ref_lca, est_lca, transitive, window):
Parameters
----------
ref_lca : scipy.sparse
est_lca : scipy.sparse
The least common ancestor matrices for the reference and
estimated annotations
Expand Down Expand Up @@ -380,7 +375,6 @@ def _compare_frame_rankings(ref, est, transitive=False):
est : np.ndarray, shape=(n,)
Reference and estimate ranked lists.
`ref[i]` is the relevance score for point `i`.
transitive : bool
If true, all pairs of reference levels are compared.
If false, only adjacent pairs of reference levels are compared.
Expand All @@ -390,7 +384,6 @@ def _compare_frame_rankings(ref, est, transitive=False):
inversions : int
The number of pairs of indices `i, j` where
`ref[i] < ref[j]` but `est[i] >= est[j]`.
normalizer : float
The total number of pairs (i, j) under consideration.
If transitive=True, then this is |{(i,j) : ref[i] < ref[j]}|
Expand Down Expand Up @@ -493,32 +486,25 @@ def tmeasure(
(in seconds) for the ``i`` th layer of the annotations. Layers are
ordered from top to bottom, so that the last list of intervals should
be the most specific.
estimated_intervals_hier : list of ndarray
Like ``reference_intervals_hier`` but for the estimated annotation
transitive : bool
whether to compute the t-measures using transitivity or not.
window : float > 0
size of the window (in seconds). For each query frame q,
result frames are only counted within q +- window.
frame_size : float > 0
length (in seconds) of frames. The frame size cannot be longer than
the window.
beta : float > 0
beta parameter for the F-measure.
Returns
-------
t_precision : number [0, 1]
T-measure Precision
t_recall : number [0, 1]
T-measure Recall
t_measure : number [0, 1]
F-beta measure for ``(t_precision, t_recall)``
Expand Down Expand Up @@ -583,31 +569,25 @@ def lmeasure(
(in seconds) for the ``i`` th layer of the annotations. Layers are
ordered from top to bottom, so that the last list of intervals should
be the most specific.
reference_labels_hier : list of list of str
``reference_labels_hier[i]`` contains the segment labels for the
``i``th layer of the annotations
estimated_intervals_hier : list of ndarray
estimated_labels_hier : list of ndarray
Like ``reference_intervals_hier`` and ``reference_labels_hier``
but for the estimated annotation
frame_size : float > 0
length (in seconds) of frames. The frame size cannot be longer than
the window.
beta : float > 0
beta parameter for the F-measure.
Returns
-------
l_precision : number [0, 1]
L-measure Precision
l_recall : number [0, 1]
L-measure Recall
l_measure : number [0, 1]
F-beta measure for ``(l_precision, l_recall)``
Expand Down Expand Up @@ -694,7 +674,6 @@ def evaluate(
'T-Recall full': 0.6523334654992341,
'T-Recall reduced': 0.60799919710921635}
Parameters
----------
ref_intervals_hier : list of list-like
Expand All @@ -705,13 +684,12 @@ def evaluate(
of segmentations. Each segmentation itself is a list (or list-like)
of intervals (\*_intervals_hier) and a list of lists of labels
(\*_labels_hier).
kwargs
**kwargs
additional keyword arguments to the evaluation metrics.
Returns
-------
scores : OrderedDict
scores : OrderedDict
Dictionary of scores, where the key is the metric name (str) and
the value is the (float) score achieved.
Expand Down
Loading

0 comments on commit b400143

Please sign in to comment.