repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
craffel/mir_eval
mir_eval/util.py
_fast_hit_windows
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
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...
[ "def", "_fast_hit_windows", "(", "ref", ",", "est", ",", "window", ")", ":", "ref", "=", "np", ".", "asarray", "(", "ref", ")", "est", "=", "np", ".", "asarray", "(", "est", ")", "ref_idx", "=", "np", ".", "argsort", "(", "ref", ")", "ref_sorted", ...
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 the following: >>> hit_ref, hit_est = np.wher...
[ "Fast", "calculation", "of", "windowed", "hits", "for", "time", "events", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L713-L755
train
craffel/mir_eval
mir_eval/util.py
validate_events
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
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...
[ "def", "validate_events", "(", "events", ",", "max_time", "=", "30000.", ")", ":", "if", "(", "events", ">", "max_time", ")", ".", "any", "(", ")", ":", "raise", "ValueError", "(", "'An event at time {} was found which is greater than '", "'the maximum allowable tim...
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 be raised. (Default value = 30000.)
[ "Checks", "that", "a", "1", "-", "d", "event", "location", "ndarray", "is", "well", "-", "formed", "and", "raises", "errors", "if", "not", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L783-L808
train
craffel/mir_eval
mir_eval/util.py
validate_frequencies
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
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...
[ "def", "validate_frequencies", "(", "frequencies", ",", "max_freq", ",", "min_freq", ",", "allow_negatives", "=", "False", ")", ":", "if", "allow_negatives", ":", "frequencies", "=", "np", ".", "abs", "(", "frequencies", ")", "if", "(", "np", ".", "abs", "...
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 : float If a frequency is found above this pitch, a ValueError will be raised. (Default value = 5000.) ...
[ "Checks", "that", "a", "1", "-", "d", "frequency", "ndarray", "is", "well", "-", "formed", "and", "raises", "errors", "if", "not", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L811-L847
train
craffel/mir_eval
mir_eval/util.py
intervals_to_durations
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
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...
[ "def", "intervals_to_durations", "(", "intervals", ")", ":", "validate_intervals", "(", "intervals", ")", "return", "np", ".", "abs", "(", "np", ".", "diff", "(", "intervals", ",", "axis", "=", "-", "1", ")", ")", ".", "flatten", "(", ")" ]
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 ``intervals[i, 0]`` to ``intervals[i, 1]``. ...
[ "Converts", "an", "array", "of", "n", "intervals", "to", "their", "n", "durations", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L907-L925
train
craffel/mir_eval
mir_eval/separation.py
validate
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
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...
[ "def", "validate", "(", "reference_sources", ",", "estimated_sources", ")", ":", "if", "reference_sources", ".", "shape", "!=", "estimated_sources", ".", "shape", ":", "raise", "ValueError", "(", "'The shape of estimated sources and the true '", "'sources should match. ref...
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=(nsrc, nsampl) matrix containing estimated sources
[ "Checks", "that", "the", "input", "data", "to", "a", "metric", "are", "valid", "and", "throws", "helpful", "errors", "if", "not", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L62-L121
train
craffel/mir_eval
mir_eval/separation.py
_any_source_silent
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
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))
[ "def", "_any_source_silent", "(", "sources", ")", ":", "return", "np", ".", "any", "(", "np", ".", "all", "(", "np", ".", "sum", "(", "sources", ",", "axis", "=", "tuple", "(", "range", "(", "2", ",", "sources", ".", "ndim", ")", ")", ")", "==", ...
Returns true if the parameter sources has any silent first dimensions
[ "Returns", "true", "if", "the", "parameter", "sources", "has", "any", "silent", "first", "dimensions" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L124-L127
train
craffel/mir_eval
mir_eval/separation.py
bss_eval_sources
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
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...
[ "def", "bss_eval_sources", "(", "reference_sources", ",", "estimated_sources", ",", "compute_permutation", "=", "True", ")", ":", "if", "estimated_sources", ".", "ndim", "==", "1", ":", "estimated_sources", "=", "estimated_sources", "[", "np", ".", "newaxis", ",",...
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 distortion of length 512, as described in Section III.B of [#vincent2006performance]_. Passing ``False`` for ``...
[ "Ordering", "and", "measurement", "of", "the", "separation", "quality", "for", "estimated", "source", "signals", "in", "terms", "of", "filtered", "true", "source", "interference", "and", "artifacts", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L130-L241
train
craffel/mir_eval
mir_eval/separation.py
bss_eval_sources_framewise
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
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...
[ "def", "bss_eval_sources_framewise", "(", "reference_sources", ",", "estimated_sources", ",", "window", "=", "30", "*", "44100", ",", "hop", "=", "15", "*", "44100", ",", "compute_permutation", "=", "False", ")", ":", "if", "estimated_sources", ".", "ndim", "=...
Framewise computation of bss_eval_sources Please be aware that this function does not compute permutations (by default) on the possible relations between reference_sources and estimated_sources due to the dangers of a changing permutation. Therefore (by default), it assumes that ``reference_sources[i]`...
[ "Framewise", "computation", "of", "bss_eval_sources" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L244-L353
train
craffel/mir_eval
mir_eval/separation.py
bss_eval_images_framewise
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
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...
[ "def", "bss_eval_images_framewise", "(", "reference_sources", ",", "estimated_sources", ",", "window", "=", "30", "*", "44100", ",", "hop", "=", "15", "*", "44100", ",", "compute_permutation", "=", "False", ")", ":", "estimated_sources", "=", "np", ".", "atlea...
Framewise computation of bss_eval_images Please be aware that this function does not compute permutations (by default) on the possible relations between ``reference_sources`` and ``estimated_sources`` due to the dangers of a changing permutation. Therefore (by default), it assumes that ``reference_sour...
[ "Framewise", "computation", "of", "bss_eval_images" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L493-L606
train
craffel/mir_eval
mir_eval/separation.py
_project
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
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...
[ "def", "_project", "(", "reference_sources", ",", "estimated_source", ",", "flen", ")", ":", "nsrc", "=", "reference_sources", ".", "shape", "[", "0", "]", "nsampl", "=", "reference_sources", ".", "shape", "[", "1", "]", "reference_sources", "=", "np", ".", ...
Least-squares projection of estimated source on the subspace spanned by delayed versions of reference sources, with delays between 0 and flen-1
[ "Least", "-", "squares", "projection", "of", "estimated", "source", "on", "the", "subspace", "spanned", "by", "delayed", "versions", "of", "reference", "sources", "with", "delays", "between", "0", "and", "flen", "-", "1" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L679-L722
train
craffel/mir_eval
mir_eval/separation.py
_bss_image_crit
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
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_...
[ "def", "_bss_image_crit", "(", "s_true", ",", "e_spat", ",", "e_interf", ",", "e_artif", ")", ":", "sdr", "=", "_safe_db", "(", "np", ".", "sum", "(", "s_true", "**", "2", ")", ",", "np", ".", "sum", "(", "(", "e_spat", "+", "e_interf", "+", "e_art...
Measurement of the separation quality for a given image in terms of filtered true source, spatial error, interference and artifacts.
[ "Measurement", "of", "the", "separation", "quality", "for", "a", "given", "image", "in", "terms", "of", "filtered", "true", "source", "spatial", "error", "interference", "and", "artifacts", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L815-L824
train
craffel/mir_eval
mir_eval/separation.py
_safe_db
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
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)
[ "def", "_safe_db", "(", "num", ",", "den", ")", ":", "if", "den", "==", "0", ":", "return", "np", ".", "Inf", "return", "10", "*", "np", ".", "log10", "(", "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.
[ "Properly", "handle", "the", "potential", "+", "Inf", "db", "SIR", "instead", "of", "raising", "a", "RuntimeWarning", ".", "Only", "denominator", "is", "checked", "because", "the", "numerator", "can", "never", "be", "0", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L827-L834
train
craffel/mir_eval
mir_eval/separation.py
evaluate
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
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...
[ "def", "evaluate", "(", "reference_sources", ",", "estimated_sources", ",", "**", "kwargs", ")", ":", "scores", "=", "collections", ".", "OrderedDict", "(", ")", "sdr", ",", "isr", ",", "sir", ",", "sar", ",", "perm", "=", "util", ".", "filter_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` for valid input with fewer than 3 dimensions. Examples --...
[ "Compute", "all", "metrics", "for", "the", "given", "reference", "and", "estimated", "signals", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/separation.py#L837-L921
train
craffel/mir_eval
mir_eval/sonify.py
clicks
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
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...
[ "def", "clicks", "(", "times", ",", "fs", ",", "click", "=", "None", ",", "length", "=", "None", ")", ":", "if", "click", "is", "None", ":", "click", "=", "np", ".", "sin", "(", "2", "*", "np", ".", "pi", "*", "np", ".", "arange", "(", "fs", ...
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 click signal, defaults to a 1 kHz blip length : int ...
[ "Returns", "a", "signal", "with", "the", "signal", "click", "placed", "at", "each", "specified", "time" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/sonify.py#L14-L60
train
craffel/mir_eval
mir_eval/sonify.py
time_frequency
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
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]``...
[ "def", "time_frequency", "(", "gram", ",", "frequencies", ",", "times", ",", "fs", ",", "function", "=", "np", ".", "sin", ",", "length", "=", "None", ",", "n_dec", "=", "1", ")", ":", "if", "times", ".", "ndim", "==", "1", ":", "times", "=", "ut...
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]`` to ``times[m + 1]`` Non-positive magnitudes are interpreted as silence. frequencies : np.ndarray ...
[ "Reverse", "synthesis", "of", "a", "time", "-", "frequency", "representation", "of", "a", "signal" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/sonify.py#L63-L184
train
craffel/mir_eval
mir_eval/sonify.py
pitch_contour
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
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 ...
[ "def", "pitch_contour", "(", "times", ",", "frequencies", ",", "fs", ",", "amplitudes", "=", "None", ",", "function", "=", "np", ".", "sin", ",", "length", "=", "None", ",", "kind", "=", "'linear'", ")", ":", "fs", "=", "float", "(", "fs", ")", "if...
Sonify a pitch contour. Parameters ---------- times : np.ndarray time indices for each frequency measurement, in seconds frequencies : np.ndarray frequency measurements, in Hz. Non-positive measurements will be interpreted as un-voiced samples. fs : int desired sam...
[ "Sonify", "a", "pitch", "contour", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/sonify.py#L187-L250
train
craffel/mir_eval
mir_eval/sonify.py
chords
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
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...
[ "def", "chords", "(", "chord_labels", ",", "intervals", ",", "fs", ",", "**", "kwargs", ")", ":", "util", ".", "validate_intervals", "(", "intervals", ")", "roots", ",", "interval_bitmaps", ",", "_", "=", "chord", ".", "encode_many", "(", "chord_labels", "...
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 rate to synthesize at kwargs Additional keyword a...
[ "Synthesizes", "chord", "labels" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/sonify.py#L300-L329
train
craffel/mir_eval
mir_eval/onset.py
validate
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
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...
[ "def", "validate", "(", "reference_onsets", ",", "estimated_onsets", ")", ":", "if", "reference_onsets", ".", "size", "==", "0", ":", "warnings", ".", "warn", "(", "\"Reference onsets are empty.\"", ")", "if", "estimated_onsets", ".", "size", "==", "0", ":", "...
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 estimated onset locations, in seconds
[ "Checks", "that", "the", "input", "annotations", "to", "a", "metric", "look", "like", "valid", "onset", "time", "arrays", "and", "throws", "helpful", "errors", "if", "not", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/onset.py#L35-L53
train
craffel/mir_eval
mir_eval/onset.py
f_measure
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
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...
[ "def", "f_measure", "(", "reference_onsets", ",", "estimated_onsets", ",", "window", "=", ".05", ")", ":", "validate", "(", "reference_onsets", ",", "estimated_onsets", ")", "if", "reference_onsets", ".", "size", "==", "0", "or", "estimated_onsets", ".", "size",...
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.io.load_events('estimated.txt') >>> F, P, R = mir_eval.onset.f_meas...
[ "Compute", "the", "F", "-", "measure", "of", "correct", "vs", "incorrectly", "predicted", "onsets", ".", "Corectness", "is", "determined", "over", "a", "small", "window", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/onset.py#L56-L98
train
craffel/mir_eval
mir_eval/transcription.py
validate
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
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...
[ "def", "validate", "(", "ref_intervals", ",", "ref_pitches", ",", "est_intervals", ",", "est_pitches", ")", ":", "validate_intervals", "(", "ref_intervals", ",", "est_intervals", ")", "if", "not", "ref_intervals", ".", "shape", "[", "0", "]", "==", "ref_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 intervals (onset and offset times) ref_pitches : np.ndarray, shape=(n,) ...
[ "Checks", "that", "the", "input", "annotations", "to", "a", "metric", "look", "like", "time", "intervals", "and", "a", "pitch", "list", "and", "throws", "helpful", "errors", "if", "not", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/transcription.py#L117-L149
train
craffel/mir_eval
mir_eval/transcription.py
validate_intervals
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
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) ...
[ "def", "validate_intervals", "(", "ref_intervals", ",", "est_intervals", ")", ":", "if", "ref_intervals", ".", "size", "==", "0", ":", "warnings", ".", "warn", "(", "\"Reference notes are empty.\"", ")", "if", "est_intervals", ".", "size", "==", "0", ":", "war...
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) est_intervals : np.ndarray, shape=(m,2) Array of e...
[ "Checks", "that", "the", "input", "annotations", "to", "a", "metric", "look", "like", "time", "intervals", "and", "throws", "helpful", "errors", "if", "not", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/transcription.py#L152-L171
train
craffel/mir_eval
mir_eval/transcription.py
match_note_offsets
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
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 ...
[ "def", "match_note_offsets", "(", "ref_intervals", ",", "est_intervals", ",", "offset_ratio", "=", "0.2", ",", "offset_min_tolerance", "=", "0.05", ",", "strict", "=", "False", ")", ":", "if", "strict", ":", "cmp_func", "=", "np", ".", "less", "else", ":", ...
Compute a maximum matching between reference and estimated notes, only taking note offsets into account. Given two note sequences represented by ``ref_intervals`` and ``est_intervals`` (see :func:`mir_eval.io.load_valued_intervals`), we seek the largest set of correspondences ``(i, j)`` such that the o...
[ "Compute", "a", "maximum", "matching", "between", "reference", "and", "estimated", "notes", "only", "taking", "note", "offsets", "into", "account", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/transcription.py#L174-L260
train
craffel/mir_eval
mir_eval/transcription.py
match_note_onsets
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
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 ...
[ "def", "match_note_onsets", "(", "ref_intervals", ",", "est_intervals", ",", "onset_tolerance", "=", "0.05", ",", "strict", "=", "False", ")", ":", "if", "strict", ":", "cmp_func", "=", "np", ".", "less", "else", ":", "cmp_func", "=", "np", ".", "less_equa...
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 :func:`mir_eval.io.load_valued_intervals`), we see the largest set of correspondences ``(i,j)`` such that the onse...
[ "Compute", "a", "maximum", "matching", "between", "reference", "and", "estimated", "notes", "only", "taking", "note", "onsets", "into", "account", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/transcription.py#L263-L333
train
craffel/mir_eval
mir_eval/melody.py
validate_voicing
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
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...
[ "def", "validate_voicing", "(", "ref_voicing", ",", "est_voicing", ")", ":", "if", "ref_voicing", ".", "size", "==", "0", ":", "warnings", ".", "warn", "(", "\"Reference voicing array is empty.\"", ")", "if", "est_voicing", ".", "size", "==", "0", ":", "warnin...
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
[ "Checks", "that", "voicing", "inputs", "to", "a", "metric", "are", "in", "the", "correct", "format", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/melody.py#L61-L87
train
craffel/mir_eval
mir_eval/melody.py
hz2cents
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
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...
[ "def", "hz2cents", "(", "freq_hz", ",", "base_frequency", "=", "10.0", ")", ":", "freq_cent", "=", "np", ".", "zeros", "(", "freq_hz", ".", "shape", "[", "0", "]", ")", "freq_nonz_ind", "=", "np", ".", "flatnonzero", "(", "freq_hz", ")", "normalized_freq...
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 = 10.0) Returns ------- cent : np.ndarray...
[ "Convert", "an", "array", "of", "frequency", "values", "in", "Hz", "to", "cents", ".", "0", "values", "are", "left", "in", "place", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/melody.py#L118-L141
train
craffel/mir_eval
mir_eval/melody.py
constant_hop_timebase
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
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 ------- ...
[ "def", "constant_hop_timebase", "(", "hop", ",", "end_time", ")", ":", "end_time", "=", "np", ".", "round", "(", "end_time", ",", "10", ")", "times", "=", "np", ".", "linspace", "(", "0", ",", "hop", "*", "int", "(", "np", ".", "floor", "(", "end_t...
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 ------- times : np.ndarray Generated timebase
[ "Generates", "a", "time", "series", "from", "0", "to", "end_time", "with", "times", "spaced", "hop", "apart" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/melody.py#L165-L187
train
craffel/mir_eval
mir_eval/segment.py
detection
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
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...
[ "def", "detection", "(", "reference_intervals", ",", "estimated_intervals", ",", "window", "=", "0.5", ",", "beta", "=", "1.0", ",", "trim", "=", "False", ")", ":", "validate_boundary", "(", "reference_intervals", ",", "estimated_intervals", ",", "trim", ")", ...
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 computing the size of a maximal matching between reference and estimated boundary points, subject to the windo...
[ "Boundary", "detection", "hit", "-", "rate", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/segment.py#L176-L260
train
craffel/mir_eval
mir_eval/segment.py
deviation
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
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(...
[ "def", "deviation", "(", "reference_intervals", ",", "estimated_intervals", ",", "trim", "=", "False", ")", ":", "validate_boundary", "(", "reference_intervals", ",", "estimated_intervals", ",", "trim", ")", "reference_boundaries", "=", "util", ".", "intervals_to_boun...
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('est.lab') >>> r_to_e, e_to_r = mir_eval.boundary.deviation(ref_interval...
[ "Compute", "the", "median", "deviations", "between", "reference", "and", "estimated", "boundary", "times", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/segment.py#L263-L321
train
craffel/mir_eval
mir_eval/segment.py
pairwise
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
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...
[ "def", "pairwise", "(", "reference_intervals", ",", "reference_labels", ",", "estimated_intervals", ",", "estimated_labels", ",", "frame_size", "=", "0.1", ",", "beta", "=", "1.0", ")", ":", "validate_structure", "(", "reference_intervals", ",", "reference_labels", ...
Frame-clustering segmentation evaluation by pair-wise agreement. 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') >>> # Trim or pad the estimate to matc...
[ "Frame", "-", "clustering", "segmentation", "evaluation", "by", "pair", "-", "wise", "agreement", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/segment.py#L324-L418
train
craffel/mir_eval
mir_eval/segment.py
_contingency_matrix
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
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...
[ "def", "_contingency_matrix", "(", "reference_indices", ",", "estimated_indices", ")", ":", "ref_classes", ",", "ref_class_idx", "=", "np", ".", "unique", "(", "reference_indices", ",", "return_inverse", "=", "True", ")", "est_classes", ",", "est_class_idx", "=", ...
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 Returns ------- contingency_matrix : np.ndarray Continge...
[ "Computes", "the", "contingency", "matrix", "of", "a", "true", "labeling", "vs", "an", "estimated", "one", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/segment.py#L516-L543
train
craffel/mir_eval
mir_eval/segment.py
_adjusted_rand_index
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
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 ...
[ "def", "_adjusted_rand_index", "(", "reference_indices", ",", "estimated_indices", ")", ":", "n_samples", "=", "len", "(", "reference_indices", ")", "ref_classes", "=", "np", ".", "unique", "(", "reference_indices", ")", "est_classes", "=", "np", ".", "unique", ...
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 : float Adjusted Rand index .. note:: Based on sklearn.met...
[ "Compute", "the", "Rand", "index", "adjusted", "for", "change", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/segment.py#L546-L589
train
craffel/mir_eval
mir_eval/segment.py
_mutual_info_score
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
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...
[ "def", "_mutual_info_score", "(", "reference_indices", ",", "estimated_indices", ",", "contingency", "=", "None", ")", ":", "if", "contingency", "is", "None", ":", "contingency", "=", "_contingency_matrix", "(", "reference_indices", ",", "estimated_indices", ")", "....
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 contingency : np.ndarray Pre-computed contingency matrix. If None, one wi...
[ "Compute", "the", "mutual", "information", "between", "two", "sequence", "labelings", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/segment.py#L663-L701
train
craffel/mir_eval
mir_eval/segment.py
_entropy
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
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: ...
[ "def", "_entropy", "(", "labels", ")", ":", "if", "len", "(", "labels", ")", "==", "0", ":", "return", "1.0", "label_idx", "=", "np", ".", "unique", "(", "labels", ",", "return_inverse", "=", "True", ")", "[", "1", "]", "pi", "=", "np", ".", "bin...
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
[ "Calculates", "the", "entropy", "for", "a", "labeling", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/segment.py#L704-L728
train
craffel/mir_eval
mir_eval/tempo.py
validate_tempi
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
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...
[ "def", "validate_tempi", "(", "tempi", ",", "reference", "=", "True", ")", ":", "if", "tempi", ".", "size", "!=", "2", ":", "raise", "ValueError", "(", "'tempi must have exactly two values'", ")", "if", "not", "np", ".", "all", "(", "np", ".", "isfinite", ...
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 value
[ "Checks", "that", "there", "are", "two", "non", "-", "negative", "tempi", ".", "For", "a", "reference", "value", "at", "least", "one", "tempo", "has", "to", "be", "greater", "than", "zero", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/tempo.py#L29-L51
train
craffel/mir_eval
mir_eval/tempo.py
validate
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
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 ...
[ "def", "validate", "(", "reference_tempi", ",", "reference_weight", ",", "estimated_tempi", ")", ":", "validate_tempi", "(", "reference_tempi", ",", "reference", "=", "True", ")", "validate_tempi", "(", "estimated_tempi", ",", "reference", "=", "False", ")", "if",...
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 slow vs fast in reference estimated_tempi : np.ndarray estim...
[ "Checks", "that", "the", "input", "annotations", "to", "a", "metric", "look", "like", "valid", "tempo", "annotations", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/tempo.py#L54-L74
train
craffel/mir_eval
mir_eval/tempo.py
detection
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
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...
[ "def", "detection", "(", "reference_tempi", ",", "reference_weight", ",", "estimated_tempi", ",", "tol", "=", "0.08", ")", ":", "validate", "(", "reference_tempi", ",", "reference_weight", ",", "estimated_tempi", ")", "if", "tol", "<", "0", "or", "tol", ">", ...
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 ``reference_tempi[0]`` vs ``reference_tempi[1]``. estimated_tempi : np.ndarray...
[ "Compute", "the", "tempo", "detection", "accuracy", "metric", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/tempo.py#L77-L145
train
craffel/mir_eval
mir_eval/multipitch.py
validate
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
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 ...
[ "def", "validate", "(", "ref_time", ",", "ref_freqs", ",", "est_time", ",", "est_freqs", ")", ":", "util", ".", "validate_events", "(", "ref_time", ",", "max_time", "=", "MAX_TIME", ")", "util", ".", "validate_events", "(", "est_time", ",", "max_time", "=", ...
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 estimate time stamps in seconds est_freqs : list of np...
[ "Checks", "that", "the", "time", "and", "frequency", "inputs", "are", "well", "-", "formed", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/multipitch.py#L57-L101
train
craffel/mir_eval
mir_eval/multipitch.py
resample_multipitch
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
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...
[ "def", "resample_multipitch", "(", "times", ",", "frequencies", ",", "target_times", ")", ":", "if", "target_times", ".", "size", "==", "0", ":", "return", "[", "]", "if", "times", ".", "size", "==", "0", ":", "return", "[", "np", ".", "array", "(", ...
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.ndarray List of np.ndarrays of frequency values target_...
[ "Resamples", "multipitch", "time", "series", "to", "a", "new", "timescale", ".", "Values", "in", "target_times", "outside", "the", "range", "of", "times", "return", "no", "pitch", "estimate", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/multipitch.py#L104-L150
train
craffel/mir_eval
mir_eval/multipitch.py
compute_num_true_positives
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
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...
[ "def", "compute_num_true_positives", "(", "ref_freqs", ",", "est_freqs", ",", "window", "=", "0.5", ",", "chroma", "=", "False", ")", ":", "n_frames", "=", "len", "(", "ref_freqs", ")", "true_positives", "=", "np", ".", "zeros", "(", "(", "n_frames", ",", ...
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 reference frequencies (MIDI) est_freqs : list of np.ndarray estimated freque...
[ "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", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/multipitch.py#L204-L243
train
craffel/mir_eval
mir_eval/multipitch.py
compute_accuracy
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
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 ...
[ "def", "compute_accuracy", "(", "true_positives", ",", "n_ref", ",", "n_est", ")", ":", "true_positive_sum", "=", "float", "(", "true_positives", ".", "sum", "(", ")", ")", "n_est_sum", "=", "n_est", ".", "sum", "(", ")", "if", "n_est_sum", ">", "0", ":"...
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 point. n_est : np.ndarray Array containi...
[ "Compute", "accuracy", "metrics", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/multipitch.py#L246-L291
train
craffel/mir_eval
mir_eval/multipitch.py
compute_err_score
def compute_err_score(true_positives, n_ref, n_est): """Compute error score 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 ti...
python
def compute_err_score(true_positives, n_ref, n_est): """Compute error score 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 ti...
[ "def", "compute_err_score", "(", "true_positives", ",", "n_ref", ",", "n_est", ")", ":", "n_ref_sum", "=", "float", "(", "n_ref", ".", "sum", "(", ")", ")", "if", "n_ref_sum", "==", "0", ":", "warnings", ".", "warn", "(", "\"Reference frequencies are all emp...
Compute error score 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 point. n_est : np.ndarray Array conta...
[ "Compute", "error", "score", "metrics", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/multipitch.py#L294-L343
train
craffel/mir_eval
mir_eval/hierarchy.py
_hierarchy_bounds
def _hierarchy_bounds(intervals_hier): '''Compute the covered time range of a hierarchical segmentation. Parameters ---------- intervals_hier : list of ndarray A hierarchical segmentation, encoded as a list of arrays of segment intervals. Returns ------- t_min : float t...
python
def _hierarchy_bounds(intervals_hier): '''Compute the covered time range of a hierarchical segmentation. Parameters ---------- intervals_hier : list of ndarray A hierarchical segmentation, encoded as a list of arrays of segment intervals. Returns ------- t_min : float t...
[ "def", "_hierarchy_bounds", "(", "intervals_hier", ")", ":", "boundaries", "=", "list", "(", "itertools", ".", "chain", "(", "*", "list", "(", "itertools", ".", "chain", "(", "*", "intervals_hier", ")", ")", ")", ")", "return", "min", "(", "boundaries", ...
Compute the covered time range of a hierarchical segmentation. Parameters ---------- intervals_hier : list of ndarray A hierarchical segmentation, encoded as a list of arrays of segment intervals. Returns ------- t_min : float t_max : float The minimum and maximum t...
[ "Compute", "the", "covered", "time", "range", "of", "a", "hierarchical", "segmentation", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/hierarchy.py#L83-L100
train
craffel/mir_eval
mir_eval/hierarchy.py
_align_intervals
def _align_intervals(int_hier, lab_hier, t_min=0.0, t_max=None): '''Align a hierarchical annotation to span a fixed start and end time. Parameters ---------- int_hier : list of list of intervals lab_hier : list of list of str Hierarchical segment annotations, encoded as a list of li...
python
def _align_intervals(int_hier, lab_hier, t_min=0.0, t_max=None): '''Align a hierarchical annotation to span a fixed start and end time. Parameters ---------- int_hier : list of list of intervals lab_hier : list of list of str Hierarchical segment annotations, encoded as a list of li...
[ "def", "_align_intervals", "(", "int_hier", ",", "lab_hier", ",", "t_min", "=", "0.0", ",", "t_max", "=", "None", ")", ":", "return", "[", "list", "(", "_", ")", "for", "_", "in", "zip", "(", "*", "[", "util", ".", "adjust_intervals", "(", "np", "....
Align a hierarchical annotation to span a fixed start and end time. Parameters ---------- int_hier : list of list of intervals lab_hier : list of list of str Hierarchical segment annotations, encoded as a list of list of intervals (int_hier) and list of list of strings (lab_hier...
[ "Align", "a", "hierarchical", "annotation", "to", "span", "a", "fixed", "start", "and", "end", "time", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/hierarchy.py#L103-L130
train
craffel/mir_eval
mir_eval/hierarchy.py
_compare_frame_rankings
def _compare_frame_rankings(ref, est, transitive=False): '''Compute the number of ranking disagreements in two lists. Parameters ---------- ref : np.ndarray, shape=(n,) est : np.ndarray, shape=(n,) Reference and estimate ranked lists. `ref[i]` is the relevance score for point `i`. ...
python
def _compare_frame_rankings(ref, est, transitive=False): '''Compute the number of ranking disagreements in two lists. Parameters ---------- ref : np.ndarray, shape=(n,) est : np.ndarray, shape=(n,) Reference and estimate ranked lists. `ref[i]` is the relevance score for point `i`. ...
[ "def", "_compare_frame_rankings", "(", "ref", ",", "est", ",", "transitive", "=", "False", ")", ":", "idx", "=", "np", ".", "argsort", "(", "ref", ")", "ref_sorted", "=", "ref", "[", "idx", "]", "est_sorted", "=", "est", "[", "idx", "]", "levels", ",...
Compute the number of ranking disagreements in two lists. Parameters ---------- ref : np.ndarray, shape=(n,) 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 le...
[ "Compute", "the", "number", "of", "ranking", "disagreements", "in", "two", "lists", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/hierarchy.py#L370-L436
train
craffel/mir_eval
mir_eval/hierarchy.py
validate_hier_intervals
def validate_hier_intervals(intervals_hier): '''Validate a hierarchical segment annotation. Parameters ---------- intervals_hier : ordered list of segmentations Raises ------ ValueError If any segmentation does not span the full duration of the top-level segmentation. ...
python
def validate_hier_intervals(intervals_hier): '''Validate a hierarchical segment annotation. Parameters ---------- intervals_hier : ordered list of segmentations Raises ------ ValueError If any segmentation does not span the full duration of the top-level segmentation. ...
[ "def", "validate_hier_intervals", "(", "intervals_hier", ")", ":", "label_top", "=", "util", ".", "generate_labels", "(", "intervals_hier", "[", "0", "]", ")", "boundaries", "=", "set", "(", "util", ".", "intervals_to_boundaries", "(", "intervals_hier", "[", "0"...
Validate a hierarchical segment annotation. Parameters ---------- intervals_hier : ordered list of segmentations Raises ------ ValueError If any segmentation does not span the full duration of the top-level segmentation. If any segmentation does not start at 0.
[ "Validate", "a", "hierarchical", "segment", "annotation", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/hierarchy.py#L439-L472
train
craffel/mir_eval
mir_eval/hierarchy.py
evaluate
def evaluate(ref_intervals_hier, ref_labels_hier, est_intervals_hier, est_labels_hier, **kwargs): '''Compute all hierarchical structure metrics for the given reference and estimated annotations. Examples -------- A toy example with two two-layer annotations >>> ref_i = [[[0, 30], ...
python
def evaluate(ref_intervals_hier, ref_labels_hier, est_intervals_hier, est_labels_hier, **kwargs): '''Compute all hierarchical structure metrics for the given reference and estimated annotations. Examples -------- A toy example with two two-layer annotations >>> ref_i = [[[0, 30], ...
[ "def", "evaluate", "(", "ref_intervals_hier", ",", "ref_labels_hier", ",", "est_intervals_hier", ",", "est_labels_hier", ",", "**", "kwargs", ")", ":", "_", ",", "t_end", "=", "_hierarchy_bounds", "(", "ref_intervals_hier", ")", "ref_intervals_hier", ",", "ref_label...
Compute all hierarchical structure metrics for the given reference and estimated annotations. Examples -------- A toy example with two two-layer annotations >>> ref_i = [[[0, 30], [30, 60]], [[0, 15], [15, 30], [30, 45], [45, 60]]] >>> est_i = [[[0, 45], [45, 60]], [[0, 15], [15, 30], [30, 45]...
[ "Compute", "all", "hierarchical", "structure", "metrics", "for", "the", "given", "reference", "and", "estimated", "annotations", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/hierarchy.py#L630-L751
train
craffel/mir_eval
mir_eval/display.py
__expand_limits
def __expand_limits(ax, limits, which='x'): '''Helper function to expand axis limits''' if which == 'x': getter, setter = ax.get_xlim, ax.set_xlim elif which == 'y': getter, setter = ax.get_ylim, ax.set_ylim else: raise ValueError('invalid axis: {}'.format(which)) old_lims ...
python
def __expand_limits(ax, limits, which='x'): '''Helper function to expand axis limits''' if which == 'x': getter, setter = ax.get_xlim, ax.set_xlim elif which == 'y': getter, setter = ax.get_ylim, ax.set_ylim else: raise ValueError('invalid axis: {}'.format(which)) old_lims ...
[ "def", "__expand_limits", "(", "ax", ",", "limits", ",", "which", "=", "'x'", ")", ":", "if", "which", "==", "'x'", ":", "getter", ",", "setter", "=", "ax", ".", "get_xlim", ",", "ax", ".", "set_xlim", "elif", "which", "==", "'y'", ":", "getter", "...
Helper function to expand axis limits
[ "Helper", "function", "to", "expand", "axis", "limits" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L19-L39
train
craffel/mir_eval
mir_eval/display.py
__get_axes
def __get_axes(ax=None, fig=None): '''Get or construct the target axes object for a new plot. Parameters ---------- ax : matplotlib.pyplot.axes, optional If provided, return this axes object directly. fig : matplotlib.figure.Figure, optional The figure to query for axes. B...
python
def __get_axes(ax=None, fig=None): '''Get or construct the target axes object for a new plot. Parameters ---------- ax : matplotlib.pyplot.axes, optional If provided, return this axes object directly. fig : matplotlib.figure.Figure, optional The figure to query for axes. B...
[ "def", "__get_axes", "(", "ax", "=", "None", ",", "fig", "=", "None", ")", ":", "new_axes", "=", "False", "if", "ax", "is", "not", "None", ":", "return", "ax", ",", "new_axes", "if", "fig", "is", "None", ":", "import", "matplotlib", ".", "pyplot", ...
Get or construct the target axes object for a new plot. Parameters ---------- ax : matplotlib.pyplot.axes, optional If provided, return this axes object directly. fig : matplotlib.figure.Figure, optional The figure to query for axes. By default, uses the current figure `plt.gc...
[ "Get", "or", "construct", "the", "target", "axes", "object", "for", "a", "new", "plot", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L42-L79
train
craffel/mir_eval
mir_eval/display.py
segments
def segments(intervals, labels, base=None, height=None, text=False, text_kw=None, ax=None, **kwargs): '''Plot a segmentation as a set of disjoint rectangles. Parameters ---------- intervals : np.ndarray, shape=(n, 2) segment intervals, in the format returned by :func:`mir_e...
python
def segments(intervals, labels, base=None, height=None, text=False, text_kw=None, ax=None, **kwargs): '''Plot a segmentation as a set of disjoint rectangles. Parameters ---------- intervals : np.ndarray, shape=(n, 2) segment intervals, in the format returned by :func:`mir_e...
[ "def", "segments", "(", "intervals", ",", "labels", ",", "base", "=", "None", ",", "height", "=", "None", ",", "text", "=", "False", ",", "text_kw", "=", "None", ",", "ax", "=", "None", ",", "**", "kwargs", ")", ":", "if", "text_kw", "is", "None", ...
Plot a segmentation as a set of disjoint rectangles. Parameters ---------- intervals : np.ndarray, shape=(n, 2) 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,) refer...
[ "Plot", "a", "segmentation", "as", "a", "set", "of", "disjoint", "rectangles", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L82-L186
train
craffel/mir_eval
mir_eval/display.py
labeled_intervals
def labeled_intervals(intervals, labels, label_set=None, base=None, height=None, extend_labels=True, ax=None, tick=True, **kwargs): '''Plot labeled intervals with each label on its own row. Parameters ---------- intervals : np.ndarray, shape=(n, 2) se...
python
def labeled_intervals(intervals, labels, label_set=None, base=None, height=None, extend_labels=True, ax=None, tick=True, **kwargs): '''Plot labeled intervals with each label on its own row. Parameters ---------- intervals : np.ndarray, shape=(n, 2) se...
[ "def", "labeled_intervals", "(", "intervals", ",", "labels", ",", "label_set", "=", "None", ",", "base", "=", "None", ",", "height", "=", "None", ",", "extend_labels", "=", "True", ",", "ax", "=", "None", ",", "tick", "=", "True", ",", "**", "kwargs", ...
Plot labeled intervals with each label on its own row. Parameters ---------- intervals : np.ndarray, shape=(n, 2) 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,) ref...
[ "Plot", "labeled", "intervals", "with", "each", "label", "on", "its", "own", "row", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L189-L320
train
craffel/mir_eval
mir_eval/display.py
hierarchy
def hierarchy(intervals_hier, labels_hier, levels=None, ax=None, **kwargs): '''Plot a hierarchical segmentation Parameters ---------- intervals_hier : list of np.ndarray A list of segmentation intervals. Each element should be an n-by-2 array of segment intervals, in the format returne...
python
def hierarchy(intervals_hier, labels_hier, levels=None, ax=None, **kwargs): '''Plot a hierarchical segmentation Parameters ---------- intervals_hier : list of np.ndarray A list of segmentation intervals. Each element should be an n-by-2 array of segment intervals, in the format returne...
[ "def", "hierarchy", "(", "intervals_hier", ",", "labels_hier", ",", "levels", "=", "None", ",", "ax", "=", "None", ",", "**", "kwargs", ")", ":", "if", "levels", "is", "None", ":", "levels", "=", "list", "(", "range", "(", "len", "(", "intervals_hier",...
Plot a hierarchical segmentation Parameters ---------- intervals_hier : list of np.ndarray A list of segmentation intervals. Each element should be an n-by-2 array of segment intervals, in the format returned by :func:`mir_eval.io.load_intervals` or :func:`mir_eval.io.load_...
[ "Plot", "a", "hierarchical", "segmentation" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L343-L391
train
craffel/mir_eval
mir_eval/display.py
events
def events(times, labels=None, base=None, height=None, ax=None, text_kw=None, **kwargs): '''Plot event times as a set of vertical lines Parameters ---------- times : np.ndarray, shape=(n,) event times, in the format returned by :func:`mir_eval.io.load_events` or :func...
python
def events(times, labels=None, base=None, height=None, ax=None, text_kw=None, **kwargs): '''Plot event times as a set of vertical lines Parameters ---------- times : np.ndarray, shape=(n,) event times, in the format returned by :func:`mir_eval.io.load_events` or :func...
[ "def", "events", "(", "times", ",", "labels", "=", "None", ",", "base", "=", "None", ",", "height", "=", "None", ",", "ax", "=", "None", ",", "text_kw", "=", "None", ",", "**", "kwargs", ")", ":", "if", "text_kw", "is", "None", ":", "text_kw", "=...
Plot event times as a set of vertical lines Parameters ---------- times : np.ndarray, shape=(n,) 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 f...
[ "Plot", "event", "times", "as", "a", "set", "of", "vertical", "lines" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L394-L490
train
craffel/mir_eval
mir_eval/display.py
pitch
def pitch(times, frequencies, midi=False, unvoiced=False, ax=None, **kwargs): '''Visualize pitch contours Parameters ---------- times : np.ndarray, shape=(n,) Sample times of frequencies frequencies : np.ndarray, shape=(n,) frequencies (in Hz) of the pitch contours. Voicing...
python
def pitch(times, frequencies, midi=False, unvoiced=False, ax=None, **kwargs): '''Visualize pitch contours Parameters ---------- times : np.ndarray, shape=(n,) Sample times of frequencies frequencies : np.ndarray, shape=(n,) frequencies (in Hz) of the pitch contours. Voicing...
[ "def", "pitch", "(", "times", ",", "frequencies", ",", "midi", "=", "False", ",", "unvoiced", "=", "False", ",", "ax", "=", "None", ",", "**", "kwargs", ")", ":", "ax", ",", "_", "=", "__get_axes", "(", "ax", "=", "ax", ")", "times", "=", "np", ...
Visualize pitch contours Parameters ---------- times : np.ndarray, shape=(n,) Sample times of frequencies frequencies : np.ndarray, shape=(n,) frequencies (in Hz) of the pitch contours. Voicing is indicated by sign (positive for voiced, non-positive for non-voiced). ...
[ "Visualize", "pitch", "contours" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L493-L574
train
craffel/mir_eval
mir_eval/display.py
multipitch
def multipitch(times, frequencies, midi=False, unvoiced=False, ax=None, **kwargs): '''Visualize multiple f0 measurements Parameters ---------- times : np.ndarray, shape=(n,) Sample times of frequencies frequencies : list of np.ndarray frequencies (in Hz) of the pitch...
python
def multipitch(times, frequencies, midi=False, unvoiced=False, ax=None, **kwargs): '''Visualize multiple f0 measurements Parameters ---------- times : np.ndarray, shape=(n,) Sample times of frequencies frequencies : list of np.ndarray frequencies (in Hz) of the pitch...
[ "def", "multipitch", "(", "times", ",", "frequencies", ",", "midi", "=", "False", ",", "unvoiced", "=", "False", ",", "ax", "=", "None", ",", "**", "kwargs", ")", ":", "ax", ",", "_", "=", "__get_axes", "(", "ax", "=", "ax", ")", "style_voiced", "=...
Visualize multiple f0 measurements Parameters ---------- times : np.ndarray, shape=(n,) Sample times of frequencies frequencies : list of np.ndarray frequencies (in Hz) of the pitch measurements. Voicing is indicated by sign (positive for voiced, non-positive for non-vo...
[ "Visualize", "multiple", "f0", "measurements" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L577-L666
train
craffel/mir_eval
mir_eval/display.py
piano_roll
def piano_roll(intervals, pitches=None, midi=None, ax=None, **kwargs): '''Plot a quantized piano roll as intervals Parameters ---------- intervals : np.ndarray, shape=(n, 2) timing intervals for notes pitches : np.ndarray, shape=(n,), optional pitches of notes (in Hz). midi : ...
python
def piano_roll(intervals, pitches=None, midi=None, ax=None, **kwargs): '''Plot a quantized piano roll as intervals Parameters ---------- intervals : np.ndarray, shape=(n, 2) timing intervals for notes pitches : np.ndarray, shape=(n,), optional pitches of notes (in Hz). midi : ...
[ "def", "piano_roll", "(", "intervals", ",", "pitches", "=", "None", ",", "midi", "=", "None", ",", "ax", "=", "None", ",", "**", "kwargs", ")", ":", "if", "midi", "is", "None", ":", "if", "pitches", "is", "None", ":", "raise", "ValueError", "(", "'...
Plot a quantized piano roll as intervals Parameters ---------- intervals : np.ndarray, shape=(n, 2) timing intervals for notes pitches : np.ndarray, shape=(n,), optional pitches of notes (in Hz). midi : np.ndarray, shape=(n,), optional pitches of notes (in MIDI numbers). ...
[ "Plot", "a", "quantized", "piano", "roll", "as", "intervals" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L669-L716
train
craffel/mir_eval
mir_eval/display.py
separation
def separation(sources, fs=22050, labels=None, alpha=0.75, ax=None, **kwargs): '''Source-separation visualization Parameters ---------- sources : np.ndarray, shape=(nsrc, nsampl) A list of waveform buffers corresponding to each source fs : number > 0 The sampling rate labels :...
python
def separation(sources, fs=22050, labels=None, alpha=0.75, ax=None, **kwargs): '''Source-separation visualization Parameters ---------- sources : np.ndarray, shape=(nsrc, nsampl) A list of waveform buffers corresponding to each source fs : number > 0 The sampling rate labels :...
[ "def", "separation", "(", "sources", ",", "fs", "=", "22050", ",", "labels", "=", "None", ",", "alpha", "=", "0.75", ",", "ax", "=", "None", ",", "**", "kwargs", ")", ":", "ax", ",", "new_axes", "=", "__get_axes", "(", "ax", "=", "ax", ")", "sour...
Source-separation visualization Parameters ---------- 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 ...
[ "Source", "-", "separation", "visualization" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L719-L803
train
craffel/mir_eval
mir_eval/display.py
__ticker_midi_note
def __ticker_midi_note(x, pos): '''A ticker function for midi notes. Inputs x are interpreted as midi numbers, and converted to [NOTE][OCTAVE]+[cents]. ''' NOTES = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'] cents = float(np.mod(x, 1.0)) if cents >= 0.5: cent...
python
def __ticker_midi_note(x, pos): '''A ticker function for midi notes. Inputs x are interpreted as midi numbers, and converted to [NOTE][OCTAVE]+[cents]. ''' NOTES = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'] cents = float(np.mod(x, 1.0)) if cents >= 0.5: cent...
[ "def", "__ticker_midi_note", "(", "x", ",", "pos", ")", ":", "NOTES", "=", "[", "'C'", ",", "'C#'", ",", "'D'", ",", "'D#'", ",", "'E'", ",", "'F'", ",", "'F#'", ",", "'G'", ",", "'G#'", ",", "'A'", ",", "'A#'", ",", "'B'", "]", "cents", "=", ...
A ticker function for midi notes. Inputs x are interpreted as midi numbers, and converted to [NOTE][OCTAVE]+[cents].
[ "A", "ticker", "function", "for", "midi", "notes", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L806-L826
train
craffel/mir_eval
mir_eval/display.py
ticker_notes
def ticker_notes(ax=None): '''Set the y-axis of the given axes to MIDI notes Parameters ---------- ax : matplotlib.pyplot.axes The axes handle to apply the ticker. By default, uses the current axes handle. ''' ax, _ = __get_axes(ax=ax) ax.yaxis.set_major_formatter(FMT_MIDI...
python
def ticker_notes(ax=None): '''Set the y-axis of the given axes to MIDI notes Parameters ---------- ax : matplotlib.pyplot.axes The axes handle to apply the ticker. By default, uses the current axes handle. ''' ax, _ = __get_axes(ax=ax) ax.yaxis.set_major_formatter(FMT_MIDI...
[ "def", "ticker_notes", "(", "ax", "=", "None", ")", ":", "ax", ",", "_", "=", "__get_axes", "(", "ax", "=", "ax", ")", "ax", ".", "yaxis", ".", "set_major_formatter", "(", "FMT_MIDI_NOTE", ")", "for", "tick", "in", "ax", ".", "yaxis", ".", "get_tickl...
Set the y-axis of the given axes to MIDI notes Parameters ---------- ax : matplotlib.pyplot.axes The axes handle to apply the ticker. By default, uses the current axes handle.
[ "Set", "the", "y", "-", "axis", "of", "the", "given", "axes", "to", "MIDI", "notes" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L839-L854
train
craffel/mir_eval
mir_eval/display.py
ticker_pitch
def ticker_pitch(ax=None): '''Set the y-axis of the given axes to MIDI frequencies Parameters ---------- ax : matplotlib.pyplot.axes The axes handle to apply the ticker. By default, uses the current axes handle. ''' ax, _ = __get_axes(ax=ax) ax.yaxis.set_major_formatter(FMT...
python
def ticker_pitch(ax=None): '''Set the y-axis of the given axes to MIDI frequencies Parameters ---------- ax : matplotlib.pyplot.axes The axes handle to apply the ticker. By default, uses the current axes handle. ''' ax, _ = __get_axes(ax=ax) ax.yaxis.set_major_formatter(FMT...
[ "def", "ticker_pitch", "(", "ax", "=", "None", ")", ":", "ax", ",", "_", "=", "__get_axes", "(", "ax", "=", "ax", ")", "ax", ".", "yaxis", ".", "set_major_formatter", "(", "FMT_MIDI_HZ", ")" ]
Set the y-axis of the given axes to MIDI frequencies Parameters ---------- ax : matplotlib.pyplot.axes The axes handle to apply the ticker. By default, uses the current axes handle.
[ "Set", "the", "y", "-", "axis", "of", "the", "given", "axes", "to", "MIDI", "frequencies" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/display.py#L857-L868
train
CartoDB/carto-python
carto/file_import.py
FileImportJob.run
def run(self, **import_params): """ Actually creates the import job on the CARTO server :param import_params: To be send to the Import API, see CARTO's docs on Import API for an updated list of accepted params :type import_...
python
def run(self, **import_params): """ Actually creates the import job on the CARTO server :param import_params: To be send to the Import API, see CARTO's docs on Import API for an updated list of accepted params :type import_...
[ "def", "run", "(", "self", ",", "**", "import_params", ")", ":", "if", "self", ".", "file", ":", "import_params", "[", "\"url\"", "]", "=", "self", ".", "file", "self", ".", "id_field", "=", "\"id\"", "if", "\"connection\"", "in", "import_params", ":", ...
Actually creates the import job on the CARTO server :param import_params: To be send to the Import API, see CARTO's docs on Import API for an updated list of accepted params :type import_params: kwargs :return: .. note:: ...
[ "Actually", "creates", "the", "import", "job", "on", "the", "CARTO", "server" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/file_import.py#L79-L103
train
CartoDB/carto-python
carto/file_import.py
FileImportJobManager.filter
def filter(self): """ Get a filtered list of file imports :return: A list of file imports, with only the id set (you need to refresh them if you want all the attributes to be filled in) :rtype: list of :class:`carto.file_import.FileImportJob` :raise: CartoExcept...
python
def filter(self): """ Get a filtered list of file imports :return: A list of file imports, with only the id set (you need to refresh them if you want all the attributes to be filled in) :rtype: list of :class:`carto.file_import.FileImportJob` :raise: CartoExcept...
[ "def", "filter", "(", "self", ")", ":", "try", ":", "response", "=", "self", ".", "send", "(", "self", ".", "get_collection_endpoint", "(", ")", ",", "\"get\"", ")", "if", "self", ".", "json_collection_attribute", "is", "not", "None", ":", "resource_ids", ...
Get a filtered list of file imports :return: A list of file imports, with only the id set (you need to refresh them if you want all the attributes to be filled in) :rtype: list of :class:`carto.file_import.FileImportJob` :raise: CartoException
[ "Get", "a", "filtered", "list", "of", "file", "imports" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/file_import.py#L117-L150
train
CartoDB/carto-python
carto/auth.py
APIKeyAuthClient.send
def send(self, relative_path, http_method, **requests_args): """ Makes an API-key-authorized request :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kwargs to be sent to requests :type relative_path: str ...
python
def send(self, relative_path, http_method, **requests_args): """ Makes an API-key-authorized request :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kwargs to be sent to requests :type relative_path: str ...
[ "def", "send", "(", "self", ",", "relative_path", ",", "http_method", ",", "**", "requests_args", ")", ":", "try", ":", "http_method", ",", "requests_args", "=", "self", ".", "prepare_send", "(", "http_method", ",", "**", "requests_args", ")", "response", "=...
Makes an API-key-authorized request :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kwargs to be sent to requests :type relative_path: str :type http_method: str :type requests_args: kwargs :return: ...
[ "Makes", "an", "API", "-", "key", "-", "authorized", "request" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/auth.py#L128-L154
train
CartoDB/carto-python
carto/auth.py
AuthAPIClient.is_valid_api_key
def is_valid_api_key(self): """ Checks validity. Right now, an API key is considered valid if it can list user API keys and the result contains that API key. This might change in the future. :return: True if the API key is considered valid for current user. """ r...
python
def is_valid_api_key(self): """ Checks validity. Right now, an API key is considered valid if it can list user API keys and the result contains that API key. This might change in the future. :return: True if the API key is considered valid for current user. """ r...
[ "def", "is_valid_api_key", "(", "self", ")", ":", "res", "=", "self", ".", "send", "(", "'api/v3/api_keys'", ",", "'get'", ")", "return", "res", ".", "ok", "and", "self", ".", "api_key", "in", "(", "ak", "[", "'token'", "]", "for", "ak", "in", "res",...
Checks validity. Right now, an API key is considered valid if it can list user API keys and the result contains that API key. This might change in the future. :return: True if the API key is considered valid for current user.
[ "Checks", "validity", ".", "Right", "now", "an", "API", "key", "is", "considered", "valid", "if", "it", "can", "list", "user", "API", "keys", "and", "the", "result", "contains", "that", "API", "key", ".", "This", "might", "change", "in", "the", "future",...
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/auth.py#L262-L273
train
CartoDB/carto-python
carto/datasets.py
DatasetManager.send
def send(self, url, http_method, **client_args): """ Sends an API request, taking into account that datasets are part of the visualization endpoint. :param url: Endpoint URL :param http_method: The method used to make the request to the API :param client_args: Arguments ...
python
def send(self, url, http_method, **client_args): """ Sends an API request, taking into account that datasets are part of the visualization endpoint. :param url: Endpoint URL :param http_method: The method used to make the request to the API :param client_args: Arguments ...
[ "def", "send", "(", "self", ",", "url", ",", "http_method", ",", "**", "client_args", ")", ":", "try", ":", "client_args", "=", "client_args", "or", "{", "}", "if", "\"params\"", "not", "in", "client_args", ":", "client_args", "[", "\"params\"", "]", "="...
Sends an API request, taking into account that datasets are part of the visualization endpoint. :param url: Endpoint URL :param http_method: The method used to make the request to the API :param client_args: Arguments to be sent to the auth client :type url: str :type ht...
[ "Sends", "an", "API", "request", "taking", "into", "account", "that", "datasets", "are", "part", "of", "the", "visualization", "endpoint", "." ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/datasets.py#L96-L124
train
CartoDB/carto-python
carto/datasets.py
DatasetManager.is_sync_table
def is_sync_table(self, archive, interval, **import_args): """ Checks if this is a request for a sync dataset. The condition for creating a sync dataset is to provide a URL or a connection to an external database and an interval in seconds :param archive: URL to the file (both ...
python
def is_sync_table(self, archive, interval, **import_args): """ Checks if this is a request for a sync dataset. The condition for creating a sync dataset is to provide a URL or a connection to an external database and an interval in seconds :param archive: URL to the file (both ...
[ "def", "is_sync_table", "(", "self", ",", "archive", ",", "interval", ",", "**", "import_args", ")", ":", "return", "(", "hasattr", "(", "archive", ",", "\"startswith\"", ")", "and", "archive", ".", "startswith", "(", "\"http\"", ")", "or", "\"connection\"",...
Checks if this is a request for a sync dataset. The condition for creating a sync dataset is to provide a URL or a connection to an external database and an interval in seconds :param archive: URL to the file (both remote URLs or local paths are supported) or StringIO objec...
[ "Checks", "if", "this", "is", "a", "request", "for", "a", "sync", "dataset", "." ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/datasets.py#L126-L146
train
CartoDB/carto-python
carto/datasets.py
DatasetManager.create
def create(self, archive, interval=None, **import_args): """ Creating a table means uploading a file or setting up a sync table :param archive: URL to the file (both remote URLs or local paths are supported) or StringIO object :param interval: Interval in seconds. ...
python
def create(self, archive, interval=None, **import_args): """ Creating a table means uploading a file or setting up a sync table :param archive: URL to the file (both remote URLs or local paths are supported) or StringIO object :param interval: Interval in seconds. ...
[ "def", "create", "(", "self", ",", "archive", ",", "interval", "=", "None", ",", "**", "import_args", ")", ":", "archive", "=", "archive", ".", "lower", "(", ")", "if", "hasattr", "(", "archive", ",", "\"lower\"", ")", "else", "archive", "if", "self", ...
Creating a table means uploading a file or setting up a sync table :param archive: URL to the file (both remote URLs or local paths are supported) or StringIO object :param interval: Interval in seconds. If not None, CARTO will try to set up a sync table ...
[ "Creating", "a", "table", "means", "uploading", "a", "file", "or", "setting", "up", "a", "sync", "table" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/datasets.py#L148-L222
train
CartoDB/carto-python
carto/visualizations.py
VisualizationManager.send
def send(self, url, http_method, **client_args): """ Sends API request, taking into account that visualizations are only a subset of the resources available at the visualization endpoint :param url: Endpoint URL :param http_method: The method used to make the request to the API ...
python
def send(self, url, http_method, **client_args): """ Sends API request, taking into account that visualizations are only a subset of the resources available at the visualization endpoint :param url: Endpoint URL :param http_method: The method used to make the request to the API ...
[ "def", "send", "(", "self", ",", "url", ",", "http_method", ",", "**", "client_args", ")", ":", "try", ":", "client_args", ".", "setdefault", "(", "'params'", ",", "{", "}", ")", "client_args", "[", "\"params\"", "]", ".", "update", "(", "{", "\"type\"...
Sends API request, taking into account that visualizations are only a subset of the resources available at the visualization endpoint :param url: Endpoint URL :param http_method: The method used to make the request to the API :param client_args: Arguments to be sent to the auth client ...
[ "Sends", "API", "request", "taking", "into", "account", "that", "visualizations", "are", "only", "a", "subset", "of", "the", "resources", "available", "at", "the", "visualization", "endpoint" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/visualizations.py#L130-L155
train
CartoDB/carto-python
carto/exceptions.py
CartoRateLimitException.is_rate_limited
def is_rate_limited(response): """ Checks if the response has been rate limited by CARTO APIs :param response: The response rate limited by CARTO APIs :type response: requests.models.Response class :return: Boolean """ if (response.status_code == codes.too_many_...
python
def is_rate_limited(response): """ Checks if the response has been rate limited by CARTO APIs :param response: The response rate limited by CARTO APIs :type response: requests.models.Response class :return: Boolean """ if (response.status_code == codes.too_many_...
[ "def", "is_rate_limited", "(", "response", ")", ":", "if", "(", "response", ".", "status_code", "==", "codes", ".", "too_many_requests", "and", "'Retry-After'", "in", "response", ".", "headers", "and", "int", "(", "response", ".", "headers", "[", "'Retry-After...
Checks if the response has been rate limited by CARTO APIs :param response: The response rate limited by CARTO APIs :type response: requests.models.Response class :return: Boolean
[ "Checks", "if", "the", "response", "has", "been", "rate", "limited", "by", "CARTO", "APIs" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/exceptions.py#L46-L59
train
CartoDB/carto-python
carto/maps.py
NamedMap.update_from_dict
def update_from_dict(self, attribute_dict): """ Method overriden from the base class """ if 'template' in attribute_dict: self.update_from_dict(attribute_dict['template']) setattr(self, self.Meta.id_field, attribute_dict['template']['name']) ...
python
def update_from_dict(self, attribute_dict): """ Method overriden from the base class """ if 'template' in attribute_dict: self.update_from_dict(attribute_dict['template']) setattr(self, self.Meta.id_field, attribute_dict['template']['name']) ...
[ "def", "update_from_dict", "(", "self", ",", "attribute_dict", ")", ":", "if", "'template'", "in", "attribute_dict", ":", "self", ".", "update_from_dict", "(", "attribute_dict", "[", "'template'", "]", ")", "setattr", "(", "self", ",", "self", ".", "Meta", "...
Method overriden from the base class
[ "Method", "overriden", "from", "the", "base", "class" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/maps.py#L165-L179
train
CartoDB/carto-python
carto/resources.py
AsyncResource.run
def run(self, **client_params): """ Actually creates the async job on the CARTO server :param client_params: To be send to the CARTO API. See CARTO's documentation depending on the subclass you are using :type client_param...
python
def run(self, **client_params): """ Actually creates the async job on the CARTO server :param client_params: To be send to the CARTO API. See CARTO's documentation depending on the subclass you are using :type client_param...
[ "def", "run", "(", "self", ",", "**", "client_params", ")", ":", "try", ":", "self", ".", "send", "(", "self", ".", "get_collection_endpoint", "(", ")", ",", "http_method", "=", "\"POST\"", ",", "**", "client_params", ")", "except", "Exception", "as", "e...
Actually creates the async job on the CARTO server :param client_params: To be send to the CARTO API. See CARTO's documentation depending on the subclass you are using :type client_params: kwargs :return: :raise: CartoEx...
[ "Actually", "creates", "the", "async", "job", "on", "the", "CARTO", "server" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/resources.py#L22-L41
train
CartoDB/carto-python
carto/sql.py
SQLClient.send
def send(self, sql, parse_json=True, do_post=True, format=None, **request_args): """ Executes SQL query in a CARTO server :param sql: The SQL :param parse_json: Set it to False if you want raw reponse :param do_post: Set it to True to force post request :param format: An...
python
def send(self, sql, parse_json=True, do_post=True, format=None, **request_args): """ Executes SQL query in a CARTO server :param sql: The SQL :param parse_json: Set it to False if you want raw reponse :param do_post: Set it to True to force post request :param format: An...
[ "def", "send", "(", "self", ",", "sql", ",", "parse_json", "=", "True", ",", "do_post", "=", "True", ",", "format", "=", "None", ",", "**", "request_args", ")", ":", "try", ":", "params", "=", "{", "'q'", ":", "sql", "}", "if", "format", ":", "pa...
Executes SQL query in a CARTO server :param sql: The SQL :param parse_json: Set it to False if you want raw reponse :param do_post: Set it to True to force post request :param format: Any of the data export formats allowed by CARTO's SQL API :param reques...
[ "Executes", "SQL", "query", "in", "a", "CARTO", "server" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L70-L114
train
CartoDB/carto-python
carto/sql.py
BatchSQLClient.send
def send(self, url, http_method, json_body=None, http_header=None): """ Executes Batch SQL query in a CARTO server :param url: Endpoint url :param http_method: The method used to make the request to the API :param json_body: The information that needs to be sent, by default ...
python
def send(self, url, http_method, json_body=None, http_header=None): """ Executes Batch SQL query in a CARTO server :param url: Endpoint url :param http_method: The method used to make the request to the API :param json_body: The information that needs to be sent, by default ...
[ "def", "send", "(", "self", ",", "url", ",", "http_method", ",", "json_body", "=", "None", ",", "http_header", "=", "None", ")", ":", "try", ":", "data", "=", "self", ".", "client", ".", "send", "(", "url", ",", "http_method", "=", "http_method", ","...
Executes Batch SQL query in a CARTO server :param url: Endpoint url :param http_method: The method used to make the request to the API :param json_body: The information that needs to be sent, by default is set to None :param http_header: The header used to ma...
[ "Executes", "Batch", "SQL", "query", "in", "a", "CARTO", "server" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L149-L180
train
CartoDB/carto-python
carto/sql.py
BatchSQLClient.create
def create(self, sql_query): """ Creates a new batch SQL query. Batch SQL jobs are asynchronous, once created you should call :func:`carto.sql.BatchSQLClient.read` method given the `job_id` to retrieve the state of the batch query :param sql_query: The SQL query to be u...
python
def create(self, sql_query): """ Creates a new batch SQL query. Batch SQL jobs are asynchronous, once created you should call :func:`carto.sql.BatchSQLClient.read` method given the `job_id` to retrieve the state of the batch query :param sql_query: The SQL query to be u...
[ "def", "create", "(", "self", ",", "sql_query", ")", ":", "header", "=", "{", "'content-type'", ":", "'application/json'", "}", "data", "=", "self", ".", "send", "(", "self", ".", "api_url", ",", "http_method", "=", "\"POST\"", ",", "json_body", "=", "{"...
Creates a new batch SQL query. Batch SQL jobs are asynchronous, once created you should call :func:`carto.sql.BatchSQLClient.read` method given the `job_id` to retrieve the state of the batch query :param sql_query: The SQL query to be used :type sql_query: str or list of str ...
[ "Creates", "a", "new", "batch", "SQL", "query", "." ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L182-L204
train
CartoDB/carto-python
carto/sql.py
BatchSQLClient.create_and_wait_for_completion
def create_and_wait_for_completion(self, sql_query): """ Creates a new batch SQL query and waits for its completion or failure Batch SQL jobs are asynchronous, once created this method automatically queries the job status until it's one of 'done', 'failed', 'canceled', 'unknown'...
python
def create_and_wait_for_completion(self, sql_query): """ Creates a new batch SQL query and waits for its completion or failure Batch SQL jobs are asynchronous, once created this method automatically queries the job status until it's one of 'done', 'failed', 'canceled', 'unknown'...
[ "def", "create_and_wait_for_completion", "(", "self", ",", "sql_query", ")", ":", "header", "=", "{", "'content-type'", ":", "'application/json'", "}", "data", "=", "self", ".", "send", "(", "self", ".", "api_url", ",", "http_method", "=", "\"POST\"", ",", "...
Creates a new batch SQL query and waits for its completion or failure Batch SQL jobs are asynchronous, once created this method automatically queries the job status until it's one of 'done', 'failed', 'canceled', 'unknown' :param sql_query: The SQL query to be used :type sql_qu...
[ "Creates", "a", "new", "batch", "SQL", "query", "and", "waits", "for", "its", "completion", "or", "failure" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L206-L238
train
CartoDB/carto-python
carto/sql.py
BatchSQLClient.read
def read(self, job_id): """ Reads the information for a specific Batch API request :param job_id: The id of the job to be read from :type job_id: str :return: Response data, either as json or as a regular response.content object :rtype: object ...
python
def read(self, job_id): """ Reads the information for a specific Batch API request :param job_id: The id of the job to be read from :type job_id: str :return: Response data, either as json or as a regular response.content object :rtype: object ...
[ "def", "read", "(", "self", ",", "job_id", ")", ":", "data", "=", "self", ".", "send", "(", "self", ".", "api_url", "+", "job_id", ",", "http_method", "=", "\"GET\"", ")", "return", "data" ]
Reads the information for a specific Batch API request :param job_id: The id of the job to be read from :type job_id: str :return: Response data, either as json or as a regular response.content object :rtype: object :raise: CartoException
[ "Reads", "the", "information", "for", "a", "specific", "Batch", "API", "request" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L240-L254
train
CartoDB/carto-python
carto/sql.py
BatchSQLClient.update
def update(self, job_id, sql_query): """ Updates the sql query of a specific job :param job_id: The id of the job to be updated :param sql_query: The new SQL query for the job :type job_id: str :type sql_query: str :return: Response data, either as json or as a ...
python
def update(self, job_id, sql_query): """ Updates the sql query of a specific job :param job_id: The id of the job to be updated :param sql_query: The new SQL query for the job :type job_id: str :type sql_query: str :return: Response data, either as json or as a ...
[ "def", "update", "(", "self", ",", "job_id", ",", "sql_query", ")", ":", "header", "=", "{", "'content-type'", ":", "'application/json'", "}", "data", "=", "self", ".", "send", "(", "self", ".", "api_url", "+", "job_id", ",", "http_method", "=", "\"PUT\"...
Updates the sql query of a specific job :param job_id: The id of the job to be updated :param sql_query: The new SQL query for the job :type job_id: str :type sql_query: str :return: Response data, either as json or as a regular response.content object ...
[ "Updates", "the", "sql", "query", "of", "a", "specific", "job" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L256-L276
train
CartoDB/carto-python
carto/sql.py
BatchSQLClient.cancel
def cancel(self, job_id): """ Cancels a job :param job_id: The id of the job to be cancelled :type job_id: str :return: A status code depending on whether the cancel request was successful :rtype: str :raise CartoException: """ ...
python
def cancel(self, job_id): """ Cancels a job :param job_id: The id of the job to be cancelled :type job_id: str :return: A status code depending on whether the cancel request was successful :rtype: str :raise CartoException: """ ...
[ "def", "cancel", "(", "self", ",", "job_id", ")", ":", "try", ":", "confirmation", "=", "self", ".", "send", "(", "self", ".", "api_url", "+", "job_id", ",", "http_method", "=", "\"DELETE\"", ")", "except", "CartoException", "as", "e", ":", "if", "'Can...
Cancels a job :param job_id: The id of the job to be cancelled :type job_id: str :return: A status code depending on whether the cancel request was successful :rtype: str :raise CartoException:
[ "Cancels", "a", "job" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L278-L298
train
CartoDB/carto-python
carto/sql.py
CopySQLClient.copyfrom
def copyfrom(self, query, iterable_data, compress=True, compression_level=DEFAULT_COMPRESSION_LEVEL): """ Gets data from an iterable object into a table :param query: The "COPY table_name [(column_name[, ...])] FROM STDIN [WITH(option[,...])]" query t...
python
def copyfrom(self, query, iterable_data, compress=True, compression_level=DEFAULT_COMPRESSION_LEVEL): """ Gets data from an iterable object into a table :param query: The "COPY table_name [(column_name[, ...])] FROM STDIN [WITH(option[,...])]" query t...
[ "def", "copyfrom", "(", "self", ",", "query", ",", "iterable_data", ",", "compress", "=", "True", ",", "compression_level", "=", "DEFAULT_COMPRESSION_LEVEL", ")", ":", "url", "=", "self", ".", "api_url", "+", "'/copyfrom'", "headers", "=", "{", "'Content-Type'...
Gets data from an iterable object into a table :param query: The "COPY table_name [(column_name[, ...])] FROM STDIN [WITH(option[,...])]" query to execute :type query: str :param iterable_data: An object that can be iterated to retrieve ...
[ "Gets", "data", "from", "an", "iterable", "object", "into", "a", "table" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L341-L386
train
CartoDB/carto-python
carto/sql.py
CopySQLClient.copyfrom_file_object
def copyfrom_file_object(self, query, file_object, compress=True, compression_level=DEFAULT_COMPRESSION_LEVEL): """ Gets data from a readable file object into a table :param query: The "COPY table_name [(column_name[, ...])] FROM STDIN [WI...
python
def copyfrom_file_object(self, query, file_object, compress=True, compression_level=DEFAULT_COMPRESSION_LEVEL): """ Gets data from a readable file object into a table :param query: The "COPY table_name [(column_name[, ...])] FROM STDIN [WI...
[ "def", "copyfrom_file_object", "(", "self", ",", "query", ",", "file_object", ",", "compress", "=", "True", ",", "compression_level", "=", "DEFAULT_COMPRESSION_LEVEL", ")", ":", "chunk_generator", "=", "self", ".", "_read_in_chunks", "(", "file_object", ")", "retu...
Gets data from a readable file object into a table :param query: The "COPY table_name [(column_name[, ...])] FROM STDIN [WITH(option[,...])]" query to execute :type query: str :param file_object: A file-like object. Normally the return val...
[ "Gets", "data", "from", "a", "readable", "file", "object", "into", "a", "table" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L388-L408
train
CartoDB/carto-python
carto/sql.py
CopySQLClient.copyfrom_file_path
def copyfrom_file_path(self, query, path, compress=True, compression_level=DEFAULT_COMPRESSION_LEVEL): """ Gets data from a readable file into a table :param query: The "COPY table_name [(column_name[, ...])] FROM STDIN [WITH(option[,...])]"...
python
def copyfrom_file_path(self, query, path, compress=True, compression_level=DEFAULT_COMPRESSION_LEVEL): """ Gets data from a readable file into a table :param query: The "COPY table_name [(column_name[, ...])] FROM STDIN [WITH(option[,...])]"...
[ "def", "copyfrom_file_path", "(", "self", ",", "query", ",", "path", ",", "compress", "=", "True", ",", "compression_level", "=", "DEFAULT_COMPRESSION_LEVEL", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "result", "=", "self", ...
Gets data from a readable file into a table :param query: The "COPY table_name [(column_name[, ...])] FROM STDIN [WITH(option[,...])]" query to execute :type query: str :param path: A path to a file :type path: str :return: Response data as json ...
[ "Gets", "data", "from", "a", "readable", "file", "into", "a", "table" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L410-L430
train
CartoDB/carto-python
carto/sql.py
CopySQLClient.copyto
def copyto(self, query): """ Gets data from a table into a Response object that can be iterated :param query: The "COPY { table_name [(column_name[, ...])] | (query) } TO STDOUT [WITH(option[,...])]" query to execute :type query: str :return: response...
python
def copyto(self, query): """ Gets data from a table into a Response object that can be iterated :param query: The "COPY { table_name [(column_name[, ...])] | (query) } TO STDOUT [WITH(option[,...])]" query to execute :type query: str :return: response...
[ "def", "copyto", "(", "self", ",", "query", ")", ":", "url", "=", "self", ".", "api_url", "+", "'/copyto'", "params", "=", "{", "'api_key'", ":", "self", ".", "api_key", ",", "'q'", ":", "query", "}", "try", ":", "response", "=", "self", ".", "clie...
Gets data from a table into a Response object that can be iterated :param query: The "COPY { table_name [(column_name[, ...])] | (query) } TO STDOUT [WITH(option[,...])]" query to execute :type query: str :return: response object :rtype: Response :ra...
[ "Gets", "data", "from", "a", "table", "into", "a", "Response", "object", "that", "can", "be", "iterated" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L432-L468
train
CartoDB/carto-python
carto/sql.py
CopySQLClient.copyto_file_object
def copyto_file_object(self, query, file_object): """ Gets data from a table into a writable file object :param query: The "COPY { table_name [(column_name[, ...])] | (query) } TO STDOUT [WITH(option[,...])]" query to execute :type query: str :param f...
python
def copyto_file_object(self, query, file_object): """ Gets data from a table into a writable file object :param query: The "COPY { table_name [(column_name[, ...])] | (query) } TO STDOUT [WITH(option[,...])]" query to execute :type query: str :param f...
[ "def", "copyto_file_object", "(", "self", ",", "query", ",", "file_object", ")", ":", "response", "=", "self", ".", "copyto", "(", "query", ")", "for", "block", "in", "response", ".", "iter_content", "(", "DEFAULT_CHUNK_SIZE", ")", ":", "file_object", ".", ...
Gets data from a table into a writable file object :param query: The "COPY { table_name [(column_name[, ...])] | (query) } TO STDOUT [WITH(option[,...])]" query to execute :type query: str :param file_object: A file-like object. Normally t...
[ "Gets", "data", "from", "a", "table", "into", "a", "writable", "file", "object" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L470-L486
train
CartoDB/carto-python
carto/sql.py
CopySQLClient.copyto_file_path
def copyto_file_path(self, query, path, append=False): """ Gets data from a table into a writable file :param query: The "COPY { table_name [(column_name[, ...])] | (query) } TO STDOUT [WITH(option[,...])]" query to execute :type query: str :param pat...
python
def copyto_file_path(self, query, path, append=False): """ Gets data from a table into a writable file :param query: The "COPY { table_name [(column_name[, ...])] | (query) } TO STDOUT [WITH(option[,...])]" query to execute :type query: str :param pat...
[ "def", "copyto_file_path", "(", "self", ",", "query", ",", "path", ",", "append", "=", "False", ")", ":", "file_mode", "=", "'wb'", "if", "not", "append", "else", "'ab'", "with", "open", "(", "path", ",", "file_mode", ")", "as", "f", ":", "self", "."...
Gets data from a table into a writable file :param query: The "COPY { table_name [(column_name[, ...])] | (query) } TO STDOUT [WITH(option[,...])]" query to execute :type query: str :param path: A path to a writable file :type path: str :param append...
[ "Gets", "data", "from", "a", "table", "into", "a", "writable", "file" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sql.py#L488-L507
train
CartoDB/carto-python
carto/sync_tables.py
SyncTableJob.run
def run(self, **import_params): """ Actually creates the job import on the CARTO server :param import_params: To be send to the Import API, see CARTO's docs on Import API for an updated list of accepted params :type import_...
python
def run(self, **import_params): """ Actually creates the job import on the CARTO server :param import_params: To be send to the Import API, see CARTO's docs on Import API for an updated list of accepted params :type import_...
[ "def", "run", "(", "self", ",", "**", "import_params", ")", ":", "import_params", "[", "\"url\"", "]", "=", "self", ".", "url", "import_params", "[", "\"interval\"", "]", "=", "self", ".", "interval", "if", "\"connection\"", "in", "import_params", ":", "se...
Actually creates the job import on the CARTO server :param import_params: To be send to the Import API, see CARTO's docs on Import API for an updated list of accepted params :type import_params: kwargs :return: .. note:: ...
[ "Actually", "creates", "the", "job", "import", "on", "the", "CARTO", "server" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sync_tables.py#L84-L106
train
CartoDB/carto-python
carto/sync_tables.py
SyncTableJob.force_sync
def force_sync(self): """ Forces to sync the SyncTableJob :return: :raise: CartoException """ try: self.send(self.get_resource_endpoint(), "put") except Exception as e: raise CartoException(e)
python
def force_sync(self): """ Forces to sync the SyncTableJob :return: :raise: CartoException """ try: self.send(self.get_resource_endpoint(), "put") except Exception as e: raise CartoException(e)
[ "def", "force_sync", "(", "self", ")", ":", "try", ":", "self", ".", "send", "(", "self", ".", "get_resource_endpoint", "(", ")", ",", "\"put\"", ")", "except", "Exception", "as", "e", ":", "raise", "CartoException", "(", "e", ")" ]
Forces to sync the SyncTableJob :return: :raise: CartoException
[ "Forces", "to", "sync", "the", "SyncTableJob" ]
f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/sync_tables.py#L118-L129
train
ikki407/stacking
stacking/base.py
BaseModel.set_prob_type
def set_prob_type(cls, problem_type, classification_type, eval_type): """ Set problem type """ assert problem_type in problem_type_list, 'Need to set Problem Type' if problem_type == 'classification': assert classification_type in classification_type_list,\ ...
python
def set_prob_type(cls, problem_type, classification_type, eval_type): """ Set problem type """ assert problem_type in problem_type_list, 'Need to set Problem Type' if problem_type == 'classification': assert classification_type in classification_type_list,\ ...
[ "def", "set_prob_type", "(", "cls", ",", "problem_type", ",", "classification_type", ",", "eval_type", ")", ":", "assert", "problem_type", "in", "problem_type_list", ",", "'Need to set Problem Type'", "if", "problem_type", "==", "'classification'", ":", "assert", "cla...
Set problem type
[ "Set", "problem", "type" ]
105073598fd4f9481212d9db9dea92559d9a9d5a
https://github.com/ikki407/stacking/blob/105073598fd4f9481212d9db9dea92559d9a9d5a/stacking/base.py#L280-L301
train
ikki407/stacking
stacking/base.py
BaseModel.make_multi_cols
def make_multi_cols(self, num_class, name): '''make cols for multi-class predictions''' cols = ['c' + str(i) + '_' for i in xrange(num_class)] cols = map(lambda x: x + name, cols) return cols
python
def make_multi_cols(self, num_class, name): '''make cols for multi-class predictions''' cols = ['c' + str(i) + '_' for i in xrange(num_class)] cols = map(lambda x: x + name, cols) return cols
[ "def", "make_multi_cols", "(", "self", ",", "num_class", ",", "name", ")", ":", "cols", "=", "[", "'c'", "+", "str", "(", "i", ")", "+", "'_'", "for", "i", "in", "xrange", "(", "num_class", ")", "]", "cols", "=", "map", "(", "lambda", "x", ":", ...
make cols for multi-class predictions
[ "make", "cols", "for", "multi", "-", "class", "predictions" ]
105073598fd4f9481212d9db9dea92559d9a9d5a
https://github.com/ikki407/stacking/blob/105073598fd4f9481212d9db9dea92559d9a9d5a/stacking/base.py#L308-L312
train
clalancette/pycdlib
pycdlib/path_table_record.py
PathTableRecord.parse
def parse(self, data): # type: (bytes) -> None ''' A method to parse an ISO9660 Path Table Record out of a string. Parameters: data - The string to parse. Returns: Nothing. ''' (self.len_di, self.xattr_length, self.extent_location, self...
python
def parse(self, data): # type: (bytes) -> None ''' A method to parse an ISO9660 Path Table Record out of a string. Parameters: data - The string to parse. Returns: Nothing. ''' (self.len_di, self.xattr_length, self.extent_location, self...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "(", "self", ".", "len_di", ",", "self", ".", "xattr_length", ",", "self", ".", "extent_location", ",", "self", ".", "parent_directory_num", ")", "=", "struct", ".", "unpack_from", "(", "self", ".", "...
A method to parse an ISO9660 Path Table Record out of a string. Parameters: data - The string to parse. Returns: Nothing.
[ "A", "method", "to", "parse", "an", "ISO9660", "Path", "Table", "Record", "out", "of", "a", "string", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/path_table_record.py#L46-L64
train
clalancette/pycdlib
pycdlib/path_table_record.py
PathTableRecord._record
def _record(self, ext_loc, parent_dir_num): # type: (int, int) -> bytes ''' An internal method to generate a string representing this Path Table Record. Parameters: ext_loc - The extent location to place in this Path Table Record. parent_dir_num - The parent directory ...
python
def _record(self, ext_loc, parent_dir_num): # type: (int, int) -> bytes ''' An internal method to generate a string representing this Path Table Record. Parameters: ext_loc - The extent location to place in this Path Table Record. parent_dir_num - The parent directory ...
[ "def", "_record", "(", "self", ",", "ext_loc", ",", "parent_dir_num", ")", ":", "return", "struct", ".", "pack", "(", "self", ".", "FMT", ",", "self", ".", "len_di", ",", "self", ".", "xattr_length", ",", "ext_loc", ",", "parent_dir_num", ")", "+", "se...
An internal method to generate a string representing this Path Table Record. Parameters: ext_loc - The extent location to place in this Path Table Record. parent_dir_num - The parent directory number to place in this Path Table Record. Returns: A str...
[ "An", "internal", "method", "to", "generate", "a", "string", "representing", "this", "Path", "Table", "Record", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/path_table_record.py#L66-L79
train
clalancette/pycdlib
pycdlib/path_table_record.py
PathTableRecord.record_little_endian
def record_little_endian(self): # type: () -> bytes ''' A method to generate a string representing the little endian version of this Path Table Record. Parameters: None. Returns: A string representing the little endian version of this Path Table Record....
python
def record_little_endian(self): # type: () -> bytes ''' A method to generate a string representing the little endian version of this Path Table Record. Parameters: None. Returns: A string representing the little endian version of this Path Table Record....
[ "def", "record_little_endian", "(", "self", ")", ":", "if", "not", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'Path Table Record not yet initialized'", ")", "return", "self", ".", "_record", "(", "self", ".", ...
A method to generate a string representing the little endian version of this Path Table Record. Parameters: None. Returns: A string representing the little endian version of this Path Table Record.
[ "A", "method", "to", "generate", "a", "string", "representing", "the", "little", "endian", "version", "of", "this", "Path", "Table", "Record", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/path_table_record.py#L81-L95
train
clalancette/pycdlib
pycdlib/path_table_record.py
PathTableRecord.record_big_endian
def record_big_endian(self): # type: () -> bytes ''' A method to generate a string representing the big endian version of this Path Table Record. Parameters: None. Returns: A string representing the big endian version of this Path Table Record. ...
python
def record_big_endian(self): # type: () -> bytes ''' A method to generate a string representing the big endian version of this Path Table Record. Parameters: None. Returns: A string representing the big endian version of this Path Table Record. ...
[ "def", "record_big_endian", "(", "self", ")", ":", "if", "not", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'Path Table Record not yet initialized'", ")", "return", "self", ".", "_record", "(", "utils", ".", "s...
A method to generate a string representing the big endian version of this Path Table Record. Parameters: None. Returns: A string representing the big endian version of this Path Table Record.
[ "A", "method", "to", "generate", "a", "string", "representing", "the", "big", "endian", "version", "of", "this", "Path", "Table", "Record", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/path_table_record.py#L97-L112
train
clalancette/pycdlib
pycdlib/path_table_record.py
PathTableRecord._new
def _new(self, name, parent_dir_num): # type: (bytes, int) -> None ''' An internal method to create a new Path Table Record. Parameters: name - The name for this Path Table Record. parent_dir_num - The directory number of the parent of this Path Table ...
python
def _new(self, name, parent_dir_num): # type: (bytes, int) -> None ''' An internal method to create a new Path Table Record. Parameters: name - The name for this Path Table Record. parent_dir_num - The directory number of the parent of this Path Table ...
[ "def", "_new", "(", "self", ",", "name", ",", "parent_dir_num", ")", ":", "self", ".", "len_di", "=", "len", "(", "name", ")", "self", ".", "xattr_length", "=", "0", "self", ".", "parent_directory_num", "=", "parent_dir_num", "self", ".", "directory_identi...
An internal method to create a new Path Table Record. Parameters: name - The name for this Path Table Record. parent_dir_num - The directory number of the parent of this Path Table Record. Returns: Nothing.
[ "An", "internal", "method", "to", "create", "a", "new", "Path", "Table", "Record", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/path_table_record.py#L127-L143
train
clalancette/pycdlib
pycdlib/path_table_record.py
PathTableRecord.new_dir
def new_dir(self, name): # type: (bytes) -> None ''' A method to create a new Path Table Record. Parameters: name - The name for this Path Table Record. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibIntern...
python
def new_dir(self, name): # type: (bytes) -> None ''' A method to create a new Path Table Record. Parameters: name - The name for this Path Table Record. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibIntern...
[ "def", "new_dir", "(", "self", ",", "name", ")", ":", "if", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'Path Table Record already initialized'", ")", "self", ".", "_new", "(", "name", ",", "0", ")" ]
A method to create a new Path Table Record. Parameters: name - The name for this Path Table Record. Returns: Nothing.
[ "A", "method", "to", "create", "a", "new", "Path", "Table", "Record", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/path_table_record.py#L160-L174
train
clalancette/pycdlib
pycdlib/path_table_record.py
PathTableRecord.update_extent_location
def update_extent_location(self, extent_loc): # type: (int) -> None ''' A method to update the extent location for this Path Table Record. Parameters: extent_loc - The new extent location. Returns: Nothing. ''' if not self._initialized: ...
python
def update_extent_location(self, extent_loc): # type: (int) -> None ''' A method to update the extent location for this Path Table Record. Parameters: extent_loc - The new extent location. Returns: Nothing. ''' if not self._initialized: ...
[ "def", "update_extent_location", "(", "self", ",", "extent_loc", ")", ":", "if", "not", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'Path Table Record not yet initialized'", ")", "self", ".", "extent_location", "="...
A method to update the extent location for this Path Table Record. Parameters: extent_loc - The new extent location. Returns: Nothing.
[ "A", "method", "to", "update", "the", "extent", "location", "for", "this", "Path", "Table", "Record", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/path_table_record.py#L176-L189
train
clalancette/pycdlib
pycdlib/path_table_record.py
PathTableRecord.update_parent_directory_number
def update_parent_directory_number(self, parent_dir_num): # type: (int) -> None ''' A method to update the parent directory number for this Path Table Record from the directory record. Parameters: parent_dir_num - The new parent directory number to assign to this PTR. ...
python
def update_parent_directory_number(self, parent_dir_num): # type: (int) -> None ''' A method to update the parent directory number for this Path Table Record from the directory record. Parameters: parent_dir_num - The new parent directory number to assign to this PTR. ...
[ "def", "update_parent_directory_number", "(", "self", ",", "parent_dir_num", ")", ":", "if", "not", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'Path Table Record not yet initialized'", ")", "self", ".", "parent_dire...
A method to update the parent directory number for this Path Table Record from the directory record. Parameters: parent_dir_num - The new parent directory number to assign to this PTR. Returns: Nothing.
[ "A", "method", "to", "update", "the", "parent", "directory", "number", "for", "this", "Path", "Table", "Record", "from", "the", "directory", "record", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/path_table_record.py#L191-L204
train
clalancette/pycdlib
pycdlib/path_table_record.py
PathTableRecord.equal_to_be
def equal_to_be(self, be_record): # type: (PathTableRecord) -> bool ''' A method to compare a little-endian path table record to its big-endian counterpart. This is used to ensure that the ISO is sane. Parameters: be_record - The big-endian object to compare with the l...
python
def equal_to_be(self, be_record): # type: (PathTableRecord) -> bool ''' A method to compare a little-endian path table record to its big-endian counterpart. This is used to ensure that the ISO is sane. Parameters: be_record - The big-endian object to compare with the l...
[ "def", "equal_to_be", "(", "self", ",", "be_record", ")", ":", "if", "not", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'This Path Table Record is not yet initialized'", ")", "if", "be_record", ".", "len_di", "!=...
A method to compare a little-endian path table record to its big-endian counterpart. This is used to ensure that the ISO is sane. Parameters: be_record - The big-endian object to compare with the little-endian object. Returns: True if this record is equal...
[ "A", "method", "to", "compare", "a", "little", "-", "endian", "path", "table", "record", "to", "its", "big", "-", "endian", "counterpart", ".", "This", "is", "used", "to", "ensure", "that", "the", "ISO", "is", "sane", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/path_table_record.py#L206-L228
train
clalancette/pycdlib
pycdlib/utils.py
copy_data
def copy_data(data_length, blocksize, infp, outfp): # type: (int, int, BinaryIO, BinaryIO) -> None ''' A utility function to copy data from the input file object to the output file object. This function will use the most efficient copy method available, which is often sendfile. Parameters: ...
python
def copy_data(data_length, blocksize, infp, outfp): # type: (int, int, BinaryIO, BinaryIO) -> None ''' A utility function to copy data from the input file object to the output file object. This function will use the most efficient copy method available, which is often sendfile. Parameters: ...
[ "def", "copy_data", "(", "data_length", ",", "blocksize", ",", "infp", ",", "outfp", ")", ":", "use_sendfile", "=", "False", "if", "have_sendfile", ":", "try", ":", "x_unused", "=", "infp", ".", "fileno", "(", ")", "y_unused", "=", "outfp", ".", "fileno"...
A utility function to copy data from the input file object to the output file object. This function will use the most efficient copy method available, which is often sendfile. Parameters: data_length - The amount of data to copy. blocksize - How much data to copy per iteration. infp - The f...
[ "A", "utility", "function", "to", "copy", "data", "from", "the", "input", "file", "object", "to", "the", "output", "file", "object", ".", "This", "function", "will", "use", "the", "most", "efficient", "copy", "method", "available", "which", "is", "often", ...
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/utils.py#L93-L151
train
clalancette/pycdlib
pycdlib/utils.py
encode_space_pad
def encode_space_pad(instr, length, encoding): # type: (bytes, int, str) -> bytes ''' A function to pad out an input string with spaces to the length specified. The space is first encoded into the specified encoding, then appended to the input string until the length is reached. Parameters: ...
python
def encode_space_pad(instr, length, encoding): # type: (bytes, int, str) -> bytes ''' A function to pad out an input string with spaces to the length specified. The space is first encoded into the specified encoding, then appended to the input string until the length is reached. Parameters: ...
[ "def", "encode_space_pad", "(", "instr", ",", "length", ",", "encoding", ")", ":", "output", "=", "instr", ".", "decode", "(", "'utf-8'", ")", ".", "encode", "(", "encoding", ")", "if", "len", "(", "output", ")", ">", "length", ":", "raise", "pycdlibex...
A function to pad out an input string with spaces to the length specified. The space is first encoded into the specified encoding, then appended to the input string until the length is reached. Parameters: instr - The input string to encode and pad. length - The length to pad the input string to....
[ "A", "function", "to", "pad", "out", "an", "input", "string", "with", "spaces", "to", "the", "length", "specified", ".", "The", "space", "is", "first", "encoded", "into", "the", "specified", "encoding", "then", "appended", "to", "the", "input", "string", "...
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/utils.py#L154-L182
train
clalancette/pycdlib
pycdlib/utils.py
gmtoffset_from_tm
def gmtoffset_from_tm(tm, local): # type: (float, time.struct_time) -> int ''' A function to compute the GMT offset from the time in seconds since the epoch and the local time object. Parameters: tm - The time in seconds since the epoch. local - The struct_time object representing the loc...
python
def gmtoffset_from_tm(tm, local): # type: (float, time.struct_time) -> int ''' A function to compute the GMT offset from the time in seconds since the epoch and the local time object. Parameters: tm - The time in seconds since the epoch. local - The struct_time object representing the loc...
[ "def", "gmtoffset_from_tm", "(", "tm", ",", "local", ")", ":", "gmtime", "=", "time", ".", "gmtime", "(", "tm", ")", "tmpyear", "=", "gmtime", ".", "tm_year", "-", "local", ".", "tm_year", "tmpyday", "=", "gmtime", ".", "tm_yday", "-", "local", ".", ...
A function to compute the GMT offset from the time in seconds since the epoch and the local time object. Parameters: tm - The time in seconds since the epoch. local - The struct_time object representing the local time. Returns: The gmtoffset.
[ "A", "function", "to", "compute", "the", "GMT", "offset", "from", "the", "time", "in", "seconds", "since", "the", "epoch", "and", "the", "local", "time", "object", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/utils.py#L223-L246
train
clalancette/pycdlib
pycdlib/utils.py
zero_pad
def zero_pad(fp, data_size, pad_size): # type: (BinaryIO, int, int) -> None ''' A function to write padding out from data_size up to pad_size efficiently. Parameters: fp - The file object to use to write padding out to. data_size - The current size of the data. pad_size - The boundar...
python
def zero_pad(fp, data_size, pad_size): # type: (BinaryIO, int, int) -> None ''' A function to write padding out from data_size up to pad_size efficiently. Parameters: fp - The file object to use to write padding out to. data_size - The current size of the data. pad_size - The boundar...
[ "def", "zero_pad", "(", "fp", ",", "data_size", ",", "pad_size", ")", ":", "padbytes", "=", "pad_size", "-", "(", "data_size", "%", "pad_size", ")", "if", "padbytes", "==", "pad_size", ":", "return", "fp", ".", "seek", "(", "padbytes", "-", "1", ",", ...
A function to write padding out from data_size up to pad_size efficiently. Parameters: fp - The file object to use to write padding out to. data_size - The current size of the data. pad_size - The boundary size of data to pad out to. Returns: Nothing.
[ "A", "function", "to", "write", "padding", "out", "from", "data_size", "up", "to", "pad_size", "efficiently", "." ]
1e7b77a809e905d67dc71e12d70e850be26b6233
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/utils.py#L249-L268
train