repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
dddomodossola/remi | examples/svgplot_app.py | SvgComposedPoly.add_coord | def add_coord(self, x, y):
""" Adds a coord to the polyline and creates another circle
"""
x = x*self.x_factor
y = y*self.y_factor
self.plotData.add_coord(x, y)
self.circles_list.append(gui.SvgCircle(x, y, self.circle_radius))
self.append(self.circles_list[-1])
... | python | def add_coord(self, x, y):
""" Adds a coord to the polyline and creates another circle
"""
x = x*self.x_factor
y = y*self.y_factor
self.plotData.add_coord(x, y)
self.circles_list.append(gui.SvgCircle(x, y, self.circle_radius))
self.append(self.circles_list[-1])
... | [
"def",
"add_coord",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"x",
"=",
"x",
"*",
"self",
".",
"x_factor",
"y",
"=",
"y",
"*",
"self",
".",
"y_factor",
"self",
".",
"plotData",
".",
"add_coord",
"(",
"x",
",",
"y",
")",
"self",
".",
"circles_l... | Adds a coord to the polyline and creates another circle | [
"Adds",
"a",
"coord",
"to",
"the",
"polyline",
"and",
"creates",
"another",
"circle"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/svgplot_app.py#L39-L49 | train |
dddomodossola/remi | examples/examples_from_contributors/Display_TreeTable.py | MyApp.My_TreeTable | def My_TreeTable(self, table, heads, heads2=None):
''' Define and display a table
in which the values in first column form one or more trees.
'''
self.Define_TreeTable(heads, heads2)
self.Display_TreeTable(table) | python | def My_TreeTable(self, table, heads, heads2=None):
''' Define and display a table
in which the values in first column form one or more trees.
'''
self.Define_TreeTable(heads, heads2)
self.Display_TreeTable(table) | [
"def",
"My_TreeTable",
"(",
"self",
",",
"table",
",",
"heads",
",",
"heads2",
"=",
"None",
")",
":",
"self",
".",
"Define_TreeTable",
"(",
"heads",
",",
"heads2",
")",
"self",
".",
"Display_TreeTable",
"(",
"table",
")"
] | Define and display a table
in which the values in first column form one or more trees. | [
"Define",
"and",
"display",
"a",
"table",
"in",
"which",
"the",
"values",
"in",
"first",
"column",
"form",
"one",
"or",
"more",
"trees",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/examples_from_contributors/Display_TreeTable.py#L26-L31 | train |
dddomodossola/remi | examples/examples_from_contributors/Display_TreeTable.py | MyApp.Define_TreeTable | def Define_TreeTable(self, heads, heads2=None):
''' Define a TreeTable with a heading row
and optionally a second heading row.
'''
display_heads = []
display_heads.append(tuple(heads[2:]))
self.tree_table = TreeTable()
self.tree_table.append_from_list(display_... | python | def Define_TreeTable(self, heads, heads2=None):
''' Define a TreeTable with a heading row
and optionally a second heading row.
'''
display_heads = []
display_heads.append(tuple(heads[2:]))
self.tree_table = TreeTable()
self.tree_table.append_from_list(display_... | [
"def",
"Define_TreeTable",
"(",
"self",
",",
"heads",
",",
"heads2",
"=",
"None",
")",
":",
"display_heads",
"=",
"[",
"]",
"display_heads",
".",
"append",
"(",
"tuple",
"(",
"heads",
"[",
"2",
":",
"]",
")",
")",
"self",
".",
"tree_table",
"=",
"Tre... | Define a TreeTable with a heading row
and optionally a second heading row. | [
"Define",
"a",
"TreeTable",
"with",
"a",
"heading",
"row",
"and",
"optionally",
"a",
"second",
"heading",
"row",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/examples_from_contributors/Display_TreeTable.py#L33-L49 | train |
dddomodossola/remi | examples/gauge_app.py | InputGauge.confirm_value | def confirm_value(self, widget, x, y):
"""event called clicking on the gauge and so changing its value.
propagates the new value
"""
self.gauge.onmousedown(self.gauge, x, y)
params = (self.gauge.value)
return params | python | def confirm_value(self, widget, x, y):
"""event called clicking on the gauge and so changing its value.
propagates the new value
"""
self.gauge.onmousedown(self.gauge, x, y)
params = (self.gauge.value)
return params | [
"def",
"confirm_value",
"(",
"self",
",",
"widget",
",",
"x",
",",
"y",
")",
":",
"self",
".",
"gauge",
".",
"onmousedown",
"(",
"self",
".",
"gauge",
",",
"x",
",",
"y",
")",
"params",
"=",
"(",
"self",
".",
"gauge",
".",
"value",
")",
"return",... | event called clicking on the gauge and so changing its value.
propagates the new value | [
"event",
"called",
"clicking",
"on",
"the",
"gauge",
"and",
"so",
"changing",
"its",
"value",
".",
"propagates",
"the",
"new",
"value"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/gauge_app.py#L40-L46 | train |
dddomodossola/remi | editor/editor.py | Editor.configure_widget_for_editing | def configure_widget_for_editing(self, widget):
""" A widget have to be added to the editor, it is configured here in order to be conformant
to the editor
"""
if not 'editor_varname' in widget.attributes:
return
widget.onclick.do(self.on_widget_selection... | python | def configure_widget_for_editing(self, widget):
""" A widget have to be added to the editor, it is configured here in order to be conformant
to the editor
"""
if not 'editor_varname' in widget.attributes:
return
widget.onclick.do(self.on_widget_selection... | [
"def",
"configure_widget_for_editing",
"(",
"self",
",",
"widget",
")",
":",
"if",
"not",
"'editor_varname'",
"in",
"widget",
".",
"attributes",
":",
"return",
"widget",
".",
"onclick",
".",
"do",
"(",
"self",
".",
"on_widget_selection",
")",
"#setup of the on_d... | A widget have to be added to the editor, it is configured here in order to be conformant
to the editor | [
"A",
"widget",
"have",
"to",
"be",
"added",
"to",
"the",
"editor",
"it",
"is",
"configured",
"here",
"in",
"order",
"to",
"be",
"conformant",
"to",
"the",
"editor"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/editor/editor.py#L656-L680 | train |
dddomodossola/remi | examples/minefield_app.py | Cell.on_right_click | def on_right_click(self, widget):
""" Here with right click the change of cell is changed """
if self.opened:
return
self.state = (self.state + 1) % 3
self.set_icon()
self.game.check_if_win() | python | def on_right_click(self, widget):
""" Here with right click the change of cell is changed """
if self.opened:
return
self.state = (self.state + 1) % 3
self.set_icon()
self.game.check_if_win() | [
"def",
"on_right_click",
"(",
"self",
",",
"widget",
")",
":",
"if",
"self",
".",
"opened",
":",
"return",
"self",
".",
"state",
"=",
"(",
"self",
".",
"state",
"+",
"1",
")",
"%",
"3",
"self",
".",
"set_icon",
"(",
")",
"self",
".",
"game",
".",... | Here with right click the change of cell is changed | [
"Here",
"with",
"right",
"click",
"the",
"change",
"of",
"cell",
"is",
"changed"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/minefield_app.py#L49-L55 | train |
dddomodossola/remi | examples/minefield_app.py | MyApp.build_mine_matrix | def build_mine_matrix(self, w, h, minenum):
"""random fill cells with mines and increments nearest mines num in adiacent cells"""
self.minecount = 0
matrix = [[Cell(30, 30, x, y, self) for x in range(w)] for y in range(h)]
for i in range(0, minenum):
x = random.randint(0, w -... | python | def build_mine_matrix(self, w, h, minenum):
"""random fill cells with mines and increments nearest mines num in adiacent cells"""
self.minecount = 0
matrix = [[Cell(30, 30, x, y, self) for x in range(w)] for y in range(h)]
for i in range(0, minenum):
x = random.randint(0, w -... | [
"def",
"build_mine_matrix",
"(",
"self",
",",
"w",
",",
"h",
",",
"minenum",
")",
":",
"self",
".",
"minecount",
"=",
"0",
"matrix",
"=",
"[",
"[",
"Cell",
"(",
"30",
",",
"30",
",",
"x",
",",
"y",
",",
"self",
")",
"for",
"x",
"in",
"range",
... | random fill cells with mines and increments nearest mines num in adiacent cells | [
"random",
"fill",
"cells",
"with",
"mines",
"and",
"increments",
"nearest",
"mines",
"num",
"in",
"adiacent",
"cells"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/minefield_app.py#L184-L201 | train |
dddomodossola/remi | examples/minefield_app.py | MyApp.check_if_win | def check_if_win(self):
"""Here are counted the flags. Is checked if the user win."""
self.flagcount = 0
win = True
for x in range(0, len(self.mine_matrix[0])):
for y in range(0, len(self.mine_matrix)):
if self.mine_matrix[y][x].state == 1:
... | python | def check_if_win(self):
"""Here are counted the flags. Is checked if the user win."""
self.flagcount = 0
win = True
for x in range(0, len(self.mine_matrix[0])):
for y in range(0, len(self.mine_matrix)):
if self.mine_matrix[y][x].state == 1:
... | [
"def",
"check_if_win",
"(",
"self",
")",
":",
"self",
".",
"flagcount",
"=",
"0",
"win",
"=",
"True",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"mine_matrix",
"[",
"0",
"]",
")",
")",
":",
"for",
"y",
"in",
"range",
"("... | Here are counted the flags. Is checked if the user win. | [
"Here",
"are",
"counted",
"the",
"flags",
".",
"Is",
"checked",
"if",
"the",
"user",
"win",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/minefield_app.py#L209-L227 | train |
dddomodossola/remi | examples/session_app.py | LoginManager.renew_session | def renew_session(self):
"""Have to be called on user actions to check and renew session
"""
if ((not 'user_uid' in self.cookieInterface.cookies) or self.cookieInterface.cookies['user_uid']!=self.session_uid) and (not self.expired):
self.on_session_expired()
if self.expired:... | python | def renew_session(self):
"""Have to be called on user actions to check and renew session
"""
if ((not 'user_uid' in self.cookieInterface.cookies) or self.cookieInterface.cookies['user_uid']!=self.session_uid) and (not self.expired):
self.on_session_expired()
if self.expired:... | [
"def",
"renew_session",
"(",
"self",
")",
":",
"if",
"(",
"(",
"not",
"'user_uid'",
"in",
"self",
".",
"cookieInterface",
".",
"cookies",
")",
"or",
"self",
".",
"cookieInterface",
".",
"cookies",
"[",
"'user_uid'",
"]",
"!=",
"self",
".",
"session_uid",
... | Have to be called on user actions to check and renew session | [
"Have",
"to",
"be",
"called",
"on",
"user",
"actions",
"to",
"check",
"and",
"renew",
"session"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/session_app.py#L146-L162 | train |
dddomodossola/remi | remi/gui.py | decorate_event_js | def decorate_event_js(js_code):
"""setup a method as an event, adding also javascript code to generate
Args:
js_code (str): javascript code to generate the event client-side.
js_code is added to the widget html as
widget.attributes['onclick'] = js_code%{'emitter_identifier':wid... | python | def decorate_event_js(js_code):
"""setup a method as an event, adding also javascript code to generate
Args:
js_code (str): javascript code to generate the event client-side.
js_code is added to the widget html as
widget.attributes['onclick'] = js_code%{'emitter_identifier':wid... | [
"def",
"decorate_event_js",
"(",
"js_code",
")",
":",
"def",
"add_annotation",
"(",
"method",
")",
":",
"setattr",
"(",
"method",
",",
"\"__is_event\"",
",",
"True",
")",
"setattr",
"(",
"method",
",",
"\"_js_code\"",
",",
"js_code",
")",
"return",
"method",... | setup a method as an event, adding also javascript code to generate
Args:
js_code (str): javascript code to generate the event client-side.
js_code is added to the widget html as
widget.attributes['onclick'] = js_code%{'emitter_identifier':widget.identifier, 'event_name':'onclick'} | [
"setup",
"a",
"method",
"as",
"an",
"event",
"adding",
"also",
"javascript",
"code",
"to",
"generate"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L128-L140 | train |
dddomodossola/remi | remi/gui.py | decorate_set_on_listener | def decorate_set_on_listener(prototype):
""" Private decorator for use in the editor.
Allows the Editor to create listener methods.
Args:
params (str): The list of parameters for the listener
method (es. "(self, new_value)")
"""
# noinspection PyDictCreation,PyP... | python | def decorate_set_on_listener(prototype):
""" Private decorator for use in the editor.
Allows the Editor to create listener methods.
Args:
params (str): The list of parameters for the listener
method (es. "(self, new_value)")
"""
# noinspection PyDictCreation,PyP... | [
"def",
"decorate_set_on_listener",
"(",
"prototype",
")",
":",
"# noinspection PyDictCreation,PyProtectedMember",
"def",
"add_annotation",
"(",
"method",
")",
":",
"method",
".",
"_event_info",
"=",
"{",
"}",
"method",
".",
"_event_info",
"[",
"'name'",
"]",
"=",
... | Private decorator for use in the editor.
Allows the Editor to create listener methods.
Args:
params (str): The list of parameters for the listener
method (es. "(self, new_value)") | [
"Private",
"decorator",
"for",
"use",
"in",
"the",
"editor",
".",
"Allows",
"the",
"Editor",
"to",
"create",
"listener",
"methods",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L143-L158 | train |
dddomodossola/remi | remi/gui.py | ClassEventConnector.do | def do(self, callback, *userdata):
""" The callback and userdata gets stored, and if there is some javascript to add
the js code is appended as attribute for the event source
"""
if hasattr(self.event_method_bound, '_js_code'):
self.event_source_instance.attributes[self.e... | python | def do(self, callback, *userdata):
""" The callback and userdata gets stored, and if there is some javascript to add
the js code is appended as attribute for the event source
"""
if hasattr(self.event_method_bound, '_js_code'):
self.event_source_instance.attributes[self.e... | [
"def",
"do",
"(",
"self",
",",
"callback",
",",
"*",
"userdata",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"event_method_bound",
",",
"'_js_code'",
")",
":",
"self",
".",
"event_source_instance",
".",
"attributes",
"[",
"self",
".",
"event_name",
"]",
... | The callback and userdata gets stored, and if there is some javascript to add
the js code is appended as attribute for the event source | [
"The",
"callback",
"and",
"userdata",
"gets",
"stored",
"and",
"if",
"there",
"is",
"some",
"javascript",
"to",
"add",
"the",
"js",
"code",
"is",
"appended",
"as",
"attribute",
"for",
"the",
"event",
"source"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L98-L106 | train |
dddomodossola/remi | remi/gui.py | Tag.add_child | def add_child(self, key, value):
"""Adds a child to the Tag
To retrieve the child call get_child or access to the Tag.children[key] dictionary.
Args:
key (str): Unique child's identifier, or iterable of keys
value (Tag, str): can be a Tag, an iterable of Tag or a str. ... | python | def add_child(self, key, value):
"""Adds a child to the Tag
To retrieve the child call get_child or access to the Tag.children[key] dictionary.
Args:
key (str): Unique child's identifier, or iterable of keys
value (Tag, str): can be a Tag, an iterable of Tag or a str. ... | [
"def",
"add_child",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"in",
"(",
"list",
",",
"tuple",
",",
"dict",
")",
":",
"if",
"type",
"(",
"value",
")",
"==",
"dict",
":",
"for",
"k",
"in",
"value",
".",
... | Adds a child to the Tag
To retrieve the child call get_child or access to the Tag.children[key] dictionary.
Args:
key (str): Unique child's identifier, or iterable of keys
value (Tag, str): can be a Tag, an iterable of Tag or a str. In case of iterable
of Tag i... | [
"Adds",
"a",
"child",
"to",
"the",
"Tag"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L380-L409 | train |
dddomodossola/remi | remi/gui.py | Tag.empty | def empty(self):
"""remove all children from the widget"""
for k in list(self.children.keys()):
self.remove_child(self.children[k]) | python | def empty(self):
"""remove all children from the widget"""
for k in list(self.children.keys()):
self.remove_child(self.children[k]) | [
"def",
"empty",
"(",
"self",
")",
":",
"for",
"k",
"in",
"list",
"(",
"self",
".",
"children",
".",
"keys",
"(",
")",
")",
":",
"self",
".",
"remove_child",
"(",
"self",
".",
"children",
"[",
"k",
"]",
")"
] | remove all children from the widget | [
"remove",
"all",
"children",
"from",
"the",
"widget"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L425-L428 | train |
dddomodossola/remi | remi/gui.py | Tag.remove_child | def remove_child(self, child):
"""Removes a child instance from the Tag's children.
Args:
child (Tag): The child to be removed.
"""
if child in self.children.values() and hasattr(child, 'identifier'):
for k in self.children.keys():
if hasattr(self... | python | def remove_child(self, child):
"""Removes a child instance from the Tag's children.
Args:
child (Tag): The child to be removed.
"""
if child in self.children.values() and hasattr(child, 'identifier'):
for k in self.children.keys():
if hasattr(self... | [
"def",
"remove_child",
"(",
"self",
",",
"child",
")",
":",
"if",
"child",
"in",
"self",
".",
"children",
".",
"values",
"(",
")",
"and",
"hasattr",
"(",
"child",
",",
"'identifier'",
")",
":",
"for",
"k",
"in",
"self",
".",
"children",
".",
"keys",
... | Removes a child instance from the Tag's children.
Args:
child (Tag): The child to be removed. | [
"Removes",
"a",
"child",
"instance",
"from",
"the",
"Tag",
"s",
"children",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L430-L445 | train |
dddomodossola/remi | remi/gui.py | Widget.set_size | def set_size(self, width, height):
"""Set the widget size.
Args:
width (int or str): An optional width for the widget (es. width=10 or width='10px' or width='10%').
height (int or str): An optional height for the widget (es. height=10 or height='10px' or height='10%').
"... | python | def set_size(self, width, height):
"""Set the widget size.
Args:
width (int or str): An optional width for the widget (es. width=10 or width='10px' or width='10%').
height (int or str): An optional height for the widget (es. height=10 or height='10px' or height='10%').
"... | [
"def",
"set_size",
"(",
"self",
",",
"width",
",",
"height",
")",
":",
"if",
"width",
"is",
"not",
"None",
":",
"try",
":",
"width",
"=",
"to_pix",
"(",
"int",
"(",
"width",
")",
")",
"except",
"ValueError",
":",
"# now we know w has 'px or % in it'",
"p... | Set the widget size.
Args:
width (int or str): An optional width for the widget (es. width=10 or width='10px' or width='10%').
height (int or str): An optional height for the widget (es. height=10 or height='10px' or height='10%'). | [
"Set",
"the",
"widget",
"size",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L548-L569 | train |
dddomodossola/remi | remi/gui.py | Widget.repr | def repr(self, changed_widgets=None):
"""Represents the widget as HTML format, packs all the attributes, children and so on.
Args:
client (App): Client instance.
changed_widgets (dict): A dictionary containing a collection of widgets that have to be updated.
The ... | python | def repr(self, changed_widgets=None):
"""Represents the widget as HTML format, packs all the attributes, children and so on.
Args:
client (App): Client instance.
changed_widgets (dict): A dictionary containing a collection of widgets that have to be updated.
The ... | [
"def",
"repr",
"(",
"self",
",",
"changed_widgets",
"=",
"None",
")",
":",
"if",
"changed_widgets",
"is",
"None",
":",
"changed_widgets",
"=",
"{",
"}",
"return",
"super",
"(",
"Widget",
",",
"self",
")",
".",
"repr",
"(",
"changed_widgets",
")"
] | Represents the widget as HTML format, packs all the attributes, children and so on.
Args:
client (App): Client instance.
changed_widgets (dict): A dictionary containing a collection of widgets that have to be updated.
The Widget that have to be updated is the key, and th... | [
"Represents",
"the",
"widget",
"as",
"HTML",
"format",
"packs",
"all",
"the",
"attributes",
"children",
"and",
"so",
"on",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L583-L593 | train |
dddomodossola/remi | remi/gui.py | HEAD.set_icon_file | def set_icon_file(self, filename, rel="icon"):
""" Allows to define an icon for the App
Args:
filename (str): the resource file name (ie. "/res:myicon.png")
rel (str): leave it unchanged (standard "icon")
"""
mimetype, encoding = mimetypes.guess_type(... | python | def set_icon_file(self, filename, rel="icon"):
""" Allows to define an icon for the App
Args:
filename (str): the resource file name (ie. "/res:myicon.png")
rel (str): leave it unchanged (standard "icon")
"""
mimetype, encoding = mimetypes.guess_type(... | [
"def",
"set_icon_file",
"(",
"self",
",",
"filename",
",",
"rel",
"=",
"\"icon\"",
")",
":",
"mimetype",
",",
"encoding",
"=",
"mimetypes",
".",
"guess_type",
"(",
"filename",
")",
"self",
".",
"add_child",
"(",
"\"favicon\"",
",",
"'<link rel=\"%s\" href=\"%s... | Allows to define an icon for the App
Args:
filename (str): the resource file name (ie. "/res:myicon.png")
rel (str): leave it unchanged (standard "icon") | [
"Allows",
"to",
"define",
"an",
"icon",
"for",
"the",
"App"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L981-L989 | train |
dddomodossola/remi | remi/gui.py | BODY.onerror | def onerror(self, message, source, lineno, colno):
"""Called when an error occurs."""
return (message, source, lineno, colno) | python | def onerror(self, message, source, lineno, colno):
"""Called when an error occurs."""
return (message, source, lineno, colno) | [
"def",
"onerror",
"(",
"self",
",",
"message",
",",
"source",
",",
"lineno",
",",
"colno",
")",
":",
"return",
"(",
"message",
",",
"source",
",",
"lineno",
",",
"colno",
")"
] | Called when an error occurs. | [
"Called",
"when",
"an",
"error",
"occurs",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1306-L1308 | train |
dddomodossola/remi | remi/gui.py | GridBox.set_column_sizes | def set_column_sizes(self, values):
"""Sets the size value for each column
Args:
values (iterable of int or str): values are treated as percentage.
"""
self.style['grid-template-columns'] = ' '.join(map(lambda value: (str(value) if str(value).endswith('%') else str(value) + ... | python | def set_column_sizes(self, values):
"""Sets the size value for each column
Args:
values (iterable of int or str): values are treated as percentage.
"""
self.style['grid-template-columns'] = ' '.join(map(lambda value: (str(value) if str(value).endswith('%') else str(value) + ... | [
"def",
"set_column_sizes",
"(",
"self",
",",
"values",
")",
":",
"self",
".",
"style",
"[",
"'grid-template-columns'",
"]",
"=",
"' '",
".",
"join",
"(",
"map",
"(",
"lambda",
"value",
":",
"(",
"str",
"(",
"value",
")",
"if",
"str",
"(",
"value",
")... | Sets the size value for each column
Args:
values (iterable of int or str): values are treated as percentage. | [
"Sets",
"the",
"size",
"value",
"for",
"each",
"column"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1406-L1412 | train |
dddomodossola/remi | remi/gui.py | GridBox.set_column_gap | def set_column_gap(self, value):
"""Sets the gap value between columns
Args:
value (int or str): gap value (i.e. 10 or "10px")
"""
value = str(value) + 'px'
value = value.replace('pxpx', 'px')
self.style['grid-column-gap'] = value | python | def set_column_gap(self, value):
"""Sets the gap value between columns
Args:
value (int or str): gap value (i.e. 10 or "10px")
"""
value = str(value) + 'px'
value = value.replace('pxpx', 'px')
self.style['grid-column-gap'] = value | [
"def",
"set_column_gap",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"+",
"'px'",
"value",
"=",
"value",
".",
"replace",
"(",
"'pxpx'",
",",
"'px'",
")",
"self",
".",
"style",
"[",
"'grid-column-gap'",
"]",
"=",
"valu... | Sets the gap value between columns
Args:
value (int or str): gap value (i.e. 10 or "10px") | [
"Sets",
"the",
"gap",
"value",
"between",
"columns"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1422-L1430 | train |
dddomodossola/remi | remi/gui.py | GridBox.set_row_gap | def set_row_gap(self, value):
"""Sets the gap value between rows
Args:
value (int or str): gap value (i.e. 10 or "10px")
"""
value = str(value) + 'px'
value = value.replace('pxpx', 'px')
self.style['grid-row-gap'] = value | python | def set_row_gap(self, value):
"""Sets the gap value between rows
Args:
value (int or str): gap value (i.e. 10 or "10px")
"""
value = str(value) + 'px'
value = value.replace('pxpx', 'px')
self.style['grid-row-gap'] = value | [
"def",
"set_row_gap",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"+",
"'px'",
"value",
"=",
"value",
".",
"replace",
"(",
"'pxpx'",
",",
"'px'",
")",
"self",
".",
"style",
"[",
"'grid-row-gap'",
"]",
"=",
"value"
] | Sets the gap value between rows
Args:
value (int or str): gap value (i.e. 10 or "10px") | [
"Sets",
"the",
"gap",
"value",
"between",
"rows"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1432-L1440 | train |
dddomodossola/remi | remi/gui.py | TabBox.select_by_widget | def select_by_widget(self, widget):
""" shows a tab identified by the contained widget """
for a, li, holder in self._tabs.values():
if holder.children['content'] == widget:
self._on_tab_pressed(a, li, holder)
return | python | def select_by_widget(self, widget):
""" shows a tab identified by the contained widget """
for a, li, holder in self._tabs.values():
if holder.children['content'] == widget:
self._on_tab_pressed(a, li, holder)
return | [
"def",
"select_by_widget",
"(",
"self",
",",
"widget",
")",
":",
"for",
"a",
",",
"li",
",",
"holder",
"in",
"self",
".",
"_tabs",
".",
"values",
"(",
")",
":",
"if",
"holder",
".",
"children",
"[",
"'content'",
"]",
"==",
"widget",
":",
"self",
".... | shows a tab identified by the contained widget | [
"shows",
"a",
"tab",
"identified",
"by",
"the",
"contained",
"widget"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1573-L1578 | train |
dddomodossola/remi | remi/gui.py | TabBox.select_by_name | def select_by_name(self, name):
""" shows a tab identified by the name """
for a, li, holder in self._tabs.values():
if a.children['text'] == name:
self._on_tab_pressed(a, li, holder)
return | python | def select_by_name(self, name):
""" shows a tab identified by the name """
for a, li, holder in self._tabs.values():
if a.children['text'] == name:
self._on_tab_pressed(a, li, holder)
return | [
"def",
"select_by_name",
"(",
"self",
",",
"name",
")",
":",
"for",
"a",
",",
"li",
",",
"holder",
"in",
"self",
".",
"_tabs",
".",
"values",
"(",
")",
":",
"if",
"a",
".",
"children",
"[",
"'text'",
"]",
"==",
"name",
":",
"self",
".",
"_on_tab_... | shows a tab identified by the name | [
"shows",
"a",
"tab",
"identified",
"by",
"the",
"name"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1580-L1585 | train |
dddomodossola/remi | remi/gui.py | TextInput.set_value | def set_value(self, text):
"""Sets the text content.
Args:
text (str): The string content that have to be appended as standard child identified by the key 'text'
"""
if self.single_line:
text = text.replace('\n', '')
self.set_text(text) | python | def set_value(self, text):
"""Sets the text content.
Args:
text (str): The string content that have to be appended as standard child identified by the key 'text'
"""
if self.single_line:
text = text.replace('\n', '')
self.set_text(text) | [
"def",
"set_value",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"single_line",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"'\\n'",
",",
"''",
")",
"self",
".",
"set_text",
"(",
"text",
")"
] | Sets the text content.
Args:
text (str): The string content that have to be appended as standard child identified by the key 'text' | [
"Sets",
"the",
"text",
"content",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1711-L1719 | train |
dddomodossola/remi | remi/gui.py | TextInput.onchange | def onchange(self, new_value):
"""Called when the user changes the TextInput content.
With single_line=True it fires in case of focus lost and Enter key pressed.
With single_line=False it fires at each key released.
Args:
new_value (str): the new string content of the TextIn... | python | def onchange(self, new_value):
"""Called when the user changes the TextInput content.
With single_line=True it fires in case of focus lost and Enter key pressed.
With single_line=False it fires at each key released.
Args:
new_value (str): the new string content of the TextIn... | [
"def",
"onchange",
"(",
"self",
",",
"new_value",
")",
":",
"self",
".",
"disable_refresh",
"(",
")",
"self",
".",
"set_value",
"(",
"new_value",
")",
"self",
".",
"enable_refresh",
"(",
")",
"return",
"(",
"new_value",
",",
")"
] | Called when the user changes the TextInput content.
With single_line=True it fires in case of focus lost and Enter key pressed.
With single_line=False it fires at each key released.
Args:
new_value (str): the new string content of the TextInput. | [
"Called",
"when",
"the",
"user",
"changes",
"the",
"TextInput",
"content",
".",
"With",
"single_line",
"=",
"True",
"it",
"fires",
"in",
"case",
"of",
"focus",
"lost",
"and",
"Enter",
"key",
"pressed",
".",
"With",
"single_line",
"=",
"False",
"it",
"fires... | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1730-L1741 | train |
dddomodossola/remi | remi/gui.py | GenericDialog.add_field_with_label | def add_field_with_label(self, key, label_description, field):
"""
Adds a field to the dialog together with a descriptive label and a unique identifier.
Note: You can access to the fields content calling the function GenericDialog.get_field(key).
Args:
key (str): The unique... | python | def add_field_with_label(self, key, label_description, field):
"""
Adds a field to the dialog together with a descriptive label and a unique identifier.
Note: You can access to the fields content calling the function GenericDialog.get_field(key).
Args:
key (str): The unique... | [
"def",
"add_field_with_label",
"(",
"self",
",",
"key",
",",
"label_description",
",",
"field",
")",
":",
"self",
".",
"inputs",
"[",
"key",
"]",
"=",
"field",
"label",
"=",
"Label",
"(",
"label_description",
")",
"label",
".",
"style",
"[",
"'margin'",
... | Adds a field to the dialog together with a descriptive label and a unique identifier.
Note: You can access to the fields content calling the function GenericDialog.get_field(key).
Args:
key (str): The unique identifier for the field.
label_description (str): The string content ... | [
"Adds",
"a",
"field",
"to",
"the",
"dialog",
"together",
"with",
"a",
"descriptive",
"label",
"and",
"a",
"unique",
"identifier",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1894-L1914 | train |
dddomodossola/remi | remi/gui.py | GenericDialog.add_field | def add_field(self, key, field):
"""
Adds a field to the dialog with a unique identifier.
Note: You can access to the fields content calling the function GenericDialog.get_field(key).
Args:
key (str): The unique identifier for the field.
field (Widget): The widg... | python | def add_field(self, key, field):
"""
Adds a field to the dialog with a unique identifier.
Note: You can access to the fields content calling the function GenericDialog.get_field(key).
Args:
key (str): The unique identifier for the field.
field (Widget): The widg... | [
"def",
"add_field",
"(",
"self",
",",
"key",
",",
"field",
")",
":",
"self",
".",
"inputs",
"[",
"key",
"]",
"=",
"field",
"container",
"=",
"HBox",
"(",
")",
"container",
".",
"style",
".",
"update",
"(",
"{",
"'justify-content'",
":",
"'space-between... | Adds a field to the dialog with a unique identifier.
Note: You can access to the fields content calling the function GenericDialog.get_field(key).
Args:
key (str): The unique identifier for the field.
field (Widget): The widget to be added to the dialog, TextInput or any Widget... | [
"Adds",
"a",
"field",
"to",
"the",
"dialog",
"with",
"a",
"unique",
"identifier",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L1916-L1930 | train |
dddomodossola/remi | remi/gui.py | InputDialog.on_keydown_listener | def on_keydown_listener(self, widget, value, keycode):
"""event called pressing on ENTER key.
propagates the string content of the input field
"""
if keycode=="13":
self.hide()
self.inputText.set_text(value)
self.confirm_value(self) | python | def on_keydown_listener(self, widget, value, keycode):
"""event called pressing on ENTER key.
propagates the string content of the input field
"""
if keycode=="13":
self.hide()
self.inputText.set_text(value)
self.confirm_value(self) | [
"def",
"on_keydown_listener",
"(",
"self",
",",
"widget",
",",
"value",
",",
"keycode",
")",
":",
"if",
"keycode",
"==",
"\"13\"",
":",
"self",
".",
"hide",
"(",
")",
"self",
".",
"inputText",
".",
"set_text",
"(",
"value",
")",
"self",
".",
"confirm_v... | event called pressing on ENTER key.
propagates the string content of the input field | [
"event",
"called",
"pressing",
"on",
"ENTER",
"key",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2001-L2009 | train |
dddomodossola/remi | remi/gui.py | ListView.new_from_list | def new_from_list(cls, items, **kwargs):
"""Populates the ListView with a string list.
Args:
items (list): list of strings to fill the widget with.
"""
obj = cls(**kwargs)
for item in items:
obj.append(ListItem(item))
return obj | python | def new_from_list(cls, items, **kwargs):
"""Populates the ListView with a string list.
Args:
items (list): list of strings to fill the widget with.
"""
obj = cls(**kwargs)
for item in items:
obj.append(ListItem(item))
return obj | [
"def",
"new_from_list",
"(",
"cls",
",",
"items",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"cls",
"(",
"*",
"*",
"kwargs",
")",
"for",
"item",
"in",
"items",
":",
"obj",
".",
"append",
"(",
"ListItem",
"(",
"item",
")",
")",
"return",
"obj"... | Populates the ListView with a string list.
Args:
items (list): list of strings to fill the widget with. | [
"Populates",
"the",
"ListView",
"with",
"a",
"string",
"list",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2041-L2050 | train |
dddomodossola/remi | remi/gui.py | ListView.empty | def empty(self):
"""Removes all children from the list"""
self._selected_item = None
self._selected_key = None
super(ListView, self).empty() | python | def empty(self):
"""Removes all children from the list"""
self._selected_item = None
self._selected_key = None
super(ListView, self).empty() | [
"def",
"empty",
"(",
"self",
")",
":",
"self",
".",
"_selected_item",
"=",
"None",
"self",
".",
"_selected_key",
"=",
"None",
"super",
"(",
"ListView",
",",
"self",
")",
".",
"empty",
"(",
")"
] | Removes all children from the list | [
"Removes",
"all",
"children",
"from",
"the",
"list"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2077-L2081 | train |
dddomodossola/remi | remi/gui.py | ListView.onselection | def onselection(self, widget):
"""Called when a new item gets selected in the list."""
self._selected_key = None
for k in self.children:
if self.children[k] == widget: # widget is the selected ListItem
self._selected_key = k
if (self._selected_item is... | python | def onselection(self, widget):
"""Called when a new item gets selected in the list."""
self._selected_key = None
for k in self.children:
if self.children[k] == widget: # widget is the selected ListItem
self._selected_key = k
if (self._selected_item is... | [
"def",
"onselection",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"_selected_key",
"=",
"None",
"for",
"k",
"in",
"self",
".",
"children",
":",
"if",
"self",
".",
"children",
"[",
"k",
"]",
"==",
"widget",
":",
"# widget is the selected ListItem",
... | Called when a new item gets selected in the list. | [
"Called",
"when",
"a",
"new",
"item",
"gets",
"selected",
"in",
"the",
"list",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2085-L2097 | train |
dddomodossola/remi | remi/gui.py | ListView.select_by_key | def select_by_key(self, key):
"""Selects an item by its key.
Args:
key (str): The unique string identifier of the item that have to be selected.
"""
self._selected_key = None
self._selected_item = None
for item in self.children.values():
item.attr... | python | def select_by_key(self, key):
"""Selects an item by its key.
Args:
key (str): The unique string identifier of the item that have to be selected.
"""
self._selected_key = None
self._selected_item = None
for item in self.children.values():
item.attr... | [
"def",
"select_by_key",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_selected_key",
"=",
"None",
"self",
".",
"_selected_item",
"=",
"None",
"for",
"item",
"in",
"self",
".",
"children",
".",
"values",
"(",
")",
":",
"item",
".",
"attributes",
"["... | Selects an item by its key.
Args:
key (str): The unique string identifier of the item that have to be selected. | [
"Selects",
"an",
"item",
"by",
"its",
"key",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2122-L2136 | train |
dddomodossola/remi | remi/gui.py | ListView.select_by_value | def select_by_value(self, value):
"""Selects an item by the text content of the child.
Args:
value (str): Text content of the item that have to be selected.
"""
self._selected_key = None
self._selected_item = None
for k in self.children:
item = se... | python | def select_by_value(self, value):
"""Selects an item by the text content of the child.
Args:
value (str): Text content of the item that have to be selected.
"""
self._selected_key = None
self._selected_item = None
for k in self.children:
item = se... | [
"def",
"select_by_value",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_selected_key",
"=",
"None",
"self",
".",
"_selected_item",
"=",
"None",
"for",
"k",
"in",
"self",
".",
"children",
":",
"item",
"=",
"self",
".",
"children",
"[",
"k",
"]",
... | Selects an item by the text content of the child.
Args:
value (str): Text content of the item that have to be selected. | [
"Selects",
"an",
"item",
"by",
"the",
"text",
"content",
"of",
"the",
"child",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2141-L2155 | train |
dddomodossola/remi | remi/gui.py | DropDown.select_by_key | def select_by_key(self, key):
"""Selects an item by its unique string identifier.
Args:
key (str): Unique string identifier of the DropDownItem that have to be selected.
"""
for item in self.children.values():
if 'selected' in item.attributes:
del... | python | def select_by_key(self, key):
"""Selects an item by its unique string identifier.
Args:
key (str): Unique string identifier of the DropDownItem that have to be selected.
"""
for item in self.children.values():
if 'selected' in item.attributes:
del... | [
"def",
"select_by_key",
"(",
"self",
",",
"key",
")",
":",
"for",
"item",
"in",
"self",
".",
"children",
".",
"values",
"(",
")",
":",
"if",
"'selected'",
"in",
"item",
".",
"attributes",
":",
"del",
"item",
".",
"attributes",
"[",
"'selected'",
"]",
... | Selects an item by its unique string identifier.
Args:
key (str): Unique string identifier of the DropDownItem that have to be selected. | [
"Selects",
"an",
"item",
"by",
"its",
"unique",
"string",
"identifier",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2235-L2246 | train |
dddomodossola/remi | remi/gui.py | DropDown.select_by_value | def select_by_value(self, value):
"""Selects a DropDownItem by means of the contained text-
Args:
value (str): Textual content of the DropDownItem that have to be selected.
"""
self._selected_key = None
self._selected_item = None
for k in self.children:
... | python | def select_by_value(self, value):
"""Selects a DropDownItem by means of the contained text-
Args:
value (str): Textual content of the DropDownItem that have to be selected.
"""
self._selected_key = None
self._selected_item = None
for k in self.children:
... | [
"def",
"select_by_value",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_selected_key",
"=",
"None",
"self",
".",
"_selected_item",
"=",
"None",
"for",
"k",
"in",
"self",
".",
"children",
":",
"item",
"=",
"self",
".",
"children",
"[",
"k",
"]",
... | Selects a DropDownItem by means of the contained text-
Args:
value (str): Textual content of the DropDownItem that have to be selected. | [
"Selects",
"a",
"DropDownItem",
"by",
"means",
"of",
"the",
"contained",
"text",
"-"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2251-L2267 | train |
dddomodossola/remi | remi/gui.py | DropDown.onchange | def onchange(self, value):
"""Called when a new DropDownItem gets selected.
"""
log.debug('combo box. selected %s' % value)
self.select_by_value(value)
return (value, ) | python | def onchange(self, value):
"""Called when a new DropDownItem gets selected.
"""
log.debug('combo box. selected %s' % value)
self.select_by_value(value)
return (value, ) | [
"def",
"onchange",
"(",
"self",
",",
"value",
")",
":",
"log",
".",
"debug",
"(",
"'combo box. selected %s'",
"%",
"value",
")",
"self",
".",
"select_by_value",
"(",
"value",
")",
"return",
"(",
"value",
",",
")"
] | Called when a new DropDownItem gets selected. | [
"Called",
"when",
"a",
"new",
"DropDownItem",
"gets",
"selected",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2294-L2299 | train |
dddomodossola/remi | remi/gui.py | Table.append_from_list | def append_from_list(self, content, fill_title=False):
"""
Appends rows created from the data contained in the provided
list of tuples of strings. The first tuple of the list can be
set as table title.
Args:
content (list): list of tuples of strings. Each tuple is a ... | python | def append_from_list(self, content, fill_title=False):
"""
Appends rows created from the data contained in the provided
list of tuples of strings. The first tuple of the list can be
set as table title.
Args:
content (list): list of tuples of strings. Each tuple is a ... | [
"def",
"append_from_list",
"(",
"self",
",",
"content",
",",
"fill_title",
"=",
"False",
")",
":",
"row_index",
"=",
"0",
"for",
"row",
"in",
"content",
":",
"tr",
"=",
"TableRow",
"(",
")",
"column_index",
"=",
"0",
"for",
"item",
"in",
"row",
":",
... | Appends rows created from the data contained in the provided
list of tuples of strings. The first tuple of the list can be
set as table title.
Args:
content (list): list of tuples of strings. Each tuple is a row.
fill_title (bool): if true, the first tuple in the list wi... | [
"Appends",
"rows",
"created",
"from",
"the",
"data",
"contained",
"in",
"the",
"provided",
"list",
"of",
"tuples",
"of",
"strings",
".",
"The",
"first",
"tuple",
"of",
"the",
"list",
"can",
"be",
"set",
"as",
"table",
"title",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2377-L2400 | train |
dddomodossola/remi | remi/gui.py | TableWidget.item_at | def item_at(self, row, column):
"""Returns the TableItem instance at row, column cordinates
Args:
row (int): zero based index
column (int): zero based index
"""
return self.children[str(row)].children[str(column)] | python | def item_at(self, row, column):
"""Returns the TableItem instance at row, column cordinates
Args:
row (int): zero based index
column (int): zero based index
"""
return self.children[str(row)].children[str(column)] | [
"def",
"item_at",
"(",
"self",
",",
"row",
",",
"column",
")",
":",
"return",
"self",
".",
"children",
"[",
"str",
"(",
"row",
")",
"]",
".",
"children",
"[",
"str",
"(",
"column",
")",
"]"
] | Returns the TableItem instance at row, column cordinates
Args:
row (int): zero based index
column (int): zero based index | [
"Returns",
"the",
"TableItem",
"instance",
"at",
"row",
"column",
"cordinates"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2468-L2475 | train |
dddomodossola/remi | remi/gui.py | TableWidget.set_row_count | def set_row_count(self, count):
"""Sets the table row count.
Args:
count (int): number of rows
"""
current_row_count = self.row_count()
current_column_count = self.column_count()
if count > current_row_count:
cl = TableEditableItem if self._editab... | python | def set_row_count(self, count):
"""Sets the table row count.
Args:
count (int): number of rows
"""
current_row_count = self.row_count()
current_column_count = self.column_count()
if count > current_row_count:
cl = TableEditableItem if self._editab... | [
"def",
"set_row_count",
"(",
"self",
",",
"count",
")",
":",
"current_row_count",
"=",
"self",
".",
"row_count",
"(",
")",
"current_column_count",
"=",
"self",
".",
"column_count",
"(",
")",
"if",
"count",
">",
"current_row_count",
":",
"cl",
"=",
"TableEdit... | Sets the table row count.
Args:
count (int): number of rows | [
"Sets",
"the",
"table",
"row",
"count",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2500-L2521 | train |
dddomodossola/remi | remi/gui.py | TableWidget.set_column_count | def set_column_count(self, count):
"""Sets the table column count.
Args:
count (int): column of rows
"""
current_row_count = self.row_count()
current_column_count = self.column_count()
if count > current_column_count:
cl = TableEditableItem if sel... | python | def set_column_count(self, count):
"""Sets the table column count.
Args:
count (int): column of rows
"""
current_row_count = self.row_count()
current_column_count = self.column_count()
if count > current_column_count:
cl = TableEditableItem if sel... | [
"def",
"set_column_count",
"(",
"self",
",",
"count",
")",
":",
"current_row_count",
"=",
"self",
".",
"row_count",
"(",
")",
"current_column_count",
"=",
"self",
".",
"column_count",
"(",
")",
"if",
"count",
">",
"current_column_count",
":",
"cl",
"=",
"Tab... | Sets the table column count.
Args:
count (int): column of rows | [
"Sets",
"the",
"table",
"column",
"count",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2523-L2545 | train |
dddomodossola/remi | remi/gui.py | TableWidget.on_item_changed | def on_item_changed(self, item, new_value, row, column):
"""Event for the item change.
Args:
emitter (TableWidget): The emitter of the event.
item (TableItem): The TableItem instance.
new_value (str): New text content.
row (int): row index.
co... | python | def on_item_changed(self, item, new_value, row, column):
"""Event for the item change.
Args:
emitter (TableWidget): The emitter of the event.
item (TableItem): The TableItem instance.
new_value (str): New text content.
row (int): row index.
co... | [
"def",
"on_item_changed",
"(",
"self",
",",
"item",
",",
"new_value",
",",
"row",
",",
"column",
")",
":",
"return",
"(",
"item",
",",
"new_value",
",",
"row",
",",
"column",
")"
] | Event for the item change.
Args:
emitter (TableWidget): The emitter of the event.
item (TableItem): The TableItem instance.
new_value (str): New text content.
row (int): row index.
column (int): column index. | [
"Event",
"for",
"the",
"item",
"change",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2549-L2559 | train |
dddomodossola/remi | remi/gui.py | Svg.set_viewbox | def set_viewbox(self, x, y, w, h):
"""Sets the origin and size of the viewbox, describing a virtual view area.
Args:
x (int): x coordinate of the viewbox origin
y (int): y coordinate of the viewbox origin
w (int): width of the viewbox
h (int): height of t... | python | def set_viewbox(self, x, y, w, h):
"""Sets the origin and size of the viewbox, describing a virtual view area.
Args:
x (int): x coordinate of the viewbox origin
y (int): y coordinate of the viewbox origin
w (int): width of the viewbox
h (int): height of t... | [
"def",
"set_viewbox",
"(",
"self",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
":",
"self",
".",
"attributes",
"[",
"'viewBox'",
"]",
"=",
"\"%s %s %s %s\"",
"%",
"(",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"self",
".",
"attributes",
"[",
"'p... | Sets the origin and size of the viewbox, describing a virtual view area.
Args:
x (int): x coordinate of the viewbox origin
y (int): y coordinate of the viewbox origin
w (int): width of the viewbox
h (int): height of the viewbox | [
"Sets",
"the",
"origin",
"and",
"size",
"of",
"the",
"viewbox",
"describing",
"a",
"virtual",
"view",
"area",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L3396-L3406 | train |
dddomodossola/remi | remi/gui.py | SvgShape.set_position | def set_position(self, x, y):
"""Sets the shape position.
Args:
x (int): the x coordinate
y (int): the y coordinate
"""
self.attributes['x'] = str(x)
self.attributes['y'] = str(y) | python | def set_position(self, x, y):
"""Sets the shape position.
Args:
x (int): the x coordinate
y (int): the y coordinate
"""
self.attributes['x'] = str(x)
self.attributes['y'] = str(y) | [
"def",
"set_position",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"self",
".",
"attributes",
"[",
"'x'",
"]",
"=",
"str",
"(",
"x",
")",
"self",
".",
"attributes",
"[",
"'y'",
"]",
"=",
"str",
"(",
"y",
")"
] | Sets the shape position.
Args:
x (int): the x coordinate
y (int): the y coordinate | [
"Sets",
"the",
"shape",
"position",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L3423-L3431 | train |
dddomodossola/remi | remi/gui.py | SvgRectangle.set_size | def set_size(self, w, h):
""" Sets the rectangle size.
Args:
w (int): width of the rectangle
h (int): height of the rectangle
"""
self.attributes['width'] = str(w)
self.attributes['height'] = str(h) | python | def set_size(self, w, h):
""" Sets the rectangle size.
Args:
w (int): width of the rectangle
h (int): height of the rectangle
"""
self.attributes['width'] = str(w)
self.attributes['height'] = str(h) | [
"def",
"set_size",
"(",
"self",
",",
"w",
",",
"h",
")",
":",
"self",
".",
"attributes",
"[",
"'width'",
"]",
"=",
"str",
"(",
"w",
")",
"self",
".",
"attributes",
"[",
"'height'",
"]",
"=",
"str",
"(",
"h",
")"
] | Sets the rectangle size.
Args:
w (int): width of the rectangle
h (int): height of the rectangle | [
"Sets",
"the",
"rectangle",
"size",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L3478-L3486 | train |
dddomodossola/remi | remi/server.py | start | def start(main_gui_class, **kwargs):
"""This method starts the webserver with a specific App subclass."""
debug = kwargs.pop('debug', False)
standalone = kwargs.pop('standalone', False)
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO,
format='%(name)-16s %(lev... | python | def start(main_gui_class, **kwargs):
"""This method starts the webserver with a specific App subclass."""
debug = kwargs.pop('debug', False)
standalone = kwargs.pop('standalone', False)
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO,
format='%(name)-16s %(lev... | [
"def",
"start",
"(",
"main_gui_class",
",",
"*",
"*",
"kwargs",
")",
":",
"debug",
"=",
"kwargs",
".",
"pop",
"(",
"'debug'",
",",
"False",
")",
"standalone",
"=",
"kwargs",
".",
"pop",
"(",
"'standalone'",
",",
"False",
")",
"logging",
".",
"basicConf... | This method starts the webserver with a specific App subclass. | [
"This",
"method",
"starts",
"the",
"webserver",
"with",
"a",
"specific",
"App",
"subclass",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/server.py#L877-L890 | train |
dddomodossola/remi | remi/server.py | App._instance | def _instance(self):
global clients
global runtimeInstances
"""
This method is used to get the Application instance previously created
managing on this, it is possible to switch to "single instance for
multiple clients" or "multiple instance for multiple clients" executio... | python | def _instance(self):
global clients
global runtimeInstances
"""
This method is used to get the Application instance previously created
managing on this, it is possible to switch to "single instance for
multiple clients" or "multiple instance for multiple clients" executio... | [
"def",
"_instance",
"(",
"self",
")",
":",
"global",
"clients",
"global",
"runtimeInstances",
"self",
".",
"session",
"=",
"0",
"#checking previously defined session",
"if",
"'cookie'",
"in",
"self",
".",
"headers",
":",
"self",
".",
"session",
"=",
"parse_sessi... | This method is used to get the Application instance previously created
managing on this, it is possible to switch to "single instance for
multiple clients" or "multiple instance for multiple clients" execution way | [
"This",
"method",
"is",
"used",
"to",
"get",
"the",
"Application",
"instance",
"previously",
"created",
"managing",
"on",
"this",
"it",
"is",
"possible",
"to",
"switch",
"to",
"single",
"instance",
"for",
"multiple",
"clients",
"or",
"multiple",
"instance",
"f... | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/server.py#L318-L397 | train |
dddomodossola/remi | remi/server.py | App.do_gui_update | def do_gui_update(self):
""" This method gets called also by Timer, a new thread, and so needs to lock the update
"""
with self.update_lock:
changed_widget_dict = {}
self.root.repr(changed_widget_dict)
for widget in changed_widget_dict.keys():
... | python | def do_gui_update(self):
""" This method gets called also by Timer, a new thread, and so needs to lock the update
"""
with self.update_lock:
changed_widget_dict = {}
self.root.repr(changed_widget_dict)
for widget in changed_widget_dict.keys():
... | [
"def",
"do_gui_update",
"(",
"self",
")",
":",
"with",
"self",
".",
"update_lock",
":",
"changed_widget_dict",
"=",
"{",
"}",
"self",
".",
"root",
".",
"repr",
"(",
"changed_widget_dict",
")",
"for",
"widget",
"in",
"changed_widget_dict",
".",
"keys",
"(",
... | This method gets called also by Timer, a new thread, and so needs to lock the update | [
"This",
"method",
"gets",
"called",
"also",
"by",
"Timer",
"a",
"new",
"thread",
"and",
"so",
"needs",
"to",
"lock",
"the",
"update"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/server.py#L436-L446 | train |
dddomodossola/remi | remi/server.py | App.do_GET | def do_GET(self):
# check here request header to identify the type of req, if http or ws
# if this is a ws req, instance a ws handler, add it to App's ws list, return
if "Upgrade" in self.headers:
if self.headers['Upgrade'] == 'websocket':
#passing arguments to websoc... | python | def do_GET(self):
# check here request header to identify the type of req, if http or ws
# if this is a ws req, instance a ws handler, add it to App's ws list, return
if "Upgrade" in self.headers:
if self.headers['Upgrade'] == 'websocket':
#passing arguments to websoc... | [
"def",
"do_GET",
"(",
"self",
")",
":",
"# check here request header to identify the type of req, if http or ws",
"# if this is a ws req, instance a ws handler, add it to App's ws list, return",
"if",
"\"Upgrade\"",
"in",
"self",
".",
"headers",
":",
"if",
"self",
".",
"headers",... | Handler for the GET requests. | [
"Handler",
"for",
"the",
"GET",
"requests",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/server.py#L551-L590 | train |
dddomodossola/remi | remi/server.py | App.on_close | def on_close(self):
""" Called by the server when the App have to be terminated
"""
self._stop_update_flag = True
for ws in self.websockets:
ws.close() | python | def on_close(self):
""" Called by the server when the App have to be terminated
"""
self._stop_update_flag = True
for ws in self.websockets:
ws.close() | [
"def",
"on_close",
"(",
"self",
")",
":",
"self",
".",
"_stop_update_flag",
"=",
"True",
"for",
"ws",
"in",
"self",
".",
"websockets",
":",
"ws",
".",
"close",
"(",
")"
] | Called by the server when the App have to be terminated | [
"Called",
"by",
"the",
"server",
"when",
"the",
"App",
"have",
"to",
"be",
"terminated"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/server.py#L680-L685 | train |
dddomodossola/remi | editor/editor_widgets.py | SignalConnectionManager.update | def update(self, widget, widget_tree):
""" for the selected widget are listed the relative signals
for each signal there is a dropdown containing all the widgets
the user will select the widget that have to listen a specific event
"""
self.listeners_list = []
self... | python | def update(self, widget, widget_tree):
""" for the selected widget are listed the relative signals
for each signal there is a dropdown containing all the widgets
the user will select the widget that have to listen a specific event
"""
self.listeners_list = []
self... | [
"def",
"update",
"(",
"self",
",",
"widget",
",",
"widget_tree",
")",
":",
"self",
".",
"listeners_list",
"=",
"[",
"]",
"self",
".",
"build_widget_list_from_tree",
"(",
"widget_tree",
")",
"self",
".",
"label",
".",
"set_text",
"(",
"'Signal connections: '",
... | for the selected widget are listed the relative signals
for each signal there is a dropdown containing all the widgets
the user will select the widget that have to listen a specific event | [
"for",
"the",
"selected",
"widget",
"are",
"listed",
"the",
"relative",
"signals",
"for",
"each",
"signal",
"there",
"is",
"a",
"dropdown",
"containing",
"all",
"the",
"widgets",
"the",
"user",
"will",
"select",
"the",
"widget",
"that",
"have",
"to",
"listen... | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/editor/editor_widgets.py#L183-L206 | train |
dddomodossola/remi | editor/editor_widgets.py | ProjectConfigurationDialog.confirm_dialog | def confirm_dialog(self, emitter):
"""event called pressing on OK button.
"""
#here the user input is transferred to the dict, ready to use
self.from_fields_to_dict()
return super(ProjectConfigurationDialog,self).confirm_dialog(self) | python | def confirm_dialog(self, emitter):
"""event called pressing on OK button.
"""
#here the user input is transferred to the dict, ready to use
self.from_fields_to_dict()
return super(ProjectConfigurationDialog,self).confirm_dialog(self) | [
"def",
"confirm_dialog",
"(",
"self",
",",
"emitter",
")",
":",
"#here the user input is transferred to the dict, ready to use",
"self",
".",
"from_fields_to_dict",
"(",
")",
"return",
"super",
"(",
"ProjectConfigurationDialog",
",",
"self",
")",
".",
"confirm_dialog",
... | event called pressing on OK button. | [
"event",
"called",
"pressing",
"on",
"OK",
"button",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/editor/editor_widgets.py#L256-L261 | train |
dddomodossola/remi | editor/editor_widgets.py | ProjectConfigurationDialog.show | def show(self, baseAppInstance):
"""Allows to show the widget as root window"""
self.from_dict_to_fields(self.configDict)
super(ProjectConfigurationDialog, self).show(baseAppInstance) | python | def show(self, baseAppInstance):
"""Allows to show the widget as root window"""
self.from_dict_to_fields(self.configDict)
super(ProjectConfigurationDialog, self).show(baseAppInstance) | [
"def",
"show",
"(",
"self",
",",
"baseAppInstance",
")",
":",
"self",
".",
"from_dict_to_fields",
"(",
"self",
".",
"configDict",
")",
"super",
"(",
"ProjectConfigurationDialog",
",",
"self",
")",
".",
"show",
"(",
"baseAppInstance",
")"
] | Allows to show the widget as root window | [
"Allows",
"to",
"show",
"the",
"widget",
"as",
"root",
"window"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/editor/editor_widgets.py#L263-L266 | train |
dddomodossola/remi | editor/editor_widgets.py | CssSizeInput.set_value | def set_value(self, value):
"""The value have to be in the form '10px' or '10%', so numeric value plus measure unit
"""
v = 0
measure_unit = 'px'
try:
v = int(float(value.replace('px', '')))
except ValueError:
try:
v = int(float(val... | python | def set_value(self, value):
"""The value have to be in the form '10px' or '10%', so numeric value plus measure unit
"""
v = 0
measure_unit = 'px'
try:
v = int(float(value.replace('px', '')))
except ValueError:
try:
v = int(float(val... | [
"def",
"set_value",
"(",
"self",
",",
"value",
")",
":",
"v",
"=",
"0",
"measure_unit",
"=",
"'px'",
"try",
":",
"v",
"=",
"int",
"(",
"float",
"(",
"value",
".",
"replace",
"(",
"'px'",
",",
"''",
")",
")",
")",
"except",
"ValueError",
":",
"try... | The value have to be in the form '10px' or '10%', so numeric value plus measure unit | [
"The",
"value",
"have",
"to",
"be",
"in",
"the",
"form",
"10px",
"or",
"10%",
"so",
"numeric",
"value",
"plus",
"measure",
"unit"
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/editor/editor_widgets.py#L629-L643 | train |
dddomodossola/remi | examples/examples_from_contributors/remi_ext.py | SingleRowSelectionTable.on_table_row_click | def on_table_row_click(self, row, item):
''' Highlight selected row.'''
if hasattr(self, "last_clicked_row"):
del self.last_clicked_row.style['outline']
self.last_clicked_row = row
self.last_clicked_row.style['outline'] = "2px dotted blue"
return (row, item) | python | def on_table_row_click(self, row, item):
''' Highlight selected row.'''
if hasattr(self, "last_clicked_row"):
del self.last_clicked_row.style['outline']
self.last_clicked_row = row
self.last_clicked_row.style['outline'] = "2px dotted blue"
return (row, item) | [
"def",
"on_table_row_click",
"(",
"self",
",",
"row",
",",
"item",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"last_clicked_row\"",
")",
":",
"del",
"self",
".",
"last_clicked_row",
".",
"style",
"[",
"'outline'",
"]",
"self",
".",
"last_clicked_row",
... | Highlight selected row. | [
"Highlight",
"selected",
"row",
"."
] | 85206f62220662bb7ecd471042268def71ccad28 | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/examples_from_contributors/remi_ext.py#L11-L17 | train |
RaRe-Technologies/smart_open | smart_open/doctools.py | extract_kwargs | def extract_kwargs(docstring):
"""Extract keyword argument documentation from a function's docstring.
Parameters
----------
docstring: str
The docstring to extract keyword arguments from.
Returns
-------
list of (str, str, list str)
str
The name of the keyword argument... | python | def extract_kwargs(docstring):
"""Extract keyword argument documentation from a function's docstring.
Parameters
----------
docstring: str
The docstring to extract keyword arguments from.
Returns
-------
list of (str, str, list str)
str
The name of the keyword argument... | [
"def",
"extract_kwargs",
"(",
"docstring",
")",
":",
"lines",
"=",
"inspect",
".",
"cleandoc",
"(",
"docstring",
")",
".",
"split",
"(",
"'\\n'",
")",
"retval",
"=",
"[",
"]",
"#",
"# 1. Find the underlined 'Parameters' section",
"# 2. Once there, continue parsing p... | Extract keyword argument documentation from a function's docstring.
Parameters
----------
docstring: str
The docstring to extract keyword arguments from.
Returns
-------
list of (str, str, list str)
str
The name of the keyword argument.
str
Its type.
str
... | [
"Extract",
"keyword",
"argument",
"documentation",
"from",
"a",
"function",
"s",
"docstring",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/doctools.py#L20-L86 | train |
RaRe-Technologies/smart_open | smart_open/doctools.py | to_docstring | def to_docstring(kwargs, lpad=''):
"""Reconstruct a docstring from keyword argument info.
Basically reverses :func:`extract_kwargs`.
Parameters
----------
kwargs: list
Output from the extract_kwargs function
lpad: str, optional
Padding string (from the left).
Returns
-... | python | def to_docstring(kwargs, lpad=''):
"""Reconstruct a docstring from keyword argument info.
Basically reverses :func:`extract_kwargs`.
Parameters
----------
kwargs: list
Output from the extract_kwargs function
lpad: str, optional
Padding string (from the left).
Returns
-... | [
"def",
"to_docstring",
"(",
"kwargs",
",",
"lpad",
"=",
"''",
")",
":",
"buf",
"=",
"io",
".",
"StringIO",
"(",
")",
"for",
"name",
",",
"type_",
",",
"description",
"in",
"kwargs",
":",
"buf",
".",
"write",
"(",
"'%s%s: %s\\n'",
"%",
"(",
"lpad",
... | Reconstruct a docstring from keyword argument info.
Basically reverses :func:`extract_kwargs`.
Parameters
----------
kwargs: list
Output from the extract_kwargs function
lpad: str, optional
Padding string (from the left).
Returns
-------
str
The docstring snipp... | [
"Reconstruct",
"a",
"docstring",
"from",
"keyword",
"argument",
"info",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/doctools.py#L89-L125 | train |
RaRe-Technologies/smart_open | smart_open/doctools.py | extract_examples_from_readme_rst | def extract_examples_from_readme_rst(indent=' '):
"""Extract examples from this project's README.rst file.
Parameters
----------
indent: str
Prepend each line with this string. Should contain some number of spaces.
Returns
-------
str
The examples.
Notes
-----
... | python | def extract_examples_from_readme_rst(indent=' '):
"""Extract examples from this project's README.rst file.
Parameters
----------
indent: str
Prepend each line with this string. Should contain some number of spaces.
Returns
-------
str
The examples.
Notes
-----
... | [
"def",
"extract_examples_from_readme_rst",
"(",
"indent",
"=",
"' '",
")",
":",
"curr_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
"readme_path",
"=",
"os",
".",
"path",
".",
"join",
... | Extract examples from this project's README.rst file.
Parameters
----------
indent: str
Prepend each line with this string. Should contain some number of spaces.
Returns
-------
str
The examples.
Notes
-----
Quite fragile, depends on named labels inside the README... | [
"Extract",
"examples",
"from",
"this",
"project",
"s",
"README",
".",
"rst",
"file",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/doctools.py#L128-L155 | train |
RaRe-Technologies/smart_open | smart_open/s3.py | open | def open(
bucket_id,
key_id,
mode,
buffer_size=DEFAULT_BUFFER_SIZE,
min_part_size=DEFAULT_MIN_PART_SIZE,
session=None,
resource_kwargs=None,
multipart_upload_kwargs=None,
):
"""Open an S3 object for reading or writing.
Parameters
-----... | python | def open(
bucket_id,
key_id,
mode,
buffer_size=DEFAULT_BUFFER_SIZE,
min_part_size=DEFAULT_MIN_PART_SIZE,
session=None,
resource_kwargs=None,
multipart_upload_kwargs=None,
):
"""Open an S3 object for reading or writing.
Parameters
-----... | [
"def",
"open",
"(",
"bucket_id",
",",
"key_id",
",",
"mode",
",",
"buffer_size",
"=",
"DEFAULT_BUFFER_SIZE",
",",
"min_part_size",
"=",
"DEFAULT_MIN_PART_SIZE",
",",
"session",
"=",
"None",
",",
"resource_kwargs",
"=",
"None",
",",
"multipart_upload_kwargs",
"=",
... | Open an S3 object for reading or writing.
Parameters
----------
bucket_id: str
The name of the bucket this object resides in.
key_id: str
The name of the key within the bucket.
mode: str
The mode for opening the object. Must be either "rb" or "wb".
buffer_size: int, opt... | [
"Open",
"an",
"S3",
"object",
"for",
"reading",
"or",
"writing",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/s3.py#L69-L131 | train |
RaRe-Technologies/smart_open | smart_open/s3.py | BufferedInputBase.read | def read(self, size=-1):
"""Read up to size bytes from the object and return them."""
if size == 0:
return b''
elif size < 0:
from_buf = self._read_from_buffer()
self._current_pos = self._content_length
return from_buf + self._raw_reader.read()
... | python | def read(self, size=-1):
"""Read up to size bytes from the object and return them."""
if size == 0:
return b''
elif size < 0:
from_buf = self._read_from_buffer()
self._current_pos = self._content_length
return from_buf + self._raw_reader.read()
... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"size",
"==",
"0",
":",
"return",
"b''",
"elif",
"size",
"<",
"0",
":",
"from_buf",
"=",
"self",
".",
"_read_from_buffer",
"(",
")",
"self",
".",
"_current_pos",
"=",
"self",
... | Read up to size bytes from the object and return them. | [
"Read",
"up",
"to",
"size",
"bytes",
"from",
"the",
"object",
"and",
"return",
"them",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/s3.py#L240-L266 | train |
RaRe-Technologies/smart_open | smart_open/s3.py | BufferedInputBase.readline | def readline(self, limit=-1):
"""Read up to and including the next newline. Returns the bytes read."""
if limit != -1:
raise NotImplementedError('limits other than -1 not implemented yet')
the_line = io.BytesIO()
while not (self._eof and len(self._buffer) == 0):
... | python | def readline(self, limit=-1):
"""Read up to and including the next newline. Returns the bytes read."""
if limit != -1:
raise NotImplementedError('limits other than -1 not implemented yet')
the_line = io.BytesIO()
while not (self._eof and len(self._buffer) == 0):
... | [
"def",
"readline",
"(",
"self",
",",
"limit",
"=",
"-",
"1",
")",
":",
"if",
"limit",
"!=",
"-",
"1",
":",
"raise",
"NotImplementedError",
"(",
"'limits other than -1 not implemented yet'",
")",
"the_line",
"=",
"io",
".",
"BytesIO",
"(",
")",
"while",
"no... | Read up to and including the next newline. Returns the bytes read. | [
"Read",
"up",
"to",
"and",
"including",
"the",
"next",
"newline",
".",
"Returns",
"the",
"bytes",
"read",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/s3.py#L281-L302 | train |
RaRe-Technologies/smart_open | smart_open/s3.py | BufferedInputBase._read_from_buffer | def _read_from_buffer(self, size=-1):
"""Remove at most size bytes from our buffer and return them."""
# logger.debug('reading %r bytes from %r byte-long buffer', size, len(self._buffer))
size = size if size >= 0 else len(self._buffer)
part = self._buffer.read(size)
self._current... | python | def _read_from_buffer(self, size=-1):
"""Remove at most size bytes from our buffer and return them."""
# logger.debug('reading %r bytes from %r byte-long buffer', size, len(self._buffer))
size = size if size >= 0 else len(self._buffer)
part = self._buffer.read(size)
self._current... | [
"def",
"_read_from_buffer",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"# logger.debug('reading %r bytes from %r byte-long buffer', size, len(self._buffer))",
"size",
"=",
"size",
"if",
"size",
">=",
"0",
"else",
"len",
"(",
"self",
".",
"_buffer",
")",
"p... | Remove at most size bytes from our buffer and return them. | [
"Remove",
"at",
"most",
"size",
"bytes",
"from",
"our",
"buffer",
"and",
"return",
"them",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/s3.py#L311-L318 | train |
RaRe-Technologies/smart_open | smart_open/ssh.py | open | def open(path, mode='r', host=None, user=None, port=DEFAULT_PORT):
"""Open a file on a remote machine over SSH.
Expects authentication to be already set up via existing keys on the local machine.
Parameters
----------
path: str
The path to the file to open on the remote machine.
mode: ... | python | def open(path, mode='r', host=None, user=None, port=DEFAULT_PORT):
"""Open a file on a remote machine over SSH.
Expects authentication to be already set up via existing keys on the local machine.
Parameters
----------
path: str
The path to the file to open on the remote machine.
mode: ... | [
"def",
"open",
"(",
"path",
",",
"mode",
"=",
"'r'",
",",
"host",
"=",
"None",
",",
"user",
"=",
"None",
",",
"port",
"=",
"DEFAULT_PORT",
")",
":",
"if",
"not",
"host",
":",
"raise",
"ValueError",
"(",
"'you must specify the host to connect to'",
")",
"... | Open a file on a remote machine over SSH.
Expects authentication to be already set up via existing keys on the local machine.
Parameters
----------
path: str
The path to the file to open on the remote machine.
mode: str, optional
The mode to use for opening the file.
host: str,... | [
"Open",
"a",
"file",
"on",
"a",
"remote",
"machine",
"over",
"SSH",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/ssh.py#L62-L97 | train |
RaRe-Technologies/smart_open | smart_open/http.py | open | def open(uri, mode, kerberos=False, user=None, password=None):
"""Implement streamed reader from a web site.
Supports Kerberos and Basic HTTP authentication.
Parameters
----------
url: str
The URL to open.
mode: str
The mode to open using.
kerberos: boolean, optional
... | python | def open(uri, mode, kerberos=False, user=None, password=None):
"""Implement streamed reader from a web site.
Supports Kerberos and Basic HTTP authentication.
Parameters
----------
url: str
The URL to open.
mode: str
The mode to open using.
kerberos: boolean, optional
... | [
"def",
"open",
"(",
"uri",
",",
"mode",
",",
"kerberos",
"=",
"False",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"if",
"mode",
"==",
"'rb'",
":",
"return",
"BufferedInputBase",
"(",
"uri",
",",
"mode",
",",
"kerberos",
"=",
... | Implement streamed reader from a web site.
Supports Kerberos and Basic HTTP authentication.
Parameters
----------
url: str
The URL to open.
mode: str
The mode to open using.
kerberos: boolean, optional
If True, will attempt to use the local Kerberos credentials
user... | [
"Implement",
"streamed",
"reader",
"from",
"a",
"web",
"site",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/http.py#L25-L51 | train |
RaRe-Technologies/smart_open | smart_open/http.py | BufferedInputBase.read | def read(self, size=-1):
"""
Mimics the read call to a filehandle object.
"""
logger.debug("reading with size: %d", size)
if self.response is None:
return b''
if size == 0:
return b''
elif size < 0 and len(self._read_buffer) == 0:
... | python | def read(self, size=-1):
"""
Mimics the read call to a filehandle object.
"""
logger.debug("reading with size: %d", size)
if self.response is None:
return b''
if size == 0:
return b''
elif size < 0 and len(self._read_buffer) == 0:
... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"logger",
".",
"debug",
"(",
"\"reading with size: %d\"",
",",
"size",
")",
"if",
"self",
".",
"response",
"is",
"None",
":",
"return",
"b''",
"if",
"size",
"==",
"0",
":",
"return",
... | Mimics the read call to a filehandle object. | [
"Mimics",
"the",
"read",
"call",
"to",
"a",
"filehandle",
"object",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/http.py#L104-L134 | train |
RaRe-Technologies/smart_open | smart_open/bytebuffer.py | ByteBuffer.read | def read(self, size=-1):
"""Read bytes from the buffer and advance the read position. Returns
the bytes in a bytestring.
Parameters
----------
size: int, optional
Maximum number of bytes to read. If negative or not supplied, read
all unread bytes in the b... | python | def read(self, size=-1):
"""Read bytes from the buffer and advance the read position. Returns
the bytes in a bytestring.
Parameters
----------
size: int, optional
Maximum number of bytes to read. If negative or not supplied, read
all unread bytes in the b... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"part",
"=",
"self",
".",
"peek",
"(",
"size",
")",
"self",
".",
"_pos",
"+=",
"len",
"(",
"part",
")",
"return",
"part"
] | Read bytes from the buffer and advance the read position. Returns
the bytes in a bytestring.
Parameters
----------
size: int, optional
Maximum number of bytes to read. If negative or not supplied, read
all unread bytes in the buffer.
Returns
----... | [
"Read",
"bytes",
"from",
"the",
"buffer",
"and",
"advance",
"the",
"read",
"position",
".",
"Returns",
"the",
"bytes",
"in",
"a",
"bytestring",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/bytebuffer.py#L67-L83 | train |
RaRe-Technologies/smart_open | smart_open/bytebuffer.py | ByteBuffer.peek | def peek(self, size=-1):
"""Get bytes from the buffer without advancing the read position.
Returns the bytes in a bytestring.
Parameters
----------
size: int, optional
Maximum number of bytes to return. If negative or not supplied,
return all unread bytes... | python | def peek(self, size=-1):
"""Get bytes from the buffer without advancing the read position.
Returns the bytes in a bytestring.
Parameters
----------
size: int, optional
Maximum number of bytes to return. If negative or not supplied,
return all unread bytes... | [
"def",
"peek",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"size",
"<",
"0",
"or",
"size",
">",
"len",
"(",
"self",
")",
":",
"size",
"=",
"len",
"(",
"self",
")",
"part",
"=",
"self",
".",
"_bytes",
"[",
"self",
".",
"_pos",
"... | Get bytes from the buffer without advancing the read position.
Returns the bytes in a bytestring.
Parameters
----------
size: int, optional
Maximum number of bytes to return. If negative or not supplied,
return all unread bytes in the buffer.
Returns
... | [
"Get",
"bytes",
"from",
"the",
"buffer",
"without",
"advancing",
"the",
"read",
"position",
".",
"Returns",
"the",
"bytes",
"in",
"a",
"bytestring",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/bytebuffer.py#L85-L103 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | register_compressor | def register_compressor(ext, callback):
"""Register a callback for transparently decompressing files with a specific extension.
Parameters
----------
ext: str
The extension.
callback: callable
The callback. It must accept two position arguments, file_obj and mode.
Examples
... | python | def register_compressor(ext, callback):
"""Register a callback for transparently decompressing files with a specific extension.
Parameters
----------
ext: str
The extension.
callback: callable
The callback. It must accept two position arguments, file_obj and mode.
Examples
... | [
"def",
"register_compressor",
"(",
"ext",
",",
"callback",
")",
":",
"if",
"not",
"(",
"ext",
"and",
"ext",
"[",
"0",
"]",
"==",
"'.'",
")",
":",
"raise",
"ValueError",
"(",
"'ext must be a string starting with ., not %r'",
"%",
"ext",
")",
"if",
"ext",
"i... | Register a callback for transparently decompressing files with a specific extension.
Parameters
----------
ext: str
The extension.
callback: callable
The callback. It must accept two position arguments, file_obj and mode.
Examples
--------
Instruct smart_open to use the i... | [
"Register",
"a",
"callback",
"for",
"transparently",
"decompressing",
"files",
"with",
"a",
"specific",
"extension",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L70-L97 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | _check_kwargs | def _check_kwargs(kallable, kwargs):
"""Check which keyword arguments the callable supports.
Parameters
----------
kallable: callable
A function or method to test
kwargs: dict
The keyword arguments to check. If the callable doesn't support any
of these, a warning message wi... | python | def _check_kwargs(kallable, kwargs):
"""Check which keyword arguments the callable supports.
Parameters
----------
kallable: callable
A function or method to test
kwargs: dict
The keyword arguments to check. If the callable doesn't support any
of these, a warning message wi... | [
"def",
"_check_kwargs",
"(",
"kallable",
",",
"kwargs",
")",
":",
"supported_keywords",
"=",
"sorted",
"(",
"_inspect_kwargs",
"(",
"kallable",
")",
")",
"unsupported_keywords",
"=",
"[",
"k",
"for",
"k",
"in",
"sorted",
"(",
"kwargs",
")",
"if",
"k",
"not... | Check which keyword arguments the callable supports.
Parameters
----------
kallable: callable
A function or method to test
kwargs: dict
The keyword arguments to check. If the callable doesn't support any
of these, a warning message will get printed.
Returns
-------
... | [
"Check",
"which",
"keyword",
"arguments",
"the",
"callable",
"supports",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L172-L195 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | open | def open(
uri,
mode='r',
buffering=-1,
encoding=None,
errors=None,
newline=None,
closefd=True,
opener=None,
ignore_ext=False,
transport_params=None,
):
r"""Open the URI object, returning a file-like object.
The URI is usual... | python | def open(
uri,
mode='r',
buffering=-1,
encoding=None,
errors=None,
newline=None,
closefd=True,
opener=None,
ignore_ext=False,
transport_params=None,
):
r"""Open the URI object, returning a file-like object.
The URI is usual... | [
"def",
"open",
"(",
"uri",
",",
"mode",
"=",
"'r'",
",",
"buffering",
"=",
"-",
"1",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
",",
"closefd",
"=",
"True",
",",
"opener",
"=",
"None",
",",
"ignore_ext",
... | r"""Open the URI object, returning a file-like object.
The URI is usually a string in a variety of formats:
1. a URI for the local filesystem: `./lines.txt`, `/home/joe/lines.txt.gz`, `file:///home/joe/lines.txt.bz2`
2. a URI for HDFS: `hdfs:///some/path/lines.txt`
3. a URI for Amazon's S3 (can also s... | [
"r",
"Open",
"the",
"URI",
"object",
"returning",
"a",
"file",
"-",
"like",
"object",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L201-L359 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | smart_open | def smart_open(uri, mode="rb", **kw):
"""Deprecated, use smart_open.open instead."""
logger.warning('this function is deprecated, use smart_open.open instead')
#
# The new function uses a shorter name for this parameter, handle it separately.
#
ignore_extension = kw.pop('ignore_extension', Fals... | python | def smart_open(uri, mode="rb", **kw):
"""Deprecated, use smart_open.open instead."""
logger.warning('this function is deprecated, use smart_open.open instead')
#
# The new function uses a shorter name for this parameter, handle it separately.
#
ignore_extension = kw.pop('ignore_extension', Fals... | [
"def",
"smart_open",
"(",
"uri",
",",
"mode",
"=",
"\"rb\"",
",",
"*",
"*",
"kw",
")",
":",
"logger",
".",
"warning",
"(",
"'this function is deprecated, use smart_open.open instead'",
")",
"#",
"# The new function uses a shorter name for this parameter, handle it separatel... | Deprecated, use smart_open.open instead. | [
"Deprecated",
"use",
"smart_open",
".",
"open",
"instead",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L383-L439 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | _shortcut_open | def _shortcut_open(
uri,
mode,
ignore_ext=False,
buffering=-1,
encoding=None,
errors=None,
):
"""Try to open the URI using the standard library io.open function.
This can be much faster than the alternative of opening in binary mode and
then decoding.... | python | def _shortcut_open(
uri,
mode,
ignore_ext=False,
buffering=-1,
encoding=None,
errors=None,
):
"""Try to open the URI using the standard library io.open function.
This can be much faster than the alternative of opening in binary mode and
then decoding.... | [
"def",
"_shortcut_open",
"(",
"uri",
",",
"mode",
",",
"ignore_ext",
"=",
"False",
",",
"buffering",
"=",
"-",
"1",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
")",
":",
"if",
"not",
"isinstance",
"(",
"uri",
",",
"six",
".",
"st... | Try to open the URI using the standard library io.open function.
This can be much faster than the alternative of opening in binary mode and
then decoding.
This is only possible under the following conditions:
1. Opening a local file
2. Ignore extension is set to True
If it is not pos... | [
"Try",
"to",
"open",
"the",
"URI",
"using",
"the",
"standard",
"library",
"io",
".",
"open",
"function",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L442-L501 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | _open_binary_stream | def _open_binary_stream(uri, mode, transport_params):
"""Open an arbitrary URI in the specified binary mode.
Not all modes are supported for all protocols.
:arg uri: The URI to open. May be a string, or something else.
:arg str mode: The mode to open with. Must be rb, wb or ab.
:arg transport_pa... | python | def _open_binary_stream(uri, mode, transport_params):
"""Open an arbitrary URI in the specified binary mode.
Not all modes are supported for all protocols.
:arg uri: The URI to open. May be a string, or something else.
:arg str mode: The mode to open with. Must be rb, wb or ab.
:arg transport_pa... | [
"def",
"_open_binary_stream",
"(",
"uri",
",",
"mode",
",",
"transport_params",
")",
":",
"if",
"mode",
"not",
"in",
"(",
"'rb'",
",",
"'rb+'",
",",
"'wb'",
",",
"'wb+'",
",",
"'ab'",
",",
"'ab+'",
")",
":",
"#",
"# This should really be a ValueError, but fo... | Open an arbitrary URI in the specified binary mode.
Not all modes are supported for all protocols.
:arg uri: The URI to open. May be a string, or something else.
:arg str mode: The mode to open with. Must be rb, wb or ab.
:arg transport_params: Keyword argumens for the transport layer.
:returns:... | [
"Open",
"an",
"arbitrary",
"URI",
"in",
"the",
"specified",
"binary",
"mode",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L504-L568 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | _my_urlsplit | def _my_urlsplit(url):
"""This is a hack to prevent the regular urlsplit from splitting around question marks.
A question mark (?) in a URL typically indicates the start of a
querystring, and the standard library's urlparse function handles the
querystring separately. Unfortunately, question marks can... | python | def _my_urlsplit(url):
"""This is a hack to prevent the regular urlsplit from splitting around question marks.
A question mark (?) in a URL typically indicates the start of a
querystring, and the standard library's urlparse function handles the
querystring separately. Unfortunately, question marks can... | [
"def",
"_my_urlsplit",
"(",
"url",
")",
":",
"if",
"'?'",
"not",
"in",
"url",
":",
"return",
"urlsplit",
"(",
"url",
",",
"allow_fragments",
"=",
"False",
")",
"sr",
"=",
"urlsplit",
"(",
"url",
".",
"replace",
"(",
"'?'",
",",
"'\\n'",
")",
",",
"... | This is a hack to prevent the regular urlsplit from splitting around question marks.
A question mark (?) in a URL typically indicates the start of a
querystring, and the standard library's urlparse function handles the
querystring separately. Unfortunately, question marks can also appear
_inside_ the ... | [
"This",
"is",
"a",
"hack",
"to",
"prevent",
"the",
"regular",
"urlsplit",
"from",
"splitting",
"around",
"question",
"marks",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L632-L655 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | _parse_uri | def _parse_uri(uri_as_string):
"""
Parse the given URI from a string.
Supported URI schemes are:
* file
* hdfs
* http
* https
* s3
* s3a
* s3n
* s3u
* webhdfs
.s3, s3a and s3n are treated the same way. s3u is s3 but without SSL.
Valid URI ex... | python | def _parse_uri(uri_as_string):
"""
Parse the given URI from a string.
Supported URI schemes are:
* file
* hdfs
* http
* https
* s3
* s3a
* s3n
* s3u
* webhdfs
.s3, s3a and s3n are treated the same way. s3u is s3 but without SSL.
Valid URI ex... | [
"def",
"_parse_uri",
"(",
"uri_as_string",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"# urlsplit doesn't work on Windows -- it parses the drive as the scheme...",
"if",
"'://'",
"not",
"in",
"uri_as_string",
":",
"# no protocol given => assume a local file",
"ur... | Parse the given URI from a string.
Supported URI schemes are:
* file
* hdfs
* http
* https
* s3
* s3a
* s3n
* s3u
* webhdfs
.s3, s3a and s3n are treated the same way. s3u is s3 but without SSL.
Valid URI examples::
* s3://my_bucket/my_key
... | [
"Parse",
"the",
"given",
"URI",
"from",
"a",
"string",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L658-L719 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | _parse_uri_ssh | def _parse_uri_ssh(unt):
"""Parse a Uri from a urllib namedtuple."""
if '@' in unt.netloc:
user, host_port = unt.netloc.split('@', 1)
else:
user, host_port = None, unt.netloc
if ':' in host_port:
host, port = host_port.split(':', 1)
else:
host, port = host_port, None... | python | def _parse_uri_ssh(unt):
"""Parse a Uri from a urllib namedtuple."""
if '@' in unt.netloc:
user, host_port = unt.netloc.split('@', 1)
else:
user, host_port = None, unt.netloc
if ':' in host_port:
host, port = host_port.split(':', 1)
else:
host, port = host_port, None... | [
"def",
"_parse_uri_ssh",
"(",
"unt",
")",
":",
"if",
"'@'",
"in",
"unt",
".",
"netloc",
":",
"user",
",",
"host_port",
"=",
"unt",
".",
"netloc",
".",
"split",
"(",
"'@'",
",",
"1",
")",
"else",
":",
"user",
",",
"host_port",
"=",
"None",
",",
"u... | Parse a Uri from a urllib namedtuple. | [
"Parse",
"a",
"Uri",
"from",
"a",
"urllib",
"namedtuple",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L807-L826 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | _need_to_buffer | def _need_to_buffer(file_obj, mode, ext):
"""Returns True if we need to buffer the whole file in memory in order to proceed."""
try:
is_seekable = file_obj.seekable()
except AttributeError:
#
# Under Py2, built-in file objects returned by open do not have
# .seekable, but hav... | python | def _need_to_buffer(file_obj, mode, ext):
"""Returns True if we need to buffer the whole file in memory in order to proceed."""
try:
is_seekable = file_obj.seekable()
except AttributeError:
#
# Under Py2, built-in file objects returned by open do not have
# .seekable, but hav... | [
"def",
"_need_to_buffer",
"(",
"file_obj",
",",
"mode",
",",
"ext",
")",
":",
"try",
":",
"is_seekable",
"=",
"file_obj",
".",
"seekable",
"(",
")",
"except",
"AttributeError",
":",
"#",
"# Under Py2, built-in file objects returned by open do not have",
"# .seekable, ... | Returns True if we need to buffer the whole file in memory in order to proceed. | [
"Returns",
"True",
"if",
"we",
"need",
"to",
"buffer",
"the",
"whole",
"file",
"in",
"memory",
"in",
"order",
"to",
"proceed",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L829-L839 | train |
RaRe-Technologies/smart_open | smart_open/smart_open_lib.py | _encoding_wrapper | def _encoding_wrapper(fileobj, mode, encoding=None, errors=None):
"""Decode bytes into text, if necessary.
If mode specifies binary access, does nothing, unless the encoding is
specified. A non-null encoding implies text mode.
:arg fileobj: must quack like a filehandle object.
:arg str mode: is t... | python | def _encoding_wrapper(fileobj, mode, encoding=None, errors=None):
"""Decode bytes into text, if necessary.
If mode specifies binary access, does nothing, unless the encoding is
specified. A non-null encoding implies text mode.
:arg fileobj: must quack like a filehandle object.
:arg str mode: is t... | [
"def",
"_encoding_wrapper",
"(",
"fileobj",
",",
"mode",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'encoding_wrapper: %r'",
",",
"locals",
"(",
")",
")",
"#",
"# If the mode is binary, but the user specifie... | Decode bytes into text, if necessary.
If mode specifies binary access, does nothing, unless the encoding is
specified. A non-null encoding implies text mode.
:arg fileobj: must quack like a filehandle object.
:arg str mode: is the mode which was originally requested by the user.
:arg str encoding... | [
"Decode",
"bytes",
"into",
"text",
"if",
"necessary",
"."
] | 2dc8d60f223fc7b00a2000c56362a7bd6cd0850e | https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L869-L903 | train |
cossacklabs/acra | examples/python/example_with_zone.py | get_zone | def get_zone():
"""make http response to AcraServer api to generate new zone and return tuple
of zone id and public key
"""
response = urlopen('{}/getNewZone'.format(ACRA_CONNECTOR_API_ADDRESS))
json_data = response.read().decode('utf-8')
zone_data = json.loads(json_data)
return zone_data['i... | python | def get_zone():
"""make http response to AcraServer api to generate new zone and return tuple
of zone id and public key
"""
response = urlopen('{}/getNewZone'.format(ACRA_CONNECTOR_API_ADDRESS))
json_data = response.read().decode('utf-8')
zone_data = json.loads(json_data)
return zone_data['i... | [
"def",
"get_zone",
"(",
")",
":",
"response",
"=",
"urlopen",
"(",
"'{}/getNewZone'",
".",
"format",
"(",
"ACRA_CONNECTOR_API_ADDRESS",
")",
")",
"json_data",
"=",
"response",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"zone_data",
"=",
"js... | make http response to AcraServer api to generate new zone and return tuple
of zone id and public key | [
"make",
"http",
"response",
"to",
"AcraServer",
"api",
"to",
"generate",
"new",
"zone",
"and",
"return",
"tuple",
"of",
"zone",
"id",
"and",
"public",
"key"
] | e30741e2dfb2f3320a08ff78450c618afcb195e4 | https://github.com/cossacklabs/acra/blob/e30741e2dfb2f3320a08ff78450c618afcb195e4/examples/python/example_with_zone.py#L34-L41 | train |
has2k1/plotnine | plotnine/stats/binning.py | iqr | def iqr(a):
"""
Calculate the IQR for an array of numbers.
"""
a = np.asarray(a)
q1 = stats.scoreatpercentile(a, 25)
q3 = stats.scoreatpercentile(a, 75)
return q3 - q1 | python | def iqr(a):
"""
Calculate the IQR for an array of numbers.
"""
a = np.asarray(a)
q1 = stats.scoreatpercentile(a, 25)
q3 = stats.scoreatpercentile(a, 75)
return q3 - q1 | [
"def",
"iqr",
"(",
"a",
")",
":",
"a",
"=",
"np",
".",
"asarray",
"(",
"a",
")",
"q1",
"=",
"stats",
".",
"scoreatpercentile",
"(",
"a",
",",
"25",
")",
"q3",
"=",
"stats",
".",
"scoreatpercentile",
"(",
"a",
",",
"75",
")",
"return",
"q3",
"-"... | Calculate the IQR for an array of numbers. | [
"Calculate",
"the",
"IQR",
"for",
"an",
"array",
"of",
"numbers",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/binning.py#L14-L21 | train |
has2k1/plotnine | plotnine/stats/binning.py | freedman_diaconis_bins | def freedman_diaconis_bins(a):
"""
Calculate number of hist bins using Freedman-Diaconis rule.
"""
# From http://stats.stackexchange.com/questions/798/
a = np.asarray(a)
h = 2 * iqr(a) / (len(a) ** (1 / 3))
# fall back to sqrt(a) bins if iqr is 0
if h == 0:
bins = np.ceil(np.sqr... | python | def freedman_diaconis_bins(a):
"""
Calculate number of hist bins using Freedman-Diaconis rule.
"""
# From http://stats.stackexchange.com/questions/798/
a = np.asarray(a)
h = 2 * iqr(a) / (len(a) ** (1 / 3))
# fall back to sqrt(a) bins if iqr is 0
if h == 0:
bins = np.ceil(np.sqr... | [
"def",
"freedman_diaconis_bins",
"(",
"a",
")",
":",
"# From http://stats.stackexchange.com/questions/798/",
"a",
"=",
"np",
".",
"asarray",
"(",
"a",
")",
"h",
"=",
"2",
"*",
"iqr",
"(",
"a",
")",
"/",
"(",
"len",
"(",
"a",
")",
"**",
"(",
"1",
"/",
... | Calculate number of hist bins using Freedman-Diaconis rule. | [
"Calculate",
"number",
"of",
"hist",
"bins",
"using",
"Freedman",
"-",
"Diaconis",
"rule",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/binning.py#L24-L38 | train |
has2k1/plotnine | plotnine/stats/binning.py | assign_bins | def assign_bins(x, breaks, weight=None, pad=False, closed='right'):
"""
Assign value in x to bins demacated by the break points
Parameters
----------
x : array_like
Values to be binned.
breaks : array_like
Sequence of break points.
weight : array_like
Weight of each ... | python | def assign_bins(x, breaks, weight=None, pad=False, closed='right'):
"""
Assign value in x to bins demacated by the break points
Parameters
----------
x : array_like
Values to be binned.
breaks : array_like
Sequence of break points.
weight : array_like
Weight of each ... | [
"def",
"assign_bins",
"(",
"x",
",",
"breaks",
",",
"weight",
"=",
"None",
",",
"pad",
"=",
"False",
",",
"closed",
"=",
"'right'",
")",
":",
"right",
"=",
"closed",
"==",
"'right'",
"# If weight not supplied to, use one (no weight)",
"if",
"weight",
"is",
"... | Assign value in x to bins demacated by the break points
Parameters
----------
x : array_like
Values to be binned.
breaks : array_like
Sequence of break points.
weight : array_like
Weight of each value in `x`. Used in creating the frequency
table. If `None`, then each... | [
"Assign",
"value",
"in",
"x",
"to",
"bins",
"demacated",
"by",
"the",
"break",
"points"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/binning.py#L120-L182 | train |
has2k1/plotnine | plotnine/stats/binning.py | result_dataframe | def result_dataframe(count, x, width, xmin=None, xmax=None):
"""
Create a dataframe to hold bin information
"""
if xmin is None:
xmin = x-width/2
if xmax is None:
xmax = x+width/2
# Eliminate any numerical roundoff discrepancies
# between the edges
xmin[1:] = xmax[:-1]
... | python | def result_dataframe(count, x, width, xmin=None, xmax=None):
"""
Create a dataframe to hold bin information
"""
if xmin is None:
xmin = x-width/2
if xmax is None:
xmax = x+width/2
# Eliminate any numerical roundoff discrepancies
# between the edges
xmin[1:] = xmax[:-1]
... | [
"def",
"result_dataframe",
"(",
"count",
",",
"x",
",",
"width",
",",
"xmin",
"=",
"None",
",",
"xmax",
"=",
"None",
")",
":",
"if",
"xmin",
"is",
"None",
":",
"xmin",
"=",
"x",
"-",
"width",
"/",
"2",
"if",
"xmax",
"is",
"None",
":",
"xmax",
"... | Create a dataframe to hold bin information | [
"Create",
"a",
"dataframe",
"to",
"hold",
"bin",
"information"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/binning.py#L185-L209 | train |
has2k1/plotnine | plotnine/stats/binning.py | fuzzybreaks | def fuzzybreaks(scale, breaks=None, boundary=None,
binwidth=None, bins=30, right=True):
"""
Compute fuzzy breaks
For a continuous scale, fuzzybreaks "preserve" the range of
the scale. The fuzzing is close to numerical roundoff and
is visually imperceptible.
Parameters
-----... | python | def fuzzybreaks(scale, breaks=None, boundary=None,
binwidth=None, bins=30, right=True):
"""
Compute fuzzy breaks
For a continuous scale, fuzzybreaks "preserve" the range of
the scale. The fuzzing is close to numerical roundoff and
is visually imperceptible.
Parameters
-----... | [
"def",
"fuzzybreaks",
"(",
"scale",
",",
"breaks",
"=",
"None",
",",
"boundary",
"=",
"None",
",",
"binwidth",
"=",
"None",
",",
"bins",
"=",
"30",
",",
"right",
"=",
"True",
")",
":",
"# Bins for categorical data should take the width",
"# of one level, and sho... | Compute fuzzy breaks
For a continuous scale, fuzzybreaks "preserve" the range of
the scale. The fuzzing is close to numerical roundoff and
is visually imperceptible.
Parameters
----------
scale : scale
Scale
breaks : array_like
Sequence of break points. If provided and the ... | [
"Compute",
"fuzzy",
"breaks"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/binning.py#L212-L274 | train |
has2k1/plotnine | plotnine/guides/guides.py | guides.build | def build(self, plot):
"""
Build the guides
Parameters
----------
plot : ggplot
ggplot object being drawn
Returns
-------
box : matplotlib.offsetbox.Offsetbox | None
A box that contains all the guides for the plot.
If ... | python | def build(self, plot):
"""
Build the guides
Parameters
----------
plot : ggplot
ggplot object being drawn
Returns
-------
box : matplotlib.offsetbox.Offsetbox | None
A box that contains all the guides for the plot.
If ... | [
"def",
"build",
"(",
"self",
",",
"plot",
")",
":",
"get_property",
"=",
"plot",
".",
"theme",
".",
"themeables",
".",
"property",
"# by default, guide boxes are vertically aligned",
"with",
"suppress",
"(",
"KeyError",
")",
":",
"self",
".",
"box_direction",
"=... | Build the guides
Parameters
----------
plot : ggplot
ggplot object being drawn
Returns
-------
box : matplotlib.offsetbox.Offsetbox | None
A box that contains all the guides for the plot.
If there are no guides, **None** is returned. | [
"Build",
"the",
"guides"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guides.py#L85-L146 | train |
has2k1/plotnine | plotnine/guides/guides.py | guides.train | def train(self, plot):
"""
Compute all the required guides
Parameters
----------
plot : ggplot
ggplot object
Returns
-------
gdefs : list
Guides for the plots
"""
gdefs = []
for scale in plot.scales:
... | python | def train(self, plot):
"""
Compute all the required guides
Parameters
----------
plot : ggplot
ggplot object
Returns
-------
gdefs : list
Guides for the plots
"""
gdefs = []
for scale in plot.scales:
... | [
"def",
"train",
"(",
"self",
",",
"plot",
")",
":",
"gdefs",
"=",
"[",
"]",
"for",
"scale",
"in",
"plot",
".",
"scales",
":",
"for",
"output",
"in",
"scale",
".",
"aesthetics",
":",
"# The guide for aesthetic 'xxx' is stored",
"# in plot.guides['xxx']. The prior... | Compute all the required guides
Parameters
----------
plot : ggplot
ggplot object
Returns
-------
gdefs : list
Guides for the plots | [
"Compute",
"all",
"the",
"required",
"guides"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guides.py#L148-L211 | train |
has2k1/plotnine | plotnine/guides/guides.py | guides.validate | def validate(self, guide):
"""
Validate guide object
"""
if is_string(guide):
guide = Registry['guide_{}'.format(guide)]()
if not isinstance(guide, guide_class):
raise PlotnineError(
"Unknown guide: {}".format(guide))
return guide | python | def validate(self, guide):
"""
Validate guide object
"""
if is_string(guide):
guide = Registry['guide_{}'.format(guide)]()
if not isinstance(guide, guide_class):
raise PlotnineError(
"Unknown guide: {}".format(guide))
return guide | [
"def",
"validate",
"(",
"self",
",",
"guide",
")",
":",
"if",
"is_string",
"(",
"guide",
")",
":",
"guide",
"=",
"Registry",
"[",
"'guide_{}'",
".",
"format",
"(",
"guide",
")",
"]",
"(",
")",
"if",
"not",
"isinstance",
"(",
"guide",
",",
"guide_clas... | Validate guide object | [
"Validate",
"guide",
"object"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guides.py#L213-L223 | train |
has2k1/plotnine | plotnine/guides/guides.py | guides.create_geoms | def create_geoms(self, gdefs, plot):
"""
Add geoms to the guide definitions
"""
new_gdefs = []
for gdef in gdefs:
gdef = gdef.create_geoms(plot)
if gdef:
new_gdefs.append(gdef)
return new_gdefs | python | def create_geoms(self, gdefs, plot):
"""
Add geoms to the guide definitions
"""
new_gdefs = []
for gdef in gdefs:
gdef = gdef.create_geoms(plot)
if gdef:
new_gdefs.append(gdef)
return new_gdefs | [
"def",
"create_geoms",
"(",
"self",
",",
"gdefs",
",",
"plot",
")",
":",
"new_gdefs",
"=",
"[",
"]",
"for",
"gdef",
"in",
"gdefs",
":",
"gdef",
"=",
"gdef",
".",
"create_geoms",
"(",
"plot",
")",
"if",
"gdef",
":",
"new_gdefs",
".",
"append",
"(",
... | Add geoms to the guide definitions | [
"Add",
"geoms",
"to",
"the",
"guide",
"definitions"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guides.py#L255-L265 | train |
has2k1/plotnine | plotnine/guides/guides.py | guides.draw | def draw(self, gdefs, theme):
"""
Draw out each guide definition
Parameters
----------
gdefs : list of guide_legend|guide_colorbar
guide definitions
theme : theme
Plot theme
Returns
-------
out : list of matplotlib.offsetb... | python | def draw(self, gdefs, theme):
"""
Draw out each guide definition
Parameters
----------
gdefs : list of guide_legend|guide_colorbar
guide definitions
theme : theme
Plot theme
Returns
-------
out : list of matplotlib.offsetb... | [
"def",
"draw",
"(",
"self",
",",
"gdefs",
",",
"theme",
")",
":",
"for",
"g",
"in",
"gdefs",
":",
"g",
".",
"theme",
"=",
"theme",
"g",
".",
"_set_defaults",
"(",
")",
"return",
"[",
"g",
".",
"draw",
"(",
")",
"for",
"g",
"in",
"gdefs",
"]"
] | Draw out each guide definition
Parameters
----------
gdefs : list of guide_legend|guide_colorbar
guide definitions
theme : theme
Plot theme
Returns
-------
out : list of matplotlib.offsetbox.Offsetbox
A drawing of each legend | [
"Draw",
"out",
"each",
"guide",
"definition"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guides.py#L267-L286 | train |
has2k1/plotnine | plotnine/guides/guides.py | guides.assemble | def assemble(self, gboxes, gdefs, theme):
"""
Put together all the guide boxes
Parameters
----------
gboxes : list
List of :class:`~matplotlib.offsetbox.Offsetbox`,
where each item is a legend for a single aesthetic.
gdefs : list of guide_legend|g... | python | def assemble(self, gboxes, gdefs, theme):
"""
Put together all the guide boxes
Parameters
----------
gboxes : list
List of :class:`~matplotlib.offsetbox.Offsetbox`,
where each item is a legend for a single aesthetic.
gdefs : list of guide_legend|g... | [
"def",
"assemble",
"(",
"self",
",",
"gboxes",
",",
"gdefs",
",",
"theme",
")",
":",
"# place the guides according to the guide.order",
"# 0 do not sort",
"# 1-99 sort",
"for",
"gdef",
"in",
"gdefs",
":",
"if",
"gdef",
".",
"order",
"==",
"0",
":",
"gdef",
"."... | Put together all the guide boxes
Parameters
----------
gboxes : list
List of :class:`~matplotlib.offsetbox.Offsetbox`,
where each item is a legend for a single aesthetic.
gdefs : list of guide_legend|guide_colorbar
guide definitions
theme : th... | [
"Put",
"together",
"all",
"the",
"guide",
"boxes"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guides.py#L288-L333 | train |
has2k1/plotnine | doc/sphinxext/examples_and_gallery.py | add_entries_to_gallery | def add_entries_to_gallery(app, doctree, docname):
"""
Add entries to the gallery node
Should happen when all the doctrees have been read
and the gallery entries have been collected. i.e at
doctree-resolved time.
"""
if docname != 'gallery':
return
if not has_gallery(app.builde... | python | def add_entries_to_gallery(app, doctree, docname):
"""
Add entries to the gallery node
Should happen when all the doctrees have been read
and the gallery entries have been collected. i.e at
doctree-resolved time.
"""
if docname != 'gallery':
return
if not has_gallery(app.builde... | [
"def",
"add_entries_to_gallery",
"(",
"app",
",",
"doctree",
",",
"docname",
")",
":",
"if",
"docname",
"!=",
"'gallery'",
":",
"return",
"if",
"not",
"has_gallery",
"(",
"app",
".",
"builder",
".",
"name",
")",
":",
"return",
"# Find gallery node",
"try",
... | Add entries to the gallery node
Should happen when all the doctrees have been read
and the gallery entries have been collected. i.e at
doctree-resolved time. | [
"Add",
"entries",
"to",
"the",
"gallery",
"node"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/doc/sphinxext/examples_and_gallery.py#L289-L315 | train |
has2k1/plotnine | doc/sphinxext/examples_and_gallery.py | GalleryEntry.html | def html(self):
"""
Return html for a the entry
"""
# No empty tooltips
if self.description:
tooltip = 'tooltip="{}"'.format(self.description)
else:
tooltip = ''
return entry_html(
title=self.title,
thumbnail=self.t... | python | def html(self):
"""
Return html for a the entry
"""
# No empty tooltips
if self.description:
tooltip = 'tooltip="{}"'.format(self.description)
else:
tooltip = ''
return entry_html(
title=self.title,
thumbnail=self.t... | [
"def",
"html",
"(",
"self",
")",
":",
"# No empty tooltips",
"if",
"self",
".",
"description",
":",
"tooltip",
"=",
"'tooltip=\"{}\"'",
".",
"format",
"(",
"self",
".",
"description",
")",
"else",
":",
"tooltip",
"=",
"''",
"return",
"entry_html",
"(",
"ti... | Return html for a the entry | [
"Return",
"html",
"for",
"a",
"the",
"entry"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/doc/sphinxext/examples_and_gallery.py#L103-L117 | train |
has2k1/plotnine | plotnine/geoms/annotation_logticks.py | _geom_logticks._check_log_scale | def _check_log_scale(base, sides, scales, coord):
"""
Check the log transforms
Parameters
----------
base : float or None
Base of the logarithm in which the ticks will be
calculated. If ``None``, the base of the log transform
the scale will be... | python | def _check_log_scale(base, sides, scales, coord):
"""
Check the log transforms
Parameters
----------
base : float or None
Base of the logarithm in which the ticks will be
calculated. If ``None``, the base of the log transform
the scale will be... | [
"def",
"_check_log_scale",
"(",
"base",
",",
"sides",
",",
"scales",
",",
"coord",
")",
":",
"def",
"is_log",
"(",
"trans",
")",
":",
"return",
"(",
"trans",
".",
"__class__",
".",
"__name__",
".",
"startswith",
"(",
"'log'",
")",
"and",
"hasattr",
"("... | Check the log transforms
Parameters
----------
base : float or None
Base of the logarithm in which the ticks will be
calculated. If ``None``, the base of the log transform
the scale will be used.
sides : str (default: bl)
Sides onto which ... | [
"Check",
"the",
"log",
"transforms"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/annotation_logticks.py#L25-L91 | train |
has2k1/plotnine | plotnine/geoms/annotation_logticks.py | _geom_logticks._calc_ticks | def _calc_ticks(value_range, base):
"""
Calculate tick marks within a range
Parameters
----------
value_range: tuple
Range for which to calculate ticks.
Returns
-------
out: tuple
(major, middle, minor) tick locations
"""
... | python | def _calc_ticks(value_range, base):
"""
Calculate tick marks within a range
Parameters
----------
value_range: tuple
Range for which to calculate ticks.
Returns
-------
out: tuple
(major, middle, minor) tick locations
"""
... | [
"def",
"_calc_ticks",
"(",
"value_range",
",",
"base",
")",
":",
"def",
"_minor",
"(",
"x",
",",
"mid_idx",
")",
":",
"return",
"np",
".",
"hstack",
"(",
"[",
"x",
"[",
"1",
":",
"mid_idx",
"]",
",",
"x",
"[",
"mid_idx",
"+",
"1",
":",
"-",
"1"... | Calculate tick marks within a range
Parameters
----------
value_range: tuple
Range for which to calculate ticks.
Returns
-------
out: tuple
(major, middle, minor) tick locations | [
"Calculate",
"tick",
"marks",
"within",
"a",
"range"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/annotation_logticks.py#L94-L133 | train |
has2k1/plotnine | plotnine/options.py | get_option | def get_option(name):
"""
Get package option
Parameters
----------
name : str
Name of the option
"""
d = globals()
if name in {'get_option', 'set_option'} or name not in d:
from ..exceptions import PlotnineError
raise PlotnineError("Unknown option {}".format(nam... | python | def get_option(name):
"""
Get package option
Parameters
----------
name : str
Name of the option
"""
d = globals()
if name in {'get_option', 'set_option'} or name not in d:
from ..exceptions import PlotnineError
raise PlotnineError("Unknown option {}".format(nam... | [
"def",
"get_option",
"(",
"name",
")",
":",
"d",
"=",
"globals",
"(",
")",
"if",
"name",
"in",
"{",
"'get_option'",
",",
"'set_option'",
"}",
"or",
"name",
"not",
"in",
"d",
":",
"from",
".",
".",
"exceptions",
"import",
"PlotnineError",
"raise",
"Plot... | Get package option
Parameters
----------
name : str
Name of the option | [
"Get",
"package",
"option"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/options.py#L18-L33 | train |
has2k1/plotnine | plotnine/options.py | set_option | def set_option(name, value):
"""
Set package option
Parameters
----------
name : str
Name of the option
value : object
New value of the option
Returns
-------
old : object
Old value of the option
"""
d = globals()
if name in {'get_option', 'set_... | python | def set_option(name, value):
"""
Set package option
Parameters
----------
name : str
Name of the option
value : object
New value of the option
Returns
-------
old : object
Old value of the option
"""
d = globals()
if name in {'get_option', 'set_... | [
"def",
"set_option",
"(",
"name",
",",
"value",
")",
":",
"d",
"=",
"globals",
"(",
")",
"if",
"name",
"in",
"{",
"'get_option'",
",",
"'set_option'",
"}",
"or",
"name",
"not",
"in",
"d",
":",
"from",
".",
".",
"exceptions",
"import",
"PlotnineError",
... | Set package option
Parameters
----------
name : str
Name of the option
value : object
New value of the option
Returns
-------
old : object
Old value of the option | [
"Set",
"package",
"option"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/options.py#L36-L60 | train |
has2k1/plotnine | plotnine/scales/limits.py | expand_limits | def expand_limits(**kwargs):
"""
Expand the limits any aesthetic using data
Parameters
----------
kwargs : dict or dataframe
Data to use in expanding the limits.
The keys should be aesthetic names
e.g. *x*, *y*, *colour*, ...
"""
def as_list(key):
with suppre... | python | def expand_limits(**kwargs):
"""
Expand the limits any aesthetic using data
Parameters
----------
kwargs : dict or dataframe
Data to use in expanding the limits.
The keys should be aesthetic names
e.g. *x*, *y*, *colour*, ...
"""
def as_list(key):
with suppre... | [
"def",
"expand_limits",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"as_list",
"(",
"key",
")",
":",
"with",
"suppress",
"(",
"KeyError",
")",
":",
"if",
"isinstance",
"(",
"kwargs",
"[",
"key",
"]",
",",
"(",
"int",
",",
"float",
",",
"str",
")",
... | Expand the limits any aesthetic using data
Parameters
----------
kwargs : dict or dataframe
Data to use in expanding the limits.
The keys should be aesthetic names
e.g. *x*, *y*, *colour*, ... | [
"Expand",
"the",
"limits",
"any",
"aesthetic",
"using",
"data"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/limits.py#L188-L215 | train |
has2k1/plotnine | plotnine/scales/limits.py | _lim.get_scale | def get_scale(self, gg):
"""
Create a scale
"""
# This method does some introspection to save users from
# scale mismatch error. This could happen when the
# aesthetic is mapped to a categorical but the limits
# are not provided in categorical form. We only handle... | python | def get_scale(self, gg):
"""
Create a scale
"""
# This method does some introspection to save users from
# scale mismatch error. This could happen when the
# aesthetic is mapped to a categorical but the limits
# are not provided in categorical form. We only handle... | [
"def",
"get_scale",
"(",
"self",
",",
"gg",
")",
":",
"# This method does some introspection to save users from",
"# scale mismatch error. This could happen when the",
"# aesthetic is mapped to a categorical but the limits",
"# are not provided in categorical form. We only handle",
"# the ca... | Create a scale | [
"Create",
"a",
"scale"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/limits.py#L46-L83 | train |
has2k1/plotnine | plotnine/geoms/geom.py | geom.from_stat | def from_stat(stat):
"""
Return an instantiated geom object
geoms should not override this method.
Parameters
----------
stat : stat
`stat`
Returns
-------
out : geom
A geom object
Raises
------
:... | python | def from_stat(stat):
"""
Return an instantiated geom object
geoms should not override this method.
Parameters
----------
stat : stat
`stat`
Returns
-------
out : geom
A geom object
Raises
------
:... | [
"def",
"from_stat",
"(",
"stat",
")",
":",
"name",
"=",
"stat",
".",
"params",
"[",
"'geom'",
"]",
"if",
"issubclass",
"(",
"type",
"(",
"name",
")",
",",
"geom",
")",
":",
"return",
"name",
"if",
"isinstance",
"(",
"name",
",",
"type",
")",
"and",... | Return an instantiated geom object
geoms should not override this method.
Parameters
----------
stat : stat
`stat`
Returns
-------
out : geom
A geom object
Raises
------
:class:`PlotnineError` if unable to create... | [
"Return",
"an",
"instantiated",
"geom",
"object"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom.py#L50-L84 | train |
has2k1/plotnine | plotnine/geoms/geom.py | geom.aesthetics | def aesthetics(cls):
"""
Return all the aesthetics for this geom
geoms should not override this method.
"""
main = cls.DEFAULT_AES.keys() | cls.REQUIRED_AES
other = {'group'}
# Need to recognize both spellings
if 'color' in main:
other.add('co... | python | def aesthetics(cls):
"""
Return all the aesthetics for this geom
geoms should not override this method.
"""
main = cls.DEFAULT_AES.keys() | cls.REQUIRED_AES
other = {'group'}
# Need to recognize both spellings
if 'color' in main:
other.add('co... | [
"def",
"aesthetics",
"(",
"cls",
")",
":",
"main",
"=",
"cls",
".",
"DEFAULT_AES",
".",
"keys",
"(",
")",
"|",
"cls",
".",
"REQUIRED_AES",
"other",
"=",
"{",
"'group'",
"}",
"# Need to recognize both spellings",
"if",
"'color'",
"in",
"main",
":",
"other",... | Return all the aesthetics for this geom
geoms should not override this method. | [
"Return",
"all",
"the",
"aesthetics",
"for",
"this",
"geom"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom.py#L87-L100 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.