Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
MusicXMLDocument.get_tempos | (self) | Return a list of all tempos in this score.
If no tempos are found, create a default tempo of 120 qpm.
Returns:
A list of all Tempo objects used in this score.
| Return a list of all tempos in this score. | def get_tempos(self):
"""Return a list of all tempos in this score.
If no tempos are found, create a default tempo of 120 qpm.
Returns:
A list of all Tempo objects used in this score.
"""
tempos = []
if self.parts:
part = self.parts[0] # Use only first part
for measure in p... | [
"def",
"get_tempos",
"(",
"self",
")",
":",
"tempos",
"=",
"[",
"]",
"if",
"self",
".",
"parts",
":",
"part",
"=",
"self",
".",
"parts",
"[",
"0",
"]",
"# Use only first part",
"for",
"measure",
"in",
"part",
".",
"measures",
":",
"for",
"tempo",
"in... | [
344,
2
] | [
367,
17
] | python | en | ['en', 'en', 'en'] | True |
ScorePart._parse | (self, xml_score_part) | Parse the <score-part> element to an in-memory representation. | Parse the <score-part> element to an in-memory representation. | def _parse(self, xml_score_part):
"""Parse the <score-part> element to an in-memory representation."""
self.id = xml_score_part.attrib['id']
if xml_score_part.find('part-name') is not None:
self.part_name = xml_score_part.find('part-name').text or ''
xml_midi_instrument = xml_score_part.find('mi... | [
"def",
"_parse",
"(",
"self",
",",
"xml_score_part",
")",
":",
"self",
".",
"id",
"=",
"xml_score_part",
".",
"attrib",
"[",
"'id'",
"]",
"if",
"xml_score_part",
".",
"find",
"(",
"'part-name'",
")",
"is",
"not",
"None",
":",
"self",
".",
"part_name",
... | [
388,
2
] | [
405,
46
] | python | en | ['en', 'en', 'en'] | True |
Part._parse | (self, xml_part, score_parts) | Parse the <part> element. | Parse the <part> element. | def _parse(self, xml_part, score_parts):
"""Parse the <part> element."""
if 'id' in xml_part.attrib:
self.id = xml_part.attrib['id']
if self.id in score_parts:
self.score_part = score_parts[self.id]
else:
# If this part references a score-part id that was not found in the file,
#... | [
"def",
"_parse",
"(",
"self",
",",
"xml_part",
",",
"score_parts",
")",
":",
"if",
"'id'",
"in",
"xml_part",
".",
"attrib",
":",
"self",
".",
"id",
"=",
"xml_part",
".",
"attrib",
"[",
"'id'",
"]",
"if",
"self",
".",
"id",
"in",
"score_parts",
":",
... | [
424,
2
] | [
447,
42
] | python | en | ['en', 'fr', 'en'] | True |
Part._repair_empty_measure | (self, measure) | Repair a measure if it is empty by inserting a whole measure rest.
If a <measure> only consists of a <forward> element that advances
the time cursor, remove the <forward> element and replace
with a whole measure rest of the same duration.
Args:
measure: The measure to repair.
| Repair a measure if it is empty by inserting a whole measure rest. | def _repair_empty_measure(self, measure):
"""Repair a measure if it is empty by inserting a whole measure rest.
If a <measure> only consists of a <forward> element that advances
the time cursor, remove the <forward> element and replace
with a whole measure rest of the same duration.
Args:
me... | [
"def",
"_repair_empty_measure",
"(",
"self",
",",
"measure",
")",
":",
"# Issue #674 - If the <forward> element is in a measure without",
"# any <note> elements, treat it as if it were a whole measure",
"# rest by inserting a rest of that duration",
"forward_count",
"=",
"len",
"(",
"m... | [
449,
2
] | [
479,
34
] | python | en | ['en', 'en', 'en'] | True |
Measure._parse | (self) | Parse the <measure> element. | Parse the <measure> element. | def _parse(self):
"""Parse the <measure> element."""
for child in self.xml_measure:
if child.tag == 'attributes':
self._parse_attributes(child)
elif child.tag == 'backup':
self._parse_backup(child)
elif child.tag == 'direction':
self._parse_direction(child)
elif ... | [
"def",
"_parse",
"(",
"self",
")",
":",
"for",
"child",
"in",
"self",
".",
"xml_measure",
":",
"if",
"child",
".",
"tag",
"==",
"'attributes'",
":",
"self",
".",
"_parse_attributes",
"(",
"child",
")",
"elif",
"child",
".",
"tag",
"==",
"'backup'",
":"... | [
507,
2
] | [
534,
12
] | python | en | ['en', 'fr', 'en'] | True |
Measure._parse_attributes | (self, xml_attributes) | Parse the MusicXML <attributes> element. | Parse the MusicXML <attributes> element. | def _parse_attributes(self, xml_attributes):
"""Parse the MusicXML <attributes> element."""
for child in xml_attributes:
if child.tag == 'divisions':
self.state.divisions = int(child.text)
elif child.tag == 'key':
self.key_signature = KeySignature(self.state, child)
elif child... | [
"def",
"_parse_attributes",
"(",
"self",
",",
"xml_attributes",
")",
":",
"for",
"child",
"in",
"xml_attributes",
":",
"if",
"child",
".",
"tag",
"==",
"'divisions'",
":",
"self",
".",
"state",
".",
"divisions",
"=",
"int",
"(",
"child",
".",
"text",
")"... | [
536,
2
] | [
566,
12
] | python | en | ['en', 'la', 'en'] | True |
Measure._parse_backup | (self, xml_backup) | Parse the MusicXML <backup> element.
This moves the global time position backwards.
Args:
xml_backup: XML element with tag type 'backup'.
| Parse the MusicXML <backup> element. | def _parse_backup(self, xml_backup):
"""Parse the MusicXML <backup> element.
This moves the global time position backwards.
Args:
xml_backup: XML element with tag type 'backup'.
"""
xml_duration = xml_backup.find('duration')
backup_duration = int(xml_duration.text)
midi_ticks = back... | [
"def",
"_parse_backup",
"(",
"self",
",",
"xml_backup",
")",
":",
"xml_duration",
"=",
"xml_backup",
".",
"find",
"(",
"'duration'",
")",
"backup_duration",
"=",
"int",
"(",
"xml_duration",
".",
"text",
")",
"midi_ticks",
"=",
"backup_duration",
"*",
"(",
"c... | [
568,
2
] | [
583,
39
] | python | en | ['en', 'en', 'en'] | True |
Measure._parse_direction | (self, xml_direction) | Parse the MusicXML <direction> element. | Parse the MusicXML <direction> element. | def _parse_direction(self, xml_direction):
"""Parse the MusicXML <direction> element."""
for child in xml_direction:
if child.tag == 'sound':
if child.get('tempo') is not None:
tempo = Tempo(self.state, child)
self.tempos.append(tempo)
self.state.qpm = tempo.qpm
... | [
"def",
"_parse_direction",
"(",
"self",
",",
"xml_direction",
")",
":",
"for",
"child",
"in",
"xml_direction",
":",
"if",
"child",
".",
"tag",
"==",
"'sound'",
":",
"if",
"child",
".",
"get",
"(",
"'tempo'",
")",
"is",
"not",
"None",
":",
"tempo",
"=",... | [
585,
2
] | [
596,
60
] | python | en | ['en', 'en', 'en'] | True |
Measure._parse_forward | (self, xml_forward) | Parse the MusicXML <forward> element.
This moves the global time position forward.
Args:
xml_forward: XML element with tag type 'forward'.
| Parse the MusicXML <forward> element. | def _parse_forward(self, xml_forward):
"""Parse the MusicXML <forward> element.
This moves the global time position forward.
Args:
xml_forward: XML element with tag type 'forward'.
"""
xml_duration = xml_forward.find('duration')
forward_duration = int(xml_duration.text)
midi_ticks =... | [
"def",
"_parse_forward",
"(",
"self",
",",
"xml_forward",
")",
":",
"xml_duration",
"=",
"xml_forward",
".",
"find",
"(",
"'duration'",
")",
"forward_duration",
"=",
"int",
"(",
"xml_duration",
".",
"text",
")",
"midi_ticks",
"=",
"forward_duration",
"*",
"(",... | [
598,
2
] | [
613,
39
] | python | en | ['en', 'en', 'en'] | True |
Measure._fix_time_signature | (self) | Correct the time signature for incomplete measures.
If the measure is incomplete or a pickup, insert an appropriate
time signature into this Measure.
| Correct the time signature for incomplete measures. | def _fix_time_signature(self):
"""Correct the time signature for incomplete measures.
If the measure is incomplete or a pickup, insert an appropriate
time signature into this Measure.
"""
# Compute the fractional time signature (duration / divisions)
# Multiply divisions by 4 because division i... | [
"def",
"_fix_time_signature",
"(",
"self",
")",
":",
"# Compute the fractional time signature (duration / divisions)",
"# Multiply divisions by 4 because division is always parts per quarter note",
"numerator",
"=",
"self",
".",
"duration",
"denominator",
"=",
"self",
".",
"state",... | [
615,
2
] | [
676,
54
] | python | en | ['en', 'en', 'en'] | True |
Note._parse | (self) | Parse the MusicXML <note> element. | Parse the MusicXML <note> element. | def _parse(self):
"""Parse the MusicXML <note> element."""
self.midi_channel = self.state.midi_channel
self.midi_program = self.state.midi_program
self.velocity = self.state.velocity
for child in self.xml_note:
if child.tag == 'chord':
self.is_in_chord = True
elif child.tag == ... | [
"def",
"_parse",
"(",
"self",
")",
":",
"self",
".",
"midi_channel",
"=",
"self",
".",
"state",
".",
"midi_channel",
"self",
".",
"midi_program",
"=",
"self",
".",
"state",
".",
"midi_program",
"self",
".",
"velocity",
"=",
"self",
".",
"state",
".",
"... | [
693,
2
] | [
723,
12
] | python | en | ['en', 'en', 'en'] | True |
Note._parse_pitch | (self, xml_pitch) | Parse the MusicXML <pitch> element. | Parse the MusicXML <pitch> element. | def _parse_pitch(self, xml_pitch):
"""Parse the MusicXML <pitch> element."""
step = xml_pitch.find('step').text
alter_text = ''
alter = 0.0
if xml_pitch.find('alter') is not None:
alter_text = xml_pitch.find('alter').text
octave = xml_pitch.find('octave').text
# Parse alter string to ... | [
"def",
"_parse_pitch",
"(",
"self",
",",
"xml_pitch",
")",
":",
"step",
"=",
"xml_pitch",
".",
"find",
"(",
"'step'",
")",
".",
"text",
"alter_text",
"=",
"''",
"alter",
"=",
"0.0",
"if",
"xml_pitch",
".",
"find",
"(",
"'alter'",
")",
"is",
"not",
"N... | [
725,
2
] | [
763,
43
] | python | en | ['en', 'en', 'en'] | True |
Note._parse_tuplet | (self, xml_time_modification) | Parses a tuplet ratio.
Represented in MusicXML by the <time-modification> element.
Args:
xml_time_modification: An xml time-modification element.
| Parses a tuplet ratio. | def _parse_tuplet(self, xml_time_modification):
"""Parses a tuplet ratio.
Represented in MusicXML by the <time-modification> element.
Args:
xml_time_modification: An xml time-modification element.
"""
numerator = int(xml_time_modification.find('actual-notes').text)
denominator = int(xml_... | [
"def",
"_parse_tuplet",
"(",
"self",
",",
"xml_time_modification",
")",
":",
"numerator",
"=",
"int",
"(",
"xml_time_modification",
".",
"find",
"(",
"'actual-notes'",
")",
".",
"text",
")",
"denominator",
"=",
"int",
"(",
"xml_time_modification",
".",
"find",
... | [
765,
2
] | [
775,
70
] | python | en | ['en', 'fr', 'it'] | False |
Note.pitch_to_midi_pitch | (step, alter, octave) | Convert MusicXML pitch representation to MIDI pitch number. | Convert MusicXML pitch representation to MIDI pitch number. | def pitch_to_midi_pitch(step, alter, octave):
"""Convert MusicXML pitch representation to MIDI pitch number."""
pitch_class = 0
if step == 'C':
pitch_class = 0
elif step == 'D':
pitch_class = 2
elif step == 'E':
pitch_class = 4
elif step == 'F':
pitch_class = 5
elif s... | [
"def",
"pitch_to_midi_pitch",
"(",
"step",
",",
"alter",
",",
"octave",
")",
":",
"pitch_class",
"=",
"0",
"if",
"step",
"==",
"'C'",
":",
"pitch_class",
"=",
"0",
"elif",
"step",
"==",
"'D'",
":",
"pitch_class",
"=",
"2",
"elif",
"step",
"==",
"'E'",
... | [
778,
2
] | [
801,
21
] | python | en | ['en', 'en', 'en'] | True |
NoteDuration.parse_duration | (self, is_in_chord, is_grace_note, duration) | Parse the duration of a note and compute timings. | Parse the duration of a note and compute timings. | def parse_duration(self, is_in_chord, is_grace_note, duration):
"""Parse the duration of a note and compute timings."""
self.duration = int(duration)
# Due to an error in Sibelius' export, force this note to have the
# duration of the previous note if it is in a chord
if is_in_chord:
self.dur... | [
"def",
"parse_duration",
"(",
"self",
",",
"is_in_chord",
",",
"is_grace_note",
",",
"duration",
")",
":",
"self",
".",
"duration",
"=",
"int",
"(",
"duration",
")",
"# Due to an error in Sibelius' export, force this note to have the",
"# duration of the previous note if it... | [
841,
2
] | [
870,
46
] | python | en | ['en', 'en', 'en'] | True |
NoteDuration._convert_type_to_ratio | (self) | Convert the MusicXML note-type-value to a Python Fraction.
Examples:
- whole = 1/1
- half = 1/2
- quarter = 1/4
- 32nd = 1/32
Returns:
A Fraction object representing the note type.
| Convert the MusicXML note-type-value to a Python Fraction. | def _convert_type_to_ratio(self):
"""Convert the MusicXML note-type-value to a Python Fraction.
Examples:
- whole = 1/1
- half = 1/2
- quarter = 1/4
- 32nd = 1/32
Returns:
A Fraction object representing the note type.
"""
return self.TYPE_RATIO_MAP[self.type] | [
"def",
"_convert_type_to_ratio",
"(",
"self",
")",
":",
"return",
"self",
".",
"TYPE_RATIO_MAP",
"[",
"self",
".",
"type",
"]"
] | [
872,
2
] | [
884,
41
] | python | en | ['en', 'en', 'en'] | True |
NoteDuration.duration_ratio | (self) | Compute the duration ratio of the note as a Python Fraction.
Examples:
- Whole Note = 1
- Quarter Note = 1/4
- Dotted Quarter Note = 3/8
- Triplet eighth note = 1/12
Returns:
The duration ratio as a Python Fraction.
| Compute the duration ratio of the note as a Python Fraction. | def duration_ratio(self):
"""Compute the duration ratio of the note as a Python Fraction.
Examples:
- Whole Note = 1
- Quarter Note = 1/4
- Dotted Quarter Note = 3/8
- Triplet eighth note = 1/12
Returns:
The duration ratio as a Python Fraction.
"""
# Get ratio from MusicXML n... | [
"def",
"duration_ratio",
"(",
"self",
")",
":",
"# Get ratio from MusicXML note type",
"duration_ratio",
"=",
"Fraction",
"(",
"1",
",",
"1",
")",
"type_ratio",
"=",
"self",
".",
"_convert_type_to_ratio",
"(",
")",
"# Compute tuplet ratio",
"duration_ratio",
"/=",
"... | [
886,
2
] | [
919,
25
] | python | en | ['en', 'en', 'en'] | True |
NoteDuration.duration_float | (self) | Return the duration ratio as a float. | Return the duration ratio as a float. | def duration_float(self):
"""Return the duration ratio as a float."""
ratio = self.duration_ratio()
return ratio.numerator / ratio.denominator | [
"def",
"duration_float",
"(",
"self",
")",
":",
"ratio",
"=",
"self",
".",
"duration_ratio",
"(",
")",
"return",
"ratio",
".",
"numerator",
"/",
"ratio",
".",
"denominator"
] | [
921,
2
] | [
924,
46
] | python | en | ['en', 'en', 'en'] | True |
ChordSymbol._alter_to_string | (self, alter_text) | Parse alter text to a string of one or two sharps/flats.
Args:
alter_text: A string representation of an integer number of semitones.
Returns:
A string, one of 'bb', 'b', '#', '##', or the empty string.
Raises:
ChordSymbolParseError: If `alter_text` cannot be parsed to an integer,
... | Parse alter text to a string of one or two sharps/flats. | def _alter_to_string(self, alter_text):
"""Parse alter text to a string of one or two sharps/flats.
Args:
alter_text: A string representation of an integer number of semitones.
Returns:
A string, one of 'bb', 'b', '#', '##', or the empty string.
Raises:
ChordSymbolParseError: If `al... | [
"def",
"_alter_to_string",
"(",
"self",
",",
"alter_text",
")",
":",
"# Parse alter text to an integer number of semitones.",
"try",
":",
"alter_semitones",
"=",
"int",
"(",
"alter_text",
")",
"except",
"ValueError",
":",
"raise",
"ChordSymbolParseError",
"(",
"'Non-int... | [
1039,
2
] | [
1073,
23
] | python | en | ['en', 'en', 'en'] | True |
ChordSymbol._parse | (self) | Parse the MusicXML <harmony> element. | Parse the MusicXML <harmony> element. | def _parse(self):
"""Parse the MusicXML <harmony> element."""
self.time_position = self.state.time_position
for child in self.xml_harmony:
if child.tag == 'root':
self._parse_root(child)
elif child.tag == 'kind':
if child.text is None:
# Seems like this shouldn't happe... | [
"def",
"_parse",
"(",
"self",
")",
":",
"self",
".",
"time_position",
"=",
"self",
".",
"state",
".",
"time_position",
"for",
"child",
"in",
"self",
".",
"xml_harmony",
":",
"if",
"child",
".",
"tag",
"==",
"'root'",
":",
"self",
".",
"_parse_root",
"(... | [
1075,
2
] | [
1109,
66
] | python | en | ['en', 'en', 'en'] | True |
ChordSymbol._parse_pitch | (self, xml_pitch, step_tag, alter_tag) | Parse and return the pitch-like <root> or <bass> element. | Parse and return the pitch-like <root> or <bass> element. | def _parse_pitch(self, xml_pitch, step_tag, alter_tag):
"""Parse and return the pitch-like <root> or <bass> element."""
if xml_pitch.find(step_tag) is None:
raise ChordSymbolParseError('Missing pitch step')
step = xml_pitch.find(step_tag).text
alter_string = ''
if xml_pitch.find(alter_tag) is... | [
"def",
"_parse_pitch",
"(",
"self",
",",
"xml_pitch",
",",
"step_tag",
",",
"alter_tag",
")",
":",
"if",
"xml_pitch",
".",
"find",
"(",
"step_tag",
")",
"is",
"None",
":",
"raise",
"ChordSymbolParseError",
"(",
"'Missing pitch step'",
")",
"step",
"=",
"xml_... | [
1111,
2
] | [
1126,
30
] | python | en | ['en', 'en', 'en'] | True |
ChordSymbol._parse_root | (self, xml_root) | Parse the <root> tag for a chord symbol. | Parse the <root> tag for a chord symbol. | def _parse_root(self, xml_root):
"""Parse the <root> tag for a chord symbol."""
self.root = self._parse_pitch(xml_root, step_tag='root-step',
alter_tag='root-alter') | [
"def",
"_parse_root",
"(",
"self",
",",
"xml_root",
")",
":",
"self",
".",
"root",
"=",
"self",
".",
"_parse_pitch",
"(",
"xml_root",
",",
"step_tag",
"=",
"'root-step'",
",",
"alter_tag",
"=",
"'root-alter'",
")"
] | [
1128,
2
] | [
1131,
57
] | python | en | ['en', 'en', 'en'] | True |
ChordSymbol._parse_bass | (self, xml_bass) | Parse the <bass> tag for a chord symbol. | Parse the <bass> tag for a chord symbol. | def _parse_bass(self, xml_bass):
"""Parse the <bass> tag for a chord symbol."""
self.bass = self._parse_pitch(xml_bass, step_tag='bass-step',
alter_tag='bass-alter') | [
"def",
"_parse_bass",
"(",
"self",
",",
"xml_bass",
")",
":",
"self",
".",
"bass",
"=",
"self",
".",
"_parse_pitch",
"(",
"xml_bass",
",",
"step_tag",
"=",
"'bass-step'",
",",
"alter_tag",
"=",
"'bass-alter'",
")"
] | [
1133,
2
] | [
1136,
57
] | python | en | ['en', 'en', 'en'] | True |
ChordSymbol._parse_degree | (self, xml_degree) | Parse and return the <degree> scale degree modification element. | Parse and return the <degree> scale degree modification element. | def _parse_degree(self, xml_degree):
"""Parse and return the <degree> scale degree modification element."""
if xml_degree.find('degree-value') is None:
raise ChordSymbolParseError('Missing scale degree value in harmony')
value_text = xml_degree.find('degree-value').text
if value_text is None:
... | [
"def",
"_parse_degree",
"(",
"self",
",",
"xml_degree",
")",
":",
"if",
"xml_degree",
".",
"find",
"(",
"'degree-value'",
")",
"is",
"None",
":",
"raise",
"ChordSymbolParseError",
"(",
"'Missing scale degree value in harmony'",
")",
"value_text",
"=",
"xml_degree",
... | [
1138,
2
] | [
1182,
50
] | python | en | ['en', 'en', 'en'] | True |
ChordSymbol.get_figure_string | (self) | Return a chord symbol figure string. | Return a chord symbol figure string. | def get_figure_string(self):
"""Return a chord symbol figure string."""
if self.kind == 'N.C.':
return self.kind
else:
degrees_string = ''.join('(%s)' % degree for degree in self.degrees)
figure = self.root + self.kind + degrees_string
if self.bass:
figure += '/' + self.bass
... | [
"def",
"get_figure_string",
"(",
"self",
")",
":",
"if",
"self",
".",
"kind",
"==",
"'N.C.'",
":",
"return",
"self",
".",
"kind",
"else",
":",
"degrees_string",
"=",
"''",
".",
"join",
"(",
"'(%s)'",
"%",
"degree",
"for",
"degree",
"in",
"self",
".",
... | [
1196,
2
] | [
1205,
19
] | python | en | ['en', 'cy', 'en'] | True |
TimeSignature._parse | (self) | Parse the MusicXML <time> element. | Parse the MusicXML <time> element. | def _parse(self):
"""Parse the MusicXML <time> element."""
if (len(self.xml_time.findall('beats')) > 1 or
len(self.xml_time.findall('beat-type')) > 1):
# If more than 1 beats or beat-type found, this time signature is
# not supported (ex: alternating meter)
raise AlternatingTimeSignatu... | [
"def",
"_parse",
"(",
"self",
")",
":",
"if",
"(",
"len",
"(",
"self",
".",
"xml_time",
".",
"findall",
"(",
"'beats'",
")",
")",
">",
"1",
"or",
"len",
"(",
"self",
".",
"xml_time",
".",
"findall",
"(",
"'beat-type'",
")",
")",
">",
"1",
")",
... | [
1226,
2
] | [
1242,
49
] | python | en | ['en', 'en', 'en'] | True |
KeySignature._parse | (self) | Parse the MusicXML <key> element into a MIDI compatible key.
If the mode is not minor (e.g. dorian), default to "major"
because MIDI only supports major and minor modes.
Raises:
KeyParseError: If the fifths element is missing.
| Parse the MusicXML <key> element into a MIDI compatible key. | def _parse(self):
"""Parse the MusicXML <key> element into a MIDI compatible key.
If the mode is not minor (e.g. dorian), default to "major"
because MIDI only supports major and minor modes.
Raises:
KeyParseError: If the fifths element is missing.
"""
fifths = self.xml_key.find('fifths'... | [
"def",
"_parse",
"(",
"self",
")",
":",
"fifths",
"=",
"self",
".",
"xml_key",
".",
"find",
"(",
"'fifths'",
")",
"if",
"fifths",
"is",
"None",
":",
"raise",
"KeyParseError",
"(",
"'Could not find fifths attribute in key signature.'",
")",
"self",
".",
"key",
... | [
1274,
2
] | [
1294,
49
] | python | en | ['en', 'it', 'en'] | True |
Tempo._parse | (self) | Parse the MusicXML <sound> element and retrieve the tempo.
If no tempo is specified, default to DEFAULT_QUARTERS_PER_MINUTE
| Parse the MusicXML <sound> element and retrieve the tempo. | def _parse(self):
"""Parse the MusicXML <sound> element and retrieve the tempo.
If no tempo is specified, default to DEFAULT_QUARTERS_PER_MINUTE
"""
self.qpm = float(self.xml_sound.get('tempo'))
if self.qpm == 0:
# If tempo is 0, set it to default
self.qpm = constants.DEFAULT_QUARTERS_P... | [
"def",
"_parse",
"(",
"self",
")",
":",
"self",
".",
"qpm",
"=",
"float",
"(",
"self",
".",
"xml_sound",
".",
"get",
"(",
"'tempo'",
")",
")",
"if",
"self",
".",
"qpm",
"==",
"0",
":",
"# If tempo is 0, set it to default",
"self",
".",
"qpm",
"=",
"c... | [
1321,
2
] | [
1330,
49
] | python | en | ['en', 'it', 'en'] | True |
stylize | (plot_func) | Return function stylizing Plot figure.
Used as a decorator for functions returning Plot so that all figures are stylized similarly.
Returns:
function: function stylizing Plot figure
| Return function stylizing Plot figure. | def stylize(plot_func):
"""Return function stylizing Plot figure.
Used as a decorator for functions returning Plot so that all figures are stylized similarly.
Returns:
function: function stylizing Plot figure
"""
@functools.wraps(plot_func)
def wrapper(self, *args, **kwargs):
... | [
"def",
"stylize",
"(",
"plot_func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"plot_func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"p",
"=",
"plot_func",
"(",
"self",
",",
"*",
"args",
",",
"*... | [
16,
0
] | [
55,
18
] | python | en | ['it', 'zu', 'en'] | False |
default_figure | (plot_specific_kwargs=None) | Create and return bokeh figure with predefined settings that should be consistent across different plots.
Additional arguments can be provided in plot_specific_kwargs argument as a kwargs dictionary of param: value pairs.
Note:
Keep in mind that supplying stylizing attributes to Figure() doesn't alway... | Create and return bokeh figure with predefined settings that should be consistent across different plots. | def default_figure(plot_specific_kwargs=None):
"""Create and return bokeh figure with predefined settings that should be consistent across different plots.
Additional arguments can be provided in plot_specific_kwargs argument as a kwargs dictionary of param: value pairs.
Note:
Keep in mind that su... | [
"def",
"default_figure",
"(",
"plot_specific_kwargs",
"=",
"None",
")",
":",
"default_kwargs",
"=",
"{",
"\"tools\"",
":",
"[",
"]",
",",
"\"toolbar_location\"",
":",
"None",
",",
"\"outline_line_color\"",
":",
"None",
"}",
"if",
"plot_specific_kwargs",
":",
"de... | [
58,
0
] | [
84,
12
] | python | en | ['en', 'en', 'en'] | True |
PairPlot.__init__ | (self, plot_design) | Create PairPlot object.
Set custom style to seaborn module.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
| Create PairPlot object. | def __init__(self, plot_design):
"""Create PairPlot object.
Set custom style to seaborn module.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
"""
self.plot_design = plot_design
text_color = self.plot_design.text_color
... | [
"def",
"__init__",
"(",
"self",
",",
"plot_design",
")",
":",
"self",
".",
"plot_design",
"=",
"plot_design",
"text_color",
"=",
"self",
".",
"plot_design",
".",
"text_color",
"text_font",
"=",
"self",
".",
"plot_design",
".",
"text_font",
"sns",
".",
"set_s... | [
97,
4
] | [
118,
23
] | python | en | ['fr', 'en', 'en'] | True |
PairPlot.pairplot | (self, dataframe) | Create seaborn pairplot with data provided in the dataframe.
Args:
dataframe (pandas.DataFrame): DataFrame to create pairplot visualization with
Returns:
seaborn.PairGrid: pairplot visualization
| Create seaborn pairplot with data provided in the dataframe. | def pairplot(self, dataframe):
"""Create seaborn pairplot with data provided in the dataframe.
Args:
dataframe (pandas.DataFrame): DataFrame to create pairplot visualization with
Returns:
seaborn.PairGrid: pairplot visualization
"""
colors = {"color": se... | [
"def",
"pairplot",
"(",
"self",
",",
"dataframe",
")",
":",
"colors",
"=",
"{",
"\"color\"",
":",
"self",
".",
"plot_design",
".",
"pairplot_color",
"}",
"p",
"=",
"sns",
".",
"pairplot",
"(",
"dataframe",
",",
"plot_kws",
"=",
"colors",
",",
"diag_kws",... | [
120,
4
] | [
131,
16
] | python | en | ['en', 'en', 'en'] | True |
CorrelationPlot.__init__ | (self, plot_design, target_name) | Create Correlation Plot object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
target_name (str): target feature name
| Create Correlation Plot object. | def __init__(self, plot_design, target_name):
"""Create Correlation Plot object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
target_name (str): target feature name
"""
self.plot_design = plot_design
self.target_name = ... | [
"def",
"__init__",
"(",
"self",
",",
"plot_design",
",",
"target_name",
")",
":",
"self",
".",
"plot_design",
"=",
"plot_design",
"self",
".",
"target_name",
"=",
"target_name"
] | [
162,
4
] | [
170,
38
] | python | en | ['en', 'ja', 'en'] | True |
CorrelationPlot.correlation_plot | (self, correlation_data_normalized, correlation_data_raw) | Create Correlation Plot with provided correlation data.
Args:
correlation_data_normalized (pandas.DataFrame): DataFrame of correlations between normalized columns
correlation_data_raw (pandas.DataFrame): DataFrame of correlations between 'raw' columns
Returns:
bokeh... | Create Correlation Plot with provided correlation data. | def correlation_plot(self, correlation_data_normalized, correlation_data_raw):
"""Create Correlation Plot with provided correlation data.
Args:
correlation_data_normalized (pandas.DataFrame): DataFrame of correlations between normalized columns
correlation_data_raw (pandas.DataF... | [
"def",
"correlation_plot",
"(",
"self",
",",
"correlation_data_normalized",
",",
"correlation_data_raw",
")",
":",
"# correlation source is left in case callback is needed in the future",
"correlation_source",
",",
"correlation_plot",
"=",
"self",
".",
"_create_correlation",
"(",... | [
172,
4
] | [
187,
31
] | python | en | ['en', 'zu', 'en'] | True |
CorrelationPlot._create_correlation | (self, data_normalized, data_raw) | Create Tabs Plot with two HeatMaps based on provided data.
Plots included in Tabs are identical when it comes to style attributes, but each of them have different title
and data underneath.
Args:
data_normalized (pandas.DataFrame): DataFrame of correlations between normalized colum... | Create Tabs Plot with two HeatMaps based on provided data. | def _create_correlation(self, data_normalized, data_raw):
"""Create Tabs Plot with two HeatMaps based on provided data.
Plots included in Tabs are identical when it comes to style attributes, but each of them have different title
and data underneath.
Args:
data_normalized (... | [
"def",
"_create_correlation",
"(",
"self",
",",
"data_normalized",
",",
"data_raw",
")",
":",
"source",
",",
"cols_in_order",
"=",
"self",
".",
"_create_correlation_source",
"(",
"data_normalized",
",",
"data_raw",
")",
"mapper",
"=",
"self",
".",
"_create_correla... | [
189,
4
] | [
213,
32
] | python | en | ['en', 'en', 'en'] | True |
CorrelationPlot._create_correlation_source | (self, data_normalized, data_raw) | Create ColumnDataSource needed for Plots.
Both normalized and 'raw' data are included in the source so that both plots can have access to all data. Cols
are returned for setting up ranges on the Plot later on.
Note:
target name is injected in the beginning of columns list so that i... | Create ColumnDataSource needed for Plots. | def _create_correlation_source(self, data_normalized, data_raw):
"""Create ColumnDataSource needed for Plots.
Both normalized and 'raw' data are included in the source so that both plots can have access to all data. Cols
are returned for setting up ranges on the Plot later on.
Note:
... | [
"def",
"_create_correlation_source",
"(",
"self",
",",
"data_normalized",
",",
"data_raw",
")",
":",
"source",
"=",
"ColumnDataSource",
"(",
")",
"cols",
"=",
"sorted",
"(",
"data_normalized",
".",
"columns",
".",
"to_list",
"(",
")",
")",
"cols",
".",
"remo... | [
215,
4
] | [
259,
27
] | python | en | ['en', 'fi', 'en'] | True |
CorrelationPlot._create_correlation_plot | (self, source, cols_for_range, color_mapper, value_to_color) | Create Correlation HeatMap Plot.
value_to_color determines which values from ColumnDataSource source are used as a fill value.
Args:
source (bokeh.ColumnDataSource): ColumnDataSource with correlation data
cols_for_range (list): list of columns (features) to be put into axes ran... | Create Correlation HeatMap Plot. | def _create_correlation_plot(self, source, cols_for_range, color_mapper, value_to_color):
"""Create Correlation HeatMap Plot.
value_to_color determines which values from ColumnDataSource source are used as a fill value.
Args:
source (bokeh.ColumnDataSource): ColumnDataSource with c... | [
"def",
"_create_correlation_plot",
"(",
"self",
",",
"source",
",",
"cols_for_range",
",",
"color_mapper",
",",
"value_to_color",
")",
":",
"# tooltip",
"tooltip_text",
"=",
"[",
"(",
"self",
".",
"_correlation_values_normalized_title",
",",
"\"@\"",
"+",
"self",
... | [
262,
4
] | [
306,
16
] | python | en | ['en', 'eu', 'en'] | True |
CorrelationPlot._create_correlation_color_mapper | (self) | Create LinearColorMapper used for Correlation HeatMap plots.
Returns:
bokeh.LinearColorMapper: color mapper used to map values to specific colors
| Create LinearColorMapper used for Correlation HeatMap plots. | def _create_correlation_color_mapper(self):
"""Create LinearColorMapper used for Correlation HeatMap plots.
Returns:
bokeh.LinearColorMapper: color mapper used to map values to specific colors
"""
tints = self.plot_design.contrary_color_tints
no_correlation = [tints... | [
"def",
"_create_correlation_color_mapper",
"(",
"self",
")",
":",
"tints",
"=",
"self",
".",
"plot_design",
".",
"contrary_color_tints",
"no_correlation",
"=",
"[",
"tints",
"[",
"9",
"]",
"]",
"small_correlation",
"=",
"[",
"tints",
"[",
"7",
"]",
"]",
"*",... | [
308,
4
] | [
330,
19
] | python | en | ['en', 'fy', 'en'] | True |
NormalTransformationsPlots.__init__ | (self, plot_design) | Create NormalTransformationsPlots object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
| Create NormalTransformationsPlots object. | def __init__(self, plot_design):
"""Create NormalTransformationsPlots object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
"""
self.plot_design = plot_design | [
"def",
"__init__",
"(",
"self",
",",
"plot_design",
")",
":",
"self",
".",
"plot_design",
"=",
"plot_design"
] | [
344,
4
] | [
350,
38
] | python | en | ['en', 'fy', 'en'] | True |
NormalTransformationsPlots.plots | (self, histogram_data) | Create pairs of 'feature name': histogram plot rows from histogram_data.
Transformations of every feature are represented in their own Histogram Plots, which are all placed together
in one row (for a feature).
Args:
histogram_data (dict): dictionary of 'feature name': tuple (Transf... | Create pairs of 'feature name': histogram plot rows from histogram_data. | def plots(self, histogram_data):
"""Create pairs of 'feature name': histogram plot rows from histogram_data.
Transformations of every feature are represented in their own Histogram Plots, which are all placed together
in one row (for a feature).
Args:
histogram_data (dict):... | [
"def",
"plots",
"(",
"self",
",",
"histogram_data",
")",
":",
"output",
"=",
"{",
"}",
"for",
"feature",
",",
"transformer_data",
"in",
"histogram_data",
".",
"items",
"(",
")",
":",
"plot_row",
"=",
"self",
".",
"_plot_row",
"(",
"transformer_data",
")",
... | [
352,
4
] | [
369,
21
] | python | en | ['en', 'en', 'en'] | True |
NormalTransformationsPlots._plot_row | (self, transformer_data) | Create row of Histogram plots depending on how many Transformations are in transformer_data.
Plots get a Spacer squeezed between them so that they aren't too cluttered.
Args:
transformer_data (list): list of tuples of (Transformer, histogram data of transformation)
Returns:
... | Create row of Histogram plots depending on how many Transformations are in transformer_data. | def _plot_row(self, transformer_data):
"""Create row of Histogram plots depending on how many Transformations are in transformer_data.
Plots get a Spacer squeezed between them so that they aren't too cluttered.
Args:
transformer_data (list): list of tuples of (Transformer, histogra... | [
"def",
"_plot_row",
"(",
"self",
",",
"transformer_data",
")",
":",
"plots",
"=",
"[",
"]",
"for",
"transformer",
",",
"histogram_data",
"in",
"transformer_data",
":",
"tr_name",
"=",
"str",
"(",
"transformer",
")",
"if",
"\"box-cox\"",
"in",
"tr_name",
":",... | [
371,
4
] | [
398,
21
] | python | en | ['en', 'en', 'en'] | True |
NormalTransformationsPlots._single_histogram | (self, plot_name, histogram_data) | Return Histogram Plot bokeh Figure.
Plot is created with plot_name as a title and unpacked histogram_data as values.
Args:
plot_name (str): title of the Plot
histogram_data (tuple): histogram values, left edges, right edges
Returns:
bokeh.Plot: Histogram Pl... | Return Histogram Plot bokeh Figure. | def _single_histogram(self, plot_name, histogram_data):
"""Return Histogram Plot bokeh Figure.
Plot is created with plot_name as a title and unpacked histogram_data as values.
Args:
plot_name (str): title of the Plot
histogram_data (tuple): histogram values, left edges,... | [
"def",
"_single_histogram",
"(",
"self",
",",
"plot_name",
",",
"histogram_data",
")",
":",
"hist",
",",
"left_edges",
",",
"right_edges",
"=",
"histogram_data",
"# figure",
"kwargs",
"=",
"{",
"\"plot_height\"",
":",
"250",
",",
"\"height_policy\"",
":",
"\"fit... | [
401,
4
] | [
434,
16
] | python | de | ['de', 'no', 'hi'] | False |
MainGrid.__init__ | (self, features, plot_design, feature_description_class) | Create MainGrid object.
Args:
features (list): list of features names
plot_design (PlotDesign): PlotDesign object with predefined style elements
feature_description_class (str): HTML (CSS) class shared between different objects indicating HTML element
with hi... | Create MainGrid object. | def __init__(self, features, plot_design, feature_description_class):
"""Create MainGrid object.
Args:
features (list): list of features names
plot_design (PlotDesign): PlotDesign object with predefined style elements
feature_description_class (str): HTML (CSS) class... | [
"def",
"__init__",
"(",
"self",
",",
"features",
",",
"plot_design",
",",
"feature_description_class",
")",
":",
"# Font won't be updated in plots until any change is made (e.g. choosing different Feature).",
"# This is a bug in bokeh: https://github.com/bokeh/bokeh/issues/9448",
"# Issu... | [
451,
4
] | [
466,
66
] | python | en | ['en', 'et', 'en'] | True |
MainGrid._create_features_dropdown | (self, name=_features_dropdown) | Create bokeh Dropdown Widget with feature names as available selections.
Name can be customized in case it is needed for Bokeh element searching.
Args:
name (str, optional): name of the dropdown, defaults to _features_dropdown class attribute.
Returns:
bokeh.Dropdown: ... | Create bokeh Dropdown Widget with feature names as available selections. | def _create_features_dropdown(self, name=_features_dropdown):
"""Create bokeh Dropdown Widget with feature names as available selections.
Name can be customized in case it is needed for Bokeh element searching.
Args:
name (str, optional): name of the dropdown, defaults to _features... | [
"def",
"_create_features_dropdown",
"(",
"self",
",",
"name",
"=",
"_features_dropdown",
")",
":",
"fts",
"=",
"sorted",
"(",
"self",
".",
"features",
")",
"d",
"=",
"Select",
"(",
"options",
"=",
"fts",
",",
"css_classes",
"=",
"[",
"self",
".",
"_featu... | [
468,
4
] | [
481,
16
] | python | en | ['en', 'en', 'en'] | True |
MainGrid._create_features_dropdown_callbacks | (self, **kwargs) | Create JS callback associated with the dropdown.
Child classes should override this method.
Args:
**kwargs: Arbitrary keyword arguments.
Raises:
NotImplementedError: Classes should implement this method.
| Create JS callback associated with the dropdown. | def _create_features_dropdown_callbacks(self, **kwargs):
"""Create JS callback associated with the dropdown.
Child classes should override this method.
Args:
**kwargs: Arbitrary keyword arguments.
Raises:
NotImplementedError: Classes should implement this metho... | [
"def",
"_create_features_dropdown_callbacks",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError"
] | [
483,
4
] | [
494,
33
] | python | en | ['en', 'en', 'en'] | True |
InfoGrid.__init__ | (self, features, plot_design, feature_description_class) | Create InfoGrid object.
Call MainGrid __init__ with necessary arguments.
Args:
features (list): list of features names
plot_design (PlotDesign): PlotDesign object with predefined style elements
feature_description_class (str): HTML (CSS) class shared between differe... | Create InfoGrid object. | def __init__(self, features, plot_design, feature_description_class):
"""Create InfoGrid object.
Call MainGrid __init__ with necessary arguments.
Args:
features (list): list of features names
plot_design (PlotDesign): PlotDesign object with predefined style elements
... | [
"def",
"__init__",
"(",
"self",
",",
"features",
",",
"plot_design",
",",
"feature_description_class",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"features",
",",
"plot_design",
",",
"feature_description_class",
")"
] | [
575,
4
] | [
586,
74
] | python | en | ['en', 'en', 'en'] | True |
InfoGrid.summary_grid | (self, summary_statistics, histogram_data, initial_feature) | Create Summary Grid with Summary Statistics and distribution histogram.
Grid has a design of:
- hidden Dropdown at the top
- Summary Statistics Div on the left
- Histogram Plot on the right
On change of value in dropdown, underlying data also changes to represent st... | Create Summary Grid with Summary Statistics and distribution histogram. | def summary_grid(self, summary_statistics, histogram_data, initial_feature):
"""Create Summary Grid with Summary Statistics and distribution histogram.
Grid has a design of:
- hidden Dropdown at the top
- Summary Statistics Div on the left
- Histogram Plot on the rig... | [
"def",
"summary_grid",
"(",
"self",
",",
"summary_statistics",
",",
"histogram_data",
",",
"initial_feature",
")",
":",
"# dropdown",
"dropdown",
"=",
"self",
".",
"_create_features_dropdown",
"(",
"self",
".",
"_infogrid_dropdown",
")",
"# histogram",
"histogram_sour... | [
588,
4
] | [
632,
21
] | python | en | ['en', 'en', 'en'] | True |
InfoGrid._create_features_dropdown_callbacks | (self, summary_statistics, histogram_data, histogram_source) | Create callbacks that will be triggered upon value change in Grid Dropdown. Implementation of method
defined in MainGrid.
Args:
summary_statistics (dict): 'feature name': summary dict pairs
histogram_data (dict): 'feature name': histogram data tuple pairs
histogram_s... | Create callbacks that will be triggered upon value change in Grid Dropdown. Implementation of method
defined in MainGrid. | def _create_features_dropdown_callbacks(self, summary_statistics, histogram_data, histogram_source):
"""Create callbacks that will be triggered upon value change in Grid Dropdown. Implementation of method
defined in MainGrid.
Args:
summary_statistics (dict): 'feature name': summary ... | [
"def",
"_create_features_dropdown_callbacks",
"(",
"self",
",",
"summary_statistics",
",",
"histogram_data",
",",
"histogram_source",
")",
":",
"callbacks",
"=",
"[",
"]",
"for",
"call",
"in",
"[",
"self",
".",
"_create_histogram_callback",
"(",
"histogram_data",
",... | [
634,
4
] | [
654,
24
] | python | en | ['en', 'en', 'en'] | True |
InfoGrid._create_histogram_callback | (self, histogram_data, histogram_source) | Create callback responsible for changing data in Histogram Plot when the feature in the Dropdown changes.
JS Code updates Histogram ColumnDataSource with data from histogram_data depending on the feature that was
chosen.
Args:
histogram_data (dict): 'feature name': histogram data t... | Create callback responsible for changing data in Histogram Plot when the feature in the Dropdown changes. | def _create_histogram_callback(self, histogram_data, histogram_source):
"""Create callback responsible for changing data in Histogram Plot when the feature in the Dropdown changes.
JS Code updates Histogram ColumnDataSource with data from histogram_data depending on the feature that was
chosen.... | [
"def",
"_create_histogram_callback",
"(",
"self",
",",
"histogram_data",
",",
"histogram_source",
")",
":",
"kwargs",
"=",
"{",
"\"hist_source\"",
":",
"histogram_source",
",",
"\"hist_data\"",
":",
"histogram_data",
"}",
"code",
"=",
"self",
".",
"_histogram_callba... | [
656,
4
] | [
681,
23
] | python | en | ['en', 'en', 'en'] | True |
InfoGrid._create_info_div_callback | (self, summary_statistics) | Create callback responsible for changing data in Summary Div when the feature in the Dropdown changes.
JS Code updates Summary Div elements with data from summary_statistics depending on the feature that was
chosen. Elements are identified via their IDs hardcoded in the JS code and during the creation ... | Create callback responsible for changing data in Summary Div when the feature in the Dropdown changes. | def _create_info_div_callback(self, summary_statistics):
"""Create callback responsible for changing data in Summary Div when the feature in the Dropdown changes.
JS Code updates Summary Div elements with data from summary_statistics depending on the feature that was
chosen. Elements are identi... | [
"def",
"_create_info_div_callback",
"(",
"self",
",",
"summary_statistics",
")",
":",
"kwargs",
"=",
"{",
"\"summary_statistics\"",
":",
"summary_statistics",
"}",
"callback",
"=",
"CustomJS",
"(",
"args",
"=",
"kwargs",
",",
"code",
"=",
"self",
".",
"_info_div... | [
683,
4
] | [
702,
23
] | python | en | ['en', 'en', 'en'] | True |
InfoGrid._create_info_div | (self, summary_statistics, feature) | Create Div containing summary statistics for a chosen feature.
Provided feature is used as an initial choice upon creation of the Div.
Args:
summary_statistics (dict): 'feature name': summary dict pairs
feature (str): feature name used to extract initial data
Returns:
... | Create Div containing summary statistics for a chosen feature. | def _create_info_div(self, summary_statistics, feature):
"""Create Div containing summary statistics for a chosen feature.
Provided feature is used as an initial choice upon creation of the Div.
Args:
summary_statistics (dict): 'feature name': summary dict pairs
feature... | [
"def",
"_create_info_div",
"(",
"self",
",",
"summary_statistics",
",",
"feature",
")",
":",
"feature_dict",
"=",
"summary_statistics",
"[",
"feature",
"]",
"# statistics using describe method of pandas.DataFrame",
"text",
"=",
"self",
".",
"_info_div_html",
".",
"forma... | [
704,
4
] | [
733,
16
] | python | en | ['en', 'en', 'en'] | True |
InfoGrid._create_histogram | (self, histogram_data, feature) | Create Histogram Plot and underlying Histogram ColumnDataSource.
Args:
histogram_data (dict): 'feature name': histogram data tuple pairs
feature (str): feature name used to extract initial data
Returns:
tuple: (Histogram ColumnDataSource, Histogram Plot Figure)
... | Create Histogram Plot and underlying Histogram ColumnDataSource. | def _create_histogram(self, histogram_data, feature):
"""Create Histogram Plot and underlying Histogram ColumnDataSource.
Args:
histogram_data (dict): 'feature name': histogram data tuple pairs
feature (str): feature name used to extract initial data
Returns:
... | [
"def",
"_create_histogram",
"(",
"self",
",",
"histogram_data",
",",
"feature",
")",
":",
"hist_source",
"=",
"self",
".",
"_create_histogram_source",
"(",
"histogram_data",
",",
"feature",
")",
"hist_plot",
"=",
"self",
".",
"_create_histogram_plot",
"(",
"hist_s... | [
735,
4
] | [
747,
37
] | python | en | ['en', 'zu', 'en'] | True |
InfoGrid._create_histogram_source | (self, histogram_data, feature) | Create ColumnDataSource used in Histogram Plot.
Provided feature is used as an initial choice upon creation of the Div.
Args:
histogram_data (dict): 'feature name': histogram data tuple pairs
feature (str): feature name used to extract initial data
Returns:
... | Create ColumnDataSource used in Histogram Plot. | def _create_histogram_source(self, histogram_data, feature):
"""Create ColumnDataSource used in Histogram Plot.
Provided feature is used as an initial choice upon creation of the Div.
Args:
histogram_data (dict): 'feature name': histogram data tuple pairs
feature (str):... | [
"def",
"_create_histogram_source",
"(",
"self",
",",
"histogram_data",
",",
"feature",
")",
":",
"source",
"=",
"ColumnDataSource",
"(",
")",
"first_values",
"=",
"histogram_data",
"[",
"feature",
"]",
"source",
".",
"data",
"=",
"{",
"self",
".",
"_hist_sourc... | [
749,
4
] | [
769,
21
] | python | en | ['en', 'la', 'en'] | True |
InfoGrid._create_histogram_plot | (self, source) | Create Histogram Plot Figure.
Args:
source (bokeh.ColumnDataSource): ColumnDataSource used to provide data to the Plot
Returns:
bokeh.Figure: bokeh Histogram Plot Figure
| Create Histogram Plot Figure. | def _create_histogram_plot(self, source):
"""Create Histogram Plot Figure.
Args:
source (bokeh.ColumnDataSource): ColumnDataSource used to provide data to the Plot
Returns:
bokeh.Figure: bokeh Histogram Plot Figure
"""
# figure
kwargs = {
... | [
"def",
"_create_histogram_plot",
"(",
"self",
",",
"source",
")",
":",
"# figure",
"kwargs",
"=",
"{",
"\"plot_height\"",
":",
"300",
",",
"\"height_policy\"",
":",
"\"fit\"",
",",
"\"plot_width\"",
":",
"300",
",",
"\"title\"",
":",
"self",
".",
"_histogram_t... | [
772,
4
] | [
808,
16
] | python | en | ['en', 'et', 'it'] | False |
ScatterPlotGrid.__init__ | (self,
features,
plot_design,
feature_description_class,
categorical_features,
feature_descriptions,
feature_mapping,
categorical_suffix="_categorical"
) | Create ScatterPlotGrid object.
Call MainGrid __init__ with necessary arguments.
Args:
features (list): list of features names
plot_design (PlotDesign): PlotDesign object with predefined style elements
feature_description_class (str): HTML (CSS) class shared between ... | Create ScatterPlotGrid object. | def __init__(self,
features,
plot_design,
feature_description_class,
categorical_features,
feature_descriptions,
feature_mapping,
categorical_suffix="_categorical"
):
"""Create... | [
"def",
"__init__",
"(",
"self",
",",
"features",
",",
"plot_design",
",",
"feature_description_class",
",",
"categorical_features",
",",
"feature_descriptions",
",",
"feature_mapping",
",",
"categorical_suffix",
"=",
"\"_categorical\"",
")",
":",
"self",
".",
"categor... | [
892,
4
] | [
919,
74
] | python | en | ['en', 'fy', 'en'] | True |
ScatterPlotGrid.scattergrid | (self, scatter_data, initial_feature) | Create ScatterGrid Visualization.
ScatterGrid consists of several rows of ScatterPlots, each row colored (hued) by the values of different
feature. X axis of all Scatter plots represents the chosen feature in the Dropdown - change in the Dropdown
triggers change in all Scatter Plots. The exact ... | Create ScatterGrid Visualization. | def scattergrid(self, scatter_data, initial_feature):
"""Create ScatterGrid Visualization.
ScatterGrid consists of several rows of ScatterPlots, each row colored (hued) by the values of different
feature. X axis of all Scatter plots represents the chosen feature in the Dropdown - change in the ... | [
"def",
"scattergrid",
"(",
"self",
",",
"scatter_data",
",",
"initial_feature",
")",
":",
"# features",
"features",
"=",
"self",
".",
"features",
"# taken from MainGrid",
"# Scatter",
"scatter_row_sources",
",",
"scatter_rows",
"=",
"self",
".",
"_create_scatter_rows"... | [
921,
4
] | [
959,
19
] | python | en | ['es', 'en', 'en'] | True |
ScatterPlotGrid._create_features_dropdown_callbacks | (self, scatter_source) | Create callbacks that will be triggered upon value change in Grid Dropdown. Implementation of method
defined in MainGrid.
Args:
scatter_source (list): ColumnDataSource sources for scatter plots
Returns:
list: created callbacks
| Create callbacks that will be triggered upon value change in Grid Dropdown. Implementation of method
defined in MainGrid. | def _create_features_dropdown_callbacks(self, scatter_source):
"""Create callbacks that will be triggered upon value change in Grid Dropdown. Implementation of method
defined in MainGrid.
Args:
scatter_source (list): ColumnDataSource sources for scatter plots
Returns:
... | [
"def",
"_create_features_dropdown_callbacks",
"(",
"self",
",",
"scatter_source",
")",
":",
"callbacks",
"=",
"[",
"]",
"for",
"call",
"in",
"[",
"self",
".",
"_create_scatter_plot_callback",
"(",
"scatter_source",
")",
",",
"]",
":",
"callbacks",
".",
"append",... | [
961,
4
] | [
977,
24
] | python | en | ['en', 'en', 'en'] | True |
ScatterPlotGrid._create_scatter_plot_callback | (self, sources) | Create callback responsible for changing data in Scatter Plots when the feature in the Dropdown changes.
JS Code updates X axis in all ColumnDataSource sources so that new chosen feature is on the X axis.
Additionally greys out row with the coloring by the new chosen feature and removes previous greyin... | Create callback responsible for changing data in Scatter Plots when the feature in the Dropdown changes. | def _create_scatter_plot_callback(self, sources):
"""Create callback responsible for changing data in Scatter Plots when the feature in the Dropdown changes.
JS Code updates X axis in all ColumnDataSource sources so that new chosen feature is on the X axis.
Additionally greys out row with the c... | [
"def",
"_create_scatter_plot_callback",
"(",
"self",
",",
"sources",
")",
":",
"kwargs",
"=",
"{",
"\"scatter_sources\"",
":",
"sources",
"}",
"code",
"=",
"self",
".",
"_scatterplot_callback_js",
".",
"format",
"(",
"chosen_feature_scatter",
"=",
"self",
".",
"... | [
979,
4
] | [
1002,
23
] | python | en | ['en', 'en', 'en'] | True |
ScatterPlotGrid._create_scatter_rows | (self, scatter_data, features, initial_feature) | Create all rows of Scatter Plots and all ColumnDataSource sources.
Additionally add greying out to the row corresponding to the initial feature.
Args:
scatter_data (dict): 'feature name': data values pairs
features (list): list of feature names
initial_feature (str)... | Create all rows of Scatter Plots and all ColumnDataSource sources. | def _create_scatter_rows(self, scatter_data, features, initial_feature):
"""Create all rows of Scatter Plots and all ColumnDataSource sources.
Additionally add greying out to the row corresponding to the initial feature.
Args:
scatter_data (dict): 'feature name': data values pairs
... | [
"def",
"_create_scatter_rows",
"(",
"self",
",",
"scatter_data",
",",
"features",
",",
"initial_feature",
")",
":",
"all_sources",
"=",
"[",
"]",
"all_rows",
"=",
"[",
"]",
"for",
"feature",
"in",
"features",
":",
"sources",
",",
"single_row",
"=",
"self",
... | [
1004,
4
] | [
1028,
36
] | python | en | ['en', 'en', 'en'] | True |
ScatterPlotGrid._create_single_scatter_row | (self, scatter_data, features, initial_feature, hue) | Create single row of Scatter Plots and corresponding ColumnDataSource sources.
First element of the Scatter Row is provided as a Color Legend depending on the feature that is used as a hue -
either ColorBar for Numerical Range or Unique Values colors in Categorical features (if their number does not
... | Create single row of Scatter Plots and corresponding ColumnDataSource sources. | def _create_single_scatter_row(self, scatter_data, features, initial_feature, hue):
"""Create single row of Scatter Plots and corresponding ColumnDataSource sources.
First element of the Scatter Row is provided as a Color Legend depending on the feature that is used as a hue -
either ColorBar f... | [
"def",
"_create_single_scatter_row",
"(",
"self",
",",
"scatter_data",
",",
"features",
",",
"initial_feature",
",",
"hue",
")",
":",
"sources",
"=",
"[",
"]",
"plots",
"=",
"[",
"]",
"color_map",
"=",
"self",
".",
"_create_color_map",
"(",
"hue",
",",
"sc... | [
1030,
4
] | [
1065,
25
] | python | en | ['en', 'en', 'en'] | True |
ScatterPlotGrid._create_scatter_source | (self, scatter_data, x, y) | Create single ColumnDataSource to be used in one of the Scatter Plots.
Full scatter_data is included in ColumnDataSource to enable dynamic changes with JS in HTML output.
Args:
scatter_data (dict): 'feature name': data values pairs
x (str): feature name chosen to be on X axis
... | Create single ColumnDataSource to be used in one of the Scatter Plots. | def _create_scatter_source(self, scatter_data, x, y):
"""Create single ColumnDataSource to be used in one of the Scatter Plots.
Full scatter_data is included in ColumnDataSource to enable dynamic changes with JS in HTML output.
Args:
scatter_data (dict): 'feature name': data values... | [
"def",
"_create_scatter_source",
"(",
"self",
",",
"scatter_data",
",",
"x",
",",
"y",
")",
":",
"source",
"=",
"ColumnDataSource",
"(",
"scatter_data",
")",
"# additional 2 columns for x and y in plots",
"source",
".",
"data",
".",
"update",
"(",
"{",
"self",
"... | [
1067,
4
] | [
1089,
21
] | python | en | ['en', 'en', 'en'] | True |
ScatterPlotGrid._create_scatter_plot | (self, source, x, y, cmap) | Create single Scatter Plot with provided data and coloring.
Note:
x argument (X feature name) is not used, but is left in case it is needed in the future.
Args:
source (bokeh.ColumnDataSource): ColumnDataSource for a single Scatter Plot
x (str): feature name chosen ... | Create single Scatter Plot with provided data and coloring. | def _create_scatter_plot(self, source, x, y, cmap):
"""Create single Scatter Plot with provided data and coloring.
Note:
x argument (X feature name) is not used, but is left in case it is needed in the future.
Args:
source (bokeh.ColumnDataSource): ColumnDataSource for ... | [
"def",
"_create_scatter_plot",
"(",
"self",
",",
"source",
",",
"x",
",",
"y",
",",
"cmap",
")",
":",
"# figure",
"p",
"=",
"default_figure",
"(",
")",
"# Scatter Plot",
"kwargs",
"=",
"{",
"\"x\"",
":",
"self",
".",
"_scatter_x_axis",
",",
"\"y\"",
":",... | [
1092,
4
] | [
1141,
16
] | python | en | ['en', 'en', 'en'] | True |
ScatterPlotGrid._create_color_map | (self, hue, data) | Create Color Mapper depending on the type of the feature.
If feature to color by is Categorical then unique values in the data are treated as separate colors - unless
their number exceeds limit of max categories, in which case None is returned. If the feature is Numerical, then
Linear Color Map... | Create Color Mapper depending on the type of the feature. | def _create_color_map(self, hue, data):
"""Create Color Mapper depending on the type of the feature.
If feature to color by is Categorical then unique values in the data are treated as separate colors - unless
their number exceeds limit of max categories, in which case None is returned. If the ... | [
"def",
"_create_color_map",
"(",
"self",
",",
"hue",
",",
"data",
")",
":",
"if",
"hue",
"in",
"self",
".",
"categorical_columns",
":",
"# adding suffix to column name to get unique str values",
"factors",
"=",
"sorted",
"(",
"set",
"(",
"data",
"[",
"hue",
"+",... | [
1143,
4
] | [
1183,
19
] | python | en | ['en', 'en', 'en'] | True |
ScatterPlotGrid._create_row_description | (self, hue, cmap) | Create Row description - first element of a given Scatter Plots row.
First element follows a fixed structure of:
- Name of a Feature used as a hue in a given row (Title)
- Color Legend
Title element is hoverable in HTML and on hover will show description of a Hue Feature. Color... | Create Row description - first element of a given Scatter Plots row. | def _create_row_description(self, hue, cmap):
"""Create Row description - first element of a given Scatter Plots row.
First element follows a fixed structure of:
- Name of a Feature used as a hue in a given row (Title)
- Color Legend
Title element is hoverable in HTML a... | [
"def",
"_create_row_description",
"(",
"self",
",",
"hue",
",",
"cmap",
")",
":",
"# HTML needs to be prepared so that description is hidden/hoverable",
"desc",
"=",
"self",
".",
"feature_descriptions",
"[",
"hue",
"]",
"parsed_html",
"=",
"BeautifulSoup",
"(",
"self",
... | [
1185,
4
] | [
1231,
16
] | python | en | ['en', 'en', 'en'] | True |
ScatterPlotGrid._create_legend | (self, hue, cmap) | Create Legend HTML element depending on coloring used in a given Scatter Plots row.
If feature for coloring is Categorical, then custom legend is created with color - category pairs of HTML
elements. If feature is Numerical then bokeh ColorBar is appended to the Div (by doing a trick of creating
... | Create Legend HTML element depending on coloring used in a given Scatter Plots row. | def _create_legend(self, hue, cmap):
"""Create Legend HTML element depending on coloring used in a given Scatter Plots row.
If feature for coloring is Categorical, then custom legend is created with color - category pairs of HTML
elements. If feature is Numerical then bokeh ColorBar is appended... | [
"def",
"_create_legend",
"(",
"self",
",",
"hue",
",",
"cmap",
")",
":",
"if",
"cmap",
":",
"if",
"hue",
"in",
"self",
".",
"categorical_columns",
":",
"mapping",
"=",
"self",
".",
"feature_mapping",
"[",
"hue",
"]",
"categories",
"=",
"cmap",
"[",
"\"... | [
1233,
4
] | [
1296,
21
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotClassification.__init__ | (self, plot_design) | Create ModelsPlotClassification object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
| Create ModelsPlotClassification object. | def __init__(self, plot_design):
"""Create ModelsPlotClassification object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
"""
self.plot_design = plot_design | [
"def",
"__init__",
"(",
"self",
",",
"plot_design",
")",
":",
"self",
".",
"plot_design",
"=",
"plot_design"
] | [
1317,
4
] | [
1323,
38
] | python | en | ['en', 'fy', 'en'] | True |
ModelsPlotClassification.models_comparison_plot | (self, roc_curves, precision_recall_curves, det_curves, target_proportion) | Create Models Comparison Plots to compare their performances in different aspects.
3 Panels included in the final Tabs Plot are:
- ROC: https://en.wikipedia.org/wiki/Receiver_operating_characteristic
- Precision Recall: https://scikit-learn.org/stable/auto_examples/model_selection/plot_... | Create Models Comparison Plots to compare their performances in different aspects. | def models_comparison_plot(self, roc_curves, precision_recall_curves, det_curves, target_proportion):
"""Create Models Comparison Plots to compare their performances in different aspects.
3 Panels included in the final Tabs Plot are:
- ROC: https://en.wikipedia.org/wiki/Receiver_operating_c... | [
"def",
"models_comparison_plot",
"(",
"self",
",",
"roc_curves",
",",
"precision_recall_curves",
",",
"det_curves",
",",
"target_proportion",
")",
":",
"new_tps",
"=",
"[",
"assess_models_names",
"(",
"tp",
")",
"for",
"tp",
"in",
"[",
"roc_curves",
",",
"precis... | [
1325,
4
] | [
1364,
24
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotClassification._roc_plot | (self, roc_curves) | Create Plot with ROC Curves calculated for different Models.
Added Legend is interactive and can be used to turn off (mute) given Models results (plotted Line).
Args:
roc_curves (list): tuples of (Model, roc curves)
Returns:
bokeh.Figure: bokeh Plot Figure
| Create Plot with ROC Curves calculated for different Models. | def _roc_plot(self, roc_curves):
"""Create Plot with ROC Curves calculated for different Models.
Added Legend is interactive and can be used to turn off (mute) given Models results (plotted Line).
Args:
roc_curves (list): tuples of (Model, roc curves)
Returns:
... | [
"def",
"_roc_plot",
"(",
"self",
",",
"roc_curves",
")",
":",
"# figure",
"p",
"=",
"default_figure",
"(",
"{",
"\"x_range\"",
":",
"(",
"-",
"0.01",
",",
"1.1",
")",
",",
"\"y_range\"",
":",
"(",
"-",
"0.01",
",",
"1.1",
")",
",",
"\"tools\"",
":",
... | [
1367,
4
] | [
1407,
16
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotClassification._precision_recall_plot | (self, precision_recall_curves, target_proportion) | Create Plot with Precision Recall Curves calculated for different Models.
Added Legend is interactive and can be used to turn off (mute) given Models results (plotted Line).
Note:
Target Proportion is used to create a parallel line to X axis (y = target_proportion).
Args:
... | Create Plot with Precision Recall Curves calculated for different Models. | def _precision_recall_plot(self, precision_recall_curves, target_proportion):
"""Create Plot with Precision Recall Curves calculated for different Models.
Added Legend is interactive and can be used to turn off (mute) given Models results (plotted Line).
Note:
Target Proportion is ... | [
"def",
"_precision_recall_plot",
"(",
"self",
",",
"precision_recall_curves",
",",
"target_proportion",
")",
":",
"# figure",
"p",
"=",
"default_figure",
"(",
"{",
"\"x_range\"",
":",
"(",
"-",
"0.01",
",",
"1.1",
")",
",",
"\"y_range\"",
":",
"(",
"-",
"0.0... | [
1410,
4
] | [
1457,
16
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotClassification._det_plot | (self, det_curves) | Create Plot with DET Curves calculated for different Models.
Added Legend is interactive and can be used to turn off (mute) given Models results (plotted Line).
Note:
DET curves represent straight lines in normal deviate scale - Axes do not follow regular linear scale
to accomm... | Create Plot with DET Curves calculated for different Models. | def _det_plot(self, det_curves):
"""Create Plot with DET Curves calculated for different Models.
Added Legend is interactive and can be used to turn off (mute) given Models results (plotted Line).
Note:
DET curves represent straight lines in normal deviate scale - Axes do not follo... | [
"def",
"_det_plot",
"(",
"self",
",",
"det_curves",
")",
":",
"# figure",
"p",
"=",
"default_figure",
"(",
"{",
"\"x_range\"",
":",
"(",
"-",
"3",
",",
"3",
")",
",",
"\"y_range\"",
":",
"(",
"-",
"3",
",",
"3",
")",
",",
"\"tools\"",
":",
"\"pan,w... | [
1460,
4
] | [
1516,
16
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotClassification._default_models_lines | (self, plot, model_values_tuple) | Add similarly stylized Lines to the plot on values provided in model_values_tuple.
model_values_tuple is pre-sorted so that the first entry is the best scoring Model. In order to plot that
Model at the top, it needs to be drawn as last - therefore the order is reversed. The best Model (new last) is
... | Add similarly stylized Lines to the plot on values provided in model_values_tuple. | def _default_models_lines(self, plot, model_values_tuple):
"""Add similarly stylized Lines to the plot on values provided in model_values_tuple.
model_values_tuple is pre-sorted so that the first entry is the best scoring Model. In order to plot that
Model at the top, it needs to be drawn as la... | [
"def",
"_default_models_lines",
"(",
"self",
",",
"plot",
",",
"model_values_tuple",
")",
":",
"new_tuples",
"=",
"list",
"(",
"reversed",
"(",
"model_values_tuple",
")",
")",
"lw",
"=",
"5",
"# models are plotted in reverse order (without the first one)",
"for",
"mod... | [
1518,
4
] | [
1558,
36
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotRegression.__init__ | (self, plot_design) | Create ModelsPlotRegression object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
| Create ModelsPlotRegression object. | def __init__(self, plot_design):
"""Create ModelsPlotRegression object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
"""
self.plot_design = plot_design | [
"def",
"__init__",
"(",
"self",
",",
"plot_design",
")",
":",
"self",
".",
"plot_design",
"=",
"plot_design"
] | [
1573,
4
] | [
1579,
38
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotRegression.prediction_error_plot | (self, prediction_errors) | Create Prediction Error Tabs for all Models in prediction_errors results.
As prediction_errors list is sorted in descending order, the first Model is the one that achieved the best
results. Therefore, it gets another color than the rest to be more outstanding in the visualization.
Args:
... | Create Prediction Error Tabs for all Models in prediction_errors results. | def prediction_error_plot(self, prediction_errors):
"""Create Prediction Error Tabs for all Models in prediction_errors results.
As prediction_errors list is sorted in descending order, the first Model is the one that achieved the best
results. Therefore, it gets another color than the rest to ... | [
"def",
"prediction_error_plot",
"(",
"self",
",",
"prediction_errors",
")",
":",
"prediction_errors",
"=",
"assess_models_names",
"(",
"prediction_errors",
")",
"_",
"=",
"[",
"]",
"i",
"=",
"0",
"for",
"model",
",",
"scatter_points",
"in",
"prediction_errors",
... | [
1581,
4
] | [
1606,
24
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotRegression.residual_plot | (self, residual_tuples) | Create Residual Plots Tabs for all Models in residual_tuples results.
As residual tuples list is sorted in descending order, the first Model is the one that achieved the best
results. Therefore, it gets another color than the rest to be more outstanding in the visualization.
Args:
... | Create Residual Plots Tabs for all Models in residual_tuples results. | def residual_plot(self, residual_tuples):
"""Create Residual Plots Tabs for all Models in residual_tuples results.
As residual tuples list is sorted in descending order, the first Model is the one that achieved the best
results. Therefore, it gets another color than the rest to be more outstand... | [
"def",
"residual_plot",
"(",
"self",
",",
"residual_tuples",
")",
":",
"residual_tuples",
"=",
"assess_models_names",
"(",
"residual_tuples",
")",
"_",
"=",
"[",
"]",
"i",
"=",
"0",
"for",
"model",
",",
"scatter_points",
"in",
"residual_tuples",
":",
"if",
"... | [
1608,
4
] | [
1633,
24
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotRegression._single_prediction_error_plot | (self, scatter_data, color) | Create a single Prediction Errors Plot.
Actual y is plotted on X axis, whereas predicted y is plotted on Y axis. If predictions were 100% correct,
points would make a straight line (x=y) - as it's usually not the case, the bigger the difference from that
line the bigger the error.
Args... | Create a single Prediction Errors Plot. | def _single_prediction_error_plot(self, scatter_data, color):
"""Create a single Prediction Errors Plot.
Actual y is plotted on X axis, whereas predicted y is plotted on Y axis. If predictions were 100% correct,
points would make a straight line (x=y) - as it's usually not the case, the bigger ... | [
"def",
"_single_prediction_error_plot",
"(",
"self",
",",
"scatter_data",
",",
"color",
")",
":",
"# figure",
"p",
"=",
"default_figure",
"(",
"{",
"\"tools\"",
":",
"\"pan,wheel_zoom,box_zoom,reset\"",
",",
"\"toolbar_location\"",
":",
"\"right\"",
"}",
")",
"# sca... | [
1636,
4
] | [
1682,
16
] | python | en | ['en', 'it', 'en'] | True |
ModelsPlotRegression._single_residual_plot | (self, scatter_data, color) | Create a single Residual Plot.
Predictions are plotted on X axis, whereas difference between predicted and actual y is plotted on Y axis.
Baseline goes through y = 0 - Residuals should be located seemingly at random, on both sides of the baseline.
If there are any noticeable patterns then it me... | Create a single Residual Plot. | def _single_residual_plot(self, scatter_data, color):
"""Create a single Residual Plot.
Predictions are plotted on X axis, whereas difference between predicted and actual y is plotted on Y axis.
Baseline goes through y = 0 - Residuals should be located seemingly at random, on both sides of the ... | [
"def",
"_single_residual_plot",
"(",
"self",
",",
"scatter_data",
",",
"color",
")",
":",
"# figure",
"p",
"=",
"default_figure",
"(",
"{",
"\"tools\"",
":",
"\"pan,wheel_zoom,box_zoom,reset\"",
",",
"\"toolbar_location\"",
":",
"\"right\"",
",",
"\"width\"",
":",
... | [
1685,
4
] | [
1727,
16
] | python | en | ['en', 'sm', 'en'] | True |
ModelsPlotMulticlass.__init__ | (self, plot_design, label_classes, original_label_mapping) | Create ModelsPlotMulticlass object.
labels and label_mapping are assessed and created to allow changing indices of confusion matrices to
corresponding values.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
label_classes (list, numpy.nda... | Create ModelsPlotMulticlass object. | def __init__(self, plot_design, label_classes, original_label_mapping):
"""Create ModelsPlotMulticlass object.
labels and label_mapping are assessed and created to allow changing indices of confusion matrices to
corresponding values.
Args:
plot_design (PlotDesign): PlotDesi... | [
"def",
"__init__",
"(",
"self",
",",
"plot_design",
",",
"label_classes",
",",
"original_label_mapping",
")",
":",
"self",
".",
"plot_design",
"=",
"plot_design",
"self",
".",
"labels",
",",
"self",
".",
"label_mapping",
"=",
"self",
".",
"_create_labels_and_map... | [
1749,
4
] | [
1761,
112
] | python | en | ['en', 'fy', 'en'] | True |
ModelsPlotMulticlass.confusion_matrices_plot | (self, confusion_matrices) | Create bokeh Row of Confusion Matrices (HeatMaps).
Confusion Matrix for every Model is plotted in the row alongside others in the same order as they are passed.
As the first Model is also the best one in terms of performance, it gets another color for better visibility
in the visualization.
... | Create bokeh Row of Confusion Matrices (HeatMaps). | def confusion_matrices_plot(self, confusion_matrices):
"""Create bokeh Row of Confusion Matrices (HeatMaps).
Confusion Matrix for every Model is plotted in the row alongside others in the same order as they are passed.
As the first Model is also the best one in terms of performance, it gets ano... | [
"def",
"confusion_matrices_plot",
"(",
"self",
",",
"confusion_matrices",
")",
":",
"confusion_matrices",
"=",
"assess_models_names",
"(",
"confusion_matrices",
")",
"_",
"=",
"[",
"]",
"i",
"=",
"0",
"for",
"model",
",",
"array",
"in",
"confusion_matrices",
":"... | [
1763,
4
] | [
1792,
24
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotMulticlass._single_confusion_matrix_plot | (self, confusion_array, palette, model_name) | Create single Confusion Matrix Plot (HeatMap).
Values are included in the ColumnDataSource, from where Plot and Coloring use them. Rectangles in the Plot
are colored based on the values of predictions - the higher the value, the more intense the color. Numbers
are additionally plotted at the ce... | Create single Confusion Matrix Plot (HeatMap). | def _single_confusion_matrix_plot(self, confusion_array, palette, model_name):
"""Create single Confusion Matrix Plot (HeatMap).
Values are included in the ColumnDataSource, from where Plot and Coloring use them. Rectangles in the Plot
are colored based on the values of predictions - the higher... | [
"def",
"_single_confusion_matrix_plot",
"(",
"self",
",",
"confusion_array",
",",
"palette",
",",
"model_name",
")",
":",
"# source and cmap",
"source",
"=",
"self",
".",
"_create_column_data_source",
"(",
"confusion_array",
")",
"cmap",
"=",
"LinearColorMapper",
"(",... | [
1795,
4
] | [
1855,
16
] | python | en | ['en', 'ro', 'en'] | True |
ModelsPlotMulticlass._create_column_data_source | (self, confusion_array) | Create ColumnDataSource from confusion matrix.
Confusion Matrix is converted to pandas.DataFrame, from which different levels of index are taken for easy
mapping between Axes ranges and values. Every index is mapped with label_mapping attribute to it's corresponding
string value.
Args:... | Create ColumnDataSource from confusion matrix. | def _create_column_data_source(self, confusion_array):
"""Create ColumnDataSource from confusion matrix.
Confusion Matrix is converted to pandas.DataFrame, from which different levels of index are taken for easy
mapping between Axes ranges and values. Every index is mapped with label_mapping at... | [
"def",
"_create_column_data_source",
"(",
"self",
",",
"confusion_array",
")",
":",
"cds",
"=",
"ColumnDataSource",
"(",
")",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"confusion_array",
")",
".",
"stack",
"(",
")",
"old_x",
"=",
"df",
".",
"index",
".",
"... | [
1857,
4
] | [
1884,
18
] | python | en | ['en', 'en', 'en'] | True |
ModelsPlotMulticlass._create_labels_and_mapping | (self, labels, mapping) | Create string counterparts of labels and appropriate label mapping to be used in Figure axes.
Keys of mapping are simple enumerations of labels list (corresponding to indices in confusion matrix). Values
of mapping are either labels converted to string (if mapping is None) or their corresponding values... | Create string counterparts of labels and appropriate label mapping to be used in Figure axes. | def _create_labels_and_mapping(self, labels, mapping):
"""Create string counterparts of labels and appropriate label mapping to be used in Figure axes.
Keys of mapping are simple enumerations of labels list (corresponding to indices in confusion matrix). Values
of mapping are either labels conv... | [
"def",
"_create_labels_and_mapping",
"(",
"self",
",",
"labels",
",",
"mapping",
")",
":",
"numbered_classes",
"=",
"list",
"(",
"enumerate",
"(",
"list",
"(",
"labels",
")",
",",
"start",
"=",
"0",
")",
")",
"if",
"mapping",
":",
"new_mapping",
"=",
"{"... | [
1886,
4
] | [
1909,
38
] | python | en | ['en', 'en', 'en'] | True |
ModelsDataTable.__init__ | (self, plot_design) | Create ModelsDataTable object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
| Create ModelsDataTable object. | def __init__(self, plot_design):
"""Create ModelsDataTable object.
Args:
plot_design (PlotDesign): PlotDesign object with predefined style elements
"""
self.plot_design = plot_design | [
"def",
"__init__",
"(",
"self",
",",
"plot_design",
")",
":",
"self",
".",
"plot_design",
"=",
"plot_design"
] | [
1925,
4
] | [
1931,
38
] | python | da | ['da', 'zu', 'en'] | False |
ModelsDataTable.data_table | (self, X, y, models_predictions) | Create bokeh DataTable with X, y and predictions data.
bokeh DataTable is an interactive Table that can be sorted, columns can be dragged around and it has a nice
modern look. In the Table the first column of the Table is y - actual results. Predictions from Models follow
and at the end, the 'r... | Create bokeh DataTable with X, y and predictions data. | def data_table(self, X, y, models_predictions):
"""Create bokeh DataTable with X, y and predictions data.
bokeh DataTable is an interactive Table that can be sorted, columns can be dragged around and it has a nice
modern look. In the Table the first column of the Table is y - actual results. Pr... | [
"def",
"data_table",
"(",
"self",
",",
"X",
",",
"y",
",",
"models_predictions",
")",
":",
"models_predictions",
"=",
"assess_models_names",
"(",
"models_predictions",
")",
"base_color",
"=",
"self",
".",
"plot_design",
".",
"base_color_tints",
"[",
"0",
"]",
... | [
1933,
4
] | [
1989,
17
] | python | en | ['en', 'en', 'en'] | True |
html_escape | (text) | Produce entities within text. | Produce entities within text. | def html_escape(text):
"""Produce entities within text."""
return "".join(html_escape_table.get(c,c) for c in text) | [
"def",
"html_escape",
"(",
"text",
")",
":",
"return",
"\"\"",
".",
"join",
"(",
"html_escape_table",
".",
"get",
"(",
"c",
",",
"c",
")",
"for",
"c",
"in",
"text",
")"
] | [
51,
0
] | [
53,
60
] | python | en | ['en', 'en', 'en'] | True |
iscoroutinefunction | (func) | Return True if func is a decorated coroutine function.
Note: copied and modified from Python 3.5's builtin couroutines.py to avoid import asyncio directly,
which in turns also initializes the "logging" module as side-effect (see issue #8).
| Return True if func is a decorated coroutine function. | def iscoroutinefunction(func):
"""Return True if func is a decorated coroutine function.
Note: copied and modified from Python 3.5's builtin couroutines.py to avoid import asyncio directly,
which in turns also initializes the "logging" module as side-effect (see issue #8).
"""
return (getattr(func,... | [
"def",
"iscoroutinefunction",
"(",
"func",
")",
":",
"return",
"(",
"getattr",
"(",
"func",
",",
"'_is_coroutine'",
",",
"False",
")",
"or",
"(",
"hasattr",
"(",
"inspect",
",",
"'iscoroutinefunction'",
")",
"and",
"inspect",
".",
"iscoroutinefunction",
"(",
... | [
58,
0
] | [
65,
92
] | python | en | ['en', 'en', 'en'] | True |
num_mock_patch_args | (function) | return number of arguments used up by mock arguments (if any) | return number of arguments used up by mock arguments (if any) | def num_mock_patch_args(function):
""" return number of arguments used up by mock arguments (if any) """
patchings = getattr(function, "patchings", None)
if not patchings:
return 0
mock_modules = [sys.modules.get("mock"), sys.modules.get("unittest.mock")]
if any(mock_modules):
sentin... | [
"def",
"num_mock_patch_args",
"(",
"function",
")",
":",
"patchings",
"=",
"getattr",
"(",
"function",
",",
"\"patchings\"",
",",
"None",
")",
"if",
"not",
"patchings",
":",
"return",
"0",
"mock_modules",
"=",
"[",
"sys",
".",
"modules",
".",
"get",
"(",
... | [
76,
0
] | [
86,
25
] | python | en | ['en', 'en', 'en'] | True |
getfuncargnames | (function, is_method=False, cls=None) | Returns the names of a function's mandatory arguments.
This should return the names of all function arguments that:
* Aren't bound to an instance or type as in instance or class methods.
* Don't have default values.
* Aren't bound with functools.partial.
* Aren't replaced with mocks... | Returns the names of a function's mandatory arguments. | def getfuncargnames(function, is_method=False, cls=None):
"""Returns the names of a function's mandatory arguments.
This should return the names of all function arguments that:
* Aren't bound to an instance or type as in instance or class methods.
* Don't have default values.
* Aren't b... | [
"def",
"getfuncargnames",
"(",
"function",
",",
"is_method",
"=",
"False",
",",
"cls",
"=",
"None",
")",
":",
"# The parameters attribute of a Signature object contains an",
"# ordered mapping of parameter names to Parameter instances. This",
"# creates a tuple of the names of the p... | [
89,
0
] | [
126,
20
] | python | en | ['en', 'en', 'en'] | True |
get_real_func | (obj) | gets the real function object of the (possibly) wrapped object by
functools.wraps or functools.partial.
| gets the real function object of the (possibly) wrapped object by
functools.wraps or functools.partial.
| def get_real_func(obj):
""" gets the real function object of the (possibly) wrapped object by
functools.wraps or functools.partial.
"""
start_obj = obj
for i in range(100):
new_obj = getattr(obj, '__wrapped__', None)
if new_obj is None:
break
obj = new_obj
els... | [
"def",
"get_real_func",
"(",
"obj",
")",
":",
"start_obj",
"=",
"obj",
"for",
"i",
"in",
"range",
"(",
"100",
")",
":",
"new_obj",
"=",
"getattr",
"(",
"obj",
",",
"'__wrapped__'",
",",
"None",
")",
"if",
"new_obj",
"is",
"None",
":",
"break",
"obj",... | [
190,
0
] | [
208,
14
] | python | en | ['en', 'en', 'en'] | True |
safe_getattr | (object, name, default) | Like getattr but return default upon any Exception or any OutcomeException.
Attribute access can potentially fail for 'evil' Python objects.
See issue #214.
It catches OutcomeException because of #2490 (issue #580), new outcomes are derived from BaseException
instead of Exception (for more details che... | Like getattr but return default upon any Exception or any OutcomeException. | def safe_getattr(object, name, default):
""" Like getattr but return default upon any Exception or any OutcomeException.
Attribute access can potentially fail for 'evil' Python objects.
See issue #214.
It catches OutcomeException because of #2490 (issue #580), new outcomes are derived from BaseExceptio... | [
"def",
"safe_getattr",
"(",
"object",
",",
"name",
",",
"default",
")",
":",
"try",
":",
"return",
"getattr",
"(",
"object",
",",
"name",
",",
"default",
")",
"except",
"TEST_OUTCOME",
":",
"return",
"default"
] | [
228,
0
] | [
239,
22
] | python | en | ['en', 'en', 'en'] | True |
_is_unittest_unexpected_success_a_failure | () | Return if the test suite should fail if a @expectedFailure unittest test PASSES.
From https://docs.python.org/3/library/unittest.html?highlight=unittest#unittest.TestResult.wasSuccessful:
Changed in version 3.4: Returns False if there were any
unexpectedSuccesses from tests marked with the expected... | Return if the test suite should fail if a @expectedFailure unittest test PASSES. | def _is_unittest_unexpected_success_a_failure():
"""Return if the test suite should fail if a @expectedFailure unittest test PASSES.
From https://docs.python.org/3/library/unittest.html?highlight=unittest#unittest.TestResult.wasSuccessful:
Changed in version 3.4: Returns False if there were any
... | [
"def",
"_is_unittest_unexpected_success_a_failure",
"(",
")",
":",
"return",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"4",
")"
] | [
242,
0
] | [
249,
37
] | python | en | ['en', 'en', 'en'] | True |
FuncargnamesCompatAttr.funcargnames | (self) | alias attribute for ``fixturenames`` for pre-2.3 compatibility | alias attribute for ``fixturenames`` for pre-2.3 compatibility | def funcargnames(self):
""" alias attribute for ``fixturenames`` for pre-2.3 compatibility"""
return self.fixturenames | [
"def",
"funcargnames",
"(",
"self",
")",
":",
"return",
"self",
".",
"fixturenames"
] | [
320,
4
] | [
322,
32
] | python | en | ['en', 'it', 'en'] | True |
test_str_args_deprecated | (tmpdir, testdir) | Deprecate passing strings to pytest.main(). Scheduled for removal in pytest-4.0. | Deprecate passing strings to pytest.main(). Scheduled for removal in pytest-4.0. | def test_str_args_deprecated(tmpdir, testdir):
"""Deprecate passing strings to pytest.main(). Scheduled for removal in pytest-4.0."""
from _pytest.main import EXIT_NOTESTSCOLLECTED
warnings = []
class Collect(object):
def pytest_logwarning(self, message):
warnings.append(message)
... | [
"def",
"test_str_args_deprecated",
"(",
"tmpdir",
",",
"testdir",
")",
":",
"from",
"_pytest",
".",
"main",
"import",
"EXIT_NOTESTSCOLLECTED",
"warnings",
"=",
"[",
"]",
"class",
"Collect",
"(",
"object",
")",
":",
"def",
"pytest_logwarning",
"(",
"self",
",",... | [
50,
0
] | [
63,
39
] | python | en | ['en', 'en', 'en'] | True |
test_terminal_reporter_writer_attr | (pytestconfig) | Check that TerminalReporter._tw is also available as 'writer' (#2984)
This attribute is planned to be deprecated in 3.4.
| Check that TerminalReporter._tw is also available as 'writer' (#2984)
This attribute is planned to be deprecated in 3.4.
| def test_terminal_reporter_writer_attr(pytestconfig):
"""Check that TerminalReporter._tw is also available as 'writer' (#2984)
This attribute is planned to be deprecated in 3.4.
"""
try:
import xdist # noqa
pytest.skip('xdist workers disable the terminal reporter plugin')
except Imp... | [
"def",
"test_terminal_reporter_writer_attr",
"(",
"pytestconfig",
")",
":",
"try",
":",
"import",
"xdist",
"# noqa",
"pytest",
".",
"skip",
"(",
"'xdist workers disable the terminal reporter plugin'",
")",
"except",
"ImportError",
":",
"pass",
"terminal_reporter",
"=",
... | [
102,
0
] | [
112,
60
] | python | en | ['en', 'en', 'en'] | True |
Typed.__init__ | (self, schema, xstq=True) |
@param schema: A schema object
@type schema: L{xsd.schema.Schema}
@param xstq: The B{x}ml B{s}chema B{t}ype B{q}ualified flag indicates
that the I{xsi:type} attribute values should be qualified by namespace.
@type xstq: bool
| def __init__(self, schema, xstq=True):
"""
@param schema: A schema object
@type schema: L{xsd.schema.Schema}
@param xstq: The B{x}ml B{s}chema B{t}ype B{q}ualified flag indicates
that the I{xsi:type} attribute values should be qualified by namespace.
@type xstq: bool
... | [
"def",
"__init__",
"(",
"self",
",",
"schema",
",",
"xstq",
"=",
"True",
")",
":",
"Core",
".",
"__init__",
"(",
"self",
")",
"self",
".",
"schema",
"=",
"schema",
"self",
".",
"xstq",
"=",
"xstq",
"self",
".",
"resolver",
"=",
"GraphResolver",
"(",
... | [
55,
4
] | [
66,
50
] | python | en | ['en', 'error', 'th'] | False | |
Typed.skip | (self, content) |
Get whether to skip this I{content}.
Should be skipped when the content is optional
and either the value=None or the value is an empty list.
@param content: The content to skip.
@type content: L{Object}
@return: True if content is to be skipped.
@rtype: bool
... |
Get whether to skip this I{content}.
Should be skipped when the content is optional
and either the value=None or the value is an empty list.
| def skip(self, content):
"""
Get whether to skip this I{content}.
Should be skipped when the content is optional
and either the value=None or the value is an empty list.
@param content: The content to skip.
@type content: L{Object}
@return: True if content is to b... | [
"def",
"skip",
"(",
"self",
",",
"content",
")",
":",
"if",
"self",
".",
"optional",
"(",
"content",
")",
":",
"v",
"=",
"content",
".",
"value",
"if",
"v",
"is",
"None",
":",
"return",
"True",
"if",
"isinstance",
"(",
"v",
",",
"(",
"list",
",",... | [
199,
4
] | [
215,
20
] | python | en | ['en', 'error', 'th'] | False |
Typed.translate | (self, content) |
Translate using the XSD type information.
Python I{dict} is translated to a suds object. Most
importantly, primative values are translated from python
types to XML types using the XSD type.
@param content: The content to translate.
@type content: L{Object}
@retu... |
Translate using the XSD type information.
Python I{dict} is translated to a suds object. Most
importantly, primative values are translated from python
types to XML types using the XSD type.
| def translate(self, content):
"""
Translate using the XSD type information.
Python I{dict} is translated to a suds object. Most
importantly, primative values are translated from python
types to XML types using the XSD type.
@param content: The content to translate.
... | [
"def",
"translate",
"(",
"self",
",",
"content",
")",
":",
"v",
"=",
"content",
".",
"value",
"if",
"v",
"is",
"None",
":",
"return",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
"cls",
"=",
"content",
".",
"real",
".",
"name",
"content",
... | [
225,
4
] | [
247,
19
] | python | en | ['en', 'error', 'th'] | False |
Typed.sort | (self, content) |
Sort suds object attributes based on ordering defined
in the XSD type information.
@param content: The content to sort.
@type content: L{Object}
@return: self
@rtype: L{Typed}
|
Sort suds object attributes based on ordering defined
in the XSD type information.
| def sort(self, content):
"""
Sort suds object attributes based on ordering defined
in the XSD type information.
@param content: The content to sort.
@type content: L{Object}
@return: self
@rtype: L{Typed}
"""
v = content.value
if isinstance... | [
"def",
"sort",
"(",
"self",
",",
"content",
")",
":",
"v",
"=",
"content",
".",
"value",
"if",
"isinstance",
"(",
"v",
",",
"Object",
")",
":",
"md",
"=",
"v",
".",
"__metadata__",
"md",
".",
"ordering",
"=",
"self",
".",
"ordering",
"(",
"content"... | [
249,
4
] | [
262,
19
] | python | en | ['en', 'error', 'th'] | False |
Typed.ordering | (self, type) |
Get the attribute ordering defined in the specified
XSD type information.
@param type: An XSD type object.
@type type: SchemaObject
@return: An ordered list of attribute names.
@rtype: list
|
Get the attribute ordering defined in the specified
XSD type information.
| def ordering(self, type):
"""
Get the attribute ordering defined in the specified
XSD type information.
@param type: An XSD type object.
@type type: SchemaObject
@return: An ordered list of attribute names.
@rtype: list
"""
result = []
for ... | [
"def",
"ordering",
"(",
"self",
",",
"type",
")",
":",
"result",
"=",
"[",
"]",
"for",
"child",
",",
"ancestry",
"in",
"type",
".",
"resolve",
"(",
")",
":",
"name",
"=",
"child",
".",
"name",
"if",
"child",
".",
"name",
"is",
"None",
":",
"conti... | [
264,
4
] | [
281,
21
] | python | en | ['en', 'error', 'th'] | False |
TextFile.__init__ | (self, filename=None, file=None, **options) | Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'. | Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'. | def __init__(self, filename=None, file=None, **options):
"""Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'.... | [
"def",
"__init__",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"file",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"filename",
"is",
"None",
"and",
"file",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"you must supply either or both of... | [
77,
4
] | [
108,
25
] | python | en | ['en', 'en', 'en'] | True |
TextFile.open | (self, filename) | Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor. | Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor. | def open(self, filename):
"""Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor."""
self.filename = filename
self.file = io.open(self.filename, 'r', errors=self.errors)
self.current_line = 0 | [
"def",
"open",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"filename",
"=",
"filename",
"self",
".",
"file",
"=",
"io",
".",
"open",
"(",
"self",
".",
"filename",
",",
"'r'",
",",
"errors",
"=",
"self",
".",
"errors",
")",
"self",
".",
"... | [
110,
4
] | [
115,
29
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.