hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | _get_class_object | <not_specific> | def _get_class_object(cls):
"""
Returns the current class object. Used by the graph ORM to construct
new Graph based classes
"""
return cls |
Returns the current class object. Used by the graph ORM to construct
new Graph based classes
| Returns the current class object. Used by the graph ORM to construct
new Graph based classes | [
"Returns",
"the",
"current",
"class",
"object",
".",
"Used",
"by",
"the",
"graph",
"ORM",
"to",
"construct",
"new",
"Graph",
"based",
"classes"
] | def _get_class_object(cls):
return cls | [
"def",
"_get_class_object",
"(",
"cls",
")",
":",
"return",
"cls"
] | Returns the current class object. | [
"Returns",
"the",
"current",
"class",
"object",
"."
] | [
"\"\"\"\n Returns the current class object. Used by the graph ORM to construct\n new Graph based classes\n \"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | _set_auto_nid | null | def _set_auto_nid(self):
"""
Set the automatically assigned node ID (nid) based on the '_id' node
attributes in the current graph
"""
_id = [attr.get('_id', 0) for attr in self.nodes.values()]
if len(_id):
self._nodeid = max(_id) + 1 |
Set the automatically assigned node ID (nid) based on the '_id' node
attributes in the current graph
| Set the automatically assigned node ID (nid) based on the '_id' node
attributes in the current graph | [
"Set",
"the",
"automatically",
"assigned",
"node",
"ID",
"(",
"nid",
")",
"based",
"on",
"the",
"'",
"_id",
"'",
"node",
"attributes",
"in",
"the",
"current",
"graph"
] | def _set_auto_nid(self):
_id = [attr.get('_id', 0) for attr in self.nodes.values()]
if len(_id):
self._nodeid = max(_id) + 1 | [
"def",
"_set_auto_nid",
"(",
"self",
")",
":",
"_id",
"=",
"[",
"attr",
".",
"get",
"(",
"'_id'",
",",
"0",
")",
"for",
"attr",
"in",
"self",
".",
"nodes",
".",
"values",
"(",
")",
"]",
"if",
"len",
"(",
"_id",
")",
":",
"self",
".",
"_nodeid",... | Set the automatically assigned node ID (nid) based on the '_id' node
attributes in the current graph | [
"Set",
"the",
"automatically",
"assigned",
"node",
"ID",
"(",
"nid",
")",
"based",
"on",
"the",
"'",
"_id",
"'",
"node",
"attributes",
"in",
"the",
"current",
"graph"
] | [
"\"\"\"\n Set the automatically assigned node ID (nid) based on the '_id' node\n attributes in the current graph\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | _set_origin | null | def _set_origin(self, graph):
"""
Set a weak reference to the full graph
:param graph: Graph instance
"""
if isinstance(graph, GraphBase):
self.origin = weakref.ref(graph.origin)() |
Set a weak reference to the full graph
:param graph: Graph instance
| Set a weak reference to the full graph | [
"Set",
"a",
"weak",
"reference",
"to",
"the",
"full",
"graph"
] | def _set_origin(self, graph):
if isinstance(graph, GraphBase):
self.origin = weakref.ref(graph.origin)() | [
"def",
"_set_origin",
"(",
"self",
",",
"graph",
")",
":",
"if",
"isinstance",
"(",
"graph",
",",
"GraphBase",
")",
":",
"self",
".",
"origin",
"=",
"weakref",
".",
"ref",
"(",
"graph",
".",
"origin",
")",
"(",
")"
] | Set a weak reference to the full graph | [
"Set",
"a",
"weak",
"reference",
"to",
"the",
"full",
"graph"
] | [
"\"\"\"\n Set a weak reference to the full graph\n \n :param graph: Graph instance\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | add_edge | <not_specific> | def add_edge(self, nd1, nd2, directed=None, node_from_edge=False, unicode_convert=True, run_edge_new=True,
**kwargs):
"""
Add edge between two nodes to the graph
An edge is defined as a connection between two node ID's.
Edge metadata defined as a dictionary allo... |
Add edge between two nodes to the graph
An edge is defined as a connection between two node ID's.
Edge metadata defined as a dictionary allows it to be queried
by the various graph query functions.
After de new edge is created the edge class 'new' method is cal... | Add edge between two nodes to the graph
An edge is defined as a connection between two node ID's.
Edge metadata defined as a dictionary allows it to be queried
by the various graph query functions.
After de new edge is created the edge class 'new' method is called once
to allow any custom edge initiation to be perform... | [
"Add",
"edge",
"between",
"two",
"nodes",
"to",
"the",
"graph",
"An",
"edge",
"is",
"defined",
"as",
"a",
"connection",
"between",
"two",
"node",
"ID",
"'",
"s",
".",
"Edge",
"metadata",
"defined",
"as",
"a",
"dictionary",
"allows",
"it",
"to",
"be",
"... | def add_edge(self, nd1, nd2, directed=None, node_from_edge=False, unicode_convert=True, run_edge_new=True,
**kwargs):
curr_auto_nid = self.auto_nid
if node_from_edge:
self.auto_nid = False
nd1 = to_unicode(nd1, convert=unicode_convert)
nd2 = to_unicode(nd2, c... | [
"def",
"add_edge",
"(",
"self",
",",
"nd1",
",",
"nd2",
",",
"directed",
"=",
"None",
",",
"node_from_edge",
"=",
"False",
",",
"unicode_convert",
"=",
"True",
",",
"run_edge_new",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"curr_auto_nid",
"=",
"self",... | Add edge between two nodes to the graph
An edge is defined as a connection between two node ID's. | [
"Add",
"edge",
"between",
"two",
"nodes",
"to",
"the",
"graph",
"An",
"edge",
"is",
"defined",
"as",
"a",
"connection",
"between",
"two",
"node",
"ID",
"'",
"s",
"."
] | [
"\"\"\"\n Add edge between two nodes to the graph\n \n An edge is defined as a connection between two node ID's.\n Edge metadata defined as a dictionary allows it to be queried\n by the various graph query functions.\n \n After de new edge is created the edge class '... | [
{
"param": "self",
"type": null
},
{
"param": "nd1",
"type": null
},
{
"param": "nd2",
"type": null
},
{
"param": "directed",
"type": null
},
{
"param": "node_from_edge",
"type": null
},
{
"param": "unicode_convert",
"type": null
},
{
"para... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": ":py:tuple"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": ... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | add_edges | <not_specific> | def add_edges(self, edges, node_from_edge=False, unicode_convert=True, run_edge_new=True, **kwargs):
"""
Add multiple edges to the graph.
This is the iterable version of the add_edge methods allowing
multiple edge additions from any iterable.
If the iterable yields a tuple with ... |
Add multiple edges to the graph.
This is the iterable version of the add_edge methods allowing
multiple edge additions from any iterable.
If the iterable yields a tuple with a dictionary as third
argument the key/value pairs of that dictionary will be added
as attribute... | Add multiple edges to the graph.
This is the iterable version of the add_edge methods allowing
multiple edge additions from any iterable.
If the iterable yields a tuple with a dictionary as third
argument the key/value pairs of that dictionary will be added
as attributes to the new edge along with any keyword arguments... | [
"Add",
"multiple",
"edges",
"to",
"the",
"graph",
".",
"This",
"is",
"the",
"iterable",
"version",
"of",
"the",
"add_edge",
"methods",
"allowing",
"multiple",
"edge",
"additions",
"from",
"any",
"iterable",
".",
"If",
"the",
"iterable",
"yields",
"a",
"tuple... | def add_edges(self, edges, node_from_edge=False, unicode_convert=True, run_edge_new=True, **kwargs):
edges_added = []
for edge in edges:
if len(edge) == 3 and isinstance(edge[2], dict):
attr = {}
attr.update(edge[2])
attr.update(kwargs)
... | [
"def",
"add_edges",
"(",
"self",
",",
"edges",
",",
"node_from_edge",
"=",
"False",
",",
"unicode_convert",
"=",
"True",
",",
"run_edge_new",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"edges_added",
"=",
"[",
"]",
"for",
"edge",
"in",
"edges",
":",
"... | Add multiple edges to the graph. | [
"Add",
"multiple",
"edges",
"to",
"the",
"graph",
"."
] | [
"\"\"\"\n Add multiple edges to the graph.\n\n This is the iterable version of the add_edge methods allowing\n multiple edge additions from any iterable.\n If the iterable yields a tuple with a dictionary as third\n argument the key/value pairs of that dictionary will be added\n ... | [
{
"param": "self",
"type": null
},
{
"param": "edges",
"type": null
},
{
"param": "node_from_edge",
"type": null
},
{
"param": "unicode_convert",
"type": null
},
{
"param": "run_edge_new",
"type": null
}
] | {
"returns": [
{
"docstring": "list of edge ids for the objects added in\nthe same order as th input iterable.",
"docstring_tokens": [
"list",
"of",
"edge",
"ids",
"for",
"the",
"objects",
"added",
"in",
"the",
"sa... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | add_node | <not_specific> | def add_node(self, node=None, unicode_convert=True, run_node_new=True, **kwargs):
"""
Add a node to the graph
All nodes are stored using a dictionary like data structure that can be
represented like:
{nid: {'_id': auto_nid, attribute_key: attribute_value... |
Add a node to the graph
All nodes are stored using a dictionary like data structure that can be
represented like:
{nid: {'_id': auto_nid, attribute_key: attribute_value, ....}}
'nid' is the primary node identifier which is either an auto-incremented
... | Add a node to the graph
All nodes are stored using a dictionary like data structure that can be
represented like.
'nid' is the primary node identifier which is either an auto-incremented
unique integer value if `Graph.auto_nid` equals True or a custom value
when False.
When `Graph.auto_nid` equals False, the `nod... | [
"Add",
"a",
"node",
"to",
"the",
"graph",
"All",
"nodes",
"are",
"stored",
"using",
"a",
"dictionary",
"like",
"data",
"structure",
"that",
"can",
"be",
"represented",
"like",
".",
"'",
"nid",
"'",
"is",
"the",
"primary",
"node",
"identifier",
"which",
"... | def add_node(self, node=None, unicode_convert=True, run_node_new=True, **kwargs):
if self.auto_nid:
nid = self._nodeid
else:
if node is None:
raise GraphitException('Node ID required when auto_nid is disabled')
nid = to_unicode(node, convert=unicode_co... | [
"def",
"add_node",
"(",
"self",
",",
"node",
"=",
"None",
",",
"unicode_convert",
"=",
"True",
",",
"run_node_new",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"if",
"self",
".",
"auto_nid",
":",
"nid",
"=",
"self",
".",
"_nodeid",
"else",
":",
"if",... | Add a node to the graph
All nodes are stored using a dictionary like data structure that can be
represented like: | [
"Add",
"a",
"node",
"to",
"the",
"graph",
"All",
"nodes",
"are",
"stored",
"using",
"a",
"dictionary",
"like",
"data",
"structure",
"that",
"can",
"be",
"represented",
"like",
":"
] | [
"\"\"\"\n Add a node to the graph\n \n All nodes are stored using a dictionary like data structure that can be\n represented like:\n \n {nid: {'_id': auto_nid, attribute_key: attribute_value, ....}}\n\n 'nid' is the primary node identifier which is either an ... | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": null
},
{
"param": "unicode_convert",
"type": null
},
{
"param": "run_node_new",
"type": null
}
] | {
"returns": [
{
"docstring": "node ID (nid)",
"docstring_tokens": [
"node",
"ID",
"(",
"nid",
")"
],
"type": "int"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstri... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | add_nodes | <not_specific> | def add_nodes(self, nodes, unicode_convert=True, run_node_new=True, **kwargs):
"""
Add multiple nodes to the graph.
This is the iterable version of the add_node methods allowing
multiple node additions from any iterable.
If the iterable yields a tuple with a dictionary a... |
Add multiple nodes to the graph.
This is the iterable version of the add_node methods allowing
multiple node additions from any iterable.
If the iterable yields a tuple with a dictionary as seconds
argument the key/value pairs of that dictionary will be added
as... | Add multiple nodes to the graph.
This is the iterable version of the add_node methods allowing
multiple node additions from any iterable.
If the iterable yields a tuple with a dictionary as seconds
argument the key/value pairs of that dictionary will be added
as attributes to the new node along with any keyword argumen... | [
"Add",
"multiple",
"nodes",
"to",
"the",
"graph",
".",
"This",
"is",
"the",
"iterable",
"version",
"of",
"the",
"add_node",
"methods",
"allowing",
"multiple",
"node",
"additions",
"from",
"any",
"iterable",
".",
"If",
"the",
"iterable",
"yields",
"a",
"tuple... | def add_nodes(self, nodes, unicode_convert=True, run_node_new=True, **kwargs):
node_collection = []
for node in nodes:
if isinstance(node, (tuple, list)):
if len(node) == 2 and isinstance(node[1], dict):
attr = {}
attr.update(node[1])
... | [
"def",
"add_nodes",
"(",
"self",
",",
"nodes",
",",
"unicode_convert",
"=",
"True",
",",
"run_node_new",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"node_collection",
"=",
"[",
"]",
"for",
"node",
"in",
"nodes",
":",
"if",
"isinstance",
"(",
"node",
"... | Add multiple nodes to the graph. | [
"Add",
"multiple",
"nodes",
"to",
"the",
"graph",
"."
] | [
"\"\"\"\n Add multiple nodes to the graph.\n \n This is the iterable version of the add_node methods allowing\n multiple node additions from any iterable.\n If the iterable yields a tuple with a dictionary as seconds\n argument the key/value pairs of that dictionary will be... | [
{
"param": "self",
"type": null
},
{
"param": "nodes",
"type": null
},
{
"param": "unicode_convert",
"type": null
},
{
"param": "run_node_new",
"type": null
}
] | {
"returns": [
{
"docstring": "list of node ids for the objects added in the\nsame order as th input iterable.",
"docstring_tokens": [
"list",
"of",
"node",
"ids",
"for",
"the",
"objects",
"added",
"in",
"the",
"sa... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | clear | null | def clear(self):
"""
Clear nodes and edges in the graph.
If the Graph instance represents a sub graph, only those nodes and edges
will be removed.
"""
self.nodes.clear()
self.edges.clear()
# Reset node ID counter if the full grap... |
Clear nodes and edges in the graph.
If the Graph instance represents a sub graph, only those nodes and edges
will be removed.
| Clear nodes and edges in the graph.
If the Graph instance represents a sub graph, only those nodes and edges
will be removed. | [
"Clear",
"nodes",
"and",
"edges",
"in",
"the",
"graph",
".",
"If",
"the",
"Graph",
"instance",
"represents",
"a",
"sub",
"graph",
"only",
"those",
"nodes",
"and",
"edges",
"will",
"be",
"removed",
"."
] | def clear(self):
self.nodes.clear()
self.edges.clear()
if len(self) == len(self.origin):
self._nodeid = 0 | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"nodes",
".",
"clear",
"(",
")",
"self",
".",
"edges",
".",
"clear",
"(",
")",
"if",
"len",
"(",
"self",
")",
"==",
"len",
"(",
"self",
".",
"origin",
")",
":",
"self",
".",
"_nodeid",
"=",
... | Clear nodes and edges in the graph. | [
"Clear",
"nodes",
"and",
"edges",
"in",
"the",
"graph",
"."
] | [
"\"\"\"\n Clear nodes and edges in the graph.\n \n If the Graph instance represents a sub graph, only those nodes and edges\n will be removed.\n \"\"\"",
"# Reset node ID counter if the full graph is cleared"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | copy | <not_specific> | def copy(self, deep=True, copy_view=False):
"""
Return a (deep) copy of the graph
The copy method offers shallow and deep copy functionality for graphs
similar to Pythons building copy and deepcopy functions.
A shallow copy (python `copy`) will copy the class and its attributes... |
Return a (deep) copy of the graph
The copy method offers shallow and deep copy functionality for graphs
similar to Pythons building copy and deepcopy functions.
A shallow copy (python `copy`) will copy the class and its attributes
except for the nodes, edges, orm and origin ob... | Return a (deep) copy of the graph
The copy method offers shallow and deep copy functionality for graphs
similar to Pythons building copy and deepcopy functions.
A shallow copy (python `copy`) will copy the class and its attributes
except for the nodes, edges, orm and origin objects that are referenced.
As such the cop... | [
"Return",
"a",
"(",
"deep",
")",
"copy",
"of",
"the",
"graph",
"The",
"copy",
"method",
"offers",
"shallow",
"and",
"deep",
"copy",
"functionality",
"for",
"graphs",
"similar",
"to",
"Pythons",
"building",
"copy",
"and",
"deepcopy",
"functions",
".",
"A",
... | def copy(self, deep=True, copy_view=False):
base_cls = self._get_class_object()
if deep:
class_copy = base_cls()
class_copy.nodes.update(copy.deepcopy(self.nodes.to_dict(return_full=copy_view)))
if copy_view and self.nodes.is_view:
class_copy.nodes.set... | [
"def",
"copy",
"(",
"self",
",",
"deep",
"=",
"True",
",",
"copy_view",
"=",
"False",
")",
":",
"base_cls",
"=",
"self",
".",
"_get_class_object",
"(",
")",
"if",
"deep",
":",
"class_copy",
"=",
"base_cls",
"(",
")",
"class_copy",
".",
"nodes",
".",
... | Return a (deep) copy of the graph
The copy method offers shallow and deep copy functionality for graphs
similar to Pythons building copy and deepcopy functions. | [
"Return",
"a",
"(",
"deep",
")",
"copy",
"of",
"the",
"graph",
"The",
"copy",
"method",
"offers",
"shallow",
"and",
"deep",
"copy",
"functionality",
"for",
"graphs",
"similar",
"to",
"Pythons",
"building",
"copy",
"and",
"deepcopy",
"functions",
"."
] | [
"\"\"\"\n Return a (deep) copy of the graph\n\n The copy method offers shallow and deep copy functionality for graphs\n similar to Pythons building copy and deepcopy functions.\n\n A shallow copy (python `copy`) will copy the class and its attributes\n except for the nodes, edges,... | [
{
"param": "self",
"type": null
},
{
"param": "deep",
"type": null
},
{
"param": "copy_view",
"type": null
}
] | {
"returns": [
{
"docstring": "copy of the graph",
"docstring_tokens": [
"copy",
"of",
"the",
"graph"
],
"type": "Graph object"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"doc... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | insert | null | def insert(self, node, between):
"""
Insert a new node in between two other
:param node: node to add
:param between: nodes to add new node in between
"""
if len(between) > 2:
raise Exception('Insert is only able to insert between two nodes... |
Insert a new node in between two other
:param node: node to add
:param between: nodes to add new node in between
| Insert a new node in between two other | [
"Insert",
"a",
"new",
"node",
"in",
"between",
"two",
"other"
] | def insert(self, node, between):
if len(between) > 2:
raise Exception('Insert is only able to insert between two nodes')
if nodes_are_interconnected(self, between):
nid = self.add_node(node)
for n in between:
self.add_edge(nid, n)
del self.... | [
"def",
"insert",
"(",
"self",
",",
"node",
",",
"between",
")",
":",
"if",
"len",
"(",
"between",
")",
">",
"2",
":",
"raise",
"Exception",
"(",
"'Insert is only able to insert between two nodes'",
")",
"if",
"nodes_are_interconnected",
"(",
"self",
",",
"betw... | Insert a new node in between two other | [
"Insert",
"a",
"new",
"node",
"in",
"between",
"two",
"other"
] | [
"\"\"\"\n Insert a new node in between two other\n \n :param node: node to add\n :param between: nodes to add new node in between\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": null
},
{
"param": "between",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": null,
"docstring": "node to add",
"docstring_t... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | iteredges | null | def iteredges(self, orm_cls=None, reverse=False, sort_key=str):
"""
Graph edge iterator
Returns a new graph view object for the given edge and it's nodes.
:param orm_cls: custom classes to construct new Graph class from for
every edge that is r... |
Graph edge iterator
Returns a new graph view object for the given edge and it's nodes.
:param orm_cls: custom classes to construct new Graph class from for
every edge that is returned
:type orm_cls: list
:param reverse: switch betwe... | Graph edge iterator
Returns a new graph view object for the given edge and it's nodes. | [
"Graph",
"edge",
"iterator",
"Returns",
"a",
"new",
"graph",
"view",
"object",
"for",
"the",
"given",
"edge",
"and",
"it",
"'",
"s",
"nodes",
"."
] | def iteredges(self, orm_cls=None, reverse=False, sort_key=str):
for edge in sorted(self.edges.keys(), reverse=reverse, key=sort_key):
yield self.getedges(edge, orm_cls=orm_cls) | [
"def",
"iteredges",
"(",
"self",
",",
"orm_cls",
"=",
"None",
",",
"reverse",
"=",
"False",
",",
"sort_key",
"=",
"str",
")",
":",
"for",
"edge",
"in",
"sorted",
"(",
"self",
".",
"edges",
".",
"keys",
"(",
")",
",",
"reverse",
"=",
"reverse",
",",... | Graph edge iterator
Returns a new graph view object for the given edge and it's nodes. | [
"Graph",
"edge",
"iterator",
"Returns",
"a",
"new",
"graph",
"view",
"object",
"for",
"the",
"given",
"edge",
"and",
"it",
"'",
"s",
"nodes",
"."
] | [
"\"\"\"\n Graph edge iterator\n \n Returns a new graph view object for the given edge and it's nodes.\n \n :param orm_cls: custom classes to construct new Graph class from for\n every edge that is returned\n :type orm_cls: list\n :param rev... | [
{
"param": "self",
"type": null
},
{
"param": "orm_cls",
"type": null
},
{
"param": "reverse",
"type": null
},
{
"param": "sort_key",
"type": null
}
] | {
"returns": [
{
"docstring": "single edge Graph object",
"docstring_tokens": [
"single",
"edge",
"Graph",
"object"
],
"type": ":graphit:Graph"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": ... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | iternodes | null | def iternodes(self, orm_cls=None, reverse=False, sort_key=str):
"""
Graph node iterator
Returns a new graph view object for the given node and it's edges.
The dynamically created object contains additional node tools.
Nodes are returned in node ID sorted order.
... |
Graph node iterator
Returns a new graph view object for the given node and it's edges.
The dynamically created object contains additional node tools.
Nodes are returned in node ID sorted order.
:param orm_cls: custom classes to construct new Graph class from for
... | Graph node iterator
Returns a new graph view object for the given node and it's edges.
The dynamically created object contains additional node tools.
Nodes are returned in node ID sorted order. | [
"Graph",
"node",
"iterator",
"Returns",
"a",
"new",
"graph",
"view",
"object",
"for",
"the",
"given",
"node",
"and",
"it",
"'",
"s",
"edges",
".",
"The",
"dynamically",
"created",
"object",
"contains",
"additional",
"node",
"tools",
".",
"Nodes",
"are",
"r... | def iternodes(self, orm_cls=None, reverse=False, sort_key=str):
for node in sorted(self.nodes.keys(), reverse=reverse, key=sort_key):
yield self.getnodes(node, orm_cls=orm_cls) | [
"def",
"iternodes",
"(",
"self",
",",
"orm_cls",
"=",
"None",
",",
"reverse",
"=",
"False",
",",
"sort_key",
"=",
"str",
")",
":",
"for",
"node",
"in",
"sorted",
"(",
"self",
".",
"nodes",
".",
"keys",
"(",
")",
",",
"reverse",
"=",
"reverse",
",",... | Graph node iterator
Returns a new graph view object for the given node and it's edges. | [
"Graph",
"node",
"iterator",
"Returns",
"a",
"new",
"graph",
"view",
"object",
"for",
"the",
"given",
"node",
"and",
"it",
"'",
"s",
"edges",
"."
] | [
"\"\"\"\n Graph node iterator\n \n Returns a new graph view object for the given node and it's edges.\n The dynamically created object contains additional node tools.\n Nodes are returned in node ID sorted order.\n\n :param orm_cls: custom classes to construct new Graph cl... | [
{
"param": "self",
"type": null
},
{
"param": "orm_cls",
"type": null
},
{
"param": "reverse",
"type": null
},
{
"param": "sort_key",
"type": null
}
] | {
"returns": [
{
"docstring": "single node Graph object",
"docstring_tokens": [
"single",
"node",
"Graph",
"object"
],
"type": ":graphit:Graph"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": ... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | query_edges | <not_specific> | def query_edges(self, query=None, orm_cls=None, **kwargs):
"""
Select nodes and edges based on edge data query
:param query: dictionary of edge data key/value pairs to query on
:type query: dict
:param orm_cls: custom classes to construct new Graph class from.
... |
Select nodes and edges based on edge data query
:param query: dictionary of edge data key/value pairs to query on
:type query: dict
:param orm_cls: custom classes to construct new Graph class from.
:type orm_cls: list
| Select nodes and edges based on edge data query | [
"Select",
"nodes",
"and",
"edges",
"based",
"on",
"edge",
"data",
"query"
] | def query_edges(self, query=None, orm_cls=None, **kwargs):
query_set = []
if isinstance(query, dict):
query_set.extend(query.items())
query_set.extend(kwargs.items())
query_set = set(query_set)
edges = []
for edge, attr in self.edges.items():
if al... | [
"def",
"query_edges",
"(",
"self",
",",
"query",
"=",
"None",
",",
"orm_cls",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"query_set",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"query",
",",
"dict",
")",
":",
"query_set",
".",
"extend",
"(",
"query",
... | Select nodes and edges based on edge data query | [
"Select",
"nodes",
"and",
"edges",
"based",
"on",
"edge",
"data",
"query"
] | [
"\"\"\"\n Select nodes and edges based on edge data query\n \n :param query: dictionary of edge data key/value pairs to query on\n :type query: dict\n :param orm_cls: custom classes to construct new Graph class from.\n :type orm_cls: list\n \"\"\"",
"# Build ... | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "orm_cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": "dictionary of edge data key/val... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | query_nodes | <not_specific> | def query_nodes(self, query=None, orm_cls=None, **kwargs):
"""
Select nodes and edges based on node data query
The `getnodes` method is called for the nodes matching the query
:param query: dictionary of node data key/value pairs to query
:type query: dict
... |
Select nodes and edges based on node data query
The `getnodes` method is called for the nodes matching the query
:param query: dictionary of node data key/value pairs to query
:type query: dict
:param orm_cls: custom classes to construct new Graph class fr... | Select nodes and edges based on node data query
The `getnodes` method is called for the nodes matching the query | [
"Select",
"nodes",
"and",
"edges",
"based",
"on",
"node",
"data",
"query",
"The",
"`",
"getnodes",
"`",
"method",
"is",
"called",
"for",
"the",
"nodes",
"matching",
"the",
"query"
] | def query_nodes(self, query=None, orm_cls=None, **kwargs):
query_set = []
if isinstance(query, dict):
query_set.extend(query.items())
query_set.extend(kwargs.items())
query_set = set(query_set)
nodes = []
for node, attr in self.nodes.items():
if al... | [
"def",
"query_nodes",
"(",
"self",
",",
"query",
"=",
"None",
",",
"orm_cls",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"query_set",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"query",
",",
"dict",
")",
":",
"query_set",
".",
"extend",
"(",
"query",
... | Select nodes and edges based on node data query
The `getnodes` method is called for the nodes matching the query | [
"Select",
"nodes",
"and",
"edges",
"based",
"on",
"node",
"data",
"query",
"The",
"`",
"getnodes",
"`",
"method",
"is",
"called",
"for",
"the",
"nodes",
"matching",
"the",
"query"
] | [
"\"\"\"\n Select nodes and edges based on node data query\n \n The `getnodes` method is called for the nodes matching the query\n \n :param query: dictionary of node data key/value pairs to query\n :type query: dict\n :param orm_cls: custom classes to construct ... | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "orm_cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": "dictionary of node data key/val... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | remove_edge | null | def remove_edge(self, nd1, nd2, directed=None):
"""
Removing an edge from the graph
Checks if the graph contains the edge, then removes it. If the graph is
undirectional, try to remove both edges of the undirectional pair.
Force directed removal of the edge using the 'di... |
Removing an edge from the graph
Checks if the graph contains the edge, then removes it. If the graph is
undirectional, try to remove both edges of the undirectional pair.
Force directed removal of the edge using the 'directed' argument.
Useful in mixed (un)-directional ... | Removing an edge from the graph
Checks if the graph contains the edge, then removes it. If the graph is
undirectional, try to remove both edges of the undirectional pair.
Force directed removal of the edge using the 'directed' argument.
Useful in mixed (un)-directional graphs.
If the graph is a (sub)graph representing... | [
"Removing",
"an",
"edge",
"from",
"the",
"graph",
"Checks",
"if",
"the",
"graph",
"contains",
"the",
"edge",
"then",
"removes",
"it",
".",
"If",
"the",
"graph",
"is",
"undirectional",
"try",
"to",
"remove",
"both",
"edges",
"of",
"the",
"undirectional",
"p... | def remove_edge(self, nd1, nd2, directed=None):
if not isinstance(directed, bool):
directed = self.directed
for edge in make_edges((nd1, nd2), directed=directed):
if edge in self.edges:
del self.edges[edge]
logger.debug('Removed edge {0} from graph... | [
"def",
"remove_edge",
"(",
"self",
",",
"nd1",
",",
"nd2",
",",
"directed",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"directed",
",",
"bool",
")",
":",
"directed",
"=",
"self",
".",
"directed",
"for",
"edge",
"in",
"make_edges",
"(",
"(... | Removing an edge from the graph
Checks if the graph contains the edge, then removes it. | [
"Removing",
"an",
"edge",
"from",
"the",
"graph",
"Checks",
"if",
"the",
"graph",
"contains",
"the",
"edge",
"then",
"removes",
"it",
"."
] | [
"\"\"\"\n Removing an edge from the graph\n \n Checks if the graph contains the edge, then removes it. If the graph is\n undirectional, try to remove both edges of the undirectional pair.\n Force directed removal of the edge using the 'directed' argument.\n Useful in mixed ... | [
{
"param": "self",
"type": null
},
{
"param": "nd1",
"type": null
},
{
"param": "nd2",
"type": null
},
{
"param": "directed",
"type": null
}
] | {
"returns": [],
"raises": [
{
"docstring": "GraphitException, if edge not in graph",
"docstring_tokens": [
"GraphitException",
"if",
"edge",
"not",
"in",
"graph"
],
"type": null
}
],
"params": [
{
"identifier": "self",
... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | remove_edges | null | def remove_edges(self, edges, directed=None):
"""
Remove multiple edges from the graph.
This is the iterable version of the remove_edge methods allowing
mutliple edge removal from any iterable.
:param edges: Iterable of edges to remove
:type edges: ... |
Remove multiple edges from the graph.
This is the iterable version of the remove_edge methods allowing
mutliple edge removal from any iterable.
:param edges: Iterable of edges to remove
:type edges: Iterable of edges defined as tuples of two node ID's
... | Remove multiple edges from the graph.
This is the iterable version of the remove_edge methods allowing
mutliple edge removal from any iterable. | [
"Remove",
"multiple",
"edges",
"from",
"the",
"graph",
".",
"This",
"is",
"the",
"iterable",
"version",
"of",
"the",
"remove_edge",
"methods",
"allowing",
"mutliple",
"edge",
"removal",
"from",
"any",
"iterable",
"."
] | def remove_edges(self, edges, directed=None):
for edge in edges:
self.remove_edge(*edge, directed=directed) | [
"def",
"remove_edges",
"(",
"self",
",",
"edges",
",",
"directed",
"=",
"None",
")",
":",
"for",
"edge",
"in",
"edges",
":",
"self",
".",
"remove_edge",
"(",
"*",
"edge",
",",
"directed",
"=",
"directed",
")"
] | Remove multiple edges from the graph. | [
"Remove",
"multiple",
"edges",
"from",
"the",
"graph",
"."
] | [
"\"\"\"\n Remove multiple edges from the graph.\n \n This is the iterable version of the remove_edge methods allowing\n mutliple edge removal from any iterable.\n \n :param edges: Iterable of edges to remove\n :type edges: Iterable of edges defined as tuples... | [
{
"param": "self",
"type": null
},
{
"param": "edges",
"type": null
},
{
"param": "directed",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "edges",
"type": null,
"docstring": "Iterable of edges to remove",
... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | remove_node | null | def remove_node(self, node):
"""
Removing a node from the graph
Checks if the graph contains the node and if the node is connected with
edges. Removes the node and associated edges.
If the graph is a (sub)graph representing a `view` on the origin graph,
the node... |
Removing a node from the graph
Checks if the graph contains the node and if the node is connected with
edges. Removes the node and associated edges.
If the graph is a (sub)graph representing a `view` on the origin graph,
the node is removed from the view and not from t... | Removing a node from the graph
Checks if the graph contains the node and if the node is connected with
edges. Removes the node and associated edges.
If the graph is a (sub)graph representing a `view` on the origin graph,
the node is removed from the view and not from the origin. | [
"Removing",
"a",
"node",
"from",
"the",
"graph",
"Checks",
"if",
"the",
"graph",
"contains",
"the",
"node",
"and",
"if",
"the",
"node",
"is",
"connected",
"with",
"edges",
".",
"Removes",
"the",
"node",
"and",
"associated",
"edges",
".",
"If",
"the",
"gr... | def remove_node(self, node):
if node in self.nodes:
edges = [edge for edge in self.edges if node in edge]
for edge in edges:
del self.edges[edge]
del self.nodes[node]
msg = 'Removed node {0} with {1} connecting edges from graph'
logger.... | [
"def",
"remove_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
"in",
"self",
".",
"nodes",
":",
"edges",
"=",
"[",
"edge",
"for",
"edge",
"in",
"self",
".",
"edges",
"if",
"node",
"in",
"edge",
"]",
"for",
"edge",
"in",
"edges",
":",
"de... | Removing a node from the graph
Checks if the graph contains the node and if the node is connected with
edges. | [
"Removing",
"a",
"node",
"from",
"the",
"graph",
"Checks",
"if",
"the",
"graph",
"contains",
"the",
"node",
"and",
"if",
"the",
"node",
"is",
"connected",
"with",
"edges",
"."
] | [
"\"\"\"\n Removing a node from the graph\n \n Checks if the graph contains the node and if the node is connected with\n edges. Removes the node and associated edges.\n\n If the graph is a (sub)graph representing a `view` on the origin graph,\n the node is removed from the v... | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": null,
"docstring": "Node to remove",
"docstrin... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | items | <not_specific> | def items(self, keystring=None, valuestring=None):
"""
Python dict-like function to return node items in the (sub)graph.
Keystring defines the value lookup key in the node data dict.
This defaults to the graph key_tag.
Valuestring defines the value lookup key in the node data di... |
Python dict-like function to return node items in the (sub)graph.
Keystring defines the value lookup key in the node data dict.
This defaults to the graph key_tag.
Valuestring defines the value lookup key in the node data dict.
:param keystring: Data key to use for dictionar... | Python dict-like function to return node items in the (sub)graph.
Keystring defines the value lookup key in the node data dict.
This defaults to the graph key_tag.
Valuestring defines the value lookup key in the node data dict. | [
"Python",
"dict",
"-",
"like",
"function",
"to",
"return",
"node",
"items",
"in",
"the",
"(",
"sub",
")",
"graph",
".",
"Keystring",
"defines",
"the",
"value",
"lookup",
"key",
"in",
"the",
"node",
"data",
"dict",
".",
"This",
"defaults",
"to",
"the",
... | def items(self, keystring=None, valuestring=None):
keystring = keystring or self.key_tag
valuestring = valuestring or self.value_tag
return [(n.get(keystring), n.get(valuestring)) for n in self.iternodes()] | [
"def",
"items",
"(",
"self",
",",
"keystring",
"=",
"None",
",",
"valuestring",
"=",
"None",
")",
":",
"keystring",
"=",
"keystring",
"or",
"self",
".",
"key_tag",
"valuestring",
"=",
"valuestring",
"or",
"self",
".",
"value_tag",
"return",
"[",
"(",
"n"... | Python dict-like function to return node items in the (sub)graph. | [
"Python",
"dict",
"-",
"like",
"function",
"to",
"return",
"node",
"items",
"in",
"the",
"(",
"sub",
")",
"graph",
"."
] | [
"\"\"\"\n Python dict-like function to return node items in the (sub)graph.\n\n Keystring defines the value lookup key in the node data dict.\n This defaults to the graph key_tag.\n Valuestring defines the value lookup key in the node data dict.\n\n :param keystring: Data key to... | [
{
"param": "self",
"type": null
},
{
"param": "keystring",
"type": null
},
{
"param": "valuestring",
"type": null
}
] | {
"returns": [
{
"docstring": "List of keys, value pairs",
"docstring_tokens": [
"List",
"of",
"keys",
"value",
"pairs"
],
"type": ":py:list"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstr... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | keys | <not_specific> | def keys(self, keystring=None):
"""
Python dict-like function to return node keys in the (sub)graph.
Keystring defines the value lookup key in the node data dict.
This defaults to the graph key_tag.
:param keystring: Data key to use for dictionary keys.
:type keystrin... |
Python dict-like function to return node keys in the (sub)graph.
Keystring defines the value lookup key in the node data dict.
This defaults to the graph key_tag.
:param keystring: Data key to use for dictionary keys.
:type keystring: :py:str
:return: ... | Python dict-like function to return node keys in the (sub)graph.
Keystring defines the value lookup key in the node data dict.
This defaults to the graph key_tag. | [
"Python",
"dict",
"-",
"like",
"function",
"to",
"return",
"node",
"keys",
"in",
"the",
"(",
"sub",
")",
"graph",
".",
"Keystring",
"defines",
"the",
"value",
"lookup",
"key",
"in",
"the",
"node",
"data",
"dict",
".",
"This",
"defaults",
"to",
"the",
"... | def keys(self, keystring=None):
keystring = keystring or self.key_tag
return [n.get(keystring) for n in self.iternodes()] | [
"def",
"keys",
"(",
"self",
",",
"keystring",
"=",
"None",
")",
":",
"keystring",
"=",
"keystring",
"or",
"self",
".",
"key_tag",
"return",
"[",
"n",
".",
"get",
"(",
"keystring",
")",
"for",
"n",
"in",
"self",
".",
"iternodes",
"(",
")",
"]"
] | Python dict-like function to return node keys in the (sub)graph. | [
"Python",
"dict",
"-",
"like",
"function",
"to",
"return",
"node",
"keys",
"in",
"the",
"(",
"sub",
")",
"graph",
"."
] | [
"\"\"\"\n Python dict-like function to return node keys in the (sub)graph.\n\n Keystring defines the value lookup key in the node data dict.\n This defaults to the graph key_tag.\n\n :param keystring: Data key to use for dictionary keys.\n :type keystring: :py:str\n\n ... | [
{
"param": "self",
"type": null
},
{
"param": "keystring",
"type": null
}
] | {
"returns": [
{
"docstring": "List of keys",
"docstring_tokens": [
"List",
"of",
"keys"
],
"type": ":py:list"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
c515cff2af1a8cbd911c6b5071cc31770ecfd274 | codacy-badger/graphit | graphit/graph.py | [
"Apache-2.0"
] | Python | values | <not_specific> | def values(self, valuestring=None):
"""
Python dict-like function to return node values in the (sub)graph.
Valuestring defines the value lookup key in the node data dict.
:param valuestring: Data key to use for dictionary values.
:type valuestring: :py:str
:return: ... |
Python dict-like function to return node values in the (sub)graph.
Valuestring defines the value lookup key in the node data dict.
:param valuestring: Data key to use for dictionary values.
:type valuestring: :py:str
:return: List of values
:rtype: ... | Python dict-like function to return node values in the (sub)graph.
Valuestring defines the value lookup key in the node data dict. | [
"Python",
"dict",
"-",
"like",
"function",
"to",
"return",
"node",
"values",
"in",
"the",
"(",
"sub",
")",
"graph",
".",
"Valuestring",
"defines",
"the",
"value",
"lookup",
"key",
"in",
"the",
"node",
"data",
"dict",
"."
] | def values(self, valuestring=None):
valuestring = valuestring or self.value_tag
return [n.get(valuestring) for n in self.iternodes()] | [
"def",
"values",
"(",
"self",
",",
"valuestring",
"=",
"None",
")",
":",
"valuestring",
"=",
"valuestring",
"or",
"self",
".",
"value_tag",
"return",
"[",
"n",
".",
"get",
"(",
"valuestring",
")",
"for",
"n",
"in",
"self",
".",
"iternodes",
"(",
")",
... | Python dict-like function to return node values in the (sub)graph. | [
"Python",
"dict",
"-",
"like",
"function",
"to",
"return",
"node",
"values",
"in",
"the",
"(",
"sub",
")",
"graph",
"."
] | [
"\"\"\"\n Python dict-like function to return node values in the (sub)graph.\n\n Valuestring defines the value lookup key in the node data dict.\n\n :param valuestring: Data key to use for dictionary values.\n :type valuestring: :py:str\n\n :return: List of values\n ... | [
{
"param": "self",
"type": null
},
{
"param": "valuestring",
"type": null
}
] | {
"returns": [
{
"docstring": "List of values",
"docstring_tokens": [
"List",
"of",
"values"
],
"type": ":py:list"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
c145e06a59951f02930e87a6177613f24d3d6330 | polyg314/streamlit-drawable-canvas | setup.py | [
"MIT"
] | Python | readme | str | def readme() -> str:
"""Utility function to read the README file.
Used for the long_description. It's nice, because now 1) we have a top
level README file and 2) it's easier to type in the README file than to put
a raw string in below.
:return: content of README.md
"""
return open(join(dirn... | Utility function to read the README file.
Used for the long_description. It's nice, because now 1) we have a top
level README file and 2) it's easier to type in the README file than to put
a raw string in below.
:return: content of README.md
| Utility function to read the README file.
Used for the long_description. It's nice, because now 1) we have a top
level README file and 2) it's easier to type in the README file than to put
a raw string in below. | [
"Utility",
"function",
"to",
"read",
"the",
"README",
"file",
".",
"Used",
"for",
"the",
"long_description",
".",
"It",
"'",
"s",
"nice",
"because",
"now",
"1",
")",
"we",
"have",
"a",
"top",
"level",
"README",
"file",
"and",
"2",
")",
"it",
"'",
"s"... | def readme() -> str:
return open(join(dirname(__file__), "README.md")).read() | [
"def",
"readme",
"(",
")",
"->",
"str",
":",
"return",
"open",
"(",
"join",
"(",
"dirname",
"(",
"__file__",
")",
",",
"\"README.md\"",
")",
")",
".",
"read",
"(",
")"
] | Utility function to read the README file. | [
"Utility",
"function",
"to",
"read",
"the",
"README",
"file",
"."
] | [
"\"\"\"Utility function to read the README file.\n Used for the long_description. It's nice, because now 1) we have a top\n level README file and 2) it's easier to type in the README file than to put\n a raw string in below.\n :return: content of README.md\n \"\"\""
] | [] | {
"returns": [
{
"docstring": "content of README.md",
"docstring_tokens": [
"content",
"of",
"README",
".",
"md"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
976b99486672be4e8c2cd85217cf0a464f71796b | polyg314/streamlit-drawable-canvas | streamlit_drawable_canvas/__init__.py | [
"MIT"
] | Python | _resize_img | Image | def _resize_img(img: Image, new_height: int = 700, new_width: int = 700) -> Image:
"""Resize the image to the provided resolution."""
h_ratio = new_height / img.height
w_ratio = new_width / img.width
img = img.resize((int(img.width * w_ratio), int(img.height * h_ratio)))
return img | Resize the image to the provided resolution. | Resize the image to the provided resolution. | [
"Resize",
"the",
"image",
"to",
"the",
"provided",
"resolution",
"."
] | def _resize_img(img: Image, new_height: int = 700, new_width: int = 700) -> Image:
h_ratio = new_height / img.height
w_ratio = new_width / img.width
img = img.resize((int(img.width * w_ratio), int(img.height * h_ratio)))
return img | [
"def",
"_resize_img",
"(",
"img",
":",
"Image",
",",
"new_height",
":",
"int",
"=",
"700",
",",
"new_width",
":",
"int",
"=",
"700",
")",
"->",
"Image",
":",
"h_ratio",
"=",
"new_height",
"/",
"img",
".",
"height",
"w_ratio",
"=",
"new_width",
"/",
"... | Resize the image to the provided resolution. | [
"Resize",
"the",
"image",
"to",
"the",
"provided",
"resolution",
"."
] | [
"\"\"\"Resize the image to the provided resolution.\"\"\""
] | [
{
"param": "img",
"type": "Image"
},
{
"param": "new_height",
"type": "int"
},
{
"param": "new_width",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "img",
"type": "Image",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_height",
"type": "int",
"docstring": null,
"docstring_t... |
c16ddebeae708e6c8925608cba1db097f6fcd810 | samuraitaiga/mt4_buildscript | dodo.py | [
"Apache-2.0"
] | Python | task_create_product | <not_specific> | def task_create_product():
"archive eas and libs for mt4"
abs_build_dir = os.path.abspath(BUILD_DIR)
product = os.path.join(BUILD_DIR, 'eas.zip')
if not os.path.exists(abs_build_dir):
os.mkdir(abs_build_dir)
return {'actions': [archive_folder],
'targets': [product],
... | archive eas and libs for mt4 | archive eas and libs for mt4 | [
"archive",
"eas",
"and",
"libs",
"for",
"mt4"
] | def task_create_product():
abs_build_dir = os.path.abspath(BUILD_DIR)
product = os.path.join(BUILD_DIR, 'eas.zip')
if not os.path.exists(abs_build_dir):
os.mkdir(abs_build_dir)
return {'actions': [archive_folder],
'targets': [product],
'task_dep': ['build_installer'],
... | [
"def",
"task_create_product",
"(",
")",
":",
"abs_build_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"BUILD_DIR",
")",
"product",
"=",
"os",
".",
"path",
".",
"join",
"(",
"BUILD_DIR",
",",
"'eas.zip'",
")",
"if",
"not",
"os",
".",
"path",
".",
... | archive eas and libs for mt4 | [
"archive",
"eas",
"and",
"libs",
"for",
"mt4"
] | [
"\"archive eas and libs for mt4\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d9d7af6ac8788ce88de458abaad3810a5f190259 | jsrimr/single-path-nas | nas-search/supernet_macro.py | [
"Apache-2.0"
] | Python | _decode_block_string | <not_specific> | def _decode_block_string(self, block_string):
"""Gets a block through a string notation of arguments.
E.g. r2_k3_s2_e1_i32_o16_se0.25_noskip: r - number of repeat blocks,
k - kernel size, s - strides (1-9), e - expansion ratio, i - input filters,
o - output filters, se - squeeze/excitation ratio
A... | Gets a block through a string notation of arguments.
E.g. r2_k3_s2_e1_i32_o16_se0.25_noskip: r - number of repeat blocks,
k - kernel size, s - strides (1-9), e - expansion ratio, i - input filters,
o - output filters, se - squeeze/excitation ratio
Args:
block_string: a string, a string represent... | Gets a block through a string notation of arguments. | [
"Gets",
"a",
"block",
"through",
"a",
"string",
"notation",
"of",
"arguments",
"."
] | def _decode_block_string(self, block_string):
assert isinstance(block_string, str)
ops = block_string.split('_')
options = {}
for op in ops:
splits = re.split(r'(\d.*)', op)
if len(splits) >= 2:
key, value = splits[:2]
options[key] = value
if 's' not in options or len(opt... | [
"def",
"_decode_block_string",
"(",
"self",
",",
"block_string",
")",
":",
"assert",
"isinstance",
"(",
"block_string",
",",
"str",
")",
"ops",
"=",
"block_string",
".",
"split",
"(",
"'_'",
")",
"options",
"=",
"{",
"}",
"for",
"op",
"in",
"ops",
":",
... | Gets a block through a string notation of arguments. | [
"Gets",
"a",
"block",
"through",
"a",
"string",
"notation",
"of",
"arguments",
"."
] | [
"\"\"\"Gets a block through a string notation of arguments.\n\n E.g. r2_k3_s2_e1_i32_o16_se0.25_noskip: r - number of repeat blocks,\n k - kernel size, s - strides (1-9), e - expansion ratio, i - input filters,\n o - output filters, se - squeeze/excitation ratio\n\n Args:\n block_string: a string, ... | [
{
"param": "self",
"type": null
},
{
"param": "block_string",
"type": null
}
] | {
"returns": [
{
"docstring": "A BlockArgs instance.",
"docstring_tokens": [
"A",
"BlockArgs",
"instance",
"."
],
"type": null
}
],
"raises": [
{
"docstring": "if the strides option is not correctly specified.",
"docstring_tokens": [
... |
d9d7af6ac8788ce88de458abaad3810a5f190259 | jsrimr/single-path-nas | nas-search/supernet_macro.py | [
"Apache-2.0"
] | Python | single_path_search | <not_specific> | def single_path_search(depth_multiplier=None):
"""Creates a single-path supermodel for search:
See Fig.2 in paper:
-- 1st and last blocks have 1 MBConv set
-- The rest 20 blocks have 4 MBConv searchable layers
Args:
depth_multiplier: multiplier to number of filters per layer.
Returns:
... | Creates a single-path supermodel for search:
See Fig.2 in paper:
-- 1st and last blocks have 1 MBConv set
-- The rest 20 blocks have 4 MBConv searchable layers
Args:
depth_multiplier: multiplier to number of filters per layer.
Returns:
blocks_args: a list of BlocksArgs for internal Mnas... | Creates a single-path supermodel for search:
See Fig.2 in paper:
1st and last blocks have 1 MBConv set
The rest 20 blocks have 4 MBConv searchable layers | [
"Creates",
"a",
"single",
"-",
"path",
"supermodel",
"for",
"search",
":",
"See",
"Fig",
".",
"2",
"in",
"paper",
":",
"1st",
"and",
"last",
"blocks",
"have",
"1",
"MBConv",
"set",
"The",
"rest",
"20",
"blocks",
"have",
"4",
"MBConv",
"searchable",
"la... | def single_path_search(depth_multiplier=None):
blocks_args = [
'r1_k3_s11_e1_i32_o16_noskip',
'r4_k5_s22_e6_i16_o24',
'r4_k5_s22_e6_i24_o40',
'r4_k5_s22_e6_i40_o80',
'r4_k5_s11_e6_i80_o96',
'r4_k5_s22_e6_i96_o192',
'r1_k3_s11_e6_i192_o320_noskip'
]
global_params = sing... | [
"def",
"single_path_search",
"(",
"depth_multiplier",
"=",
"None",
")",
":",
"blocks_args",
"=",
"[",
"'r1_k3_s11_e1_i32_o16_noskip'",
",",
"'r4_k5_s22_e6_i16_o24'",
",",
"'r4_k5_s22_e6_i24_o40'",
",",
"'r4_k5_s22_e6_i40_o80'",
",",
"'r4_k5_s11_e6_i80_o96'",
",",
"'r4_k5_s2... | Creates a single-path supermodel for search:
See Fig.2 in paper:
1st and last blocks have 1 MBConv set
The rest 20 blocks have 4 MBConv searchable layers | [
"Creates",
"a",
"single",
"-",
"path",
"supermodel",
"for",
"search",
":",
"See",
"Fig",
".",
"2",
"in",
"paper",
":",
"1st",
"and",
"last",
"blocks",
"have",
"1",
"MBConv",
"set",
"The",
"rest",
"20",
"blocks",
"have",
"4",
"MBConv",
"searchable",
"la... | [
"\"\"\"Creates a single-path supermodel for search:\n See Fig.2 in paper:\n -- 1st and last blocks have 1 MBConv set\n -- The rest 20 blocks have 4 MBConv searchable layers\n\n Args:\n depth_multiplier: multiplier to number of filters per layer.\n\n Returns:\n blocks_args: a list of BlocksAr... | [
{
"param": "depth_multiplier",
"type": null
}
] | {
"returns": [
{
"docstring": "a list of BlocksArgs for internal MnasNet blocks.\nglobal_params: GlobalParams, global parameters for the model.",
"docstring_tokens": [
"a",
"list",
"of",
"BlocksArgs",
"for",
"internal",
"MnasNet",
"blocks... |
d9d7af6ac8788ce88de458abaad3810a5f190259 | jsrimr/single-path-nas | nas-search/supernet_macro.py | [
"Apache-2.0"
] | Python | build_supernet | <not_specific> | def build_supernet(images, model_name, training, override_params=None, dropout_rate=None):
"""A helper function to creates the NAS Supernet and returns predicted logits.
Args:
images: input images tensor.
model_name: string, the model name
training: boolean, whether the model is constructed for trainin... | A helper function to creates the NAS Supernet and returns predicted logits.
Args:
images: input images tensor.
model_name: string, the model name
training: boolean, whether the model is constructed for training.
override_params: A dictionary of params for overriding. Fields must exist in
single... | A helper function to creates the NAS Supernet and returns predicted logits.
Args:
images: input images tensor.
model_name: string, the model name
training: boolean, whether the model is constructed for training.
override_params: A dictionary of params for overriding.
the logits tensor of classes.
runtime: the total ru... | [
"A",
"helper",
"function",
"to",
"creates",
"the",
"NAS",
"Supernet",
"and",
"returns",
"predicted",
"logits",
".",
"Args",
":",
"images",
":",
"input",
"images",
"tensor",
".",
"model_name",
":",
"string",
"the",
"model",
"name",
"training",
":",
"boolean",... | def build_supernet(images, model_name, training, override_params=None, dropout_rate=None):
assert isinstance(images, tf.Tensor)
if model_name == 'single-path-search':
blocks_args, global_params = single_path_search()
else:
raise NotImplementedError('model name is not pre-defined: %s' % model_name)
if ov... | [
"def",
"build_supernet",
"(",
"images",
",",
"model_name",
",",
"training",
",",
"override_params",
"=",
"None",
",",
"dropout_rate",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"images",
",",
"tf",
".",
"Tensor",
")",
"if",
"model_name",
"==",
"'s... | A helper function to creates the NAS Supernet and returns predicted logits. | [
"A",
"helper",
"function",
"to",
"creates",
"the",
"NAS",
"Supernet",
"and",
"returns",
"predicted",
"logits",
"."
] | [
"\"\"\"A helper function to creates the NAS Supernet and returns predicted logits.\n\n Args:\n images: input images tensor.\n model_name: string, the model name\n training: boolean, whether the model is constructed for training.\n override_params: A dictionary of params for overriding. Fields must exis... | [
{
"param": "images",
"type": null
},
{
"param": "model_name",
"type": null
},
{
"param": "training",
"type": null
},
{
"param": "override_params",
"type": null
},
{
"param": "dropout_rate",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "images",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_name",
"type": null,
"docstring": null,
"docstring_to... |
75b28cd4070732da5aec1d25952dca4ad68940d0 | jsrimr/single-path-nas | runtime-modeling/model_def.py | [
"Apache-2.0"
] | Python | round_filters | <not_specific> | def round_filters(filters, global_params):
"""Round number of filters based on depth multiplier."""
multiplier = global_params.depth_multiplier
# dstam addition
if multiplier > 10:
multiplier = float(multiplier) / 100
divisor = global_params.depth_divisor
min_depth = global_params.min_depth
if not mu... | Round number of filters based on depth multiplier. | Round number of filters based on depth multiplier. | [
"Round",
"number",
"of",
"filters",
"based",
"on",
"depth",
"multiplier",
"."
] | def round_filters(filters, global_params):
multiplier = global_params.depth_multiplier
if multiplier > 10:
multiplier = float(multiplier) / 100
divisor = global_params.depth_divisor
min_depth = global_params.min_depth
if not multiplier:
return filters
filters *= multiplier
min_depth = min_depth or... | [
"def",
"round_filters",
"(",
"filters",
",",
"global_params",
")",
":",
"multiplier",
"=",
"global_params",
".",
"depth_multiplier",
"if",
"multiplier",
">",
"10",
":",
"multiplier",
"=",
"float",
"(",
"multiplier",
")",
"/",
"100",
"divisor",
"=",
"global_par... | Round number of filters based on depth multiplier. | [
"Round",
"number",
"of",
"filters",
"based",
"on",
"depth",
"multiplier",
"."
] | [
"\"\"\"Round number of filters based on depth multiplier.\"\"\"",
"# dstam addition",
"# Make sure that round down does not go down by more than 10%."
] | [
{
"param": "filters",
"type": null
},
{
"param": "global_params",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filters",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "global_params",
"type": null,
"docstring": null,
"docstrin... |
75b28cd4070732da5aec1d25952dca4ad68940d0 | jsrimr/single-path-nas | runtime-modeling/model_def.py | [
"Apache-2.0"
] | Python | _build | null | def _build(self):
"""Builds MnasNet block according to the arguments."""
filters = self._block_args.input_filters * self._block_args.expand_ratio
if self._block_args.expand_ratio != 1:
# Expansion phase:
self._expand_conv = tf.keras.layers.Conv2D(
filters,
kernel_size=[1, 1],... | Builds MnasNet block according to the arguments. | Builds MnasNet block according to the arguments. | [
"Builds",
"MnasNet",
"block",
"according",
"to",
"the",
"arguments",
"."
] | def _build(self):
filters = self._block_args.input_filters * self._block_args.expand_ratio
if self._block_args.expand_ratio != 1:
self._expand_conv = tf.keras.layers.Conv2D(
filters,
kernel_size=[1, 1],
strides=[1, 1],
kernel_initializer=conv_kernel_initializer,
... | [
"def",
"_build",
"(",
"self",
")",
":",
"filters",
"=",
"self",
".",
"_block_args",
".",
"input_filters",
"*",
"self",
".",
"_block_args",
".",
"expand_ratio",
"if",
"self",
".",
"_block_args",
".",
"expand_ratio",
"!=",
"1",
":",
"self",
".",
"_expand_con... | Builds MnasNet block according to the arguments. | [
"Builds",
"MnasNet",
"block",
"according",
"to",
"the",
"arguments",
"."
] | [
"\"\"\"Builds MnasNet block according to the arguments.\"\"\"",
"# Expansion phase:",
"# Depth-wise convolution phase:",
"# Squeeze and Excitation layer.",
"# Output phase:"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75b28cd4070732da5aec1d25952dca4ad68940d0 | jsrimr/single-path-nas | runtime-modeling/model_def.py | [
"Apache-2.0"
] | Python | _call_se | <not_specific> | def _call_se(self, input_tensor):
"""Call Squeeze and Excitation layer.
Args:
input_tensor: Tensor, a single input tensor for Squeeze/Excitation layer.
Returns:
A output tensor, which should have the same shape as input.
"""
se_tensor = tf.reduce_mean(input_tensor, self._spatial_dims, ... | Call Squeeze and Excitation layer.
Args:
input_tensor: Tensor, a single input tensor for Squeeze/Excitation layer.
Returns:
A output tensor, which should have the same shape as input.
| Call Squeeze and Excitation layer. | [
"Call",
"Squeeze",
"and",
"Excitation",
"layer",
"."
] | def _call_se(self, input_tensor):
se_tensor = tf.reduce_mean(input_tensor, self._spatial_dims, keepdims=True)
se_tensor = self._se_expand(tf.nn.relu(self._se_reduce(se_tensor)))
tf.logging.info('Built Squeeze and Excitation with tensor shape: %s' %
(se_tensor.shape))
return tf.sigmoi... | [
"def",
"_call_se",
"(",
"self",
",",
"input_tensor",
")",
":",
"se_tensor",
"=",
"tf",
".",
"reduce_mean",
"(",
"input_tensor",
",",
"self",
".",
"_spatial_dims",
",",
"keepdims",
"=",
"True",
")",
"se_tensor",
"=",
"self",
".",
"_se_expand",
"(",
"tf",
... | Call Squeeze and Excitation layer. | [
"Call",
"Squeeze",
"and",
"Excitation",
"layer",
"."
] | [
"\"\"\"Call Squeeze and Excitation layer.\n\n Args:\n input_tensor: Tensor, a single input tensor for Squeeze/Excitation layer.\n\n Returns:\n A output tensor, which should have the same shape as input.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "input_tensor",
"type": null
}
] | {
"returns": [
{
"docstring": "A output tensor, which should have the same shape as input.",
"docstring_tokens": [
"A",
"output",
"tensor",
"which",
"should",
"have",
"the",
"same",
"shape",
"as",
"input",
... |
75b28cd4070732da5aec1d25952dca4ad68940d0 | jsrimr/single-path-nas | runtime-modeling/model_def.py | [
"Apache-2.0"
] | Python | call | <not_specific> | def call(self, inputs, training=True):
"""Implementation of MnasBlock call().
Args:
inputs: the inputs tensor.
training: boolean, whether the model is constructed for training.
Returns:
A output tensor.
"""
tf.logging.info('Block input: %s shape: %s' % (inputs.name, inputs.shape)... | Implementation of MnasBlock call().
Args:
inputs: the inputs tensor.
training: boolean, whether the model is constructed for training.
Returns:
A output tensor.
| Implementation of MnasBlock call(). | [
"Implementation",
"of",
"MnasBlock",
"call",
"()",
"."
] | def call(self, inputs, training=True):
tf.logging.info('Block input: %s shape: %s' % (inputs.name, inputs.shape))
if self._block_args.expand_ratio != 1:
x = tf.nn.relu(self._bn0(self._expand_conv(inputs), training=training))
else:
x = inputs
tf.logging.info('Expand: %s shape: %s' % (x.name, ... | [
"def",
"call",
"(",
"self",
",",
"inputs",
",",
"training",
"=",
"True",
")",
":",
"tf",
".",
"logging",
".",
"info",
"(",
"'Block input: %s shape: %s'",
"%",
"(",
"inputs",
".",
"name",
",",
"inputs",
".",
"shape",
")",
")",
"if",
"self",
".",
"_blo... | Implementation of MnasBlock call(). | [
"Implementation",
"of",
"MnasBlock",
"call",
"()",
"."
] | [
"\"\"\"Implementation of MnasBlock call().\n\n Args:\n inputs: the inputs tensor.\n training: boolean, whether the model is constructed for training.\n\n Returns:\n A output tensor.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "inputs",
"type": null
},
{
"param": "training",
"type": null
}
] | {
"returns": [
{
"docstring": "A output tensor.",
"docstring_tokens": [
"A",
"output",
"tensor",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_toke... |
75b28cd4070732da5aec1d25952dca4ad68940d0 | jsrimr/single-path-nas | runtime-modeling/model_def.py | [
"Apache-2.0"
] | Python | call | <not_specific> | def call(self, inputs, training=True):
"""Implementation of MnasNetModel call().
Args:
inputs: input tensors.
training: boolean, whether the model is constructed for training.
Returns:
output tensors.
"""
outputs = None
self.endpoints = {}
# Calls Stem layers
with tf.... | Implementation of MnasNetModel call().
Args:
inputs: input tensors.
training: boolean, whether the model is constructed for training.
Returns:
output tensors.
| Implementation of MnasNetModel call(). | [
"Implementation",
"of",
"MnasNetModel",
"call",
"()",
"."
] | def call(self, inputs, training=True):
outputs = None
self.endpoints = {}
with tf.variable_scope('mnas_stem'):
outputs = tf.nn.relu(
self._bn0(self._conv_stem(inputs), training=training))
tf.logging.info('Built stem layers with output shape: %s' % outputs.shape)
self.endpoints['stem'... | [
"def",
"call",
"(",
"self",
",",
"inputs",
",",
"training",
"=",
"True",
")",
":",
"outputs",
"=",
"None",
"self",
".",
"endpoints",
"=",
"{",
"}",
"with",
"tf",
".",
"variable_scope",
"(",
"'mnas_stem'",
")",
":",
"outputs",
"=",
"tf",
".",
"nn",
... | Implementation of MnasNetModel call(). | [
"Implementation",
"of",
"MnasNetModel",
"call",
"()",
"."
] | [
"\"\"\"Implementation of MnasNetModel call().\n\n Args:\n inputs: input tensors.\n training: boolean, whether the model is constructed for training.\n\n Returns:\n output tensors.\n \"\"\"",
"# Calls Stem layers",
"# Calls blocks.",
"# Calls final layers and returns logits."
] | [
{
"param": "self",
"type": null
},
{
"param": "inputs",
"type": null
},
{
"param": "training",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
240fde4b81de9f6b6d47e708cfd28bbd1ab16795 | jsrimr/single-path-nas | nas-search/search_main.py | [
"Apache-2.0"
] | Python | host_call_fn | <not_specific> | def host_call_fn(gs, loss, lr, runtime,
t5x5_1, t50c_1, t100c_1, t5x5_2, t50c_2, t100c_2,
t5x5_3, t50c_3, t100c_3, t5x5_4, t50c_4, t100c_4,
t5x5_5, t50c_5, t100c_5, t5x5_6, t50c_6, t100c_6,
t5x5_7, t50c_7, t100c_7, t5x5_8, t50c_8, t100c_8,
t5x5_... | Training host call. Creates scalar summaries for training metrics.
This function is executed on the CPU and should not directly reference
any Tensors in the rest of the `model_fn`. To pass Tensors from the
model to the `metric_fn`, provide as part of the `host_call`. See
https://www.ten... | Training host call. Creates scalar summaries for training metrics.
This function is executed on the CPU and should not directly reference
any Tensors in the rest of the `model_fn`. To pass Tensors from the
model to the `metric_fn`, provide as part of the `host_call`.
Arguments should match the list of `Tensor` objects... | [
"Training",
"host",
"call",
".",
"Creates",
"scalar",
"summaries",
"for",
"training",
"metrics",
".",
"This",
"function",
"is",
"executed",
"on",
"the",
"CPU",
"and",
"should",
"not",
"directly",
"reference",
"any",
"Tensors",
"in",
"the",
"rest",
"of",
"the... | def host_call_fn(gs, loss, lr, runtime,
t5x5_1, t50c_1, t100c_1, t5x5_2, t50c_2, t100c_2,
t5x5_3, t50c_3, t100c_3, t5x5_4, t50c_4, t100c_4,
t5x5_5, t50c_5, t100c_5, t5x5_6, t50c_6, t100c_6,
t5x5_7, t50c_7, t100c_7, t5x5_8, t50c_8, t100c_8,
t5x5_... | [
"def",
"host_call_fn",
"(",
"gs",
",",
"loss",
",",
"lr",
",",
"runtime",
",",
"t5x5_1",
",",
"t50c_1",
",",
"t100c_1",
",",
"t5x5_2",
",",
"t50c_2",
",",
"t100c_2",
",",
"t5x5_3",
",",
"t50c_3",
",",
"t100c_3",
",",
"t5x5_4",
",",
"t50c_4",
",",
"t1... | Training host call. | [
"Training",
"host",
"call",
"."
] | [
"\"\"\"Training host call. Creates scalar summaries for training metrics.\n\n This function is executed on the CPU and should not directly reference\n any Tensors in the rest of the `model_fn`. To pass Tensors from the\n model to the `metric_fn`, provide as part of the `host_call`. See\n ... | [
{
"param": "gs",
"type": null
},
{
"param": "loss",
"type": null
},
{
"param": "lr",
"type": null
},
{
"param": "runtime",
"type": null
},
{
"param": "t5x5_1",
"type": null
},
{
"param": "t50c_1",
"type": null
},
{
"param": "t100c_1",
"... | {
"returns": [
{
"docstring": "List of summary ops to run on the CPU host.",
"docstring_tokens": [
"List",
"of",
"summary",
"ops",
"to",
"run",
"on",
"the",
"CPU",
"host",
"."
],
"type": null
}
],... |
240fde4b81de9f6b6d47e708cfd28bbd1ab16795 | jsrimr/single-path-nas | nas-search/search_main.py | [
"Apache-2.0"
] | Python | export | <not_specific> | def export(est, export_dir, post_quantize=True):
"""Export graph to SavedModel and TensorFlow Lite.
Args:
est: estimator instance.
export_dir: string, exporting directory.
post_quantize: boolean, whether to quantize model checkpoint after training.
Raises:
ValueError: the export directory path i... | Export graph to SavedModel and TensorFlow Lite.
Args:
est: estimator instance.
export_dir: string, exporting directory.
post_quantize: boolean, whether to quantize model checkpoint after training.
Raises:
ValueError: the export directory path is not specified.
| Export graph to SavedModel and TensorFlow Lite. | [
"Export",
"graph",
"to",
"SavedModel",
"and",
"TensorFlow",
"Lite",
"."
] | def export(est, export_dir, post_quantize=True):
if not export_dir:
raise ValueError('The export directory path is not specified.')
def lite_image_serving_input_fn():
input_shape = [1, FLAGS.input_image_size, FLAGS.input_image_size, 3]
images = tf.placeholder(shape=input_shape, dtype=tf.float32)
ret... | [
"def",
"export",
"(",
"est",
",",
"export_dir",
",",
"post_quantize",
"=",
"True",
")",
":",
"if",
"not",
"export_dir",
":",
"raise",
"ValueError",
"(",
"'The export directory path is not specified.'",
")",
"def",
"lite_image_serving_input_fn",
"(",
")",
":",
"\"\... | Export graph to SavedModel and TensorFlow Lite. | [
"Export",
"graph",
"to",
"SavedModel",
"and",
"TensorFlow",
"Lite",
"."
] | [
"\"\"\"Export graph to SavedModel and TensorFlow Lite.\n\n Args:\n est: estimator instance.\n export_dir: string, exporting directory.\n post_quantize: boolean, whether to quantize model checkpoint after training.\n\n Raises:\n ValueError: the export directory path is not specified.\n \"\"\"",
"# T... | [
{
"param": "est",
"type": null
},
{
"param": "export_dir",
"type": null
},
{
"param": "post_quantize",
"type": null
}
] | {
"returns": [],
"raises": [
{
"docstring": "the export directory path is not specified.",
"docstring_tokens": [
"the",
"export",
"directory",
"path",
"is",
"not",
"specified",
"."
],
"type": "ValueError"
}
],
"param... |
240fde4b81de9f6b6d47e708cfd28bbd1ab16795 | jsrimr/single-path-nas | nas-search/search_main.py | [
"Apache-2.0"
] | Python | lite_image_serving_input_fn | <not_specific> | def lite_image_serving_input_fn():
"""serving input fn for raw images."""
input_shape = [1, FLAGS.input_image_size, FLAGS.input_image_size, 3]
images = tf.placeholder(shape=input_shape, dtype=tf.float32)
return tf.estimator.export.ServingInputReceiver(images, {'images': images}) | serving input fn for raw images. | serving input fn for raw images. | [
"serving",
"input",
"fn",
"for",
"raw",
"images",
"."
] | def lite_image_serving_input_fn():
input_shape = [1, FLAGS.input_image_size, FLAGS.input_image_size, 3]
images = tf.placeholder(shape=input_shape, dtype=tf.float32)
return tf.estimator.export.ServingInputReceiver(images, {'images': images}) | [
"def",
"lite_image_serving_input_fn",
"(",
")",
":",
"input_shape",
"=",
"[",
"1",
",",
"FLAGS",
".",
"input_image_size",
",",
"FLAGS",
".",
"input_image_size",
",",
"3",
"]",
"images",
"=",
"tf",
".",
"placeholder",
"(",
"shape",
"=",
"input_shape",
",",
... | serving input fn for raw images. | [
"serving",
"input",
"fn",
"for",
"raw",
"images",
"."
] | [
"\"\"\"serving input fn for raw images.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
dd45ec6f149ab63d1ae86b1aa5874f3ae1485916 | jsrimr/single-path-nas | runtime-modeling/models.py | [
"Apache-2.0"
] | Python | _decode_block_string | <not_specific> | def _decode_block_string(self, block_string):
"""Gets a MNasNet block through a string notation of arguments.
E.g. r2_k3_s2_e1_i32_o16_se0.25_noskip: r - number of repeat blocks,
k - kernel size, s - strides (1-9), e - expansion ratio, i - input filters,
o - output filters, se - squeeze/excitation rati... | Gets a MNasNet block through a string notation of arguments.
E.g. r2_k3_s2_e1_i32_o16_se0.25_noskip: r - number of repeat blocks,
k - kernel size, s - strides (1-9), e - expansion ratio, i - input filters,
o - output filters, se - squeeze/excitation ratio
Args:
block_string: a string, a string r... | Gets a MNasNet block through a string notation of arguments. | [
"Gets",
"a",
"MNasNet",
"block",
"through",
"a",
"string",
"notation",
"of",
"arguments",
"."
] | def _decode_block_string(self, block_string):
assert isinstance(block_string, str)
ops = block_string.split('_')
options = {}
for op in ops:
splits = re.split(r'(\d.*)', op)
if len(splits) >= 2:
key, value = splits[:2]
options[key] = value
if 's' not in options or len(opt... | [
"def",
"_decode_block_string",
"(",
"self",
",",
"block_string",
")",
":",
"assert",
"isinstance",
"(",
"block_string",
",",
"str",
")",
"ops",
"=",
"block_string",
".",
"split",
"(",
"'_'",
")",
"options",
"=",
"{",
"}",
"for",
"op",
"in",
"ops",
":",
... | Gets a MNasNet block through a string notation of arguments. | [
"Gets",
"a",
"MNasNet",
"block",
"through",
"a",
"string",
"notation",
"of",
"arguments",
"."
] | [
"\"\"\"Gets a MNasNet block through a string notation of arguments.\n\n E.g. r2_k3_s2_e1_i32_o16_se0.25_noskip: r - number of repeat blocks,\n k - kernel size, s - strides (1-9), e - expansion ratio, i - input filters,\n o - output filters, se - squeeze/excitation ratio\n\n Args:\n block_string: a ... | [
{
"param": "self",
"type": null
},
{
"param": "block_string",
"type": null
}
] | {
"returns": [
{
"docstring": "A BlockArgs instance.",
"docstring_tokens": [
"A",
"BlockArgs",
"instance",
"."
],
"type": null
}
],
"raises": [
{
"docstring": "if the strides option is not correctly specified.",
"docstring_tokens": [
... |
dd45ec6f149ab63d1ae86b1aa5874f3ae1485916 | jsrimr/single-path-nas | runtime-modeling/models.py | [
"Apache-2.0"
] | Python | mnasnet_backbone | <not_specific> | def mnasnet_backbone(k, e):
"""Creates a mnasnet-like model with a certain type
of MBConv layers (k, e).
"""
blocks_args = [
'r1_k3_s11_e1_i32_o16_noskip',
'r4_k'+str(k)+'_s22_e'+str(e)+'_i16_o24',
'r4_k'+str(k)+'_s22_e'+str(e)+'_i24_o40',
'r4_k'+str(k)+'_s22_e'+str(e)+'_i40_o80', ... | Creates a mnasnet-like model with a certain type
of MBConv layers (k, e).
| Creates a mnasnet-like model with a certain type
of MBConv layers (k, e). | [
"Creates",
"a",
"mnasnet",
"-",
"like",
"model",
"with",
"a",
"certain",
"type",
"of",
"MBConv",
"layers",
"(",
"k",
"e",
")",
"."
] | def mnasnet_backbone(k, e):
blocks_args = [
'r1_k3_s11_e1_i32_o16_noskip',
'r4_k'+str(k)+'_s22_e'+str(e)+'_i16_o24',
'r4_k'+str(k)+'_s22_e'+str(e)+'_i24_o40',
'r4_k'+str(k)+'_s22_e'+str(e)+'_i40_o80',
'r4_k'+str(k)+'_s11_e'+str(e)+'_i80_o96',
'r4_k'+str(k)+'_s22_e'+str(e)+'_i96_... | [
"def",
"mnasnet_backbone",
"(",
"k",
",",
"e",
")",
":",
"blocks_args",
"=",
"[",
"'r1_k3_s11_e1_i32_o16_noskip'",
",",
"'r4_k'",
"+",
"str",
"(",
"k",
")",
"+",
"'_s22_e'",
"+",
"str",
"(",
"e",
")",
"+",
"'_i16_o24'",
",",
"'r4_k'",
"+",
"str",
"(",
... | Creates a mnasnet-like model with a certain type
of MBConv layers (k, e). | [
"Creates",
"a",
"mnasnet",
"-",
"like",
"model",
"with",
"a",
"certain",
"type",
"of",
"MBConv",
"layers",
"(",
"k",
"e",
")",
"."
] | [
"\"\"\"Creates a mnasnet-like model with a certain type \n of MBConv layers (k, e).\n \"\"\""
] | [
{
"param": "k",
"type": null
},
{
"param": "e",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "k",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
dd45ec6f149ab63d1ae86b1aa5874f3ae1485916 | jsrimr/single-path-nas | runtime-modeling/models.py | [
"Apache-2.0"
] | Python | build_mnasnet_model | <not_specific> | def build_mnasnet_model(images, model_name, training, override_params=None):
"""A helper functiion to creates a ConvNet MnasNet-based model and returns predicted logits.
Args:
images: input images tensor.
model_name: string, the model name of a pre-defined MnasNet.
training: boolean, whether the model ... | A helper functiion to creates a ConvNet MnasNet-based model and returns predicted logits.
Args:
images: input images tensor.
model_name: string, the model name of a pre-defined MnasNet.
training: boolean, whether the model is constructed for training.
override_params: A dictionary of params for overr... | A helper functiion to creates a ConvNet MnasNet-based model and returns predicted logits.
Args:
images: input images tensor.
model_name: string, the model name of a pre-defined MnasNet.
training: boolean, whether the model is constructed for training.
override_params: A dictionary of params for overriding.
the logits ... | [
"A",
"helper",
"functiion",
"to",
"creates",
"a",
"ConvNet",
"MnasNet",
"-",
"based",
"model",
"and",
"returns",
"predicted",
"logits",
".",
"Args",
":",
"images",
":",
"input",
"images",
"tensor",
".",
"model_name",
":",
"string",
"the",
"model",
"name",
... | def build_mnasnet_model(images, model_name, training, override_params=None):
assert isinstance(images, tf.Tensor)
if model_name == 'mnasnet-backbone':
kernel = int(override_params['kernel'])
expratio = int(override_params['expratio'])
blocks_args, global_params = mnasnet_backbone(kernel, expratio)
els... | [
"def",
"build_mnasnet_model",
"(",
"images",
",",
"model_name",
",",
"training",
",",
"override_params",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"images",
",",
"tf",
".",
"Tensor",
")",
"if",
"model_name",
"==",
"'mnasnet-backbone'",
":",
"kernel",... | A helper functiion to creates a ConvNet MnasNet-based model and returns predicted logits. | [
"A",
"helper",
"functiion",
"to",
"creates",
"a",
"ConvNet",
"MnasNet",
"-",
"based",
"model",
"and",
"returns",
"predicted",
"logits",
"."
] | [
"\"\"\"A helper functiion to creates a ConvNet MnasNet-based model and returns predicted logits.\n\n Args:\n images: input images tensor.\n model_name: string, the model name of a pre-defined MnasNet.\n training: boolean, whether the model is constructed for training.\n override_params: A dictionary of... | [
{
"param": "images",
"type": null
},
{
"param": "model_name",
"type": null
},
{
"param": "training",
"type": null
},
{
"param": "override_params",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "images",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_name",
"type": null,
"docstring": null,
"docstring_to... |
99b7d8ebc2be38139ce302a8d9ef99cbea809774 | jsrimr/single-path-nas | nas-search/singlepath_supernet.py | [
"Apache-2.0"
] | Python | _build | null | def _build(self):
"""Builds MBConv block according to the arguments."""
filters = self._block_args.input_filters * self._block_args.expand_ratio
if self._block_args.expand_ratio != 1:
# Expansion phase:
self._expand_conv = tf.keras.layers.Conv2D(
filters,
kernel_size=[1, 1],
... | Builds MBConv block according to the arguments. | Builds MBConv block according to the arguments. | [
"Builds",
"MBConv",
"block",
"according",
"to",
"the",
"arguments",
"."
] | def _build(self):
filters = self._block_args.input_filters * self._block_args.expand_ratio
if self._block_args.expand_ratio != 1:
self._expand_conv = tf.keras.layers.Conv2D(
filters,
kernel_size=[1, 1],
strides=[1, 1],
kernel_initializer=conv_kernel_initializer,
... | [
"def",
"_build",
"(",
"self",
")",
":",
"filters",
"=",
"self",
".",
"_block_args",
".",
"input_filters",
"*",
"self",
".",
"_block_args",
".",
"expand_ratio",
"if",
"self",
".",
"_block_args",
".",
"expand_ratio",
"!=",
"1",
":",
"self",
".",
"_expand_con... | Builds MBConv block according to the arguments. | [
"Builds",
"MBConv",
"block",
"according",
"to",
"the",
"arguments",
"."
] | [
"\"\"\"Builds MBConv block according to the arguments.\"\"\"",
"# Expansion phase:",
"# for \"default\" layers",
"# Default depth-wise convolution phase:",
"# Learnable Depth-wise convolution Superkernel",
"# why would you have SE in the supernet during search?",
"# Squeeze and Excitation layer.",
"#... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
99b7d8ebc2be38139ce302a8d9ef99cbea809774 | jsrimr/single-path-nas | nas-search/singlepath_supernet.py | [
"Apache-2.0"
] | Python | call | <not_specific> | def call(self, inputs, runtime, training=True):
"""Implementation of MBConvBlock call().
Args:
inputs: the inputs tensor.
training: boolean, whether the model is constructed for training.
Returns:
A output tensor.
"""
tf.logging.info('Block input: %s shape: %s' % (inputs.name, in... | Implementation of MBConvBlock call().
Args:
inputs: the inputs tensor.
training: boolean, whether the model is constructed for training.
Returns:
A output tensor.
| Implementation of MBConvBlock call(). | [
"Implementation",
"of",
"MBConvBlock",
"call",
"()",
"."
] | def call(self, inputs, runtime, training=True):
tf.logging.info('Block input: %s shape: %s' % (inputs.name, inputs.shape))
if self._block_args.expand_ratio != 1:
x = tf.nn.relu(self._bn0(self._expand_conv(inputs), training=training))
else:
x = inputs
tf.logging.info('Expand: %s shape: %s' % ... | [
"def",
"call",
"(",
"self",
",",
"inputs",
",",
"runtime",
",",
"training",
"=",
"True",
")",
":",
"tf",
".",
"logging",
".",
"info",
"(",
"'Block input: %s shape: %s'",
"%",
"(",
"inputs",
".",
"name",
",",
"inputs",
".",
"shape",
")",
")",
"if",
"s... | Implementation of MBConvBlock call(). | [
"Implementation",
"of",
"MBConvBlock",
"call",
"()",
"."
] | [
"\"\"\"Implementation of MBConvBlock call().\n\n Args:\n inputs: the inputs tensor.\n training: boolean, whether the model is constructed for training.\n\n Returns:\n A output tensor.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "inputs",
"type": null
},
{
"param": "runtime",
"type": null
},
{
"param": "training",
"type": null
}
] | {
"returns": [
{
"docstring": "A output tensor.",
"docstring_tokens": [
"A",
"output",
"tensor",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_toke... |
99b7d8ebc2be38139ce302a8d9ef99cbea809774 | jsrimr/single-path-nas | nas-search/singlepath_supernet.py | [
"Apache-2.0"
] | Python | call | <not_specific> | def call(self, inputs, training=True):
"""Implementation of SuperNet call().
Args:
inputs: input tensors.
training: boolean, whether the model is constructed for training.
Returns:
output tensors.
"""
outputs = None
self.endpoints = {}
self.indicators = {}
# rest of ... | Implementation of SuperNet call().
Args:
inputs: input tensors.
training: boolean, whether the model is constructed for training.
Returns:
output tensors.
| Implementation of SuperNet call(). | [
"Implementation",
"of",
"SuperNet",
"call",
"()",
"."
] | def call(self, inputs, training=True):
outputs = None
self.endpoints = {}
self.indicators = {}
total_runtime = 19.5999
with tf.variable_scope('mnas_stem'):
outputs = tf.nn.relu(
self._bn0(self._conv_stem(inputs), training=training))
tf.logging.info('Built stem layers with output ... | [
"def",
"call",
"(",
"self",
",",
"inputs",
",",
"training",
"=",
"True",
")",
":",
"outputs",
"=",
"None",
"self",
".",
"endpoints",
"=",
"{",
"}",
"self",
".",
"indicators",
"=",
"{",
"}",
"total_runtime",
"=",
"19.5999",
"with",
"tf",
".",
"variabl... | Implementation of SuperNet call(). | [
"Implementation",
"of",
"SuperNet",
"call",
"()",
"."
] | [
"\"\"\"Implementation of SuperNet call().\n\n Args:\n inputs: input tensors.\n training: boolean, whether the model is constructed for training.\n\n Returns:\n output tensors.\n \"\"\"",
"# rest of runtime (i.e., stem, head, logits, block0, block21)",
"# Calls Stem layers",
"# Calls bl... | [
{
"param": "self",
"type": null
},
{
"param": "inputs",
"type": null
},
{
"param": "training",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
4f5e08bc8debebb9a06eec2870c5ab0e009f403a | jsrimr/single-path-nas | train-final/models.py | [
"Apache-2.0"
] | Python | parse_netarch_model | <not_specific> | def parse_netarch_model(parse_lambda_dir, depth_multiplier=None):
"""Creates the RNAS found model. No need to hard-code
model, it parses the output of previous search
Args:
depth_multiplier: multiplier to number of filters per layer.
Returns:
blocks_args: a list of BlocksArgs for internal MnasNet bloc... | Creates the RNAS found model. No need to hard-code
model, it parses the output of previous search
Args:
depth_multiplier: multiplier to number of filters per layer.
Returns:
blocks_args: a list of BlocksArgs for internal MnasNet blocks.
global_params: GlobalParams, global parameters for the model.
... | Creates the RNAS found model. No need to hard-code
model, it parses the output of previous search | [
"Creates",
"the",
"RNAS",
"found",
"model",
".",
"No",
"need",
"to",
"hard",
"-",
"code",
"model",
"it",
"parses",
"the",
"output",
"of",
"previous",
"search"
] | def parse_netarch_model(parse_lambda_dir, depth_multiplier=None):
tf_size_guidance = {
'compressedHistograms': 10,
'images': 0,
'scalars': 100,
'histograms': 1
}
indicator_values = parse_netarch.parse_indicators_single_path_nas(parse_lambda_dir, tf_size_guidance)
network = parse_... | [
"def",
"parse_netarch_model",
"(",
"parse_lambda_dir",
",",
"depth_multiplier",
"=",
"None",
")",
":",
"tf_size_guidance",
"=",
"{",
"'compressedHistograms'",
":",
"10",
",",
"'images'",
":",
"0",
",",
"'scalars'",
":",
"100",
",",
"'histograms'",
":",
"1",
"}... | Creates the RNAS found model. | [
"Creates",
"the",
"RNAS",
"found",
"model",
"."
] | [
"\"\"\"Creates the RNAS found model. No need to hard-code\n model, it parses the output of previous search\n\n Args:\n depth_multiplier: multiplier to number of filters per layer.\n\n Returns:\n blocks_args: a list of BlocksArgs for internal MnasNet blocks.\n global_params: GlobalParams, global paramete... | [
{
"param": "parse_lambda_dir",
"type": null
},
{
"param": "depth_multiplier",
"type": null
}
] | {
"returns": [
{
"docstring": "a list of BlocksArgs for internal MnasNet blocks.\nglobal_params: GlobalParams, global parameters for the model.",
"docstring_tokens": [
"a",
"list",
"of",
"BlocksArgs",
"for",
"internal",
"MnasNet",
"blocks... |
4f5e08bc8debebb9a06eec2870c5ab0e009f403a | jsrimr/single-path-nas | train-final/models.py | [
"Apache-2.0"
] | Python | build_model | <not_specific> | def build_model(images, model_name, training, override_params=None,
parse_search_dir=None):
"""A helper functiion to creates a ConvNet model and returns predicted logits.
Args:
images: input images tensor.
model_name: string, the model name of a pre-defined MnasNet.
training: boolean, whether t... | A helper functiion to creates a ConvNet model and returns predicted logits.
Args:
images: input images tensor.
model_name: string, the model name of a pre-defined MnasNet.
training: boolean, whether the model is constructed for training.
override_params: A dictionary of params for overriding. Fields ... | A helper functiion to creates a ConvNet model and returns predicted logits.
Args:
images: input images tensor.
model_name: string, the model name of a pre-defined MnasNet.
training: boolean, whether the model is constructed for training.
override_params: A dictionary of params for overriding.
the logits tensor of clas... | [
"A",
"helper",
"functiion",
"to",
"creates",
"a",
"ConvNet",
"model",
"and",
"returns",
"predicted",
"logits",
".",
"Args",
":",
"images",
":",
"input",
"images",
"tensor",
".",
"model_name",
":",
"string",
"the",
"model",
"name",
"of",
"a",
"pre",
"-",
... | def build_model(images, model_name, training, override_params=None,
parse_search_dir=None):
assert isinstance(images, tf.Tensor)
if model_name == 'single-path':
assert parse_search_dir is not None
blocks_args, global_params = parse_netarch_model(parse_search_dir)
else:
raise NotImplementedErro... | [
"def",
"build_model",
"(",
"images",
",",
"model_name",
",",
"training",
",",
"override_params",
"=",
"None",
",",
"parse_search_dir",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"images",
",",
"tf",
".",
"Tensor",
")",
"if",
"model_name",
"==",
"'... | A helper functiion to creates a ConvNet model and returns predicted logits. | [
"A",
"helper",
"functiion",
"to",
"creates",
"a",
"ConvNet",
"model",
"and",
"returns",
"predicted",
"logits",
"."
] | [
"\"\"\"A helper functiion to creates a ConvNet model and returns predicted logits.\n\n Args:\n images: input images tensor.\n model_name: string, the model name of a pre-defined MnasNet.\n training: boolean, whether the model is constructed for training.\n override_params: A dictionary of params for ov... | [
{
"param": "images",
"type": null
},
{
"param": "model_name",
"type": null
},
{
"param": "training",
"type": null
},
{
"param": "override_params",
"type": null
},
{
"param": "parse_search_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "images",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_name",
"type": null,
"docstring": null,
"docstring_to... |
68b008306eb75e00c96695c7221bbd83e23df755 | laugh12321/3D-Attention-Keras | model/CBAM_attention3D.py | [
"MIT"
] | Python | cbam_block | <not_specific> | def cbam_block(feature, ratio=8, kernel_size=7):
"""
Contains the implementation of Convolutional Block Attention Module(CBAM) block.
As described in https://arxiv.org/abs/1807.06521.
"""
feature = channel_attention(ratio=ratio)(feature)
feature = spatial_attention(kernel_size=kernel_size)(feat... |
Contains the implementation of Convolutional Block Attention Module(CBAM) block.
As described in https://arxiv.org/abs/1807.06521.
| Contains the implementation of Convolutional Block Attention Module(CBAM) block. | [
"Contains",
"the",
"implementation",
"of",
"Convolutional",
"Block",
"Attention",
"Module",
"(",
"CBAM",
")",
"block",
"."
] | def cbam_block(feature, ratio=8, kernel_size=7):
feature = channel_attention(ratio=ratio)(feature)
feature = spatial_attention(kernel_size=kernel_size)(feature)
return feature | [
"def",
"cbam_block",
"(",
"feature",
",",
"ratio",
"=",
"8",
",",
"kernel_size",
"=",
"7",
")",
":",
"feature",
"=",
"channel_attention",
"(",
"ratio",
"=",
"ratio",
")",
"(",
"feature",
")",
"feature",
"=",
"spatial_attention",
"(",
"kernel_size",
"=",
... | Contains the implementation of Convolutional Block Attention Module(CBAM) block. | [
"Contains",
"the",
"implementation",
"of",
"Convolutional",
"Block",
"Attention",
"Module",
"(",
"CBAM",
")",
"block",
"."
] | [
"\"\"\"\n Contains the implementation of Convolutional Block Attention Module(CBAM) block.\n As described in https://arxiv.org/abs/1807.06521.\n \"\"\""
] | [
{
"param": "feature",
"type": null
},
{
"param": "ratio",
"type": null
},
{
"param": "kernel_size",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "feature",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ratio",
"type": null,
"docstring": null,
"docstring_tokens... |
c1275bbd6b6f6be12f5da6c987d3f7c0df5b9142 | jherland/browson | browson/utils.py | [
"MIT"
] | Python | debug_time | <not_specific> | def debug_time(f):
"""Decorator to produce debug log messages with function run times."""
@wraps(f)
def wrapper(*args, **kwargs):
global debug_indent
verb = "returned"
debug_indent += 1
t = now()
try:
return f(*args, **kwargs)
except BaseException... | Decorator to produce debug log messages with function run times. | Decorator to produce debug log messages with function run times. | [
"Decorator",
"to",
"produce",
"debug",
"log",
"messages",
"with",
"function",
"run",
"times",
"."
] | def debug_time(f):
@wraps(f)
def wrapper(*args, **kwargs):
global debug_indent
verb = "returned"
debug_indent += 1
t = now()
try:
return f(*args, **kwargs)
except BaseException:
verb = "aborted"
raise
finally:
... | [
"def",
"debug_time",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"global",
"debug_indent",
"verb",
"=",
"\"returned\"",
"debug_indent",
"+=",
"1",
"t",
"=",
"now",
"(",
")",
"t... | Decorator to produce debug log messages with function run times. | [
"Decorator",
"to",
"produce",
"debug",
"log",
"messages",
"with",
"function",
"run",
"times",
"."
] | [
"\"\"\"Decorator to produce debug log messages with function run times.\"\"\""
] | [
{
"param": "f",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "f",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c1275bbd6b6f6be12f5da6c987d3f7c0df5b9142 | jherland/browson | browson/utils.py | [
"MIT"
] | Python | signal_handler | null | def signal_handler(signalnum, handler):
"""Install the given signal handler for the duration of this context."""
def wrapped_handler(signum, frame):
logger.debug(f"signal handler invoked with signal {signum}, {frame}")
handler()
prev = signal.signal(signalnum, wrapped_handler)
try:
... | Install the given signal handler for the duration of this context. | Install the given signal handler for the duration of this context. | [
"Install",
"the",
"given",
"signal",
"handler",
"for",
"the",
"duration",
"of",
"this",
"context",
"."
] | def signal_handler(signalnum, handler):
def wrapped_handler(signum, frame):
logger.debug(f"signal handler invoked with signal {signum}, {frame}")
handler()
prev = signal.signal(signalnum, wrapped_handler)
try:
yield
finally:
signal.signal(signalnum, prev) | [
"def",
"signal_handler",
"(",
"signalnum",
",",
"handler",
")",
":",
"def",
"wrapped_handler",
"(",
"signum",
",",
"frame",
")",
":",
"logger",
".",
"debug",
"(",
"f\"signal handler invoked with signal {signum}, {frame}\"",
")",
"handler",
"(",
")",
"prev",
"=",
... | Install the given signal handler for the duration of this context. | [
"Install",
"the",
"given",
"signal",
"handler",
"for",
"the",
"duration",
"of",
"this",
"context",
"."
] | [
"\"\"\"Install the given signal handler for the duration of this context.\"\"\""
] | [
{
"param": "signalnum",
"type": null
},
{
"param": "handler",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "signalnum",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handler",
"type": null,
"docstring": null,
"docstring_to... |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | adjust_viewport | None | def adjust_viewport(self) -> None:
"""Scroll the viewport to make sure the focused line is visible."""
first = self.visible.first
if self.focus < first + self.context: # scroll viewport up
first = self.focus - self.context
elif self.focus > first + self.height - self.contex... | Scroll the viewport to make sure the focused line is visible. | Scroll the viewport to make sure the focused line is visible. | [
"Scroll",
"the",
"viewport",
"to",
"make",
"sure",
"the",
"focused",
"line",
"is",
"visible",
"."
] | def adjust_viewport(self) -> None:
first = self.visible.first
if self.focus < first + self.context:
first = self.focus - self.context
elif self.focus > first + self.height - self.context:
first = self.focus + self.context - self.height
first = max(
... | [
"def",
"adjust_viewport",
"(",
"self",
")",
"->",
"None",
":",
"first",
"=",
"self",
".",
"visible",
".",
"first",
"if",
"self",
".",
"focus",
"<",
"first",
"+",
"self",
".",
"context",
":",
"first",
"=",
"self",
".",
"focus",
"-",
"self",
".",
"co... | Scroll the viewport to make sure the focused line is visible. | [
"Scroll",
"the",
"viewport",
"to",
"make",
"sure",
"the",
"focused",
"line",
"is",
"visible",
"."
] | [
"\"\"\"Scroll the viewport to make sure the focused line is visible.\"\"\"",
"# scroll viewport up",
"# scroll down",
"# Keep viewport within rendered lines"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | jump_node | None | def jump_node(self, *, forwards: bool = False) -> None:
"""Move focus to the first/last line of the current (or parent) node.
Jump to the first line representing the current node. If already at the
first line, jump to the first line of the parent node. If 'forwards' is
True, jump to the... | Move focus to the first/last line of the current (or parent) node.
Jump to the first line representing the current node. If already at the
first line, jump to the first line of the parent node. If 'forwards' is
True, jump to the last line representing the current node (or parent
node).
... | Move focus to the first/last line of the current (or parent) node.
Jump to the first line representing the current node. If already at the
first line, jump to the first line of the parent node. If 'forwards' is
True, jump to the last line representing the current node (or parent
node). | [
"Move",
"focus",
"to",
"the",
"first",
"/",
"last",
"line",
"of",
"the",
"current",
"(",
"or",
"parent",
")",
"node",
".",
"Jump",
"to",
"the",
"first",
"line",
"representing",
"the",
"current",
"node",
".",
"If",
"already",
"at",
"the",
"first",
"line... | def jump_node(self, *, forwards: bool = False) -> None:
first, last = self.node_span()
target = last if forwards else first
current = self.lines[self.focus].node
while self.focus == target:
parent = current.parent
if parent is None:
break
... | [
"def",
"jump_node",
"(",
"self",
",",
"*",
",",
"forwards",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"first",
",",
"last",
"=",
"self",
".",
"node_span",
"(",
")",
"target",
"=",
"last",
"if",
"forwards",
"else",
"first",
"current",
"=",
... | Move focus to the first/last line of the current (or parent) node. | [
"Move",
"focus",
"to",
"the",
"first",
"/",
"last",
"line",
"of",
"the",
"current",
"(",
"or",
"parent",
")",
"node",
"."
] | [
"\"\"\"Move focus to the first/last line of the current (or parent) node.\n\n Jump to the first line representing the current node. If already at the\n first line, jump to the first line of the parent node. If 'forwards' is\n True, jump to the last line representing the current node (or parent\... | [
{
"param": "self",
"type": null
},
{
"param": "forwards",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "forwards",
"type": "bool",
"docstring": null,
"docstring_toke... |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | jump_match | None | def jump_match(self, *, forwards: bool = False) -> None:
"""Move focus to the previous/next match for .search."""
if forwards:
indices = range(self.focus + 1, len(self.lines))
else:
indices = range(self.focus - 1, -1, -1)
for i in indices:
if self._mat... | Move focus to the previous/next match for .search. | Move focus to the previous/next match for .search. | [
"Move",
"focus",
"to",
"the",
"previous",
"/",
"next",
"match",
"for",
".",
"search",
"."
] | def jump_match(self, *, forwards: bool = False) -> None:
if forwards:
indices = range(self.focus + 1, len(self.lines))
else:
indices = range(self.focus - 1, -1, -1)
for i in indices:
if self._matches(i):
self.set_focus(i)
return | [
"def",
"jump_match",
"(",
"self",
",",
"*",
",",
"forwards",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"if",
"forwards",
":",
"indices",
"=",
"range",
"(",
"self",
".",
"focus",
"+",
"1",
",",
"len",
"(",
"self",
".",
"lines",
")",
")",
... | Move focus to the previous/next match for .search. | [
"Move",
"focus",
"to",
"the",
"previous",
"/",
"next",
"match",
"for",
".",
"search",
"."
] | [
"\"\"\"Move focus to the previous/next match for .search.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "forwards",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "forwards",
"type": "bool",
"docstring": null,
"docstring_toke... |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | collapse_current | None | def collapse_current(self) -> None:
"""Collapse the current node.
Redraw the part of the tree related to the current node. Put focus on
(the now single line representing) the current node.
"""
current = self.lines[self.focus].node
if current.collapsed:
return... | Collapse the current node.
Redraw the part of the tree related to the current node. Put focus on
(the now single line representing) the current node.
| Collapse the current node.
Redraw the part of the tree related to the current node. Put focus on
(the now single line representing) the current node. | [
"Collapse",
"the",
"current",
"node",
".",
"Redraw",
"the",
"part",
"of",
"the",
"tree",
"related",
"to",
"the",
"current",
"node",
".",
"Put",
"focus",
"on",
"(",
"the",
"now",
"single",
"line",
"representing",
")",
"the",
"current",
"node",
"."
] | def collapse_current(self) -> None:
current = self.lines[self.focus].node
if current.collapsed:
return
current.collapsed = True
new_focus = self.rerender(self.focus).first
self.set_focus(new_focus) | [
"def",
"collapse_current",
"(",
"self",
")",
"->",
"None",
":",
"current",
"=",
"self",
".",
"lines",
"[",
"self",
".",
"focus",
"]",
".",
"node",
"if",
"current",
".",
"collapsed",
":",
"return",
"current",
".",
"collapsed",
"=",
"True",
"new_focus",
... | Collapse the current node. | [
"Collapse",
"the",
"current",
"node",
"."
] | [
"\"\"\"Collapse the current node.\n\n Redraw the part of the tree related to the current node. Put focus on\n (the now single line representing) the current node.\n \"\"\"",
"# already collapsed"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | collapse_other | None | def collapse_other(self) -> None:
"""Collapse all nodes not on the path to the current node.
Do not affect the children of the current node.
Put focus on (the first line of) the current node.
"""
current = self.lines[self.focus].node
path = list(current.ancestors(include... | Collapse all nodes not on the path to the current node.
Do not affect the children of the current node.
Put focus on (the first line of) the current node.
| Collapse all nodes not on the path to the current node.
Do not affect the children of the current node.
Put focus on (the first line of) the current node. | [
"Collapse",
"all",
"nodes",
"not",
"on",
"the",
"path",
"to",
"the",
"current",
"node",
".",
"Do",
"not",
"affect",
"the",
"children",
"of",
"the",
"current",
"node",
".",
"Put",
"focus",
"on",
"(",
"the",
"first",
"line",
"of",
")",
"the",
"current",
... | def collapse_other(self) -> None:
current = self.lines[self.focus].node
path = list(current.ancestors(include_self=True))
for node in self.root.dfwalk():
if current in list(node.ancestors()):
continue
if node not in path:
node.collapsed =... | [
"def",
"collapse_other",
"(",
"self",
")",
"->",
"None",
":",
"current",
"=",
"self",
".",
"lines",
"[",
"self",
".",
"focus",
"]",
".",
"node",
"path",
"=",
"list",
"(",
"current",
".",
"ancestors",
"(",
"include_self",
"=",
"True",
")",
")",
"for",... | Collapse all nodes not on the path to the current node. | [
"Collapse",
"all",
"nodes",
"not",
"on",
"the",
"path",
"to",
"the",
"current",
"node",
"."
] | [
"\"\"\"Collapse all nodes not on the path to the current node.\n\n Do not affect the children of the current node.\n Put focus on (the first line of) the current node.\n \"\"\"",
"# don't affect children",
"# collapse unrelated nodes",
"# redraw everything",
"# Re-focus current node"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | collapse_all | None | def collapse_all(self) -> None:
"""Collapse all nodes. Put focus on the first/only line."""
for node in self.root.dfwalk():
node.collapsed = True
new_focus = self.rerender(0).first # redraw everything
self.set_focus(new_focus) | Collapse all nodes. Put focus on the first/only line. | Collapse all nodes. Put focus on the first/only line. | [
"Collapse",
"all",
"nodes",
".",
"Put",
"focus",
"on",
"the",
"first",
"/",
"only",
"line",
"."
] | def collapse_all(self) -> None:
for node in self.root.dfwalk():
node.collapsed = True
new_focus = self.rerender(0).first
self.set_focus(new_focus) | [
"def",
"collapse_all",
"(",
"self",
")",
"->",
"None",
":",
"for",
"node",
"in",
"self",
".",
"root",
".",
"dfwalk",
"(",
")",
":",
"node",
".",
"collapsed",
"=",
"True",
"new_focus",
"=",
"self",
".",
"rerender",
"(",
"0",
")",
".",
"first",
"self... | Collapse all nodes. | [
"Collapse",
"all",
"nodes",
"."
] | [
"\"\"\"Collapse all nodes. Put focus on the first/only line.\"\"\"",
"# redraw everything"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | expand_current | None | def expand_current(self) -> None:
"""Expand the current node.
Redraw the part of the tree related to the current node. Put focus on
the first line representing the current node.
"""
current = self.lines[self.focus].node
if not current.collapsed:
return # alr... | Expand the current node.
Redraw the part of the tree related to the current node. Put focus on
the first line representing the current node.
| Expand the current node.
Redraw the part of the tree related to the current node. Put focus on
the first line representing the current node. | [
"Expand",
"the",
"current",
"node",
".",
"Redraw",
"the",
"part",
"of",
"the",
"tree",
"related",
"to",
"the",
"current",
"node",
".",
"Put",
"focus",
"on",
"the",
"first",
"line",
"representing",
"the",
"current",
"node",
"."
] | def expand_current(self) -> None:
current = self.lines[self.focus].node
if not current.collapsed:
return
current.collapsed = False
new_focus = self.rerender(self.focus).first
self.set_focus(new_focus) | [
"def",
"expand_current",
"(",
"self",
")",
"->",
"None",
":",
"current",
"=",
"self",
".",
"lines",
"[",
"self",
".",
"focus",
"]",
".",
"node",
"if",
"not",
"current",
".",
"collapsed",
":",
"return",
"current",
".",
"collapsed",
"=",
"False",
"new_fo... | Expand the current node. | [
"Expand",
"the",
"current",
"node",
"."
] | [
"\"\"\"Expand the current node.\n\n Redraw the part of the tree related to the current node. Put focus on\n the first line representing the current node.\n \"\"\"",
"# already expanded"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | expand_below | None | def expand_below(self) -> None:
"""Expand this node and all its descendants.
Do not affect unrelated nodes.
Put focus on (the first line of) the current node.
"""
current = self.lines[self.focus].node
for node in current.dfwalk():
node.collapsed = False # ex... | Expand this node and all its descendants.
Do not affect unrelated nodes.
Put focus on (the first line of) the current node.
| Expand this node and all its descendants.
Do not affect unrelated nodes.
Put focus on (the first line of) the current node. | [
"Expand",
"this",
"node",
"and",
"all",
"its",
"descendants",
".",
"Do",
"not",
"affect",
"unrelated",
"nodes",
".",
"Put",
"focus",
"on",
"(",
"the",
"first",
"line",
"of",
")",
"the",
"current",
"node",
"."
] | def expand_below(self) -> None:
current = self.lines[self.focus].node
for node in current.dfwalk():
node.collapsed = False
new_focus = self.rerender(self.focus).first
self.set_focus(new_focus) | [
"def",
"expand_below",
"(",
"self",
")",
"->",
"None",
":",
"current",
"=",
"self",
".",
"lines",
"[",
"self",
".",
"focus",
"]",
".",
"node",
"for",
"node",
"in",
"current",
".",
"dfwalk",
"(",
")",
":",
"node",
".",
"collapsed",
"=",
"False",
"ne... | Expand this node and all its descendants. | [
"Expand",
"this",
"node",
"and",
"all",
"its",
"descendants",
"."
] | [
"\"\"\"Expand this node and all its descendants.\n\n Do not affect unrelated nodes.\n Put focus on (the first line of) the current node.\n \"\"\"",
"# expand descendants"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | expand_all | None | def expand_all(self) -> None:
"""Expand all nodes.
Put focus back onto (the first line of) the current node.
"""
current = self.lines[self.focus].node
for node in self.root.dfwalk():
node.collapsed = False
self.rerender(0) # redraw everything
# Re-f... | Expand all nodes.
Put focus back onto (the first line of) the current node.
| Expand all nodes.
Put focus back onto (the first line of) the current node. | [
"Expand",
"all",
"nodes",
".",
"Put",
"focus",
"back",
"onto",
"(",
"the",
"first",
"line",
"of",
")",
"the",
"current",
"node",
"."
] | def expand_all(self) -> None:
current = self.lines[self.focus].node
for node in self.root.dfwalk():
node.collapsed = False
self.rerender(0)
for i, (_, n) in enumerate(self.lines):
if n is current:
self.set_focus(i)
break | [
"def",
"expand_all",
"(",
"self",
")",
"->",
"None",
":",
"current",
"=",
"self",
".",
"lines",
"[",
"self",
".",
"focus",
"]",
".",
"node",
"for",
"node",
"in",
"self",
".",
"root",
".",
"dfwalk",
"(",
")",
":",
"node",
".",
"collapsed",
"=",
"F... | Expand all nodes. | [
"Expand",
"all",
"nodes",
"."
] | [
"\"\"\"Expand all nodes.\n\n Put focus back onto (the first line of) the current node.\n \"\"\"",
"# redraw everything",
"# Re-focus current node"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | resize | None | def resize(self, new_width: int, new_height: int) -> None:
"""Resize this tree view to the given dimensions."""
self.width, self.height = new_width, new_height
self.style.resize(new_width, new_height)
self.rerender_all() | Resize this tree view to the given dimensions. | Resize this tree view to the given dimensions. | [
"Resize",
"this",
"tree",
"view",
"to",
"the",
"given",
"dimensions",
"."
] | def resize(self, new_width: int, new_height: int) -> None:
self.width, self.height = new_width, new_height
self.style.resize(new_width, new_height)
self.rerender_all() | [
"def",
"resize",
"(",
"self",
",",
"new_width",
":",
"int",
",",
"new_height",
":",
"int",
")",
"->",
"None",
":",
"self",
".",
"width",
",",
"self",
".",
"height",
"=",
"new_width",
",",
"new_height",
"self",
".",
"style",
".",
"resize",
"(",
"new_w... | Resize this tree view to the given dimensions. | [
"Resize",
"this",
"tree",
"view",
"to",
"the",
"given",
"dimensions",
"."
] | [
"\"\"\"Resize this tree view to the given dimensions.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "new_width",
"type": "int"
},
{
"param": "new_height",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_width",
"type": "int",
"docstring": null,
"docstring_toke... |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | _highlight_matches | str | def _highlight_matches(self, line: str) -> str:
"""Apply search highlight to the given rendered line.
Return 'line' with its original terminal escapes, as well as with
'self.search' styled with black text on yellow background.
"""
# This is largely an exercise in proper handling... | Apply search highlight to the given rendered line.
Return 'line' with its original terminal escapes, as well as with
'self.search' styled with black text on yellow background.
| Apply search highlight to the given rendered line.
Return 'line' with its original terminal escapes, as well as with
'self.search' styled with black text on yellow background. | [
"Apply",
"search",
"highlight",
"to",
"the",
"given",
"rendered",
"line",
".",
"Return",
"'",
"line",
"'",
"with",
"its",
"original",
"terminal",
"escapes",
"as",
"well",
"as",
"with",
"'",
"self",
".",
"search",
"'",
"styled",
"with",
"black",
"text",
"... | def _highlight_matches(self, line: str) -> str:
haystack = self.term.strip_seqs(line)
assert self.term.length(line) == len(haystack)
needle = self.search
def term_escapes_before(index):
letters = []
escapes = []
for fragment in self.term.split_seqs(l... | [
"def",
"_highlight_matches",
"(",
"self",
",",
"line",
":",
"str",
")",
"->",
"str",
":",
"haystack",
"=",
"self",
".",
"term",
".",
"strip_seqs",
"(",
"line",
")",
"assert",
"self",
".",
"term",
".",
"length",
"(",
"line",
")",
"==",
"len",
"(",
"... | Apply search highlight to the given rendered line. | [
"Apply",
"search",
"highlight",
"to",
"the",
"given",
"rendered",
"line",
"."
] | [
"\"\"\"Apply search highlight to the given rendered line.\n\n Return 'line' with its original terminal escapes, as well as with\n 'self.search' styled with black text on yellow background.\n \"\"\"",
"# This is largely an exercise in proper handling of terminal escapes.",
"# We must search ... | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "str",
"docstring": null,
"docstring_tokens": ... |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | term_escapes_before | <not_specific> | def term_escapes_before(index):
"""Return terminal escapes that occur before 'index' in line."""
letters = []
escapes = []
for fragment in self.term.split_seqs(line):
fraglen = self.term.length(fragment)
assert fraglen in [0, 1]
... | Return terminal escapes that occur before 'index' in line. | Return terminal escapes that occur before 'index' in line. | [
"Return",
"terminal",
"escapes",
"that",
"occur",
"before",
"'",
"index",
"'",
"in",
"line",
"."
] | def term_escapes_before(index):
letters = []
escapes = []
for fragment in self.term.split_seqs(line):
fraglen = self.term.length(fragment)
assert fraglen in [0, 1]
[escapes, letters][fraglen].append(fragment)
if len(lett... | [
"def",
"term_escapes_before",
"(",
"index",
")",
":",
"letters",
"=",
"[",
"]",
"escapes",
"=",
"[",
"]",
"for",
"fragment",
"in",
"self",
".",
"term",
".",
"split_seqs",
"(",
"line",
")",
":",
"fraglen",
"=",
"self",
".",
"term",
".",
"length",
"(",... | Return terminal escapes that occur before 'index' in line. | [
"Return",
"terminal",
"escapes",
"that",
"occur",
"before",
"'",
"index",
"'",
"in",
"line",
"."
] | [
"\"\"\"Return terminal escapes that occur before 'index' in line.\"\"\""
] | [
{
"param": "index",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "index",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41cdeb075efe4fe2c2fa9f8fe415e0133df86b64 | jherland/browson | browson/nodeview.py | [
"MIT"
] | Python | draw | <not_specific> | def draw(self):
"""Yield the currently visible lines in this tree view."""
first, last = self.visible
ret = []
for i, (line, _) in enumerate(self.lines[first : last + 1], first):
if self.search and self._matches(i):
line = self._highlight_matches(line)
... | Yield the currently visible lines in this tree view. | Yield the currently visible lines in this tree view. | [
"Yield",
"the",
"currently",
"visible",
"lines",
"in",
"this",
"tree",
"view",
"."
] | def draw(self):
first, last = self.visible
ret = []
for i, (line, _) in enumerate(self.lines[first : last + 1], first):
if self.search and self._matches(i):
line = self._highlight_matches(line)
if i == self.focus:
line = self.term.on_gray20... | [
"def",
"draw",
"(",
"self",
")",
":",
"first",
",",
"last",
"=",
"self",
".",
"visible",
"ret",
"=",
"[",
"]",
"for",
"i",
",",
"(",
"line",
",",
"_",
")",
"in",
"enumerate",
"(",
"self",
".",
"lines",
"[",
"first",
":",
"last",
"+",
"1",
"]"... | Yield the currently visible lines in this tree view. | [
"Yield",
"the",
"currently",
"visible",
"lines",
"in",
"this",
"tree",
"view",
"."
] | [
"\"\"\"Yield the currently visible lines in this tree view.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f37f824204bf63d8337618d5e971adb68525481e | jherland/browson | browson/node.py | [
"MIT"
] | Python | is_leaf | <not_specific> | def is_leaf(self):
"""Return True iff this is a leaf node (i.e. cannot have any children).
This is different from an empty container, i.e. an "internal" node
whose list of children is empty."""
return self._children is None | Return True iff this is a leaf node (i.e. cannot have any children).
This is different from an empty container, i.e. an "internal" node
whose list of children is empty. | Return True iff this is a leaf node .
This is different from an empty container, i.e. an "internal" node
whose list of children is empty. | [
"Return",
"True",
"iff",
"this",
"is",
"a",
"leaf",
"node",
".",
"This",
"is",
"different",
"from",
"an",
"empty",
"container",
"i",
".",
"e",
".",
"an",
"\"",
"internal",
"\"",
"node",
"whose",
"list",
"of",
"children",
"is",
"empty",
"."
] | def is_leaf(self):
return self._children is None | [
"def",
"is_leaf",
"(",
"self",
")",
":",
"return",
"self",
".",
"_children",
"is",
"None"
] | Return True iff this is a leaf node (i.e. | [
"Return",
"True",
"iff",
"this",
"is",
"a",
"leaf",
"node",
"(",
"i",
".",
"e",
"."
] | [
"\"\"\"Return True iff this is a leaf node (i.e. cannot have any children).\n\n This is different from an empty container, i.e. an \"internal\" node\n whose list of children is empty.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f37f824204bf63d8337618d5e971adb68525481e | jherland/browson | browson/node.py | [
"MIT"
] | Python | children | <not_specific> | def children(self):
"""Return this node's children.
Return an empty list for leaf nodes, as a convenience for callers that
typically iterated over this methods return value."""
return [] if self._children is None else self._children | Return this node's children.
Return an empty list for leaf nodes, as a convenience for callers that
typically iterated over this methods return value. | Return this node's children.
Return an empty list for leaf nodes, as a convenience for callers that
typically iterated over this methods return value. | [
"Return",
"this",
"node",
"'",
"s",
"children",
".",
"Return",
"an",
"empty",
"list",
"for",
"leaf",
"nodes",
"as",
"a",
"convenience",
"for",
"callers",
"that",
"typically",
"iterated",
"over",
"this",
"methods",
"return",
"value",
"."
] | def children(self):
return [] if self._children is None else self._children | [
"def",
"children",
"(",
"self",
")",
":",
"return",
"[",
"]",
"if",
"self",
".",
"_children",
"is",
"None",
"else",
"self",
".",
"_children"
] | Return this node's children. | [
"Return",
"this",
"node",
"'",
"s",
"children",
"."
] | [
"\"\"\"Return this node's children.\n\n Return an empty list for leaf nodes, as a convenience for callers that\n typically iterated over this methods return value.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f37f824204bf63d8337618d5e971adb68525481e | jherland/browson | browson/node.py | [
"MIT"
] | Python | ancestors | null | def ancestors(self, include_self=False):
"""Yield transitive parents of this node."""
if include_self:
yield self
if self.parent is not None:
yield from self.parent.ancestors(include_self=True) | Yield transitive parents of this node. | Yield transitive parents of this node. | [
"Yield",
"transitive",
"parents",
"of",
"this",
"node",
"."
] | def ancestors(self, include_self=False):
if include_self:
yield self
if self.parent is not None:
yield from self.parent.ancestors(include_self=True) | [
"def",
"ancestors",
"(",
"self",
",",
"include_self",
"=",
"False",
")",
":",
"if",
"include_self",
":",
"yield",
"self",
"if",
"self",
".",
"parent",
"is",
"not",
"None",
":",
"yield",
"from",
"self",
".",
"parent",
".",
"ancestors",
"(",
"include_self"... | Yield transitive parents of this node. | [
"Yield",
"transitive",
"parents",
"of",
"this",
"node",
"."
] | [
"\"\"\"Yield transitive parents of this node.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "include_self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "include_self",
"type": null,
"docstring": null,
"docstring_to... |
f37f824204bf63d8337618d5e971adb68525481e | jherland/browson | browson/node.py | [
"MIT"
] | Python | dfwalk | null | def dfwalk(self, preorder=yield_node, postorder=None):
"""Depth-first walk, yields values yielded from visitor function."""
if preorder is not None:
yield from preorder(self)
for child in self.children:
yield from child.dfwalk(preorder, postorder)
if postorder is ... | Depth-first walk, yields values yielded from visitor function. | Depth-first walk, yields values yielded from visitor function. | [
"Depth",
"-",
"first",
"walk",
"yields",
"values",
"yielded",
"from",
"visitor",
"function",
"."
] | def dfwalk(self, preorder=yield_node, postorder=None):
if preorder is not None:
yield from preorder(self)
for child in self.children:
yield from child.dfwalk(preorder, postorder)
if postorder is not None:
yield from postorder(self) | [
"def",
"dfwalk",
"(",
"self",
",",
"preorder",
"=",
"yield_node",
",",
"postorder",
"=",
"None",
")",
":",
"if",
"preorder",
"is",
"not",
"None",
":",
"yield",
"from",
"preorder",
"(",
"self",
")",
"for",
"child",
"in",
"self",
".",
"children",
":",
... | Depth-first walk, yields values yielded from visitor function. | [
"Depth",
"-",
"first",
"walk",
"yields",
"values",
"yielded",
"from",
"visitor",
"function",
"."
] | [
"\"\"\"Depth-first walk, yields values yielded from visitor function.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "preorder",
"type": null
},
{
"param": "postorder",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "preorder",
"type": null,
"docstring": null,
"docstring_tokens... |
02764598cf69886999cc7bd2d3d294d3251e4581 | jherland/browson | browson/style.py | [
"MIT"
] | Python | full | Tuple[List[str], List[str]] | def full(self, node: DrawableNode) -> Tuple[List[str], List[str]]:
"""Return the full representation for the given node.
Return a (pre_lines, post_lines) pair of string lists holding the
lines to display preceding the node's children (if any), and the lines
to display following the node... | Return the full representation for the given node.
Return a (pre_lines, post_lines) pair of string lists holding the
lines to display preceding the node's children (if any), and the lines
to display following the node's children.
| Return the full representation for the given node.
Return a (pre_lines, post_lines) pair of string lists holding the
lines to display preceding the node's children (if any), and the lines
to display following the node's children. | [
"Return",
"the",
"full",
"representation",
"for",
"the",
"given",
"node",
".",
"Return",
"a",
"(",
"pre_lines",
"post_lines",
")",
"pair",
"of",
"string",
"lists",
"holding",
"the",
"lines",
"to",
"display",
"preceding",
"the",
"node",
"'",
"s",
"children",
... | def full(self, node: DrawableNode) -> Tuple[List[str], List[str]]:
raise NotImplementedError | [
"def",
"full",
"(",
"self",
",",
"node",
":",
"DrawableNode",
")",
"->",
"Tuple",
"[",
"List",
"[",
"str",
"]",
",",
"List",
"[",
"str",
"]",
"]",
":",
"raise",
"NotImplementedError"
] | Return the full representation for the given node. | [
"Return",
"the",
"full",
"representation",
"for",
"the",
"given",
"node",
"."
] | [
"\"\"\"Return the full representation for the given node.\n\n Return a (pre_lines, post_lines) pair of string lists holding the\n lines to display preceding the node's children (if any), and the lines\n to display following the node's children.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": "DrawableNode"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": "DrawableNode",
"docstring": null,
"docstring_... |
28e827da77523649aeff1d27ef5bd6d5bc241117 | abrolon87/journal-app | ja_env/lib/python3.7/site-packages/pry.py | [
"MIT"
] | Python | ls | null | def ls(self, query):
"""
Show local variables/methods/class properties
"""
lines = []
width = terminal_size()[0]
methods = []
properties = []
has_query = True
... |
Show local variables/methods/class properties
| Show local variables/methods/class properties | [
"Show",
"local",
"variables",
"/",
"methods",
"/",
"class",
"properties"
] | def ls(self, query):
lines = []
width = terminal_size()[0]
methods = []
properties = []
has_query = True
that = self.shell.user_ns.get(query, None)
if that is None:
... | [
"def",
"ls",
"(",
"self",
",",
"query",
")",
":",
"lines",
"=",
"[",
"]",
"width",
"=",
"terminal_size",
"(",
")",
"[",
"0",
"]",
"methods",
"=",
"[",
"]",
"properties",
"=",
"[",
"]",
"has_query",
"=",
"True",
"that",
"=",
"self",
".",
"shell",
... | Show local variables/methods/class properties | [
"Show",
"local",
"variables",
"/",
"methods",
"/",
"class",
"properties"
] | [
"\"\"\"\n Show local variables/methods/class properties\n \"\"\"",
"# apparently there is no better way to check if the caller",
"# is a method"
] | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": ... |
28e827da77523649aeff1d27ef5bd6d5bc241117 | abrolon87/journal-app | ja_env/lib/python3.7/site-packages/pry.py | [
"MIT"
] | Python | editfile | null | def editfile(self, query):
"""
open current breakpoint in editor.
"""
self.shell.hooks.editor(
self.active_frame.filename,
linenum=self.active_frame.lineno) |
open current breakpoint in editor.
| open current breakpoint in editor. | [
"open",
"current",
"breakpoint",
"in",
"editor",
"."
] | def editfile(self, query):
self.shell.hooks.editor(
self.active_frame.filename,
linenum=self.active_frame.lineno) | [
"def",
"editfile",
"(",
"self",
",",
"query",
")",
":",
"self",
".",
"shell",
".",
"hooks",
".",
"editor",
"(",
"self",
".",
"active_frame",
".",
"filename",
",",
"linenum",
"=",
"self",
".",
"active_frame",
".",
"lineno",
")"
] | open current breakpoint in editor. | [
"open",
"current",
"breakpoint",
"in",
"editor",
"."
] | [
"\"\"\"\n open current breakpoint in editor.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": ... |
28e827da77523649aeff1d27ef5bd6d5bc241117 | abrolon87/journal-app | ja_env/lib/python3.7/site-packages/pry.py | [
"MIT"
] | Python | up | null | def up(self, query):
"""
Get from call frame up.
"""
self.frame_offset += 1
self.frame_offset = min(self.frame_offset,
len(self.frames) - 1)
self.update_con... |
Get from call frame up.
| Get from call frame up. | [
"Get",
"from",
"call",
"frame",
"up",
"."
] | def up(self, query):
self.frame_offset += 1
self.frame_offset = min(self.frame_offset,
len(self.frames) - 1)
self.update_context() | [
"def",
"up",
"(",
"self",
",",
"query",
")",
":",
"self",
".",
"frame_offset",
"+=",
"1",
"self",
".",
"frame_offset",
"=",
"min",
"(",
"self",
".",
"frame_offset",
",",
"len",
"(",
"self",
".",
"frames",
")",
"-",
"1",
")",
"self",
".",
"update_co... | Get from call frame up. | [
"Get",
"from",
"call",
"frame",
"up",
"."
] | [
"\"\"\"\n Get from call frame up.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": ... |
28e827da77523649aeff1d27ef5bd6d5bc241117 | abrolon87/journal-app | ja_env/lib/python3.7/site-packages/pry.py | [
"MIT"
] | Python | down | null | def down(self, query):
"""
Get from call frame down.
"""
self.frame_offset -= 1
self.frame_offset = max(self.frame_offset, 0)
self.update_context() |
Get from call frame down.
| Get from call frame down. | [
"Get",
"from",
"call",
"frame",
"down",
"."
] | def down(self, query):
self.frame_offset -= 1
self.frame_offset = max(self.frame_offset, 0)
self.update_context() | [
"def",
"down",
"(",
"self",
",",
"query",
")",
":",
"self",
".",
"frame_offset",
"-=",
"1",
"self",
".",
"frame_offset",
"=",
"max",
"(",
"self",
".",
"frame_offset",
",",
"0",
")",
"self",
".",
"update_context",
"(",
")"
] | Get from call frame down. | [
"Get",
"from",
"call",
"frame",
"down",
"."
] | [
"\"\"\"\n Get from call frame down.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": ... |
28e827da77523649aeff1d27ef5bd6d5bc241117 | abrolon87/journal-app | ja_env/lib/python3.7/site-packages/pry.py | [
"MIT"
] | Python | removepry | null | def removepry(self, query):
"""
Remove pry call at current breakpoint.
"""
f = self.calling_frame
with open(f.filename) as src, \
tempfile.NamedTemporaryFile(mode='w') as dst:
... |
Remove pry call at current breakpoint.
| Remove pry call at current breakpoint. | [
"Remove",
"pry",
"call",
"at",
"current",
"breakpoint",
"."
] | def removepry(self, query):
f = self.calling_frame
with open(f.filename) as src, \
tempfile.NamedTemporaryFile(mode='w') as dst:
for i, line in enumerate(src):
if (i + 1) == f.lineno:
... | [
"def",
"removepry",
"(",
"self",
",",
"query",
")",
":",
"f",
"=",
"self",
".",
"calling_frame",
"with",
"open",
"(",
"f",
".",
"filename",
")",
"as",
"src",
",",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"mode",
"=",
"'w'",
")",
"as",
"dst",
":",
... | Remove pry call at current breakpoint. | [
"Remove",
"pry",
"call",
"at",
"current",
"breakpoint",
"."
] | [
"\"\"\"\n Remove pry call at current breakpoint.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": ... |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | devices_from_config | <not_specific> | def devices_from_config(domain_config):
"""Parse configuration and add cover devices."""
devices = []
for device_id, config in domain_config[CONF_DEVICES].items():
name = config.pop(CONF_NAME)
travel_time_down = config.pop(CONF_TRAVELLING_TIME_DOWN)
travel_time_up = config.pop(CONF_T... | Parse configuration and add cover devices. | Parse configuration and add cover devices. | [
"Parse",
"configuration",
"and",
"add",
"cover",
"devices",
"."
] | def devices_from_config(domain_config):
devices = []
for device_id, config in domain_config[CONF_DEVICES].items():
name = config.pop(CONF_NAME)
travel_time_down = config.pop(CONF_TRAVELLING_TIME_DOWN)
travel_time_up = config.pop(CONF_TRAVELLING_TIME_UP)
open_script_entity_id = co... | [
"def",
"devices_from_config",
"(",
"domain_config",
")",
":",
"devices",
"=",
"[",
"]",
"for",
"device_id",
",",
"config",
"in",
"domain_config",
"[",
"CONF_DEVICES",
"]",
".",
"items",
"(",
")",
":",
"name",
"=",
"config",
".",
"pop",
"(",
"CONF_NAME",
... | Parse configuration and add cover devices. | [
"Parse",
"configuration",
"and",
"add",
"cover",
"devices",
"."
] | [
"\"\"\"Parse configuration and add cover devices.\"\"\""
] | [
{
"param": "domain_config",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "domain_config",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | async_setup_platform | null | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the cover platform."""
async_add_entities(devices_from_config(config))
platform = entity_platform.current_platform.get()
platform.async_register_entity_service(
SERVICE_SET_KNOWN_POSITION, POSITION... | Set up the cover platform. | Set up the cover platform. | [
"Set",
"up",
"the",
"cover",
"platform",
"."
] | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
async_add_entities(devices_from_config(config))
platform = entity_platform.current_platform.get()
platform.async_register_entity_service(
SERVICE_SET_KNOWN_POSITION, POSITION_SCHEMA, "set_known_position"
)
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"devices_from_config",
"(",
"config",
")",
")",
"platform",
"=",
"entity_platform",
".",
"curren... | Set up the cover platform. | [
"Set",
"up",
"the",
"cover",
"platform",
"."
] | [
"\"\"\"Set up the cover platform.\"\"\""
] | [
{
"param": "hass",
"type": null
},
{
"param": "config",
"type": null
},
{
"param": "async_add_entities",
"type": null
},
{
"param": "discovery_info",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hass",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config",
"type": null,
"docstring": null,
"docstring_tokens":... |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | async_added_to_hass | null | async def async_added_to_hass(self):
""" Only cover position and confidence in that matters."""
""" The rest is calculated from this attribute. """
old_state = await self.async_get_last_state()
_LOGGER.debug(self._name + ': ' + 'async_added_to_hass :: oldState %s', old_state)
... | Only cover position and confidence in that matters. | Only cover position and confidence in that matters. | [
"Only",
"cover",
"position",
"and",
"confidence",
"in",
"that",
"matters",
"."
] | async def async_added_to_hass(self):
old_state = await self.async_get_last_state()
_LOGGER.debug(self._name + ': ' + 'async_added_to_hass :: oldState %s', old_state)
if (old_state is not None and self.tc is not None and old_state.attributes.get(ATTR_CURRENT_POSITION) is not None):
se... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"\"\"\" The rest is calculated from this attribute. \"\"\"",
"old_state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"self",
".",
"_name",
"+",
"': '",... | Only cover position and confidence in that matters. | [
"Only",
"cover",
"position",
"and",
"confidence",
"in",
"that",
"matters",
"."
] | [
"\"\"\" Only cover position and confidence in that matters.\"\"\"",
"\"\"\" The rest is calculated from this attribute. \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | device_state_attributes | <not_specific> | def device_state_attributes(self):
"""Return the device state attributes."""
attr = {}
if self._travel_time_down is not None:
attr[CONF_TRAVELLING_TIME_DOWN] = self._travel_time_down
if self._travel_time_up is not None:
attr[CONF_TRAVELLING_TIME_UP] = self._travel... | Return the device state attributes. | Return the device state attributes. | [
"Return",
"the",
"device",
"state",
"attributes",
"."
] | def device_state_attributes(self):
attr = {}
if self._travel_time_down is not None:
attr[CONF_TRAVELLING_TIME_DOWN] = self._travel_time_down
if self._travel_time_up is not None:
attr[CONF_TRAVELLING_TIME_UP] = self._travel_time_up
attr[ATTR_UNCONFIRMED_STATE] = s... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"}",
"if",
"self",
".",
"_travel_time_down",
"is",
"not",
"None",
":",
"attr",
"[",
"CONF_TRAVELLING_TIME_DOWN",
"]",
"=",
"self",
".",
"_travel_time_down",
"if",
"self",
".",
"_trave... | Return the device state attributes. | [
"Return",
"the",
"device",
"state",
"attributes",
"."
] | [
"\"\"\"Return the device state attributes.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | is_opening | <not_specific> | def is_opening(self):
"""Return if the cover is opening or not."""
from xknx.devices import TravelStatus
return self.tc.is_traveling() and \
self.tc.travel_direction == TravelStatus.DIRECTION_UP | Return if the cover is opening or not. | Return if the cover is opening or not. | [
"Return",
"if",
"the",
"cover",
"is",
"opening",
"or",
"not",
"."
] | def is_opening(self):
from xknx.devices import TravelStatus
return self.tc.is_traveling() and \
self.tc.travel_direction == TravelStatus.DIRECTION_UP | [
"def",
"is_opening",
"(",
"self",
")",
":",
"from",
"xknx",
".",
"devices",
"import",
"TravelStatus",
"return",
"self",
".",
"tc",
".",
"is_traveling",
"(",
")",
"and",
"self",
".",
"tc",
".",
"travel_direction",
"==",
"TravelStatus",
".",
"DIRECTION_UP"
] | Return if the cover is opening or not. | [
"Return",
"if",
"the",
"cover",
"is",
"opening",
"or",
"not",
"."
] | [
"\"\"\"Return if the cover is opening or not.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | is_closing | <not_specific> | def is_closing(self):
"""Return if the cover is closing or not."""
from xknx.devices import TravelStatus
return self.tc.is_traveling() and \
self.tc.travel_direction == TravelStatus.DIRECTION_DOWN | Return if the cover is closing or not. | Return if the cover is closing or not. | [
"Return",
"if",
"the",
"cover",
"is",
"closing",
"or",
"not",
"."
] | def is_closing(self):
from xknx.devices import TravelStatus
return self.tc.is_traveling() and \
self.tc.travel_direction == TravelStatus.DIRECTION_DOWN | [
"def",
"is_closing",
"(",
"self",
")",
":",
"from",
"xknx",
".",
"devices",
"import",
"TravelStatus",
"return",
"self",
".",
"tc",
".",
"is_traveling",
"(",
")",
"and",
"self",
".",
"tc",
".",
"travel_direction",
"==",
"TravelStatus",
".",
"DIRECTION_DOWN"
] | Return if the cover is closing or not. | [
"Return",
"if",
"the",
"cover",
"is",
"closing",
"or",
"not",
"."
] | [
"\"\"\"Return if the cover is closing or not.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | async_set_cover_position | null | async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
if ATTR_POSITION in kwargs:
self._target_position = kwargs[ATTR_POSITION]
_LOGGER.debug(self._name + ': ' + 'async_set_cover_position: %d', self._target_position)
await self.se... | Move the cover to a specific position. | Move the cover to a specific position. | [
"Move",
"the",
"cover",
"to",
"a",
"specific",
"position",
"."
] | async def async_set_cover_position(self, **kwargs):
if ATTR_POSITION in kwargs:
self._target_position = kwargs[ATTR_POSITION]
_LOGGER.debug(self._name + ': ' + 'async_set_cover_position: %d', self._target_position)
await self.set_position(self._target_position) | [
"async",
"def",
"async_set_cover_position",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"ATTR_POSITION",
"in",
"kwargs",
":",
"self",
".",
"_target_position",
"=",
"kwargs",
"[",
"ATTR_POSITION",
"]",
"_LOGGER",
".",
"debug",
"(",
"self",
".",
"_name",... | Move the cover to a specific position. | [
"Move",
"the",
"cover",
"to",
"a",
"specific",
"position",
"."
] | [
"\"\"\"Move the cover to a specific position.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | start_auto_updater | null | def start_auto_updater(self):
"""Start the autoupdater to update HASS while cover is moving."""
_LOGGER.debug(self._name + ': ' + 'start_auto_updater')
if self._unsubscribe_auto_updater is None:
_LOGGER.debug(self._name + ': ' + 'init _unsubscribe_auto_updater')
interval ... | Start the autoupdater to update HASS while cover is moving. | Start the autoupdater to update HASS while cover is moving. | [
"Start",
"the",
"autoupdater",
"to",
"update",
"HASS",
"while",
"cover",
"is",
"moving",
"."
] | def start_auto_updater(self):
_LOGGER.debug(self._name + ': ' + 'start_auto_updater')
if self._unsubscribe_auto_updater is None:
_LOGGER.debug(self._name + ': ' + 'init _unsubscribe_auto_updater')
interval = timedelta(seconds=0.1)
self._unsubscribe_auto_updater = asyn... | [
"def",
"start_auto_updater",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"self",
".",
"_name",
"+",
"': '",
"+",
"'start_auto_updater'",
")",
"if",
"self",
".",
"_unsubscribe_auto_updater",
"is",
"None",
":",
"_LOGGER",
".",
"debug",
"(",
"self",
... | Start the autoupdater to update HASS while cover is moving. | [
"Start",
"the",
"autoupdater",
"to",
"update",
"HASS",
"while",
"cover",
"is",
"moving",
"."
] | [
"\"\"\"Start the autoupdater to update HASS while cover is moving.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | auto_stop_if_necessary | null | async def auto_stop_if_necessary(self):
"""Do auto stop if necessary."""
current_position = self.tc.current_position()
if self.position_reached() and not self._processing_known_position:
self.tc.stop()
if (current_position > 0) and (current_position < 100):
... | Do auto stop if necessary. | Do auto stop if necessary. | [
"Do",
"auto",
"stop",
"if",
"necessary",
"."
] | async def auto_stop_if_necessary(self):
current_position = self.tc.current_position()
if self.position_reached() and not self._processing_known_position:
self.tc.stop()
if (current_position > 0) and (current_position < 100):
_LOGGER.debug(self._name + ': ' + 'auto... | [
"async",
"def",
"auto_stop_if_necessary",
"(",
"self",
")",
":",
"current_position",
"=",
"self",
".",
"tc",
".",
"current_position",
"(",
")",
"if",
"self",
".",
"position_reached",
"(",
")",
"and",
"not",
"self",
".",
"_processing_known_position",
":",
"self... | Do auto stop if necessary. | [
"Do",
"auto",
"stop",
"if",
"necessary",
"."
] | [
"\"\"\"Do auto stop if necessary.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
056dc754df9e7b6a418eba22a4ba6511829fe66d | zoranke/BroadlinkCover | custom_components/broadlinkcover/cover.py | [
"MIT"
] | Python | _async_handle_command | null | async def _async_handle_command(self, command, *args):
"""We have cover.* triggered command. Reset assumed state and known_position processsing and execute"""
self._assume_uncertain_position = True
self._processing_known_position = False
if command == "close_cover":
cmd = "DO... | We have cover.* triggered command. Reset assumed state and known_position processsing and execute | We have cover.* triggered command. Reset assumed state and known_position processsing and execute | [
"We",
"have",
"cover",
".",
"*",
"triggered",
"command",
".",
"Reset",
"assumed",
"state",
"and",
"known_position",
"processsing",
"and",
"execute"
] | async def _async_handle_command(self, command, *args):
self._assume_uncertain_position = True
self._processing_known_position = False
if command == "close_cover":
cmd = "DOWN"
self._state = False
await self.hass.services.async_call("homeassistant", "turn_on", ... | [
"async",
"def",
"_async_handle_command",
"(",
"self",
",",
"command",
",",
"*",
"args",
")",
":",
"self",
".",
"_assume_uncertain_position",
"=",
"True",
"self",
".",
"_processing_known_position",
"=",
"False",
"if",
"command",
"==",
"\"close_cover\"",
":",
"cmd... | We have cover. | [
"We",
"have",
"cover",
"."
] | [
"\"\"\"We have cover.* triggered command. Reset assumed state and known_position processsing and execute\"\"\"",
"# Update state of entity"
] | [
{
"param": "self",
"type": null
},
{
"param": "command",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "command",
"type": null,
"docstring": null,
"docstring_tokens"... |
71923a33399e723240212f9982d47a6459a2709e | zoranke/BroadlinkCover | custom_components/broadlinkcover/climate.py | [
"MIT"
] | Python | async_setup_platform | <not_specific> | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the IR Climate platform."""
device_code = config.get(CONF_DEVICE_CODE)
device_files_subdir = os.path.join('codes', 'climate')
device_files_absdir = os.path.join(COMPONENT_ABS_DIR, device_files_subdir)
i... | Set up the IR Climate platform. | Set up the IR Climate platform. | [
"Set",
"up",
"the",
"IR",
"Climate",
"platform",
"."
] | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
device_code = config.get(CONF_DEVICE_CODE)
device_files_subdir = os.path.join('codes', 'climate')
device_files_absdir = os.path.join(COMPONENT_ABS_DIR, device_files_subdir)
if not os.path.isdir(device_files_absdir):
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"device_code",
"=",
"config",
".",
"get",
"(",
"CONF_DEVICE_CODE",
")",
"device_files_subdir",
"=",
"os",
".",
"path",
... | Set up the IR Climate platform. | [
"Set",
"up",
"the",
"IR",
"Climate",
"platform",
"."
] | [
"\"\"\"Set up the IR Climate platform.\"\"\""
] | [
{
"param": "hass",
"type": null
},
{
"param": "config",
"type": null
},
{
"param": "async_add_entities",
"type": null
},
{
"param": "discovery_info",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hass",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config",
"type": null,
"docstring": null,
"docstring_tokens":... |
71923a33399e723240212f9982d47a6459a2709e | zoranke/BroadlinkCover | custom_components/broadlinkcover/climate.py | [
"MIT"
] | Python | async_added_to_hass | null | async def async_added_to_hass(self):
"""Run when entity about to be added."""
await super().async_added_to_hass()
last_state = await self.async_get_last_state()
if last_state is not None:
self._hvac_mode = last_state.state
self._current_fan_mode = la... | Run when entity about to be added. | Run when entity about to be added. | [
"Run",
"when",
"entity",
"about",
"to",
"be",
"added",
"."
] | async def async_added_to_hass(self):
await super().async_added_to_hass()
last_state = await self.async_get_last_state()
if last_state is not None:
self._hvac_mode = last_state.state
self._current_fan_mode = last_state.attributes['fan_mode']
self._target_temper... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"last_state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"last_state",
"is",
"not",
"None",
":",
"self",
... | Run when entity about to be added. | [
"Run",
"when",
"entity",
"about",
"to",
"be",
"added",
"."
] | [
"\"\"\"Run when entity about to be added.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
71923a33399e723240212f9982d47a6459a2709e | zoranke/BroadlinkCover | custom_components/broadlinkcover/climate.py | [
"MIT"
] | Python | _async_update_temp | null | def _async_update_temp(self, state):
"""Update thermostat with latest state from temperature sensor."""
try:
if state.state != STATE_UNKNOWN:
self._current_temperature = float(state.state)
except ValueError as ex:
_LOGGER.error("Unable to update from tempe... | Update thermostat with latest state from temperature sensor. | Update thermostat with latest state from temperature sensor. | [
"Update",
"thermostat",
"with",
"latest",
"state",
"from",
"temperature",
"sensor",
"."
] | def _async_update_temp(self, state):
try:
if state.state != STATE_UNKNOWN:
self._current_temperature = float(state.state)
except ValueError as ex:
_LOGGER.error("Unable to update from temperature sensor: %s", ex) | [
"def",
"_async_update_temp",
"(",
"self",
",",
"state",
")",
":",
"try",
":",
"if",
"state",
".",
"state",
"!=",
"STATE_UNKNOWN",
":",
"self",
".",
"_current_temperature",
"=",
"float",
"(",
"state",
".",
"state",
")",
"except",
"ValueError",
"as",
"ex",
... | Update thermostat with latest state from temperature sensor. | [
"Update",
"thermostat",
"with",
"latest",
"state",
"from",
"temperature",
"sensor",
"."
] | [
"\"\"\"Update thermostat with latest state from temperature sensor.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "state",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "state",
"type": null,
"docstring": null,
"docstring_tokens": ... |
71923a33399e723240212f9982d47a6459a2709e | zoranke/BroadlinkCover | custom_components/broadlinkcover/climate.py | [
"MIT"
] | Python | _async_update_humidity | null | def _async_update_humidity(self, state):
"""Update thermostat with latest state from humidity sensor."""
try:
if state.state != STATE_UNKNOWN:
self._current_humidity = float(state.state)
except ValueError as ex:
_LOGGER.error("Unable to update from humidit... | Update thermostat with latest state from humidity sensor. | Update thermostat with latest state from humidity sensor. | [
"Update",
"thermostat",
"with",
"latest",
"state",
"from",
"humidity",
"sensor",
"."
] | def _async_update_humidity(self, state):
try:
if state.state != STATE_UNKNOWN:
self._current_humidity = float(state.state)
except ValueError as ex:
_LOGGER.error("Unable to update from humidity sensor: %s", ex) | [
"def",
"_async_update_humidity",
"(",
"self",
",",
"state",
")",
":",
"try",
":",
"if",
"state",
".",
"state",
"!=",
"STATE_UNKNOWN",
":",
"self",
".",
"_current_humidity",
"=",
"float",
"(",
"state",
".",
"state",
")",
"except",
"ValueError",
"as",
"ex",
... | Update thermostat with latest state from humidity sensor. | [
"Update",
"thermostat",
"with",
"latest",
"state",
"from",
"humidity",
"sensor",
"."
] | [
"\"\"\"Update thermostat with latest state from humidity sensor.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "state",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "state",
"type": null,
"docstring": null,
"docstring_tokens": ... |
f72c6c14815e59ace61d84641f721f81f31b67ac | luweishuang/sentence-transformers | sentence_transformers/datasets/SentenceLabelDataset.py | [
"Apache-2.0"
] | Python | convert_input_examples | null | def convert_input_examples(self, examples: List[InputExample], model: SentenceTransformer):
"""
Converts input examples to a SentenceLabelDataset.
Assumes only one sentence per InputExample and labels as integers from 0 to max_num_labels
and should be used in combination with dataset_re... |
Converts input examples to a SentenceLabelDataset.
Assumes only one sentence per InputExample and labels as integers from 0 to max_num_labels
and should be used in combination with dataset_reader.LabelSentenceReader.
Labels with only one example are ignored.
:param examples:
... | Converts input examples to a SentenceLabelDataset.
Assumes only one sentence per InputExample and labels as integers from 0 to max_num_labels
and should be used in combination with dataset_reader.LabelSentenceReader.
Labels with only one example are ignored.
:param examples:
the input examples for the training
:param... | [
"Converts",
"input",
"examples",
"to",
"a",
"SentenceLabelDataset",
".",
"Assumes",
"only",
"one",
"sentence",
"per",
"InputExample",
"and",
"labels",
"as",
"integers",
"from",
"0",
"to",
"max_num_labels",
"and",
"should",
"be",
"used",
"in",
"combination",
"wit... | def convert_input_examples(self, examples: List[InputExample], model: SentenceTransformer):
inputs = []
labels = []
label_sent_mapping = {}
too_long = 0
label_type = None
logging.info("Start tokenization")
if not self.parallel_tokenization or self.max_processes ==... | [
"def",
"convert_input_examples",
"(",
"self",
",",
"examples",
":",
"List",
"[",
"InputExample",
"]",
",",
"model",
":",
"SentenceTransformer",
")",
":",
"inputs",
"=",
"[",
"]",
"labels",
"=",
"[",
"]",
"label_sent_mapping",
"=",
"{",
"}",
"too_long",
"="... | Converts input examples to a SentenceLabelDataset. | [
"Converts",
"input",
"examples",
"to",
"a",
"SentenceLabelDataset",
"."
] | [
"\"\"\"\n Converts input examples to a SentenceLabelDataset.\n\n Assumes only one sentence per InputExample and labels as integers from 0 to max_num_labels\n and should be used in combination with dataset_reader.LabelSentenceReader.\n\n Labels with only one example are ignored.\n\n ... | [
{
"param": "self",
"type": null
},
{
"param": "examples",
"type": "List[InputExample]"
},
{
"param": "model",
"type": "SentenceTransformer"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "examples",
"type": "List[InputExample]",
"docstring": null,
"... |
efcbaefeb6228f643750fbbfa3fda44b122b841b | emdupre/fmralign | examples/plot_alignment_simulated_2D_data.py | [
"BSD-3-Clause"
] | Python | _rotate | <not_specific> | def _rotate(origin, point, angle):
"""Rotate a point counterclockwise by a given angle around a given origin.
"""
ox, oy = origin
px, py = point
qx = ox + math.cos(angle) * (px - ox) - math.sin(angle) * (py - oy)
qy = oy + math.sin(angle) * (px - ox) + math.cos(angle) * (py - oy)
return qx, ... | Rotate a point counterclockwise by a given angle around a given origin.
| Rotate a point counterclockwise by a given angle around a given origin. | [
"Rotate",
"a",
"point",
"counterclockwise",
"by",
"a",
"given",
"angle",
"around",
"a",
"given",
"origin",
"."
] | def _rotate(origin, point, angle):
ox, oy = origin
px, py = point
qx = ox + math.cos(angle) * (px - ox) - math.sin(angle) * (py - oy)
qy = oy + math.sin(angle) * (px - ox) + math.cos(angle) * (py - oy)
return qx, qy | [
"def",
"_rotate",
"(",
"origin",
",",
"point",
",",
"angle",
")",
":",
"ox",
",",
"oy",
"=",
"origin",
"px",
",",
"py",
"=",
"point",
"qx",
"=",
"ox",
"+",
"math",
".",
"cos",
"(",
"angle",
")",
"*",
"(",
"px",
"-",
"ox",
")",
"-",
"math",
... | Rotate a point counterclockwise by a given angle around a given origin. | [
"Rotate",
"a",
"point",
"counterclockwise",
"by",
"a",
"given",
"angle",
"around",
"a",
"given",
"origin",
"."
] | [
"\"\"\"Rotate a point counterclockwise by a given angle around a given origin.\n \"\"\""
] | [
{
"param": "origin",
"type": null
},
{
"param": "point",
"type": null
},
{
"param": "angle",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "origin",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "point",
"type": null,
"docstring": null,
"docstring_tokens"... |
efcbaefeb6228f643750fbbfa3fda44b122b841b | emdupre/fmralign | examples/plot_alignment_simulated_2D_data.py | [
"BSD-3-Clause"
] | Python | _plot2D_samples_mat | null | def _plot2D_samples_mat(xs, xt, R, thr=1e-8, **kwargs):
""" Plot matrix R in 2D with lines for coefficients above threshold thr.
REPRODUCED FROM POT PACKAGE
"""
if ('color' not in kwargs) and ('c' not in kwargs):
kwargs['color'] = 'k'
mx = R.max()
for i in range(xs.shape[0]):
for... | Plot matrix R in 2D with lines for coefficients above threshold thr.
REPRODUCED FROM POT PACKAGE
| Plot matrix R in 2D with lines for coefficients above threshold thr.
REPRODUCED FROM POT PACKAGE | [
"Plot",
"matrix",
"R",
"in",
"2D",
"with",
"lines",
"for",
"coefficients",
"above",
"threshold",
"thr",
".",
"REPRODUCED",
"FROM",
"POT",
"PACKAGE"
] | def _plot2D_samples_mat(xs, xt, R, thr=1e-8, **kwargs):
if ('color' not in kwargs) and ('c' not in kwargs):
kwargs['color'] = 'k'
mx = R.max()
for i in range(xs.shape[0]):
for j in range(xt.shape[0]):
if R[i, j] / mx > thr:
plt.plot([xs[i, 0], xt[j, 0]], [xs[i, 1]... | [
"def",
"_plot2D_samples_mat",
"(",
"xs",
",",
"xt",
",",
"R",
",",
"thr",
"=",
"1e-8",
",",
"**",
"kwargs",
")",
":",
"if",
"(",
"'color'",
"not",
"in",
"kwargs",
")",
"and",
"(",
"'c'",
"not",
"in",
"kwargs",
")",
":",
"kwargs",
"[",
"'color'",
... | Plot matrix R in 2D with lines for coefficients above threshold thr. | [
"Plot",
"matrix",
"R",
"in",
"2D",
"with",
"lines",
"for",
"coefficients",
"above",
"threshold",
"thr",
"."
] | [
"\"\"\" Plot matrix R in 2D with lines for coefficients above threshold thr.\n REPRODUCED FROM POT PACKAGE\n \"\"\""
] | [
{
"param": "xs",
"type": null
},
{
"param": "xt",
"type": null
},
{
"param": "R",
"type": null
},
{
"param": "thr",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "xs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "xt",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
e8cca5350da99f682387b08c3ec3c4c85de86747 | emdupre/fmralign | fmralign/_utils.py | [
"BSD-3-Clause"
] | Python | _make_parcellation | <not_specific> | def _make_parcellation(imgs, clustering, n_pieces, masker, smoothing_fwhm=5, verbose=0):
"""Convenience function to use nilearn Parcellation class in our pipeline.
It is used to find local regions of the brain in which alignment will be later applied.
For alignment computational efficiency, regions should b... | Convenience function to use nilearn Parcellation class in our pipeline.
It is used to find local regions of the brain in which alignment will be later applied.
For alignment computational efficiency, regions should be of hundreds of voxels.
Parameters
----------
imgs: Niimgs
data to cluster... | Convenience function to use nilearn Parcellation class in our pipeline.
It is used to find local regions of the brain in which alignment will be later applied.
For alignment computational efficiency, regions should be of hundreds of voxels.
Parameters
Returns
labels : list of ints (len n_features)
Parcellation of ... | [
"Convenience",
"function",
"to",
"use",
"nilearn",
"Parcellation",
"class",
"in",
"our",
"pipeline",
".",
"It",
"is",
"used",
"to",
"find",
"local",
"regions",
"of",
"the",
"brain",
"in",
"which",
"alignment",
"will",
"be",
"later",
"applied",
".",
"For",
... | def _make_parcellation(imgs, clustering, n_pieces, masker, smoothing_fwhm=5, verbose=0):
if type(clustering) == nibabel.nifti1.Nifti1Image:
_check_same_fov(masker.mask_img_, clustering)
labels_img = clustering
else:
if clustering == "kmeans" and smoothing_fwhm is not None:
im... | [
"def",
"_make_parcellation",
"(",
"imgs",
",",
"clustering",
",",
"n_pieces",
",",
"masker",
",",
"smoothing_fwhm",
"=",
"5",
",",
"verbose",
"=",
"0",
")",
":",
"if",
"type",
"(",
"clustering",
")",
"==",
"nibabel",
".",
"nifti1",
".",
"Nifti1Image",
":... | Convenience function to use nilearn Parcellation class in our pipeline. | [
"Convenience",
"function",
"to",
"use",
"nilearn",
"Parcellation",
"class",
"in",
"our",
"pipeline",
"."
] | [
"\"\"\"Convenience function to use nilearn Parcellation class in our pipeline.\n It is used to find local regions of the brain in which alignment will be later applied.\n For alignment computational efficiency, regions should be of hundreds of voxels.\n\n Parameters\n ----------\n imgs: Niimgs\n ... | [
{
"param": "imgs",
"type": null
},
{
"param": "clustering",
"type": null
},
{
"param": "n_pieces",
"type": null
},
{
"param": "masker",
"type": null
},
{
"param": "smoothing_fwhm",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "imgs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clustering",
"type": null,
"docstring": null,
"docstring_toke... |
e8cca5350da99f682387b08c3ec3c4c85de86747 | emdupre/fmralign | fmralign/_utils.py | [
"BSD-3-Clause"
] | Python | voxelwise_correlation | <not_specific> | def voxelwise_correlation(ground_truth, prediction, masker):
"""
Parameters
----------
ground_truth: 3D or 4D Niimg
Reference image (data acquired but never used before and considered as missing)
prediction : 3D or 4D Niimg
Same shape as ground_truth
masker: instance of NiftiMask... |
Parameters
----------
ground_truth: 3D or 4D Niimg
Reference image (data acquired but never used before and considered as missing)
prediction : 3D or 4D Niimg
Same shape as ground_truth
masker: instance of NiftiMasker or MultiNiftiMasker
Masker to be used on ground_truth and... | Parameters
ground_truth: 3D or 4D Niimg
Reference image (data acquired but never used before and considered as missing)
prediction : 3D or 4D Niimg
Same shape as ground_truth
masker: instance of NiftiMasker or MultiNiftiMasker
Masker to be used on ground_truth and prediction.
Returns
voxelwise_correlation : 3D Niimg
... | [
"Parameters",
"ground_truth",
":",
"3D",
"or",
"4D",
"Niimg",
"Reference",
"image",
"(",
"data",
"acquired",
"but",
"never",
"used",
"before",
"and",
"considered",
"as",
"missing",
")",
"prediction",
":",
"3D",
"or",
"4D",
"Niimg",
"Same",
"shape",
"as",
"... | def voxelwise_correlation(ground_truth, prediction, masker):
X_gt = masker.transform(ground_truth)
X_pred = masker.transform(prediction)
voxelwise_correlation = np.array([pearsonr(X_gt[:, vox], X_pred[:, vox])[0]
for vox in range(X_pred.shape[1])])
return masker.inv... | [
"def",
"voxelwise_correlation",
"(",
"ground_truth",
",",
"prediction",
",",
"masker",
")",
":",
"X_gt",
"=",
"masker",
".",
"transform",
"(",
"ground_truth",
")",
"X_pred",
"=",
"masker",
".",
"transform",
"(",
"prediction",
")",
"voxelwise_correlation",
"=",
... | Parameters
ground_truth: 3D or 4D Niimg
Reference image (data acquired but never used before and considered as missing)
prediction : 3D or 4D Niimg
Same shape as ground_truth
masker: instance of NiftiMasker or MultiNiftiMasker
Masker to be used on ground_truth and prediction. | [
"Parameters",
"ground_truth",
":",
"3D",
"or",
"4D",
"Niimg",
"Reference",
"image",
"(",
"data",
"acquired",
"but",
"never",
"used",
"before",
"and",
"considered",
"as",
"missing",
")",
"prediction",
":",
"3D",
"or",
"4D",
"Niimg",
"Same",
"shape",
"as",
"... | [
"\"\"\"\n Parameters\n ----------\n ground_truth: 3D or 4D Niimg\n Reference image (data acquired but never used before and considered as missing)\n prediction : 3D or 4D Niimg\n Same shape as ground_truth\n masker: instance of NiftiMasker or MultiNiftiMasker\n Masker to be used ... | [
{
"param": "ground_truth",
"type": null
},
{
"param": "prediction",
"type": null
},
{
"param": "masker",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ground_truth",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prediction",
"type": null,
"docstring": null,
"docstr... |
1c3109a7f8d581710331ce81326405acb22b82e2 | emdupre/fmralign | fmralign/fetch_example_data.py | [
"BSD-3-Clause"
] | Python | fetch_ibc_subjects_contrasts | <not_specific> | def fetch_ibc_subjects_contrasts(subjects, data_dir=None, verbose=1):
"""Fetch all IBC contrast maps for each of subjects.
After downloading all relevant images that are not already cached,
it returns a dataframe with all needed links.
Parameters
----------
subjects : list of str.
Subje... | Fetch all IBC contrast maps for each of subjects.
After downloading all relevant images that are not already cached,
it returns a dataframe with all needed links.
Parameters
----------
subjects : list of str.
Subjects data to download. Available strings are ['sub-01', 'sub-02',
'sub... | Fetch all IBC contrast maps for each of subjects.
After downloading all relevant images that are not already cached,
it returns a dataframe with all needed links.
Parameters
subjects : list of str.
Subjects data to download.
Returns
files : list of list of str
List (for every subject) of list of path (for every con... | [
"Fetch",
"all",
"IBC",
"contrast",
"maps",
"for",
"each",
"of",
"subjects",
".",
"After",
"downloading",
"all",
"relevant",
"images",
"that",
"are",
"not",
"already",
"cached",
"it",
"returns",
"a",
"dataframe",
"with",
"all",
"needed",
"links",
".",
"Parame... | def fetch_ibc_subjects_contrasts(subjects, data_dir=None, verbose=1):
if subjects is "all":
subjects = ['sub-%02d' %
i for i in [1, 2, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15]]
dataset_name = 'ibc'
data_dir = _get_dataset_dir(dataset_name, data_dir=data_dir,
... | [
"def",
"fetch_ibc_subjects_contrasts",
"(",
"subjects",
",",
"data_dir",
"=",
"None",
",",
"verbose",
"=",
"1",
")",
":",
"if",
"subjects",
"is",
"\"all\"",
":",
"subjects",
"=",
"[",
"'sub-%02d'",
"%",
"i",
"for",
"i",
"in",
"[",
"1",
",",
"2",
",",
... | Fetch all IBC contrast maps for each of subjects. | [
"Fetch",
"all",
"IBC",
"contrast",
"maps",
"for",
"each",
"of",
"subjects",
"."
] | [
"\"\"\"Fetch all IBC contrast maps for each of subjects.\n After downloading all relevant images that are not already cached,\n it returns a dataframe with all needed links.\n\n Parameters\n ----------\n subjects : list of str.\n Subjects data to download. Available strings are ['sub-01', 'sub... | [
{
"param": "subjects",
"type": null
},
{
"param": "data_dir",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "subjects",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data_dir",
"type": null,
"docstring": null,
"docstring_to... |
a4e5535d9cbc72860eb54e4e6959365df44f5e72 | ZeroTwo36/infinipy | infinipy/syncHookHTTP.py | [
"MIT"
] | Python | check | <not_specific> | def check(webhook,func,request):
"""
The check function is used to verify that the request is coming from a trusted source.
The check function takes in a webhook object and returns a decorator which will run the decorated function only if
the request is authenticated with the correct secret key.
... |
The check function is used to verify that the request is coming from a trusted source.
The check function takes in a webhook object and returns a decorator which will run the decorated function only if
the request is authenticated with the correct secret key.
:param webhook: Used to Pass the webho... | The check function is used to verify that the request is coming from a trusted source.
The check function takes in a webhook object and returns a decorator which will run the decorated function only if
the request is authenticated with the correct secret key. | [
"The",
"check",
"function",
"is",
"used",
"to",
"verify",
"that",
"the",
"request",
"is",
"coming",
"from",
"a",
"trusted",
"source",
".",
"The",
"check",
"function",
"takes",
"in",
"a",
"webhook",
"object",
"and",
"returns",
"a",
"decorator",
"which",
"wi... | def check(webhook,func,request):
if request.method == "POST" and request.headers.get("Authorization") == webhook.secret_key:
func()
return True
return False | [
"def",
"check",
"(",
"webhook",
",",
"func",
",",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"\"POST\"",
"and",
"request",
".",
"headers",
".",
"get",
"(",
"\"Authorization\"",
")",
"==",
"webhook",
".",
"secret_key",
":",
"func",
"(",
... | The check function is used to verify that the request is coming from a trusted source. | [
"The",
"check",
"function",
"is",
"used",
"to",
"verify",
"that",
"the",
"request",
"is",
"coming",
"from",
"a",
"trusted",
"source",
"."
] | [
"\"\"\"\n The check function is used to verify that the request is coming from a trusted source.\n The check function takes in a webhook object and returns a decorator which will run the decorated function only if\n the request is authenticated with the correct secret key.\n \n :param webhook: Used t... | [
{
"param": "webhook",
"type": null
},
{
"param": "func",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [
{
"docstring": "A function that is used as a decorator.",
"docstring_tokens": [
"A",
"function",
"that",
"is",
"used",
"as",
"a",
"decorator",
"."
],
"type": null
}
],
"raises": [],
"params": [... |
a82a05035f1aaa7609886b63cabaddee809f7c8a | ZeroTwo36/infinipy | infinipy/core.py | [
"MIT"
] | Python | jsonify | <not_specific> | def jsonify(this):
"""
Returns the Classes Variables as JSON/Dicts
"""
return vars(this) |
Returns the Classes Variables as JSON/Dicts
| Returns the Classes Variables as JSON/Dicts | [
"Returns",
"the",
"Classes",
"Variables",
"as",
"JSON",
"/",
"Dicts"
] | def jsonify(this):
return vars(this) | [
"def",
"jsonify",
"(",
"this",
")",
":",
"return",
"vars",
"(",
"this",
")"
] | Returns the Classes Variables as JSON/Dicts | [
"Returns",
"the",
"Classes",
"Variables",
"as",
"JSON",
"/",
"Dicts"
] | [
"\"\"\"\r\n Returns the Classes Variables as JSON/Dicts\r\n \"\"\""
] | [
{
"param": "this",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "this",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a82a05035f1aaa7609886b63cabaddee809f7c8a | ZeroTwo36/infinipy | infinipy/core.py | [
"MIT"
] | Python | postStats | null | def postStats(self,shards:int=0,servers:int=0):
"""
Post stats to IBL's API
:param shards: Shard Count
:param servers: Server Count
Sample Usage:
.. code-block:: py
from infinipy import SyncAPISession
cs = SyncAPISession("A... |
Post stats to IBL's API
:param shards: Shard Count
:param servers: Server Count
Sample Usage:
.. code-block:: py
from infinipy import SyncAPISession
cs = SyncAPISession("API_TOKEN")
cs.postStats(servers=12)
| Post stats to IBL's API | [
"Post",
"stats",
"to",
"IBL",
"'",
"s",
"API"
] | def postStats(self,shards:int=0,servers:int=0):
data = {
'servers':servers,
'shards':shards
}
resp = self._post('bots/stats',jsondata=data)
self.session['UPDATE_RESPONSE'] = resp | [
"def",
"postStats",
"(",
"self",
",",
"shards",
":",
"int",
"=",
"0",
",",
"servers",
":",
"int",
"=",
"0",
")",
":",
"data",
"=",
"{",
"'servers'",
":",
"servers",
",",
"'shards'",
":",
"shards",
"}",
"resp",
"=",
"self",
".",
"_post",
"(",
"'bo... | Post stats to IBL's API | [
"Post",
"stats",
"to",
"IBL",
"'",
"s",
"API"
] | [
"\"\"\"\r\n Post stats to IBL's API\r\n\r\n :param shards: Shard Count\r\n :param servers: Server Count \r\n\r\n Sample Usage:\r\n \r\n .. code-block:: py\r\n from infinipy import SyncAPISession\r\n\r\n cs = SyncAPISession(\"API_TOKEN\")\r\n ... | [
{
"param": "self",
"type": null
},
{
"param": "shards",
"type": "int"
},
{
"param": "servers",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "shards",
"type": "int",
"docstring": null,
"docstring_tokens"... |
24d617ccadcdf3c72d0ab4f6929177346220b13a | ZeroTwo36/infinipy | infinipy/helpers.py | [
"MIT"
] | Python | endpoint_for | <not_specific> | def endpoint_for(user_id):
"""Determines whether an ID belongs to the /user or to /bots endpoint
"""
req = requests.get(f"https://japi.rest/discord/v1/user/{user_id}").json()
if "bot" in req["data"] and req["data"]["bot"] == True:
return f'/bots/{user_id}'
return f'/user/{user_id}' | Determines whether an ID belongs to the /user or to /bots endpoint
| Determines whether an ID belongs to the /user or to /bots endpoint | [
"Determines",
"whether",
"an",
"ID",
"belongs",
"to",
"the",
"/",
"user",
"or",
"to",
"/",
"bots",
"endpoint"
] | def endpoint_for(user_id):
req = requests.get(f"https://japi.rest/discord/v1/user/{user_id}").json()
if "bot" in req["data"] and req["data"]["bot"] == True:
return f'/bots/{user_id}'
return f'/user/{user_id}' | [
"def",
"endpoint_for",
"(",
"user_id",
")",
":",
"req",
"=",
"requests",
".",
"get",
"(",
"f\"https://japi.rest/discord/v1/user/{user_id}\"",
")",
".",
"json",
"(",
")",
"if",
"\"bot\"",
"in",
"req",
"[",
"\"data\"",
"]",
"and",
"req",
"[",
"\"data\"",
"]",
... | Determines whether an ID belongs to the /user or to /bots endpoint | [
"Determines",
"whether",
"an",
"ID",
"belongs",
"to",
"the",
"/",
"user",
"or",
"to",
"/",
"bots",
"endpoint"
] | [
"\"\"\"Determines whether an ID belongs to the /user or to /bots endpoint\r\n \"\"\""
] | [
{
"param": "user_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "user_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f29b2e19320b965ab311da20b84ada8d336663c9 | abulte/python-influxdb-alerts | monitor.py | [
"MIT"
] | Python | run | null | def run(verbose, config):
"""Parse indicator values and alert if needed"""
hosts, indicators, alerters = setup(config)
for host in hosts:
for indicator in indicators:
alert = False
value = indicator.get_value(host)
if value and indicator.is_alert(host, value=value... | Parse indicator values and alert if needed | Parse indicator values and alert if needed | [
"Parse",
"indicator",
"values",
"and",
"alert",
"if",
"needed"
] | def run(verbose, config):
hosts, indicators, alerters = setup(config)
for host in hosts:
for indicator in indicators:
alert = False
value = indicator.get_value(host)
if value and indicator.is_alert(host, value=value):
alert = True
for a... | [
"def",
"run",
"(",
"verbose",
",",
"config",
")",
":",
"hosts",
",",
"indicators",
",",
"alerters",
"=",
"setup",
"(",
"config",
")",
"for",
"host",
"in",
"hosts",
":",
"for",
"indicator",
"in",
"indicators",
":",
"alert",
"=",
"False",
"value",
"=",
... | Parse indicator values and alert if needed | [
"Parse",
"indicator",
"values",
"and",
"alert",
"if",
"needed"
] | [
"\"\"\"Parse indicator values and alert if needed\"\"\""
] | [
{
"param": "verbose",
"type": null
},
{
"param": "config",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "verbose",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config",
"type": null,
"docstring": null,
"docstring_token... |
74d63eff62587b07c71f453631dbdd3c5ff65317 | abulte/python-influxdb-alerts | query.py | [
"MIT"
] | Python | query_last_mean | <not_specific> | def query_last_mean(self, indicator, host, timeframe='10m', filters=None):
"""Get the last mean value of the indicator"""
if filters is not None:
filters_str = ' AND '
for k, v in filters.items():
filters_str += "%s = '%s'" % (k, v)
filters_str += ' '
... | Get the last mean value of the indicator | Get the last mean value of the indicator | [
"Get",
"the",
"last",
"mean",
"value",
"of",
"the",
"indicator"
] | def query_last_mean(self, indicator, host, timeframe='10m', filters=None):
if filters is not None:
filters_str = ' AND '
for k, v in filters.items():
filters_str += "%s = '%s'" % (k, v)
filters_str += ' '
else:
filters_str = ''
quer... | [
"def",
"query_last_mean",
"(",
"self",
",",
"indicator",
",",
"host",
",",
"timeframe",
"=",
"'10m'",
",",
"filters",
"=",
"None",
")",
":",
"if",
"filters",
"is",
"not",
"None",
":",
"filters_str",
"=",
"' AND '",
"for",
"k",
",",
"v",
"in",
"filters"... | Get the last mean value of the indicator | [
"Get",
"the",
"last",
"mean",
"value",
"of",
"the",
"indicator"
] | [
"\"\"\"Get the last mean value of the indicator\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "indicator",
"type": null
},
{
"param": "host",
"type": null
},
{
"param": "timeframe",
"type": null
},
{
"param": "filters",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "indicator",
"type": null,
"docstring": null,
"docstring_token... |
518cbea5c562284c593ce1baf95f933fea0e9083 | aquadrop/leetcode | leetcode225.py | [
"MIT"
] | Python | push | null | def push(self, x):
"""
Push element x onto stack.
:type x: int
:rtype: void
""" |
Push element x onto stack.
:type x: int
:rtype: void
| Push element x onto stack. | [
"Push",
"element",
"x",
"onto",
"stack",
"."
] | def push(self, x): | [
"def",
"push",
"(",
"self",
",",
"x",
")",
":"
] | Push element x onto stack. | [
"Push",
"element",
"x",
"onto",
"stack",
"."
] | [
"\"\"\"\n Push element x onto stack.\n :type x: int\n :rtype: void\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "void"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
518cbea5c562284c593ce1baf95f933fea0e9083 | aquadrop/leetcode | leetcode225.py | [
"MIT"
] | Python | pop | null | def pop(self):
"""
Removes the element on top of the stack and returns that element.
:rtype: int
""" |
Removes the element on top of the stack and returns that element.
:rtype: int
| Removes the element on top of the stack and returns that element. | [
"Removes",
"the",
"element",
"on",
"top",
"of",
"the",
"stack",
"and",
"returns",
"that",
"element",
"."
] | def pop(self): | [
"def",
"pop",
"(",
"self",
")",
":"
] | Removes the element on top of the stack and returns that element. | [
"Removes",
"the",
"element",
"on",
"top",
"of",
"the",
"stack",
"and",
"returns",
"that",
"element",
"."
] | [
"\"\"\"\n Removes the element on top of the stack and returns that element.\n :rtype: int\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "int"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
518cbea5c562284c593ce1baf95f933fea0e9083 | aquadrop/leetcode | leetcode225.py | [
"MIT"
] | Python | empty | null | def empty(self):
"""
Returns whether the stack is empty.
:rtype: bool
""" |
Returns whether the stack is empty.
:rtype: bool
| Returns whether the stack is empty. | [
"Returns",
"whether",
"the",
"stack",
"is",
"empty",
"."
] | def empty(self): | [
"def",
"empty",
"(",
"self",
")",
":"
] | Returns whether the stack is empty. | [
"Returns",
"whether",
"the",
"stack",
"is",
"empty",
"."
] | [
"\"\"\"\n Returns whether the stack is empty.\n :rtype: bool\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
4d355a09da411ab58a3c43bdec862cd3409ec598 | aquadrop/leetcode | leetcode449.py | [
"MIT"
] | Python | serialize | <not_specific> | def serialize(self, root):
"""Encodes a tree to a single string.
:type root: TreeNode
:rtype: str
"""
strings = []
def pre_search(node):
if not node:
return
strings.append(node.val)
pre_search(node.left)
pre... | Encodes a tree to a single string.
:type root: TreeNode
:rtype: str
| Encodes a tree to a single string. | [
"Encodes",
"a",
"tree",
"to",
"a",
"single",
"string",
"."
] | def serialize(self, root):
strings = []
def pre_search(node):
if not node:
return
strings.append(node.val)
pre_search(node.left)
pre_search(node.right)
pre_search(root)
return '#'.join(str(s) for s in strings) | [
"def",
"serialize",
"(",
"self",
",",
"root",
")",
":",
"strings",
"=",
"[",
"]",
"def",
"pre_search",
"(",
"node",
")",
":",
"if",
"not",
"node",
":",
"return",
"strings",
".",
"append",
"(",
"node",
".",
"val",
")",
"pre_search",
"(",
"node",
"."... | Encodes a tree to a single string. | [
"Encodes",
"a",
"tree",
"to",
"a",
"single",
"string",
"."
] | [
"\"\"\"Encodes a tree to a single string.\n\n :type root: TreeNode\n :rtype: str\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "root",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "str"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
4d355a09da411ab58a3c43bdec862cd3409ec598 | aquadrop/leetcode | leetcode449.py | [
"MIT"
] | Python | deserialize | <not_specific> | def deserialize(self, data):
"""Decodes your encoded data to tree.
:type data: str
:rtype: TreeNode
"""
if not data:
return None
strings = data.split('#')
def insert(x, node):
if x < node.val:
if not node.left:
... | Decodes your encoded data to tree.
:type data: str
:rtype: TreeNode
| Decodes your encoded data to tree. | [
"Decodes",
"your",
"encoded",
"data",
"to",
"tree",
"."
] | def deserialize(self, data):
if not data:
return None
strings = data.split('#')
def insert(x, node):
if x < node.val:
if not node.left:
node.left = TreeNode(x)
else:
insert(x, node.left)
e... | [
"def",
"deserialize",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"data",
":",
"return",
"None",
"strings",
"=",
"data",
".",
"split",
"(",
"'#'",
")",
"def",
"insert",
"(",
"x",
",",
"node",
")",
":",
"if",
"x",
"<",
"node",
".",
"val",
"... | Decodes your encoded data to tree. | [
"Decodes",
"your",
"encoded",
"data",
"to",
"tree",
"."
] | [
"\"\"\"Decodes your encoded data to tree.\n\n :type data: str\n :rtype: TreeNode\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "TreeNode"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": n... |
2e0385b57a710915d543bcf7ecd054ea0bca9836 | saintlyzero/aerich | aerich/migrate.py | [
"Apache-2.0"
] | Python | _add_operator | null | def _add_operator(cls, operator: str, upgrade=True, fk=False):
"""
add operator,differentiate fk because fk is order limit
:param operator:
:param upgrade:
:param fk_m2m:
:return:
"""
if upgrade:
if fk:
cls._upgrade_fk_m2m_index... |
add operator,differentiate fk because fk is order limit
:param operator:
:param upgrade:
:param fk_m2m:
:return:
| add operator,differentiate fk because fk is order limit | [
"add",
"operator",
"differentiate",
"fk",
"because",
"fk",
"is",
"order",
"limit"
] | def _add_operator(cls, operator: str, upgrade=True, fk=False):
if upgrade:
if fk:
cls._upgrade_fk_m2m_index_operators.append(operator)
else:
cls.upgrade_operators.append(operator)
else:
if fk:
cls._downgrade_fk_m2m_index... | [
"def",
"_add_operator",
"(",
"cls",
",",
"operator",
":",
"str",
",",
"upgrade",
"=",
"True",
",",
"fk",
"=",
"False",
")",
":",
"if",
"upgrade",
":",
"if",
"fk",
":",
"cls",
".",
"_upgrade_fk_m2m_index_operators",
".",
"append",
"(",
"operator",
")",
... | add operator,differentiate fk because fk is order limit | [
"add",
"operator",
"differentiate",
"fk",
"because",
"fk",
"is",
"order",
"limit"
] | [
"\"\"\"\n add operator,differentiate fk because fk is order limit\n :param operator:\n :param upgrade:\n :param fk_m2m:\n :return:\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "operator",
"type": "str"
},
{
"param": "upgrade",
"type": null
},
{
"param": "fk",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.