partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | beat | r'''Beat tracking evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary of scores, where the key i... | jams/eval.py | def beat(ref, est, **kwargs):
r'''Beat tracking evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dic... | def beat(ref, est, **kwargs):
r'''Beat tracking evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dic... | [
"r",
"Beat",
"tracking",
"evaluation"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L73-L113 | [
"def",
"beat",
"(",
"ref",
",",
"est",
",",
"*",
"*",
"kwargs",
")",
":",
"namespace",
"=",
"'beat'",
"ref",
"=",
"coerce_annotation",
"(",
"ref",
",",
"namespace",
")",
"est",
"=",
"coerce_annotation",
"(",
"est",
",",
"namespace",
")",
"ref_times",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | chord | r'''Chord evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary of scores, where the key is the me... | jams/eval.py | def chord(ref, est, **kwargs):
r'''Chord evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary... | def chord(ref, est, **kwargs):
r'''Chord evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary... | [
"r",
"Chord",
"evaluation"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L158-L198 | [
"def",
"chord",
"(",
"ref",
",",
"est",
",",
"*",
"*",
"kwargs",
")",
":",
"namespace",
"=",
"'chord'",
"ref",
"=",
"coerce_annotation",
"(",
"ref",
",",
"namespace",
")",
"est",
"=",
"coerce_annotation",
"(",
"est",
",",
"namespace",
")",
"ref_interval"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | hierarchy_flatten | Flatten a multi_segment annotation into mir_eval style.
Parameters
----------
annotation : jams.Annotation
An annotation in the `multi_segment` namespace
Returns
-------
hier_intervalss : list
A list of lists of intervals, ordered by increasing specificity.
hier_labels : l... | jams/eval.py | def hierarchy_flatten(annotation):
'''Flatten a multi_segment annotation into mir_eval style.
Parameters
----------
annotation : jams.Annotation
An annotation in the `multi_segment` namespace
Returns
-------
hier_intervalss : list
A list of lists of intervals, ordered by in... | def hierarchy_flatten(annotation):
'''Flatten a multi_segment annotation into mir_eval style.
Parameters
----------
annotation : jams.Annotation
An annotation in the `multi_segment` namespace
Returns
-------
hier_intervalss : list
A list of lists of intervals, ordered by in... | [
"Flatten",
"a",
"multi_segment",
"annotation",
"into",
"mir_eval",
"style",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L243-L276 | [
"def",
"hierarchy_flatten",
"(",
"annotation",
")",
":",
"intervals",
",",
"values",
"=",
"annotation",
".",
"to_interval_values",
"(",
")",
"ordering",
"=",
"dict",
"(",
")",
"for",
"interval",
",",
"value",
"in",
"zip",
"(",
"intervals",
",",
"values",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | hierarchy | r'''Multi-level segmentation evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary of scores, wher... | jams/eval.py | def hierarchy(ref, est, **kwargs):
r'''Multi-level segmentation evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : ... | def hierarchy(ref, est, **kwargs):
r'''Multi-level segmentation evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : ... | [
"r",
"Multi",
"-",
"level",
"segmentation",
"evaluation"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L279-L319 | [
"def",
"hierarchy",
"(",
"ref",
",",
"est",
",",
"*",
"*",
"kwargs",
")",
":",
"namespace",
"=",
"'multi_segment'",
"ref",
"=",
"coerce_annotation",
"(",
"ref",
",",
"namespace",
")",
"est",
"=",
"coerce_annotation",
"(",
"est",
",",
"namespace",
")",
"r... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | tempo | r'''Tempo evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary of scores, where the key is the me... | jams/eval.py | def tempo(ref, est, **kwargs):
r'''Tempo evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary... | def tempo(ref, est, **kwargs):
r'''Tempo evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary... | [
"r",
"Tempo",
"evaluation"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L322-L362 | [
"def",
"tempo",
"(",
"ref",
",",
"est",
",",
"*",
"*",
"kwargs",
")",
":",
"ref",
"=",
"coerce_annotation",
"(",
"ref",
",",
"'tempo'",
")",
"est",
"=",
"coerce_annotation",
"(",
"est",
",",
"'tempo'",
")",
"ref_tempi",
"=",
"np",
".",
"asarray",
"("... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | melody | r'''Melody extraction evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary of scores, where the k... | jams/eval.py | def melody(ref, est, **kwargs):
r'''Melody extraction evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
... | def melody(ref, est, **kwargs):
r'''Melody extraction evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
... | [
"r",
"Melody",
"extraction",
"evaluation"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L366-L411 | [
"def",
"melody",
"(",
"ref",
",",
"est",
",",
"*",
"*",
"kwargs",
")",
":",
"namespace",
"=",
"'pitch_contour'",
"ref",
"=",
"coerce_annotation",
"(",
"ref",
",",
"namespace",
")",
"est",
"=",
"coerce_annotation",
"(",
"est",
",",
"namespace",
")",
"ref_... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | pattern_to_mireval | Convert a pattern_jku annotation object to mir_eval format.
Parameters
----------
ann : jams.Annotation
Must have `namespace='pattern_jku'`
Returns
-------
patterns : list of list of tuples
- `patterns[x]` is a list containing all occurrences of pattern x
- `patterns[x... | jams/eval.py | def pattern_to_mireval(ann):
'''Convert a pattern_jku annotation object to mir_eval format.
Parameters
----------
ann : jams.Annotation
Must have `namespace='pattern_jku'`
Returns
-------
patterns : list of list of tuples
- `patterns[x]` is a list containing all occurrences... | def pattern_to_mireval(ann):
'''Convert a pattern_jku annotation object to mir_eval format.
Parameters
----------
ann : jams.Annotation
Must have `namespace='pattern_jku'`
Returns
-------
patterns : list of list of tuples
- `patterns[x]` is a list containing all occurrences... | [
"Convert",
"a",
"pattern_jku",
"annotation",
"object",
"to",
"mir_eval",
"format",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L415-L452 | [
"def",
"pattern_to_mireval",
"(",
"ann",
")",
":",
"# It's easier to work with dictionaries, since we can't assume",
"# sequential pattern or occurrence identifiers",
"patterns",
"=",
"defaultdict",
"(",
"lambda",
":",
"defaultdict",
"(",
"list",
")",
")",
"# Iterate over the d... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | pattern | r'''Pattern detection evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary of scores, where the k... | jams/eval.py | def pattern(ref, est, **kwargs):
r'''Pattern detection evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
... | def pattern(ref, est, **kwargs):
r'''Pattern detection evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
... | [
"r",
"Pattern",
"detection",
"evaluation"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L455-L495 | [
"def",
"pattern",
"(",
"ref",
",",
"est",
",",
"*",
"*",
"kwargs",
")",
":",
"namespace",
"=",
"'pattern_jku'",
"ref",
"=",
"coerce_annotation",
"(",
"ref",
",",
"namespace",
")",
"est",
"=",
"coerce_annotation",
"(",
"est",
",",
"namespace",
")",
"ref_p... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | transcription | r'''Note transcription evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary of scores, where the ... | jams/eval.py | def transcription(ref, est, **kwargs):
r'''Note transcription evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : di... | def transcription(ref, est, **kwargs):
r'''Note transcription evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : di... | [
"r",
"Note",
"transcription",
"evaluation"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L498-L542 | [
"def",
"transcription",
"(",
"ref",
",",
"est",
",",
"*",
"*",
"kwargs",
")",
":",
"namespace",
"=",
"'pitch_contour'",
"ref",
"=",
"coerce_annotation",
"(",
"ref",
",",
"namespace",
")",
"est",
"=",
"coerce_annotation",
"(",
"est",
",",
"namespace",
")",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | add_namespace | Add a namespace definition to our working set.
Namespace files consist of partial JSON schemas defining the behavior
of the `value` and `confidence` fields of an Annotation.
Parameters
----------
filename : str
Path to json file defining the namespace object | jams/schema.py | def add_namespace(filename):
'''Add a namespace definition to our working set.
Namespace files consist of partial JSON schemas defining the behavior
of the `value` and `confidence` fields of an Annotation.
Parameters
----------
filename : str
Path to json file defining the namespace ob... | def add_namespace(filename):
'''Add a namespace definition to our working set.
Namespace files consist of partial JSON schemas defining the behavior
of the `value` and `confidence` fields of an Annotation.
Parameters
----------
filename : str
Path to json file defining the namespace ob... | [
"Add",
"a",
"namespace",
"definition",
"to",
"our",
"working",
"set",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/schema.py#L35-L47 | [
"def",
"add_namespace",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"mode",
"=",
"'r'",
")",
"as",
"fileobj",
":",
"__NAMESPACE__",
".",
"update",
"(",
"json",
".",
"load",
"(",
"fileobj",
")",
")"
] | b16778399b9528efbd71434842a079f7691a7a66 |
valid | namespace | Construct a validation schema for a given namespace.
Parameters
----------
ns_key : str
Namespace key identifier (eg, 'beat' or 'segment_tut')
Returns
-------
schema : dict
JSON schema of `namespace` | jams/schema.py | def namespace(ns_key):
'''Construct a validation schema for a given namespace.
Parameters
----------
ns_key : str
Namespace key identifier (eg, 'beat' or 'segment_tut')
Returns
-------
schema : dict
JSON schema of `namespace`
'''
if ns_key not in __NAMESPACE__:
... | def namespace(ns_key):
'''Construct a validation schema for a given namespace.
Parameters
----------
ns_key : str
Namespace key identifier (eg, 'beat' or 'segment_tut')
Returns
-------
schema : dict
JSON schema of `namespace`
'''
if ns_key not in __NAMESPACE__:
... | [
"Construct",
"a",
"validation",
"schema",
"for",
"a",
"given",
"namespace",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/schema.py#L50-L75 | [
"def",
"namespace",
"(",
"ns_key",
")",
":",
"if",
"ns_key",
"not",
"in",
"__NAMESPACE__",
":",
"raise",
"NamespaceError",
"(",
"'Unknown namespace: {:s}'",
".",
"format",
"(",
"ns_key",
")",
")",
"sch",
"=",
"copy",
".",
"deepcopy",
"(",
"JAMS_SCHEMA",
"[",... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | namespace_array | Construct a validation schema for arrays of a given namespace.
Parameters
----------
ns_key : str
Namespace key identifier
Returns
-------
schema : dict
JSON schema of `namespace` observation arrays | jams/schema.py | def namespace_array(ns_key):
'''Construct a validation schema for arrays of a given namespace.
Parameters
----------
ns_key : str
Namespace key identifier
Returns
-------
schema : dict
JSON schema of `namespace` observation arrays
'''
obs_sch = namespace(ns_key)
... | def namespace_array(ns_key):
'''Construct a validation schema for arrays of a given namespace.
Parameters
----------
ns_key : str
Namespace key identifier
Returns
-------
schema : dict
JSON schema of `namespace` observation arrays
'''
obs_sch = namespace(ns_key)
... | [
"Construct",
"a",
"validation",
"schema",
"for",
"arrays",
"of",
"a",
"given",
"namespace",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/schema.py#L78-L97 | [
"def",
"namespace_array",
"(",
"ns_key",
")",
":",
"obs_sch",
"=",
"namespace",
"(",
"ns_key",
")",
"obs_sch",
"[",
"'title'",
"]",
"=",
"'Observation'",
"sch",
"=",
"copy",
".",
"deepcopy",
"(",
"JAMS_SCHEMA",
"[",
"'definitions'",
"]",
"[",
"'SparseObserva... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | values | Return the allowed values for an enumerated namespace.
Parameters
----------
ns_key : str
Namespace key identifier
Returns
-------
values : list
Raises
------
NamespaceError
If `ns_key` is not found, or does not have enumerated values
Examples
--------
... | jams/schema.py | def values(ns_key):
'''Return the allowed values for an enumerated namespace.
Parameters
----------
ns_key : str
Namespace key identifier
Returns
-------
values : list
Raises
------
NamespaceError
If `ns_key` is not found, or does not have enumerated values
... | def values(ns_key):
'''Return the allowed values for an enumerated namespace.
Parameters
----------
ns_key : str
Namespace key identifier
Returns
-------
values : list
Raises
------
NamespaceError
If `ns_key` is not found, or does not have enumerated values
... | [
"Return",
"the",
"allowed",
"values",
"for",
"an",
"enumerated",
"namespace",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/schema.py#L121-L151 | [
"def",
"values",
"(",
"ns_key",
")",
":",
"if",
"ns_key",
"not",
"in",
"__NAMESPACE__",
":",
"raise",
"NamespaceError",
"(",
"'Unknown namespace: {:s}'",
".",
"format",
"(",
"ns_key",
")",
")",
"if",
"'enum'",
"not",
"in",
"__NAMESPACE__",
"[",
"ns_key",
"]"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | get_dtypes | Get the dtypes associated with the value and confidence fields
for a given namespace.
Parameters
----------
ns_key : str
The namespace key in question
Returns
-------
value_dtype, confidence_dtype : numpy.dtype
Type identifiers for value and confidence fields. | jams/schema.py | def get_dtypes(ns_key):
'''Get the dtypes associated with the value and confidence fields
for a given namespace.
Parameters
----------
ns_key : str
The namespace key in question
Returns
-------
value_dtype, confidence_dtype : numpy.dtype
Type identifiers for value and c... | def get_dtypes(ns_key):
'''Get the dtypes associated with the value and confidence fields
for a given namespace.
Parameters
----------
ns_key : str
The namespace key in question
Returns
-------
value_dtype, confidence_dtype : numpy.dtype
Type identifiers for value and c... | [
"Get",
"the",
"dtypes",
"associated",
"with",
"the",
"value",
"and",
"confidence",
"fields",
"for",
"a",
"given",
"namespace",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/schema.py#L154-L176 | [
"def",
"get_dtypes",
"(",
"ns_key",
")",
":",
"# First, get the schema",
"if",
"ns_key",
"not",
"in",
"__NAMESPACE__",
":",
"raise",
"NamespaceError",
"(",
"'Unknown namespace: {:s}'",
".",
"format",
"(",
"ns_key",
")",
")",
"value_dtype",
"=",
"__get_dtype",
"(",... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | list_namespaces | Print out a listing of available namespaces | jams/schema.py | def list_namespaces():
'''Print out a listing of available namespaces'''
print('{:30s}\t{:40s}'.format('NAME', 'DESCRIPTION'))
print('-' * 78)
for sch in sorted(__NAMESPACE__):
desc = __NAMESPACE__[sch]['description']
desc = (desc[:44] + '..') if len(desc) > 46 else desc
print('{... | def list_namespaces():
'''Print out a listing of available namespaces'''
print('{:30s}\t{:40s}'.format('NAME', 'DESCRIPTION'))
print('-' * 78)
for sch in sorted(__NAMESPACE__):
desc = __NAMESPACE__[sch]['description']
desc = (desc[:44] + '..') if len(desc) > 46 else desc
print('{... | [
"Print",
"out",
"a",
"listing",
"of",
"available",
"namespaces"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/schema.py#L179-L186 | [
"def",
"list_namespaces",
"(",
")",
":",
"print",
"(",
"'{:30s}\\t{:40s}'",
".",
"format",
"(",
"'NAME'",
",",
"'DESCRIPTION'",
")",
")",
"print",
"(",
"'-'",
"*",
"78",
")",
"for",
"sch",
"in",
"sorted",
"(",
"__NAMESPACE__",
")",
":",
"desc",
"=",
"_... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | __get_dtype | Get the dtype associated with a jsonschema type definition
Parameters
----------
typespec : dict
The schema definition
Returns
-------
dtype : numpy.dtype
The associated dtype | jams/schema.py | def __get_dtype(typespec):
'''Get the dtype associated with a jsonschema type definition
Parameters
----------
typespec : dict
The schema definition
Returns
-------
dtype : numpy.dtype
The associated dtype
'''
if 'type' in typespec:
return __TYPE_MAP__.get(... | def __get_dtype(typespec):
'''Get the dtype associated with a jsonschema type definition
Parameters
----------
typespec : dict
The schema definition
Returns
-------
dtype : numpy.dtype
The associated dtype
'''
if 'type' in typespec:
return __TYPE_MAP__.get(... | [
"Get",
"the",
"dtype",
"associated",
"with",
"a",
"jsonschema",
"type",
"definition"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/schema.py#L199-L228 | [
"def",
"__get_dtype",
"(",
"typespec",
")",
":",
"if",
"'type'",
"in",
"typespec",
":",
"return",
"__TYPE_MAP__",
".",
"get",
"(",
"typespec",
"[",
"'type'",
"]",
",",
"np",
".",
"object_",
")",
"elif",
"'enum'",
"in",
"typespec",
":",
"# Enums map to obje... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | __load_jams_schema | Load the schema file from the package. | jams/schema.py | def __load_jams_schema():
'''Load the schema file from the package.'''
schema_file = os.path.join(SCHEMA_DIR, 'jams_schema.json')
jams_schema = None
with open(resource_filename(__name__, schema_file), mode='r') as fdesc:
jams_schema = json.load(fdesc)
if jams_schema is None:
raise... | def __load_jams_schema():
'''Load the schema file from the package.'''
schema_file = os.path.join(SCHEMA_DIR, 'jams_schema.json')
jams_schema = None
with open(resource_filename(__name__, schema_file), mode='r') as fdesc:
jams_schema = json.load(fdesc)
if jams_schema is None:
raise... | [
"Load",
"the",
"schema",
"file",
"from",
"the",
"package",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/schema.py#L231-L243 | [
"def",
"__load_jams_schema",
"(",
")",
":",
"schema_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"SCHEMA_DIR",
",",
"'jams_schema.json'",
")",
"jams_schema",
"=",
"None",
"with",
"open",
"(",
"resource_filename",
"(",
"__name__",
",",
"schema_file",
")",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | import_lab | r'''Load a .lab file as an Annotation object.
.lab files are assumed to have the following format:
``TIME_START\tTIME_END\tANNOTATION``
By default, .lab files are assumed to have columns separated by one
or more white-space characters, and have no header or index column
information.
If t... | jams/util.py | def import_lab(namespace, filename, infer_duration=True, **parse_options):
r'''Load a .lab file as an Annotation object.
.lab files are assumed to have the following format:
``TIME_START\tTIME_END\tANNOTATION``
By default, .lab files are assumed to have columns separated by one
or more white-... | def import_lab(namespace, filename, infer_duration=True, **parse_options):
r'''Load a .lab file as an Annotation object.
.lab files are assumed to have the following format:
``TIME_START\tTIME_END\tANNOTATION``
By default, .lab files are assumed to have columns separated by one
or more white-... | [
"r",
"Load",
"a",
".",
"lab",
"file",
"as",
"an",
"Annotation",
"object",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/util.py#L24-L113 | [
"def",
"import_lab",
"(",
"namespace",
",",
"filename",
",",
"infer_duration",
"=",
"True",
",",
"*",
"*",
"parse_options",
")",
":",
"# Create a new annotation object",
"annotation",
"=",
"core",
".",
"Annotation",
"(",
"namespace",
")",
"parse_options",
".",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | expand_filepaths | Expand a list of relative paths to a give base directory.
Parameters
----------
base_dir : str
The target base directory
rel_paths : list (or list-like)
Collection of relative path strings
Returns
-------
expanded_paths : list
`rel_paths` rooted at `base_dir`
... | jams/util.py | def expand_filepaths(base_dir, rel_paths):
"""Expand a list of relative paths to a give base directory.
Parameters
----------
base_dir : str
The target base directory
rel_paths : list (or list-like)
Collection of relative path strings
Returns
-------
expanded_paths : l... | def expand_filepaths(base_dir, rel_paths):
"""Expand a list of relative paths to a give base directory.
Parameters
----------
base_dir : str
The target base directory
rel_paths : list (or list-like)
Collection of relative path strings
Returns
-------
expanded_paths : l... | [
"Expand",
"a",
"list",
"of",
"relative",
"paths",
"to",
"a",
"give",
"base",
"directory",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/util.py#L116-L138 | [
"def",
"expand_filepaths",
"(",
"base_dir",
",",
"rel_paths",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"base_dir",
",",
"os",
".",
"path",
".",
"normpath",
"(",
"rp",
")",
")",
"for",
"rp",
"in",
"rel_paths",
"]"
] | b16778399b9528efbd71434842a079f7691a7a66 |
valid | smkdirs | Safely make a full directory path if it doesn't exist.
Parameters
----------
dpath : str
Path of directory/directories to create
mode : int [default=0777]
Permissions for the new directories
See also
--------
os.makedirs | jams/util.py | def smkdirs(dpath, mode=0o777):
"""Safely make a full directory path if it doesn't exist.
Parameters
----------
dpath : str
Path of directory/directories to create
mode : int [default=0777]
Permissions for the new directories
See also
--------
os.makedirs
"""
i... | def smkdirs(dpath, mode=0o777):
"""Safely make a full directory path if it doesn't exist.
Parameters
----------
dpath : str
Path of directory/directories to create
mode : int [default=0777]
Permissions for the new directories
See also
--------
os.makedirs
"""
i... | [
"Safely",
"make",
"a",
"full",
"directory",
"path",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/util.py#L141-L157 | [
"def",
"smkdirs",
"(",
"dpath",
",",
"mode",
"=",
"0o777",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dpath",
")",
":",
"os",
".",
"makedirs",
"(",
"dpath",
",",
"mode",
"=",
"mode",
")"
] | b16778399b9528efbd71434842a079f7691a7a66 |
valid | find_with_extension | Naive depth-search into a directory for files with a given extension.
Parameters
----------
in_dir : str
Path to search.
ext : str
File extension to match.
depth : int
Depth of directories to search.
sort : bool
Sort the list alphabetically
Returns
-----... | jams/util.py | def find_with_extension(in_dir, ext, depth=3, sort=True):
"""Naive depth-search into a directory for files with a given extension.
Parameters
----------
in_dir : str
Path to search.
ext : str
File extension to match.
depth : int
Depth of directories to search.
sort :... | def find_with_extension(in_dir, ext, depth=3, sort=True):
"""Naive depth-search into a directory for files with a given extension.
Parameters
----------
in_dir : str
Path to search.
ext : str
File extension to match.
depth : int
Depth of directories to search.
sort :... | [
"Naive",
"depth",
"-",
"search",
"into",
"a",
"directory",
"for",
"files",
"with",
"a",
"given",
"extension",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/util.py#L182-L223 | [
"def",
"find_with_extension",
"(",
"in_dir",
",",
"ext",
",",
"depth",
"=",
"3",
",",
"sort",
"=",
"True",
")",
":",
"assert",
"depth",
">=",
"1",
"ext",
"=",
"ext",
".",
"strip",
"(",
"os",
".",
"extsep",
")",
"match",
"=",
"list",
"(",
")",
"fo... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | get_comments | Get the metadata from a jam and an annotation, combined as a string.
Parameters
----------
jam : JAMS
The jams object
ann : Annotation
An annotation object
Returns
-------
comments : str
The jam.file_metadata and ann.annotation_metadata, combined and serialized | scripts/jams_to_lab.py | def get_comments(jam, ann):
'''Get the metadata from a jam and an annotation, combined as a string.
Parameters
----------
jam : JAMS
The jams object
ann : Annotation
An annotation object
Returns
-------
comments : str
The jam.file_metadata and ann.annotation_me... | def get_comments(jam, ann):
'''Get the metadata from a jam and an annotation, combined as a string.
Parameters
----------
jam : JAMS
The jams object
ann : Annotation
An annotation object
Returns
-------
comments : str
The jam.file_metadata and ann.annotation_me... | [
"Get",
"the",
"metadata",
"from",
"a",
"jam",
"and",
"an",
"annotation",
"combined",
"as",
"a",
"string",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/scripts/jams_to_lab.py#L36-L56 | [
"def",
"get_comments",
"(",
"jam",
",",
"ann",
")",
":",
"jam_comments",
"=",
"jam",
".",
"file_metadata",
".",
"__json__",
"ann_comments",
"=",
"ann",
".",
"annotation_metadata",
".",
"__json__",
"return",
"json",
".",
"dumps",
"(",
"{",
"'metadata'",
":",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | lab_dump | Save an annotation as a lab/csv.
Parameters
----------
ann : Annotation
The annotation object
comment : str
The comment string header
filename : str
The output filename
sep : str
The separator string for output
comment_char : str
The character use... | scripts/jams_to_lab.py | def lab_dump(ann, comment, filename, sep, comment_char):
'''Save an annotation as a lab/csv.
Parameters
----------
ann : Annotation
The annotation object
comment : str
The comment string header
filename : str
The output filename
sep : str
The separator str... | def lab_dump(ann, comment, filename, sep, comment_char):
'''Save an annotation as a lab/csv.
Parameters
----------
ann : Annotation
The annotation object
comment : str
The comment string header
filename : str
The output filename
sep : str
The separator str... | [
"Save",
"an",
"annotation",
"as",
"a",
"lab",
"/",
"csv",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/scripts/jams_to_lab.py#L59-L91 | [
"def",
"lab_dump",
"(",
"ann",
",",
"comment",
",",
"filename",
",",
"sep",
",",
"comment_char",
")",
":",
"intervals",
",",
"values",
"=",
"ann",
".",
"to_interval_values",
"(",
")",
"frame",
"=",
"pd",
".",
"DataFrame",
"(",
"columns",
"=",
"[",
"'Ti... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | convert_jams | Convert jams to labs.
Parameters
----------
jams_file : str
The path on disk to the jams file in question
output_prefix : str
The file path prefix of the outputs
csv : bool
Whether to output in csv (True) or lab (False) format
comment_char : str
The character ... | scripts/jams_to_lab.py | def convert_jams(jams_file, output_prefix, csv=False, comment_char='#', namespaces=None):
'''Convert jams to labs.
Parameters
----------
jams_file : str
The path on disk to the jams file in question
output_prefix : str
The file path prefix of the outputs
csv : bool
Whe... | def convert_jams(jams_file, output_prefix, csv=False, comment_char='#', namespaces=None):
'''Convert jams to labs.
Parameters
----------
jams_file : str
The path on disk to the jams file in question
output_prefix : str
The file path prefix of the outputs
csv : bool
Whe... | [
"Convert",
"jams",
"to",
"labs",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/scripts/jams_to_lab.py#L94-L153 | [
"def",
"convert_jams",
"(",
"jams_file",
",",
"output_prefix",
",",
"csv",
"=",
"False",
",",
"comment_char",
"=",
"'#'",
",",
"namespaces",
"=",
"None",
")",
":",
"if",
"namespaces",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'No namespaces provided. Try... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | parse_arguments | Parse arguments from the command line | scripts/jams_to_lab.py | def parse_arguments(args):
'''Parse arguments from the command line'''
parser = argparse.ArgumentParser(description='Convert JAMS to .lab files')
parser.add_argument('-c',
'--comma-separated',
dest='csv',
action='store_true',
... | def parse_arguments(args):
'''Parse arguments from the command line'''
parser = argparse.ArgumentParser(description='Convert JAMS to .lab files')
parser.add_argument('-c',
'--comma-separated',
dest='csv',
action='store_true',
... | [
"Parse",
"arguments",
"from",
"the",
"command",
"line"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/scripts/jams_to_lab.py#L156-L182 | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Convert JAMS to .lab files'",
")",
"parser",
".",
"add_argument",
"(",
"'-c'",
",",
"'--comma-separated'",
",",
"dest",
"=",
"'csv'",
",... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | _conversion | A decorator to register namespace conversions.
Usage
-----
>>> @conversion('tag_open', 'tag_.*')
... def tag_to_open(annotation):
... annotation.namespace = 'tag_open'
... return annotation | jams/nsconvert.py | def _conversion(target, source):
'''A decorator to register namespace conversions.
Usage
-----
>>> @conversion('tag_open', 'tag_.*')
... def tag_to_open(annotation):
... annotation.namespace = 'tag_open'
... return annotation
'''
def register(func):
'''This decorato... | def _conversion(target, source):
'''A decorator to register namespace conversions.
Usage
-----
>>> @conversion('tag_open', 'tag_.*')
... def tag_to_open(annotation):
... annotation.namespace = 'tag_open'
... return annotation
'''
def register(func):
'''This decorato... | [
"A",
"decorator",
"to",
"register",
"namespace",
"conversions",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/nsconvert.py#L28-L44 | [
"def",
"_conversion",
"(",
"target",
",",
"source",
")",
":",
"def",
"register",
"(",
"func",
")",
":",
"'''This decorator registers func as mapping source to target'''",
"__CONVERSION__",
"[",
"target",
"]",
"[",
"source",
"]",
"=",
"func",
"return",
"func",
"ret... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | convert | Convert a given annotation to the target namespace.
Parameters
----------
annotation : jams.Annotation
An annotation object
target_namespace : str
The target namespace
Returns
-------
mapped_annotation : jams.Annotation
if `annotation` already belongs to `target_na... | jams/nsconvert.py | def convert(annotation, target_namespace):
'''Convert a given annotation to the target namespace.
Parameters
----------
annotation : jams.Annotation
An annotation object
target_namespace : str
The target namespace
Returns
-------
mapped_annotation : jams.Annotation
... | def convert(annotation, target_namespace):
'''Convert a given annotation to the target namespace.
Parameters
----------
annotation : jams.Annotation
An annotation object
target_namespace : str
The target namespace
Returns
-------
mapped_annotation : jams.Annotation
... | [
"Convert",
"a",
"given",
"annotation",
"to",
"the",
"target",
"namespace",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/nsconvert.py#L47-L105 | [
"def",
"convert",
"(",
"annotation",
",",
"target_namespace",
")",
":",
"# First, validate the input. If this fails, we can't auto-convert.",
"annotation",
".",
"validate",
"(",
"strict",
"=",
"True",
")",
"# If we're already in the target namespace, do nothing",
"if",
"annotat... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | can_convert | Test if an annotation can be mapped to a target namespace
Parameters
----------
annotation : jams.Annotation
An annotation object
target_namespace : str
The target namespace
Returns
-------
True
if `annotation` can be automatically converted to
`target_name... | jams/nsconvert.py | def can_convert(annotation, target_namespace):
'''Test if an annotation can be mapped to a target namespace
Parameters
----------
annotation : jams.Annotation
An annotation object
target_namespace : str
The target namespace
Returns
-------
True
if `annotation` ... | def can_convert(annotation, target_namespace):
'''Test if an annotation can be mapped to a target namespace
Parameters
----------
annotation : jams.Annotation
An annotation object
target_namespace : str
The target namespace
Returns
-------
True
if `annotation` ... | [
"Test",
"if",
"an",
"annotation",
"can",
"be",
"mapped",
"to",
"a",
"target",
"namespace"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/nsconvert.py#L108-L138 | [
"def",
"can_convert",
"(",
"annotation",
",",
"target_namespace",
")",
":",
"# If we're already in the target namespace, do nothing",
"if",
"annotation",
".",
"namespace",
"==",
"target_namespace",
":",
"return",
"True",
"if",
"target_namespace",
"in",
"__CONVERSION__",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | pitch_hz_to_contour | Convert a pitch_hz annotation to a contour | jams/nsconvert.py | def pitch_hz_to_contour(annotation):
'''Convert a pitch_hz annotation to a contour'''
annotation.namespace = 'pitch_contour'
data = annotation.pop_data()
for obs in data:
annotation.append(time=obs.time, duration=obs.duration,
confidence=obs.confidence,
... | def pitch_hz_to_contour(annotation):
'''Convert a pitch_hz annotation to a contour'''
annotation.namespace = 'pitch_contour'
data = annotation.pop_data()
for obs in data:
annotation.append(time=obs.time, duration=obs.duration,
confidence=obs.confidence,
... | [
"Convert",
"a",
"pitch_hz",
"annotation",
"to",
"a",
"contour"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/nsconvert.py#L142-L153 | [
"def",
"pitch_hz_to_contour",
"(",
"annotation",
")",
":",
"annotation",
".",
"namespace",
"=",
"'pitch_contour'",
"data",
"=",
"annotation",
".",
"pop_data",
"(",
")",
"for",
"obs",
"in",
"data",
":",
"annotation",
".",
"append",
"(",
"time",
"=",
"obs",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | note_hz_to_midi | Convert a pitch_hz annotation to pitch_midi | jams/nsconvert.py | def note_hz_to_midi(annotation):
'''Convert a pitch_hz annotation to pitch_midi'''
annotation.namespace = 'note_midi'
data = annotation.pop_data()
for obs in data:
annotation.append(time=obs.time, duration=obs.duration,
confidence=obs.confidence,
... | def note_hz_to_midi(annotation):
'''Convert a pitch_hz annotation to pitch_midi'''
annotation.namespace = 'note_midi'
data = annotation.pop_data()
for obs in data:
annotation.append(time=obs.time, duration=obs.duration,
confidence=obs.confidence,
... | [
"Convert",
"a",
"pitch_hz",
"annotation",
"to",
"pitch_midi"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/nsconvert.py#L179-L191 | [
"def",
"note_hz_to_midi",
"(",
"annotation",
")",
":",
"annotation",
".",
"namespace",
"=",
"'note_midi'",
"data",
"=",
"annotation",
".",
"pop_data",
"(",
")",
"for",
"obs",
"in",
"data",
":",
"annotation",
".",
"append",
"(",
"time",
"=",
"obs",
".",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | scaper_to_tag | Convert scaper annotations to tag_open | jams/nsconvert.py | def scaper_to_tag(annotation):
'''Convert scaper annotations to tag_open'''
annotation.namespace = 'tag_open'
data = annotation.pop_data()
for obs in data:
annotation.append(time=obs.time, duration=obs.duration,
confidence=obs.confidence, value=obs.value['label'])
... | def scaper_to_tag(annotation):
'''Convert scaper annotations to tag_open'''
annotation.namespace = 'tag_open'
data = annotation.pop_data()
for obs in data:
annotation.append(time=obs.time, duration=obs.duration,
confidence=obs.confidence, value=obs.value['label'])
... | [
"Convert",
"scaper",
"annotations",
"to",
"tag_open"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/nsconvert.py#L242-L252 | [
"def",
"scaper_to_tag",
"(",
"annotation",
")",
":",
"annotation",
".",
"namespace",
"=",
"'tag_open'",
"data",
"=",
"annotation",
".",
"pop_data",
"(",
")",
"for",
"obs",
"in",
"data",
":",
"annotation",
".",
"append",
"(",
"time",
"=",
"obs",
".",
"tim... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | deprecated | This is a decorator which can be used to mark functions
as deprecated.
It will result in a warning being emitted when the function is used. | jams/core.py | def deprecated(version, version_removed):
'''This is a decorator which can be used to mark functions
as deprecated.
It will result in a warning being emitted when the function is used.'''
def __wrapper(func, *args, **kwargs):
'''Warn the user, and then proceed.'''
code = six.get_functi... | def deprecated(version, version_removed):
'''This is a decorator which can be used to mark functions
as deprecated.
It will result in a warning being emitted when the function is used.'''
def __wrapper(func, *args, **kwargs):
'''Warn the user, and then proceed.'''
code = six.get_functi... | [
"This",
"is",
"a",
"decorator",
"which",
"can",
"be",
"used",
"to",
"mark",
"functions",
"as",
"deprecated",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L63-L83 | [
"def",
"deprecated",
"(",
"version",
",",
"version_removed",
")",
":",
"def",
"__wrapper",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"'''Warn the user, and then proceed.'''",
"code",
"=",
"six",
".",
"get_function_code",
"(",
"func",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | _open | An intelligent wrapper for ``open``.
Parameters
----------
name_or_fdesc : string-type or open file descriptor
If a string type, refers to the path to a file on disk.
If an open file descriptor, it is returned as-is.
mode : string
The mode with which to open the file.
... | jams/core.py | def _open(name_or_fdesc, mode='r', fmt='auto'):
'''An intelligent wrapper for ``open``.
Parameters
----------
name_or_fdesc : string-type or open file descriptor
If a string type, refers to the path to a file on disk.
If an open file descriptor, it is returned as-is.
mode : string... | def _open(name_or_fdesc, mode='r', fmt='auto'):
'''An intelligent wrapper for ``open``.
Parameters
----------
name_or_fdesc : string-type or open file descriptor
If a string type, refers to the path to a file on disk.
If an open file descriptor, it is returned as-is.
mode : string... | [
"An",
"intelligent",
"wrapper",
"for",
"open",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L87-L152 | [
"def",
"_open",
"(",
"name_or_fdesc",
",",
"mode",
"=",
"'r'",
",",
"fmt",
"=",
"'auto'",
")",
":",
"open_map",
"=",
"{",
"'jams'",
":",
"open",
",",
"'json'",
":",
"open",
",",
"'jamz'",
":",
"gzip",
".",
"open",
",",
"'gz'",
":",
"gzip",
".",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | load | r"""Load a JAMS Annotation from a file.
Parameters
----------
path_or_file : str or file-like
Path to the JAMS file to load
OR
An open file handle to load from.
validate : bool
Attempt to validate the JAMS object
strict : bool
if `validate == True`, enforc... | jams/core.py | def load(path_or_file, validate=True, strict=True, fmt='auto'):
r"""Load a JAMS Annotation from a file.
Parameters
----------
path_or_file : str or file-like
Path to the JAMS file to load
OR
An open file handle to load from.
validate : bool
Attempt to validate the ... | def load(path_or_file, validate=True, strict=True, fmt='auto'):
r"""Load a JAMS Annotation from a file.
Parameters
----------
path_or_file : str or file-like
Path to the JAMS file to load
OR
An open file handle to load from.
validate : bool
Attempt to validate the ... | [
"r",
"Load",
"a",
"JAMS",
"Annotation",
"from",
"a",
"file",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L155-L218 | [
"def",
"load",
"(",
"path_or_file",
",",
"validate",
"=",
"True",
",",
"strict",
"=",
"True",
",",
"fmt",
"=",
"'auto'",
")",
":",
"with",
"_open",
"(",
"path_or_file",
",",
"mode",
"=",
"'r'",
",",
"fmt",
"=",
"fmt",
")",
"as",
"fdesc",
":",
"jam"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | query_pop | Pop a prefix from a query string.
Parameters
----------
query : str
The query string
prefix : str
The prefix string to pop, if it exists
sep : str
The string to separate fields
Returns
-------
popped : str
`query` with a `prefix` removed from the fron... | jams/core.py | def query_pop(query, prefix, sep='.'):
'''Pop a prefix from a query string.
Parameters
----------
query : str
The query string
prefix : str
The prefix string to pop, if it exists
sep : str
The string to separate fields
Returns
-------
popped : str
... | def query_pop(query, prefix, sep='.'):
'''Pop a prefix from a query string.
Parameters
----------
query : str
The query string
prefix : str
The prefix string to pop, if it exists
sep : str
The string to separate fields
Returns
-------
popped : str
... | [
"Pop",
"a",
"prefix",
"from",
"a",
"query",
"string",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L2009-L2044 | [
"def",
"query_pop",
"(",
"query",
",",
"prefix",
",",
"sep",
"=",
"'.'",
")",
":",
"terms",
"=",
"query",
".",
"split",
"(",
"sep",
")",
"if",
"terms",
"[",
"0",
"]",
"==",
"prefix",
":",
"terms",
"=",
"terms",
"[",
"1",
":",
"]",
"return",
"se... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | match_query | Test if a string matches a query.
Parameters
----------
string : str
The string to test
query : string, callable, or object
Either a regular expression, callable function, or object.
Returns
-------
match : bool
`True` if:
- `query` is a callable and `query... | jams/core.py | def match_query(string, query):
'''Test if a string matches a query.
Parameters
----------
string : str
The string to test
query : string, callable, or object
Either a regular expression, callable function, or object.
Returns
-------
match : bool
`True` if:
... | def match_query(string, query):
'''Test if a string matches a query.
Parameters
----------
string : str
The string to test
query : string, callable, or object
Either a regular expression, callable function, or object.
Returns
-------
match : bool
`True` if:
... | [
"Test",
"if",
"a",
"string",
"matches",
"a",
"query",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L2047-L2078 | [
"def",
"match_query",
"(",
"string",
",",
"query",
")",
":",
"if",
"six",
".",
"callable",
"(",
"query",
")",
":",
"return",
"query",
"(",
"string",
")",
"elif",
"(",
"isinstance",
"(",
"query",
",",
"six",
".",
"string_types",
")",
"and",
"isinstance"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | serialize_obj | Custom serialization functionality for working with advanced data types.
- numpy arrays are converted to lists
- lists are recursively serialized element-wise | jams/core.py | def serialize_obj(obj):
'''Custom serialization functionality for working with advanced data types.
- numpy arrays are converted to lists
- lists are recursively serialized element-wise
'''
if isinstance(obj, np.integer):
return int(obj)
elif isinstance(obj, np.floating):
ret... | def serialize_obj(obj):
'''Custom serialization functionality for working with advanced data types.
- numpy arrays are converted to lists
- lists are recursively serialized element-wise
'''
if isinstance(obj, np.integer):
return int(obj)
elif isinstance(obj, np.floating):
ret... | [
"Custom",
"serialization",
"functionality",
"for",
"working",
"with",
"advanced",
"data",
"types",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L2081-L2104 | [
"def",
"serialize_obj",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"np",
".",
"integer",
")",
":",
"return",
"int",
"(",
"obj",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"np",
".",
"floating",
")",
":",
"return",
"float",
"(",
"ob... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | summary | Helper function to format repr strings for JObjects and friends.
Parameters
----------
obj
The object to repr
indent : int >= 0
indent each new line by `indent` spaces
Returns
-------
r : str
If `obj` has a `__summary__` method, it is used.
If `obj` is a `... | jams/core.py | def summary(obj, indent=0):
'''Helper function to format repr strings for JObjects and friends.
Parameters
----------
obj
The object to repr
indent : int >= 0
indent each new line by `indent` spaces
Returns
-------
r : str
If `obj` has a `__summary__` method, i... | def summary(obj, indent=0):
'''Helper function to format repr strings for JObjects and friends.
Parameters
----------
obj
The object to repr
indent : int >= 0
indent each new line by `indent` spaces
Returns
-------
r : str
If `obj` has a `__summary__` method, i... | [
"Helper",
"function",
"to",
"format",
"repr",
"strings",
"for",
"JObjects",
"and",
"friends",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L2107-L2135 | [
"def",
"summary",
"(",
"obj",
",",
"indent",
"=",
"0",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'__summary__'",
")",
":",
"rep",
"=",
"obj",
".",
"__summary__",
"(",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"SortedKeyList",
")",
":",
"rep",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | JObject.update | Update the attributes of a JObject.
Parameters
----------
kwargs
Keyword arguments of the form `attribute=new_value`
Examples
--------
>>> J = jams.JObject(foo=5)
>>> J.dumps()
'{"foo": 5}'
>>> J.update(bar='baz')
>>> J.dumps(... | jams/core.py | def update(self, **kwargs):
'''Update the attributes of a JObject.
Parameters
----------
kwargs
Keyword arguments of the form `attribute=new_value`
Examples
--------
>>> J = jams.JObject(foo=5)
>>> J.dumps()
'{"foo": 5}'
>>> J... | def update(self, **kwargs):
'''Update the attributes of a JObject.
Parameters
----------
kwargs
Keyword arguments of the form `attribute=new_value`
Examples
--------
>>> J = jams.JObject(foo=5)
>>> J.dumps()
'{"foo": 5}'
>>> J... | [
"Update",
"the",
"attributes",
"of",
"a",
"JObject",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L436-L454 | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"name",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"kwargs",
")",
":",
"setattr",
"(",
"self",
",",
"name",
",",
"value",
")"
] | b16778399b9528efbd71434842a079f7691a7a66 |
valid | JObject.search | Query this object (and its descendants).
Parameters
----------
kwargs
Each `(key, value)` pair encodes a search field in `key`
and a target value in `value`.
`key` must be a string, and should correspond to a property in
the JAMS object hierarchy... | jams/core.py | def search(self, **kwargs):
'''Query this object (and its descendants).
Parameters
----------
kwargs
Each `(key, value)` pair encodes a search field in `key`
and a target value in `value`.
`key` must be a string, and should correspond to a property i... | def search(self, **kwargs):
'''Query this object (and its descendants).
Parameters
----------
kwargs
Each `(key, value)` pair encodes a search field in `key`
and a target value in `value`.
`key` must be a string, and should correspond to a property i... | [
"Query",
"this",
"object",
"(",
"and",
"its",
"descendants",
")",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L490-L559 | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"match",
"=",
"False",
"r_query",
"=",
"{",
"}",
"myself",
"=",
"self",
".",
"__class__",
".",
"__name__",
"# Pop this object name off the query",
"for",
"k",
",",
"value",
"in",
"six",
"."... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | JObject.validate | Validate a JObject against its schema
Parameters
----------
strict : bool
Enforce strict schema validation
Returns
-------
valid : bool
True if the jam validates
False if not, and `strict==False`
Raises
------
... | jams/core.py | def validate(self, strict=True):
'''Validate a JObject against its schema
Parameters
----------
strict : bool
Enforce strict schema validation
Returns
-------
valid : bool
True if the jam validates
False if not, and `strict==F... | def validate(self, strict=True):
'''Validate a JObject against its schema
Parameters
----------
strict : bool
Enforce strict schema validation
Returns
-------
valid : bool
True if the jam validates
False if not, and `strict==F... | [
"Validate",
"a",
"JObject",
"against",
"its",
"schema"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L561-L594 | [
"def",
"validate",
"(",
"self",
",",
"strict",
"=",
"True",
")",
":",
"valid",
"=",
"True",
"try",
":",
"jsonschema",
".",
"validate",
"(",
"self",
".",
"__json__",
",",
"self",
".",
"__schema__",
")",
"except",
"jsonschema",
".",
"ValidationError",
"as"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.append | Append an observation to the data field
Parameters
----------
time : float >= 0
duration : float >= 0
The time and duration of the new observation, in seconds
value
confidence
The value and confidence of the new observations.
Types an... | jams/core.py | def append(self, time=None, duration=None, value=None, confidence=None):
'''Append an observation to the data field
Parameters
----------
time : float >= 0
duration : float >= 0
The time and duration of the new observation, in seconds
value
confidence... | def append(self, time=None, duration=None, value=None, confidence=None):
'''Append an observation to the data field
Parameters
----------
time : float >= 0
duration : float >= 0
The time and duration of the new observation, in seconds
value
confidence... | [
"Append",
"an",
"observation",
"to",
"the",
"data",
"field"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L675-L699 | [
"def",
"append",
"(",
"self",
",",
"time",
"=",
"None",
",",
"duration",
"=",
"None",
",",
"value",
"=",
"None",
",",
"confidence",
"=",
"None",
")",
":",
"self",
".",
"data",
".",
"add",
"(",
"Observation",
"(",
"time",
"=",
"float",
"(",
"time",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.append_records | Add observations from row-major storage.
This is primarily useful for deserializing sparsely packed data.
Parameters
----------
records : iterable of dicts or Observations
Each element of `records` corresponds to one observation. | jams/core.py | def append_records(self, records):
'''Add observations from row-major storage.
This is primarily useful for deserializing sparsely packed data.
Parameters
----------
records : iterable of dicts or Observations
Each element of `records` corresponds to one observation... | def append_records(self, records):
'''Add observations from row-major storage.
This is primarily useful for deserializing sparsely packed data.
Parameters
----------
records : iterable of dicts or Observations
Each element of `records` corresponds to one observation... | [
"Add",
"observations",
"from",
"row",
"-",
"major",
"storage",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L701-L715 | [
"def",
"append_records",
"(",
"self",
",",
"records",
")",
":",
"for",
"obs",
"in",
"records",
":",
"if",
"isinstance",
"(",
"obs",
",",
"Observation",
")",
":",
"self",
".",
"append",
"(",
"*",
"*",
"obs",
".",
"_asdict",
"(",
")",
")",
"else",
":... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.append_columns | Add observations from column-major storage.
This is primarily used for deserializing densely packed data.
Parameters
----------
columns : dict of lists
Keys must be `time, duration, value, confidence`,
and each much be a list of equal length. | jams/core.py | def append_columns(self, columns):
'''Add observations from column-major storage.
This is primarily used for deserializing densely packed data.
Parameters
----------
columns : dict of lists
Keys must be `time, duration, value, confidence`,
and each much ... | def append_columns(self, columns):
'''Add observations from column-major storage.
This is primarily used for deserializing densely packed data.
Parameters
----------
columns : dict of lists
Keys must be `time, duration, value, confidence`,
and each much ... | [
"Add",
"observations",
"from",
"column",
"-",
"major",
"storage",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L717-L734 | [
"def",
"append_columns",
"(",
"self",
",",
"columns",
")",
":",
"self",
".",
"append_records",
"(",
"[",
"dict",
"(",
"time",
"=",
"t",
",",
"duration",
"=",
"d",
",",
"value",
"=",
"v",
",",
"confidence",
"=",
"c",
")",
"for",
"(",
"t",
",",
"d"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.validate | Validate this annotation object against the JAMS schema,
and its data against the namespace schema.
Parameters
----------
strict : bool
If `True`, then schema violations will cause an Exception.
If `False`, then schema violations will issue a warning.
Re... | jams/core.py | def validate(self, strict=True):
'''Validate this annotation object against the JAMS schema,
and its data against the namespace schema.
Parameters
----------
strict : bool
If `True`, then schema violations will cause an Exception.
If `False`, then schema ... | def validate(self, strict=True):
'''Validate this annotation object against the JAMS schema,
and its data against the namespace schema.
Parameters
----------
strict : bool
If `True`, then schema violations will cause an Exception.
If `False`, then schema ... | [
"Validate",
"this",
"annotation",
"object",
"against",
"the",
"JAMS",
"schema",
"and",
"its",
"data",
"against",
"the",
"namespace",
"schema",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L736-L783 | [
"def",
"validate",
"(",
"self",
",",
"strict",
"=",
"True",
")",
":",
"# Get the schema for this annotation",
"ann_schema",
"=",
"schema",
".",
"namespace_array",
"(",
"self",
".",
"namespace",
")",
"valid",
"=",
"True",
"try",
":",
"jsonschema",
".",
"validat... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.trim | Trim the annotation and return as a new `Annotation` object.
Trimming will result in the new annotation only containing observations
that occur in the intersection of the time range spanned by the
annotation and the time range specified by the user. The new annotation
will span the time... | jams/core.py | def trim(self, start_time, end_time, strict=False):
'''
Trim the annotation and return as a new `Annotation` object.
Trimming will result in the new annotation only containing observations
that occur in the intersection of the time range spanned by the
annotation and the time ra... | def trim(self, start_time, end_time, strict=False):
'''
Trim the annotation and return as a new `Annotation` object.
Trimming will result in the new annotation only containing observations
that occur in the intersection of the time range spanned by the
annotation and the time ra... | [
"Trim",
"the",
"annotation",
"and",
"return",
"as",
"a",
"new",
"Annotation",
"object",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L785-L941 | [
"def",
"trim",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"strict",
"=",
"False",
")",
":",
"# Check for basic start_time and end_time validity",
"if",
"end_time",
"<=",
"start_time",
":",
"raise",
"ParameterError",
"(",
"'end_time must be greater than start_... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.slice | Slice the annotation and return as a new `Annotation` object.
Slicing has the same effect as trimming (see `Annotation.trim`) except
that while trimming does not modify the start time of the annotation or
the observations it contains, slicing will set the new annotation's
start time to ... | jams/core.py | def slice(self, start_time, end_time, strict=False):
'''
Slice the annotation and return as a new `Annotation` object.
Slicing has the same effect as trimming (see `Annotation.trim`) except
that while trimming does not modify the start time of the annotation or
the observations ... | def slice(self, start_time, end_time, strict=False):
'''
Slice the annotation and return as a new `Annotation` object.
Slicing has the same effect as trimming (see `Annotation.trim`) except
that while trimming does not modify the start time of the annotation or
the observations ... | [
"Slice",
"the",
"annotation",
"and",
"return",
"as",
"a",
"new",
"Annotation",
"object",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L943-L1050 | [
"def",
"slice",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"strict",
"=",
"False",
")",
":",
"# start by trimming the annotation",
"sliced_ann",
"=",
"self",
".",
"trim",
"(",
"start_time",
",",
"end_time",
",",
"strict",
"=",
"strict",
")",
"raw_... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.pop_data | Replace this observation's data with a fresh container.
Returns
-------
annotation_data : SortedKeyList
The original annotation data container | jams/core.py | def pop_data(self):
'''Replace this observation's data with a fresh container.
Returns
-------
annotation_data : SortedKeyList
The original annotation data container
'''
data = self.data
self.data = SortedKeyList(key=self._key)
return data | def pop_data(self):
'''Replace this observation's data with a fresh container.
Returns
-------
annotation_data : SortedKeyList
The original annotation data container
'''
data = self.data
self.data = SortedKeyList(key=self._key)
return data | [
"Replace",
"this",
"observation",
"s",
"data",
"with",
"a",
"fresh",
"container",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1052-L1063 | [
"def",
"pop_data",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"data",
"self",
".",
"data",
"=",
"SortedKeyList",
"(",
"key",
"=",
"self",
".",
"_key",
")",
"return",
"data"
] | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.to_interval_values | Extract observation data in a `mir_eval`-friendly format.
Returns
-------
intervals : np.ndarray [shape=(n, 2), dtype=float]
Start- and end-times of all valued intervals
`intervals[i, :] = [time[i], time[i] + duration[i]]`
labels : list
List view of... | jams/core.py | def to_interval_values(self):
'''Extract observation data in a `mir_eval`-friendly format.
Returns
-------
intervals : np.ndarray [shape=(n, 2), dtype=float]
Start- and end-times of all valued intervals
`intervals[i, :] = [time[i], time[i] + duration[i]]`
... | def to_interval_values(self):
'''Extract observation data in a `mir_eval`-friendly format.
Returns
-------
intervals : np.ndarray [shape=(n, 2), dtype=float]
Start- and end-times of all valued intervals
`intervals[i, :] = [time[i], time[i] + duration[i]]`
... | [
"Extract",
"observation",
"data",
"in",
"a",
"mir_eval",
"-",
"friendly",
"format",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1065-L1087 | [
"def",
"to_interval_values",
"(",
"self",
")",
":",
"ints",
",",
"vals",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"obs",
"in",
"self",
".",
"data",
":",
"ints",
".",
"append",
"(",
"[",
"obs",
".",
"time",
",",
"obs",
".",
"time",
"+",
"obs",
".",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.to_event_values | Extract observation data in a `mir_eval`-friendly format.
Returns
-------
times : np.ndarray [shape=(n,), dtype=float]
Start-time of all observations
labels : list
List view of value field. | jams/core.py | def to_event_values(self):
'''Extract observation data in a `mir_eval`-friendly format.
Returns
-------
times : np.ndarray [shape=(n,), dtype=float]
Start-time of all observations
labels : list
List view of value field.
'''
ints, vals = [... | def to_event_values(self):
'''Extract observation data in a `mir_eval`-friendly format.
Returns
-------
times : np.ndarray [shape=(n,), dtype=float]
Start-time of all observations
labels : list
List view of value field.
'''
ints, vals = [... | [
"Extract",
"observation",
"data",
"in",
"a",
"mir_eval",
"-",
"friendly",
"format",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1089-L1105 | [
"def",
"to_event_values",
"(",
"self",
")",
":",
"ints",
",",
"vals",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"obs",
"in",
"self",
".",
"data",
":",
"ints",
".",
"append",
"(",
"obs",
".",
"time",
")",
"vals",
".",
"append",
"(",
"obs",
".",
"valu... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.to_samples | Sample the annotation at specified times.
Parameters
----------
times : np.ndarray, non-negative, ndim=1
The times (in seconds) to sample the annotation
confidence : bool
If `True`, return both values and confidences.
If `False` (default) only return... | jams/core.py | def to_samples(self, times, confidence=False):
'''Sample the annotation at specified times.
Parameters
----------
times : np.ndarray, non-negative, ndim=1
The times (in seconds) to sample the annotation
confidence : bool
If `True`, return both values and... | def to_samples(self, times, confidence=False):
'''Sample the annotation at specified times.
Parameters
----------
times : np.ndarray, non-negative, ndim=1
The times (in seconds) to sample the annotation
confidence : bool
If `True`, return both values and... | [
"Sample",
"the",
"annotation",
"at",
"specified",
"times",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1121-L1162 | [
"def",
"to_samples",
"(",
"self",
",",
"times",
",",
"confidence",
"=",
"False",
")",
":",
"times",
"=",
"np",
".",
"asarray",
"(",
"times",
")",
"if",
"times",
".",
"ndim",
"!=",
"1",
"or",
"np",
".",
"any",
"(",
"times",
"<",
"0",
")",
":",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation.to_html | Render this annotation list in HTML
Returns
-------
rendered : str
An HTML table containing this annotation's data. | jams/core.py | def to_html(self, max_rows=None):
'''Render this annotation list in HTML
Returns
-------
rendered : str
An HTML table containing this annotation's data.
'''
n = len(self.data)
div_id = _get_divid(self)
out = r''' <div class="panel panel-def... | def to_html(self, max_rows=None):
'''Render this annotation list in HTML
Returns
-------
rendered : str
An HTML table containing this annotation's data.
'''
n = len(self.data)
div_id = _get_divid(self)
out = r''' <div class="panel panel-def... | [
"Render",
"this",
"annotation",
"list",
"in",
"HTML"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1167-L1237 | [
"def",
"to_html",
"(",
"self",
",",
"max_rows",
"=",
"None",
")",
":",
"n",
"=",
"len",
"(",
"self",
".",
"data",
")",
"div_id",
"=",
"_get_divid",
"(",
"self",
")",
"out",
"=",
"r''' <div class=\"panel panel-default\">\n <div class=\"panel... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | Annotation._key | Provides sorting index for Observation objects | jams/core.py | def _key(cls, obs):
'''Provides sorting index for Observation objects'''
if not isinstance(obs, Observation):
raise JamsError('{} must be of type jams.Observation'.format(obs))
return obs.time | def _key(cls, obs):
'''Provides sorting index for Observation objects'''
if not isinstance(obs, Observation):
raise JamsError('{} must be of type jams.Observation'.format(obs))
return obs.time | [
"Provides",
"sorting",
"index",
"for",
"Observation",
"objects"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1305-L1310 | [
"def",
"_key",
"(",
"cls",
",",
"obs",
")",
":",
"if",
"not",
"isinstance",
"(",
"obs",
",",
"Observation",
")",
":",
"raise",
"JamsError",
"(",
"'{} must be of type jams.Observation'",
".",
"format",
"(",
"obs",
")",
")",
"return",
"obs",
".",
"time"
] | b16778399b9528efbd71434842a079f7691a7a66 |
valid | AnnotationArray.search | Filter the annotation array down to only those Annotation
objects matching the query.
Parameters
----------
kwargs : search parameters
See JObject.search
Returns
-------
results : AnnotationArray
An annotation array of the objects matchi... | jams/core.py | def search(self, **kwargs):
'''Filter the annotation array down to only those Annotation
objects matching the query.
Parameters
----------
kwargs : search parameters
See JObject.search
Returns
-------
results : AnnotationArray
An... | def search(self, **kwargs):
'''Filter the annotation array down to only those Annotation
objects matching the query.
Parameters
----------
kwargs : search parameters
See JObject.search
Returns
-------
results : AnnotationArray
An... | [
"Filter",
"the",
"annotation",
"array",
"down",
"to",
"only",
"those",
"Annotation",
"objects",
"matching",
"the",
"query",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1504-L1530 | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"results",
"=",
"AnnotationArray",
"(",
")",
"for",
"annotation",
"in",
"self",
":",
"if",
"annotation",
".",
"search",
"(",
"*",
"*",
"kwargs",
")",
":",
"results",
".",
"append",
"(",... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | AnnotationArray.trim | Trim every annotation contained in the annotation array using
`Annotation.trim` and return as a new `AnnotationArray`.
See `Annotation.trim` for details about trimming. This function does
not modify the annotations in the original annotation array.
Parameters
----------
... | jams/core.py | def trim(self, start_time, end_time, strict=False):
'''
Trim every annotation contained in the annotation array using
`Annotation.trim` and return as a new `AnnotationArray`.
See `Annotation.trim` for details about trimming. This function does
not modify the annotations in the o... | def trim(self, start_time, end_time, strict=False):
'''
Trim every annotation contained in the annotation array using
`Annotation.trim` and return as a new `AnnotationArray`.
See `Annotation.trim` for details about trimming. This function does
not modify the annotations in the o... | [
"Trim",
"every",
"annotation",
"contained",
"in",
"the",
"annotation",
"array",
"using",
"Annotation",
".",
"trim",
"and",
"return",
"as",
"a",
"new",
"AnnotationArray",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1548-L1581 | [
"def",
"trim",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"strict",
"=",
"False",
")",
":",
"trimmed_array",
"=",
"AnnotationArray",
"(",
")",
"for",
"ann",
"in",
"self",
":",
"trimmed_array",
".",
"append",
"(",
"ann",
".",
"trim",
"(",
"st... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | AnnotationArray.slice | Slice every annotation contained in the annotation array using
`Annotation.slice`
and return as a new AnnotationArray
See `Annotation.slice` for details about slicing. This function does
not modify the annotations in the original annotation array.
Parameters
----------
... | jams/core.py | def slice(self, start_time, end_time, strict=False):
'''
Slice every annotation contained in the annotation array using
`Annotation.slice`
and return as a new AnnotationArray
See `Annotation.slice` for details about slicing. This function does
not modify the annotations ... | def slice(self, start_time, end_time, strict=False):
'''
Slice every annotation contained in the annotation array using
`Annotation.slice`
and return as a new AnnotationArray
See `Annotation.slice` for details about slicing. This function does
not modify the annotations ... | [
"Slice",
"every",
"annotation",
"contained",
"in",
"the",
"annotation",
"array",
"using",
"Annotation",
".",
"slice",
"and",
"return",
"as",
"a",
"new",
"AnnotationArray"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1583-L1616 | [
"def",
"slice",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"strict",
"=",
"False",
")",
":",
"sliced_array",
"=",
"AnnotationArray",
"(",
")",
"for",
"ann",
"in",
"self",
":",
"sliced_array",
".",
"append",
"(",
"ann",
".",
"slice",
"(",
"st... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | JAMS.add | Add the contents of another jam to this object.
Note that, by default, this method fails if file_metadata is not
identical and raises a ValueError; either resolve this manually
(because conflicts should almost never happen), force an 'overwrite',
or tell the method to 'ignore' the metad... | jams/core.py | def add(self, jam, on_conflict='fail'):
"""Add the contents of another jam to this object.
Note that, by default, this method fails if file_metadata is not
identical and raises a ValueError; either resolve this manually
(because conflicts should almost never happen), force an 'overwrite... | def add(self, jam, on_conflict='fail'):
"""Add the contents of another jam to this object.
Note that, by default, this method fails if file_metadata is not
identical and raises a ValueError; either resolve this manually
(because conflicts should almost never happen), force an 'overwrite... | [
"Add",
"the",
"contents",
"of",
"another",
"jam",
"to",
"this",
"object",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1674-L1712 | [
"def",
"add",
"(",
"self",
",",
"jam",
",",
"on_conflict",
"=",
"'fail'",
")",
":",
"if",
"on_conflict",
"not",
"in",
"[",
"'overwrite'",
",",
"'fail'",
",",
"'ignore'",
"]",
":",
"raise",
"ParameterError",
"(",
"\"on_conflict='{}' is not in ['fail', \"",
"\"'... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | JAMS.save | Serialize annotation as a JSON formatted stream to file.
Parameters
----------
path_or_file : str or file-like
Path to save the JAMS object on disk
OR
An open file descriptor to write into
strict : bool
Force strict schema validation
... | jams/core.py | def save(self, path_or_file, strict=True, fmt='auto'):
"""Serialize annotation as a JSON formatted stream to file.
Parameters
----------
path_or_file : str or file-like
Path to save the JAMS object on disk
OR
An open file descriptor to write into
... | def save(self, path_or_file, strict=True, fmt='auto'):
"""Serialize annotation as a JSON formatted stream to file.
Parameters
----------
path_or_file : str or file-like
Path to save the JAMS object on disk
OR
An open file descriptor to write into
... | [
"Serialize",
"annotation",
"as",
"a",
"JSON",
"formatted",
"stream",
"to",
"file",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1743-L1779 | [
"def",
"save",
"(",
"self",
",",
"path_or_file",
",",
"strict",
"=",
"True",
",",
"fmt",
"=",
"'auto'",
")",
":",
"self",
".",
"validate",
"(",
"strict",
"=",
"strict",
")",
"with",
"_open",
"(",
"path_or_file",
",",
"mode",
"=",
"'w'",
",",
"fmt",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | JAMS.validate | Validate a JAMS object against the schema.
Parameters
----------
strict : bool
If `True`, an exception will be raised on validation failure.
If `False`, a warning will be raised on validation failure.
Returns
-------
valid : bool
`Tru... | jams/core.py | def validate(self, strict=True):
'''Validate a JAMS object against the schema.
Parameters
----------
strict : bool
If `True`, an exception will be raised on validation failure.
If `False`, a warning will be raised on validation failure.
Returns
-... | def validate(self, strict=True):
'''Validate a JAMS object against the schema.
Parameters
----------
strict : bool
If `True`, an exception will be raised on validation failure.
If `False`, a warning will be raised on validation failure.
Returns
-... | [
"Validate",
"a",
"JAMS",
"object",
"against",
"the",
"schema",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1781-L1829 | [
"def",
"validate",
"(",
"self",
",",
"strict",
"=",
"True",
")",
":",
"valid",
"=",
"True",
"try",
":",
"jsonschema",
".",
"validate",
"(",
"self",
".",
"__json_light__",
",",
"schema",
".",
"JAMS_SCHEMA",
")",
"for",
"ann",
"in",
"self",
".",
"annotat... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | JAMS.trim | Trim all the annotations inside the jam and return as a new `JAMS`
object.
See `Annotation.trim` for details about how the annotations
are trimmed.
This operation is also documented in the jam-level sandbox
with a list keyed by ``JAMS.sandbox.trim`` containing a tuple for each
... | jams/core.py | def trim(self, start_time, end_time, strict=False):
'''
Trim all the annotations inside the jam and return as a new `JAMS`
object.
See `Annotation.trim` for details about how the annotations
are trimmed.
This operation is also documented in the jam-level sandbox
... | def trim(self, start_time, end_time, strict=False):
'''
Trim all the annotations inside the jam and return as a new `JAMS`
object.
See `Annotation.trim` for details about how the annotations
are trimmed.
This operation is also documented in the jam-level sandbox
... | [
"Trim",
"all",
"the",
"annotations",
"inside",
"the",
"jam",
"and",
"return",
"as",
"a",
"new",
"JAMS",
"object",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1831-L1903 | [
"def",
"trim",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"strict",
"=",
"False",
")",
":",
"# Make sure duration is set in file metadata",
"if",
"self",
".",
"file_metadata",
".",
"duration",
"is",
"None",
":",
"raise",
"JamsError",
"(",
"'Duration m... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | JAMS.slice | Slice all the annotations inside the jam and return as a new `JAMS`
object.
See `Annotation.slice` for details about how the annotations
are sliced.
This operation is also documented in the jam-level sandbox
with a list keyed by ``JAMS.sandbox.slice`` containing a tuple for eac... | jams/core.py | def slice(self, start_time, end_time, strict=False):
'''
Slice all the annotations inside the jam and return as a new `JAMS`
object.
See `Annotation.slice` for details about how the annotations
are sliced.
This operation is also documented in the jam-level sandbox
... | def slice(self, start_time, end_time, strict=False):
'''
Slice all the annotations inside the jam and return as a new `JAMS`
object.
See `Annotation.slice` for details about how the annotations
are sliced.
This operation is also documented in the jam-level sandbox
... | [
"Slice",
"all",
"the",
"annotations",
"inside",
"the",
"jam",
"and",
"return",
"as",
"a",
"new",
"JAMS",
"object",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L1905-L1984 | [
"def",
"slice",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"strict",
"=",
"False",
")",
":",
"# Make sure duration is set in file metadata",
"if",
"self",
".",
"file_metadata",
".",
"duration",
"is",
"None",
":",
"raise",
"JamsError",
"(",
"'Duration ... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | pprint_jobject | Pretty-print a jobject.
Parameters
----------
obj : jams.JObject
kwargs
additional parameters to `json.dumps`
Returns
-------
string
A simplified display of `obj` contents. | jams/display.py | def pprint_jobject(obj, **kwargs):
'''Pretty-print a jobject.
Parameters
----------
obj : jams.JObject
kwargs
additional parameters to `json.dumps`
Returns
-------
string
A simplified display of `obj` contents.
'''
obj_simple = {k: v for k, v in six.iteritems(... | def pprint_jobject(obj, **kwargs):
'''Pretty-print a jobject.
Parameters
----------
obj : jams.JObject
kwargs
additional parameters to `json.dumps`
Returns
-------
string
A simplified display of `obj` contents.
'''
obj_simple = {k: v for k, v in six.iteritems(... | [
"Pretty",
"-",
"print",
"a",
"jobject",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/display.py#L32-L61 | [
"def",
"pprint_jobject",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"obj_simple",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"obj",
".",
"__json__",
")",
"if",
"v",
"}",
"string",
"=",
"json",
".",
"d... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | intervals | Plotting wrapper for labeled intervals | jams/display.py | def intervals(annotation, **kwargs):
'''Plotting wrapper for labeled intervals'''
times, labels = annotation.to_interval_values()
return mir_eval.display.labeled_intervals(times, labels, **kwargs) | def intervals(annotation, **kwargs):
'''Plotting wrapper for labeled intervals'''
times, labels = annotation.to_interval_values()
return mir_eval.display.labeled_intervals(times, labels, **kwargs) | [
"Plotting",
"wrapper",
"for",
"labeled",
"intervals"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/display.py#L64-L68 | [
"def",
"intervals",
"(",
"annotation",
",",
"*",
"*",
"kwargs",
")",
":",
"times",
",",
"labels",
"=",
"annotation",
".",
"to_interval_values",
"(",
")",
"return",
"mir_eval",
".",
"display",
".",
"labeled_intervals",
"(",
"times",
",",
"labels",
",",
"*",... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | hierarchy | Plotting wrapper for hierarchical segmentations | jams/display.py | def hierarchy(annotation, **kwargs):
'''Plotting wrapper for hierarchical segmentations'''
htimes, hlabels = hierarchy_flatten(annotation)
htimes = [np.asarray(_) for _ in htimes]
return mir_eval.display.hierarchy(htimes, hlabels, **kwargs) | def hierarchy(annotation, **kwargs):
'''Plotting wrapper for hierarchical segmentations'''
htimes, hlabels = hierarchy_flatten(annotation)
htimes = [np.asarray(_) for _ in htimes]
return mir_eval.display.hierarchy(htimes, hlabels, **kwargs) | [
"Plotting",
"wrapper",
"for",
"hierarchical",
"segmentations"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/display.py#L71-L76 | [
"def",
"hierarchy",
"(",
"annotation",
",",
"*",
"*",
"kwargs",
")",
":",
"htimes",
",",
"hlabels",
"=",
"hierarchy_flatten",
"(",
"annotation",
")",
"htimes",
"=",
"[",
"np",
".",
"asarray",
"(",
"_",
")",
"for",
"_",
"in",
"htimes",
"]",
"return",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | pitch_contour | Plotting wrapper for pitch contours | jams/display.py | def pitch_contour(annotation, **kwargs):
'''Plotting wrapper for pitch contours'''
ax = kwargs.pop('ax', None)
# If the annotation is empty, we need to construct a new axes
ax = mir_eval.display.__get_axes(ax=ax)[0]
times, values = annotation.to_interval_values()
indices = np.unique([v['index... | def pitch_contour(annotation, **kwargs):
'''Plotting wrapper for pitch contours'''
ax = kwargs.pop('ax', None)
# If the annotation is empty, we need to construct a new axes
ax = mir_eval.display.__get_axes(ax=ax)[0]
times, values = annotation.to_interval_values()
indices = np.unique([v['index... | [
"Plotting",
"wrapper",
"for",
"pitch",
"contours"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/display.py#L79-L99 | [
"def",
"pitch_contour",
"(",
"annotation",
",",
"*",
"*",
"kwargs",
")",
":",
"ax",
"=",
"kwargs",
".",
"pop",
"(",
"'ax'",
",",
"None",
")",
"# If the annotation is empty, we need to construct a new axes",
"ax",
"=",
"mir_eval",
".",
"display",
".",
"__get_axes... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | event | Plotting wrapper for events | jams/display.py | def event(annotation, **kwargs):
'''Plotting wrapper for events'''
times, values = annotation.to_interval_values()
if any(values):
labels = values
else:
labels = None
return mir_eval.display.events(times, labels=labels, **kwargs) | def event(annotation, **kwargs):
'''Plotting wrapper for events'''
times, values = annotation.to_interval_values()
if any(values):
labels = values
else:
labels = None
return mir_eval.display.events(times, labels=labels, **kwargs) | [
"Plotting",
"wrapper",
"for",
"events"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/display.py#L102-L112 | [
"def",
"event",
"(",
"annotation",
",",
"*",
"*",
"kwargs",
")",
":",
"times",
",",
"values",
"=",
"annotation",
".",
"to_interval_values",
"(",
")",
"if",
"any",
"(",
"values",
")",
":",
"labels",
"=",
"values",
"else",
":",
"labels",
"=",
"None",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | beat_position | Plotting wrapper for beat-position data | jams/display.py | def beat_position(annotation, **kwargs):
'''Plotting wrapper for beat-position data'''
times, values = annotation.to_interval_values()
labels = [_['position'] for _ in values]
# TODO: plot time signature, measure number
return mir_eval.display.events(times, labels=labels, **kwargs) | def beat_position(annotation, **kwargs):
'''Plotting wrapper for beat-position data'''
times, values = annotation.to_interval_values()
labels = [_['position'] for _ in values]
# TODO: plot time signature, measure number
return mir_eval.display.events(times, labels=labels, **kwargs) | [
"Plotting",
"wrapper",
"for",
"beat",
"-",
"position",
"data"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/display.py#L115-L123 | [
"def",
"beat_position",
"(",
"annotation",
",",
"*",
"*",
"kwargs",
")",
":",
"times",
",",
"values",
"=",
"annotation",
".",
"to_interval_values",
"(",
")",
"labels",
"=",
"[",
"_",
"[",
"'position'",
"]",
"for",
"_",
"in",
"values",
"]",
"# TODO: plot ... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | piano_roll | Plotting wrapper for piano rolls | jams/display.py | def piano_roll(annotation, **kwargs):
'''Plotting wrapper for piano rolls'''
times, midi = annotation.to_interval_values()
return mir_eval.display.piano_roll(times, midi=midi, **kwargs) | def piano_roll(annotation, **kwargs):
'''Plotting wrapper for piano rolls'''
times, midi = annotation.to_interval_values()
return mir_eval.display.piano_roll(times, midi=midi, **kwargs) | [
"Plotting",
"wrapper",
"for",
"piano",
"rolls"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/display.py#L126-L130 | [
"def",
"piano_roll",
"(",
"annotation",
",",
"*",
"*",
"kwargs",
")",
":",
"times",
",",
"midi",
"=",
"annotation",
".",
"to_interval_values",
"(",
")",
"return",
"mir_eval",
".",
"display",
".",
"piano_roll",
"(",
"times",
",",
"midi",
"=",
"midi",
",",... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | display | Visualize a jams annotation through mir_eval
Parameters
----------
annotation : jams.Annotation
The annotation to display
meta : bool
If `True`, include annotation metadata in the figure
kwargs
Additional keyword arguments to mir_eval.display functions
Returns
---... | jams/display.py | def display(annotation, meta=True, **kwargs):
'''Visualize a jams annotation through mir_eval
Parameters
----------
annotation : jams.Annotation
The annotation to display
meta : bool
If `True`, include annotation metadata in the figure
kwargs
Additional keyword argumen... | def display(annotation, meta=True, **kwargs):
'''Visualize a jams annotation through mir_eval
Parameters
----------
annotation : jams.Annotation
The annotation to display
meta : bool
If `True`, include annotation metadata in the figure
kwargs
Additional keyword argumen... | [
"Visualize",
"a",
"jams",
"annotation",
"through",
"mir_eval"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/display.py#L146-L197 | [
"def",
"display",
"(",
"annotation",
",",
"meta",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"namespace",
",",
"func",
"in",
"six",
".",
"iteritems",
"(",
"VIZ_MAPPING",
")",
":",
"try",
":",
"ann",
"=",
"coerce_annotation",
"(",
"annotatio... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | display_multi | Display multiple annotations with shared axes
Parameters
----------
annotations : jams.AnnotationArray
A collection of annotations to display
fig_kw : dict
Keyword arguments to `plt.figure`
meta : bool
If `True`, display annotation metadata for each annotation
kwargs
... | jams/display.py | def display_multi(annotations, fig_kw=None, meta=True, **kwargs):
'''Display multiple annotations with shared axes
Parameters
----------
annotations : jams.AnnotationArray
A collection of annotations to display
fig_kw : dict
Keyword arguments to `plt.figure`
meta : bool
... | def display_multi(annotations, fig_kw=None, meta=True, **kwargs):
'''Display multiple annotations with shared axes
Parameters
----------
annotations : jams.AnnotationArray
A collection of annotations to display
fig_kw : dict
Keyword arguments to `plt.figure`
meta : bool
... | [
"Display",
"multiple",
"annotations",
"with",
"shared",
"axes"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/display.py#L200-L253 | [
"def",
"display_multi",
"(",
"annotations",
",",
"fig_kw",
"=",
"None",
",",
"meta",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"fig_kw",
"is",
"None",
":",
"fig_kw",
"=",
"dict",
"(",
")",
"fig_kw",
".",
"setdefault",
"(",
"'sharex'",
","... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | mkclick | Generate a click sample.
This replicates functionality from mir_eval.sonify.clicks,
but exposes the target frequency and duration. | jams/sonify.py | def mkclick(freq, sr=22050, duration=0.1):
'''Generate a click sample.
This replicates functionality from mir_eval.sonify.clicks,
but exposes the target frequency and duration.
'''
times = np.arange(int(sr * duration))
click = np.sin(2 * np.pi * times * freq / float(sr))
click *= np.exp(- ... | def mkclick(freq, sr=22050, duration=0.1):
'''Generate a click sample.
This replicates functionality from mir_eval.sonify.clicks,
but exposes the target frequency and duration.
'''
times = np.arange(int(sr * duration))
click = np.sin(2 * np.pi * times * freq / float(sr))
click *= np.exp(- ... | [
"Generate",
"a",
"click",
"sample",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/sonify.py#L25-L36 | [
"def",
"mkclick",
"(",
"freq",
",",
"sr",
"=",
"22050",
",",
"duration",
"=",
"0.1",
")",
":",
"times",
"=",
"np",
".",
"arange",
"(",
"int",
"(",
"sr",
"*",
"duration",
")",
")",
"click",
"=",
"np",
".",
"sin",
"(",
"2",
"*",
"np",
".",
"pi"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | clicks | Sonify events with clicks.
This uses mir_eval.sonify.clicks, and is appropriate for instantaneous
events such as beats or segment boundaries. | jams/sonify.py | def clicks(annotation, sr=22050, length=None, **kwargs):
'''Sonify events with clicks.
This uses mir_eval.sonify.clicks, and is appropriate for instantaneous
events such as beats or segment boundaries.
'''
interval, _ = annotation.to_interval_values()
return filter_kwargs(mir_eval.sonify.clic... | def clicks(annotation, sr=22050, length=None, **kwargs):
'''Sonify events with clicks.
This uses mir_eval.sonify.clicks, and is appropriate for instantaneous
events such as beats or segment boundaries.
'''
interval, _ = annotation.to_interval_values()
return filter_kwargs(mir_eval.sonify.clic... | [
"Sonify",
"events",
"with",
"clicks",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/sonify.py#L39-L49 | [
"def",
"clicks",
"(",
"annotation",
",",
"sr",
"=",
"22050",
",",
"length",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"interval",
",",
"_",
"=",
"annotation",
".",
"to_interval_values",
"(",
")",
"return",
"filter_kwargs",
"(",
"mir_eval",
".",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | downbeat | Sonify beats and downbeats together. | jams/sonify.py | def downbeat(annotation, sr=22050, length=None, **kwargs):
'''Sonify beats and downbeats together.
'''
beat_click = mkclick(440 * 2, sr=sr)
downbeat_click = mkclick(440 * 3, sr=sr)
intervals, values = annotation.to_interval_values()
beats, downbeats = [], []
for time, value in zip(interv... | def downbeat(annotation, sr=22050, length=None, **kwargs):
'''Sonify beats and downbeats together.
'''
beat_click = mkclick(440 * 2, sr=sr)
downbeat_click = mkclick(440 * 3, sr=sr)
intervals, values = annotation.to_interval_values()
beats, downbeats = [], []
for time, value in zip(interv... | [
"Sonify",
"beats",
"and",
"downbeats",
"together",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/sonify.py#L52-L80 | [
"def",
"downbeat",
"(",
"annotation",
",",
"sr",
"=",
"22050",
",",
"length",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"beat_click",
"=",
"mkclick",
"(",
"440",
"*",
"2",
",",
"sr",
"=",
"sr",
")",
"downbeat_click",
"=",
"mkclick",
"(",
"440... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | multi_segment | Sonify multi-level segmentations | jams/sonify.py | def multi_segment(annotation, sr=22050, length=None, **kwargs):
'''Sonify multi-level segmentations'''
# Pentatonic scale, because why not
PENT = [1, 32./27, 4./3, 3./2, 16./9]
DURATION = 0.1
h_int, _ = hierarchy_flatten(annotation)
if length is None:
length = int(sr * (max(np.max(_) ... | def multi_segment(annotation, sr=22050, length=None, **kwargs):
'''Sonify multi-level segmentations'''
# Pentatonic scale, because why not
PENT = [1, 32./27, 4./3, 3./2, 16./9]
DURATION = 0.1
h_int, _ = hierarchy_flatten(annotation)
if length is None:
length = int(sr * (max(np.max(_) ... | [
"Sonify",
"multi",
"-",
"level",
"segmentations"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/sonify.py#L83-L103 | [
"def",
"multi_segment",
"(",
"annotation",
",",
"sr",
"=",
"22050",
",",
"length",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Pentatonic scale, because why not",
"PENT",
"=",
"[",
"1",
",",
"32.",
"/",
"27",
",",
"4.",
"/",
"3",
",",
"3.",
"/... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | chord | Sonify chords
This uses mir_eval.sonify.chords. | jams/sonify.py | def chord(annotation, sr=22050, length=None, **kwargs):
'''Sonify chords
This uses mir_eval.sonify.chords.
'''
intervals, chords = annotation.to_interval_values()
return filter_kwargs(mir_eval.sonify.chords,
chords, intervals,
fs=sr, length=length... | def chord(annotation, sr=22050, length=None, **kwargs):
'''Sonify chords
This uses mir_eval.sonify.chords.
'''
intervals, chords = annotation.to_interval_values()
return filter_kwargs(mir_eval.sonify.chords,
chords, intervals,
fs=sr, length=length... | [
"Sonify",
"chords"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/sonify.py#L106-L117 | [
"def",
"chord",
"(",
"annotation",
",",
"sr",
"=",
"22050",
",",
"length",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"intervals",
",",
"chords",
"=",
"annotation",
".",
"to_interval_values",
"(",
")",
"return",
"filter_kwargs",
"(",
"mir_eval",
"."... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | pitch_contour | Sonify pitch contours.
This uses mir_eval.sonify.pitch_contour, and should only be applied
to pitch annotations using the pitch_contour namespace.
Each contour is sonified independently, and the resulting waveforms
are summed together. | jams/sonify.py | def pitch_contour(annotation, sr=22050, length=None, **kwargs):
'''Sonify pitch contours.
This uses mir_eval.sonify.pitch_contour, and should only be applied
to pitch annotations using the pitch_contour namespace.
Each contour is sonified independently, and the resulting waveforms
are summed toget... | def pitch_contour(annotation, sr=22050, length=None, **kwargs):
'''Sonify pitch contours.
This uses mir_eval.sonify.pitch_contour, and should only be applied
to pitch annotations using the pitch_contour namespace.
Each contour is sonified independently, and the resulting waveforms
are summed toget... | [
"Sonify",
"pitch",
"contours",
"."
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/sonify.py#L120-L150 | [
"def",
"pitch_contour",
"(",
"annotation",
",",
"sr",
"=",
"22050",
",",
"length",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Map contours to lists of observations",
"times",
"=",
"defaultdict",
"(",
"list",
")",
"freqs",
"=",
"defaultdict",
"(",
"li... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | piano_roll | Sonify a piano-roll
This uses mir_eval.sonify.time_frequency, and is appropriate
for sparse transcription data, e.g., annotations in the `note_midi`
namespace. | jams/sonify.py | def piano_roll(annotation, sr=22050, length=None, **kwargs):
'''Sonify a piano-roll
This uses mir_eval.sonify.time_frequency, and is appropriate
for sparse transcription data, e.g., annotations in the `note_midi`
namespace.
'''
intervals, pitches = annotation.to_interval_values()
# Constr... | def piano_roll(annotation, sr=22050, length=None, **kwargs):
'''Sonify a piano-roll
This uses mir_eval.sonify.time_frequency, and is appropriate
for sparse transcription data, e.g., annotations in the `note_midi`
namespace.
'''
intervals, pitches = annotation.to_interval_values()
# Constr... | [
"Sonify",
"a",
"piano",
"-",
"roll"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/sonify.py#L153-L173 | [
"def",
"piano_roll",
"(",
"annotation",
",",
"sr",
"=",
"22050",
",",
"length",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"intervals",
",",
"pitches",
"=",
"annotation",
".",
"to_interval_values",
"(",
")",
"# Construct the pitchogram",
"pitch_map",
"=... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | sonify | Sonify a jams annotation through mir_eval
Parameters
----------
annotation : jams.Annotation
The annotation to sonify
sr = : positive number
The sampling rate of the output waveform
duration : float (optional)
Optional length (in seconds) of the output waveform
kwargs... | jams/sonify.py | def sonify(annotation, sr=22050, duration=None, **kwargs):
'''Sonify a jams annotation through mir_eval
Parameters
----------
annotation : jams.Annotation
The annotation to sonify
sr = : positive number
The sampling rate of the output waveform
duration : float (optional)
... | def sonify(annotation, sr=22050, duration=None, **kwargs):
'''Sonify a jams annotation through mir_eval
Parameters
----------
annotation : jams.Annotation
The annotation to sonify
sr = : positive number
The sampling rate of the output waveform
duration : float (optional)
... | [
"Sonify",
"a",
"jams",
"annotation",
"through",
"mir_eval"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/sonify.py#L187-L239 | [
"def",
"sonify",
"(",
"annotation",
",",
"sr",
"=",
"22050",
",",
"duration",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"length",
"=",
"None",
"if",
"duration",
"is",
"None",
":",
"duration",
"=",
"annotation",
".",
"duration",
"if",
"duration",
... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | validate | Validate a jams file against a schema | jams/schemata/validate.py | def validate(schema_file=None, jams_files=None):
'''Validate a jams file against a schema'''
schema = load_json(schema_file)
for jams_file in jams_files:
try:
jams = load_json(jams_file)
jsonschema.validate(jams, schema)
print '{:s} was successfully validated'.f... | def validate(schema_file=None, jams_files=None):
'''Validate a jams file against a schema'''
schema = load_json(schema_file)
for jams_file in jams_files:
try:
jams = load_json(jams_file)
jsonschema.validate(jams, schema)
print '{:s} was successfully validated'.f... | [
"Validate",
"a",
"jams",
"file",
"against",
"a",
"schema"
] | marl/jams | python | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/schemata/validate.py#L31-L44 | [
"def",
"validate",
"(",
"schema_file",
"=",
"None",
",",
"jams_files",
"=",
"None",
")",
":",
"schema",
"=",
"load_json",
"(",
"schema_file",
")",
"for",
"jams_file",
"in",
"jams_files",
":",
"try",
":",
"jams",
"=",
"load_json",
"(",
"jams_file",
")",
"... | b16778399b9528efbd71434842a079f7691a7a66 |
valid | StreamSASLHandler.make_stream_features | Add SASL features to the <features/> element of the stream.
[receving entity only]
:returns: update <features/> element. | pyxmpp2/streamsasl.py | def make_stream_features(self, stream, features):
"""Add SASL features to the <features/> element of the stream.
[receving entity only]
:returns: update <features/> element."""
mechs = self.settings['sasl_mechanisms']
if mechs and not stream.authenticated:
sub = Ele... | def make_stream_features(self, stream, features):
"""Add SASL features to the <features/> element of the stream.
[receving entity only]
:returns: update <features/> element."""
mechs = self.settings['sasl_mechanisms']
if mechs and not stream.authenticated:
sub = Ele... | [
"Add",
"SASL",
"features",
"to",
"the",
"<features",
"/",
">",
"element",
"of",
"the",
"stream",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L98-L110 | [
"def",
"make_stream_features",
"(",
"self",
",",
"stream",
",",
"features",
")",
":",
"mechs",
"=",
"self",
".",
"settings",
"[",
"'sasl_mechanisms'",
"]",
"if",
"mechs",
"and",
"not",
"stream",
".",
"authenticated",
":",
"sub",
"=",
"ElementTree",
".",
"S... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler.handle_stream_features | Process incoming <stream:features/> element.
[initiating entity only] | pyxmpp2/streamsasl.py | def handle_stream_features(self, stream, features):
"""Process incoming <stream:features/> element.
[initiating entity only]
"""
element = features.find(MECHANISMS_TAG)
self.peer_sasl_mechanisms = []
if element is None:
return None
for sub in element:... | def handle_stream_features(self, stream, features):
"""Process incoming <stream:features/> element.
[initiating entity only]
"""
element = features.find(MECHANISMS_TAG)
self.peer_sasl_mechanisms = []
if element is None:
return None
for sub in element:... | [
"Process",
"incoming",
"<stream",
":",
"features",
"/",
">",
"element",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L112-L137 | [
"def",
"handle_stream_features",
"(",
"self",
",",
"stream",
",",
"features",
")",
":",
"element",
"=",
"features",
".",
"find",
"(",
"MECHANISMS_TAG",
")",
"self",
".",
"peer_sasl_mechanisms",
"=",
"[",
"]",
"if",
"element",
"is",
"None",
":",
"return",
"... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler.process_sasl_auth | Process incoming <sasl:auth/> element.
[receiving entity only] | pyxmpp2/streamsasl.py | def process_sasl_auth(self, stream, element):
"""Process incoming <sasl:auth/> element.
[receiving entity only]
"""
if self.authenticator:
logger.debug("Authentication already started")
return False
password_db = self.settings["password_database"]
... | def process_sasl_auth(self, stream, element):
"""Process incoming <sasl:auth/> element.
[receiving entity only]
"""
if self.authenticator:
logger.debug("Authentication already started")
return False
password_db = self.settings["password_database"]
... | [
"Process",
"incoming",
"<sasl",
":",
"auth",
"/",
">",
"element",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L140-L180 | [
"def",
"process_sasl_auth",
"(",
"self",
",",
"stream",
",",
"element",
")",
":",
"if",
"self",
".",
"authenticator",
":",
"logger",
".",
"debug",
"(",
"\"Authentication already started\"",
")",
"return",
"False",
"password_db",
"=",
"self",
".",
"settings",
"... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler._handle_auth_success | Handle successful authentication.
Send <success/> and mark the stream peer authenticated.
[receiver only] | pyxmpp2/streamsasl.py | def _handle_auth_success(self, stream, success):
"""Handle successful authentication.
Send <success/> and mark the stream peer authenticated.
[receiver only]
"""
if not self._check_authorization(success.properties, stream):
element = ElementTree.Element(FAILURE_TAG)... | def _handle_auth_success(self, stream, success):
"""Handle successful authentication.
Send <success/> and mark the stream peer authenticated.
[receiver only]
"""
if not self._check_authorization(success.properties, stream):
element = ElementTree.Element(FAILURE_TAG)... | [
"Handle",
"successful",
"authentication",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L182-L201 | [
"def",
"_handle_auth_success",
"(",
"self",
",",
"stream",
",",
"success",
")",
":",
"if",
"not",
"self",
".",
"_check_authorization",
"(",
"success",
".",
"properties",
",",
"stream",
")",
":",
"element",
"=",
"ElementTree",
".",
"Element",
"(",
"FAILURE_TA... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler._process_sasl_challenge | Process incoming <sasl:challenge/> element.
[initiating entity only] | pyxmpp2/streamsasl.py | def _process_sasl_challenge(self, stream, element):
"""Process incoming <sasl:challenge/> element.
[initiating entity only]
"""
if not self.authenticator:
logger.debug("Unexpected SASL challenge")
return False
content = element.text.encode("us-ascii")
... | def _process_sasl_challenge(self, stream, element):
"""Process incoming <sasl:challenge/> element.
[initiating entity only]
"""
if not self.authenticator:
logger.debug("Unexpected SASL challenge")
return False
content = element.text.encode("us-ascii")
... | [
"Process",
"incoming",
"<sasl",
":",
"challenge",
"/",
">",
"element",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L204-L227 | [
"def",
"_process_sasl_challenge",
"(",
"self",
",",
"stream",
",",
"element",
")",
":",
"if",
"not",
"self",
".",
"authenticator",
":",
"logger",
".",
"debug",
"(",
"\"Unexpected SASL challenge\"",
")",
"return",
"False",
"content",
"=",
"element",
".",
"text"... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler._process_sasl_response | Process incoming <sasl:response/> element.
[receiving entity only] | pyxmpp2/streamsasl.py | def _process_sasl_response(self, stream, element):
"""Process incoming <sasl:response/> element.
[receiving entity only]
"""
if not self.authenticator:
logger.debug("Unexpected SASL response")
return False
content = element.text.encode("us-ascii")
... | def _process_sasl_response(self, stream, element):
"""Process incoming <sasl:response/> element.
[receiving entity only]
"""
if not self.authenticator:
logger.debug("Unexpected SASL response")
return False
content = element.text.encode("us-ascii")
... | [
"Process",
"incoming",
"<sasl",
":",
"response",
"/",
">",
"element",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L230-L258 | [
"def",
"_process_sasl_response",
"(",
"self",
",",
"stream",
",",
"element",
")",
":",
"if",
"not",
"self",
".",
"authenticator",
":",
"logger",
".",
"debug",
"(",
"\"Unexpected SASL response\"",
")",
"return",
"False",
"content",
"=",
"element",
".",
"text",
... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler._check_authorization | Check authorization id and other properties returned by the
authentication mechanism.
[receiving entity only]
Allow only no authzid or authzid equal to current username@domain
FIXME: other rules in s2s
:Parameters:
- `properties`: data obtained during authenticati... | pyxmpp2/streamsasl.py | def _check_authorization(self, properties, stream):
"""Check authorization id and other properties returned by the
authentication mechanism.
[receiving entity only]
Allow only no authzid or authzid equal to current username@domain
FIXME: other rules in s2s
:Parameters... | def _check_authorization(self, properties, stream):
"""Check authorization id and other properties returned by the
authentication mechanism.
[receiving entity only]
Allow only no authzid or authzid equal to current username@domain
FIXME: other rules in s2s
:Parameters... | [
"Check",
"authorization",
"id",
"and",
"other",
"properties",
"returned",
"by",
"the",
"authentication",
"mechanism",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L260-L296 | [
"def",
"_check_authorization",
"(",
"self",
",",
"properties",
",",
"stream",
")",
":",
"authzid",
"=",
"properties",
".",
"get",
"(",
"\"authzid\"",
")",
"if",
"not",
"authzid",
":",
"return",
"True",
"try",
":",
"jid",
"=",
"JID",
"(",
"authzid",
")",
... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler._process_sasl_success | Process incoming <sasl:success/> element.
[initiating entity only] | pyxmpp2/streamsasl.py | def _process_sasl_success(self, stream, element):
"""Process incoming <sasl:success/> element.
[initiating entity only]
"""
if not self.authenticator:
logger.debug("Unexpected SASL response")
return False
content = element.text
if content:
... | def _process_sasl_success(self, stream, element):
"""Process incoming <sasl:success/> element.
[initiating entity only]
"""
if not self.authenticator:
logger.debug("Unexpected SASL response")
return False
content = element.text
if content:
... | [
"Process",
"incoming",
"<sasl",
":",
"success",
"/",
">",
"element",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L299-L331 | [
"def",
"_process_sasl_success",
"(",
"self",
",",
"stream",
",",
"element",
")",
":",
"if",
"not",
"self",
".",
"authenticator",
":",
"logger",
".",
"debug",
"(",
"\"Unexpected SASL response\"",
")",
"return",
"False",
"content",
"=",
"element",
".",
"text",
... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler._process_sasl_failure | Process incoming <sasl:failure/> element.
[initiating entity only] | pyxmpp2/streamsasl.py | def _process_sasl_failure(self, stream, element):
"""Process incoming <sasl:failure/> element.
[initiating entity only]
"""
_unused = stream
if not self.authenticator:
logger.debug("Unexpected SASL response")
return False
logger.debug("SASL authe... | def _process_sasl_failure(self, stream, element):
"""Process incoming <sasl:failure/> element.
[initiating entity only]
"""
_unused = stream
if not self.authenticator:
logger.debug("Unexpected SASL response")
return False
logger.debug("SASL authe... | [
"Process",
"incoming",
"<sasl",
":",
"failure",
"/",
">",
"element",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L334-L346 | [
"def",
"_process_sasl_failure",
"(",
"self",
",",
"stream",
",",
"element",
")",
":",
"_unused",
"=",
"stream",
"if",
"not",
"self",
".",
"authenticator",
":",
"logger",
".",
"debug",
"(",
"\"Unexpected SASL response\"",
")",
"return",
"False",
"logger",
".",
... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler._process_sasl_abort | Process incoming <sasl:abort/> element.
[receiving entity only] | pyxmpp2/streamsasl.py | def _process_sasl_abort(self, stream, element):
"""Process incoming <sasl:abort/> element.
[receiving entity only]"""
_unused, _unused = stream, element
if not self.authenticator:
logger.debug("Unexpected SASL response")
return False
self.authenticator =... | def _process_sasl_abort(self, stream, element):
"""Process incoming <sasl:abort/> element.
[receiving entity only]"""
_unused, _unused = stream, element
if not self.authenticator:
logger.debug("Unexpected SASL response")
return False
self.authenticator =... | [
"Process",
"incoming",
"<sasl",
":",
"abort",
"/",
">",
"element",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L349-L360 | [
"def",
"_process_sasl_abort",
"(",
"self",
",",
"stream",
",",
"element",
")",
":",
"_unused",
",",
"_unused",
"=",
"stream",
",",
"element",
"if",
"not",
"self",
".",
"authenticator",
":",
"logger",
".",
"debug",
"(",
"\"Unexpected SASL response\"",
")",
"r... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | StreamSASLHandler._sasl_authenticate | Start SASL authentication process.
[initiating entity only]
:Parameters:
- `username`: user name.
- `authzid`: authorization ID.
- `mechanism`: SASL mechanism to use. | pyxmpp2/streamsasl.py | def _sasl_authenticate(self, stream, username, authzid):
"""Start SASL authentication process.
[initiating entity only]
:Parameters:
- `username`: user name.
- `authzid`: authorization ID.
- `mechanism`: SASL mechanism to use."""
if not stream.initia... | def _sasl_authenticate(self, stream, username, authzid):
"""Start SASL authentication process.
[initiating entity only]
:Parameters:
- `username`: user name.
- `authzid`: authorization ID.
- `mechanism`: SASL mechanism to use."""
if not stream.initia... | [
"Start",
"SASL",
"authentication",
"process",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L362-L419 | [
"def",
"_sasl_authenticate",
"(",
"self",
",",
"stream",
",",
"username",
",",
"authzid",
")",
":",
"if",
"not",
"stream",
".",
"initiator",
":",
"raise",
"SASLAuthenticationFailed",
"(",
"\"Only initiating entity start\"",
"\" SASL authentication\"",
")",
"if",
"st... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | timeout_handler | Method decorator generator for decorating event handlers.
To be used on `TimeoutHandler` subclass methods only.
:Parameters:
- `interval`: interval (in seconds) before the method will be called.
- `recurring`: When `True`, the handler will be called each `interval`
seconds, when `Fal... | pyxmpp2/mainloop/interfaces.py | def timeout_handler(interval, recurring = None):
"""Method decorator generator for decorating event handlers.
To be used on `TimeoutHandler` subclass methods only.
:Parameters:
- `interval`: interval (in seconds) before the method will be called.
- `recurring`: When `True`, the handler wil... | def timeout_handler(interval, recurring = None):
"""Method decorator generator for decorating event handlers.
To be used on `TimeoutHandler` subclass methods only.
:Parameters:
- `interval`: interval (in seconds) before the method will be called.
- `recurring`: When `True`, the handler wil... | [
"Method",
"decorator",
"generator",
"for",
"decorating",
"event",
"handlers",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/mainloop/interfaces.py#L214-L234 | [
"def",
"timeout_handler",
"(",
"interval",
",",
"recurring",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"\"\"\"The decorator\"\"\"",
"func",
".",
"_pyxmpp_timeout",
"=",
"interval",
"func",
".",
"_pyxmpp_recurring",
"=",
"recurring",
"retu... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | MainLoop.delayed_call | Schedule function to be called from the main loop after `delay`
seconds.
:Parameters:
- `delay`: seconds to wait
:Types:
- `delay`: `float` | pyxmpp2/mainloop/interfaces.py | def delayed_call(self, delay, function):
"""Schedule function to be called from the main loop after `delay`
seconds.
:Parameters:
- `delay`: seconds to wait
:Types:
- `delay`: `float`
"""
main_loop = self
handler = []
class Delayed... | def delayed_call(self, delay, function):
"""Schedule function to be called from the main loop after `delay`
seconds.
:Parameters:
- `delay`: seconds to wait
:Types:
- `delay`: `float`
"""
main_loop = self
handler = []
class Delayed... | [
"Schedule",
"function",
"to",
"be",
"called",
"from",
"the",
"main",
"loop",
"after",
"delay",
"seconds",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/mainloop/interfaces.py#L264-L286 | [
"def",
"delayed_call",
"(",
"self",
",",
"delay",
",",
"function",
")",
":",
"main_loop",
"=",
"self",
"handler",
"=",
"[",
"]",
"class",
"DelayedCallHandler",
"(",
"TimeoutHandler",
")",
":",
"\"\"\"Wrapper timeout handler class for the delayed call.\"\"\"",
"# pylin... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | RosterItem.from_xml | Make a RosterItem from an XML element.
:Parameters:
- `element`: the XML element
:Types:
- `element`: :etree:`ElementTree.Element`
:return: a freshly created roster item
:returntype: `cls` | pyxmpp2/roster.py | def from_xml(cls, element):
"""Make a RosterItem from an XML element.
:Parameters:
- `element`: the XML element
:Types:
- `element`: :etree:`ElementTree.Element`
:return: a freshly created roster item
:returntype: `cls`
"""
if element.tag... | def from_xml(cls, element):
"""Make a RosterItem from an XML element.
:Parameters:
- `element`: the XML element
:Types:
- `element`: :etree:`ElementTree.Element`
:return: a freshly created roster item
:returntype: `cls`
"""
if element.tag... | [
"Make",
"a",
"RosterItem",
"from",
"an",
"XML",
"element",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/roster.py#L192-L235 | [
"def",
"from_xml",
"(",
"cls",
",",
"element",
")",
":",
"if",
"element",
".",
"tag",
"!=",
"ITEM_TAG",
":",
"raise",
"ValueError",
"(",
"\"{0!r} is not a roster item\"",
".",
"format",
"(",
"element",
")",
")",
"try",
":",
"jid",
"=",
"JID",
"(",
"eleme... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | RosterItem.as_xml | Make an XML element from self.
:Parameters:
- `parent`: Parent element
:Types:
- `parent`: :etree:`ElementTree.Element` | pyxmpp2/roster.py | def as_xml(self, parent = None):
"""Make an XML element from self.
:Parameters:
- `parent`: Parent element
:Types:
- `parent`: :etree:`ElementTree.Element`
"""
if parent is not None:
element = ElementTree.SubElement(parent, ITEM_TAG)
e... | def as_xml(self, parent = None):
"""Make an XML element from self.
:Parameters:
- `parent`: Parent element
:Types:
- `parent`: :etree:`ElementTree.Element`
"""
if parent is not None:
element = ElementTree.SubElement(parent, ITEM_TAG)
e... | [
"Make",
"an",
"XML",
"element",
"from",
"self",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/roster.py#L237-L260 | [
"def",
"as_xml",
"(",
"self",
",",
"parent",
"=",
"None",
")",
":",
"if",
"parent",
"is",
"not",
"None",
":",
"element",
"=",
"ElementTree",
".",
"SubElement",
"(",
"parent",
",",
"ITEM_TAG",
")",
"else",
":",
"element",
"=",
"ElementTree",
".",
"Eleme... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | RosterItem._verify | Check if `self` is valid roster item.
Valid item must have proper `subscription` and valid value for 'ask'.
:Parameters:
- `valid_subscriptions`: sequence of valid subscription values
- `fix`: if `True` than replace invalid 'subscription' and 'ask'
values with the... | pyxmpp2/roster.py | def _verify(self, valid_subscriptions, fix):
"""Check if `self` is valid roster item.
Valid item must have proper `subscription` and valid value for 'ask'.
:Parameters:
- `valid_subscriptions`: sequence of valid subscription values
- `fix`: if `True` than replace invali... | def _verify(self, valid_subscriptions, fix):
"""Check if `self` is valid roster item.
Valid item must have proper `subscription` and valid value for 'ask'.
:Parameters:
- `valid_subscriptions`: sequence of valid subscription values
- `fix`: if `True` than replace invali... | [
"Check",
"if",
"self",
"is",
"valid",
"roster",
"item",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/roster.py#L262-L289 | [
"def",
"_verify",
"(",
"self",
",",
"valid_subscriptions",
",",
"fix",
")",
":",
"if",
"self",
".",
"subscription",
"not",
"in",
"valid_subscriptions",
":",
"if",
"fix",
":",
"logger",
".",
"debug",
"(",
"\"RosterItem.from_xml: got unknown 'subscription':\"",
"\" ... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | RosterItem.verify_roster_result | Check if `self` is valid roster item.
Valid item must have proper `subscription` value other than 'remove'
and valid value for 'ask'.
:Parameters:
- `fix`: if `True` than replace invalid 'subscription' and 'ask'
values with the defaults
:Types:
- `... | pyxmpp2/roster.py | def verify_roster_result(self, fix = False):
"""Check if `self` is valid roster item.
Valid item must have proper `subscription` value other than 'remove'
and valid value for 'ask'.
:Parameters:
- `fix`: if `True` than replace invalid 'subscription' and 'ask'
... | def verify_roster_result(self, fix = False):
"""Check if `self` is valid roster item.
Valid item must have proper `subscription` value other than 'remove'
and valid value for 'ask'.
:Parameters:
- `fix`: if `True` than replace invalid 'subscription' and 'ask'
... | [
"Check",
"if",
"self",
"is",
"valid",
"roster",
"item",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/roster.py#L291-L305 | [
"def",
"verify_roster_result",
"(",
"self",
",",
"fix",
"=",
"False",
")",
":",
"self",
".",
"_verify",
"(",
"(",
"None",
",",
"u\"from\"",
",",
"u\"to\"",
",",
"u\"both\"",
")",
",",
"fix",
")"
] | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | RosterItem.verify_roster_push | Check if `self` is valid roster push item.
Valid item must have proper `subscription` value other and valid value
for 'ask'.
:Parameters:
- `fix`: if `True` than replace invalid 'subscription' and 'ask'
values with the defaults
:Types:
- `fix`: `bo... | pyxmpp2/roster.py | def verify_roster_push(self, fix = False):
"""Check if `self` is valid roster push item.
Valid item must have proper `subscription` value other and valid value
for 'ask'.
:Parameters:
- `fix`: if `True` than replace invalid 'subscription' and 'ask'
values with... | def verify_roster_push(self, fix = False):
"""Check if `self` is valid roster push item.
Valid item must have proper `subscription` value other and valid value
for 'ask'.
:Parameters:
- `fix`: if `True` than replace invalid 'subscription' and 'ask'
values with... | [
"Check",
"if",
"self",
"is",
"valid",
"roster",
"push",
"item",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/roster.py#L307-L321 | [
"def",
"verify_roster_push",
"(",
"self",
",",
"fix",
"=",
"False",
")",
":",
"self",
".",
"_verify",
"(",
"(",
"None",
",",
"u\"from\"",
",",
"u\"to\"",
",",
"u\"both\"",
",",
"u\"remove\"",
")",
",",
"fix",
")"
] | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | RosterItem.verify_roster_set | Check if `self` is valid roster set item.
For use on server to validate incoming roster sets.
Valid item must have proper `subscription` value other and valid value
for 'ask'. The lengths of name and group names must fit the configured
limits.
:Parameters:
- `fix`:... | pyxmpp2/roster.py | def verify_roster_set(self, fix = False, settings = None):
"""Check if `self` is valid roster set item.
For use on server to validate incoming roster sets.
Valid item must have proper `subscription` value other and valid value
for 'ask'. The lengths of name and group names must fit the... | def verify_roster_set(self, fix = False, settings = None):
"""Check if `self` is valid roster set item.
For use on server to validate incoming roster sets.
Valid item must have proper `subscription` value other and valid value
for 'ask'. The lengths of name and group names must fit the... | [
"Check",
"if",
"self",
"is",
"valid",
"roster",
"set",
"item",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/roster.py#L323-L369 | [
"def",
"verify_roster_set",
"(",
"self",
",",
"fix",
"=",
"False",
",",
"settings",
"=",
"None",
")",
":",
"# pylint: disable=R0912",
"try",
":",
"self",
".",
"_verify",
"(",
"(",
"None",
",",
"u\"remove\"",
")",
",",
"fix",
")",
"except",
"ValueError",
... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | Roster.groups | Set of groups defined in the roster.
:Return: the groups
:ReturnType: `set` of `unicode` | pyxmpp2/roster.py | def groups(self):
"""Set of groups defined in the roster.
:Return: the groups
:ReturnType: `set` of `unicode`
"""
groups = set()
for item in self._items:
groups |= item.groups
return groups | def groups(self):
"""Set of groups defined in the roster.
:Return: the groups
:ReturnType: `set` of `unicode`
"""
groups = set()
for item in self._items:
groups |= item.groups
return groups | [
"Set",
"of",
"groups",
"defined",
"in",
"the",
"roster",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/roster.py#L539-L548 | [
"def",
"groups",
"(",
"self",
")",
":",
"groups",
"=",
"set",
"(",
")",
"for",
"item",
"in",
"self",
".",
"_items",
":",
"groups",
"|=",
"item",
".",
"groups",
"return",
"groups"
] | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
valid | Roster.get_items_by_name | Return a list of items with given name.
:Parameters:
- `name`: name to look-up
- `case_sensitive`: if `False` the matching will be case
insensitive.
:Types:
- `name`: `unicode`
- `case_sensitive`: `bool`
:Returntype: `list` of `Rost... | pyxmpp2/roster.py | def get_items_by_name(self, name, case_sensitive = True):
"""
Return a list of items with given name.
:Parameters:
- `name`: name to look-up
- `case_sensitive`: if `False` the matching will be case
insensitive.
:Types:
- `name`: `unicode... | def get_items_by_name(self, name, case_sensitive = True):
"""
Return a list of items with given name.
:Parameters:
- `name`: name to look-up
- `case_sensitive`: if `False` the matching will be case
insensitive.
:Types:
- `name`: `unicode... | [
"Return",
"a",
"list",
"of",
"items",
"with",
"given",
"name",
"."
] | Jajcus/pyxmpp2 | python | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/roster.py#L550-L574 | [
"def",
"get_items_by_name",
"(",
"self",
",",
"name",
",",
"case_sensitive",
"=",
"True",
")",
":",
"if",
"not",
"case_sensitive",
"and",
"name",
":",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
... | 14a40a3950910a9cd008b55f0d8905aa0186ce18 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.