_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q236500
Client._webdav_move_copy
train
def _webdav_move_copy(self, remote_path_source, remote_path_target, operation): """Copies or moves a remote file or directory :param remote_path_source: source file or folder to copy / move :param remote_path_target: target file to which to copy / move :param ...
python
{ "resource": "" }
q236501
Client._xml_to_dict
train
def _xml_to_dict(self, element): """ Take an XML element, iterate over it and build a dict :param element: An xml.etree.ElementTree.Element, or a list of the same :returns: A dictionary """ return_dict = {} for el in element: return_dict[el.tag] = Non...
python
{ "resource": "" }
q236502
Client._get_shareinfo
train
def _get_shareinfo(self, data_el): """Simple helper which returns instance of ShareInfo class :param data_el: 'data' element extracted from _make_ocs_request :returns: instance of ShareInfo class """ if (data_el is None) or not (isinstance(data_el, ET.Element)): retu...
python
{ "resource": "" }
q236503
Signal.emit
train
def emit(self, *args, **kwargs): """ Calls all the connected slots with the provided args and kwargs unless block is activated """ if self._block: return for slot in self._slots: if not slot: continue elif isinstance(slot, par...
python
{ "resource": "" }
q236504
Signal.connect
train
def connect(self, slot): """ Connects the signal to any callable object """ if not callable(slot): raise ValueError("Connection to non-callable '%s' object failed" % slot.__class__.__name__) if (isinstance(slot, partial) or '<' in slot.__name__): # If it'...
python
{ "resource": "" }
q236505
Signal.disconnect
train
def disconnect(self, slot): """ Disconnects the slot from the signal """ if not callable(slot): return if inspect.ismethod(slot): # If it's a method, then find it by its instance slotSelf = slot.__self__ for s in self._slots: ...
python
{ "resource": "" }
q236506
SignalFactory.block
train
def block(self, signals=None, isBlocked=True): """ Sets the block on any provided signals, or to all signals :param signals: defaults to all signals. Accepts either a single string or a list of strings :param isBlocked: the state to set the signal to """ if signals: ...
python
{ "resource": "" }
q236507
_open
train
def _open(file_or_str, **kwargs): '''Either open a file handle, or use an existing file-like object. This will behave as the `open` function if `file_or_str` is a string. If `file_or_str` has the `read` attribute, it will return `file_or_str`. Otherwise, an `IOError` is raised. ''' if hasattr...
python
{ "resource": "" }
q236508
load_delimited
train
def load_delimited(filename, converters, delimiter=r'\s+'): r"""Utility function for loading in data from an annotation file where columns are delimited. The number of columns is inferred from the length of the provided converters list. Examples -------- >>> # Load in a one-column list of even...
python
{ "resource": "" }
q236509
load_events
train
def load_events(filename, delimiter=r'\s+'): r"""Import time-stamp events from an annotation file. The file should consist of a single column of numeric values corresponding to the event times. This is primarily useful for processing events which lack duration, such as beats or onsets. Parameters ...
python
{ "resource": "" }
q236510
load_labeled_events
train
def load_labeled_events(filename, delimiter=r'\s+'): r"""Import labeled time-stamp events from an annotation file. The file should consist of two columns; the first having numeric values corresponding to the event times and the second having string labels for each event. This is primarily useful for p...
python
{ "resource": "" }
q236511
load_time_series
train
def load_time_series(filename, delimiter=r'\s+'): r"""Import a time series from an annotation file. The file should consist of two columns of numeric values corresponding to the time and value of each sample of the time series. Parameters ---------- filename : str Path to the annotatio...
python
{ "resource": "" }
q236512
load_wav
train
def load_wav(path, mono=True): """Loads a .wav file as a numpy array using ``scipy.io.wavfile``. Parameters ---------- path : str Path to a .wav file mono : bool If the provided .wav has more than one channel, it will be converted to mono if ``mono=True``. (Default value = T...
python
{ "resource": "" }
q236513
load_ragged_time_series
train
def load_ragged_time_series(filename, dtype=float, delimiter=r'\s+', header=False): r"""Utility function for loading in data from a delimited time series annotation file with a variable number of columns. Assumes that column 0 contains time stamps and columns 1 through n contain ...
python
{ "resource": "" }
q236514
pitch_class_to_semitone
train
def pitch_class_to_semitone(pitch_class): r'''Convert a pitch class to semitone. Parameters ---------- pitch_class : str Spelling of a given pitch class, e.g. 'C#', 'Gbb' Returns ------- semitone : int Semitone value of the pitch class. ''' semitone = 0 for idx...
python
{ "resource": "" }
q236515
scale_degree_to_semitone
train
def scale_degree_to_semitone(scale_degree): r"""Convert a scale degree to semitone. Parameters ---------- scale degree : str Spelling of a relative scale degree, e.g. 'b3', '7', '#5' Returns ------- semitone : int Relative semitone of the scale degree, wrapped to a single o...
python
{ "resource": "" }
q236516
scale_degree_to_bitmap
train
def scale_degree_to_bitmap(scale_degree, modulo=False, length=BITMAP_LENGTH): """Create a bitmap representation of a scale degree. Note that values in the bitmap may be negative, indicating that the semitone is to be removed. Parameters ---------- scale_degree : str Spelling of a relat...
python
{ "resource": "" }
q236517
quality_to_bitmap
train
def quality_to_bitmap(quality): """Return the bitmap for a given quality. Parameters ---------- quality : str Chord quality name. Returns ------- bitmap : np.ndarray Bitmap representation of this quality (12-dim). """ if quality not in QUALITIES: raise Inva...
python
{ "resource": "" }
q236518
validate_chord_label
train
def validate_chord_label(chord_label): """Test for well-formedness of a chord label. Parameters ---------- chord : str Chord label to validate. """ # This monster regexp is pulled from the JAMS chord namespace, # which is in turn derived from the context-free grammar of # Hart...
python
{ "resource": "" }
q236519
join
train
def join(chord_root, quality='', extensions=None, bass=''): r"""Join the parts of a chord into a complete chord label. Parameters ---------- chord_root : str Root pitch class of the chord, e.g. 'C', 'Eb' quality : str Quality of the chord, e.g. 'maj', 'hdim7' (Default value ...
python
{ "resource": "" }
q236520
encode
train
def encode(chord_label, reduce_extended_chords=False, strict_bass_intervals=False): """Translate a chord label to numerical representations for evaluation. Parameters ---------- chord_label : str Chord label to encode. reduce_extended_chords : bool Whether to map the uppe...
python
{ "resource": "" }
q236521
encode_many
train
def encode_many(chord_labels, reduce_extended_chords=False): """Translate a set of chord labels to numerical representations for sane evaluation. Parameters ---------- chord_labels : list Set of chord labels to encode. reduce_extended_chords : bool Whether to map the upper voici...
python
{ "resource": "" }
q236522
rotate_bitmap_to_root
train
def rotate_bitmap_to_root(bitmap, chord_root): """Circularly shift a relative bitmap to its asbolute pitch classes. For clarity, the best explanation is an example. Given 'G:Maj', the root and quality map are as follows:: root=5 quality=[1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0] # Relative chor...
python
{ "resource": "" }
q236523
rotate_bitmaps_to_roots
train
def rotate_bitmaps_to_roots(bitmaps, roots): """Circularly shift a relative bitmaps to asbolute pitch classes. See :func:`rotate_bitmap_to_root` for more information. Parameters ---------- bitmap : np.ndarray, shape=(N, 12) Bitmap of active notes, relative to the given root. root : np....
python
{ "resource": "" }
q236524
validate
train
def validate(reference_labels, estimated_labels): """Checks that the input annotations to a comparison function look like valid chord labels. Parameters ---------- reference_labels : list, len=n Reference chord labels to score against. estimated_labels : list, len=n Estimated ch...
python
{ "resource": "" }
q236525
weighted_accuracy
train
def weighted_accuracy(comparisons, weights): """Compute the weighted accuracy of a list of chord comparisons. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est...
python
{ "resource": "" }
q236526
thirds
train
def thirds(reference_labels, estimated_labels): """Compare chords along root & third relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') ...
python
{ "resource": "" }
q236527
thirds_inv
train
def thirds_inv(reference_labels, estimated_labels): """Score chords along root, third, & bass relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est....
python
{ "resource": "" }
q236528
root
train
def root(reference_labels, estimated_labels): """Compare chords according to roots. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_interva...
python
{ "resource": "" }
q236529
mirex
train
def mirex(reference_labels, estimated_labels): """Compare chords along MIREX rules. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_interva...
python
{ "resource": "" }
q236530
seg
train
def seg(reference_intervals, estimated_intervals): """Compute the MIREX 'MeanSeg' score. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> score ...
python
{ "resource": "" }
q236531
merge_chord_intervals
train
def merge_chord_intervals(intervals, labels): """ Merge consecutive chord intervals if they represent the same chord. Parameters ---------- intervals : np.ndarray, shape=(n, 2), dtype=float Chord intervals to be merged, in the format returned by :func:`mir_eval.io.load_labeled_inter...
python
{ "resource": "" }
q236532
evaluate
train
def evaluate(ref_intervals, ref_labels, est_intervals, est_labels, **kwargs): """Computes weighted accuracy for all comparison functions for the given reference and estimated annotations. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') ...
python
{ "resource": "" }
q236533
_n_onset_midi
train
def _n_onset_midi(patterns): """Computes the number of onset_midi objects in a pattern Parameters ---------- patterns : A list of patterns using the format returned by :func:`mir_eval.io.load_patterns()` Returns ------- n_onsets : int Number of onsets within the pat...
python
{ "resource": "" }
q236534
validate
train
def validate(reference_patterns, estimated_patterns): """Checks that the input annotations to a metric look like valid pattern lists, and throws helpful errors if not. Parameters ---------- reference_patterns : list The reference patterns using the format returned by :func:`mir_eval...
python
{ "resource": "" }
q236535
_occurrence_intersection
train
def _occurrence_intersection(occ_P, occ_Q): """Computes the intersection between two occurrences. Parameters ---------- occ_P : list of tuples (onset, midi) pairs representing the reference occurrence. occ_Q : list second list of (onset, midi) tuples Returns ------- S :...
python
{ "resource": "" }
q236536
_compute_score_matrix
train
def _compute_score_matrix(P, Q, similarity_metric="cardinality_score"): """Computes the score matrix between the patterns P and Q. Parameters ---------- P : list Pattern containing a list of occurrences. Q : list Pattern containing a list of occurrences. similarity_metric : str ...
python
{ "resource": "" }
q236537
standard_FPR
train
def standard_FPR(reference_patterns, estimated_patterns, tol=1e-5): """Standard F1 Score, Precision and Recall. This metric checks if the prototype patterns of the reference match possible translated patterns in the prototype patterns of the estimations. Since the sizes of these prototypes must be equa...
python
{ "resource": "" }
q236538
three_layer_FPR
train
def three_layer_FPR(reference_patterns, estimated_patterns): """Three Layer F1 Score, Precision and Recall. As described by Meridith. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt") >>> F, P, R = m...
python
{ "resource": "" }
q236539
first_n_three_layer_P
train
def first_n_three_layer_P(reference_patterns, estimated_patterns, n=5): """First n three-layer precision. This metric is basically the same as the three-layer FPR but it is only applied to the first n estimated patterns, and it only returns the precision. In MIREX and typically, n = 5. Examples ...
python
{ "resource": "" }
q236540
first_n_target_proportion_R
train
def first_n_target_proportion_R(reference_patterns, estimated_patterns, n=5): """First n target proportion establishment recall metric. This metric is similar is similar to the establishment FPR score, but it only takes into account the first n estimated patterns and it only outputs the Recall value of...
python
{ "resource": "" }
q236541
evaluate
train
def evaluate(ref_patterns, est_patterns, **kwargs): """Load data and perform the evaluation. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt") >>> scores = mir_eval.pattern.evaluate(ref_patterns, est...
python
{ "resource": "" }
q236542
validate
train
def validate(ref_intervals, ref_pitches, ref_velocities, est_intervals, est_pitches, est_velocities): """Checks that the input annotations have valid time intervals, pitches, and velocities, and throws helpful errors if not. Parameters ---------- ref_intervals : np.ndarray, shape=(n,2)...
python
{ "resource": "" }
q236543
match_notes
train
def match_notes( ref_intervals, ref_pitches, ref_velocities, est_intervals, est_pitches, est_velocities, onset_tolerance=0.05, pitch_tolerance=50.0, offset_ratio=0.2, offset_min_tolerance=0.05, strict=False, velocity_tolerance=0.1): """Match notes, taking note velocity into considera...
python
{ "resource": "" }
q236544
validate
train
def validate(reference_beats, estimated_beats): """Checks that the input annotations to a metric look like valid beat time arrays, and throws helpful errors if not. Parameters ---------- reference_beats : np.ndarray reference beat times, in seconds estimated_beats : np.ndarray e...
python
{ "resource": "" }
q236545
_get_reference_beat_variations
train
def _get_reference_beat_variations(reference_beats): """Return metric variations of the reference beats Parameters ---------- reference_beats : np.ndarray beat locations in seconds Returns ------- reference_beats : np.ndarray Original beat locations off_beat : np.ndarra...
python
{ "resource": "" }
q236546
f_measure
train
def f_measure(reference_beats, estimated_beats, f_measure_threshold=0.07): """Compute the F-measure of correct vs incorrectly predicted beats. "Correctness" is determined over a small window. Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt'...
python
{ "resource": "" }
q236547
cemgil
train
def cemgil(reference_beats, estimated_beats, cemgil_sigma=0.04): """Cemgil's score, computes a gaussian error of each estimated beat. Compares against the original beat times and all metrical variations. Examples -------- >>> reference_beats = mir_eval.io.load_events('referenc...
python
{ "resource": "" }
q236548
goto
train
def goto(reference_beats, estimated_beats, goto_threshold=0.35, goto_mu=0.2, goto_sigma=0.2): """Calculate Goto's score, a binary 1 or 0 depending on some specific heuristic criteria Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt')...
python
{ "resource": "" }
q236549
p_score
train
def p_score(reference_beats, estimated_beats, p_score_threshold=0.2): """Get McKinney's P-score. Based on the autocorrelation of the reference and estimated beats Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> reference_beats = mir_e...
python
{ "resource": "" }
q236550
information_gain
train
def information_gain(reference_beats, estimated_beats, bins=41): """Get the information gain - K-L divergence of the beat error histogram to a uniform histogram Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> referen...
python
{ "resource": "" }
q236551
index_labels
train
def index_labels(labels, case_sensitive=False): """Convert a list of string identifiers into numerical indices. Parameters ---------- labels : list of strings, shape=(n,) A list of annotations, e.g., segment or chord labels from an annotation file. case_sensitive : bool Set...
python
{ "resource": "" }
q236552
intervals_to_samples
train
def intervals_to_samples(intervals, labels, offset=0, sample_size=0.1, fill_value=None): """Convert an array of labeled time intervals to annotated samples. Parameters ---------- intervals : np.ndarray, shape=(n, d) An array of time intervals, as returned by :fu...
python
{ "resource": "" }
q236553
interpolate_intervals
train
def interpolate_intervals(intervals, labels, time_points, fill_value=None): """Assign labels to a set of points in time given a set of intervals. Time points that do not lie within an interval are mapped to `fill_value`. Parameters ---------- intervals : np.ndarray, shape=(n, 2) An array o...
python
{ "resource": "" }
q236554
sort_labeled_intervals
train
def sort_labeled_intervals(intervals, labels=None): '''Sort intervals, and optionally, their corresponding labels according to start time. Parameters ---------- intervals : np.ndarray, shape=(n, 2) The input intervals labels : list, optional Labels for each interval Return...
python
{ "resource": "" }
q236555
f_measure
train
def f_measure(precision, recall, beta=1.0): """Compute the f-measure from precision and recall scores. Parameters ---------- precision : float in (0, 1] Precision recall : float in (0, 1] Recall beta : float > 0 Weighting factor for f-measure (Default value = 1.0...
python
{ "resource": "" }
q236556
intervals_to_boundaries
train
def intervals_to_boundaries(intervals, q=5): """Convert interval times into boundaries. Parameters ---------- intervals : np.ndarray, shape=(n_events, 2) Array of interval start and end-times q : int Number of decimals to round to. (Default value = 5) Returns ------- bo...
python
{ "resource": "" }
q236557
boundaries_to_intervals
train
def boundaries_to_intervals(boundaries): """Convert an array of event times into intervals Parameters ---------- boundaries : list-like List-like of event times. These are assumed to be unique timestamps in ascending order. Returns ------- intervals : np.ndarray, shape=(n_...
python
{ "resource": "" }
q236558
merge_labeled_intervals
train
def merge_labeled_intervals(x_intervals, x_labels, y_intervals, y_labels): r"""Merge the time intervals of two sequences. Parameters ---------- x_intervals : np.ndarray Array of interval times (seconds) x_labels : list or None List of labels y_intervals : np.ndarray Arra...
python
{ "resource": "" }
q236559
match_events
train
def match_events(ref, est, window, distance=None): """Compute a maximum matching between reference and estimated event times, subject to a window constraint. Given two lists of event times ``ref`` and ``est``, we seek the largest set of correspondences ``(ref[i], est[j])`` such that ``distance(ref[...
python
{ "resource": "" }
q236560
_fast_hit_windows
train
def _fast_hit_windows(ref, est, window): '''Fast calculation of windowed hits for time events. Given two lists of event times ``ref`` and ``est``, and a tolerance window, computes a list of pairings ``(i, j)`` where ``|ref[i] - est[j]| <= window``. This is equivalent to, but more efficient than th...
python
{ "resource": "" }
q236561
validate_events
train
def validate_events(events, max_time=30000.): """Checks that a 1-d event location ndarray is well-formed, and raises errors if not. Parameters ---------- events : np.ndarray, shape=(n,) Array of event times max_time : float If an event is found above this time, a ValueError will...
python
{ "resource": "" }
q236562
validate_frequencies
train
def validate_frequencies(frequencies, max_freq, min_freq, allow_negatives=False): """Checks that a 1-d frequency ndarray is well-formed, and raises errors if not. Parameters ---------- frequencies : np.ndarray, shape=(n,) Array of frequency values max_freq : flo...
python
{ "resource": "" }
q236563
intervals_to_durations
train
def intervals_to_durations(intervals): """Converts an array of n intervals to their n durations. Parameters ---------- intervals : np.ndarray, shape=(n, 2) An array of time intervals, as returned by :func:`mir_eval.io.load_intervals()`. The ``i`` th interval spans time ``interva...
python
{ "resource": "" }
q236564
validate
train
def validate(reference_sources, estimated_sources): """Checks that the input data to a metric are valid, and throws helpful errors if not. Parameters ---------- reference_sources : np.ndarray, shape=(nsrc, nsampl) matrix containing true sources estimated_sources : np.ndarray, shape=(nsr...
python
{ "resource": "" }
q236565
_any_source_silent
train
def _any_source_silent(sources): """Returns true if the parameter sources has any silent first dimensions""" return np.any(np.all(np.sum( sources, axis=tuple(range(2, sources.ndim))) == 0, axis=1))
python
{ "resource": "" }
q236566
bss_eval_sources
train
def bss_eval_sources(reference_sources, estimated_sources, compute_permutation=True): """ Ordering and measurement of the separation quality for estimated source signals in terms of filtered true source, interference and artifacts. The decomposition allows a time-invariant filter d...
python
{ "resource": "" }
q236567
bss_eval_sources_framewise
train
def bss_eval_sources_framewise(reference_sources, estimated_sources, window=30*44100, hop=15*44100, compute_permutation=False): """Framewise computation of bss_eval_sources Please be aware that this function does not compute permutations (by def...
python
{ "resource": "" }
q236568
bss_eval_images_framewise
train
def bss_eval_images_framewise(reference_sources, estimated_sources, window=30*44100, hop=15*44100, compute_permutation=False): """Framewise computation of bss_eval_images Please be aware that this function does not compute permutations (by default...
python
{ "resource": "" }
q236569
_project
train
def _project(reference_sources, estimated_source, flen): """Least-squares projection of estimated source on the subspace spanned by delayed versions of reference sources, with delays between 0 and flen-1 """ nsrc = reference_sources.shape[0] nsampl = reference_sources.shape[1] # computing coeff...
python
{ "resource": "" }
q236570
_bss_image_crit
train
def _bss_image_crit(s_true, e_spat, e_interf, e_artif): """Measurement of the separation quality for a given image in terms of filtered true source, spatial error, interference and artifacts. """ # energy ratios sdr = _safe_db(np.sum(s_true**2), np.sum((e_spat+e_interf+e_artif)**2)) isr = _safe_...
python
{ "resource": "" }
q236571
_safe_db
train
def _safe_db(num, den): """Properly handle the potential +Inf db SIR, instead of raising a RuntimeWarning. Only denominator is checked because the numerator can never be 0. """ if den == 0: return np.Inf return 10 * np.log10(num / den)
python
{ "resource": "" }
q236572
evaluate
train
def evaluate(reference_sources, estimated_sources, **kwargs): """Compute all metrics for the given reference and estimated signals. NOTE: This will always compute :func:`mir_eval.separation.bss_eval_images` for any valid input and will additionally compute :func:`mir_eval.separation.bss_eval_sources` f...
python
{ "resource": "" }
q236573
clicks
train
def clicks(times, fs, click=None, length=None): """Returns a signal with the signal 'click' placed at each specified time Parameters ---------- times : np.ndarray times to place clicks, in seconds fs : int desired sampling rate of the output signal click : np.ndarray cli...
python
{ "resource": "" }
q236574
time_frequency
train
def time_frequency(gram, frequencies, times, fs, function=np.sin, length=None, n_dec=1): """Reverse synthesis of a time-frequency representation of a signal Parameters ---------- gram : np.ndarray ``gram[n, m]`` is the magnitude of ``frequencies[n]`` from ``times[m]``...
python
{ "resource": "" }
q236575
pitch_contour
train
def pitch_contour(times, frequencies, fs, amplitudes=None, function=np.sin, length=None, kind='linear'): '''Sonify a pitch contour. Parameters ---------- times : np.ndarray time indices for each frequency measurement, in seconds frequencies : np.ndarray frequency ...
python
{ "resource": "" }
q236576
chords
train
def chords(chord_labels, intervals, fs, **kwargs): """Synthesizes chord labels Parameters ---------- chord_labels : list of str List of chord label strings. intervals : np.ndarray, shape=(len(chord_labels), 2) Start and end times of each chord label fs : int Sampling rat...
python
{ "resource": "" }
q236577
validate
train
def validate(reference_onsets, estimated_onsets): """Checks that the input annotations to a metric look like valid onset time arrays, and throws helpful errors if not. Parameters ---------- reference_onsets : np.ndarray reference onset locations, in seconds estimated_onsets : np.ndarray...
python
{ "resource": "" }
q236578
f_measure
train
def f_measure(reference_onsets, estimated_onsets, window=.05): """Compute the F-measure of correct vs incorrectly predicted onsets. "Corectness" is determined over a small window. Examples -------- >>> reference_onsets = mir_eval.io.load_events('reference.txt') >>> estimated_onsets = mir_eval.i...
python
{ "resource": "" }
q236579
validate
train
def validate(ref_intervals, ref_pitches, est_intervals, est_pitches): """Checks that the input annotations to a metric look like time intervals and a pitch list, and throws helpful errors if not. Parameters ---------- ref_intervals : np.ndarray, shape=(n,2) Array of reference notes time int...
python
{ "resource": "" }
q236580
validate_intervals
train
def validate_intervals(ref_intervals, est_intervals): """Checks that the input annotations to a metric look like time intervals, and throws helpful errors if not. Parameters ---------- ref_intervals : np.ndarray, shape=(n,2) Array of reference notes time intervals (onset and offset times) ...
python
{ "resource": "" }
q236581
match_note_offsets
train
def match_note_offsets(ref_intervals, est_intervals, offset_ratio=0.2, offset_min_tolerance=0.05, strict=False): """Compute a maximum matching between reference and estimated notes, only taking note offsets into account. Given two note sequences represented by ``ref_intervals`` and ...
python
{ "resource": "" }
q236582
match_note_onsets
train
def match_note_onsets(ref_intervals, est_intervals, onset_tolerance=0.05, strict=False): """Compute a maximum matching between reference and estimated notes, only taking note onsets into account. Given two note sequences represented by ``ref_intervals`` and ``est_intervals`` (see ...
python
{ "resource": "" }
q236583
validate_voicing
train
def validate_voicing(ref_voicing, est_voicing): """Checks that voicing inputs to a metric are in the correct format. Parameters ---------- ref_voicing : np.ndarray Reference boolean voicing array est_voicing : np.ndarray Estimated boolean voicing array """ if ref_voicing.si...
python
{ "resource": "" }
q236584
hz2cents
train
def hz2cents(freq_hz, base_frequency=10.0): """Convert an array of frequency values in Hz to cents. 0 values are left in place. Parameters ---------- freq_hz : np.ndarray Array of frequencies in Hz. base_frequency : float Base frequency for conversion. (Default value = 1...
python
{ "resource": "" }
q236585
constant_hop_timebase
train
def constant_hop_timebase(hop, end_time): """Generates a time series from 0 to ``end_time`` with times spaced ``hop`` apart Parameters ---------- hop : float Spacing of samples in the time series end_time : float Time series will span ``[0, end_time]`` Returns ------- ...
python
{ "resource": "" }
q236586
detection
train
def detection(reference_intervals, estimated_intervals, window=0.5, beta=1.0, trim=False): """Boundary detection hit-rate. A hit is counted whenever an reference boundary is within ``window`` of a estimated boundary. Note that each boundary is matched at most once: this is achieved by co...
python
{ "resource": "" }
q236587
deviation
train
def deviation(reference_intervals, estimated_intervals, trim=False): """Compute the median deviations between reference and estimated boundary times. Examples -------- >>> ref_intervals, _ = mir_eval.io.load_labeled_intervals('ref.lab') >>> est_intervals, _ = mir_eval.io.load_labeled_intervals(...
python
{ "resource": "" }
q236588
pairwise
train
def pairwise(reference_intervals, reference_labels, estimated_intervals, estimated_labels, frame_size=0.1, beta=1.0): """Frame-clustering segmentation evaluation by pair-wise agreement. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_inter...
python
{ "resource": "" }
q236589
_contingency_matrix
train
def _contingency_matrix(reference_indices, estimated_indices): """Computes the contingency matrix of a true labeling vs an estimated one. Parameters ---------- reference_indices : np.ndarray Array of reference indices estimated_indices : np.ndarray Array of estimated indices Re...
python
{ "resource": "" }
q236590
_adjusted_rand_index
train
def _adjusted_rand_index(reference_indices, estimated_indices): """Compute the Rand index, adjusted for change. Parameters ---------- reference_indices : np.ndarray Array of reference indices estimated_indices : np.ndarray Array of estimated indices Returns ------- ari ...
python
{ "resource": "" }
q236591
_mutual_info_score
train
def _mutual_info_score(reference_indices, estimated_indices, contingency=None): """Compute the mutual information between two sequence labelings. Parameters ---------- reference_indices : np.ndarray Array of reference indices estimated_indices : np.ndarray Array of estimated indices...
python
{ "resource": "" }
q236592
_entropy
train
def _entropy(labels): """Calculates the entropy for a labeling. Parameters ---------- labels : list-like List of labels. Returns ------- entropy : float Entropy of the labeling. .. note:: Based on sklearn.metrics.cluster.entropy """ if len(labels) == 0: ...
python
{ "resource": "" }
q236593
validate_tempi
train
def validate_tempi(tempi, reference=True): """Checks that there are two non-negative tempi. For a reference value, at least one tempo has to be greater than zero. Parameters ---------- tempi : np.ndarray length-2 array of tempo, in bpm reference : bool indicates a reference val...
python
{ "resource": "" }
q236594
validate
train
def validate(reference_tempi, reference_weight, estimated_tempi): """Checks that the input annotations to a metric look like valid tempo annotations. Parameters ---------- reference_tempi : np.ndarray reference tempo values, in bpm reference_weight : float perceptual weight of ...
python
{ "resource": "" }
q236595
detection
train
def detection(reference_tempi, reference_weight, estimated_tempi, tol=0.08): """Compute the tempo detection accuracy metric. Parameters ---------- reference_tempi : np.ndarray, shape=(2,) Two non-negative reference tempi reference_weight : float > 0 The relative strength of ``refer...
python
{ "resource": "" }
q236596
validate
train
def validate(ref_time, ref_freqs, est_time, est_freqs): """Checks that the time and frequency inputs are well-formed. Parameters ---------- ref_time : np.ndarray reference time stamps in seconds ref_freqs : list of np.ndarray reference frequencies in Hz est_time : np.ndarray ...
python
{ "resource": "" }
q236597
resample_multipitch
train
def resample_multipitch(times, frequencies, target_times): """Resamples multipitch time series to a new timescale. Values in ``target_times`` outside the range of ``times`` return no pitch estimate. Parameters ---------- times : np.ndarray Array of time stamps frequencies : list of np.n...
python
{ "resource": "" }
q236598
compute_num_true_positives
train
def compute_num_true_positives(ref_freqs, est_freqs, window=0.5, chroma=False): """Compute the number of true positives in an estimate given a reference. A frequency is correct if it is within a quartertone of the correct frequency. Parameters ---------- ref_freqs : list of np.ndarray r...
python
{ "resource": "" }
q236599
compute_accuracy
train
def compute_accuracy(true_positives, n_ref, n_est): """Compute accuracy metrics. Parameters ---------- true_positives : np.ndarray Array containing the number of true positives at each time point. n_ref : np.ndarray Array containing the number of reference frequencies at each time ...
python
{ "resource": "" }