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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5537a97283785e954381b68b74364d84fa2a75f6 | bergzand/matrix-zabbix-bot | zabbix_bot.py | [
"Apache-2.0"
] | Python | zabbix_callback | <not_specific> | def zabbix_callback(room, event):
"""Callback function for the !zabbix matches.
:param room: reference to the room
:type room: room thingie
:param event: the message, essentially
:type event: event
"""
try:
room_id, zabbix_config = _room_init(room)
if room_id is None:
... | Callback function for the !zabbix matches.
:param room: reference to the room
:type room: room thingie
:param event: the message, essentially
:type event: event
| Callback function for the !zabbix matches. | [
"Callback",
"function",
"for",
"the",
"!zabbix",
"matches",
"."
] | def zabbix_callback(room, event):
try:
room_id, zabbix_config = _room_init(room)
if room_id is None:
return
args = event['content']['body'].split()
args.pop(0)
messages = []
if len(args) == 0:
messages = _zabbix_unacked_triggers(zabbix_config)
... | [
"def",
"zabbix_callback",
"(",
"room",
",",
"event",
")",
":",
"try",
":",
"room_id",
",",
"zabbix_config",
"=",
"_room_init",
"(",
"room",
")",
"if",
"room_id",
"is",
"None",
":",
"return",
"args",
"=",
"event",
"[",
"'content'",
"]",
"[",
"'body'",
"... | Callback function for the !zabbix matches. | [
"Callback",
"function",
"for",
"the",
"!zabbix",
"matches",
"."
] | [
"\"\"\"Callback function for the !zabbix matches.\n\n :param room: reference to the room\n :type room: room thingie\n :param event: the message, essentially\n :type event: event\n \"\"\"",
"# elif arg == 'hosts':",
"# hosts = zabbix.hosts(zabbix_config)",
"# Keep running!"
] | [
{
"param": "room",
"type": null
},
{
"param": "event",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "room",
"type": null,
"docstring": "reference to the room",
"docstring_tokens": [
"reference",
"to",
"the",
"room"
],
"default": null,
"is_optional": null
},
{
"id... |
5537a97283785e954381b68b74364d84fa2a75f6 | bergzand/matrix-zabbix-bot | zabbix_bot.py | [
"Apache-2.0"
] | Python | _dnsjedi_help | <not_specific> | def _dnsjedi_help():
"""Returns the help text for the !dnsjedi command.
"""
help_text = (
"Usage: !dnsjedi {arguments}"
"<br /><br />"
"This command returns current statistics for dnsjedi measurements."
"<br />"
"Currently supported arguments:"
"<br /><br />"
... | Returns the help text for the !dnsjedi command.
| Returns the help text for the !dnsjedi command. | [
"Returns",
"the",
"help",
"text",
"for",
"the",
"!dnsjedi",
"command",
"."
] | def _dnsjedi_help():
help_text = (
"Usage: !dnsjedi {arguments}"
"<br /><br />"
"This command returns current statistics for dnsjedi measurements."
"<br />"
"Currently supported arguments:"
"<br /><br />"
"left: queries the clustermangers how many chunks are l... | [
"def",
"_dnsjedi_help",
"(",
")",
":",
"help_text",
"=",
"(",
"\"Usage: !dnsjedi {arguments}\"",
"\"<br /><br />\"",
"\"This command returns current statistics for dnsjedi measurements.\"",
"\"<br />\"",
"\"Currently supported arguments:\"",
"\"<br /><br />\"",
"\"left: queries the clust... | Returns the help text for the !dnsjedi command. | [
"Returns",
"the",
"help",
"text",
"for",
"the",
"!dnsjedi",
"command",
"."
] | [
"\"\"\"Returns the help text for the !dnsjedi command.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5537a97283785e954381b68b74364d84fa2a75f6 | bergzand/matrix-zabbix-bot | zabbix_bot.py | [
"Apache-2.0"
] | Python | _dnsjedi_forecast_format | <not_specific> | def _dnsjedi_forecast_format(value):
"""Converts a forecast value string into a formatted string.
:param value: seconds string
:type value: str
:return: formatted string
"""
seconds = int(float(value))
logging.debug(seconds)
if seconds == 999999999999:
time_left = "done in a lon... | Converts a forecast value string into a formatted string.
:param value: seconds string
:type value: str
:return: formatted string
| Converts a forecast value string into a formatted string. | [
"Converts",
"a",
"forecast",
"value",
"string",
"into",
"a",
"formatted",
"string",
"."
] | def _dnsjedi_forecast_format(value):
seconds = int(float(value))
logging.debug(seconds)
if seconds == 999999999999:
time_left = "done in a long time"
else:
time_delta = datetime.timedelta(seconds=seconds)
done = datetime.datetime.utcnow() + time_delta
warning = ""
... | [
"def",
"_dnsjedi_forecast_format",
"(",
"value",
")",
":",
"seconds",
"=",
"int",
"(",
"float",
"(",
"value",
")",
")",
"logging",
".",
"debug",
"(",
"seconds",
")",
"if",
"seconds",
"==",
"999999999999",
":",
"time_left",
"=",
"\"done in a long time\"",
"el... | Converts a forecast value string into a formatted string. | [
"Converts",
"a",
"forecast",
"value",
"string",
"into",
"a",
"formatted",
"string",
"."
] | [
"\"\"\"Converts a forecast value string into a formatted string.\n\n :param value: seconds string\n :type value: str\n :return: formatted string\n \"\"\""
] | [
{
"param": "value",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
5537a97283785e954381b68b74364d84fa2a75f6 | bergzand/matrix-zabbix-bot | zabbix_bot.py | [
"Apache-2.0"
] | Python | _dnsjedi_chunks_summary | <not_specific> | def _dnsjedi_chunks_summary(zabbix_config):
"""Returns a summary about the clustermanager chunks.
:param zabbix_config: the zabbix configuration
:type zabbix_config: dict
:return: message to send back
"""
color_config = {}
for key, value in matrix.read_config(args['config'], 'Colors').items... | Returns a summary about the clustermanager chunks.
:param zabbix_config: the zabbix configuration
:type zabbix_config: dict
:return: message to send back
| Returns a summary about the clustermanager chunks. | [
"Returns",
"a",
"summary",
"about",
"the",
"clustermanager",
"chunks",
"."
] | def _dnsjedi_chunks_summary(zabbix_config):
color_config = {}
for key, value in matrix.read_config(args['config'], 'Colors').items():
if key.startswith('dnsjedi'):
key = key.replace('dnsjedi_', '')
color_config[key] = value
logging.debug(color_config)
lines = []
clust... | [
"def",
"_dnsjedi_chunks_summary",
"(",
"zabbix_config",
")",
":",
"color_config",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"matrix",
".",
"read_config",
"(",
"args",
"[",
"'config'",
"]",
",",
"'Colors'",
")",
".",
"items",
"(",
")",
":",
"if",
... | Returns a summary about the clustermanager chunks. | [
"Returns",
"a",
"summary",
"about",
"the",
"clustermanager",
"chunks",
"."
] | [
"\"\"\"Returns a summary about the clustermanager chunks.\n\n :param zabbix_config: the zabbix configuration\n :type zabbix_config: dict\n :return: message to send back\n \"\"\""
] | [
{
"param": "zabbix_config",
"type": null
}
] | {
"returns": [
{
"docstring": "message to send back",
"docstring_tokens": [
"message",
"to",
"send",
"back"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "zabbix_config",
"type": null,
"docstring": "the zabbix... |
5537a97283785e954381b68b74364d84fa2a75f6 | bergzand/matrix-zabbix-bot | zabbix_bot.py | [
"Apache-2.0"
] | Python | _dnsjedi_chunks_left | <not_specific> | def _dnsjedi_chunks_left(zabbix_config):
"""Returns the chunks left for each clustermanager.
:param zabbix_config: the zabbix configuration
:type zabbix_config: dict
:return: message to send back
"""
lines = []
clustermanagers = zabbix.get_itemvalues_for_group(
zabbix_config, 'Clust... | Returns the chunks left for each clustermanager.
:param zabbix_config: the zabbix configuration
:type zabbix_config: dict
:return: message to send back
| Returns the chunks left for each clustermanager. | [
"Returns",
"the",
"chunks",
"left",
"for",
"each",
"clustermanager",
"."
] | def _dnsjedi_chunks_left(zabbix_config):
lines = []
clustermanagers = zabbix.get_itemvalues_for_group(
zabbix_config, 'Clustermanagers',
['cms.chunks_left',
])
if clustermanagers is not None:
for name, value in sorted(clustermanagers.items()):
left = value[0]
... | [
"def",
"_dnsjedi_chunks_left",
"(",
"zabbix_config",
")",
":",
"lines",
"=",
"[",
"]",
"clustermanagers",
"=",
"zabbix",
".",
"get_itemvalues_for_group",
"(",
"zabbix_config",
",",
"'Clustermanagers'",
",",
"[",
"'cms.chunks_left'",
",",
"]",
")",
"if",
"clusterma... | Returns the chunks left for each clustermanager. | [
"Returns",
"the",
"chunks",
"left",
"for",
"each",
"clustermanager",
"."
] | [
"\"\"\"Returns the chunks left for each clustermanager.\n\n :param zabbix_config: the zabbix configuration\n :type zabbix_config: dict\n :return: message to send back\n \"\"\""
] | [
{
"param": "zabbix_config",
"type": null
}
] | {
"returns": [
{
"docstring": "message to send back",
"docstring_tokens": [
"message",
"to",
"send",
"back"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "zabbix_config",
"type": null,
"docstring": "the zabbix... |
5537a97283785e954381b68b74364d84fa2a75f6 | bergzand/matrix-zabbix-bot | zabbix_bot.py | [
"Apache-2.0"
] | Python | _dnsjedi_chunks_forecast | <not_specific> | def _dnsjedi_chunks_forecast(zabbix_config):
"""Returns the chunks forecast for each clustermanager.
:param zabbix_config: the zabbix configuration
:type zabbix_config: dict
:return: message to send back
"""
lines = []
clustermanagers = zabbix.get_itemvalues_for_group(
zabbix_config... | Returns the chunks forecast for each clustermanager.
:param zabbix_config: the zabbix configuration
:type zabbix_config: dict
:return: message to send back
| Returns the chunks forecast for each clustermanager. | [
"Returns",
"the",
"chunks",
"forecast",
"for",
"each",
"clustermanager",
"."
] | def _dnsjedi_chunks_forecast(zabbix_config):
lines = []
clustermanagers = zabbix.get_itemvalues_for_group(
zabbix_config, 'Clustermanagers',
['cms.co_queue_len_forecast',
])
if clustermanagers is not None:
for name, value in sorted(clustermanagers.items()):
loggi... | [
"def",
"_dnsjedi_chunks_forecast",
"(",
"zabbix_config",
")",
":",
"lines",
"=",
"[",
"]",
"clustermanagers",
"=",
"zabbix",
".",
"get_itemvalues_for_group",
"(",
"zabbix_config",
",",
"'Clustermanagers'",
",",
"[",
"'cms.co_queue_len_forecast'",
",",
"]",
")",
"if"... | Returns the chunks forecast for each clustermanager. | [
"Returns",
"the",
"chunks",
"forecast",
"for",
"each",
"clustermanager",
"."
] | [
"\"\"\"Returns the chunks forecast for each clustermanager.\n\n :param zabbix_config: the zabbix configuration\n :type zabbix_config: dict\n :return: message to send back\n \"\"\""
] | [
{
"param": "zabbix_config",
"type": null
}
] | {
"returns": [
{
"docstring": "message to send back",
"docstring_tokens": [
"message",
"to",
"send",
"back"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "zabbix_config",
"type": null,
"docstring": "the zabbix... |
5537a97283785e954381b68b74364d84fa2a75f6 | bergzand/matrix-zabbix-bot | zabbix_bot.py | [
"Apache-2.0"
] | Python | dnsjedi_callback | <not_specific> | def dnsjedi_callback(room, event):
"""Callback function for the !dnsjedi matches.
:param room: reference to the room
:type room: room thingie
:param event: the message, essentially
:type event: event
"""
try:
room_id, zabbix_config = _room_init(room)
if room_id is None:
... | Callback function for the !dnsjedi matches.
:param room: reference to the room
:type room: room thingie
:param event: the message, essentially
:type event: event
| Callback function for the !dnsjedi matches. | [
"Callback",
"function",
"for",
"the",
"!dnsjedi",
"matches",
"."
] | def dnsjedi_callback(room, event):
try:
room_id, zabbix_config = _room_init(room)
if room_id is None:
return
if room_id not in ['!OUZabccnPEwNGbzecZ', '!OTdomlClomfOdIOdOa']:
return
args = event['content']['body'].split()
args.pop(0)
if len(arg... | [
"def",
"dnsjedi_callback",
"(",
"room",
",",
"event",
")",
":",
"try",
":",
"room_id",
",",
"zabbix_config",
"=",
"_room_init",
"(",
"room",
")",
"if",
"room_id",
"is",
"None",
":",
"return",
"if",
"room_id",
"not",
"in",
"[",
"'!OUZabccnPEwNGbzecZ'",
",",... | Callback function for the !dnsjedi matches. | [
"Callback",
"function",
"for",
"the",
"!dnsjedi",
"matches",
"."
] | [
"\"\"\"Callback function for the !dnsjedi matches.\n\n :param room: reference to the room\n :type room: room thingie\n :param event: the message, essentially\n :type event: event\n \"\"\"",
"# Keep running!"
] | [
{
"param": "room",
"type": null
},
{
"param": "event",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "room",
"type": null,
"docstring": "reference to the room",
"docstring_tokens": [
"reference",
"to",
"the",
"room"
],
"default": null,
"is_optional": null
},
{
"id... |
bb48f66d7c29fb5f6e6606476ee9e0e8a9132b04 | ijkilchenko/siMLpy | Algorithms.py | [
"MIT"
] | Python | kmeanspp | <not_specific> | def kmeanspp(X, k, **kwargs):
'''
Performs k-means on X into k clusters. Initialization of the k centroids is done via k-means++.
:param X: X is an iterable of iterables, e.g., [[1, 2], [3, 4]] or ((1), (2)).
:param k: number of clusters.
:param kwargs['fn']: select a distance function ... |
Performs k-means on X into k clusters. Initialization of the k centroids is done via k-means++.
:param X: X is an iterable of iterables, e.g., [[1, 2], [3, 4]] or ((1), (2)).
:param k: number of clusters.
:param kwargs['fn']: select a distance function (default is 'euclid') or provide your ... | Performs k-means on X into k clusters. Initialization of the k centroids is done via k-means++. | [
"Performs",
"k",
"-",
"means",
"on",
"X",
"into",
"k",
"clusters",
".",
"Initialization",
"of",
"the",
"k",
"centroids",
"is",
"done",
"via",
"k",
"-",
"means",
"++",
"."
] | def kmeanspp(X, k, **kwargs):
assert len(X) >= k
dim = len(X[0]) if isinstance(X[0], Iterable) else 1
if 'fn' in kwargs:
fn = kwargs['fn']
else:
fn = euclid()
if 'tol' in kwargs:
tol = kwargs['tol']
else:
tol = 10 ** -3
if 'iter_max' in kwargs:
iter_m... | [
"def",
"kmeanspp",
"(",
"X",
",",
"k",
",",
"**",
"kwargs",
")",
":",
"assert",
"len",
"(",
"X",
")",
">=",
"k",
"dim",
"=",
"len",
"(",
"X",
"[",
"0",
"]",
")",
"if",
"isinstance",
"(",
"X",
"[",
"0",
"]",
",",
"Iterable",
")",
"else",
"1"... | Performs k-means on X into k clusters. | [
"Performs",
"k",
"-",
"means",
"on",
"X",
"into",
"k",
"clusters",
"."
] | [
"'''\r\n Performs k-means on X into k clusters. Initialization of the k centroids is done via k-means++. \r\n \r\n :param X: X is an iterable of iterables, e.g., [[1, 2], [3, 4]] or ((1), (2)). \r\n :param k: number of clusters.\r\n :param kwargs['fn']: select a distance function (default is 'euclid'... | [
{
"param": "X",
"type": null
},
{
"param": "k",
"type": null
}
] | {
"returns": [
{
"docstring": "returns an MlList L of length len(X) where each index i in L belongs to cluster L[i].",
"docstring_tokens": [
"returns",
"an",
"MlList",
"L",
"of",
"length",
"len",
"(",
"X",
")",
"wh... |
bb48f66d7c29fb5f6e6606476ee9e0e8a9132b04 | ijkilchenko/siMLpy | Algorithms.py | [
"MIT"
] | Python | euclid | <not_specific> | def euclid():
'''
Return a function which calculates the Euclidean distance between two iterables (points).
If either of two arguments to the function are not iterable, each are put in its own list first.
:return: returns the Euclidean distance function
'''
seq = lambda x, y: zip(x, y)... |
Return a function which calculates the Euclidean distance between two iterables (points).
If either of two arguments to the function are not iterable, each are put in its own list first.
:return: returns the Euclidean distance function
| Return a function which calculates the Euclidean distance between two iterables (points).
If either of two arguments to the function are not iterable, each are put in its own list first. | [
"Return",
"a",
"function",
"which",
"calculates",
"the",
"Euclidean",
"distance",
"between",
"two",
"iterables",
"(",
"points",
")",
".",
"If",
"either",
"of",
"two",
"arguments",
"to",
"the",
"function",
"are",
"not",
"iterable",
"each",
"are",
"put",
"in",... | def euclid():
seq = lambda x, y: zip(x, y) if all(isinstance(z, Iterable) for z in [x, y]) else zip([x], [y])
euc = lambda x, y: sqrt(sum([(p[0] - p[1]) ** 2 for p in seq(x, y)]))
return euc | [
"def",
"euclid",
"(",
")",
":",
"seq",
"=",
"lambda",
"x",
",",
"y",
":",
"zip",
"(",
"x",
",",
"y",
")",
"if",
"all",
"(",
"isinstance",
"(",
"z",
",",
"Iterable",
")",
"for",
"z",
"in",
"[",
"x",
",",
"y",
"]",
")",
"else",
"zip",
"(",
... | Return a function which calculates the Euclidean distance between two iterables (points). | [
"Return",
"a",
"function",
"which",
"calculates",
"the",
"Euclidean",
"distance",
"between",
"two",
"iterables",
"(",
"points",
")",
"."
] | [
"'''\r\n Return a function which calculates the Euclidean distance between two iterables (points). \r\n If either of two arguments to the function are not iterable, each are put in its own list first. \r\n\r\n :return: returns the Euclidean distance function\r\n '''"
] | [] | {
"returns": [
{
"docstring": "returns the Euclidean distance function",
"docstring_tokens": [
"returns",
"the",
"Euclidean",
"distance",
"function"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5d9a4549ee017bff5c38f61dc51c0f8f9b335736 | rcbensley/flask-pymysql | flask_pymysql/__init__.py | [
"MIT"
] | Python | init_app | null | def init_app(self, app):
"""Initialize the `app` for use with this
:class:`~flask_pymysql.MySQL` class.
This is called automatically if `app` is passed to
:meth:`~MySQL.__init__`.
:param flask.Flask app: the application to configure for use with
this :class:`~flask_p... | Initialize the `app` for use with this
:class:`~flask_pymysql.MySQL` class.
This is called automatically if `app` is passed to
:meth:`~MySQL.__init__`.
:param flask.Flask app: the application to configure for use with
this :class:`~flask_pymysql.MySQL` class.
| Initialize the `app` for use with this | [
"Initialize",
"the",
"`",
"app",
"`",
"for",
"use",
"with",
"this"
] | def init_app(self, app):
if hasattr(app, 'teardown_appcontext'):
app.teardown_appcontext(self.teardown) | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"if",
"hasattr",
"(",
"app",
",",
"'teardown_appcontext'",
")",
":",
"app",
".",
"teardown_appcontext",
"(",
"self",
".",
"teardown",
")"
] | Initialize the `app` for use with this | [
"Initialize",
"the",
"`",
"app",
"`",
"for",
"use",
"with",
"this"
] | [
"\"\"\"Initialize the `app` for use with this\n :class:`~flask_pymysql.MySQL` class.\n This is called automatically if `app` is passed to\n :meth:`~MySQL.__init__`.\n\n :param flask.Flask app: the application to configure for use with\n this :class:`~flask_pymysql.MySQL` class... | [
{
"param": "self",
"type": null
},
{
"param": "app",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "app",
"type": null,
"docstring": "the application to configure for ... |
22a81fe3632a2bb1486dbeb661a40ac0d12f9f23 | manicstar/trac-ticketmodifiedfiles | ticketmodifiedfiles/api.py | [
"BSD-3-Clause"
] | Python | _save_ticket_references | null | def _save_ticket_references(self, repos, revision, tickets):
"""Saves the ticket references by revision."""
@self.env.with_transaction()
def do_save(db):
cursor = db.cursor()
for ticket in tickets:
try:
cursor.execute("""
... | Saves the ticket references by revision. | Saves the ticket references by revision. | [
"Saves",
"the",
"ticket",
"references",
"by",
"revision",
"."
] | def _save_ticket_references(self, repos, revision, tickets):
@self.env.with_transaction()
def do_save(db):
cursor = db.cursor()
for ticket in tickets:
try:
cursor.execute("""
INSERT INTO ticketmodifiedfiles (repos, rev, ... | [
"def",
"_save_ticket_references",
"(",
"self",
",",
"repos",
",",
"revision",
",",
"tickets",
")",
":",
"@",
"self",
".",
"env",
".",
"with_transaction",
"(",
")",
"def",
"do_save",
"(",
"db",
")",
":",
"cursor",
"=",
"db",
".",
"cursor",
"(",
")",
"... | Saves the ticket references by revision. | [
"Saves",
"the",
"ticket",
"references",
"by",
"revision",
"."
] | [
"\"\"\"Saves the ticket references by revision.\"\"\"",
"# catch duplicate key errors and ignore them"
] | [
{
"param": "self",
"type": null
},
{
"param": "repos",
"type": null
},
{
"param": "revision",
"type": null
},
{
"param": "tickets",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "repos",
"type": null,
"docstring": null,
"docstring_tokens": ... |
e0c44c32f64238340aa797f7f2f71239a4e68f47 | haifangong/CMSA-MTPT-4-MedicalVQA | multi-task-pretrain/dataloaders/brain_tumor_dataset.py | [
"MIT"
] | Python | tokenize | null | def tokenize(self, max_length=12):
"""Tokenizes the questions.
This will add q_token in each entry of the dataset.
-1 represent nil, and should be treated as padding_idx in embedding
"""
for entry in self.entries:
tokens = self.dictionary.tokenize(entry['quest... | Tokenizes the questions.
This will add q_token in each entry of the dataset.
-1 represent nil, and should be treated as padding_idx in embedding
| Tokenizes the questions.
This will add q_token in each entry of the dataset.
1 represent nil, and should be treated as padding_idx in embedding | [
"Tokenizes",
"the",
"questions",
".",
"This",
"will",
"add",
"q_token",
"in",
"each",
"entry",
"of",
"the",
"dataset",
".",
"1",
"represent",
"nil",
"and",
"should",
"be",
"treated",
"as",
"padding_idx",
"in",
"embedding"
] | def tokenize(self, max_length=12):
for entry in self.entries:
tokens = self.dictionary.tokenize(entry['question'], False)
tokens = tokens[:max_length]
if len(tokens) < max_length:
padding = [self.dictionary.padding_idx] * (max_length - len(tokens))
... | [
"def",
"tokenize",
"(",
"self",
",",
"max_length",
"=",
"12",
")",
":",
"for",
"entry",
"in",
"self",
".",
"entries",
":",
"tokens",
"=",
"self",
".",
"dictionary",
".",
"tokenize",
"(",
"entry",
"[",
"'question'",
"]",
",",
"False",
")",
"tokens",
"... | Tokenizes the questions. | [
"Tokenizes",
"the",
"questions",
"."
] | [
"\"\"\"Tokenizes the questions.\r\n\r\n This will add q_token in each entry of the dataset.\r\n -1 represent nil, and should be treated as padding_idx in embedding\r\n \"\"\"",
"# Note here we pad in front of the sentence\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "max_length",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_length",
"type": null,
"docstring": null,
"docstring_toke... |
d27680acb670d4872c857679da430f1ab016e01d | negrinho/deep_architect_legacy | darch/modules.py | [
"MIT"
] | Python | propagate_seq | <not_specific> | def propagate_seq(bs, i):
""" Propagates choices in a sequence of modules.
If the module in the current position of the sequence is specified, we can
initialize the next module in the sequence (if there is any), and go to
the next module in the chain if the initialized module becomes specified.
... | Propagates choices in a sequence of modules.
If the module in the current position of the sequence is specified, we can
initialize the next module in the sequence (if there is any), and go to
the next module in the chain if the initialized module becomes specified.
| Propagates choices in a sequence of modules.
If the module in the current position of the sequence is specified, we can
initialize the next module in the sequence (if there is any), and go to
the next module in the chain if the initialized module becomes specified. | [
"Propagates",
"choices",
"in",
"a",
"sequence",
"of",
"modules",
".",
"If",
"the",
"module",
"in",
"the",
"current",
"position",
"of",
"the",
"sequence",
"is",
"specified",
"we",
"can",
"initialize",
"the",
"next",
"module",
"in",
"the",
"sequence",
"(",
"... | def propagate_seq(bs, i):
while bs[i].is_specified():
prev_scope = bs[i].scope
prev_out_d = bs[i].get_outdim()
i += 1
if i < len(bs):
bs[i].initialize(prev_out_d, prev_scope)
else:
break
return i | [
"def",
"propagate_seq",
"(",
"bs",
",",
"i",
")",
":",
"while",
"bs",
"[",
"i",
"]",
".",
"is_specified",
"(",
")",
":",
"prev_scope",
"=",
"bs",
"[",
"i",
"]",
".",
"scope",
"prev_out_d",
"=",
"bs",
"[",
"i",
"]",
".",
"get_outdim",
"(",
")",
... | Propagates choices in a sequence of modules. | [
"Propagates",
"choices",
"in",
"a",
"sequence",
"of",
"modules",
"."
] | [
"\"\"\" Propagates choices in a sequence of modules.\n\n If the module in the current position of the sequence is specified, we can \n initialize the next module in the sequence (if there is any), and go to \n the next module in the chain if the initialized module becomes specified.\n \n \"\"\""
] | [
{
"param": "bs",
"type": null
},
{
"param": "i",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "i",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
d27680acb670d4872c857679da430f1ab016e01d | negrinho/deep_architect_legacy | darch/modules.py | [
"MIT"
] | Python | propagate | null | def propagate(b):
""" Propagates choices in a module.
While the module is in a state where there is only one option available for
the next choice, we take that choice. This function leaves the module
specified or in a state where there multiple choices. This function will
typically be called by ... | Propagates choices in a module.
While the module is in a state where there is only one option available for
the next choice, we take that choice. This function leaves the module
specified or in a state where there multiple choices. This function will
typically be called by the submodule when initia... | Propagates choices in a module.
While the module is in a state where there is only one option available for
the next choice, we take that choice. This function leaves the module
specified or in a state where there multiple choices. This function will
typically be called by the submodule when initialize or choose is cal... | [
"Propagates",
"choices",
"in",
"a",
"module",
".",
"While",
"the",
"module",
"is",
"in",
"a",
"state",
"where",
"there",
"is",
"only",
"one",
"option",
"available",
"for",
"the",
"next",
"choice",
"we",
"take",
"that",
"choice",
".",
"This",
"function",
... | def propagate(b):
while not b.is_specified() and len(b.get_choices()[1]) == 1:
b.choose(0) | [
"def",
"propagate",
"(",
"b",
")",
":",
"while",
"not",
"b",
".",
"is_specified",
"(",
")",
"and",
"len",
"(",
"b",
".",
"get_choices",
"(",
")",
"[",
"1",
"]",
")",
"==",
"1",
":",
"b",
".",
"choose",
"(",
"0",
")"
] | Propagates choices in a module. | [
"Propagates",
"choices",
"in",
"a",
"module",
"."
] | [
"\"\"\" Propagates choices in a module.\n\n While the module is in a state where there is only one option available for \n the next choice, we take that choice. This function leaves the module \n specified or in a state where there multiple choices. This function will \n typically be called by the submo... | [
{
"param": "b",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "b",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d27680acb670d4872c857679da430f1ab016e01d | negrinho/deep_architect_legacy | darch/modules.py | [
"MIT"
] | Python | MaybeSwap_fn | <not_specific> | def MaybeSwap_fn(b1, b2):
"""Builds a module that has a parameter to swapping the order of modules
passed as argument.
"""
b = Or([
Concat([b1, b2]),
Concat([b2, b1])
])
return b | Builds a module that has a parameter to swapping the order of modules
passed as argument.
| Builds a module that has a parameter to swapping the order of modules
passed as argument. | [
"Builds",
"a",
"module",
"that",
"has",
"a",
"parameter",
"to",
"swapping",
"the",
"order",
"of",
"modules",
"passed",
"as",
"argument",
"."
] | def MaybeSwap_fn(b1, b2):
b = Or([
Concat([b1, b2]),
Concat([b2, b1])
])
return b | [
"def",
"MaybeSwap_fn",
"(",
"b1",
",",
"b2",
")",
":",
"b",
"=",
"Or",
"(",
"[",
"Concat",
"(",
"[",
"b1",
",",
"b2",
"]",
")",
",",
"Concat",
"(",
"[",
"b2",
",",
"b1",
"]",
")",
"]",
")",
"return",
"b"
] | Builds a module that has a parameter to swapping the order of modules
passed as argument. | [
"Builds",
"a",
"module",
"that",
"has",
"a",
"parameter",
"to",
"swapping",
"the",
"order",
"of",
"modules",
"passed",
"as",
"argument",
"."
] | [
"\"\"\"Builds a module that has a parameter to swapping the order of modules \n passed as argument.\n \"\"\""
] | [
{
"param": "b1",
"type": null
},
{
"param": "b2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "b1",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b2",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
ea836d14c4cc3fcfcd398ef4d84267206eb94b3a | negrinho/deep_architect_legacy | darch/searchers.py | [
"MIT"
] | Python | walk_hist | null | def walk_hist(b, hist):
"""Makes a sequence of choices specified by hist towards specifying b.
This function directly changes b.
"""
for ch_i in hist:
b.choose(ch_i) | Makes a sequence of choices specified by hist towards specifying b.
This function directly changes b.
| Makes a sequence of choices specified by hist towards specifying b.
This function directly changes b. | [
"Makes",
"a",
"sequence",
"of",
"choices",
"specified",
"by",
"hist",
"towards",
"specifying",
"b",
".",
"This",
"function",
"directly",
"changes",
"b",
"."
] | def walk_hist(b, hist):
for ch_i in hist:
b.choose(ch_i) | [
"def",
"walk_hist",
"(",
"b",
",",
"hist",
")",
":",
"for",
"ch_i",
"in",
"hist",
":",
"b",
".",
"choose",
"(",
"ch_i",
")"
] | Makes a sequence of choices specified by hist towards specifying b. | [
"Makes",
"a",
"sequence",
"of",
"choices",
"specified",
"by",
"hist",
"towards",
"specifying",
"b",
"."
] | [
"\"\"\"Makes a sequence of choices specified by hist towards specifying b.\n This function directly changes b.\n\n \"\"\""
] | [
{
"param": "b",
"type": null
},
{
"param": "hist",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "b",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hist",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
ea836d14c4cc3fcfcd398ef4d84267206eb94b3a | negrinho/deep_architect_legacy | darch/searchers.py | [
"MIT"
] | Python | sample_new_epoch | <not_specific> | def sample_new_epoch(self, nsamples):
"""Generates random specified models in the search space and evaluates
them based on the currect surrogate model.
The function returns the epoch number, the specified models, and the
scores output by the surrogate function.
"""
epo... | Generates random specified models in the search space and evaluates
them based on the currect surrogate model.
The function returns the epoch number, the specified models, and the
scores output by the surrogate function.
| Generates random specified models in the search space and evaluates
them based on the currect surrogate model.
The function returns the epoch number, the specified models, and the
scores output by the surrogate function. | [
"Generates",
"random",
"specified",
"models",
"in",
"the",
"search",
"space",
"and",
"evaluates",
"them",
"based",
"on",
"the",
"currect",
"surrogate",
"model",
".",
"The",
"function",
"returns",
"the",
"epoch",
"number",
"the",
"specified",
"models",
"and",
"... | def sample_new_epoch(self, nsamples):
epoch_i = self.epoch_i
samples = []
scores = []
choice_hists = []
for _ in xrange(nsamples):
bk = copy.deepcopy(self.b_search)
bk.initialize(self.in_d, Scope())
hist = []
while( not bk.is_specif... | [
"def",
"sample_new_epoch",
"(",
"self",
",",
"nsamples",
")",
":",
"epoch_i",
"=",
"self",
".",
"epoch_i",
"samples",
"=",
"[",
"]",
"scores",
"=",
"[",
"]",
"choice_hists",
"=",
"[",
"]",
"for",
"_",
"in",
"xrange",
"(",
"nsamples",
")",
":",
"bk",
... | Generates random specified models in the search space and evaluates
them based on the currect surrogate model. | [
"Generates",
"random",
"specified",
"models",
"in",
"the",
"search",
"space",
"and",
"evaluates",
"them",
"based",
"on",
"the",
"currect",
"surrogate",
"model",
"."
] | [
"\"\"\"Generates random specified models in the search space and evaluates\n them based on the currect surrogate model.\n\n The function returns the epoch number, the specified models, and the\n scores output by the surrogate function.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "nsamples",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nsamples",
"type": null,
"docstring": null,
"docstring_tokens... |
ea836d14c4cc3fcfcd398ef4d84267206eb94b3a | negrinho/deep_architect_legacy | darch/searchers.py | [
"MIT"
] | Python | forget_epoch | null | def forget_epoch(self, epoch_i):
"""Removes a given sample epoch from history.
After removing an epoch, the specific models can no longer be queried
by the model.
"""
if epoch_i not in self.sample_hist or epoch_i not in self.histories:
raise KeyError("Epoch %d not ... | Removes a given sample epoch from history.
After removing an epoch, the specific models can no longer be queried
by the model.
| Removes a given sample epoch from history.
After removing an epoch, the specific models can no longer be queried
by the model. | [
"Removes",
"a",
"given",
"sample",
"epoch",
"from",
"history",
".",
"After",
"removing",
"an",
"epoch",
"the",
"specific",
"models",
"can",
"no",
"longer",
"be",
"queried",
"by",
"the",
"model",
"."
] | def forget_epoch(self, epoch_i):
if epoch_i not in self.sample_hist or epoch_i not in self.histories:
raise KeyError("Epoch %d not present in history" % epoch_i)
self.sample_hist.pop(epoch_i)
self.histories.pop(epoch_i) | [
"def",
"forget_epoch",
"(",
"self",
",",
"epoch_i",
")",
":",
"if",
"epoch_i",
"not",
"in",
"self",
".",
"sample_hist",
"or",
"epoch_i",
"not",
"in",
"self",
".",
"histories",
":",
"raise",
"KeyError",
"(",
"\"Epoch %d not present in history\"",
"%",
"epoch_i"... | Removes a given sample epoch from history. | [
"Removes",
"a",
"given",
"sample",
"epoch",
"from",
"history",
"."
] | [
"\"\"\"Removes a given sample epoch from history.\n\n After removing an epoch, the specific models can no longer be queried\n by the model.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "epoch_i",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "epoch_i",
"type": null,
"docstring": null,
"docstring_tokens"... |
ea836d14c4cc3fcfcd398ef4d84267206eb94b3a | negrinho/deep_architect_legacy | darch/searchers.py | [
"MIT"
] | Python | tell_observed_scores | null | def tell_observed_scores(self, epoch_i, sample_inds, scores):
"""Update the state of the searcher based on the actual scores of the
models proposed.
"""
if len(sample_inds) != len(scores):
raise ValueError
if epoch_i not in self.sample_hist:
raise KeyErr... | Update the state of the searcher based on the actual scores of the
models proposed.
| Update the state of the searcher based on the actual scores of the
models proposed. | [
"Update",
"the",
"state",
"of",
"the",
"searcher",
"based",
"on",
"the",
"actual",
"scores",
"of",
"the",
"models",
"proposed",
"."
] | def tell_observed_scores(self, epoch_i, sample_inds, scores):
if len(sample_inds) != len(scores):
raise ValueError
if epoch_i not in self.sample_hist:
raise KeyError
epoch_samples = self.sample_hist[epoch_i]
epoch_hists = self.histories[epoch_i]
for i, sc ... | [
"def",
"tell_observed_scores",
"(",
"self",
",",
"epoch_i",
",",
"sample_inds",
",",
"scores",
")",
":",
"if",
"len",
"(",
"sample_inds",
")",
"!=",
"len",
"(",
"scores",
")",
":",
"raise",
"ValueError",
"if",
"epoch_i",
"not",
"in",
"self",
".",
"sample... | Update the state of the searcher based on the actual scores of the
models proposed. | [
"Update",
"the",
"state",
"of",
"the",
"searcher",
"based",
"on",
"the",
"actual",
"scores",
"of",
"the",
"models",
"proposed",
"."
] | [
"\"\"\"Update the state of the searcher based on the actual scores of the \n models proposed.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "epoch_i",
"type": null
},
{
"param": "sample_inds",
"type": null
},
{
"param": "scores",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "epoch_i",
"type": null,
"docstring": null,
"docstring_tokens"... |
ea836d14c4cc3fcfcd398ef4d84267206eb94b3a | negrinho/deep_architect_legacy | darch/searchers.py | [
"MIT"
] | Python | refit_model | null | def refit_model(self):
"""Learns a new surrogate model using the data observed so far.
"""
# only fit the model if there is data for it.
if len(self.known_models) > 0:
self._build_feature_maps(self.known_models, self.ngram_maxlen, self.thres)
X = sp.vstack([ s... | Learns a new surrogate model using the data observed so far.
| Learns a new surrogate model using the data observed so far. | [
"Learns",
"a",
"new",
"surrogate",
"model",
"using",
"the",
"data",
"observed",
"so",
"far",
"."
] | def refit_model(self):
if len(self.known_models) > 0:
self._build_feature_maps(self.known_models, self.ngram_maxlen, self.thres)
X = sp.vstack([ self._compute_features(mdl)
for mdl in self.known_models], "csr")
y = np.array(self.known_scores, dtype='float6... | [
"def",
"refit_model",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"known_models",
")",
">",
"0",
":",
"self",
".",
"_build_feature_maps",
"(",
"self",
".",
"known_models",
",",
"self",
".",
"ngram_maxlen",
",",
"self",
".",
"thres",
")",
"X",... | Learns a new surrogate model using the data observed so far. | [
"Learns",
"a",
"new",
"surrogate",
"model",
"using",
"the",
"data",
"observed",
"so",
"far",
"."
] | [
"\"\"\"Learns a new surrogate model using the data observed so far.\n\n \"\"\"",
"# only fit the model if there is data for it.",
"#A = np.dot(X.T, X) + lamb * np.eye(X.shape[1])",
"#b = np.dot(X.T, y)"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ea836d14c4cc3fcfcd398ef4d84267206eb94b3a | negrinho/deep_architect_legacy | darch/searchers.py | [
"MIT"
] | Python | sample_models | <not_specific> | def sample_models(self, num_samples):
"""Generates random specified models in the search space and evaluates
them based on the currect surrogate model.
The function returns the epoch number, the specified models, and the
history of choices that lead to those particular models.
... | Generates random specified models in the search space and evaluates
them based on the currect surrogate model.
The function returns the epoch number, the specified models, and the
history of choices that lead to those particular models.
| Generates random specified models in the search space and evaluates
them based on the currect surrogate model.
The function returns the epoch number, the specified models, and the
history of choices that lead to those particular models. | [
"Generates",
"random",
"specified",
"models",
"in",
"the",
"search",
"space",
"and",
"evaluates",
"them",
"based",
"on",
"the",
"currect",
"surrogate",
"model",
".",
"The",
"function",
"returns",
"the",
"epoch",
"number",
"the",
"specified",
"models",
"and",
"... | def sample_models(self, num_samples):
models = []
choice_hists = []
for _ in xrange(num_samples):
bk = copy.deepcopy(self.b_search)
bk.initialize(self.in_d, Scope())
tree_hist = self._tree_walk(bk)
roll_hist = self._rollout_walk(bk)
his... | [
"def",
"sample_models",
"(",
"self",
",",
"num_samples",
")",
":",
"models",
"=",
"[",
"]",
"choice_hists",
"=",
"[",
"]",
"for",
"_",
"in",
"xrange",
"(",
"num_samples",
")",
":",
"bk",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"b_search",
")"... | Generates random specified models in the search space and evaluates
them based on the currect surrogate model. | [
"Generates",
"random",
"specified",
"models",
"in",
"the",
"search",
"space",
"and",
"evaluates",
"them",
"based",
"on",
"the",
"currect",
"surrogate",
"model",
"."
] | [
"\"\"\"Generates random specified models in the search space and evaluates\n them based on the currect surrogate model.\n\n The function returns the epoch number, the specified models, and the\n history of choices that lead to those particular models.\n\n \"\"\"",
"# initialization of ... | [
{
"param": "self",
"type": null
},
{
"param": "num_samples",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num_samples",
"type": null,
"docstring": null,
"docstring_tok... |
ae8f024d9f8f1bef97a78a77dfcdd6fe8d22b12c | negrinho/deep_architect_legacy | experiments.py | [
"MIT"
] | Python | eval_model | <not_specific> | def eval_model(self, b):
"""Extract parameters from a UserHyperparams module and uses then to
udpate the values of certain hyperparameters of the evaluator. This
code is still very much based on ClassifierEvaluator.
"""
### this part is AWFUL
# NOTE: I'm breaking encap... | Extract parameters from a UserHyperparams module and uses then to
udpate the values of certain hyperparameters of the evaluator. This
code is still very much based on ClassifierEvaluator.
| Extract parameters from a UserHyperparams module and uses then to
udpate the values of certain hyperparameters of the evaluator. This
code is still very much based on ClassifierEvaluator. | [
"Extract",
"parameters",
"from",
"a",
"UserHyperparams",
"module",
"and",
"uses",
"then",
"to",
"udpate",
"the",
"values",
"of",
"certain",
"hyperparameters",
"of",
"the",
"evaluator",
".",
"This",
"code",
"is",
"still",
"very",
"much",
"based",
"on",
"Classif... | def eval_model(self, b):
if self.args['bisect_search_space']:
b_hp, b_search = b.b.bs
else:
b_hp, b_search = b.bs
b_hp.compile(None, None, None)
hpsc_name = self.user_hyperparams_scope_name
order = b_hp.scope.s[hpsc_name]['hyperp_names']
vals = b_h... | [
"def",
"eval_model",
"(",
"self",
",",
"b",
")",
":",
"if",
"self",
".",
"args",
"[",
"'bisect_search_space'",
"]",
":",
"b_hp",
",",
"b_search",
"=",
"b",
".",
"b",
".",
"bs",
"else",
":",
"b_hp",
",",
"b_search",
"=",
"b",
".",
"bs",
"b_hp",
".... | Extract parameters from a UserHyperparams module and uses then to
udpate the values of certain hyperparameters of the evaluator. | [
"Extract",
"parameters",
"from",
"a",
"UserHyperparams",
"module",
"and",
"uses",
"then",
"to",
"udpate",
"the",
"values",
"of",
"certain",
"hyperparameters",
"of",
"the",
"evaluator",
"."
] | [
"\"\"\"Extract parameters from a UserHyperparams module and uses then to \n udpate the values of certain hyperparameters of the evaluator. This \n code is still very much based on ClassifierEvaluator.\n \"\"\"",
"### this part is AWFUL",
"# NOTE: I'm breaking encapsulation here for now.",
... | [
{
"param": "self",
"type": null
},
{
"param": "b",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
0b9a1387ee2c895c316bbfa234b9affb693f274d | negrinho/deep_architect_legacy | darch/datasets.py | [
"MIT"
] | Python | load_cifar10 | <not_specific> | def load_cifar10(data_dir, flatten=False, one_hot=True, normalize_range=False,
whiten_pixels=True, border_pad_size=0):
"""Loads all of CIFAR-10 in a numpy array.
Provides a few options for the output formats. For example,
normalize_range returns the output images with pixel values in [0.0, 1.0].
... | Loads all of CIFAR-10 in a numpy array.
Provides a few options for the output formats. For example,
normalize_range returns the output images with pixel values in [0.0, 1.0].
The other options are self explanatory. Border padding corresponds to
upsampling the image by zero padding the border of the i... | Loads all of CIFAR-10 in a numpy array.
Provides a few options for the output formats. For example,
normalize_range returns the output images with pixel values in [0.0, 1.0].
The other options are self explanatory. Border padding corresponds to
upsampling the image by zero padding the border of the image. | [
"Loads",
"all",
"of",
"CIFAR",
"-",
"10",
"in",
"a",
"numpy",
"array",
".",
"Provides",
"a",
"few",
"options",
"for",
"the",
"output",
"formats",
".",
"For",
"example",
"normalize_range",
"returns",
"the",
"output",
"images",
"with",
"pixel",
"values",
"in... | def load_cifar10(data_dir, flatten=False, one_hot=True, normalize_range=False,
whiten_pixels=True, border_pad_size=0):
train_filenames = ['data_batch_1', 'data_batch_2', 'data_batch_3', 'data_batch_4']
val_filenames = ['data_batch_5']
test_filenames = ['test_batch']
def _load_data(fpath):
... | [
"def",
"load_cifar10",
"(",
"data_dir",
",",
"flatten",
"=",
"False",
",",
"one_hot",
"=",
"True",
",",
"normalize_range",
"=",
"False",
",",
"whiten_pixels",
"=",
"True",
",",
"border_pad_size",
"=",
"0",
")",
":",
"train_filenames",
"=",
"[",
"'data_batch_... | Loads all of CIFAR-10 in a numpy array. | [
"Loads",
"all",
"of",
"CIFAR",
"-",
"10",
"in",
"a",
"numpy",
"array",
"."
] | [
"\"\"\"Loads all of CIFAR-10 in a numpy array.\n\n Provides a few options for the output formats. For example, \n normalize_range returns the output images with pixel values in [0.0, 1.0].\n The other options are self explanatory. Border padding corresponds to \n upsampling the image by zero padding the... | [
{
"param": "data_dir",
"type": null
},
{
"param": "flatten",
"type": null
},
{
"param": "one_hot",
"type": null
},
{
"param": "normalize_range",
"type": null
},
{
"param": "whiten_pixels",
"type": null
},
{
"param": "border_pad_size",
"type": null
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flatten",
"type": null,
"docstring": null,
"docstring_tok... |
0b9a1387ee2c895c316bbfa234b9affb693f274d | negrinho/deep_architect_legacy | darch/datasets.py | [
"MIT"
] | Python | per_image_whiten | <not_specific> | def per_image_whiten(X):
""" Subtracts the mean of each image in X and renormalizes them to unit norm.
"""
num_examples, height, width, depth = X.shape
X_flat = X.reshape((num_examples, -1))
X_mean = X_flat.mean(axis=1)
X_cent = X_flat - X_mean[:, None]
X_norm = np.sqrt( np.sum( X_cent * X... | Subtracts the mean of each image in X and renormalizes them to unit norm.
| Subtracts the mean of each image in X and renormalizes them to unit norm. | [
"Subtracts",
"the",
"mean",
"of",
"each",
"image",
"in",
"X",
"and",
"renormalizes",
"them",
"to",
"unit",
"norm",
"."
] | def per_image_whiten(X):
num_examples, height, width, depth = X.shape
X_flat = X.reshape((num_examples, -1))
X_mean = X_flat.mean(axis=1)
X_cent = X_flat - X_mean[:, None]
X_norm = np.sqrt( np.sum( X_cent * X_cent, axis=1) )
X_out = X_cent / X_norm[:, None]
X_out = X_out.reshape(X.shape)
... | [
"def",
"per_image_whiten",
"(",
"X",
")",
":",
"num_examples",
",",
"height",
",",
"width",
",",
"depth",
"=",
"X",
".",
"shape",
"X_flat",
"=",
"X",
".",
"reshape",
"(",
"(",
"num_examples",
",",
"-",
"1",
")",
")",
"X_mean",
"=",
"X_flat",
".",
"... | Subtracts the mean of each image in X and renormalizes them to unit norm. | [
"Subtracts",
"the",
"mean",
"of",
"each",
"image",
"in",
"X",
"and",
"renormalizes",
"them",
"to",
"unit",
"norm",
"."
] | [
"\"\"\" Subtracts the mean of each image in X and renormalizes them to unit norm.\n\n \"\"\""
] | [
{
"param": "X",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "X",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | build_convs | <not_specific> | def build_convs(df):
"""
Use parallel computing. Consider only one post at each time.
Reconstruct the dataframe to a more conversation-like dataframe.
Arg:
df: A given dataframe scraped from a certain subreddit.
Return:
df_convs: A more conversation-like dataframe with the columns s... |
Use parallel computing. Consider only one post at each time.
Reconstruct the dataframe to a more conversation-like dataframe.
Arg:
df: A given dataframe scraped from a certain subreddit.
Return:
df_convs: A more conversation-like dataframe with the columns such as
conversation... | Use parallel computing. Consider only one post at each time.
Reconstruct the dataframe to a more conversation-like dataframe.
A given dataframe scraped from a certain subreddit.
Return:
df_convs: A more conversation-like dataframe with the columns such as
conversation ID, subreddit, post title, author, dialog turn, an... | [
"Use",
"parallel",
"computing",
".",
"Consider",
"only",
"one",
"post",
"at",
"each",
"time",
".",
"Reconstruct",
"the",
"dataframe",
"to",
"a",
"more",
"conversation",
"-",
"like",
"dataframe",
".",
"A",
"given",
"dataframe",
"scraped",
"from",
"a",
"certai... | def build_convs(df):
df_convs = pd.DataFrame(columns = ['subreddit', 'post title', 'author', 'dialog turn', 'text'])
df_link_id = df.reset_index().drop('index', axis = 1)
row_list = []
convs_turn = 0
post_row = df_link_id.loc[0, :]
convs_turn += 1
row_list.append({'subreddit': post_row['subr... | [
"def",
"build_convs",
"(",
"df",
")",
":",
"df_convs",
"=",
"pd",
".",
"DataFrame",
"(",
"columns",
"=",
"[",
"'subreddit'",
",",
"'post title'",
",",
"'author'",
",",
"'dialog turn'",
",",
"'text'",
"]",
")",
"df_link_id",
"=",
"df",
".",
"reset_index",
... | Use parallel computing. | [
"Use",
"parallel",
"computing",
"."
] | [
"\"\"\"\n Use parallel computing. Consider only one post at each time.\n Reconstruct the dataframe to a more conversation-like dataframe.\n\n Arg:\n df: A given dataframe scraped from a certain subreddit.\n Return:\n df_convs: A more conversation-like dataframe with the columns such as \n ... | [
{
"param": "df",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | apply_parallel | <not_specific> | def apply_parallel(grouped_df, func):
"""
Parallelize the 'build_convs' function by grouping each post and its comments.
And then concatenate all of them into a complete dataframe.
Arg:
grouped_df: A dataframe on which groupby function is applied.
Return:
pd.concat(retLst): A comple... |
Parallelize the 'build_convs' function by grouping each post and its comments.
And then concatenate all of them into a complete dataframe.
Arg:
grouped_df: A dataframe on which groupby function is applied.
Return:
pd.concat(retLst): A complete dataframe with the conversation sets betwe... | Parallelize the 'build_convs' function by grouping each post and its comments.
And then concatenate all of them into a complete dataframe.
A dataframe on which groupby function is applied.
Return:
pd.concat(retLst): A complete dataframe with the conversation sets between posts and comments. | [
"Parallelize",
"the",
"'",
"build_convs",
"'",
"function",
"by",
"grouping",
"each",
"post",
"and",
"its",
"comments",
".",
"And",
"then",
"concatenate",
"all",
"of",
"them",
"into",
"a",
"complete",
"dataframe",
".",
"A",
"dataframe",
"on",
"which",
"groupb... | def apply_parallel(grouped_df, func):
retLst = Parallel(n_jobs = mp.cpu_count())(delayed(func)(group) for id, group in grouped_df)
return pd.concat(retLst) | [
"def",
"apply_parallel",
"(",
"grouped_df",
",",
"func",
")",
":",
"retLst",
"=",
"Parallel",
"(",
"n_jobs",
"=",
"mp",
".",
"cpu_count",
"(",
")",
")",
"(",
"delayed",
"(",
"func",
")",
"(",
"group",
")",
"for",
"id",
",",
"group",
"in",
"grouped_df... | Parallelize the 'build_convs' function by grouping each post and its comments. | [
"Parallelize",
"the",
"'",
"build_convs",
"'",
"function",
"by",
"grouping",
"each",
"post",
"and",
"its",
"comments",
"."
] | [
"\"\"\"\n Parallelize the 'build_convs' function by grouping each post and its comments.\n And then concatenate all of them into a complete dataframe.\n\n Arg:\n grouped_df: A dataframe on which groupby function is applied.\n Return:\n pd.concat(retLst): A complete dataframe with the conve... | [
{
"param": "grouped_df",
"type": null
},
{
"param": "func",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "grouped_df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_toke... |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | build_concise_convs_df | <not_specific> | def build_concise_convs_df(df_convs, njobs = mp.cpu_count()):
"""
Using the functions, build_convs and apply_parallel, a dataframe with conversation sets
can be easily built. Also the id for each conversation is added.
Arg:
df_convs: The original dataframe consisting of posts and comments parse... |
Using the functions, build_convs and apply_parallel, a dataframe with conversation sets
can be easily built. Also the id for each conversation is added.
Arg:
df_convs: The original dataframe consisting of posts and comments parsed from the text files.
Return:
df_convs_concise: The conc... | Using the functions, build_convs and apply_parallel, a dataframe with conversation sets
can be easily built. Also the id for each conversation is added.
The original dataframe consisting of posts and comments parsed from the text files.
Return:
df_convs_concise: The concise version of a dataframe with conversation set... | [
"Using",
"the",
"functions",
"build_convs",
"and",
"apply_parallel",
"a",
"dataframe",
"with",
"conversation",
"sets",
"can",
"be",
"easily",
"built",
".",
"Also",
"the",
"id",
"for",
"each",
"conversation",
"is",
"added",
".",
"The",
"original",
"dataframe",
... | def build_concise_convs_df(df_convs, njobs = mp.cpu_count()):
df_convs_concise = apply_parallel(df_convs.groupby(df_convs.link_id), build_convs)
df_convs_concise['conversation id'] = (df_convs_concise.groupby(['post title']).cumcount() == 0).astype(int)
df_convs_concise['conversation id'] = df_convs_concise... | [
"def",
"build_concise_convs_df",
"(",
"df_convs",
",",
"njobs",
"=",
"mp",
".",
"cpu_count",
"(",
")",
")",
":",
"df_convs_concise",
"=",
"apply_parallel",
"(",
"df_convs",
".",
"groupby",
"(",
"df_convs",
".",
"link_id",
")",
",",
"build_convs",
")",
"df_co... | Using the functions, build_convs and apply_parallel, a dataframe with conversation sets
can be easily built. | [
"Using",
"the",
"functions",
"build_convs",
"and",
"apply_parallel",
"a",
"dataframe",
"with",
"conversation",
"sets",
"can",
"be",
"easily",
"built",
"."
] | [
"\"\"\"\n Using the functions, build_convs and apply_parallel, a dataframe with conversation sets\n can be easily built. Also the id for each conversation is added.\n\n Arg:\n df_convs: The original dataframe consisting of posts and comments parsed from the text files.\n Return:\n df_convs... | [
{
"param": "df_convs",
"type": null
},
{
"param": "njobs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df_convs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "njobs",
"type": null,
"docstring": null,
"docstring_token... |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | remove_marks | <not_specific> | def remove_marks(text):
"""
Remove those unnecessary marks inside texts.
Arg:
text: A string that could be either posts or comments.
Return:
new_text: A string which is a clean sentence.
"""
# remove HTML tags
new_text = re.sub('<.*?>', '', text)
# remove URL
new_... |
Remove those unnecessary marks inside texts.
Arg:
text: A string that could be either posts or comments.
Return:
new_text: A string which is a clean sentence.
| Remove those unnecessary marks inside texts.
Arg:
text: A string that could be either posts or comments.
Return:
new_text: A string which is a clean sentence. | [
"Remove",
"those",
"unnecessary",
"marks",
"inside",
"texts",
".",
"Arg",
":",
"text",
":",
"A",
"string",
"that",
"could",
"be",
"either",
"posts",
"or",
"comments",
".",
"Return",
":",
"new_text",
":",
"A",
"string",
"which",
"is",
"a",
"clean",
"sente... | def remove_marks(text):
new_text = re.sub('<.*?>', '', text)
new_text = re.sub('http\S+', '', new_text)
new_text = re.sub('\d+', ' NUM ', new_text)
return new_text | [
"def",
"remove_marks",
"(",
"text",
")",
":",
"new_text",
"=",
"re",
".",
"sub",
"(",
"'<.*?>'",
",",
"''",
",",
"text",
")",
"new_text",
"=",
"re",
".",
"sub",
"(",
"'http\\S+'",
",",
"''",
",",
"new_text",
")",
"new_text",
"=",
"re",
".",
"sub",
... | Remove those unnecessary marks inside texts. | [
"Remove",
"those",
"unnecessary",
"marks",
"inside",
"texts",
"."
] | [
"\"\"\"\n Remove those unnecessary marks inside texts.\n\n Arg:\n text: A string that could be either posts or comments.\n Return:\n new_text: A string which is a clean sentence.\n \"\"\"",
"# remove HTML tags ",
"# remove URL",
"# replace number with <NUM> token"
] | [
{
"param": "text",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | token_lemmatize | <not_specific> | def token_lemmatize(token, lemmatizer):
"""
Lemmatize a token to convert a token back to its root form.
When dealing with punctuation marks or emojis, simply return them as usual.
Arg:
token: A word in the string type.
lemmatizer: The object from wordnet lemmatizer.
Return:
... |
Lemmatize a token to convert a token back to its root form.
When dealing with punctuation marks or emojis, simply return them as usual.
Arg:
token: A word in the string type.
lemmatizer: The object from wordnet lemmatizer.
Return:
token in its root form.
| Lemmatize a token to convert a token back to its root form.
When dealing with punctuation marks or emojis, simply return them as usual.
A word in the string type.
lemmatizer: The object from wordnet lemmatizer.
Return:
token in its root form. | [
"Lemmatize",
"a",
"token",
"to",
"convert",
"a",
"token",
"back",
"to",
"its",
"root",
"form",
".",
"When",
"dealing",
"with",
"punctuation",
"marks",
"or",
"emojis",
"simply",
"return",
"them",
"as",
"usual",
".",
"A",
"word",
"in",
"the",
"string",
"ty... | def token_lemmatize(token, lemmatizer):
if token == 'NUM':
return token
elif token in string.punctuation:
return token
elif token in UNICODE_EMOJI:
return token
elif token.isalpha():
token, tag = pos_tag([token])[0][0], pos_tag([token])[0][1]
return lemmatizer.le... | [
"def",
"token_lemmatize",
"(",
"token",
",",
"lemmatizer",
")",
":",
"if",
"token",
"==",
"'NUM'",
":",
"return",
"token",
"elif",
"token",
"in",
"string",
".",
"punctuation",
":",
"return",
"token",
"elif",
"token",
"in",
"UNICODE_EMOJI",
":",
"return",
"... | Lemmatize a token to convert a token back to its root form. | [
"Lemmatize",
"a",
"token",
"to",
"convert",
"a",
"token",
"back",
"to",
"its",
"root",
"form",
"."
] | [
"\"\"\"\n Lemmatize a token to convert a token back to its root form.\n When dealing with punctuation marks or emojis, simply return them as usual.\n\n Arg:\n token: A word in the string type.\n lemmatizer: The object from wordnet lemmatizer.\n Return:\n token in its root form.\n ... | [
{
"param": "token",
"type": null
},
{
"param": "lemmatizer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "token",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lemmatizer",
"type": null,
"docstring": null,
"docstring_tok... |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | text_lemmatize | <not_specific> | def text_lemmatize(text, lemmatizer):
"""
Apply lemmatization on the raw texts to convert the words in texts back to their root
forms. Before lemmatization, remove unnecessary marks and stopwords to keep only the
meaningful words.
Arg:
text: A string text.
lemmatizer: An object of ... |
Apply lemmatization on the raw texts to convert the words in texts back to their root
forms. Before lemmatization, remove unnecessary marks and stopwords to keep only the
meaningful words.
Arg:
text: A string text.
lemmatizer: An object of WordNetLemmatizer.
Return:
lem_wo... | Apply lemmatization on the raw texts to convert the words in texts back to their root
forms. Before lemmatization, remove unnecessary marks and stopwords to keep only the
meaningful words.
A string text.
lemmatizer: An object of WordNetLemmatizer.
Return:
lem_words: A list of lemmatized words. | [
"Apply",
"lemmatization",
"on",
"the",
"raw",
"texts",
"to",
"convert",
"the",
"words",
"in",
"texts",
"back",
"to",
"their",
"root",
"forms",
".",
"Before",
"lemmatization",
"remove",
"unnecessary",
"marks",
"and",
"stopwords",
"to",
"keep",
"only",
"the",
... | def text_lemmatize(text, lemmatizer):
tokens = word_tokenize(remove_marks(text))
filtered_tokens = [word for word in tokens if word not in stopwords.words('english')]
lem_words = []
lem_words += list(map(token_lemmatize, filtered_tokens, repeat(lemmatizer)))
return lem_words | [
"def",
"text_lemmatize",
"(",
"text",
",",
"lemmatizer",
")",
":",
"tokens",
"=",
"word_tokenize",
"(",
"remove_marks",
"(",
"text",
")",
")",
"filtered_tokens",
"=",
"[",
"word",
"for",
"word",
"in",
"tokens",
"if",
"word",
"not",
"in",
"stopwords",
".",
... | Apply lemmatization on the raw texts to convert the words in texts back to their root
forms. | [
"Apply",
"lemmatization",
"on",
"the",
"raw",
"texts",
"to",
"convert",
"the",
"words",
"in",
"texts",
"back",
"to",
"their",
"root",
"forms",
"."
] | [
"\"\"\"\n Apply lemmatization on the raw texts to convert the words in texts back to their root\n forms. Before lemmatization, remove unnecessary marks and stopwords to keep only the \n meaningful words.\n\n Arg:\n text: A string text.\n lemmatizer: An object of WordNetLemmatizer.\n Ret... | [
{
"param": "text",
"type": null
},
{
"param": "lemmatizer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lemmatizer",
"type": null,
"docstring": null,
"docstring_toke... |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | compute_tokens | <not_specific> | def compute_tokens(subreddit_convs_concise):
"""
Given the text data from a subreddit, lemmatize and compute the word tokens using the defined function, text_lemmatize.
Before that, remove the newline tag and expanding the English contraction.
The reason why the progress_bar is set to false is because o... |
Given the text data from a subreddit, lemmatize and compute the word tokens using the defined function, text_lemmatize.
Before that, remove the newline tag and expanding the English contraction.
The reason why the progress_bar is set to false is because of Google Colab's memory limitation.
If it's not ... | Given the text data from a subreddit, lemmatize and compute the word tokens using the defined function, text_lemmatize.
Before that, remove the newline tag and expanding the English contraction.
The reason why the progress_bar is set to false is because of Google Colab's memory limitation.
If it's not the problem in yo... | [
"Given",
"the",
"text",
"data",
"from",
"a",
"subreddit",
"lemmatize",
"and",
"compute",
"the",
"word",
"tokens",
"using",
"the",
"defined",
"function",
"text_lemmatize",
".",
"Before",
"that",
"remove",
"the",
"newline",
"tag",
"and",
"expanding",
"the",
"Eng... | def compute_tokens(subreddit_convs_concise):
subreddit_text = subreddit_convs_concise['text'].copy()
subreddit_text = subreddit_text.swifter.progress_bar(False).apply(lambda text: text.replace('\n', ' '))\
.swifter.progress_bar(False).apply(lambda text: ' '.join([contractions.... | [
"def",
"compute_tokens",
"(",
"subreddit_convs_concise",
")",
":",
"subreddit_text",
"=",
"subreddit_convs_concise",
"[",
"'text'",
"]",
".",
"copy",
"(",
")",
"subreddit_text",
"=",
"subreddit_text",
".",
"swifter",
".",
"progress_bar",
"(",
"False",
")",
".",
... | Given the text data from a subreddit, lemmatize and compute the word tokens using the defined function, text_lemmatize. | [
"Given",
"the",
"text",
"data",
"from",
"a",
"subreddit",
"lemmatize",
"and",
"compute",
"the",
"word",
"tokens",
"using",
"the",
"defined",
"function",
"text_lemmatize",
"."
] | [
"\"\"\"\n Given the text data from a subreddit, lemmatize and compute the word tokens using the defined function, text_lemmatize.\n Before that, remove the newline tag and expanding the English contraction.\n The reason why the progress_bar is set to false is because of Google Colab's memory limitation.\n ... | [
{
"param": "subreddit_convs_concise",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "subreddit_convs_concise",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | compute_turn_distribution | <not_specific> | def compute_turn_distribution(df):
"""
Given a conversation dataframe from a subreddit (note that the dataframe is in the concise format indicated by Supervisor),
find out the dialog turn distribution.
Arg:
df: A conversation dataframe from a subreddit.
Return:
turn_dist: A series a... |
Given a conversation dataframe from a subreddit (note that the dataframe is in the concise format indicated by Supervisor),
find out the dialog turn distribution.
Arg:
df: A conversation dataframe from a subreddit.
Return:
turn_dist: A series about dialog turn distribution.
| Given a conversation dataframe from a subreddit (note that the dataframe is in the concise format indicated by Supervisor),
find out the dialog turn distribution.
A conversation dataframe from a subreddit.
Return:
turn_dist: A series about dialog turn distribution. | [
"Given",
"a",
"conversation",
"dataframe",
"from",
"a",
"subreddit",
"(",
"note",
"that",
"the",
"dataframe",
"is",
"in",
"the",
"concise",
"format",
"indicated",
"by",
"Supervisor",
")",
"find",
"out",
"the",
"dialog",
"turn",
"distribution",
".",
"A",
"con... | def compute_turn_distribution(df):
turn_dist = df.groupby('conversation id').size().value_counts().sort_index()
turn_dist = pd.DataFrame(turn_dist).reset_index().rename(columns = {'index': 'turns', 0: 'count'})
return turn_dist | [
"def",
"compute_turn_distribution",
"(",
"df",
")",
":",
"turn_dist",
"=",
"df",
".",
"groupby",
"(",
"'conversation id'",
")",
".",
"size",
"(",
")",
".",
"value_counts",
"(",
")",
".",
"sort_index",
"(",
")",
"turn_dist",
"=",
"pd",
".",
"DataFrame",
"... | Given a conversation dataframe from a subreddit (note that the dataframe is in the concise format indicated by Supervisor),
find out the dialog turn distribution. | [
"Given",
"a",
"conversation",
"dataframe",
"from",
"a",
"subreddit",
"(",
"note",
"that",
"the",
"dataframe",
"is",
"in",
"the",
"concise",
"format",
"indicated",
"by",
"Supervisor",
")",
"find",
"out",
"the",
"dialog",
"turn",
"distribution",
"."
] | [
"\"\"\"\n Given a conversation dataframe from a subreddit (note that the dataframe is in the concise format indicated by Supervisor),\n find out the dialog turn distribution.\n\n Arg:\n df: A conversation dataframe from a subreddit.\n Return:\n turn_dist: A series about dialog turn distrib... | [
{
"param": "df",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | extract_turn_10_more | <not_specific> | def extract_turn_10_more(df):
"""
Given a concise conversation dataframe, extract those with 10 or more dialog turns.
Arg:
df: A conversation dataframe from a subreddit.
Return:
turn_10_more: A dataframe containing only those conversations with 10 or more turns.
"""
turn_dist = ... |
Given a concise conversation dataframe, extract those with 10 or more dialog turns.
Arg:
df: A conversation dataframe from a subreddit.
Return:
turn_10_more: A dataframe containing only those conversations with 10 or more turns.
| Given a concise conversation dataframe, extract those with 10 or more dialog turns.
Arg:
df: A conversation dataframe from a subreddit.
Return:
turn_10_more: A dataframe containing only those conversations with 10 or more turns. | [
"Given",
"a",
"concise",
"conversation",
"dataframe",
"extract",
"those",
"with",
"10",
"or",
"more",
"dialog",
"turns",
".",
"Arg",
":",
"df",
":",
"A",
"conversation",
"dataframe",
"from",
"a",
"subreddit",
".",
"Return",
":",
"turn_10_more",
":",
"A",
"... | def extract_turn_10_more(df):
turn_dist = df.groupby('conversation id').size()
turn_dist_10_more_index = turn_dist[turn_dist >= 10].index
turn_10_more = df[df['conversation id'].isin(list(turn_dist_10_more_index))]
return turn_10_more | [
"def",
"extract_turn_10_more",
"(",
"df",
")",
":",
"turn_dist",
"=",
"df",
".",
"groupby",
"(",
"'conversation id'",
")",
".",
"size",
"(",
")",
"turn_dist_10_more_index",
"=",
"turn_dist",
"[",
"turn_dist",
">=",
"10",
"]",
".",
"index",
"turn_10_more",
"=... | Given a concise conversation dataframe, extract those with 10 or more dialog turns. | [
"Given",
"a",
"concise",
"conversation",
"dataframe",
"extract",
"those",
"with",
"10",
"or",
"more",
"dialog",
"turns",
"."
] | [
"\"\"\"\n Given a concise conversation dataframe, extract those with 10 or more dialog turns.\n\n Arg:\n df: A conversation dataframe from a subreddit.\n Return:\n turn_10_more: A dataframe containing only those conversations with 10 or more turns.\n \"\"\""
] | [
{
"param": "df",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | remove_newline | <not_specific> | def remove_newline(df):
"""
For each text in either post or comment, remove the newline tag.
Arg:
df: A given conversation dataframe from a certain subreddit.
Return:
df: A cleaner conversation dataframe without the newline tags.
"""
df['text'] = df['text'].swifter.progress_... |
For each text in either post or comment, remove the newline tag.
Arg:
df: A given conversation dataframe from a certain subreddit.
Return:
df: A cleaner conversation dataframe without the newline tags.
| For each text in either post or comment, remove the newline tag.
Arg:
df: A given conversation dataframe from a certain subreddit.
Return:
df: A cleaner conversation dataframe without the newline tags. | [
"For",
"each",
"text",
"in",
"either",
"post",
"or",
"comment",
"remove",
"the",
"newline",
"tag",
".",
"Arg",
":",
"df",
":",
"A",
"given",
"conversation",
"dataframe",
"from",
"a",
"certain",
"subreddit",
".",
"Return",
":",
"df",
":",
"A",
"cleaner",
... | def remove_newline(df):
df['text'] = df['text'].swifter.progress_bar(False).apply(lambda text: text.replace('\n', ' '))
df['text'] = df['text'].swifter.progress_bar(False).apply(lambda text: text.replace("\\", ''))
return df | [
"def",
"remove_newline",
"(",
"df",
")",
":",
"df",
"[",
"'text'",
"]",
"=",
"df",
"[",
"'text'",
"]",
".",
"swifter",
".",
"progress_bar",
"(",
"False",
")",
".",
"apply",
"(",
"lambda",
"text",
":",
"text",
".",
"replace",
"(",
"'\\n'",
",",
"' '... | For each text in either post or comment, remove the newline tag. | [
"For",
"each",
"text",
"in",
"either",
"post",
"or",
"comment",
"remove",
"the",
"newline",
"tag",
"."
] | [
"\"\"\"\n For each text in either post or comment, remove the newline tag.\n \n Arg:\n df: A given conversation dataframe from a certain subreddit.\n Return:\n df: A cleaner conversation dataframe without the newline tags.\n \"\"\""
] | [
{
"param": "df",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | remove_toxicity | <not_specific> | def remove_toxicity(df):
"""
Use parallel computing. Consider only one post at each time.
In each post, detect the toxicity and remove the following dialog turns.
Arg:
df: A given conversation dataframe from a certain subreddit.
Return:
df_clean: A cleaner version of the conversatio... |
Use parallel computing. Consider only one post at each time.
In each post, detect the toxicity and remove the following dialog turns.
Arg:
df: A given conversation dataframe from a certain subreddit.
Return:
df_clean: A cleaner version of the conversation dataframe with no toxic words.... | Use parallel computing. Consider only one post at each time.
In each post, detect the toxicity and remove the following dialog turns.
A given conversation dataframe from a certain subreddit.
Return:
df_clean: A cleaner version of the conversation dataframe with no toxic words. | [
"Use",
"parallel",
"computing",
".",
"Consider",
"only",
"one",
"post",
"at",
"each",
"time",
".",
"In",
"each",
"post",
"detect",
"the",
"toxicity",
"and",
"remove",
"the",
"following",
"dialog",
"turns",
".",
"A",
"given",
"conversation",
"dataframe",
"fro... | def remove_toxicity(df):
df_clean = pd.DataFrame(columns = ['conversation id', 'subreddit', 'post title', 'author', 'dialog turn', 'text'])
df_post = df.reset_index().drop('index', axis = 1)
clean_row_list = []
for i, row in df_post.iterrows():
if predict_prob([row['text']])[0] > 0.95 and row['d... | [
"def",
"remove_toxicity",
"(",
"df",
")",
":",
"df_clean",
"=",
"pd",
".",
"DataFrame",
"(",
"columns",
"=",
"[",
"'conversation id'",
",",
"'subreddit'",
",",
"'post title'",
",",
"'author'",
",",
"'dialog turn'",
",",
"'text'",
"]",
")",
"df_post",
"=",
... | Use parallel computing. | [
"Use",
"parallel",
"computing",
"."
] | [
"\"\"\"\n Use parallel computing. Consider only one post at each time.\n In each post, detect the toxicity and remove the following dialog turns.\n\n Arg:\n df: A given conversation dataframe from a certain subreddit.\n Return:\n df_clean: A cleaner version of the conversation dataframe wi... | [
{
"param": "df",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | extract_toxicity | <not_specific> | def extract_toxicity(df):
"""
Use parallel computing. Consider only one post at each time.
In each post, extract the toxic texts.
Arg:
df: A given conversation dataframe from a certain subreddit.
Return:
df_toxic: A conversation dataframe with exclusively toxic words.
"""
# ... |
Use parallel computing. Consider only one post at each time.
In each post, extract the toxic texts.
Arg:
df: A given conversation dataframe from a certain subreddit.
Return:
df_toxic: A conversation dataframe with exclusively toxic words.
| Use parallel computing. Consider only one post at each time.
In each post, extract the toxic texts.
A given conversation dataframe from a certain subreddit.
Return:
df_toxic: A conversation dataframe with exclusively toxic words. | [
"Use",
"parallel",
"computing",
".",
"Consider",
"only",
"one",
"post",
"at",
"each",
"time",
".",
"In",
"each",
"post",
"extract",
"the",
"toxic",
"texts",
".",
"A",
"given",
"conversation",
"dataframe",
"from",
"a",
"certain",
"subreddit",
".",
"Return",
... | def extract_toxicity(df):
df_toxic = pd.DataFrame(columns = ['conversation id', 'subreddit', 'post title', 'author', 'dialog turn', 'text'])
df_post = df.reset_index().drop('index', axis = 1)
toxic_row_list = []
for i, row in df_post.iterrows():
if predict_prob([row['text']])[0] > 0.95 and row['... | [
"def",
"extract_toxicity",
"(",
"df",
")",
":",
"df_toxic",
"=",
"pd",
".",
"DataFrame",
"(",
"columns",
"=",
"[",
"'conversation id'",
",",
"'subreddit'",
",",
"'post title'",
",",
"'author'",
",",
"'dialog turn'",
",",
"'text'",
"]",
")",
"df_post",
"=",
... | Use parallel computing. | [
"Use",
"parallel",
"computing",
"."
] | [
"\"\"\"\n Use parallel computing. Consider only one post at each time.\n In each post, extract the toxic texts.\n\n Arg:\n df: A given conversation dataframe from a certain subreddit.\n Return:\n df_toxic: A conversation dataframe with exclusively toxic words.\n \"\"\"",
"# initialize... | [
{
"param": "df",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | differentiate_clean_toxic_convs_df | <not_specific> | def differentiate_clean_toxic_convs_df(df_convs, njobs = mp.cpu_count()):
"""
Applying the profanity checking functions, differentiate clean conversations and toxic ones from a raw conversation dataframe.
Arg:
df_convs: A given conversation dataframe from a certain subreddit.
Return:
... |
Applying the profanity checking functions, differentiate clean conversations and toxic ones from a raw conversation dataframe.
Arg:
df_convs: A given conversation dataframe from a certain subreddit.
Return:
df_clean: A cleaner conversation dataframe without profanity.
df_toxic:... | Applying the profanity checking functions, differentiate clean conversations and toxic ones from a raw conversation dataframe.
Arg:
df_convs: A given conversation dataframe from a certain subreddit.
Return:
df_clean: A cleaner conversation dataframe without profanity.
df_toxic: A toxic conversation dataframe with only ... | [
"Applying",
"the",
"profanity",
"checking",
"functions",
"differentiate",
"clean",
"conversations",
"and",
"toxic",
"ones",
"from",
"a",
"raw",
"conversation",
"dataframe",
".",
"Arg",
":",
"df_convs",
":",
"A",
"given",
"conversation",
"dataframe",
"from",
"a",
... | def differentiate_clean_toxic_convs_df(df_convs, njobs = mp.cpu_count()):
df_clean = apply_parallel(df_convs.groupby(df_convs['conversation id']), remove_toxicity)
df_toxic = apply_parallel(df_convs.groupby(df_convs['conversation id']), extract_toxicity)
df_clean = df_clean.reset_index().drop('index', axis ... | [
"def",
"differentiate_clean_toxic_convs_df",
"(",
"df_convs",
",",
"njobs",
"=",
"mp",
".",
"cpu_count",
"(",
")",
")",
":",
"df_clean",
"=",
"apply_parallel",
"(",
"df_convs",
".",
"groupby",
"(",
"df_convs",
"[",
"'conversation id'",
"]",
")",
",",
"remove_t... | Applying the profanity checking functions, differentiate clean conversations and toxic ones from a raw conversation dataframe. | [
"Applying",
"the",
"profanity",
"checking",
"functions",
"differentiate",
"clean",
"conversations",
"and",
"toxic",
"ones",
"from",
"a",
"raw",
"conversation",
"dataframe",
"."
] | [
"\"\"\"\n Applying the profanity checking functions, differentiate clean conversations and toxic ones from a raw conversation dataframe.\n \n Arg:\n df_convs: A given conversation dataframe from a certain subreddit.\n Return:\n df_clean: A cleaner conversation dataframe without profanity.\... | [
{
"param": "df_convs",
"type": null
},
{
"param": "njobs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df_convs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "njobs",
"type": null,
"docstring": null,
"docstring_token... |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | find_speaker_frequent_words | <not_specific> | def find_speaker_frequent_words(df, num):
"""
Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers.
Args:
df: A specified dataframe from a subreddit.
num: A ranking number used for finding the top frequent words.
For example, i... |
Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers.
Args:
df: A specified dataframe from a subreddit.
num: A ranking number used for finding the top frequent words.
For example, if num = 5, then we'll find the top 5 frequent wor... | Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers. | [
"Given",
"a",
"conversation",
"dataframe",
"from",
"a",
"certain",
"subreddit",
"find",
"the",
"top",
"frequent",
"words",
"spoken",
"by",
"speakers",
"."
] | def find_speaker_frequent_words(df, num):
df_speaker = df[df['dialog turn'] == 1]
df_speaker_filtered = compute_tokens(df_speaker)
result = pd.DataFrame(Counter(df_speaker_filtered.sum()).most_common(num), columns = ["word", "count"])
return result | [
"def",
"find_speaker_frequent_words",
"(",
"df",
",",
"num",
")",
":",
"df_speaker",
"=",
"df",
"[",
"df",
"[",
"'dialog turn'",
"]",
"==",
"1",
"]",
"df_speaker_filtered",
"=",
"compute_tokens",
"(",
"df_speaker",
")",
"result",
"=",
"pd",
".",
"DataFrame",... | Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers. | [
"Given",
"a",
"conversation",
"dataframe",
"from",
"a",
"certain",
"subreddit",
"find",
"the",
"top",
"frequent",
"words",
"spoken",
"by",
"speakers",
"."
] | [
"\"\"\"\n Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by speakers.\n\n Args:\n df: A specified dataframe from a subreddit.\n num: A ranking number used for finding the top frequent words.\n For example, if num = 5, then we'll find the t... | [
{
"param": "df",
"type": null
},
{
"param": "num",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": "A specified dataframe from a subreddit.",
"docstring_tokens": [
"A",
"specified",
"dataframe",
"from",
"a",
"subreddit",
"."
],
... |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | find_listener_frequent_words | <not_specific> | def find_listener_frequent_words(df, num):
"""
Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by listeners.
Args:
df: A specified dataframe from a subreddit.
num: A ranking number used for finding the top frequent words.
Return:
resul... |
Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by listeners.
Args:
df: A specified dataframe from a subreddit.
num: A ranking number used for finding the top frequent words.
Return:
result: A dataframe showing the top frequent words.
... | Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by listeners. | [
"Given",
"a",
"conversation",
"dataframe",
"from",
"a",
"certain",
"subreddit",
"find",
"the",
"top",
"frequent",
"words",
"spoken",
"by",
"listeners",
"."
] | def find_listener_frequent_words(df, num):
df_listener = df[df['dialog turn'] != 1]
df_listener_filtered = compute_tokens(df_listener)
result = pd.DataFrame(Counter(df_listener_filtered.sum()).most_common(num), columns = ["word", "count"])
return result | [
"def",
"find_listener_frequent_words",
"(",
"df",
",",
"num",
")",
":",
"df_listener",
"=",
"df",
"[",
"df",
"[",
"'dialog turn'",
"]",
"!=",
"1",
"]",
"df_listener_filtered",
"=",
"compute_tokens",
"(",
"df_listener",
")",
"result",
"=",
"pd",
".",
"DataFra... | Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by listeners. | [
"Given",
"a",
"conversation",
"dataframe",
"from",
"a",
"certain",
"subreddit",
"find",
"the",
"top",
"frequent",
"words",
"spoken",
"by",
"listeners",
"."
] | [
"\"\"\"\n Given a conversation dataframe from a certain subreddit, find the top frequent words spoken by listeners.\n\n Args:\n df: A specified dataframe from a subreddit.\n num: A ranking number used for finding the top frequent words.\n Return:\n result: A dataframe showing the top f... | [
{
"param": "df",
"type": null
},
{
"param": "num",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": "A specified dataframe from a subreddit.",
"docstring_tokens": [
"A",
"specified",
"dataframe",
"from",
"a",
"subreddit",
"."
],
... |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | extract_profanity | <not_specific> | def extract_profanity(df):
"""
Use parallel computing. Consider only one post at each time.
In each post, extract the profanity considering post texts and comments.
Arg:
df: A given conversation dataframe from a certain subreddit.
Return:
df_toxic: A conversation dataframe with exc... |
Use parallel computing. Consider only one post at each time.
In each post, extract the profanity considering post texts and comments.
Arg:
df: A given conversation dataframe from a certain subreddit.
Return:
df_toxic: A conversation dataframe with exclusively toxic words.
| Use parallel computing. Consider only one post at each time.
In each post, extract the profanity considering post texts and comments.
A given conversation dataframe from a certain subreddit.
Return:
df_toxic: A conversation dataframe with exclusively toxic words. | [
"Use",
"parallel",
"computing",
".",
"Consider",
"only",
"one",
"post",
"at",
"each",
"time",
".",
"In",
"each",
"post",
"extract",
"the",
"profanity",
"considering",
"post",
"texts",
"and",
"comments",
".",
"A",
"given",
"conversation",
"dataframe",
"from",
... | def extract_profanity(df):
df_toxic = pd.DataFrame(columns = ['conversation id', 'subreddit', 'post title', 'author', 'dialog turn', 'text'])
df_post = df.reset_index().drop('index', axis = 1)
toxic_row_list = []
for i, row in df_post.iterrows():
if predict_prob([row['text']])[0] > 0.95:
... | [
"def",
"extract_profanity",
"(",
"df",
")",
":",
"df_toxic",
"=",
"pd",
".",
"DataFrame",
"(",
"columns",
"=",
"[",
"'conversation id'",
",",
"'subreddit'",
",",
"'post title'",
",",
"'author'",
",",
"'dialog turn'",
",",
"'text'",
"]",
")",
"df_post",
"=",
... | Use parallel computing. | [
"Use",
"parallel",
"computing",
"."
] | [
"\"\"\"\n Use parallel computing. Consider only one post at each time.\n In each post, extract the profanity considering post texts and comments. \n\n Arg:\n df: A given conversation dataframe from a certain subreddit.\n Return:\n df_toxic: A conversation dataframe with exclusively toxic w... | [
{
"param": "df",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | count_speaker_profanity | <not_specific> | def count_speaker_profanity(df):
"""
Compute the number of profane words spoken by the speakers.
Arg:
df: A dataframe containing profane utterances.
Return:
len(df_speaker_toxic): the length of the dataframe of profanity from speakers.
"""
# extract speakers' turn
df_speaker... |
Compute the number of profane words spoken by the speakers.
Arg:
df: A dataframe containing profane utterances.
Return:
len(df_speaker_toxic): the length of the dataframe of profanity from speakers.
| Compute the number of profane words spoken by the speakers.
Arg:
df: A dataframe containing profane utterances.
Return:
len(df_speaker_toxic): the length of the dataframe of profanity from speakers. | [
"Compute",
"the",
"number",
"of",
"profane",
"words",
"spoken",
"by",
"the",
"speakers",
".",
"Arg",
":",
"df",
":",
"A",
"dataframe",
"containing",
"profane",
"utterances",
".",
"Return",
":",
"len",
"(",
"df_speaker_toxic",
")",
":",
"the",
"length",
"of... | def count_speaker_profanity(df):
df_speaker = df[df['dialog turn'] == 1]
df_speaker_toxic = apply_parallel(df_speaker.groupby(df_speaker['conversation id']), extract_profanity)
return len(df_speaker_toxic) | [
"def",
"count_speaker_profanity",
"(",
"df",
")",
":",
"df_speaker",
"=",
"df",
"[",
"df",
"[",
"'dialog turn'",
"]",
"==",
"1",
"]",
"df_speaker_toxic",
"=",
"apply_parallel",
"(",
"df_speaker",
".",
"groupby",
"(",
"df_speaker",
"[",
"'conversation id'",
"]"... | Compute the number of profane words spoken by the speakers. | [
"Compute",
"the",
"number",
"of",
"profane",
"words",
"spoken",
"by",
"the",
"speakers",
"."
] | [
"\"\"\"\n Compute the number of profane words spoken by the speakers.\n\n Arg:\n df: A dataframe containing profane utterances.\n Return:\n len(df_speaker_toxic): the length of the dataframe of profanity from speakers.\n \"\"\"",
"# extract speakers' turn",
"# extract toxic turn"
] | [
{
"param": "df",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | count_listener_profanity | <not_specific> | def count_listener_profanity(df):
"""
Compute the number of profane words spoken by the listeners.
Arg:
df: A dataframe containing profane utterances.
Return:
len(df_listener_toxic): the length of the dataframe of profanity from listeners.
"""
# extract listeners' turn
df_li... |
Compute the number of profane words spoken by the listeners.
Arg:
df: A dataframe containing profane utterances.
Return:
len(df_listener_toxic): the length of the dataframe of profanity from listeners.
| Compute the number of profane words spoken by the listeners.
Arg:
df: A dataframe containing profane utterances.
Return:
len(df_listener_toxic): the length of the dataframe of profanity from listeners. | [
"Compute",
"the",
"number",
"of",
"profane",
"words",
"spoken",
"by",
"the",
"listeners",
".",
"Arg",
":",
"df",
":",
"A",
"dataframe",
"containing",
"profane",
"utterances",
".",
"Return",
":",
"len",
"(",
"df_listener_toxic",
")",
":",
"the",
"length",
"... | def count_listener_profanity(df):
df_listener = df[df['dialog turn'] != 1]
df_listener_toxic = apply_parallel(df_listener.groupby(df_listener['conversation id']), extract_profanity)
return len(df_listener_toxic) | [
"def",
"count_listener_profanity",
"(",
"df",
")",
":",
"df_listener",
"=",
"df",
"[",
"df",
"[",
"'dialog turn'",
"]",
"!=",
"1",
"]",
"df_listener_toxic",
"=",
"apply_parallel",
"(",
"df_listener",
".",
"groupby",
"(",
"df_listener",
"[",
"'conversation id'",
... | Compute the number of profane words spoken by the listeners. | [
"Compute",
"the",
"number",
"of",
"profane",
"words",
"spoken",
"by",
"the",
"listeners",
"."
] | [
"\"\"\"\n Compute the number of profane words spoken by the listeners.\n\n Arg:\n df: A dataframe containing profane utterances.\n Return:\n len(df_listener_toxic): the length of the dataframe of profanity from listeners.\n \"\"\"",
"# extract listeners' turn",
"# extract toxic turn"
] | [
{
"param": "df",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | lang_correct | <not_specific> | def lang_correct(subreddit_convs_clean, tool):
"""
Fix the utterances to the correct English format.
Arg:
subreddit_convs_clean: A dataframe containing clean conversations.
tool: A toolkit for language correction.
Return:
subreddit_convs_clean: A dataframe with clean and grammat... |
Fix the utterances to the correct English format.
Arg:
subreddit_convs_clean: A dataframe containing clean conversations.
tool: A toolkit for language correction.
Return:
subreddit_convs_clean: A dataframe with clean and grammatically correct conversations.
| Fix the utterances to the correct English format.
Arg:
subreddit_convs_clean: A dataframe containing clean conversations.
tool: A toolkit for language correction.
Return:
subreddit_convs_clean: A dataframe with clean and grammatically correct conversations. | [
"Fix",
"the",
"utterances",
"to",
"the",
"correct",
"English",
"format",
".",
"Arg",
":",
"subreddit_convs_clean",
":",
"A",
"dataframe",
"containing",
"clean",
"conversations",
".",
"tool",
":",
"A",
"toolkit",
"for",
"language",
"correction",
".",
"Return",
... | def lang_correct(subreddit_convs_clean, tool):
subreddit_convs_clean['text'] = subreddit_convs_clean['text'].swifter.apply(lambda text: tool.correct(text))
return subreddit_convs_clean | [
"def",
"lang_correct",
"(",
"subreddit_convs_clean",
",",
"tool",
")",
":",
"subreddit_convs_clean",
"[",
"'text'",
"]",
"=",
"subreddit_convs_clean",
"[",
"'text'",
"]",
".",
"swifter",
".",
"apply",
"(",
"lambda",
"text",
":",
"tool",
".",
"correct",
"(",
... | Fix the utterances to the correct English format. | [
"Fix",
"the",
"utterances",
"to",
"the",
"correct",
"English",
"format",
"."
] | [
"\"\"\"\n Fix the utterances to the correct English format.\n\n Arg:\n subreddit_convs_clean: A dataframe containing clean conversations.\n tool: A toolkit for language correction.\n Return:\n subreddit_convs_clean: A dataframe with clean and grammatically correct conversations.\n \... | [
{
"param": "subreddit_convs_clean",
"type": null
},
{
"param": "tool",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "subreddit_convs_clean",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tool",
"type": null,
"docstring": null,
"doc... |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | determine_pos_neu_neg | <not_specific> | def determine_pos_neu_neg(compound):
"""
Based on the compound score, classify a sentiment into positive, negative, or neutral.
Arg:
compound: A numerical compound score.
Return:
A label in "positive", "negative", or "neutral".
"""
if compound >= 0.05:
return 'positive'
... |
Based on the compound score, classify a sentiment into positive, negative, or neutral.
Arg:
compound: A numerical compound score.
Return:
A label in "positive", "negative", or "neutral".
| Based on the compound score, classify a sentiment into positive, negative, or neutral.
Arg:
compound: A numerical compound score. | [
"Based",
"on",
"the",
"compound",
"score",
"classify",
"a",
"sentiment",
"into",
"positive",
"negative",
"or",
"neutral",
".",
"Arg",
":",
"compound",
":",
"A",
"numerical",
"compound",
"score",
"."
] | def determine_pos_neu_neg(compound):
if compound >= 0.05:
return 'positive'
elif compound < 0.05 and compound > -0.05:
return 'neutral'
else:
return 'negative' | [
"def",
"determine_pos_neu_neg",
"(",
"compound",
")",
":",
"if",
"compound",
">=",
"0.05",
":",
"return",
"'positive'",
"elif",
"compound",
"<",
"0.05",
"and",
"compound",
">",
"-",
"0.05",
":",
"return",
"'neutral'",
"else",
":",
"return",
"'negative'"
] | Based on the compound score, classify a sentiment into positive, negative, or neutral. | [
"Based",
"on",
"the",
"compound",
"score",
"classify",
"a",
"sentiment",
"into",
"positive",
"negative",
"or",
"neutral",
"."
] | [
"\"\"\"\n Based on the compound score, classify a sentiment into positive, negative, or neutral.\n\n Arg:\n compound: A numerical compound score.\n Return:\n A label in \"positive\", \"negative\", or \"neutral\".\n \"\"\""
] | [
{
"param": "compound",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "compound",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | compute_sentiment | <not_specific> | def compute_sentiment(subreddit_convs_clean, analyzer = SentimentIntensityAnalyzer()):
"""
Calculate the conversation sentiment via the built sentiment analyzer.
Args:
subreddit_convs_clean: A dataframe containing clean conversations.
analyzer: A built analyzer for sentiment analysis.
R... |
Calculate the conversation sentiment via the built sentiment analyzer.
Args:
subreddit_convs_clean: A dataframe containing clean conversations.
analyzer: A built analyzer for sentiment analysis.
Return:
subreddit_convs_clean: A dataframe added with sentiment prediction.
| Calculate the conversation sentiment via the built sentiment analyzer. | [
"Calculate",
"the",
"conversation",
"sentiment",
"via",
"the",
"built",
"sentiment",
"analyzer",
"."
] | def compute_sentiment(subreddit_convs_clean, analyzer = SentimentIntensityAnalyzer()):
subreddit_convs_clean['text'] = subreddit_convs_clean['text'].astype(str)
subreddit_convs_clean['compound'] = subreddit_convs_clean['text']\
.swifter.apply(lambda text: analyzer.pol... | [
"def",
"compute_sentiment",
"(",
"subreddit_convs_clean",
",",
"analyzer",
"=",
"SentimentIntensityAnalyzer",
"(",
")",
")",
":",
"subreddit_convs_clean",
"[",
"'text'",
"]",
"=",
"subreddit_convs_clean",
"[",
"'text'",
"]",
".",
"astype",
"(",
"str",
")",
"subred... | Calculate the conversation sentiment via the built sentiment analyzer. | [
"Calculate",
"the",
"conversation",
"sentiment",
"via",
"the",
"built",
"sentiment",
"analyzer",
"."
] | [
"\"\"\"\n Calculate the conversation sentiment via the built sentiment analyzer.\n\n Args:\n subreddit_convs_clean: A dataframe containing clean conversations.\n analyzer: A built analyzer for sentiment analysis.\n Return:\n subreddit_convs_clean: A dataframe added with sentiment predi... | [
{
"param": "subreddit_convs_clean",
"type": null
},
{
"param": "analyzer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "subreddit_convs_clean",
"type": null,
"docstring": "A dataframe containing clean conversations.",
"docstring_tokens": [
"A",
"dataframe",
"containing",
"clean",
"conversations",
... |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | speaker_emotion_count | <not_specific> | def speaker_emotion_count(df_convs):
"""
Compute the number of emotion prediction.
Arg:
df_convs: A conversation dataframe with predicted emotion labels.
Return:
df_speaker_emotion_count: A dataframe summarizing predicted emotion counting.
"""
if len(df_convs['dialog turn']) >=... |
Compute the number of emotion prediction.
Arg:
df_convs: A conversation dataframe with predicted emotion labels.
Return:
df_speaker_emotion_count: A dataframe summarizing predicted emotion counting.
| Compute the number of emotion prediction.
Arg:
df_convs: A conversation dataframe with predicted emotion labels.
Return:
df_speaker_emotion_count: A dataframe summarizing predicted emotion counting. | [
"Compute",
"the",
"number",
"of",
"emotion",
"prediction",
".",
"Arg",
":",
"df_convs",
":",
"A",
"conversation",
"dataframe",
"with",
"predicted",
"emotion",
"labels",
".",
"Return",
":",
"df_speaker_emotion_count",
":",
"A",
"dataframe",
"summarizing",
"predicte... | def speaker_emotion_count(df_convs):
if len(df_convs['dialog turn']) >= 1:
speaker = df_convs[df_convs['dialog turn'] == 1].author.values[0]
df_convs_speaker = df_convs[df_convs['author'] == speaker]
df_speaker_emotion_count = pd.DataFrame(df_convs_speaker['emotion prediction'].value_counts(... | [
"def",
"speaker_emotion_count",
"(",
"df_convs",
")",
":",
"if",
"len",
"(",
"df_convs",
"[",
"'dialog turn'",
"]",
")",
">=",
"1",
":",
"speaker",
"=",
"df_convs",
"[",
"df_convs",
"[",
"'dialog turn'",
"]",
"==",
"1",
"]",
".",
"author",
".",
"values",... | Compute the number of emotion prediction. | [
"Compute",
"the",
"number",
"of",
"emotion",
"prediction",
"."
] | [
"\"\"\"\n Compute the number of emotion prediction.\n\n Arg:\n df_convs: A conversation dataframe with predicted emotion labels.\n Return:\n df_speaker_emotion_count: A dataframe summarizing predicted emotion counting. \n \"\"\""
] | [
{
"param": "df_convs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df_convs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73b03533e55164883c7ff3eb53a7db36294879a2 | yehchunhung/reddit-dialogues | utils4text.py | [
"MIT"
] | Python | listener_emotion_count | <not_specific> | def listener_emotion_count(df_convs):
"""
Compute the number of emotion prediction.
Arg:
df_convs: A conversation dataframe with predicted emotion labels.
Return:
df_listener_emotion_count: A dataframe summarizing predicted emotion counting.
"""
if len(df_convs['dialog turn']) ... |
Compute the number of emotion prediction.
Arg:
df_convs: A conversation dataframe with predicted emotion labels.
Return:
df_listener_emotion_count: A dataframe summarizing predicted emotion counting.
| Compute the number of emotion prediction.
Arg:
df_convs: A conversation dataframe with predicted emotion labels.
Return:
df_listener_emotion_count: A dataframe summarizing predicted emotion counting. | [
"Compute",
"the",
"number",
"of",
"emotion",
"prediction",
".",
"Arg",
":",
"df_convs",
":",
"A",
"conversation",
"dataframe",
"with",
"predicted",
"emotion",
"labels",
".",
"Return",
":",
"df_listener_emotion_count",
":",
"A",
"dataframe",
"summarizing",
"predict... | def listener_emotion_count(df_convs):
if len(df_convs['dialog turn']) >= 1:
speaker = df_convs[df_convs['dialog turn'] == 1].author.values[0]
df_convs_listener = df_convs[df_convs['author'] != speaker]
df_listener_emotion_count = pd.DataFrame(df_convs_listener['emotion prediction'].value_cou... | [
"def",
"listener_emotion_count",
"(",
"df_convs",
")",
":",
"if",
"len",
"(",
"df_convs",
"[",
"'dialog turn'",
"]",
")",
">=",
"1",
":",
"speaker",
"=",
"df_convs",
"[",
"df_convs",
"[",
"'dialog turn'",
"]",
"==",
"1",
"]",
".",
"author",
".",
"values"... | Compute the number of emotion prediction. | [
"Compute",
"the",
"number",
"of",
"emotion",
"prediction",
"."
] | [
"\"\"\"\n Compute the number of emotion prediction.\n\n Arg:\n df_convs: A conversation dataframe with predicted emotion labels.\n Return:\n df_listener_emotion_count: A dataframe summarizing predicted emotion counting. \n \"\"\""
] | [
{
"param": "df_convs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df_convs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91e6f9425237c8e57842aa5c03ec9371ffc4f680 | julianirwin/hloopy | hloopy/hloop.py | [
"MIT"
] | Python | num_cols | <not_specific> | def num_cols(self):
"""Number of columns in the linked data file.
Returns:
n (int): Number of columns.
"""
return len(self.df.columns) | Number of columns in the linked data file.
Returns:
n (int): Number of columns.
| Number of columns in the linked data file. | [
"Number",
"of",
"columns",
"in",
"the",
"linked",
"data",
"file",
"."
] | def num_cols(self):
return len(self.df.columns) | [
"def",
"num_cols",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"df",
".",
"columns",
")"
] | Number of columns in the linked data file. | [
"Number",
"of",
"columns",
"in",
"the",
"linked",
"data",
"file",
"."
] | [
"\"\"\"Number of columns in the linked data file.\n\n Returns:\n n (int): Number of columns.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "n (int): Number of columns.",
"docstring_tokens": [
"n",
"(",
"int",
")",
":",
"Number",
"of",
"columns",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identif... |
91e6f9425237c8e57842aa5c03ec9371ffc4f680 | julianirwin/hloopy | hloopy/hloop.py | [
"MIT"
] | Python | _x | <not_specific> | def _x(self):
"""Get this HLoop's x-axis data. In a custom subclass of
hloopy.HLoop this can be overridden to allow custom
transformation/manipulation of the x data. The only
requirement is that it returns an numpy.ndarray like object
that will have the same length as the one HL... | Get this HLoop's x-axis data. In a custom subclass of
hloopy.HLoop this can be overridden to allow custom
transformation/manipulation of the x data. The only
requirement is that it returns an numpy.ndarray like object
that will have the same length as the one HLoop.y() returns.
| Get this HLoop's x-axis data. In a custom subclass of
hloopy.HLoop this can be overridden to allow custom
transformation/manipulation of the x data. The only
requirement is that it returns an numpy.ndarray like object
that will have the same length as the one HLoop.y() returns. | [
"Get",
"this",
"HLoop",
"'",
"s",
"x",
"-",
"axis",
"data",
".",
"In",
"a",
"custom",
"subclass",
"of",
"hloopy",
".",
"HLoop",
"this",
"can",
"be",
"overridden",
"to",
"allow",
"custom",
"transformation",
"/",
"manipulation",
"of",
"the",
"x",
"data",
... | def _x(self):
try:
xcol = self.xcol[0]
return self.df.ix[:, xcol]
except (AttributeError, ValueError):
return self.df.ix[:, 0] | [
"def",
"_x",
"(",
"self",
")",
":",
"try",
":",
"xcol",
"=",
"self",
".",
"xcol",
"[",
"0",
"]",
"return",
"self",
".",
"df",
".",
"ix",
"[",
":",
",",
"xcol",
"]",
"except",
"(",
"AttributeError",
",",
"ValueError",
")",
":",
"return",
"self",
... | Get this HLoop's x-axis data. | [
"Get",
"this",
"HLoop",
"'",
"s",
"x",
"-",
"axis",
"data",
"."
] | [
"\"\"\"Get this HLoop's x-axis data. In a custom subclass of\n hloopy.HLoop this can be overridden to allow custom \n transformation/manipulation of the x data. The only\n requirement is that it returns an numpy.ndarray like object\n that will have the same length as the one HLoop.y() re... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91e6f9425237c8e57842aa5c03ec9371ffc4f680 | julianirwin/hloopy | hloopy/hloop.py | [
"MIT"
] | Python | _y | <not_specific> | def _y(self):
"""Get this HLoop's y-axis data. In a custom subclass of
hloopy.HLoop this can be overridden to allow custom
transformation/manipulation of the y data. The only
requirement is that it returns an numpy.ndarray like object
that will have the same length as the one HL... | Get this HLoop's y-axis data. In a custom subclass of
hloopy.HLoop this can be overridden to allow custom
transformation/manipulation of the y data. The only
requirement is that it returns an numpy.ndarray like object
that will have the same length as the one HLoop.x() returns.
| Get this HLoop's y-axis data. In a custom subclass of
hloopy.HLoop this can be overridden to allow custom
transformation/manipulation of the y data. The only
requirement is that it returns an numpy.ndarray like object
that will have the same length as the one HLoop.x() returns. | [
"Get",
"this",
"HLoop",
"'",
"s",
"y",
"-",
"axis",
"data",
".",
"In",
"a",
"custom",
"subclass",
"of",
"hloopy",
".",
"HLoop",
"this",
"can",
"be",
"overridden",
"to",
"allow",
"custom",
"transformation",
"/",
"manipulation",
"of",
"the",
"y",
"data",
... | def _y(self):
try:
ycol = self.ycol[0]
return self.df.ix[:, ycol]
except (AttributeError, ValueError):
return self.df.ix[:, 1] | [
"def",
"_y",
"(",
"self",
")",
":",
"try",
":",
"ycol",
"=",
"self",
".",
"ycol",
"[",
"0",
"]",
"return",
"self",
".",
"df",
".",
"ix",
"[",
":",
",",
"ycol",
"]",
"except",
"(",
"AttributeError",
",",
"ValueError",
")",
":",
"return",
"self",
... | Get this HLoop's y-axis data. | [
"Get",
"this",
"HLoop",
"'",
"s",
"y",
"-",
"axis",
"data",
"."
] | [
"\"\"\"Get this HLoop's y-axis data. In a custom subclass of\n hloopy.HLoop this can be overridden to allow custom \n transformation/manipulation of the y data. The only\n requirement is that it returns an numpy.ndarray like object\n that will have the same length as the one HLoop.x() re... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91e6f9425237c8e57842aa5c03ec9371ffc4f680 | julianirwin/hloopy | hloopy/hloop.py | [
"MIT"
] | Python | _pick_shape | <not_specific> | def _pick_shape(self, N):
"""Pick a good grid shape for N HLoops."""
ncols = int(np.ceil(np.sqrt(N)))
nrows = int(np.ceil(N / ncols))
return nrows, ncols | Pick a good grid shape for N HLoops. | Pick a good grid shape for N HLoops. | [
"Pick",
"a",
"good",
"grid",
"shape",
"for",
"N",
"HLoops",
"."
] | def _pick_shape(self, N):
ncols = int(np.ceil(np.sqrt(N)))
nrows = int(np.ceil(N / ncols))
return nrows, ncols | [
"def",
"_pick_shape",
"(",
"self",
",",
"N",
")",
":",
"ncols",
"=",
"int",
"(",
"np",
".",
"ceil",
"(",
"np",
".",
"sqrt",
"(",
"N",
")",
")",
")",
"nrows",
"=",
"int",
"(",
"np",
".",
"ceil",
"(",
"N",
"/",
"ncols",
")",
")",
"return",
"n... | Pick a good grid shape for N HLoops. | [
"Pick",
"a",
"good",
"grid",
"shape",
"for",
"N",
"HLoops",
"."
] | [
"\"\"\"Pick a good grid shape for N HLoops.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "N",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "N",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
91e6f9425237c8e57842aa5c03ec9371ffc4f680 | julianirwin/hloopy | hloopy/hloop.py | [
"MIT"
] | Python | _assert_mapping_func_valid | null | def _assert_mapping_func_valid(self, func, hloop):
"""Assert that mapping_func takes an hloop and returns a (row, col)
sequence.
"""
output = func(hloop)
if not len(output) == 2:
raise ValueError("'mapping_func' not outputting length 2 sequence")
if not isinst... | Assert that mapping_func takes an hloop and returns a (row, col)
sequence.
| Assert that mapping_func takes an hloop and returns a (row, col)
sequence. | [
"Assert",
"that",
"mapping_func",
"takes",
"an",
"hloop",
"and",
"returns",
"a",
"(",
"row",
"col",
")",
"sequence",
"."
] | def _assert_mapping_func_valid(self, func, hloop):
output = func(hloop)
if not len(output) == 2:
raise ValueError("'mapping_func' not outputting length 2 sequence")
if not isinstance(output[0], int) and isinstance(output[1], int):
msg = "'mapping_func' sequence output con... | [
"def",
"_assert_mapping_func_valid",
"(",
"self",
",",
"func",
",",
"hloop",
")",
":",
"output",
"=",
"func",
"(",
"hloop",
")",
"if",
"not",
"len",
"(",
"output",
")",
"==",
"2",
":",
"raise",
"ValueError",
"(",
"\"'mapping_func' not outputting length 2 seque... | Assert that mapping_func takes an hloop and returns a (row, col)
sequence. | [
"Assert",
"that",
"mapping_func",
"takes",
"an",
"hloop",
"and",
"returns",
"a",
"(",
"row",
"col",
")",
"sequence",
"."
] | [
"\"\"\"Assert that mapping_func takes an hloop and returns a (row, col)\n sequence.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "func",
"type": null
},
{
"param": "hloop",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_tokens": [... |
bc371e4d236f165238ef1566e6d9acb8cd01d4cc | julianirwin/hloopy | hloopy/plotters.py | [
"MIT"
] | Python | extracts_as_df | <not_specific> | def extracts_as_df(self):
"""After plotting, get all extracts in a dataframe with rows like:
"/Path/to/hloop/data, label, avg_val, xcoords, ycoords, indices"
If you want the actual extracts just grab them from
GridPlot.extract_instances, which is a dict keyed by fpaths and with
... | After plotting, get all extracts in a dataframe with rows like:
"/Path/to/hloop/data, label, avg_val, xcoords, ycoords, indices"
If you want the actual extracts just grab them from
GridPlot.extract_instances, which is a dict keyed by fpaths and with
lists of extacts as values.
... | After plotting, get all extracts in a dataframe with rows like:
"/Path/to/hloop/data, label, avg_val, xcoords, ycoords, indices"
If you want the actual extracts just grab them from
GridPlot.extract_instances, which is a dict keyed by fpaths and with
lists of extacts as values. | [
"After",
"plotting",
"get",
"all",
"extracts",
"in",
"a",
"dataframe",
"with",
"rows",
"like",
":",
"\"",
"/",
"Path",
"/",
"to",
"/",
"hloop",
"/",
"data",
"label",
"avg_val",
"xcoords",
"ycoords",
"indices",
"\"",
"If",
"you",
"want",
"the",
"actual",
... | def extracts_as_df(self):
from pandas import DataFrame
d = defaultdict(list)
for fpath, extracts in self.extract_instances.items():
for e in extracts:
d['fpath'].append(fpath)
d['label'].append(e.label)
d['avg_val'].append(e.avg_val)
... | [
"def",
"extracts_as_df",
"(",
"self",
")",
":",
"from",
"pandas",
"import",
"DataFrame",
"d",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"fpath",
",",
"extracts",
"in",
"self",
".",
"extract_instances",
".",
"items",
"(",
")",
":",
"for",
"e",
"in",
... | After plotting, get all extracts in a dataframe with rows like:
"/Path/to/hloop/data, label, avg_val, xcoords, ycoords, indices" | [
"After",
"plotting",
"get",
"all",
"extracts",
"in",
"a",
"dataframe",
"with",
"rows",
"like",
":",
"\"",
"/",
"Path",
"/",
"to",
"/",
"hloop",
"/",
"data",
"label",
"avg_val",
"xcoords",
"ycoords",
"indices",
"\""
] | [
"\"\"\"After plotting, get all extracts in a dataframe with rows like:\n\n \"/Path/to/hloop/data, label, avg_val, xcoords, ycoords, indices\"\n\n If you want the actual extracts just grab them from \n GridPlot.extract_instances, which is a dict keyed by fpaths and with\n lists of extacts... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bc371e4d236f165238ef1566e6d9acb8cd01d4cc | julianirwin/hloopy | hloopy/plotters.py | [
"MIT"
] | Python | plot | <not_specific> | def plot(self, simple_label=False, extract_plot_kwargs={},
ostring='nwes', **kwargs):
"""Plot the HLoops on a grid.
Args:
- ostring (string): A four character string that determines the
orientation transformation applied. Letters correspond to
c... | Plot the HLoops on a grid.
Args:
- ostring (string): A four character string that determines the
orientation transformation applied. Letters correspond to
cardinal directions n, e, s, w. The first two characters
are the location of (0, 0), the third c... | Plot the HLoops on a grid. | [
"Plot",
"the",
"HLoops",
"on",
"a",
"grid",
"."
] | def plot(self, simple_label=False, extract_plot_kwargs={},
ostring='nwes', **kwargs):
ostring = ostring.lower()
final_nrows, final_ncols = self.rotated_shape(ostring, self.nrows,
self.ncols)
self.fig, self.axarr = plt.subplots(... | [
"def",
"plot",
"(",
"self",
",",
"simple_label",
"=",
"False",
",",
"extract_plot_kwargs",
"=",
"{",
"}",
",",
"ostring",
"=",
"'nwes'",
",",
"**",
"kwargs",
")",
":",
"ostring",
"=",
"ostring",
".",
"lower",
"(",
")",
"final_nrows",
",",
"final_ncols",
... | Plot the HLoops on a grid. | [
"Plot",
"the",
"HLoops",
"on",
"a",
"grid",
"."
] | [
"\"\"\"Plot the HLoops on a grid.\n\n Args:\n - ostring (string): A four character string that determines the\n orientation transformation applied. Letters correspond to\n cardinal directions n, e, s, w. The first two characters\n are the location of (0... | [
{
"param": "self",
"type": null
},
{
"param": "simple_label",
"type": null
},
{
"param": "extract_plot_kwargs",
"type": null
},
{
"param": "ostring",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "simple_label",
"type": null,
"docstring": null,
"docstring_to... |
bc371e4d236f165238ef1566e6d9acb8cd01d4cc | julianirwin/hloopy | hloopy/plotters.py | [
"MIT"
] | Python | plot | <not_specific> | def plot(self, ostring='nwes', colorbar={}, clim=None, hideaxes=False,
missing_val=0.0, **kwargs):
"""Plot the HLoops on a grid.
Also adds extract_instances 2d array to this ExtractGridPlot instance
if the instances are needed for something morecomplicated than just an
imsh... | Plot the HLoops on a grid.
Also adds extract_instances 2d array to this ExtractGridPlot instance
if the instances are needed for something morecomplicated than just an
imshow of the avg_vals.
Args:
- ostring (string): A four character string that determines the
... | Plot the HLoops on a grid.
Also adds extract_instances 2d array to this ExtractGridPlot instance
if the instances are needed for something morecomplicated than just an
imshow of the avg_vals. | [
"Plot",
"the",
"HLoops",
"on",
"a",
"grid",
".",
"Also",
"adds",
"extract_instances",
"2d",
"array",
"to",
"this",
"ExtractGridPlot",
"instance",
"if",
"the",
"instances",
"are",
"needed",
"for",
"something",
"morecomplicated",
"than",
"just",
"an",
"imshow",
... | def plot(self, ostring='nwes', colorbar={}, clim=None, hideaxes=False,
missing_val=0.0, **kwargs):
ostring = ostring.lower()
final_nrows, final_ncols = self.rotated_shape(ostring, self.nrows,
self.ncols)
self.extract_avg_vals = ... | [
"def",
"plot",
"(",
"self",
",",
"ostring",
"=",
"'nwes'",
",",
"colorbar",
"=",
"{",
"}",
",",
"clim",
"=",
"None",
",",
"hideaxes",
"=",
"False",
",",
"missing_val",
"=",
"0.0",
",",
"**",
"kwargs",
")",
":",
"ostring",
"=",
"ostring",
".",
"lowe... | Plot the HLoops on a grid. | [
"Plot",
"the",
"HLoops",
"on",
"a",
"grid",
"."
] | [
"\"\"\"Plot the HLoops on a grid.\n\n Also adds extract_instances 2d array to this ExtractGridPlot instance\n if the instances are needed for something morecomplicated than just an\n imshow of the avg_vals.\n\n\n Args:\n - ostring (string): A four character string that determi... | [
{
"param": "self",
"type": null
},
{
"param": "ostring",
"type": null
},
{
"param": "colorbar",
"type": null
},
{
"param": "clim",
"type": null
},
{
"param": "hideaxes",
"type": null
},
{
"param": "missing_val",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ostring",
"type": null,
"docstring": null,
"docstring_tokens"... |
bc371e4d236f165238ef1566e6d9acb8cd01d4cc | julianirwin/hloopy | hloopy/plotters.py | [
"MIT"
] | Python | histogram | <not_specific> | def histogram(self, xslice=(None, None), yslice=(None, None), ax=None, hist_kwargs={}):
"""Plot histogram of extract values. Must be run
after self.plot()!!!
Args:
xslice / yslice (tuple): A tuple of ints or None. Used to select
which subregion of the 2d gri... | Plot histogram of extract values. Must be run
after self.plot()!!!
Args:
xslice / yslice (tuple): A tuple of ints or None. Used to select
which subregion of the 2d grid is to be turned into a
histogram. (None, None) will select the whole range.
... | Plot histogram of extract values. Must be run
after self.plot() | [
"Plot",
"histogram",
"of",
"extract",
"values",
".",
"Must",
"be",
"run",
"after",
"self",
".",
"plot",
"()"
] | def histogram(self, xslice=(None, None), yslice=(None, None), ax=None, hist_kwargs={}):
if ax is None:
fig, ax = plt.subplots()
ret_fig = True
else:
ret_fig = False
vals = np.array(self.extract_avg_vals)
vals = vals[xslice[0]:xslice[1], yslice[0]:yslic... | [
"def",
"histogram",
"(",
"self",
",",
"xslice",
"=",
"(",
"None",
",",
"None",
")",
",",
"yslice",
"=",
"(",
"None",
",",
"None",
")",
",",
"ax",
"=",
"None",
",",
"hist_kwargs",
"=",
"{",
"}",
")",
":",
"if",
"ax",
"is",
"None",
":",
"fig",
... | Plot histogram of extract values. | [
"Plot",
"histogram",
"of",
"extract",
"values",
"."
] | [
"\"\"\"Plot histogram of extract values. Must be run \n after self.plot()!!!\n \n Args:\n xslice / yslice (tuple): A tuple of ints or None. Used to select\n which subregion of the 2d grid is to be turned into a \n histogram. (None, None) will select the ... | [
{
"param": "self",
"type": null
},
{
"param": "xslice",
"type": null
},
{
"param": "yslice",
"type": null
},
{
"param": "ax",
"type": null
},
{
"param": "hist_kwargs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "xslice",
"type": null,
"docstring": null,
"docstring_tokens":... |
bc371e4d236f165238ef1566e6d9acb8cd01d4cc | julianirwin/hloopy | hloopy/plotters.py | [
"MIT"
] | Python | plot | <not_specific> | def plot(self, ostring='nwes', colorbar={}, clim=None, hideaxes=False,
**kwargs):
"""Plot the HLoops on a grid.
Also adds extract_instances 2d array to this ExtractGridPlot instance
if the instances are needed for something morecomplicated than just an
imshow of the avg_va... | Plot the HLoops on a grid.
Also adds extract_instances 2d array to this ExtractGridPlot instance
if the instances are needed for something morecomplicated than just an
imshow of the avg_vals.
Args:
- ostring (string): A four character string that determines the
... | Plot the HLoops on a grid.
Also adds extract_instances 2d array to this ExtractGridPlot instance
if the instances are needed for something morecomplicated than just an
imshow of the avg_vals. | [
"Plot",
"the",
"HLoops",
"on",
"a",
"grid",
".",
"Also",
"adds",
"extract_instances",
"2d",
"array",
"to",
"this",
"ExtractGridPlot",
"instance",
"if",
"the",
"instances",
"are",
"needed",
"for",
"something",
"morecomplicated",
"than",
"just",
"an",
"imshow",
... | def plot(self, ostring='nwes', colorbar={}, clim=None, hideaxes=False,
**kwargs):
ostring = ostring.lower()
final_nrows, final_ncols = self.rotated_shape(ostring, self.nrows,
self.ncols)
self.extract_avg_vals = self._empty_2dar... | [
"def",
"plot",
"(",
"self",
",",
"ostring",
"=",
"'nwes'",
",",
"colorbar",
"=",
"{",
"}",
",",
"clim",
"=",
"None",
",",
"hideaxes",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"ostring",
"=",
"ostring",
".",
"lower",
"(",
")",
"final_nrows",
","... | Plot the HLoops on a grid. | [
"Plot",
"the",
"HLoops",
"on",
"a",
"grid",
"."
] | [
"\"\"\"Plot the HLoops on a grid.\n\n Also adds extract_instances 2d array to this ExtractGridPlot instance\n if the instances are needed for something morecomplicated than just an\n imshow of the avg_vals.\n\n\n Args:\n - ostring (string): A four character string that determi... | [
{
"param": "self",
"type": null
},
{
"param": "ostring",
"type": null
},
{
"param": "colorbar",
"type": null
},
{
"param": "clim",
"type": null
},
{
"param": "hideaxes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ostring",
"type": null,
"docstring": null,
"docstring_tokens"... |
7c911a22f50d93fb24dbd701151712d6b4099ada | julianirwin/hloopy | hloopy/extract.py | [
"MIT"
] | Python | plot | null | def plot(self, ax, **kwargs):
"""Convert the data represented in this class into a graphical
representation and then plot it on :code:`ax`, a mpl.axes object.
Args:
ax (matplotlib.axes): Axes to plot extract on.
kwargs: Keyword parameters of :code:`matplotlib.axes.plot`
... | Convert the data represented in this class into a graphical
representation and then plot it on :code:`ax`, a mpl.axes object.
Args:
ax (matplotlib.axes): Axes to plot extract on.
kwargs: Keyword parameters of :code:`matplotlib.axes.plot`
Returns:
Same as `ma... | Convert the data represented in this class into a graphical
representation and then plot it on :code:`ax`, a mpl.axes object. | [
"Convert",
"the",
"data",
"represented",
"in",
"this",
"class",
"into",
"a",
"graphical",
"representation",
"and",
"then",
"plot",
"it",
"on",
":",
"code",
":",
"`",
"ax",
"`",
"a",
"mpl",
".",
"axes",
"object",
"."
] | def plot(self, ax, **kwargs):
styles = {'linestyle': 'none',
'marker': 'o',
'label': self.label_short,
'alpha': 0.7,
'mew': 1,
'ms': 8}
styles.update(kwargs)
ax.plot(self.xs, self.ys, **styles) | [
"def",
"plot",
"(",
"self",
",",
"ax",
",",
"**",
"kwargs",
")",
":",
"styles",
"=",
"{",
"'linestyle'",
":",
"'none'",
",",
"'marker'",
":",
"'o'",
",",
"'label'",
":",
"self",
".",
"label_short",
",",
"'alpha'",
":",
"0.7",
",",
"'mew'",
":",
"1"... | Convert the data represented in this class into a graphical
representation and then plot it on :code:`ax`, a mpl.axes object. | [
"Convert",
"the",
"data",
"represented",
"in",
"this",
"class",
"into",
"a",
"graphical",
"representation",
"and",
"then",
"plot",
"it",
"on",
":",
"code",
":",
"`",
"ax",
"`",
"a",
"mpl",
".",
"axes",
"object",
"."
] | [
"\"\"\"Convert the data represented in this class into a graphical\n representation and then plot it on :code:`ax`, a mpl.axes object.\n\n Args:\n ax (matplotlib.axes): Axes to plot extract on.\n kwargs: Keyword parameters of :code:`matplotlib.axes.plot`\n\n Returns:\n ... | [
{
"param": "self",
"type": null
},
{
"param": "ax",
"type": null
}
] | {
"returns": [
{
"docstring": "Same as `matplotlib.axes.plot`",
"docstring_tokens": [
"Same",
"as",
"`",
"matplotlib",
".",
"axes",
".",
"plot",
"`"
],
"type": null
}
],
"raises": [],
"params": [
{
... |
9cacd0aab6d3edff99fc414ca919be59978a8862 | julianirwin/hloopy | hloopy/preprocess.py | [
"MIT"
] | Python | crop | <not_specific> | def crop(arr, numcycles, precrop=0, postcrop=0):
"""Crop out some initial and final cycles in data that contains
several cycles.
Args:
arr (numpy.ndarray): Sequence to operate on.
numcycles (int): number of cycles in the total array.
precrop (int): number of cycles to remove from t... | Crop out some initial and final cycles in data that contains
several cycles.
Args:
arr (numpy.ndarray): Sequence to operate on.
numcycles (int): number of cycles in the total array.
precrop (int): number of cycles to remove from the beginning of the
array
... | Crop out some initial and final cycles in data that contains
several cycles. | [
"Crop",
"out",
"some",
"initial",
"and",
"final",
"cycles",
"in",
"data",
"that",
"contains",
"several",
"cycles",
"."
] | def crop(arr, numcycles, precrop=0, postcrop=0):
N = len(arr)
cyclen = N/numcycles
arr = arr[int(precrop * cyclen):]
if postcrop * cyclen > 0:
arr = arr[:int(-postcrop * cyclen)]
return arr | [
"def",
"crop",
"(",
"arr",
",",
"numcycles",
",",
"precrop",
"=",
"0",
",",
"postcrop",
"=",
"0",
")",
":",
"N",
"=",
"len",
"(",
"arr",
")",
"cyclen",
"=",
"N",
"/",
"numcycles",
"arr",
"=",
"arr",
"[",
"int",
"(",
"precrop",
"*",
"cyclen",
")... | Crop out some initial and final cycles in data that contains
several cycles. | [
"Crop",
"out",
"some",
"initial",
"and",
"final",
"cycles",
"in",
"data",
"that",
"contains",
"several",
"cycles",
"."
] | [
"\"\"\"Crop out some initial and final cycles in data that contains\n several cycles.\n\n Args:\n arr (numpy.ndarray): Sequence to operate on.\n numcycles (int): number of cycles in the total array. \n precrop (int): number of cycles to remove from the beginning of the \n ... | [
{
"param": "arr",
"type": null
},
{
"param": "numcycles",
"type": null
},
{
"param": "precrop",
"type": null
},
{
"param": "postcrop",
"type": null
}
] | {
"returns": [
{
"docstring": "The cropped sequence, as an ndarray.",
"docstring_tokens": [
"The",
"cropped",
"sequence",
"as",
"an",
"ndarray",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "a... |
9cacd0aab6d3edff99fc414ca919be59978a8862 | julianirwin/hloopy | hloopy/preprocess.py | [
"MIT"
] | Python | average_cycles | <not_specific> | def average_cycles(arr, numcycles):
"""For cyclical data, split into cyles and then average the cycles
together. This is for data where signal averaging is desired.
Args:
arr (ndarray): Array to be operated on.
numcycles: Number of cycles in the total array. The array must divide
... | For cyclical data, split into cyles and then average the cycles
together. This is for data where signal averaging is desired.
Args:
arr (ndarray): Array to be operated on.
numcycles: Number of cycles in the total array. The array must divide
evenly by this number, otherwise ... | For cyclical data, split into cyles and then average the cycles
together. This is for data where signal averaging is desired. | [
"For",
"cyclical",
"data",
"split",
"into",
"cyles",
"and",
"then",
"average",
"the",
"cycles",
"together",
".",
"This",
"is",
"for",
"data",
"where",
"signal",
"averaging",
"is",
"desired",
"."
] | def average_cycles(arr, numcycles):
N = len(arr)
cyclen = N/numcycles
return arr.reshape(numcycles, cyclen).mean(axis=0) | [
"def",
"average_cycles",
"(",
"arr",
",",
"numcycles",
")",
":",
"N",
"=",
"len",
"(",
"arr",
")",
"cyclen",
"=",
"N",
"/",
"numcycles",
"return",
"arr",
".",
"reshape",
"(",
"numcycles",
",",
"cyclen",
")",
".",
"mean",
"(",
"axis",
"=",
"0",
")"
... | For cyclical data, split into cyles and then average the cycles
together. | [
"For",
"cyclical",
"data",
"split",
"into",
"cyles",
"and",
"then",
"average",
"the",
"cycles",
"together",
"."
] | [
"\"\"\"For cyclical data, split into cyles and then average the cycles \n together. This is for data where signal averaging is desired.\n\n Args:\n arr (ndarray): Array to be operated on.\n numcycles: Number of cycles in the total array. The array must divide\n evenly by this n... | [
{
"param": "arr",
"type": null
},
{
"param": "numcycles",
"type": null
}
] | {
"returns": [
{
"docstring": "The signal averaged ndarray.",
"docstring_tokens": [
"The",
"signal",
"averaged",
"ndarray",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "arr",
"type": null,
"docst... |
9cacd0aab6d3edff99fc414ca919be59978a8862 | julianirwin/hloopy | hloopy/preprocess.py | [
"MIT"
] | Python | average_points | <not_specific> | def average_points(arr, d):
"""Average every `d` points together. This creates a new array so
be careful if using on a large dataset.
Args:
arr (ndarray-like): Array to be operated on.
d (int): Number of points to average together. Must divide array
evenly otherwise unexpe... | Average every `d` points together. This creates a new array so
be careful if using on a large dataset.
Args:
arr (ndarray-like): Array to be operated on.
d (int): Number of points to average together. Must divide array
evenly otherwise unexpected results could occur, or a rais... | Average every `d` points together. This creates a new array so
be careful if using on a large dataset. | [
"Average",
"every",
"`",
"d",
"`",
"points",
"together",
".",
"This",
"creates",
"a",
"new",
"array",
"so",
"be",
"careful",
"if",
"using",
"on",
"a",
"large",
"dataset",
"."
] | def average_points(arr, d):
return np.array(list(arr[i:i+d].mean() for i in range(0, len(arr), d))) | [
"def",
"average_points",
"(",
"arr",
",",
"d",
")",
":",
"return",
"np",
".",
"array",
"(",
"list",
"(",
"arr",
"[",
"i",
":",
"i",
"+",
"d",
"]",
".",
"mean",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"arr",
")",
",",... | Average every `d` points together. | [
"Average",
"every",
"`",
"d",
"`",
"points",
"together",
"."
] | [
"\"\"\"Average every `d` points together. This creates a new array so\n be careful if using on a large dataset.\n\n Args:\n arr (ndarray-like): Array to be operated on.\n d (int): Number of points to average together. Must divide array \n evenly otherwise unexpected results could... | [
{
"param": "arr",
"type": null
},
{
"param": "d",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arr",
"type": null,
"docstring": "Array to be operated on.",
"docstring_tokens": [
"Array",
"to",
"be",
"operated",
"on",
"."
],
"default": null,
"is_optional":... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | _set_properties | null | def _set_properties(self, api_response):
"""Update properties from resource in body of ``api_response``
:type api_response: dict
:param api_response: response returned from an API call
"""
cleaned = api_response.copy()
self._scrub_local_properties(cleaned)
stati... | Update properties from resource in body of ``api_response``
:type api_response: dict
:param api_response: response returned from an API call
| Update properties from resource in body of ``api_response`` | [
"Update",
"properties",
"from",
"resource",
"in",
"body",
"of",
"`",
"`",
"api_response",
"`",
"`"
] | def _set_properties(self, api_response):
cleaned = api_response.copy()
self._scrub_local_properties(cleaned)
statistics = cleaned.get('statistics', {})
if 'creationTime' in statistics:
statistics['creationTime'] = float(statistics['creationTime'])
if 'startTime' in st... | [
"def",
"_set_properties",
"(",
"self",
",",
"api_response",
")",
":",
"cleaned",
"=",
"api_response",
".",
"copy",
"(",
")",
"self",
".",
"_scrub_local_properties",
"(",
"cleaned",
")",
"statistics",
"=",
"cleaned",
".",
"get",
"(",
"'statistics'",
",",
"{",... | Update properties from resource in body of ``api_response`` | [
"Update",
"properties",
"from",
"resource",
"in",
"body",
"of",
"`",
"`",
"api_response",
"`",
"`"
] | [
"\"\"\"Update properties from resource in body of ``api_response``\n\n :type api_response: dict\n :param api_response: response returned from an API call\n \"\"\"",
"# For Future interface"
] | [
{
"param": "self",
"type": null
},
{
"param": "api_response",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "api_response",
"type": null,
"docstring": "response returned from a... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | reload | null | def reload(self, client=None, retry=DEFAULT_RETRY):
"""API call: refresh job properties via a GET request.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get
:type client: :class:`~google.cloud.bigquery.client.Client` or
``NoneType``
:p... | API call: refresh job properties via a GET request.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get
:type client: :class:`~google.cloud.bigquery.client.Client` or
``NoneType``
:param client: the client to use. If not passed, falls back to t... | API call: refresh job properties via a GET request. | [
"API",
"call",
":",
"refresh",
"job",
"properties",
"via",
"a",
"GET",
"request",
"."
] | def reload(self, client=None, retry=DEFAULT_RETRY):
client = self._require_client(client)
api_response = client._call_api(retry, method='GET', path=self.path)
self._set_properties(api_response) | [
"def",
"reload",
"(",
"self",
",",
"client",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"client",
"=",
"self",
".",
"_require_client",
"(",
"client",
")",
"api_response",
"=",
"client",
".",
"_call_api",
"(",
"retry",
",",
"method",
"=",
... | API call: refresh job properties via a GET request. | [
"API",
"call",
":",
"refresh",
"job",
"properties",
"via",
"a",
"GET",
"request",
"."
] | [
"\"\"\"API call: refresh job properties via a GET request.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get\n\n :type client: :class:`~google.cloud.bigquery.client.Client` or\n ``NoneType``\n :param client: the client to use. If not passe... | [
{
"param": "self",
"type": null
},
{
"param": "client",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "client",
"type": null,
"docstring": "the client to use. If not pas... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | to_api_repr | <not_specific> | def to_api_repr(self):
"""Build an API representation of the load job config.
:rtype: dict
:returns: A dictionary in the format used by the BigQuery API.
"""
config = copy.deepcopy(self._properties)
if len(self.schema) > 0:
config['schema'] = {'fields': _buil... | Build an API representation of the load job config.
:rtype: dict
:returns: A dictionary in the format used by the BigQuery API.
| Build an API representation of the load job config. | [
"Build",
"an",
"API",
"representation",
"of",
"the",
"load",
"job",
"config",
"."
] | def to_api_repr(self):
config = copy.deepcopy(self._properties)
if len(self.schema) > 0:
config['schema'] = {'fields': _build_schema_resource(self.schema)}
slr = config.get('skipLeadingRows')
if slr is not None:
config['skipLeadingRows'] = str(slr)
return ... | [
"def",
"to_api_repr",
"(",
"self",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"_properties",
")",
"if",
"len",
"(",
"self",
".",
"schema",
")",
">",
"0",
":",
"config",
"[",
"'schema'",
"]",
"=",
"{",
"'fields'",
":",
"_bui... | Build an API representation of the load job config. | [
"Build",
"an",
"API",
"representation",
"of",
"the",
"load",
"job",
"config",
"."
] | [
"\"\"\"Build an API representation of the load job config.\n\n :rtype: dict\n :returns: A dictionary in the format used by the BigQuery API.\n \"\"\"",
"# skipLeadingRows is a string because it's defined as an int64, which",
"# can't be represented as a JSON number."
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "A dictionary in the format used by the BigQuery API.",
"docstring_tokens": [
"A",
"dictionary",
"in",
"the",
"format",
"used",
"by",
"the",
"BigQuery",
"API",
"."
],
"type... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | from_api_repr | null | def from_api_repr(cls, resource):
"""Factory: construct a job configuration given its API representation
:type resource: dict
:param resource:
An extract job configuration in the same representation as is
returned from the API.
:rtype: :class:`google.cloud.bigqu... | Factory: construct a job configuration given its API representation
:type resource: dict
:param resource:
An extract job configuration in the same representation as is
returned from the API.
:rtype: :class:`google.cloud.bigquery.job.LoadJobConfig`
:returns: Conf... | construct a job configuration given its API representation | [
"construct",
"a",
"job",
"configuration",
"given",
"its",
"API",
"representation"
] | def from_api_repr(cls, resource):
schema = resource.pop('schema', {'fields': ()})
slr = resource.pop('skipLeadingRows', None)
config = cls()
config._properties = copy.deepcopy(resource)
config.schema = _parse_schema_resource(schema)
config.skip_leading_rows = _int_or_none... | [
"def",
"from_api_repr",
"(",
"cls",
",",
"resource",
")",
":",
"schema",
"=",
"resource",
".",
"pop",
"(",
"'schema'",
",",
"{",
"'fields'",
":",
"(",
")",
"}",
")",
"slr",
"=",
"resource",
".",
"pop",
"(",
"'skipLeadingRows'",
",",
"None",
")",
"con... | Factory: construct a job configuration given its API representation | [
"Factory",
":",
"construct",
"a",
"job",
"configuration",
"given",
"its",
"API",
"representation"
] | [
"\"\"\"Factory: construct a job configuration given its API representation\n\n :type resource: dict\n :param resource:\n An extract job configuration in the same representation as is\n returned from the API.\n\n :rtype: :class:`google.cloud.bigquery.job.LoadJobConfig`\n ... | [
{
"param": "cls",
"type": null
},
{
"param": "resource",
"type": null
}
] | {
"returns": [
{
"docstring": "Configuration parsed from ``resource``.",
"docstring_tokens": [
"Configuration",
"parsed",
"from",
"`",
"`",
"resource",
"`",
"`",
"."
],
"type": ":class:`google.cloud.bigquery.job.LoadJo... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | from_api_repr | <not_specific> | def from_api_repr(cls, resource, client):
"""Factory: construct a job given its API representation
.. note:
This method assumes that the project found in the resource matches
the client's project.
:type resource: dict
:param resource: dataset job representation ... | Factory: construct a job given its API representation
.. note:
This method assumes that the project found in the resource matches
the client's project.
:type resource: dict
:param resource: dataset job representation returned from the API
:type client: :class:`... | construct a job given its API representation
note.
This method assumes that the project found in the resource matches
the client's project. | [
"construct",
"a",
"job",
"given",
"its",
"API",
"representation",
"note",
".",
"This",
"method",
"assumes",
"that",
"the",
"project",
"found",
"in",
"the",
"resource",
"matches",
"the",
"client",
"'",
"s",
"project",
"."
] | def from_api_repr(cls, resource, client):
job_id, config_resource = cls._get_resource_config(resource)
config = LoadJobConfig.from_api_repr(config_resource)
dest_config = config_resource['destinationTable']
ds_ref = DatasetReference(dest_config['projectId'],
... | [
"def",
"from_api_repr",
"(",
"cls",
",",
"resource",
",",
"client",
")",
":",
"job_id",
",",
"config_resource",
"=",
"cls",
".",
"_get_resource_config",
"(",
"resource",
")",
"config",
"=",
"LoadJobConfig",
".",
"from_api_repr",
"(",
"config_resource",
")",
"d... | Factory: construct a job given its API representation
.. note: | [
"Factory",
":",
"construct",
"a",
"job",
"given",
"its",
"API",
"representation",
"..",
"note",
":"
] | [
"\"\"\"Factory: construct a job given its API representation\n\n .. note:\n\n This method assumes that the project found in the resource matches\n the client's project.\n\n :type resource: dict\n :param resource: dataset job representation returned from the API\n\n :... | [
{
"param": "cls",
"type": null
},
{
"param": "resource",
"type": null
},
{
"param": "client",
"type": null
}
] | {
"returns": [
{
"docstring": "Job parsed from ``resource``.",
"docstring_tokens": [
"Job",
"parsed",
"from",
"`",
"`",
"resource",
"`",
"`",
"."
],
"type": ":class:`google.cloud.bigquery.job.LoadJob`"
}
],
"ra... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | from_api_repr | <not_specific> | def from_api_repr(cls, resource, client):
"""Factory: construct a job given its API representation
.. note:
This method assumes that the project found in the resource matches
the client's project.
:type resource: dict
:param resource: dataset job representation ... | Factory: construct a job given its API representation
.. note:
This method assumes that the project found in the resource matches
the client's project.
:type resource: dict
:param resource: dataset job representation returned from the API
:type client: :class:`... | construct a job given its API representation
note.
This method assumes that the project found in the resource matches
the client's project. | [
"construct",
"a",
"job",
"given",
"its",
"API",
"representation",
"note",
".",
"This",
"method",
"assumes",
"that",
"the",
"project",
"found",
"in",
"the",
"resource",
"matches",
"the",
"client",
"'",
"s",
"project",
"."
] | def from_api_repr(cls, resource, client):
job_id, config_resource = cls._get_resource_config(resource)
config = CopyJobConfig.from_api_repr(config_resource)
destination = TableReference.from_api_repr(
config_resource['destinationTable'])
sources = []
source_configs = ... | [
"def",
"from_api_repr",
"(",
"cls",
",",
"resource",
",",
"client",
")",
":",
"job_id",
",",
"config_resource",
"=",
"cls",
".",
"_get_resource_config",
"(",
"resource",
")",
"config",
"=",
"CopyJobConfig",
".",
"from_api_repr",
"(",
"config_resource",
")",
"d... | Factory: construct a job given its API representation
.. note: | [
"Factory",
":",
"construct",
"a",
"job",
"given",
"its",
"API",
"representation",
"..",
"note",
":"
] | [
"\"\"\"Factory: construct a job given its API representation\n\n .. note:\n\n This method assumes that the project found in the resource matches\n the client's project.\n\n :type resource: dict\n :param resource: dataset job representation returned from the API\n\n :... | [
{
"param": "cls",
"type": null
},
{
"param": "resource",
"type": null
},
{
"param": "client",
"type": null
}
] | {
"returns": [
{
"docstring": "Job parsed from ``resource``.",
"docstring_tokens": [
"Job",
"parsed",
"from",
"`",
"`",
"resource",
"`",
"`",
"."
],
"type": ":class:`google.cloud.bigquery.job.CopyJob`"
}
],
"ra... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | from_api_repr | <not_specific> | def from_api_repr(cls, resource, client):
"""Factory: construct a job given its API representation
.. note:
This method assumes that the project found in the resource matches
the client's project.
:type resource: dict
:param resource: dataset job representation ... | Factory: construct a job given its API representation
.. note:
This method assumes that the project found in the resource matches
the client's project.
:type resource: dict
:param resource: dataset job representation returned from the API
:type client: :class:`... | construct a job given its API representation
note.
This method assumes that the project found in the resource matches
the client's project. | [
"construct",
"a",
"job",
"given",
"its",
"API",
"representation",
"note",
".",
"This",
"method",
"assumes",
"that",
"the",
"project",
"found",
"in",
"the",
"resource",
"matches",
"the",
"client",
"'",
"s",
"project",
"."
] | def from_api_repr(cls, resource, client):
job_id, config_resource = cls._get_resource_config(resource)
config = ExtractJobConfig.from_api_repr(config_resource)
source_config = config_resource['sourceTable']
dataset = DatasetReference(
source_config['projectId'], source_config... | [
"def",
"from_api_repr",
"(",
"cls",
",",
"resource",
",",
"client",
")",
":",
"job_id",
",",
"config_resource",
"=",
"cls",
".",
"_get_resource_config",
"(",
"resource",
")",
"config",
"=",
"ExtractJobConfig",
".",
"from_api_repr",
"(",
"config_resource",
")",
... | Factory: construct a job given its API representation
.. note: | [
"Factory",
":",
"construct",
"a",
"job",
"given",
"its",
"API",
"representation",
"..",
"note",
":"
] | [
"\"\"\"Factory: construct a job given its API representation\n\n .. note:\n\n This method assumes that the project found in the resource matches\n the client's project.\n\n :type resource: dict\n :param resource: dataset job representation returned from the API\n\n :... | [
{
"param": "cls",
"type": null
},
{
"param": "resource",
"type": null
},
{
"param": "client",
"type": null
}
] | {
"returns": [
{
"docstring": "Job parsed from ``resource``.",
"docstring_tokens": [
"Job",
"parsed",
"from",
"`",
"`",
"resource",
"`",
"`",
"."
],
"type": ":class:`google.cloud.bigquery.job.ExtractJob`"
}
],
... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | to_api_repr | <not_specific> | def to_api_repr(self):
"""Build an API representation of the copy job config.
:rtype: dict
:returns: A dictionary in the format used by the BigQuery API.
"""
resource = copy.deepcopy(self._properties)
# Query parameters have an addition property associated with them
... | Build an API representation of the copy job config.
:rtype: dict
:returns: A dictionary in the format used by the BigQuery API.
| Build an API representation of the copy job config. | [
"Build",
"an",
"API",
"representation",
"of",
"the",
"copy",
"job",
"config",
"."
] | def to_api_repr(self):
resource = copy.deepcopy(self._properties)
query_parameters = resource.get(self._QUERY_PARAMETERS_KEY)
if query_parameters:
if query_parameters[0].name is None:
resource['parameterMode'] = 'POSITIONAL'
else:
resource[... | [
"def",
"to_api_repr",
"(",
"self",
")",
":",
"resource",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"_properties",
")",
"query_parameters",
"=",
"resource",
".",
"get",
"(",
"self",
".",
"_QUERY_PARAMETERS_KEY",
")",
"if",
"query_parameters",
":",
"if",... | Build an API representation of the copy job config. | [
"Build",
"an",
"API",
"representation",
"of",
"the",
"copy",
"job",
"config",
"."
] | [
"\"\"\"Build an API representation of the copy job config.\n\n :rtype: dict\n :returns: A dictionary in the format used by the BigQuery API.\n \"\"\"",
"# Query parameters have an addition property associated with them",
"# to indicate if the query is using named or positional parameters."
... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "A dictionary in the format used by the BigQuery API.",
"docstring_tokens": [
"A",
"dictionary",
"in",
"the",
"format",
"used",
"by",
"the",
"BigQuery",
"API",
"."
],
"type... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | from_api_repr | <not_specific> | def from_api_repr(cls, resource):
"""Factory: construct a job configuration given its API representation
:type resource: dict
:param resource:
An extract job configuration in the same representation as is
returned from the API.
:rtype: :class:`google.cloud.bigqu... | Factory: construct a job configuration given its API representation
:type resource: dict
:param resource:
An extract job configuration in the same representation as is
returned from the API.
:rtype: :class:`google.cloud.bigquery.job.QueryJobConfig`
:returns: Con... | construct a job configuration given its API representation | [
"construct",
"a",
"job",
"configuration",
"given",
"its",
"API",
"representation"
] | def from_api_repr(cls, resource):
config = cls()
config._properties = copy.deepcopy(resource)
for prop, convert in cls._NESTED_PROPERTIES.items():
from_resource, _ = convert
nested_resource = resource.get(prop)
if nested_resource is not None:
c... | [
"def",
"from_api_repr",
"(",
"cls",
",",
"resource",
")",
":",
"config",
"=",
"cls",
"(",
")",
"config",
".",
"_properties",
"=",
"copy",
".",
"deepcopy",
"(",
"resource",
")",
"for",
"prop",
",",
"convert",
"in",
"cls",
".",
"_NESTED_PROPERTIES",
".",
... | Factory: construct a job configuration given its API representation | [
"Factory",
":",
"construct",
"a",
"job",
"configuration",
"given",
"its",
"API",
"representation"
] | [
"\"\"\"Factory: construct a job configuration given its API representation\n\n :type resource: dict\n :param resource:\n An extract job configuration in the same representation as is\n returned from the API.\n\n :rtype: :class:`google.cloud.bigquery.job.QueryJobConfig`\n ... | [
{
"param": "cls",
"type": null
},
{
"param": "resource",
"type": null
}
] | {
"returns": [
{
"docstring": "Configuration parsed from ``resource``.",
"docstring_tokens": [
"Configuration",
"parsed",
"from",
"`",
"`",
"resource",
"`",
"`",
"."
],
"type": ":class:`google.cloud.bigquery.job.QueryJ... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | _scrub_local_properties | null | def _scrub_local_properties(self, cleaned):
"""Helper: handle subclass properties in cleaned.
.. note:
This method assumes that the project found in the resource matches
the client's project.
"""
configuration = cleaned['configuration']['query']
self.quer... | Helper: handle subclass properties in cleaned.
.. note:
This method assumes that the project found in the resource matches
the client's project.
| handle subclass properties in cleaned.
note.
This method assumes that the project found in the resource matches
the client's project. | [
"handle",
"subclass",
"properties",
"in",
"cleaned",
".",
"note",
".",
"This",
"method",
"assumes",
"that",
"the",
"project",
"found",
"in",
"the",
"resource",
"matches",
"the",
"client",
"'",
"s",
"project",
"."
] | def _scrub_local_properties(self, cleaned):
configuration = cleaned['configuration']['query']
self.query = configuration['query']
self._configuration.dry_run = cleaned['configuration'].get('dryRun') | [
"def",
"_scrub_local_properties",
"(",
"self",
",",
"cleaned",
")",
":",
"configuration",
"=",
"cleaned",
"[",
"'configuration'",
"]",
"[",
"'query'",
"]",
"self",
".",
"query",
"=",
"configuration",
"[",
"'query'",
"]",
"self",
".",
"_configuration",
".",
"... | Helper: handle subclass properties in cleaned. | [
"Helper",
":",
"handle",
"subclass",
"properties",
"in",
"cleaned",
"."
] | [
"\"\"\"Helper: handle subclass properties in cleaned.\n\n .. note:\n\n This method assumes that the project found in the resource matches\n the client's project.\n \"\"\"",
"# The dryRun property only applies to query jobs, but it is defined at",
"# a level higher up. We need ... | [
{
"param": "self",
"type": null
},
{
"param": "cleaned",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cleaned",
"type": null,
"docstring": null,
"docstring_tokens"... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | _copy_configuration_properties | null | def _copy_configuration_properties(self, configuration):
"""Helper: assign subclass configuration properties in cleaned."""
# The dryRun property only applies to query jobs, but it is defined at
# a level higher up. We need to copy it to the query config.
# It should already be correctl... | Helper: assign subclass configuration properties in cleaned. | assign subclass configuration properties in cleaned. | [
"assign",
"subclass",
"configuration",
"properties",
"in",
"cleaned",
"."
] | def _copy_configuration_properties(self, configuration):
dry_run = self.dry_run
self._configuration = QueryJobConfig.from_api_repr(configuration)
self._configuration.dry_run = dry_run | [
"def",
"_copy_configuration_properties",
"(",
"self",
",",
"configuration",
")",
":",
"dry_run",
"=",
"self",
".",
"dry_run",
"self",
".",
"_configuration",
"=",
"QueryJobConfig",
".",
"from_api_repr",
"(",
"configuration",
")",
"self",
".",
"_configuration",
".",... | Helper: assign subclass configuration properties in cleaned. | [
"Helper",
":",
"assign",
"subclass",
"configuration",
"properties",
"in",
"cleaned",
"."
] | [
"\"\"\"Helper: assign subclass configuration properties in cleaned.\"\"\"",
"# The dryRun property only applies to query jobs, but it is defined at",
"# a level higher up. We need to copy it to the query config.",
"# It should already be correctly set by the _scrub_local_properties()",
"# method."
] | [
{
"param": "self",
"type": null
},
{
"param": "configuration",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "configuration",
"type": null,
"docstring": null,
"docstring_t... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | from_api_repr | <not_specific> | def from_api_repr(cls, resource, client):
"""Factory: construct a job given its API representation
:type resource: dict
:param resource: dataset job representation returned from the API
:type client: :class:`google.cloud.bigquery.client.Client`
:param client: Client which hold... | Factory: construct a job given its API representation
:type resource: dict
:param resource: dataset job representation returned from the API
:type client: :class:`google.cloud.bigquery.client.Client`
:param client: Client which holds credentials and project
conf... | construct a job given its API representation | [
"construct",
"a",
"job",
"given",
"its",
"API",
"representation"
] | def from_api_repr(cls, resource, client):
job_id, config = cls._get_resource_config(resource)
query = config['query']
job = cls(job_id, query, client=client)
job._set_properties(resource)
return job | [
"def",
"from_api_repr",
"(",
"cls",
",",
"resource",
",",
"client",
")",
":",
"job_id",
",",
"config",
"=",
"cls",
".",
"_get_resource_config",
"(",
"resource",
")",
"query",
"=",
"config",
"[",
"'query'",
"]",
"job",
"=",
"cls",
"(",
"job_id",
",",
"q... | Factory: construct a job given its API representation | [
"Factory",
":",
"construct",
"a",
"job",
"given",
"its",
"API",
"representation"
] | [
"\"\"\"Factory: construct a job given its API representation\n\n :type resource: dict\n :param resource: dataset job representation returned from the API\n\n :type client: :class:`google.cloud.bigquery.client.Client`\n :param client: Client which holds credentials and project\n ... | [
{
"param": "cls",
"type": null
},
{
"param": "resource",
"type": null
},
{
"param": "client",
"type": null
}
] | {
"returns": [
{
"docstring": "Job parsed from ``resource``.",
"docstring_tokens": [
"Job",
"parsed",
"from",
"`",
"`",
"resource",
"`",
"`",
"."
],
"type": ":class:`google.cloud.bigquery.job.QueryJob`"
}
],
"r... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | undeclared_query_paramters | <not_specific> | def undeclared_query_paramters(self):
"""Return undeclared query parameters from job statistics, if present.
See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.undeclaredQueryParamters
:rtype:
list of
:class:`~google.cloud.bigque... | Return undeclared query parameters from job statistics, if present.
See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.undeclaredQueryParamters
:rtype:
list of
:class:`~google.cloud.bigquery.ArrayQueryParameter`,
:class:`~goo... | Return undeclared query parameters from job statistics, if present. | [
"Return",
"undeclared",
"query",
"parameters",
"from",
"job",
"statistics",
"if",
"present",
"."
] | def undeclared_query_paramters(self):
parameters = []
undeclared = self._job_statistics().get('undeclaredQueryParamters', ())
for parameter in undeclared:
p_type = parameter['parameterType']
if 'arrayType' in p_type:
klass = ArrayQueryParameter
... | [
"def",
"undeclared_query_paramters",
"(",
"self",
")",
":",
"parameters",
"=",
"[",
"]",
"undeclared",
"=",
"self",
".",
"_job_statistics",
"(",
")",
".",
"get",
"(",
"'undeclaredQueryParamters'",
",",
"(",
")",
")",
"for",
"parameter",
"in",
"undeclared",
"... | Return undeclared query parameters from job statistics, if present. | [
"Return",
"undeclared",
"query",
"parameters",
"from",
"job",
"statistics",
"if",
"present",
"."
] | [
"\"\"\"Return undeclared query parameters from job statistics, if present.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.undeclaredQueryParamters\n\n :rtype:\n list of\n :class:`~google.cloud.bigquery.ArrayQueryParameter`,\n ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "undeclared parameters, or an empty list if the query has\nnot yet completed.",
"docstring_tokens": [
"undeclared",
"parameters",
"or",
"an",
"empty",
"list",
"if",
"the",
"query",
"has",
... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | query_results | <not_specific> | def query_results(self, retry=DEFAULT_RETRY):
"""Construct a QueryResults instance, bound to this job.
:type retry: :class:`google.api_core.retry.Retry`
:param retry: (Optional) How to retry the RPC.
:rtype: :class:`~google.cloud.bigquery.QueryResults`
:returns: results instanc... | Construct a QueryResults instance, bound to this job.
:type retry: :class:`google.api_core.retry.Retry`
:param retry: (Optional) How to retry the RPC.
:rtype: :class:`~google.cloud.bigquery.QueryResults`
:returns: results instance
| Construct a QueryResults instance, bound to this job. | [
"Construct",
"a",
"QueryResults",
"instance",
"bound",
"to",
"this",
"job",
"."
] | def query_results(self, retry=DEFAULT_RETRY):
if not self._query_results:
self._query_results = self._client._get_query_results(
self.job_id, retry, project=self.project)
return self._query_results | [
"def",
"query_results",
"(",
"self",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"if",
"not",
"self",
".",
"_query_results",
":",
"self",
".",
"_query_results",
"=",
"self",
".",
"_client",
".",
"_get_query_results",
"(",
"self",
".",
"job_id",
",",
"ret... | Construct a QueryResults instance, bound to this job. | [
"Construct",
"a",
"QueryResults",
"instance",
"bound",
"to",
"this",
"job",
"."
] | [
"\"\"\"Construct a QueryResults instance, bound to this job.\n\n :type retry: :class:`google.api_core.retry.Retry`\n :param retry: (Optional) How to retry the RPC.\n\n :rtype: :class:`~google.cloud.bigquery.QueryResults`\n :returns: results instance\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": ":class:`~google.cloud.bigquery.QueryResults`"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"de... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | done | <not_specific> | def done(self, retry=DEFAULT_RETRY):
"""Refresh the job and checks if it is complete.
:rtype: bool
:returns: True if the job is complete, False otherwise.
"""
# Since the API to getQueryResults can hang up to the timeout value
# (default of 10 seconds), set the timeout p... | Refresh the job and checks if it is complete.
:rtype: bool
:returns: True if the job is complete, False otherwise.
| Refresh the job and checks if it is complete. | [
"Refresh",
"the",
"job",
"and",
"checks",
"if",
"it",
"is",
"complete",
"."
] | def done(self, retry=DEFAULT_RETRY):
timeout_ms = None
if self._done_timeout is not None:
timeout = self._done_timeout - _TIMEOUT_BUFFER_SECS
timeout = max(min(timeout, 10), 0)
self._done_timeout -= timeout
self._done_timeout = max(0, self._done_timeout)
... | [
"def",
"done",
"(",
"self",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"timeout_ms",
"=",
"None",
"if",
"self",
".",
"_done_timeout",
"is",
"not",
"None",
":",
"timeout",
"=",
"self",
".",
"_done_timeout",
"-",
"_TIMEOUT_BUFFER_SECS",
"timeout",
"=",
"m... | Refresh the job and checks if it is complete. | [
"Refresh",
"the",
"job",
"and",
"checks",
"if",
"it",
"is",
"complete",
"."
] | [
"\"\"\"Refresh the job and checks if it is complete.\n\n :rtype: bool\n :returns: True if the job is complete, False otherwise.\n \"\"\"",
"# Since the API to getQueryResults can hang up to the timeout value",
"# (default of 10 seconds), set the timeout parameter to ensure that",
"# the t... | [
{
"param": "self",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": "True if the job is complete, False otherwise.",
"docstring_tokens": [
"True",
"if",
"the",
"job",
"is",
"complete",
"False",
"otherwise",
"."
],
"type": "bool"
}
],
"raises": [],
... |
1ecf35cd4d0436ae82faf15dbef3c2b639f5e31b | zero-master/bigquery | google/cloud/bigquery/job.py | [
"Apache-2.0"
] | Python | result | <not_specific> | def result(self, timeout=None, retry=DEFAULT_RETRY):
"""Start the job and wait for it to complete and get the result.
:type timeout: float
:param timeout:
How long (in seconds) to wait for job to complete before raising
a :class:`concurrent.futures.TimeoutError`.
... | Start the job and wait for it to complete and get the result.
:type timeout: float
:param timeout:
How long (in seconds) to wait for job to complete before raising
a :class:`concurrent.futures.TimeoutError`.
:type retry: :class:`google.api_core.retry.Retry`
:par... | Start the job and wait for it to complete and get the result. | [
"Start",
"the",
"job",
"and",
"wait",
"for",
"it",
"to",
"complete",
"and",
"get",
"the",
"result",
"."
] | def result(self, timeout=None, retry=DEFAULT_RETRY):
super(QueryJob, self).result(timeout=timeout)
schema = self.query_results().schema
dest_table = self.destination
return self._client.list_rows(dest_table, selected_fields=schema,
retry=retry) | [
"def",
"result",
"(",
"self",
",",
"timeout",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"super",
"(",
"QueryJob",
",",
"self",
")",
".",
"result",
"(",
"timeout",
"=",
"timeout",
")",
"schema",
"=",
"self",
".",
"query_results",
"(",
... | Start the job and wait for it to complete and get the result. | [
"Start",
"the",
"job",
"and",
"wait",
"for",
"it",
"to",
"complete",
"and",
"get",
"the",
"result",
"."
] | [
"\"\"\"Start the job and wait for it to complete and get the result.\n\n :type timeout: float\n :param timeout:\n How long (in seconds) to wait for job to complete before raising\n a :class:`concurrent.futures.TimeoutError`.\n\n :type retry: :class:`google.api_core.retry.R... | [
{
"param": "self",
"type": null
},
{
"param": "timeout",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": "Iterator of row data :class:`tuple`s. During each page, the\niterator will have the ``total_rows`` attribute set, which counts\nthe total number of rows **in the result set** (this is distinct\nfrom the total number of rows in the current page:\n``iterator.page.num_items``).",... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | list_projects | <not_specific> | def list_projects(self, max_results=None, page_token=None,
retry=DEFAULT_RETRY):
"""List projects for the project associated with this client.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/projects/list
:type max_results: int
:param max_resu... | List projects for the project associated with this client.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/projects/list
:type max_results: int
:param max_results: maximum number of projects to return, If not
passed, defaults to a value set by t... | List projects for the project associated with this client. | [
"List",
"projects",
"for",
"the",
"project",
"associated",
"with",
"this",
"client",
"."
] | def list_projects(self, max_results=None, page_token=None,
retry=DEFAULT_RETRY):
return page_iterator.HTTPIterator(
client=self,
api_request=functools.partial(self._call_api, retry),
path='/projects',
item_to_value=_item_to_project,
... | [
"def",
"list_projects",
"(",
"self",
",",
"max_results",
"=",
"None",
",",
"page_token",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"return",
"page_iterator",
".",
"HTTPIterator",
"(",
"client",
"=",
"self",
",",
"api_request",
"=",
"functool... | List projects for the project associated with this client. | [
"List",
"projects",
"for",
"the",
"project",
"associated",
"with",
"this",
"client",
"."
] | [
"\"\"\"List projects for the project associated with this client.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/projects/list\n\n :type max_results: int\n :param max_results: maximum number of projects to return, If not\n passed, defaults t... | [
{
"param": "self",
"type": null
},
{
"param": "max_results",
"type": null
},
{
"param": "page_token",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": "Iterator of :class:`~google.cloud.bigquery.client.Project`\naccessible to the current client.",
"docstring_tokens": [
"Iterator",
"of",
":",
"class",
":",
"`",
"~google",
".",
"cloud",
".",
... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | list_datasets | <not_specific> | def list_datasets(self, include_all=False, filter=None, max_results=None,
page_token=None, retry=DEFAULT_RETRY):
"""List datasets for the project associated with this client.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/list
:type include_... | List datasets for the project associated with this client.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/list
:type include_all: bool
:param include_all: True if results include hidden datasets.
:type filter: str
:param filter: an expression for... | List datasets for the project associated with this client. | [
"List",
"datasets",
"for",
"the",
"project",
"associated",
"with",
"this",
"client",
"."
] | def list_datasets(self, include_all=False, filter=None, max_results=None,
page_token=None, retry=DEFAULT_RETRY):
extra_params = {}
if include_all:
extra_params['all'] = True
if filter:
extra_params['filter'] = filter
path = '/projects/%s/data... | [
"def",
"list_datasets",
"(",
"self",
",",
"include_all",
"=",
"False",
",",
"filter",
"=",
"None",
",",
"max_results",
"=",
"None",
",",
"page_token",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"extra_params",
"=",
"{",
"}",
"if",
"includ... | List datasets for the project associated with this client. | [
"List",
"datasets",
"for",
"the",
"project",
"associated",
"with",
"this",
"client",
"."
] | [
"\"\"\"List datasets for the project associated with this client.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/list\n\n :type include_all: bool\n :param include_all: True if results include hidden datasets.\n\n :type filter: str\n :param filte... | [
{
"param": "self",
"type": null
},
{
"param": "include_all",
"type": null
},
{
"param": "filter",
"type": null
},
{
"param": "max_results",
"type": null
},
{
"param": "page_token",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": "Iterator of :class:`~google.cloud.bigquery.dataset.Dataset`.\naccessible to the current client.",
"docstring_tokens": [
"Iterator",
"of",
":",
"class",
":",
"`",
"~google",
".",
"cloud",
".",... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | dataset | <not_specific> | def dataset(self, dataset_id, project=None):
"""Construct a reference to a dataset.
:type dataset_id: str
:param dataset_id: ID of the dataset.
:type project: str
:param project: (Optional) project ID for the dataset (defaults to
the project of the clien... | Construct a reference to a dataset.
:type dataset_id: str
:param dataset_id: ID of the dataset.
:type project: str
:param project: (Optional) project ID for the dataset (defaults to
the project of the client).
:rtype: :class:`google.cloud.bigquery.datas... | Construct a reference to a dataset. | [
"Construct",
"a",
"reference",
"to",
"a",
"dataset",
"."
] | def dataset(self, dataset_id, project=None):
if project is None:
project = self.project
return DatasetReference(project, dataset_id) | [
"def",
"dataset",
"(",
"self",
",",
"dataset_id",
",",
"project",
"=",
"None",
")",
":",
"if",
"project",
"is",
"None",
":",
"project",
"=",
"self",
".",
"project",
"return",
"DatasetReference",
"(",
"project",
",",
"dataset_id",
")"
] | Construct a reference to a dataset. | [
"Construct",
"a",
"reference",
"to",
"a",
"dataset",
"."
] | [
"\"\"\"Construct a reference to a dataset.\n\n :type dataset_id: str\n :param dataset_id: ID of the dataset.\n\n :type project: str\n :param project: (Optional) project ID for the dataset (defaults to\n the project of the client).\n\n :rtype: :class:`google.... | [
{
"param": "self",
"type": null
},
{
"param": "dataset_id",
"type": null
},
{
"param": "project",
"type": null
}
] | {
"returns": [
{
"docstring": "a new ``DatasetReference`` instance",
"docstring_tokens": [
"a",
"new",
"`",
"`",
"DatasetReference",
"`",
"`",
"instance"
],
"type": ":class:`google.cloud.bigquery.dataset.DatasetReference`"
... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | create_dataset | <not_specific> | def create_dataset(self, dataset):
"""API call: create the dataset via a PUT request.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/insert
:type dataset: :class:`~google.cloud.bigquery.dataset.Dataset`
:param dataset: A ``Dataset`` populated with the desi... | API call: create the dataset via a PUT request.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/insert
:type dataset: :class:`~google.cloud.bigquery.dataset.Dataset`
:param dataset: A ``Dataset`` populated with the desired initial state.
If ... | API call: create the dataset via a PUT request. | [
"API",
"call",
":",
"create",
"the",
"dataset",
"via",
"a",
"PUT",
"request",
"."
] | def create_dataset(self, dataset):
path = '/projects/%s/datasets' % (dataset.project,)
api_response = self._connection.api_request(
method='POST', path=path, data=dataset._build_resource())
return Dataset.from_api_repr(api_response) | [
"def",
"create_dataset",
"(",
"self",
",",
"dataset",
")",
":",
"path",
"=",
"'/projects/%s/datasets'",
"%",
"(",
"dataset",
".",
"project",
",",
")",
"api_response",
"=",
"self",
".",
"_connection",
".",
"api_request",
"(",
"method",
"=",
"'POST'",
",",
"... | API call: create the dataset via a PUT request. | [
"API",
"call",
":",
"create",
"the",
"dataset",
"via",
"a",
"PUT",
"request",
"."
] | [
"\"\"\"API call: create the dataset via a PUT request.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/insert\n\n :type dataset: :class:`~google.cloud.bigquery.dataset.Dataset`\n :param dataset: A ``Dataset`` populated with the desired initial state.\n ... | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
}
] | {
"returns": [
{
"docstring": "a new ``Dataset`` returned from the service.",
"docstring_tokens": [
"a",
"new",
"`",
"`",
"Dataset",
"`",
"`",
"returned",
"from",
"the",
"service",
"."
],
"type"... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | list_dataset_tables | <not_specific> | def list_dataset_tables(self, dataset, max_results=None, page_token=None,
retry=DEFAULT_RETRY):
"""List tables in the dataset.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/list
:type dataset: One of:
:class:`~goo... | List tables in the dataset.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/list
:type dataset: One of:
:class:`~google.cloud.bigquery.dataset.Dataset`
:class:`~google.cloud.bigquery.dataset.DatasetReference`
:param data... | List tables in the dataset. | [
"List",
"tables",
"in",
"the",
"dataset",
"."
] | def list_dataset_tables(self, dataset, max_results=None, page_token=None,
retry=DEFAULT_RETRY):
if not isinstance(dataset, (Dataset, DatasetReference)):
raise TypeError('dataset must be a Dataset or a DatasetReference')
path = '%s/tables' % dataset.path
re... | [
"def",
"list_dataset_tables",
"(",
"self",
",",
"dataset",
",",
"max_results",
"=",
"None",
",",
"page_token",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"if",
"not",
"isinstance",
"(",
"dataset",
",",
"(",
"Dataset",
",",
"DatasetReference",... | List tables in the dataset. | [
"List",
"tables",
"in",
"the",
"dataset",
"."
] | [
"\"\"\"List tables in the dataset.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/list\n\n :type dataset: One of:\n :class:`~google.cloud.bigquery.dataset.Dataset`\n :class:`~google.cloud.bigquery.dataset.DatasetReference`\n... | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "max_results",
"type": null
},
{
"param": "page_token",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": "Iterator of :class:`~google.cloud.bigquery.table.Table`\ncontained within the current dataset.",
"docstring_tokens": [
"Iterator",
"of",
":",
"class",
":",
"`",
"~google",
".",
"cloud",
".",
... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | _get_query_results | <not_specific> | def _get_query_results(self, job_id, retry, project=None, timeout_ms=None):
"""Get the query results object for a query job.
:type job_id: str
:param job_id: Name of the query job.
:type retry: :class:`google.api_core.retry.Retry`
:param retry: (Optional) How to retry the RPC.
... | Get the query results object for a query job.
:type job_id: str
:param job_id: Name of the query job.
:type retry: :class:`google.api_core.retry.Retry`
:param retry: (Optional) How to retry the RPC.
:type project: str
:param project:
(Optional) project ID f... | Get the query results object for a query job. | [
"Get",
"the",
"query",
"results",
"object",
"for",
"a",
"query",
"job",
"."
] | def _get_query_results(self, job_id, retry, project=None, timeout_ms=None):
extra_params = {'maxResults': 0}
if project is None:
project = self.project
if timeout_ms is not None:
extra_params['timeoutMs'] = timeout_ms
path = '/projects/{}/queries/{}'.format(projec... | [
"def",
"_get_query_results",
"(",
"self",
",",
"job_id",
",",
"retry",
",",
"project",
"=",
"None",
",",
"timeout_ms",
"=",
"None",
")",
":",
"extra_params",
"=",
"{",
"'maxResults'",
":",
"0",
"}",
"if",
"project",
"is",
"None",
":",
"project",
"=",
"... | Get the query results object for a query job. | [
"Get",
"the",
"query",
"results",
"object",
"for",
"a",
"query",
"job",
"."
] | [
"\"\"\"Get the query results object for a query job.\n\n :type job_id: str\n :param job_id: Name of the query job.\n\n :type retry: :class:`google.api_core.retry.Retry`\n :param retry: (Optional) How to retry the RPC.\n\n :type project: str\n :param project:\n (O... | [
{
"param": "self",
"type": null
},
{
"param": "job_id",
"type": null
},
{
"param": "retry",
"type": null
},
{
"param": "project",
"type": null
},
{
"param": "timeout_ms",
"type": null
}
] | {
"returns": [
{
"docstring": "a new ``QueryResults`` instance",
"docstring_tokens": [
"a",
"new",
"`",
"`",
"QueryResults",
"`",
"`",
"instance"
],
"type": ":class:`google.cloud.bigquery.query.QueryResults`"
}
],
"rai... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | job_from_resource | <not_specific> | def job_from_resource(self, resource):
"""Detect correct job type from resource and instantiate.
:type resource: dict
:param resource: one job resource from API response
:rtype: One of:
:class:`google.cloud.bigquery.job.LoadJob`,
:class:`google.cloud.big... | Detect correct job type from resource and instantiate.
:type resource: dict
:param resource: one job resource from API response
:rtype: One of:
:class:`google.cloud.bigquery.job.LoadJob`,
:class:`google.cloud.bigquery.job.CopyJob`,
:class:`google... | Detect correct job type from resource and instantiate. | [
"Detect",
"correct",
"job",
"type",
"from",
"resource",
"and",
"instantiate",
"."
] | def job_from_resource(self, resource):
config = resource['configuration']
if 'load' in config:
return LoadJob.from_api_repr(resource, self)
elif 'copy' in config:
return CopyJob.from_api_repr(resource, self)
elif 'extract' in config:
return ExtractJob.... | [
"def",
"job_from_resource",
"(",
"self",
",",
"resource",
")",
":",
"config",
"=",
"resource",
"[",
"'configuration'",
"]",
"if",
"'load'",
"in",
"config",
":",
"return",
"LoadJob",
".",
"from_api_repr",
"(",
"resource",
",",
"self",
")",
"elif",
"'copy'",
... | Detect correct job type from resource and instantiate. | [
"Detect",
"correct",
"job",
"type",
"from",
"resource",
"and",
"instantiate",
"."
] | [
"\"\"\"Detect correct job type from resource and instantiate.\n\n :type resource: dict\n :param resource: one job resource from API response\n\n :rtype: One of:\n :class:`google.cloud.bigquery.job.LoadJob`,\n :class:`google.cloud.bigquery.job.CopyJob`,\n ... | [
{
"param": "self",
"type": null
},
{
"param": "resource",
"type": null
}
] | {
"returns": [
{
"docstring": "the job instance, constructed via the resource",
"docstring_tokens": [
"the",
"job",
"instance",
"constructed",
"via",
"the",
"resource"
],
"type": "One of:\n:class:`google.cloud.bigquery.job.LoadJob`,\n... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | cancel_job | <not_specific> | def cancel_job(self, job_id, project=None, retry=DEFAULT_RETRY):
"""Attempt to cancel a job from a job ID.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/cancel
:type job_id: str
:param job_id: Name of the job.
:type project: str
:param proje... | Attempt to cancel a job from a job ID.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/cancel
:type job_id: str
:param job_id: Name of the job.
:type project: str
:param project:
project ID owning the job (defaults to the client's project)... | Attempt to cancel a job from a job ID. | [
"Attempt",
"to",
"cancel",
"a",
"job",
"from",
"a",
"job",
"ID",
"."
] | def cancel_job(self, job_id, project=None, retry=DEFAULT_RETRY):
extra_params = {'projection': 'full'}
if project is None:
project = self.project
path = '/projects/{}/jobs/{}/cancel'.format(project, job_id)
resource = self._call_api(
retry, method='POST', path=pat... | [
"def",
"cancel_job",
"(",
"self",
",",
"job_id",
",",
"project",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"extra_params",
"=",
"{",
"'projection'",
":",
"'full'",
"}",
"if",
"project",
"is",
"None",
":",
"project",
"=",
"self",
".",
"... | Attempt to cancel a job from a job ID. | [
"Attempt",
"to",
"cancel",
"a",
"job",
"from",
"a",
"job",
"ID",
"."
] | [
"\"\"\"Attempt to cancel a job from a job ID.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/cancel\n\n :type job_id: str\n :param job_id: Name of the job.\n\n :type project: str\n :param project:\n project ID owning the job (defaults to ... | [
{
"param": "self",
"type": null
},
{
"param": "job_id",
"type": null
},
{
"param": "project",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": "Concrete job instance, based on the resource returned by the API.",
"docstring_tokens": [
"Concrete",
"job",
"instance",
"based",
"on",
"the",
"resource",
"returned",
"by",
"the",
"AP... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | list_jobs | <not_specific> | def list_jobs(self, max_results=None, page_token=None, all_users=None,
state_filter=None, retry=DEFAULT_RETRY):
"""List jobs for the project associated with this client.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/list
:type max_results: int
... | List jobs for the project associated with this client.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/list
:type max_results: int
:param max_results: maximum number of jobs to return, If not
passed, defaults to a value set by the API.
... | List jobs for the project associated with this client. | [
"List",
"jobs",
"for",
"the",
"project",
"associated",
"with",
"this",
"client",
"."
] | def list_jobs(self, max_results=None, page_token=None, all_users=None,
state_filter=None, retry=DEFAULT_RETRY):
extra_params = {'projection': 'full'}
if all_users is not None:
extra_params['allUsers'] = all_users
if state_filter is not None:
extra_params... | [
"def",
"list_jobs",
"(",
"self",
",",
"max_results",
"=",
"None",
",",
"page_token",
"=",
"None",
",",
"all_users",
"=",
"None",
",",
"state_filter",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"extra_params",
"=",
"{",
"'projection'",
":",
... | List jobs for the project associated with this client. | [
"List",
"jobs",
"for",
"the",
"project",
"associated",
"with",
"this",
"client",
"."
] | [
"\"\"\"List jobs for the project associated with this client.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/list\n\n :type max_results: int\n :param max_results: maximum number of jobs to return, If not\n passed, defaults to a value se... | [
{
"param": "self",
"type": null
},
{
"param": "max_results",
"type": null
},
{
"param": "page_token",
"type": null
},
{
"param": "all_users",
"type": null
},
{
"param": "state_filter",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": "Iterable of job instances.",
"docstring_tokens": [
"Iterable",
"of",
"job",
"instances",
"."
],
"type": ":class:`~google.api_core.page_iterator.Iterator`"
}
],
"raises": [],
"params": [
{
"identifier... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | load_table_from_uri | <not_specific> | def load_table_from_uri(self, source_uris, destination,
job_id=None, job_id_prefix=None,
job_config=None, retry=DEFAULT_RETRY):
"""Starts a job for loading data into a table from CloudStorage.
See
https://cloud.google.com/bigquery/docs/ref... | Starts a job for loading data into a table from CloudStorage.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load
:type source_uris: One of:
str
sequence of string
:param source_uris: URIs of data fi... | Starts a job for loading data into a table from CloudStorage. | [
"Starts",
"a",
"job",
"for",
"loading",
"data",
"into",
"a",
"table",
"from",
"CloudStorage",
"."
] | def load_table_from_uri(self, source_uris, destination,
job_id=None, job_id_prefix=None,
job_config=None, retry=DEFAULT_RETRY):
job_id = _make_job_id(job_id, job_id_prefix)
if isinstance(source_uris, six.string_types):
source_uris = [so... | [
"def",
"load_table_from_uri",
"(",
"self",
",",
"source_uris",
",",
"destination",
",",
"job_id",
"=",
"None",
",",
"job_id_prefix",
"=",
"None",
",",
"job_config",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"job_id",
"=",
"_make_job_id",
"("... | Starts a job for loading data into a table from CloudStorage. | [
"Starts",
"a",
"job",
"for",
"loading",
"data",
"into",
"a",
"table",
"from",
"CloudStorage",
"."
] | [
"\"\"\"Starts a job for loading data into a table from CloudStorage.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load\n\n :type source_uris: One of:\n str\n sequence of string\n :param source_ur... | [
{
"param": "self",
"type": null
},
{
"param": "source_uris",
"type": null
},
{
"param": "destination",
"type": null
},
{
"param": "job_id",
"type": null
},
{
"param": "job_id_prefix",
"type": null
},
{
"param": "job_config",
"type": null
},
{
... | {
"returns": [
{
"docstring": "a new :class:`~google.cloud.bigquery.job.LoadJob` instance",
"docstring_tokens": [
"a",
"new",
":",
"class",
":",
"`",
"~google",
".",
"cloud",
".",
"bigquery",
".",
"... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | copy_table | <not_specific> | def copy_table(self, sources, destination, job_id=None, job_id_prefix=None,
job_config=None, retry=DEFAULT_RETRY):
"""Start a job for copying one or more tables into another table.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.copy
:... | Start a job for copying one or more tables into another table.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.copy
:type sources: One of:
:class:`~google.cloud.bigquery.table.TableReference`
sequence of
... | Start a job for copying one or more tables into another table. | [
"Start",
"a",
"job",
"for",
"copying",
"one",
"or",
"more",
"tables",
"into",
"another",
"table",
"."
] | def copy_table(self, sources, destination, job_id=None, job_id_prefix=None,
job_config=None, retry=DEFAULT_RETRY):
job_id = _make_job_id(job_id, job_id_prefix)
if not isinstance(sources, collections.Sequence):
sources = [sources]
job = CopyJob(job_id, sources, dest... | [
"def",
"copy_table",
"(",
"self",
",",
"sources",
",",
"destination",
",",
"job_id",
"=",
"None",
",",
"job_id_prefix",
"=",
"None",
",",
"job_config",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"job_id",
"=",
"_make_job_id",
"(",
"job_id",... | Start a job for copying one or more tables into another table. | [
"Start",
"a",
"job",
"for",
"copying",
"one",
"or",
"more",
"tables",
"into",
"another",
"table",
"."
] | [
"\"\"\"Start a job for copying one or more tables into another table.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.copy\n\n :type sources: One of:\n :class:`~google.cloud.bigquery.table.TableReference`\n sequen... | [
{
"param": "self",
"type": null
},
{
"param": "sources",
"type": null
},
{
"param": "destination",
"type": null
},
{
"param": "job_id",
"type": null
},
{
"param": "job_id_prefix",
"type": null
},
{
"param": "job_config",
"type": null
},
{
"... | {
"returns": [
{
"docstring": "a new :class:`google.cloud.bigquery.job.copyjob` instance",
"docstring_tokens": [
"a",
"new",
":",
"class",
":",
"`",
"google",
".",
"cloud",
".",
"bigquery",
".",
"jo... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | extract_table | <not_specific> | def extract_table(
self, source, destination_uris, job_config=None, job_id=None,
job_id_prefix=None, retry=DEFAULT_RETRY):
"""Start a job to extract a table into Cloud Storage files.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.extract
... | Start a job to extract a table into Cloud Storage files.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.extract
:type source: :class:`google.cloud.bigquery.table.TableReference`
:param source: table to be extracted.
:type destination_uris: One ... | Start a job to extract a table into Cloud Storage files. | [
"Start",
"a",
"job",
"to",
"extract",
"a",
"table",
"into",
"Cloud",
"Storage",
"files",
"."
] | def extract_table(
self, source, destination_uris, job_config=None, job_id=None,
job_id_prefix=None, retry=DEFAULT_RETRY):
job_id = _make_job_id(job_id, job_id_prefix)
if isinstance(destination_uris, six.string_types):
destination_uris = [destination_uris]
job... | [
"def",
"extract_table",
"(",
"self",
",",
"source",
",",
"destination_uris",
",",
"job_config",
"=",
"None",
",",
"job_id",
"=",
"None",
",",
"job_id_prefix",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"job_id",
"=",
"_make_job_id",
"(",
"j... | Start a job to extract a table into Cloud Storage files. | [
"Start",
"a",
"job",
"to",
"extract",
"a",
"table",
"into",
"Cloud",
"Storage",
"files",
"."
] | [
"\"\"\"Start a job to extract a table into Cloud Storage files.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.extract\n\n :type source: :class:`google.cloud.bigquery.table.TableReference`\n :param source: table to be extracted.\n\n :type des... | [
{
"param": "self",
"type": null
},
{
"param": "source",
"type": null
},
{
"param": "destination_uris",
"type": null
},
{
"param": "job_config",
"type": null
},
{
"param": "job_id",
"type": null
},
{
"param": "job_id_prefix",
"type": null
},
{
... | {
"returns": [
{
"docstring": "a new :class:`google.cloud.bigquery.job.ExtractJob` instance",
"docstring_tokens": [
"a",
"new",
":",
"class",
":",
"`",
"google",
".",
"cloud",
".",
"bigquery",
".",
... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | query | <not_specific> | def query(self, query, job_config=None, job_id=None, job_id_prefix=None,
retry=DEFAULT_RETRY):
"""Start a job that runs a SQL query.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query
:type query: str
:param query:
SQ... | Start a job that runs a SQL query.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query
:type query: str
:param query:
SQL query to be executed. Defaults to the standard SQL dialect.
Use the ``job_config`` parameter to change dia... | Start a job that runs a SQL query. | [
"Start",
"a",
"job",
"that",
"runs",
"a",
"SQL",
"query",
"."
] | def query(self, query, job_config=None, job_id=None, job_id_prefix=None,
retry=DEFAULT_RETRY):
job_id = _make_job_id(job_id, job_id_prefix)
job = QueryJob(job_id, query, client=self, job_config=job_config)
job._begin(retry=retry)
return job | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"job_config",
"=",
"None",
",",
"job_id",
"=",
"None",
",",
"job_id_prefix",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"job_id",
"=",
"_make_job_id",
"(",
"job_id",
",",
"job_id_prefix",
")... | Start a job that runs a SQL query. | [
"Start",
"a",
"job",
"that",
"runs",
"a",
"SQL",
"query",
"."
] | [
"\"\"\"Start a job that runs a SQL query.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query\n\n :type query: str\n :param query:\n SQL query to be executed. Defaults to the standard SQL dialect.\n Use the ``job_config`` para... | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "job_config",
"type": null
},
{
"param": "job_id",
"type": null
},
{
"param": "job_id_prefix",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": "a new :class:`google.cloud.bigquery.job.QueryJob` instance",
"docstring_tokens": [
"a",
"new",
":",
"class",
":",
"`",
"google",
".",
"cloud",
".",
"bigquery",
".",
"j... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | query_rows | <not_specific> | def query_rows(
self, query, job_config=None, job_id=None, job_id_prefix=None,
timeout=None, retry=DEFAULT_RETRY):
"""Start a query job and wait for the results.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query
:type query: s... | Start a query job and wait for the results.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query
:type query: str
:param query:
SQL query to be executed. Defaults to the standard SQL dialect.
Use the ``job_config`` parameter to c... | Start a query job and wait for the results. | [
"Start",
"a",
"query",
"job",
"and",
"wait",
"for",
"the",
"results",
"."
] | def query_rows(
self, query, job_config=None, job_id=None, job_id_prefix=None,
timeout=None, retry=DEFAULT_RETRY):
job_id = _make_job_id(job_id, job_id_prefix)
try:
job = self.query(
query, job_config=job_config, job_id=job_id, retry=retry)
... | [
"def",
"query_rows",
"(",
"self",
",",
"query",
",",
"job_config",
"=",
"None",
",",
"job_id",
"=",
"None",
",",
"job_id_prefix",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"job_id",
"=",
"_make_job_id",
"(",
... | Start a query job and wait for the results. | [
"Start",
"a",
"query",
"job",
"and",
"wait",
"for",
"the",
"results",
"."
] | [
"\"\"\"Start a query job and wait for the results.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query\n\n :type query: str\n :param query:\n SQL query to be executed. Defaults to the standard SQL dialect.\n Use the ``job_conf... | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "job_config",
"type": null
},
{
"param": "job_id",
"type": null
},
{
"param": "job_id_prefix",
"type": null
},
{
"param": "timeout",
"type": null
},
{
"param"... | {
"returns": [
{
"docstring": "Iterator of row data :class:`tuple`s. During each page, the\niterator will have the ``total_rows`` attribute set, which counts\nthe total number of rows **in the result set** (this is distinct\nfrom the total number of rows in the current page:\n``iterator.page.num_items``).",... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | list_rows | <not_specific> | def list_rows(self, table, selected_fields=None, max_results=None,
page_token=None, start_index=None, retry=DEFAULT_RETRY):
"""List the rows of the table.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/list
.. note::
This method ass... | List the rows of the table.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/list
.. note::
This method assumes that the provided schema is up-to-date with the
schema as defined on the back-end: if the two schemas are not
identical, the v... | List the rows of the table.
This method assumes that the provided schema is up-to-date with the
schema as defined on the back-end: if the two schemas are not
identical, the values returned may be incomplete. To ensure that the
local copy of the schema is up-to-date, call ``client.get_table``. | [
"List",
"the",
"rows",
"of",
"the",
"table",
".",
"This",
"method",
"assumes",
"that",
"the",
"provided",
"schema",
"is",
"up",
"-",
"to",
"-",
"date",
"with",
"the",
"schema",
"as",
"defined",
"on",
"the",
"back",
"-",
"end",
":",
"if",
"the",
"two"... | def list_rows(self, table, selected_fields=None, max_results=None,
page_token=None, start_index=None, retry=DEFAULT_RETRY):
if selected_fields is not None:
schema = selected_fields
elif isinstance(table, TableReference):
raise ValueError('need selected_fields wi... | [
"def",
"list_rows",
"(",
"self",
",",
"table",
",",
"selected_fields",
"=",
"None",
",",
"max_results",
"=",
"None",
",",
"page_token",
"=",
"None",
",",
"start_index",
"=",
"None",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"if",
"selected_fields",
"is... | List the rows of the table. | [
"List",
"the",
"rows",
"of",
"the",
"table",
"."
] | [
"\"\"\"List the rows of the table.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/list\n\n .. note::\n\n This method assumes that the provided schema is up-to-date with the\n schema as defined on the back-end: if the two schemas are not\n ... | [
{
"param": "self",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "selected_fields",
"type": null
},
{
"param": "max_results",
"type": null
},
{
"param": "page_token",
"type": null
},
{
"param": "start_index",
"type": null
},
{
... | {
"returns": [
{
"docstring": "Iterator of row data :class:`tuple`s. During each page, the\niterator will have the ``total_rows`` attribute set,\nwhich counts the total number of rows **in the table\n(this is distinct from the total number of rows in the\ncurrent page: ``iterator.page.num_items``).",
... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | list_partitions | <not_specific> | def list_partitions(self, table, retry=DEFAULT_RETRY):
"""List the partitions in a table.
:type table: One of:
:class:`~google.cloud.bigquery.table.Table`
:class:`~google.cloud.bigquery.table.TableReference`
:param table: the table to list, or a referen... | List the partitions in a table.
:type table: One of:
:class:`~google.cloud.bigquery.table.Table`
:class:`~google.cloud.bigquery.table.TableReference`
:param table: the table to list, or a reference to it.
:type retry: :class:`google.api_core.retry.Retr... | List the partitions in a table. | [
"List",
"the",
"partitions",
"in",
"a",
"table",
"."
] | def list_partitions(self, table, retry=DEFAULT_RETRY):
config = QueryJobConfig()
config.use_legacy_sql = True
rows = self.query_rows(
'SELECT partition_id from [%s:%s.%s$__PARTITIONS_SUMMARY__]' %
(table.project, table.dataset_id, table.table_id),
job_config... | [
"def",
"list_partitions",
"(",
"self",
",",
"table",
",",
"retry",
"=",
"DEFAULT_RETRY",
")",
":",
"config",
"=",
"QueryJobConfig",
"(",
")",
"config",
".",
"use_legacy_sql",
"=",
"True",
"rows",
"=",
"self",
".",
"query_rows",
"(",
"'SELECT partition_id from ... | List the partitions in a table. | [
"List",
"the",
"partitions",
"in",
"a",
"table",
"."
] | [
"\"\"\"List the partitions in a table.\n\n :type table: One of:\n :class:`~google.cloud.bigquery.table.Table`\n :class:`~google.cloud.bigquery.table.TableReference`\n :param table: the table to list, or a reference to it.\n\n :type retry: :class:`google.a... | [
{
"param": "self",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "retry",
"type": null
}
] | {
"returns": [
{
"docstring": "a list of time partitions",
"docstring_tokens": [
"a",
"list",
"of",
"time",
"partitions"
],
"type": "list"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | _item_to_dataset | <not_specific> | def _item_to_dataset(iterator, resource):
"""Convert a JSON dataset to the native object.
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type resource: dict
:param resource: An item to be converted to a dataset.
:rtype... | Convert a JSON dataset to the native object.
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type resource: dict
:param resource: An item to be converted to a dataset.
:rtype: :class:`.Dataset`
:returns: The next datase... | Convert a JSON dataset to the native object. | [
"Convert",
"a",
"JSON",
"dataset",
"to",
"the",
"native",
"object",
"."
] | def _item_to_dataset(iterator, resource):
return Dataset.from_api_repr(resource) | [
"def",
"_item_to_dataset",
"(",
"iterator",
",",
"resource",
")",
":",
"return",
"Dataset",
".",
"from_api_repr",
"(",
"resource",
")"
] | Convert a JSON dataset to the native object. | [
"Convert",
"a",
"JSON",
"dataset",
"to",
"the",
"native",
"object",
"."
] | [
"\"\"\"Convert a JSON dataset to the native object.\n\n :type iterator: :class:`~google.api_core.page_iterator.Iterator`\n :param iterator: The iterator that is currently in use.\n\n :type resource: dict\n :param resource: An item to be converted to a dataset.\n\n :rtype: :class:`.Dataset`\n :retu... | [
{
"param": "iterator",
"type": null
},
{
"param": "resource",
"type": null
}
] | {
"returns": [
{
"docstring": "The next dataset in the page.",
"docstring_tokens": [
"The",
"next",
"dataset",
"in",
"the",
"page",
"."
],
"type": ":class:`.Dataset`"
}
],
"raises": [],
"params": [
{
"identifier": ... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | _item_to_table | <not_specific> | def _item_to_table(iterator, resource):
"""Convert a JSON table to the native object.
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type resource: dict
:param resource: An item to be converted to a table.
:rtype: :cla... | Convert a JSON table to the native object.
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type resource: dict
:param resource: An item to be converted to a table.
:rtype: :class:`~google.cloud.bigquery.table.Table`
:re... | Convert a JSON table to the native object. | [
"Convert",
"a",
"JSON",
"table",
"to",
"the",
"native",
"object",
"."
] | def _item_to_table(iterator, resource):
return Table.from_api_repr(resource) | [
"def",
"_item_to_table",
"(",
"iterator",
",",
"resource",
")",
":",
"return",
"Table",
".",
"from_api_repr",
"(",
"resource",
")"
] | Convert a JSON table to the native object. | [
"Convert",
"a",
"JSON",
"table",
"to",
"the",
"native",
"object",
"."
] | [
"\"\"\"Convert a JSON table to the native object.\n\n :type iterator: :class:`~google.api_core.page_iterator.Iterator`\n :param iterator: The iterator that is currently in use.\n\n :type resource: dict\n :param resource: An item to be converted to a table.\n\n :rtype: :class:`~google.cloud.bigquery.t... | [
{
"param": "iterator",
"type": null
},
{
"param": "resource",
"type": null
}
] | {
"returns": [
{
"docstring": "The next table in the page.",
"docstring_tokens": [
"The",
"next",
"table",
"in",
"the",
"page",
"."
],
"type": ":class:`~google.cloud.bigquery.table.Table`"
}
],
"raises": [],
"params": [
... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | _make_job_id | <not_specific> | def _make_job_id(job_id, prefix=None):
"""Construct an ID for a new job.
:type job_id: str or ``NoneType``
:param job_id: the user-provided job ID
:type prefix: str or ``NoneType``
:param prefix: (Optional) the user-provided prefix for a job ID
:rtype: str
:returns: A job ID
"""
i... | Construct an ID for a new job.
:type job_id: str or ``NoneType``
:param job_id: the user-provided job ID
:type prefix: str or ``NoneType``
:param prefix: (Optional) the user-provided prefix for a job ID
:rtype: str
:returns: A job ID
| Construct an ID for a new job. | [
"Construct",
"an",
"ID",
"for",
"a",
"new",
"job",
"."
] | def _make_job_id(job_id, prefix=None):
if job_id is not None:
return job_id
elif prefix is not None:
return str(prefix) + str(uuid.uuid4())
else:
return str(uuid.uuid4()) | [
"def",
"_make_job_id",
"(",
"job_id",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"job_id",
"is",
"not",
"None",
":",
"return",
"job_id",
"elif",
"prefix",
"is",
"not",
"None",
":",
"return",
"str",
"(",
"prefix",
")",
"+",
"str",
"(",
"uuid",
".",
... | Construct an ID for a new job. | [
"Construct",
"an",
"ID",
"for",
"a",
"new",
"job",
"."
] | [
"\"\"\"Construct an ID for a new job.\n\n :type job_id: str or ``NoneType``\n :param job_id: the user-provided job ID\n\n :type prefix: str or ``NoneType``\n :param prefix: (Optional) the user-provided prefix for a job ID\n\n :rtype: str\n :returns: A job ID\n \"\"\""
] | [
{
"param": "job_id",
"type": null
},
{
"param": "prefix",
"type": null
}
] | {
"returns": [
{
"docstring": "A job ID",
"docstring_tokens": [
"A",
"job",
"ID"
],
"type": "str"
}
],
"raises": [],
"params": [
{
"identifier": "job_id",
"type": null,
"docstring": "the user-provided job ID",
"docstring_tokens"... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | _check_mode | null | def _check_mode(stream):
"""Check that a stream was opened in read-binary mode.
:type stream: IO[bytes]
:param stream: A bytes IO object open for reading.
:raises: :exc:`ValueError` if the ``stream.mode`` is a valid attribute
and is not among ``rb``, ``r+b`` or ``rb+``.
"""
mode =... | Check that a stream was opened in read-binary mode.
:type stream: IO[bytes]
:param stream: A bytes IO object open for reading.
:raises: :exc:`ValueError` if the ``stream.mode`` is a valid attribute
and is not among ``rb``, ``r+b`` or ``rb+``.
| Check that a stream was opened in read-binary mode. | [
"Check",
"that",
"a",
"stream",
"was",
"opened",
"in",
"read",
"-",
"binary",
"mode",
"."
] | def _check_mode(stream):
mode = getattr(stream, 'mode', None)
if mode is not None and mode not in ('rb', 'r+b', 'rb+'):
raise ValueError(
"Cannot upload files opened in text mode: use "
"open(filename, mode='rb') or open(filename, mode='r+b')") | [
"def",
"_check_mode",
"(",
"stream",
")",
":",
"mode",
"=",
"getattr",
"(",
"stream",
",",
"'mode'",
",",
"None",
")",
"if",
"mode",
"is",
"not",
"None",
"and",
"mode",
"not",
"in",
"(",
"'rb'",
",",
"'r+b'",
",",
"'rb+'",
")",
":",
"raise",
"Value... | Check that a stream was opened in read-binary mode. | [
"Check",
"that",
"a",
"stream",
"was",
"opened",
"in",
"read",
"-",
"binary",
"mode",
"."
] | [
"\"\"\"Check that a stream was opened in read-binary mode.\n\n :type stream: IO[bytes]\n :param stream: A bytes IO object open for reading.\n\n :raises: :exc:`ValueError` if the ``stream.mode`` is a valid attribute\n and is not among ``rb``, ``r+b`` or ``rb+``.\n \"\"\""
] | [
{
"param": "stream",
"type": null
}
] | {
"returns": [],
"raises": [
{
"docstring": ":exc:`ValueError` if the ``stream.mode`` is a valid attribute\nand is not among ``rb``, ``r+b`` or ``rb+``.",
"docstring_tokens": [
":",
"exc",
":",
"`",
"ValueError",
"`",
"if",
"the",
... |
07fd6045629ab24a2148aa7338612eda603cc3a6 | zero-master/bigquery | google/cloud/bigquery/client.py | [
"Apache-2.0"
] | Python | _get_upload_headers | <not_specific> | def _get_upload_headers(user_agent):
"""Get the headers for an upload request.
:type user_agent: str
:param user_agent: The user-agent for requests.
:rtype: dict
:returns: The headers to be used for the request.
"""
return {
'Accept': 'application/json',
'Accept-Encoding': ... | Get the headers for an upload request.
:type user_agent: str
:param user_agent: The user-agent for requests.
:rtype: dict
:returns: The headers to be used for the request.
| Get the headers for an upload request. | [
"Get",
"the",
"headers",
"for",
"an",
"upload",
"request",
"."
] | def _get_upload_headers(user_agent):
return {
'Accept': 'application/json',
'Accept-Encoding': 'gzip, deflate',
'User-Agent': user_agent,
'content-type': 'application/json',
} | [
"def",
"_get_upload_headers",
"(",
"user_agent",
")",
":",
"return",
"{",
"'Accept'",
":",
"'application/json'",
",",
"'Accept-Encoding'",
":",
"'gzip, deflate'",
",",
"'User-Agent'",
":",
"user_agent",
",",
"'content-type'",
":",
"'application/json'",
",",
"}"
] | Get the headers for an upload request. | [
"Get",
"the",
"headers",
"for",
"an",
"upload",
"request",
"."
] | [
"\"\"\"Get the headers for an upload request.\n\n :type user_agent: str\n :param user_agent: The user-agent for requests.\n\n :rtype: dict\n :returns: The headers to be used for the request.\n \"\"\""
] | [
{
"param": "user_agent",
"type": null
}
] | {
"returns": [
{
"docstring": "The headers to be used for the request.",
"docstring_tokens": [
"The",
"headers",
"to",
"be",
"used",
"for",
"the",
"request",
"."
],
"type": "dict"
}
],
"raises": [],
"params":... |
eb7372876c1ffd979cbd807189c2f1600bc1354a | zero-master/bigquery | google/cloud/bigquery/dataset.py | [
"Apache-2.0"
] | Python | path | <not_specific> | def path(self):
"""URL path for the dataset's APIs.
:rtype: str
:returns: the path based on project and dataset name.
"""
return '/projects/%s/datasets/%s' % (self.project, self.dataset_id) | URL path for the dataset's APIs.
:rtype: str
:returns: the path based on project and dataset name.
| URL path for the dataset's APIs. | [
"URL",
"path",
"for",
"the",
"dataset",
"'",
"s",
"APIs",
"."
] | def path(self):
return '/projects/%s/datasets/%s' % (self.project, self.dataset_id) | [
"def",
"path",
"(",
"self",
")",
":",
"return",
"'/projects/%s/datasets/%s'",
"%",
"(",
"self",
".",
"project",
",",
"self",
".",
"dataset_id",
")"
] | URL path for the dataset's APIs. | [
"URL",
"path",
"for",
"the",
"dataset",
"'",
"s",
"APIs",
"."
] | [
"\"\"\"URL path for the dataset's APIs.\n\n :rtype: str\n :returns: the path based on project and dataset name.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "the path based on project and dataset name.",
"docstring_tokens": [
"the",
"path",
"based",
"on",
"project",
"and",
"dataset",
"name",
"."
],
"type": "str"
}
],
"raises": [],
"p... |
eb7372876c1ffd979cbd807189c2f1600bc1354a | zero-master/bigquery | google/cloud/bigquery/dataset.py | [
"Apache-2.0"
] | Python | _key | <not_specific> | def _key(self):
"""A tuple key that uniquely describes this field.
Used to compute this instance's hashcode and evaluate equality.
Returns:
tuple: The contents of this :class:`.DatasetReference`.
"""
return (
self._project,
self._dataset_id,
... | A tuple key that uniquely describes this field.
Used to compute this instance's hashcode and evaluate equality.
Returns:
tuple: The contents of this :class:`.DatasetReference`.
| A tuple key that uniquely describes this field.
Used to compute this instance's hashcode and evaluate equality. | [
"A",
"tuple",
"key",
"that",
"uniquely",
"describes",
"this",
"field",
".",
"Used",
"to",
"compute",
"this",
"instance",
"'",
"s",
"hashcode",
"and",
"evaluate",
"equality",
"."
] | def _key(self):
return (
self._project,
self._dataset_id,
) | [
"def",
"_key",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_project",
",",
"self",
".",
"_dataset_id",
",",
")"
] | A tuple key that uniquely describes this field. | [
"A",
"tuple",
"key",
"that",
"uniquely",
"describes",
"this",
"field",
"."
] | [
"\"\"\"A tuple key that uniquely describes this field.\n\n Used to compute this instance's hashcode and evaluate equality.\n\n Returns:\n tuple: The contents of this :class:`.DatasetReference`.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "The contents of this :class:`.DatasetReference`.",
"docstring_tokens": [
"The",
"contents",
"of",
"this",
":",
"class",
":",
"`",
".",
"DatasetReference",
"`",
"."
],
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.