Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
add_partition_secondary_key | (table, day, key, path) | Adds a day's partition to a specified table with compound partitioning key, using specified path as source | Adds a day's partition to a specified table with compound partitioning key, using specified path as source | def add_partition_secondary_key(table, day, key, path):
"""Adds a day's partition to a specified table with compound partitioning key, using specified path as source"""
try:
cur.execute(
("ALTER TABLE {6}{3}{5} ADD PARTITION (dt = '{2}', {4} = '{1}') location '{0}/{1}/{2}/'").format(s3_path,... | [
"def",
"add_partition_secondary_key",
"(",
"table",
",",
"day",
",",
"key",
",",
"path",
")",
":",
"try",
":",
"cur",
".",
"execute",
"(",
"(",
"\"ALTER TABLE {6}{3}{5} ADD PARTITION (dt = '{2}', {4} = '{1}') location '{0}/{1}/{2}/'\"",
")",
".",
"format",
"(",
"s3_pa... | [
42,
0
] | [
50,
66
] | python | en | ['en', 'en', 'en'] | True |
drop_partition | (table, day) | Drops a day's partition from a specified table. If key and path are specified it can be used for compound indexed partitions | Drops a day's partition from a specified table. If key and path are specified it can be used for compound indexed partitions | def drop_partition(table, day):
"""Drops a day's partition from a specified table. If key and path are specified it can be used for compound indexed partitions"""
try:
cur.execute(
"""ALTER TABLE {3}{0}{2} DROP IF EXISTS PARTITION (dt = '{1}')""".format(table, day, table_suffix, table_prefix... | [
"def",
"drop_partition",
"(",
"table",
",",
"day",
")",
":",
"try",
":",
"cur",
".",
"execute",
"(",
"\"\"\"ALTER TABLE {3}{0}{2} DROP IF EXISTS PARTITION (dt = '{1}')\"\"\"",
".",
"format",
"(",
"table",
",",
"day",
",",
"table_suffix",
",",
"table_prefix",
")",
... | [
52,
0
] | [
60,
56
] | python | en | ['en', 'en', 'en'] | True |
drop_partition_secondary_key | (table, day, key, path) | Drops a day's partition from a specified table. If key and path are specified it can be used for compound indexed partitions | Drops a day's partition from a specified table. If key and path are specified it can be used for compound indexed partitions | def drop_partition_secondary_key(table, day, key, path):
"""Drops a day's partition from a specified table. If key and path are specified it can be used for compound indexed partitions"""
try:
cur.execute(
"""ALTER TABLE {3}{0}{2} DROP IF EXISTS PARTITION (dt = '{1}', {4} = '{5}')""".format(... | [
"def",
"drop_partition_secondary_key",
"(",
"table",
",",
"day",
",",
"key",
",",
"path",
")",
":",
"try",
":",
"cur",
".",
"execute",
"(",
"\"\"\"ALTER TABLE {3}{0}{2} DROP IF EXISTS PARTITION (dt = '{1}', {4} = '{5}')\"\"\"",
".",
"format",
"(",
"table",
",",
"day",... | [
62,
0
] | [
70,
56
] | python | en | ['en', 'en', 'en'] | True |
drop_partitions_older_than | (table, months_ago) | Drops all partitions older than `months_ago` months from a specified table. Currently compound keys are not supported | Drops all partitions older than `months_ago` months from a specified table. Currently compound keys are not supported | def drop_partitions_older_than(table, months_ago):
"""Drops all partitions older than `months_ago` months from a specified table. Currently compound keys are not supported"""
drop_date = (dt.datetime.today() - relativedelta(months=months_ago)).strftime("%Y-%m-%d")
try:
cur.execute(
"ALTE... | [
"def",
"drop_partitions_older_than",
"(",
"table",
",",
"months_ago",
")",
":",
"drop_date",
"=",
"(",
"dt",
".",
"datetime",
".",
"today",
"(",
")",
"-",
"relativedelta",
"(",
"months",
"=",
"months_ago",
")",
")",
".",
"strftime",
"(",
"\"%Y-%m-%d\"",
")... | [
72,
0
] | [
81,
63
] | python | en | ['en', 'en', 'en'] | True |
Bottleneck.__init__ | (self,
inplanes,
planes,
groups=1,
base_width=4,
base_channels=64,
**kwargs) | Bottleneck block for ResNeXt.
If style is "pytorch", the stride-two layer is the 3x3 conv layer, if
it is "caffe", the stride-two layer is the first 1x1 conv layer.
| Bottleneck block for ResNeXt. | def __init__(self,
inplanes,
planes,
groups=1,
base_width=4,
base_channels=64,
**kwargs):
"""Bottleneck block for ResNeXt.
If style is "pytorch", the stride-two layer is the 3x3 conv layer, if
... | [
"def",
"__init__",
"(",
"self",
",",
"inplanes",
",",
"planes",
",",
"groups",
"=",
"1",
",",
"base_width",
"=",
"4",
",",
"base_channels",
"=",
"64",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Bottleneck",
",",
"self",
")",
".",
"__init__",
... | [
12,
4
] | [
93,
47
] | python | en | ['en', 'no', 'en'] | True |
is_distributed | () |
Return if we are in distributed mode.
|
Return if we are in distributed mode.
| def is_distributed():
"""
Return if we are in distributed mode.
"""
return TORCH_AVAILABLE and dist.is_available() and dist.is_initialized() | [
"def",
"is_distributed",
"(",
")",
":",
"return",
"TORCH_AVAILABLE",
"and",
"dist",
".",
"is_available",
"(",
")",
"and",
"dist",
".",
"is_initialized",
"(",
")"
] | [
33,
0
] | [
37,
76
] | python | en | ['en', 'error', 'th'] | False |
num_workers | () |
Get the total number of workers.
|
Get the total number of workers.
| def num_workers():
"""
Get the total number of workers.
"""
if not is_distributed():
return 1
else:
return dist.get_world_size() | [
"def",
"num_workers",
"(",
")",
":",
"if",
"not",
"is_distributed",
"(",
")",
":",
"return",
"1",
"else",
":",
"return",
"dist",
".",
"get_world_size",
"(",
")"
] | [
40,
0
] | [
47,
36
] | python | en | ['en', 'error', 'th'] | False |
is_primary_worker | () |
Determine if we are the primary (rank 0) worker.
Returns False if we are a secondary worker. Returns True if we are either (1) not in
distributed mode (2) or are the primary (rank 0) worker.
|
Determine if we are the primary (rank 0) worker. | def is_primary_worker():
"""
Determine if we are the primary (rank 0) worker.
Returns False if we are a secondary worker. Returns True if we are either (1) not in
distributed mode (2) or are the primary (rank 0) worker.
"""
return not is_distributed() or dist.get_rank() == 0 | [
"def",
"is_primary_worker",
"(",
")",
":",
"return",
"not",
"is_distributed",
"(",
")",
"or",
"dist",
".",
"get_rank",
"(",
")",
"==",
"0"
] | [
50,
0
] | [
57,
55
] | python | en | ['en', 'error', 'th'] | False |
get_rank | () |
Returns the rank of the current worker.
Returns 0 if not in distributed.
|
Returns the rank of the current worker. | def get_rank():
"""
Returns the rank of the current worker.
Returns 0 if not in distributed.
"""
if not is_distributed():
return 0
else:
return dist.get_rank() | [
"def",
"get_rank",
"(",
")",
":",
"if",
"not",
"is_distributed",
"(",
")",
":",
"return",
"0",
"else",
":",
"return",
"dist",
".",
"get_rank",
"(",
")"
] | [
60,
0
] | [
69,
30
] | python | en | ['en', 'error', 'th'] | False |
override_print | (suppress=False, prefix=None) |
Context manager to override the print to suppress or modify output.
Recommended usage is to call this with suppress=True for all non-primary
workers, or call with a
prefix of rank on all workers.
>>> with override_print(prefix="rank{}".format(rank)):
... my_computation()
:param bool s... |
Context manager to override the print to suppress or modify output. | def override_print(suppress=False, prefix=None):
"""
Context manager to override the print to suppress or modify output.
Recommended usage is to call this with suppress=True for all non-primary
workers, or call with a
prefix of rank on all workers.
>>> with override_print(prefix="rank{}".forma... | [
"def",
"override_print",
"(",
"suppress",
"=",
"False",
",",
"prefix",
"=",
"None",
")",
":",
"builtin_print",
"=",
"builtins",
".",
"print",
"def",
"new_print",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"suppress",
":",
"# do nothing",
... | [
73,
0
] | [
112,
24
] | python | en | ['en', 'error', 'th'] | False |
all_gather_list | (data) |
Gather arbitrary data from all nodes into a list.
Similar to `~torch.distributed.all_gather` but for arbitrary Python
data. Note that *data* must be picklable.
:param data:
data from the local worker to be gathered on other workers
:returns:
a list containing [data1, data2, ...] ... |
Gather arbitrary data from all nodes into a list. | def all_gather_list(data):
"""
Gather arbitrary data from all nodes into a list.
Similar to `~torch.distributed.all_gather` but for arbitrary Python
data. Note that *data* must be picklable.
:param data:
data from the local worker to be gathered on other workers
:returns:
a li... | [
"def",
"all_gather_list",
"(",
"data",
")",
":",
"if",
"not",
"is_distributed",
"(",
")",
":",
"# fall back to just keeping things basic if we're not distributed",
"return",
"[",
"data",
"]",
"# stolen shamelessly from fairseq",
"# https://github.com/pytorch/fairseq/blob/c37250ab... | [
115,
0
] | [
170,
17
] | python | en | ['en', 'error', 'th'] | False |
sync_object | (data) |
Sync an object among all workers.
All workers will return the same value for `data` when returning from this
method, always using the primary worker's version. Useful for ensuring control
flow decisions are made the same.
:param object data:
The object to synchronize. Must be pickleable.
... |
Sync an object among all workers. | def sync_object(data):
"""
Sync an object among all workers.
All workers will return the same value for `data` when returning from this
method, always using the primary worker's version. Useful for ensuring control
flow decisions are made the same.
:param object data:
The object to syn... | [
"def",
"sync_object",
"(",
"data",
")",
":",
"value",
"=",
"all_gather_list",
"(",
"data",
"if",
"get_rank",
"(",
")",
"==",
"0",
"else",
"None",
")",
"[",
"0",
"]",
"return",
"value"
] | [
173,
0
] | [
187,
16
] | python | en | ['en', 'error', 'th'] | False |
sync_parameters | (model: torch.nn.Module) |
Sync all parameters across all workers are the same.
Always returns True, or raises an AssertionError if there was a failure.
:param model: A pytorch model.
:return: always True
|
Sync all parameters across all workers are the same. | def sync_parameters(model: torch.nn.Module) -> bool:
"""
Sync all parameters across all workers are the same.
Always returns True, or raises an AssertionError if there was a failure.
:param model: A pytorch model.
:return: always True
"""
if not is_distributed():
# if things aren't... | [
"def",
"sync_parameters",
"(",
"model",
":",
"torch",
".",
"nn",
".",
"Module",
")",
"->",
"bool",
":",
"if",
"not",
"is_distributed",
"(",
")",
":",
"# if things aren't distributed, of course things are in sync",
"return",
"True",
"# sync all the parameters",
"with",... | [
190,
0
] | [
223,
15
] | python | en | ['en', 'error', 'th'] | False |
distributed_context | (
rank, opt, rank_offset=0, gpu=None, init_method="tcp://localhost:61337"
) |
A context which wraps initialization of a distributed/multiprocessing run.
Every process in the distributed run should launch with this. In true
distributed setting you may wish to use slurm_distributed_context instead.
:param int rank:
This process's rank, less rank_offset.
:param int ra... |
A context which wraps initialization of a distributed/multiprocessing run. | def distributed_context(
rank, opt, rank_offset=0, gpu=None, init_method="tcp://localhost:61337"
):
"""
A context which wraps initialization of a distributed/multiprocessing run.
Every process in the distributed run should launch with this. In true
distributed setting you may wish to use slurm_dist... | [
"def",
"distributed_context",
"(",
"rank",
",",
"opt",
",",
"rank_offset",
"=",
"0",
",",
"gpu",
"=",
"None",
",",
"init_method",
"=",
"\"tcp://localhost:61337\"",
")",
":",
"# Set per-host options",
"opt",
"=",
"copy",
".",
"deepcopy",
"(",
"opt",
")",
"# w... | [
227,
0
] | [
292,
17
] | python | en | ['en', 'error', 'th'] | False |
slurm_distributed_context | (opt) |
Initialize a distributed context, using the SLURM environment.
Does some work to read the environment to find a list of participating nodes
and the main node.
:param opt:
Command line options.
|
Initialize a distributed context, using the SLURM environment. | def slurm_distributed_context(opt):
"""
Initialize a distributed context, using the SLURM environment.
Does some work to read the environment to find a list of participating nodes
and the main node.
:param opt:
Command line options.
"""
# We can determine the init method automatica... | [
"def",
"slurm_distributed_context",
"(",
"opt",
")",
":",
"# We can determine the init method automatically for Slurm.",
"# double check we're using SLURM",
"node_list",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'SLURM_JOB_NODELIST'",
")",
"if",
"node_list",
"is",
"None"... | [
296,
0
] | [
344,
68
] | python | en | ['en', 'error', 'th'] | False |
available_commands | () | Index available commands. | Index available commands. | def available_commands():
"""Index available commands."""
return [
{"name": "help", "summary": "Print available commands"},
{"name": "provision", "summary": "Provision an agent"},
{"name": "start", "summary": "Start a new agent process"},
] | [
"def",
"available_commands",
"(",
")",
":",
"return",
"[",
"{",
"\"name\"",
":",
"\"help\"",
",",
"\"summary\"",
":",
"\"Print available commands\"",
"}",
",",
"{",
"\"name\"",
":",
"\"provision\"",
",",
"\"summary\"",
":",
"\"Provision an agent\"",
"}",
",",
"{... | [
6,
0
] | [
12,
5
] | python | en | ['en', 'en', 'en'] | True |
load_command | (command: str) | Load the module corresponding with a named command. | Load the module corresponding with a named command. | def load_command(command: str):
"""Load the module corresponding with a named command."""
module = None
module_path = None
for cmd in available_commands():
if cmd["name"] == command:
module = cmd["name"]
if "module" in cmd:
module_path = cmd["module"]
... | [
"def",
"load_command",
"(",
"command",
":",
"str",
")",
":",
"module",
"=",
"None",
"module_path",
"=",
"None",
"for",
"cmd",
"in",
"available_commands",
"(",
")",
":",
"if",
"cmd",
"[",
"\"name\"",
"]",
"==",
"command",
":",
"module",
"=",
"cmd",
"[",... | [
15,
0
] | [
28,
41
] | python | en | ['en', 'en', 'en'] | True |
run_command | (command: str, argv: Sequence[str] = None) | Execute a named command with command line arguments. | Execute a named command with command line arguments. | def run_command(command: str, argv: Sequence[str] = None):
"""Execute a named command with command line arguments."""
module = load_command(command) or load_command("help")
module.execute(argv) | [
"def",
"run_command",
"(",
"command",
":",
"str",
",",
"argv",
":",
"Sequence",
"[",
"str",
"]",
"=",
"None",
")",
":",
"module",
"=",
"load_command",
"(",
"command",
")",
"or",
"load_command",
"(",
"\"help\"",
")",
"module",
".",
"execute",
"(",
"argv... | [
31,
0
] | [
34,
24
] | python | en | ['en', 'en', 'en'] | True |
represents_int | (s) | Judge whether string s represents an int.
Args:
s(str): The input string to be judged.
Returns:
bool: Whether s represents int or not.
| Judge whether string s represents an int. | def represents_int(s):
"""Judge whether string s represents an int.
Args:
s(str): The input string to be judged.
Returns:
bool: Whether s represents int or not.
"""
try:
int(s)
return True
except ValueError:
return False | [
"def",
"represents_int",
"(",
"s",
")",
":",
"try",
":",
"int",
"(",
"s",
")",
"return",
"True",
"except",
"ValueError",
":",
"return",
"False"
] | [
15,
0
] | [
28,
20
] | python | en | ['en', 'en', 'en'] | True |
read_mesh_vertices | (filename) | Read XYZ for each vertex.
Args:
filename(str): The name of the mesh vertices file.
Returns:
ndarray: Vertices.
| Read XYZ for each vertex. | def read_mesh_vertices(filename):
"""Read XYZ for each vertex.
Args:
filename(str): The name of the mesh vertices file.
Returns:
ndarray: Vertices.
"""
assert os.path.isfile(filename)
with open(filename, 'rb') as f:
plydata = PlyData.read(f)
num_verts = plydata[... | [
"def",
"read_mesh_vertices",
"(",
"filename",
")",
":",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"plydata",
"=",
"PlyData",
".",
"read",
"(",
"f",
")",
"num_v... | [
45,
0
] | [
62,
19
] | python | en | ['en', 'ga', 'en'] | True |
read_mesh_vertices_rgb | (filename) | Read XYZ and RGB for each vertex.
Args:
filename(str): The name of the mesh vertices file.
Returns:
Vertices. Note that RGB values are in 0-255.
| Read XYZ and RGB for each vertex. | def read_mesh_vertices_rgb(filename):
"""Read XYZ and RGB for each vertex.
Args:
filename(str): The name of the mesh vertices file.
Returns:
Vertices. Note that RGB values are in 0-255.
"""
assert os.path.isfile(filename)
with open(filename, 'rb') as f:
plydata = PlyDat... | [
"def",
"read_mesh_vertices_rgb",
"(",
"filename",
")",
":",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"plydata",
"=",
"PlyData",
".",
"read",
"(",
"f",
")",
"n... | [
65,
0
] | [
85,
19
] | python | en | ['en', 'ga', 'en'] | True |
connection_sort_key | (conn) | Get the sorting key for a particular connection. | Get the sorting key for a particular connection. | def connection_sort_key(conn):
"""Get the sorting key for a particular connection."""
if conn["state"] == ConnectionRecord.STATE_INACTIVE:
pfx = "2"
elif conn["state"] == ConnectionRecord.STATE_INVITATION:
pfx = "1"
else:
pfx = "0"
return pfx + conn["created_at"] | [
"def",
"connection_sort_key",
"(",
"conn",
")",
":",
"if",
"conn",
"[",
"\"state\"",
"]",
"==",
"ConnectionRecord",
".",
"STATE_INACTIVE",
":",
"pfx",
"=",
"\"2\"",
"elif",
"conn",
"[",
"\"state\"",
"]",
"==",
"ConnectionRecord",
".",
"STATE_INVITATION",
":",
... | [
68,
0
] | [
76,
35
] | python | en | ['en', 'en', 'en'] | True |
connections_list | (request: web.BaseRequest) |
Request handler for searching connection records.
Args:
request: aiohttp request object
Returns:
The connection list response
|
Request handler for searching connection records. | async def connections_list(request: web.BaseRequest):
"""
Request handler for searching connection records.
Args:
request: aiohttp request object
Returns:
The connection list response
"""
context = request.app["request_context"]
tag_filter = {}
for param_name in (
... | [
"async",
"def",
"connections_list",
"(",
"request",
":",
"web",
".",
"BaseRequest",
")",
":",
"context",
"=",
"request",
".",
"app",
"[",
"\"request_context\"",
"]",
"tag_filter",
"=",
"{",
"}",
"for",
"param_name",
"in",
"(",
"\"invitation_id\"",
",",
"\"my... | [
139,
0
] | [
172,
50
] | python | en | ['en', 'error', 'th'] | False |
connections_retrieve | (request: web.BaseRequest) |
Request handler for fetching a single connection record.
Args:
request: aiohttp request object
Returns:
The connection record response
|
Request handler for fetching a single connection record. | async def connections_retrieve(request: web.BaseRequest):
"""
Request handler for fetching a single connection record.
Args:
request: aiohttp request object
Returns:
The connection record response
"""
context = request.app["request_context"]
connection_id = request.match_i... | [
"async",
"def",
"connections_retrieve",
"(",
"request",
":",
"web",
".",
"BaseRequest",
")",
":",
"context",
"=",
"request",
".",
"app",
"[",
"\"request_context\"",
"]",
"connection_id",
"=",
"request",
".",
"match_info",
"[",
"\"id\"",
"]",
"try",
":",
"rec... | [
177,
0
] | [
194,
48
] | python | en | ['en', 'error', 'th'] | False |
connections_create_invitation | (request: web.BaseRequest) |
Request handler for creating a new connection invitation.
Args:
request: aiohttp request object
Returns:
The connection invitation details
|
Request handler for creating a new connection invitation. | async def connections_create_invitation(request: web.BaseRequest):
"""
Request handler for creating a new connection invitation.
Args:
request: aiohttp request object
Returns:
The connection invitation details
"""
context = request.app["request_context"]
accept = request.q... | [
"async",
"def",
"connections_create_invitation",
"(",
"request",
":",
"web",
".",
"BaseRequest",
")",
":",
"context",
"=",
"request",
".",
"app",
"[",
"\"request_context\"",
"]",
"accept",
"=",
"request",
".",
"query",
".",
"get",
"(",
"\"accept\"",
")",
"al... | [
217,
0
] | [
251,
36
] | python | en | ['en', 'error', 'th'] | False |
connections_receive_invitation | (request: web.BaseRequest) |
Request handler for receiving a new connection invitation.
Args:
request: aiohttp request object
Returns:
The resulting connection record details
|
Request handler for receiving a new connection invitation. | async def connections_receive_invitation(request: web.BaseRequest):
"""
Request handler for receiving a new connection invitation.
Args:
request: aiohttp request object
Returns:
The resulting connection record details
"""
context = request.app["request_context"]
if context... | [
"async",
"def",
"connections_receive_invitation",
"(",
"request",
":",
"web",
".",
"BaseRequest",
")",
":",
"context",
"=",
"request",
".",
"app",
"[",
"\"request_context\"",
"]",
"if",
"context",
".",
"settings",
".",
"get",
"(",
"\"admin.no_receive_invites\"",
... | [
274,
0
] | [
296,
52
] | python | en | ['en', 'error', 'th'] | False |
connections_accept_invitation | (request: web.BaseRequest) |
Request handler for accepting a stored connection invitation.
Args:
request: aiohttp request object
Returns:
The resulting connection record details
|
Request handler for accepting a stored connection invitation. | async def connections_accept_invitation(request: web.BaseRequest):
"""
Request handler for accepting a stored connection invitation.
Args:
request: aiohttp request object
Returns:
The resulting connection record details
"""
context = request.app["request_context"]
outbound... | [
"async",
"def",
"connections_accept_invitation",
"(",
"request",
":",
"web",
".",
"BaseRequest",
")",
":",
"context",
"=",
"request",
".",
"app",
"[",
"\"request_context\"",
"]",
"outbound_handler",
"=",
"request",
".",
"app",
"[",
"\"outbound_message_router\"",
"... | [
318,
0
] | [
341,
52
] | python | en | ['en', 'error', 'th'] | False |
connections_accept_request | (request: web.BaseRequest) |
Request handler for accepting a stored connection request.
Args:
request: aiohttp request object
Returns:
The resulting connection record details
|
Request handler for accepting a stored connection request. | async def connections_accept_request(request: web.BaseRequest):
"""
Request handler for accepting a stored connection request.
Args:
request: aiohttp request object
Returns:
The resulting connection record details
"""
context = request.app["request_context"]
outbound_handl... | [
"async",
"def",
"connections_accept_request",
"(",
"request",
":",
"web",
".",
"BaseRequest",
")",
":",
"context",
"=",
"request",
".",
"app",
"[",
"\"request_context\"",
"]",
"outbound_handler",
"=",
"request",
".",
"app",
"[",
"\"outbound_message_router\"",
"]",... | [
357,
0
] | [
379,
52
] | python | en | ['en', 'error', 'th'] | False |
connections_establish_inbound | (request: web.BaseRequest) |
Request handler for setting the inbound connection on a connection record.
Args:
request: aiohttp request object
|
Request handler for setting the inbound connection on a connection record. | async def connections_establish_inbound(request: web.BaseRequest):
"""
Request handler for setting the inbound connection on a connection record.
Args:
request: aiohttp request object
"""
context = request.app["request_context"]
connection_id = request.match_info["id"]
outbound_hand... | [
"async",
"def",
"connections_establish_inbound",
"(",
"request",
":",
"web",
".",
"BaseRequest",
")",
":",
"context",
"=",
"request",
".",
"app",
"[",
"\"request_context\"",
"]",
"connection_id",
"=",
"request",
".",
"match_info",
"[",
"\"id\"",
"]",
"outbound_h... | [
385,
0
] | [
404,
32
] | python | en | ['en', 'error', 'th'] | False |
connections_remove | (request: web.BaseRequest) |
Request handler for removing a connection record.
Args:
request: aiohttp request object
|
Request handler for removing a connection record. | async def connections_remove(request: web.BaseRequest):
"""
Request handler for removing a connection record.
Args:
request: aiohttp request object
"""
context = request.app["request_context"]
connection_id = request.match_info["id"]
try:
connection = await ConnectionRecord.... | [
"async",
"def",
"connections_remove",
"(",
"request",
":",
"web",
".",
"BaseRequest",
")",
":",
"context",
"=",
"request",
".",
"app",
"[",
"\"request_context\"",
"]",
"connection_id",
"=",
"request",
".",
"match_info",
"[",
"\"id\"",
"]",
"try",
":",
"conne... | [
408,
0
] | [
422,
32
] | python | en | ['en', 'error', 'th'] | False |
connections_create_static | (request: web.BaseRequest) |
Request handler for creating a new static connection.
Args:
request: aiohttp request object
Returns:
The new connection record
|
Request handler for creating a new static connection. | async def connections_create_static(request: web.BaseRequest):
"""
Request handler for creating a new static connection.
Args:
request: aiohttp request object
Returns:
The new connection record
"""
context = request.app["request_context"]
body = await request.json()
c... | [
"async",
"def",
"connections_create_static",
"(",
"request",
":",
"web",
".",
"BaseRequest",
")",
":",
"context",
"=",
"request",
".",
"app",
"[",
"\"request_context\"",
"]",
"body",
"=",
"await",
"request",
".",
"json",
"(",
")",
"connection_mgr",
"=",
"Con... | [
428,
0
] | [
455,
36
] | python | en | ['en', 'error', 'th'] | False |
register | (app: web.Application) | Register routes. | Register routes. | async def register(app: web.Application):
"""Register routes."""
app.add_routes(
[
web.get("/connections", connections_list),
web.get("/connections/{id}", connections_retrieve),
web.post("/connections/create-invitation", connections_create_invitation),
we... | [
"async",
"def",
"register",
"(",
"app",
":",
"web",
".",
"Application",
")",
":",
"app",
".",
"add_routes",
"(",
"[",
"web",
".",
"get",
"(",
"\"/connections\"",
",",
"connections_list",
")",
",",
"web",
".",
"get",
"(",
"\"/connections/{id}\"",
",",
"co... | [
458,
0
] | [
477,
5
] | python | en | ['en', 'fr', 'en'] | False |
Tickfont.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... | def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A name... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
63,
28
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... | def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
72,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf] | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
"""
return self["size"] | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
103,
4
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Tickfont object
Sets the color bar's tick label font
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.histogram.mark
er.colorbar.Tickfont`
... |
Construct a new Tickfont object
Sets the color bar's tick label font | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Tickfont object
Sets the color bar's tick label font
Parameters
----------
arg
dict of properties compatible with this constructor or
an insta... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Tickfont",
",",
"self",
")",
".",
"__init__",
"(",
"\"tick... | [
143,
4
] | [
226,
34
] | python | en | ['en', 'error', 'th'] | False |
tensor2imgs | (tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True) | Convert tensor to images.
Args:
tensor (torch.Tensor): Tensor that contains multiple images
mean (tuple[float], optional): Mean of images. Defaults to (0, 0, 0).
std (tuple[float], optional): Standard deviation of images.
Defaults to (1, 1, 1).
to_rgb (bool, optional): W... | Convert tensor to images. | def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True):
"""Convert tensor to images.
Args:
tensor (torch.Tensor): Tensor that contains multiple images
mean (tuple[float], optional): Mean of images. Defaults to (0, 0, 0).
std (tuple[float], optional): Standard deviation of i... | [
"def",
"tensor2imgs",
"(",
"tensor",
",",
"mean",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
",",
"std",
"=",
"(",
"1",
",",
"1",
",",
"1",
")",
",",
"to_rgb",
"=",
"True",
")",
":",
"num_imgs",
"=",
"tensor",
".",
"size",
"(",
"0",
")",
"mean... | [
8,
0
] | [
31,
15
] | python | en | ['en', 'en', 'en'] | True |
multi_apply | (func, *args, **kwargs) | Apply function to a list of arguments.
Note:
This function applies the ``func`` to multiple inputs and
map the multiple outputs of the ``func`` into different
list. Each list contains the same type of outputs corresponding
to different inputs.
Args:
func (Fu... | Apply function to a list of arguments. | def multi_apply(func, *args, **kwargs):
"""Apply function to a list of arguments.
Note:
This function applies the ``func`` to multiple inputs and
map the multiple outputs of the ``func`` into different
list. Each list contains the same type of outputs corresponding
t... | [
"def",
"multi_apply",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pfunc",
"=",
"partial",
"(",
"func",
",",
"*",
"*",
"kwargs",
")",
"if",
"kwargs",
"else",
"func",
"map_results",
"=",
"map",
"(",
"pfunc",
",",
"*",
"args",
... | [
34,
0
] | [
53,
46
] | python | en | ['en', 'en', 'en'] | True |
unmap | (data, count, inds, fill=0) | Unmap a subset of item (data) back to the original set of items (of size
count) | Unmap a subset of item (data) back to the original set of items (of size
count) | def unmap(data, count, inds, fill=0):
"""Unmap a subset of item (data) back to the original set of items (of size
count)"""
if data.dim() == 1:
ret = data.new_full((count, ), fill)
ret[inds.type(torch.bool)] = data
else:
new_size = (count, ) + data.size()[1:]
ret = data.n... | [
"def",
"unmap",
"(",
"data",
",",
"count",
",",
"inds",
",",
"fill",
"=",
"0",
")",
":",
"if",
"data",
".",
"dim",
"(",
")",
"==",
"1",
":",
"ret",
"=",
"data",
".",
"new_full",
"(",
"(",
"count",
",",
")",
",",
"fill",
")",
"ret",
"[",
"in... | [
56,
0
] | [
66,
14
] | python | en | ['en', 'en', 'en'] | True |
add_common_cmdline_args | (parser) |
Add common command line args.
|
Add common command line args.
| def add_common_cmdline_args(parser):
"""
Add common command line args.
"""
parser.add_argument(
'-esz',
'--embedding-size',
type=int,
default=300,
help='Size of all embedding layers',
)
parser.add_argument('-nl', '--n-layers', type=int, default=2)
pars... | [
"def",
"add_common_cmdline_args",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'-esz'",
",",
"'--embedding-size'",
",",
"type",
"=",
"int",
",",
"default",
"=",
"300",
",",
"help",
"=",
"'Size of all embedding layers'",
",",
")",
"parser",
"."... | [
27,
0
] | [
129,
5
] | python | en | ['en', 'error', 'th'] | False |
TransformerRankerAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command-line arguments specifically for this agent.
|
Add command-line arguments specifically for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command-line arguments specifically for this agent.
"""
super().add_cmdline_args(parser, partial_opt=partial_opt)
agent = parser.add_argument_group('Transform... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"super",
"(",
")",
".",
"add_cmdline_args",
"(",
"parser",
",",
"partial_opt",
"="... | [
155,
4
] | [
216,
20
] | python | en | ['en', 'error', 'th'] | False |
TransformerRankerAgent.build_model | (self, states=None) |
Build and return model.
|
Build and return model.
| def build_model(self, states=None):
"""
Build and return model.
"""
model = TransformerMemNetModel(self.opt, self.dict)
if self.opt['embedding_type'] != 'random':
self._copy_embeddings(model.embeddings.weight, self.opt['embedding_type'])
return model | [
"def",
"build_model",
"(",
"self",
",",
"states",
"=",
"None",
")",
":",
"model",
"=",
"TransformerMemNetModel",
"(",
"self",
".",
"opt",
",",
"self",
".",
"dict",
")",
"if",
"self",
".",
"opt",
"[",
"'embedding_type'",
"]",
"!=",
"'random'",
":",
"sel... | [
228,
4
] | [
235,
20
] | python | en | ['en', 'error', 'th'] | False |
TransformerRankerAgent.batchify | (self, obs_batch, sort=False) |
Override so that we can add memories to the Batch object.
|
Override so that we can add memories to the Batch object.
| def batchify(self, obs_batch, sort=False):
"""
Override so that we can add memories to the Batch object.
"""
batch = super().batchify(obs_batch, sort)
if self.opt['use_memories']:
valid_obs = [(i, ex) for i, ex in enumerate(obs_batch) if self.is_valid(ex)]
... | [
"def",
"batchify",
"(",
"self",
",",
"obs_batch",
",",
"sort",
"=",
"False",
")",
":",
"batch",
"=",
"super",
"(",
")",
".",
"batchify",
"(",
"obs_batch",
",",
"sort",
")",
"if",
"self",
".",
"opt",
"[",
"'use_memories'",
"]",
":",
"valid_obs",
"=",
... | [
237,
4
] | [
249,
20
] | python | en | ['en', 'error', 'th'] | False |
TransformerRankerAgent.vectorize | (self, *args, **kwargs) |
Override to include vectorization of memories.
|
Override to include vectorization of memories.
| def vectorize(self, *args, **kwargs):
"""
Override to include vectorization of memories.
"""
kwargs['add_start'] = False
kwargs['add_end'] = False
obs = super().vectorize(*args, **kwargs)
if self.opt['use_memories']:
obs = self._vectorize_memories(obs)... | [
"def",
"vectorize",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'add_start'",
"]",
"=",
"False",
"kwargs",
"[",
"'add_end'",
"]",
"=",
"False",
"obs",
"=",
"super",
"(",
")",
".",
"vectorize",
"(",
"*",
"args",... | [
257,
4
] | [
266,
18
] | python | en | ['en', 'error', 'th'] | False |
TransformerRankerAgent.encode_candidates | (self, padded_cands) |
Encode candidates.
|
Encode candidates.
| def encode_candidates(self, padded_cands):
"""
Encode candidates.
"""
_, cands = self.model(xs=None, mems=None, cands=padded_cands)
return cands | [
"def",
"encode_candidates",
"(",
"self",
",",
"padded_cands",
")",
":",
"_",
",",
"cands",
"=",
"self",
".",
"model",
"(",
"xs",
"=",
"None",
",",
"mems",
"=",
"None",
",",
"cands",
"=",
"padded_cands",
")",
"return",
"cands"
] | [
268,
4
] | [
274,
20
] | python | en | ['en', 'error', 'th'] | False |
TransformerRankerAgent.score_candidates | (self, batch, cand_vecs, cand_encs=None) |
Score candidates.
|
Score candidates.
| def score_candidates(self, batch, cand_vecs, cand_encs=None):
"""
Score candidates.
"""
# convoluted check that not all memories are empty
if (
self.opt['use_memories']
and batch.memory_vecs is not None
and sum(len(m) for m in batch.memory_vecs... | [
"def",
"score_candidates",
"(",
"self",
",",
"batch",
",",
"cand_vecs",
",",
"cand_encs",
"=",
"None",
")",
":",
"# convoluted check that not all memories are empty",
"if",
"(",
"self",
".",
"opt",
"[",
"'use_memories'",
"]",
"and",
"batch",
".",
"memory_vecs",
... | [
276,
4
] | [
302,
21
] | python | en | ['en', 'error', 'th'] | False |
TransformerGeneratorAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command-line arguments specifically for this agent.
|
Add command-line arguments specifically for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command-line arguments specifically for this agent.
"""
agent = parser.add_argument_group('Transformer Arguments')
add_common_cmdline_args(agent)
cls.... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"agent",
"=",
"parser",
".",
"add_argument_group",
"(",
"'Transformer Arguments'",
")"... | [
313,
4
] | [
324,
20
] | python | en | ['en', 'error', 'th'] | False |
TransformerGeneratorAgent.build_model | (self, states=None) |
Build and return model.
|
Build and return model.
| def build_model(self, states=None):
"""
Build and return model.
"""
model = TransformerGeneratorModel(self.opt, self.dict)
if self.opt['embedding_type'] != 'random':
self._copy_embeddings(
model.encoder.embeddings.weight, self.opt['embedding_type']
... | [
"def",
"build_model",
"(",
"self",
",",
"states",
"=",
"None",
")",
":",
"model",
"=",
"TransformerGeneratorModel",
"(",
"self",
".",
"opt",
",",
"self",
".",
"dict",
")",
"if",
"self",
".",
"opt",
"[",
"'embedding_type'",
"]",
"!=",
"'random'",
":",
"... | [
326,
4
] | [
335,
20
] | python | en | ['en', 'error', 'th'] | False |
TransformerGeneratorAgent._resize_token_embeddings | (self, state_dict, msg=None) |
Resize the token embeddings when are adding extra special tokens.
|
Resize the token embeddings when are adding extra special tokens.
| def _resize_token_embeddings(self, state_dict, msg=None):
"""
Resize the token embeddings when are adding extra special tokens.
"""
# map extra special tokens carefully
new_size = self.model.embeddings.weight.size()[0]
orig_size = state_dict['embeddings.weight'].size()[0]... | [
"def",
"_resize_token_embeddings",
"(",
"self",
",",
"state_dict",
",",
"msg",
"=",
"None",
")",
":",
"# map extra special tokens carefully",
"new_size",
"=",
"self",
".",
"model",
".",
"embeddings",
".",
"weight",
".",
"size",
"(",
")",
"[",
"0",
"]",
"orig... | [
337,
4
] | [
363,
25
] | python | en | ['en', 'error', 'th'] | False |
TransformerClassifierAgent.vectorize | (self, *args, **kwargs) |
Add the start and end token to the text.
|
Add the start and end token to the text.
| def vectorize(self, *args, **kwargs):
"""
Add the start and end token to the text.
"""
kwargs['add_start'] = True
kwargs['add_end'] = True
obs = super().vectorize(*args, **kwargs)
return obs | [
"def",
"vectorize",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'add_start'",
"]",
"=",
"True",
"kwargs",
"[",
"'add_end'",
"]",
"=",
"True",
"obs",
"=",
"super",
"(",
")",
".",
"vectorize",
"(",
"*",
"args",
... | [
394,
4
] | [
401,
18
] | python | en | ['en', 'error', 'th'] | False |
TransformerClassifierAgent._set_text_vec | (self, *args, **kwargs) |
Add the start and end token to the text.
|
Add the start and end token to the text.
| def _set_text_vec(self, *args, **kwargs):
"""
Add the start and end token to the text.
"""
obs = super()._set_text_vec(*args, **kwargs)
if 'text_vec' in obs and 'added_start_end' not in obs:
obs.force_set(
'text_vec', self._add_start_end_tokens(obs['t... | [
"def",
"_set_text_vec",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obs",
"=",
"super",
"(",
")",
".",
"_set_text_vec",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"'text_vec'",
"in",
"obs",
"and",
"'added_start_end'"... | [
403,
4
] | [
422,
18
] | python | en | ['en', 'error', 'th'] | False |
TransformerClassifierAgent.load_state_dict | (self, state_dict) |
Load the state dict into model.
This is easily overridable to facilitate transfer of state dicts.
|
Load the state dict into model. | def load_state_dict(self, state_dict):
"""
Load the state dict into model.
This is easily overridable to facilitate transfer of state dicts.
"""
if self.is_finetune and self.opt['load_from_pretrained_ranker']:
self.base_model.load_state_dict(state_dict, strict=False)... | [
"def",
"load_state_dict",
"(",
"self",
",",
"state_dict",
")",
":",
"if",
"self",
".",
"is_finetune",
"and",
"self",
".",
"opt",
"[",
"'load_from_pretrained_ranker'",
"]",
":",
"self",
".",
"base_model",
".",
"load_state_dict",
"(",
"state_dict",
",",
"strict"... | [
427,
4
] | [
436,
50
] | python | en | ['en', 'error', 'th'] | False |
CmdTutorial.func | (self) |
All we do is to scan the current location for an Attribute
called `tutorial_info` and display that.
|
All we do is to scan the current location for an Attribute
called `tutorial_info` and display that.
| def func(self):
"""
All we do is to scan the current location for an Attribute
called `tutorial_info` and display that.
"""
caller = self.caller
if not self.args:
target = self.obj # this is the room the command is defined on
else:
targe... | [
"def",
"func",
"(",
"self",
")",
":",
"caller",
"=",
"self",
".",
"caller",
"if",
"not",
"self",
".",
"args",
":",
"target",
"=",
"self",
".",
"obj",
"# this is the room the command is defined on",
"else",
":",
"target",
"=",
"caller",
".",
"search",
"(",
... | [
55,
4
] | [
73,
78
] | python | en | ['en', 'error', 'th'] | False |
CmdTutorialSetDetail.func | (self) |
All this does is to check if the object has
the set_detail method and uses it.
|
All this does is to check if the object has
the set_detail method and uses it.
| def func(self):
"""
All this does is to check if the object has
the set_detail method and uses it.
"""
if not self.args or not self.rhs:
self.caller.msg("Usage: @detail key = description")
return
if not hasattr(self.obj, "set_detail"):
... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"args",
"or",
"not",
"self",
".",
"rhs",
":",
"self",
".",
"caller",
".",
"msg",
"(",
"\"Usage: @detail key = description\"",
")",
"return",
"if",
"not",
"hasattr",
"(",
"self",
".",
"obj"... | [
103,
4
] | [
118,
72
] | python | en | ['en', 'error', 'th'] | False |
CmdTutorialLook.func | (self) |
Handle the looking. This is a copy of the default look
code except for adding in the details.
|
Handle the looking. This is a copy of the default look
code except for adding in the details.
| def func(self):
"""
Handle the looking. This is a copy of the default look
code except for adding in the details.
"""
caller = self.caller
args = self.args
if args:
# we use quiet=True to turn off automatic error reporting.
# This tells sea... | [
"def",
"func",
"(",
"self",
")",
":",
"caller",
"=",
"self",
".",
"caller",
"args",
"=",
"self",
".",
"args",
"if",
"args",
":",
"# we use quiet=True to turn off automatic error reporting.",
"# This tells search that we want to handle error messages",
"# ourself. This also ... | [
143,
4
] | [
193,
14
] | python | en | ['en', 'error', 'th'] | False |
TutorialRoomCmdSet.at_cmdset_creation | (self) | add the tutorial-room commands | add the tutorial-room commands | def at_cmdset_creation(self):
"""add the tutorial-room commands"""
self.add(CmdTutorial())
self.add(CmdTutorialSetDetail())
self.add(CmdTutorialLook()) | [
"def",
"at_cmdset_creation",
"(",
"self",
")",
":",
"self",
".",
"add",
"(",
"CmdTutorial",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdTutorialSetDetail",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdTutorialLook",
"(",
")",
")"
] | [
205,
4
] | [
209,
35
] | python | en | ['en', 'en', 'en'] | True |
TutorialRoom.at_object_creation | (self) | Called when room is first created | Called when room is first created | def at_object_creation(self):
"""Called when room is first created"""
self.db.tutorial_info = "This is a tutorial room. It allows you to use the 'tutorial' command."
self.cmdset.add_default(TutorialRoomCmdSet) | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"self",
".",
"db",
".",
"tutorial_info",
"=",
"\"This is a tutorial room. It allows you to use the 'tutorial' command.\"",
"self",
".",
"cmdset",
".",
"add_default",
"(",
"TutorialRoomCmdSet",
")"
] | [
218,
4
] | [
221,
51
] | python | en | ['en', 'en', 'en'] | True |
TutorialRoom.at_object_receive | (self, new_arrival, source_location) |
When an object enter a tutorial room we tell other objects in
the room about it by trying to call a hook on them. The Mob object
uses this to cheaply get notified of enemies without having
to constantly scan for them.
Args:
new_arrival (Object): the object that just... |
When an object enter a tutorial room we tell other objects in
the room about it by trying to call a hook on them. The Mob object
uses this to cheaply get notified of enemies without having
to constantly scan for them. | def at_object_receive(self, new_arrival, source_location):
"""
When an object enter a tutorial room we tell other objects in
the room about it by trying to call a hook on them. The Mob object
uses this to cheaply get notified of enemies without having
to constantly scan for them.... | [
"def",
"at_object_receive",
"(",
"self",
",",
"new_arrival",
",",
"source_location",
")",
":",
"if",
"new_arrival",
".",
"has_account",
"and",
"not",
"new_arrival",
".",
"is_superuser",
":",
"# this is a character",
"for",
"obj",
"in",
"self",
".",
"contents_get",... | [
223,
4
] | [
239,
51
] | python | en | ['en', 'error', 'th'] | False |
TutorialRoom.return_detail | (self, detailkey) |
This looks for an Attribute "obj_details" and possibly
returns the value of it.
Args:
detailkey (str): The detail being looked at. This is
case-insensitive.
|
This looks for an Attribute "obj_details" and possibly
returns the value of it. | def return_detail(self, detailkey):
"""
This looks for an Attribute "obj_details" and possibly
returns the value of it.
Args:
detailkey (str): The detail being looked at. This is
case-insensitive.
"""
details = self.db.details
if deta... | [
"def",
"return_detail",
"(",
"self",
",",
"detailkey",
")",
":",
"details",
"=",
"self",
".",
"db",
".",
"details",
"if",
"details",
":",
"return",
"details",
".",
"get",
"(",
"detailkey",
".",
"lower",
"(",
")",
",",
"None",
")"
] | [
241,
4
] | [
253,
55
] | python | en | ['en', 'error', 'th'] | False |
TutorialRoom.set_detail | (self, detailkey, description) |
This sets a new detail, using an Attribute "details".
Args:
detailkey (str): The detail identifier to add (for
aliases you need to add multiple keys to the
same description). Case-insensitive.
description (str): The text to return when looking
... |
This sets a new detail, using an Attribute "details". | def set_detail(self, detailkey, description):
"""
This sets a new detail, using an Attribute "details".
Args:
detailkey (str): The detail identifier to add (for
aliases you need to add multiple keys to the
same description). Case-insensitive.
... | [
"def",
"set_detail",
"(",
"self",
",",
"detailkey",
",",
"description",
")",
":",
"if",
"self",
".",
"db",
".",
"details",
":",
"self",
".",
"db",
".",
"details",
"[",
"detailkey",
".",
"lower",
"(",
")",
"]",
"=",
"description",
"else",
":",
"self",... | [
255,
4
] | [
270,
62
] | python | en | ['en', 'error', 'th'] | False |
WeatherRoom.at_object_creation | (self) |
Called when object is first created.
We set up a ticker to update this room regularly.
Note that we could in principle also use a Script to manage
the ticking of the room; the TickerHandler works fine for
simple things like this though.
|
Called when object is first created.
We set up a ticker to update this room regularly. | def at_object_creation(self):
"""
Called when object is first created.
We set up a ticker to update this room regularly.
Note that we could in principle also use a Script to manage
the ticking of the room; the TickerHandler works fine for
simple things like this though.
... | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"super",
"(",
"WeatherRoom",
",",
"self",
")",
".",
"at_object_creation",
"(",
")",
"# subscribe ourselves to a ticker to repeatedly call the hook",
"# \"update_weather\" on this object. The interval is randomized",
"# so as to ... | [
304,
4
] | [
321,
111
] | python | en | ['en', 'error', 'th'] | False |
WeatherRoom.update_weather | (self, *args, **kwargs) |
Called by the tickerhandler at regular intervals. Even so, we
only update 20% of the time, picking a random weather message
when we do. The tickerhandler requires that this hook accepts
any arguments and keyword arguments (hence the *args, **kwargs
even though we don't actually ... |
Called by the tickerhandler at regular intervals. Even so, we
only update 20% of the time, picking a random weather message
when we do. The tickerhandler requires that this hook accepts
any arguments and keyword arguments (hence the *args, **kwargs
even though we don't actually ... | def update_weather(self, *args, **kwargs):
"""
Called by the tickerhandler at regular intervals. Even so, we
only update 20% of the time, picking a random weather message
when we do. The tickerhandler requires that this hook accepts
any arguments and keyword arguments (hence the ... | [
"def",
"update_weather",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"random",
".",
"random",
"(",
")",
"<",
"0.2",
":",
"# only update 20 % of the time",
"self",
".",
"msg_contents",
"(",
"\"|w%s|n\"",
"%",
"random",
".",
"ch... | [
323,
4
] | [
333,
72
] | python | en | ['en', 'error', 'th'] | False |
IntroRoom.at_object_creation | (self) |
Called when the room is first created.
|
Called when the room is first created.
| def at_object_creation(self):
"""
Called when the room is first created.
"""
super(IntroRoom, self).at_object_creation()
self.db.tutorial_info = "The first room of the tutorial. " \
"This assigns the health Attribute to "\
... | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"super",
"(",
"IntroRoom",
",",
"self",
")",
".",
"at_object_creation",
"(",
")",
"self",
".",
"db",
".",
"tutorial_info",
"=",
"\"The first room of the tutorial. \"",
"\"This assigns the health Attribute to \"",
"\"... | [
360,
4
] | [
367,
46
] | python | en | ['en', 'error', 'th'] | False |
IntroRoom.at_object_receive | (self, character, source_location) |
Assign properties on characters
|
Assign properties on characters
| def at_object_receive(self, character, source_location):
"""
Assign properties on characters
"""
# setup character for the tutorial
health = self.db.char_health or 20
if character.has_account:
character.db.health = health
character.db.health_max ... | [
"def",
"at_object_receive",
"(",
"self",
",",
"character",
",",
"source_location",
")",
":",
"# setup character for the tutorial",
"health",
"=",
"self",
".",
"db",
".",
"char_health",
"or",
"20",
"if",
"character",
".",
"has_account",
":",
"character",
".",
"db... | [
369,
4
] | [
383,
91
] | python | en | ['en', 'error', 'th'] | False |
CmdEast.func | (self) | move one step eastwards | move one step eastwards | def func(self):
"""move one step eastwards"""
caller = self.caller
bridge_step = min(5, caller.db.tutorial_bridge_position + 1)
if bridge_step > 4:
# we have reached the far east end of the bridge.
# Move to the east room.
eexit = search_object(self.... | [
"def",
"func",
"(",
"self",
")",
":",
"caller",
"=",
"self",
".",
"caller",
"bridge_step",
"=",
"min",
"(",
"5",
",",
"caller",
".",
"db",
".",
"tutorial_bridge_position",
"+",
"1",
")",
"if",
"bridge_step",
">",
"4",
":",
"# we have reached the far east e... | [
424,
4
] | [
443,
34
] | python | en | ['en', 'en', 'en'] | True |
CmdWest.func | (self) | move one step westwards | move one step westwards | def func(self):
"""move one step westwards"""
caller = self.caller
bridge_step = max(-1, caller.db.tutorial_bridge_position - 1)
if bridge_step < 0:
# we have reached the far west end of the bridge.
# Move to the west room.
wexit = search_object(self... | [
"def",
"func",
"(",
"self",
")",
":",
"caller",
"=",
"self",
".",
"caller",
"bridge_step",
"=",
"max",
"(",
"-",
"1",
",",
"caller",
".",
"db",
".",
"tutorial_bridge_position",
"-",
"1",
")",
"if",
"bridge_step",
"<",
"0",
":",
"# we have reached the far... | [
468,
4
] | [
487,
34
] | python | en | ['en', 'en', 'en'] | True |
CmdLookBridge.func | (self) | Looking around, including a chance to fall. | Looking around, including a chance to fall. | def func(self):
"""Looking around, including a chance to fall."""
caller = self.caller
bridge_position = self.caller.db.tutorial_bridge_position
# this command is defined on the room, so we get it through self.obj
location = self.obj
# randomize the look-echo
mess... | [
"def",
"func",
"(",
"self",
")",
":",
"caller",
"=",
"self",
".",
"caller",
"bridge_position",
"=",
"self",
".",
"caller",
".",
"db",
".",
"tutorial_bridge_position",
"# this command is defined on the room, so we get it through self.obj",
"location",
"=",
"self",
".",... | [
531,
4
] | [
558,
85
] | python | en | ['en', 'en', 'en'] | True |
CmdBridgeHelp.func | (self) | Implements the command. | Implements the command. | def func(self):
"""Implements the command."""
string = "You are trying hard not to fall off the bridge ..." \
"\n\nWhat you can do is trying to cross the bridge |weast|n" \
" or try to get back to the mainland |wwest|n)."
self.caller.msg(string) | [
"def",
"func",
"(",
"self",
")",
":",
"string",
"=",
"\"You are trying hard not to fall off the bridge ...\"",
"\"\\n\\nWhat you can do is trying to cross the bridge |weast|n\"",
"\" or try to get back to the mainland |wwest|n).\"",
"self",
".",
"caller",
".",
"msg",
"(",
"string",... | [
571,
4
] | [
576,
31
] | python | en | ['en', 'en', 'en'] | True |
BridgeCmdSet.at_cmdset_creation | (self) | Called at first cmdset creation | Called at first cmdset creation | def at_cmdset_creation(self):
"""Called at first cmdset creation"""
self.add(CmdTutorial())
self.add(CmdEast())
self.add(CmdWest())
self.add(CmdLookBridge())
self.add(CmdBridgeHelp()) | [
"def",
"at_cmdset_creation",
"(",
"self",
")",
":",
"self",
".",
"add",
"(",
"CmdTutorial",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdEast",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdWest",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdLookBridge... | [
584,
4
] | [
590,
33
] | python | en | ['en', 'de', 'en'] | True |
BridgeRoom.at_object_creation | (self) | Setups the room | Setups the room | def at_object_creation(self):
"""Setups the room"""
# this will start the weather room's ticker and tell
# it to call update_weather regularly.
super(BridgeRoom, self).at_object_creation()
# this identifies the exits from the room (should be the command
# needed to leave ... | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"# this will start the weather room's ticker and tell",
"# it to call update_weather regularly.",
"super",
"(",
"BridgeRoom",
",",
"self",
")",
".",
"at_object_creation",
"(",
")",
"# this identifies the exits from the room (sho... | [
631,
4
] | [
649,
38
] | python | en | ['en', 'haw', 'en'] | True |
BridgeRoom.update_weather | (self, *args, **kwargs) |
This is called at irregular intervals and makes the passage
over the bridge a little more interesting.
|
This is called at irregular intervals and makes the passage
over the bridge a little more interesting.
| def update_weather(self, *args, **kwargs):
"""
This is called at irregular intervals and makes the passage
over the bridge a little more interesting.
"""
if random.random() < 80:
# send a message most of the time
self.msg_contents("|w%s|n" % random.choice(... | [
"def",
"update_weather",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"random",
".",
"random",
"(",
")",
"<",
"80",
":",
"# send a message most of the time",
"self",
".",
"msg_contents",
"(",
"\"|w%s|n\"",
"%",
"random",
".",
"... | [
651,
4
] | [
658,
71
] | python | en | ['en', 'error', 'th'] | False |
BridgeRoom.at_object_receive | (self, character, source_location) |
This hook is called by the engine whenever the player is moved
into this room.
|
This hook is called by the engine whenever the player is moved
into this room.
| def at_object_receive(self, character, source_location):
"""
This hook is called by the engine whenever the player is moved
into this room.
"""
if character.has_account:
# we only run this if the entered object is indeed a player object.
# check so our eas... | [
"def",
"at_object_receive",
"(",
"self",
",",
"character",
",",
"source_location",
")",
":",
"if",
"character",
".",
"has_account",
":",
"# we only run this if the entered object is indeed a player object.",
"# check so our east/west exits are correctly defined.",
"wexit",
"=",
... | [
660,
4
] | [
682,
41
] | python | en | ['en', 'error', 'th'] | False |
BridgeRoom.at_object_leave | (self, character, target_location) |
This is triggered when the player leaves the bridge room.
|
This is triggered when the player leaves the bridge room.
| def at_object_leave(self, character, target_location):
"""
This is triggered when the player leaves the bridge room.
"""
if character.has_account:
# clean up the position attribute
del character.db.tutorial_bridge_position | [
"def",
"at_object_leave",
"(",
"self",
",",
"character",
",",
"target_location",
")",
":",
"if",
"character",
".",
"has_account",
":",
"# clean up the position attribute",
"del",
"character",
".",
"db",
".",
"tutorial_bridge_position"
] | [
684,
4
] | [
690,
53
] | python | en | ['en', 'error', 'th'] | False |
CmdLookDark.func | (self) |
Implement the command.
This works both as a look and a search command; there is a
random chance of eventually finding a light source.
|
Implement the command. | def func(self):
"""
Implement the command.
This works both as a look and a search command; there is a
random chance of eventually finding a light source.
"""
caller = self.caller
# count how many searches we've done
nr_searches = caller.ndb.dark_searches... | [
"def",
"func",
"(",
"self",
")",
":",
"caller",
"=",
"self",
".",
"caller",
"# count how many searches we've done",
"nr_searches",
"=",
"caller",
".",
"ndb",
".",
"dark_searches",
"if",
"nr_searches",
"is",
"None",
":",
"nr_searches",
"=",
"0",
"caller",
".",
... | [
740,
4
] | [
767,
45
] | python | en | ['en', 'error', 'th'] | False |
CmdDarkHelp.func | (self) |
Replace the the help command with a not-so-useful help
|
Replace the the help command with a not-so-useful help
| def func(self):
"""
Replace the the help command with a not-so-useful help
"""
string = "Can't help you until you find some light! Try looking/feeling around for something to burn. " \
"You shouldn't give up even if you don't find anything right away."
self.calle... | [
"def",
"func",
"(",
"self",
")",
":",
"string",
"=",
"\"Can't help you until you find some light! Try looking/feeling around for something to burn. \"",
"\"You shouldn't give up even if you don't find anything right away.\"",
"self",
".",
"caller",
".",
"msg",
"(",
"string",
")"
] | [
778,
4
] | [
784,
31
] | python | en | ['en', 'error', 'th'] | False |
CmdDarkNoMatch.func | (self) | Implements the command. | Implements the command. | def func(self):
"""Implements the command."""
self.caller.msg("Until you find some light, there's not much you can do. "
"Try feeling around, maybe you'll find something helpful!") | [
"def",
"func",
"(",
"self",
")",
":",
"self",
".",
"caller",
".",
"msg",
"(",
"\"Until you find some light, there's not much you can do. \"",
"\"Try feeling around, maybe you'll find something helpful!\"",
")"
] | [
798,
4
] | [
801,
83
] | python | en | ['en', 'en', 'en'] | True |
DarkCmdSet.at_cmdset_creation | (self) | populate the cmdset. | populate the cmdset. | def at_cmdset_creation(self):
"""populate the cmdset."""
self.add(CmdTutorial())
self.add(CmdLookDark())
self.add(CmdDarkHelp())
self.add(CmdDarkNoMatch())
self.add(default_cmds.CmdSay())
self.add(default_cmds.CmdQuit())
self.add(default_cmds.CmdHome()) | [
"def",
"at_cmdset_creation",
"(",
"self",
")",
":",
"self",
".",
"add",
"(",
"CmdTutorial",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdLookDark",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdDarkHelp",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdDa... | [
818,
4
] | [
826,
40
] | python | en | ['en', 'zh', 'en'] | True |
DarkRoom.at_object_creation | (self) |
Called when object is first created.
|
Called when object is first created.
| def at_object_creation(self):
"""
Called when object is first created.
"""
super(DarkRoom, self).at_object_creation()
self.db.tutorial_info = "This is a room with custom command sets on itself."
# the room starts dark.
self.db.is_lit = False
self.cmdset.ad... | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"super",
"(",
"DarkRoom",
",",
"self",
")",
".",
"at_object_creation",
"(",
")",
"self",
".",
"db",
".",
"tutorial_info",
"=",
"\"This is a room with custom command sets on itself.\"",
"# the room starts dark.",
"sel... | [
844,
4
] | [
852,
51
] | python | en | ['en', 'error', 'th'] | False |
DarkRoom.at_init | (self) |
Called when room is first recached (such as after a reload)
|
Called when room is first recached (such as after a reload)
| def at_init(self):
"""
Called when room is first recached (such as after a reload)
"""
self.check_light_state() | [
"def",
"at_init",
"(",
"self",
")",
":",
"self",
".",
"check_light_state",
"(",
")"
] | [
854,
4
] | [
858,
32
] | python | en | ['en', 'error', 'th'] | False |
DarkRoom._carries_light | (self, obj) |
Checks if the given object carries anything that gives light.
Note that we do NOT look for a specific LightSource typeclass,
but for the Attribute is_giving_light - this makes it easy to
later add other types of light-giving items. We also accept
if there is a light-giving obje... |
Checks if the given object carries anything that gives light. | def _carries_light(self, obj):
"""
Checks if the given object carries anything that gives light.
Note that we do NOT look for a specific LightSource typeclass,
but for the Attribute is_giving_light - this makes it easy to
later add other types of light-giving items. We also acce... | [
"def",
"_carries_light",
"(",
"self",
",",
"obj",
")",
":",
"return",
"obj",
".",
"is_superuser",
"or",
"obj",
".",
"db",
".",
"is_giving_light",
"or",
"any",
"(",
"o",
"for",
"o",
"in",
"obj",
".",
"contents",
"if",
"o",
".",
"db",
".",
"is_giving_l... | [
860,
4
] | [
870,
113
] | python | en | ['en', 'error', 'th'] | False |
DarkRoom._heal | (self, character) |
Heal a character.
|
Heal a character.
| def _heal(self, character):
"""
Heal a character.
"""
health = character.db.health_max or 20
character.db.health = health | [
"def",
"_heal",
"(",
"self",
",",
"character",
")",
":",
"health",
"=",
"character",
".",
"db",
".",
"health_max",
"or",
"20",
"character",
".",
"db",
".",
"health",
"=",
"health"
] | [
872,
4
] | [
877,
36
] | python | en | ['en', 'error', 'th'] | False |
DarkRoom.check_light_state | (self, exclude=None) |
This method checks if there are any light sources in the room.
If there isn't it makes sure to add the dark cmdset to all
characters in the room. It is called whenever characters enter
the room and also by the Light sources when they turn on.
Args:
exclude (Object):... |
This method checks if there are any light sources in the room.
If there isn't it makes sure to add the dark cmdset to all
characters in the room. It is called whenever characters enter
the room and also by the Light sources when they turn on. | def check_light_state(self, exclude=None):
"""
This method checks if there are any light sources in the room.
If there isn't it makes sure to add the dark cmdset to all
characters in the room. It is called whenever characters enter
the room and also by the Light sources when they... | [
"def",
"check_light_state",
"(",
"self",
",",
"exclude",
"=",
"None",
")",
":",
"if",
"any",
"(",
"self",
".",
"_carries_light",
"(",
"obj",
")",
"for",
"obj",
"in",
"self",
".",
"contents",
"if",
"obj",
"!=",
"exclude",
")",
":",
"self",
".",
"locks... | [
879,
4
] | [
906,
60
] | python | en | ['en', 'error', 'th'] | False |
DarkRoom.at_object_receive | (self, obj, source_location) |
Called when an object enters the room.
|
Called when an object enters the room.
| def at_object_receive(self, obj, source_location):
"""
Called when an object enters the room.
"""
if obj.has_account:
# a puppeted object, that is, a Character
self._heal(obj)
# in case the new guy carries light with them
self.check_light_s... | [
"def",
"at_object_receive",
"(",
"self",
",",
"obj",
",",
"source_location",
")",
":",
"if",
"obj",
".",
"has_account",
":",
"# a puppeted object, that is, a Character",
"self",
".",
"_heal",
"(",
"obj",
")",
"# in case the new guy carries light with them",
"self",
".... | [
908,
4
] | [
916,
36
] | python | en | ['en', 'error', 'th'] | False |
DarkRoom.at_object_leave | (self, obj, target_location) |
In case people leave with the light, we make sure to clear the
DarkCmdSet if necessary. This also works if they are
teleported away.
|
In case people leave with the light, we make sure to clear the
DarkCmdSet if necessary. This also works if they are
teleported away.
| def at_object_leave(self, obj, target_location):
"""
In case people leave with the light, we make sure to clear the
DarkCmdSet if necessary. This also works if they are
teleported away.
"""
# since this hook is called while the object is still in the room,
# we e... | [
"def",
"at_object_leave",
"(",
"self",
",",
"obj",
",",
"target_location",
")",
":",
"# since this hook is called while the object is still in the room,",
"# we exclude it from the light check, to ignore any light sources",
"# it may be carrying.",
"self",
".",
"check_light_state",
"... | [
918,
4
] | [
927,
43
] | python | en | ['en', 'error', 'th'] | False |
TeleportRoom.at_object_creation | (self) | Called at first creation | Called at first creation | def at_object_creation(self):
"""Called at first creation"""
super(TeleportRoom, self).at_object_creation()
# what character.db.puzzle_clue must be set to, to avoid teleportation.
self.db.puzzle_value = 1
# target of successful teleportation. Can be a dbref or a
# unique ... | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"super",
"(",
"TeleportRoom",
",",
"self",
")",
".",
"at_object_creation",
"(",
")",
"# what character.db.puzzle_clue must be set to, to avoid teleportation.",
"self",
".",
"db",
".",
"puzzle_value",
"=",
"1",
"# tar... | [
960,
4
] | [
971,
49
] | python | en | ['en', 'en', 'en'] | True |
TeleportRoom.at_object_receive | (self, character, source_location) |
This hook is called by the engine whenever the player is moved into
this room.
|
This hook is called by the engine whenever the player is moved into
this room.
| def at_object_receive(self, character, source_location):
"""
This hook is called by the engine whenever the player is moved into
this room.
"""
if not character.has_account:
# only act on player characters.
return
# determine if the puzzle is a suc... | [
"def",
"at_object_receive",
"(",
"self",
",",
"character",
",",
"source_location",
")",
":",
"if",
"not",
"character",
".",
"has_account",
":",
"# only act on player characters.",
"return",
"# determine if the puzzle is a success or not",
"is_success",
"=",
"str",
"(",
... | [
973,
4
] | [
1004,
53
] | python | en | ['en', 'error', 'th'] | False |
OutroRoom.at_object_creation | (self) |
Called when the room is first created.
|
Called when the room is first created.
| def at_object_creation(self):
"""
Called when the room is first created.
"""
super(OutroRoom, self).at_object_creation()
self.db.tutorial_info = "The last room of the tutorial. " \
"This cleans up all temporary Attributes " \
... | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"super",
"(",
"OutroRoom",
",",
"self",
")",
".",
"at_object_creation",
"(",
")",
"self",
".",
"db",
".",
"tutorial_info",
"=",
"\"The last room of the tutorial. \"",
"\"This cleans up all temporary Attributes \"",
"... | [
1024,
4
] | [
1032,
44
] | python | en | ['en', 'error', 'th'] | False |
OutroRoom.at_object_receive | (self, character, source_location) |
Do cleanup.
|
Do cleanup.
| def at_object_receive(self, character, source_location):
"""
Do cleanup.
"""
if character.has_account:
del character.db.health_max
del character.db.health
del character.db.last_climbed
del character.db.puzzle_clue
del character.... | [
"def",
"at_object_receive",
"(",
"self",
",",
"character",
",",
"source_location",
")",
":",
"if",
"character",
".",
"has_account",
":",
"del",
"character",
".",
"db",
".",
"health_max",
"del",
"character",
".",
"db",
".",
"health",
"del",
"character",
".",
... | [
1034,
4
] | [
1048,
59
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... | def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A name... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
63,
28
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... | def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
72,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf] | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
"""
return self["size"] | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
103,
4
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Tickfont object
Sets the color bar's tick label font
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.streamtube.colorbar.Tickfont`
colo... |
Construct a new Tickfont object
Sets the color bar's tick label font | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Tickfont object
Sets the color bar's tick label font
Parameters
----------
arg
dict of properties compatible with this constructor or
an insta... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Tickfont",
",",
"self",
")",
".",
"__init__",
"(",
"\"tick... | [
143,
4
] | [
226,
34
] | python | en | ['en', 'error', 'th'] | False |
CandidateBaseTeacher.__init__ | (
self,
opt: Opt,
shared: dict = None,
vocab_size: int = VOCAB_SIZE,
example_size: int = EXAMPLE_SIZE,
num_candidates: int = NUM_CANDIDATES,
num_train: int = NUM_TRAIN,
num_test: int = NUM_TEST,
) |
:param int vocab_size:
size of the vocabulary
:param int example_size:
length of each example
:param int num_candidates:
number of label_candidates generated
:param int num_train:
size of the training set
:param int num_test:
... |
:param int vocab_size:
size of the vocabulary
:param int example_size:
length of each example
:param int num_candidates:
number of label_candidates generated
:param int num_train:
size of the training set
:param int num_test:
... | def __init__(
self,
opt: Opt,
shared: dict = None,
vocab_size: int = VOCAB_SIZE,
example_size: int = EXAMPLE_SIZE,
num_candidates: int = NUM_CANDIDATES,
num_train: int = NUM_TRAIN,
num_test: int = NUM_TEST,
):
"""
:param int vocab_size:... | [
"def",
"__init__",
"(",
"self",
",",
"opt",
":",
"Opt",
",",
"shared",
":",
"dict",
"=",
"None",
",",
"vocab_size",
":",
"int",
"=",
"VOCAB_SIZE",
",",
"example_size",
":",
"int",
"=",
"EXAMPLE_SIZE",
",",
"num_candidates",
":",
"int",
"=",
"NUM_CANDIDAT... | [
51,
4
] | [
85,
37
] | python | en | ['en', 'error', 'th'] | False |
CandidateBaseTeacher.build_corpus | (self) |
Build corpus; override for customization.
|
Build corpus; override for customization.
| def build_corpus(self):
"""
Build corpus; override for customization.
"""
return [list(x) for x in itertools.permutations(self.words, self.example_size)] | [
"def",
"build_corpus",
"(",
"self",
")",
":",
"return",
"[",
"list",
"(",
"x",
")",
"for",
"x",
"in",
"itertools",
".",
"permutations",
"(",
"self",
".",
"words",
",",
"self",
".",
"example_size",
")",
"]"
] | [
87,
4
] | [
91,
87
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogCandidateTeacher.__init__ | (self, *args, **kwargs) |
Override to build candidates.
|
Override to build candidates.
| def __init__(self, *args, **kwargs):
"""
Override to build candidates.
"""
super().__init__(*args, **kwargs)
opt = args[0]
if 'shared' not in kwargs:
self._setup_data(opt['datatype'].split(':')[0])
self._build_candidates()
else:
... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"opt",
"=",
"args",
"[",
"0",
"]",
"if",
"'shared'",
"not",
"in",
"kwargs",... | [
140,
4
] | [
153,
20
] | python | en | ['en', 'error', 'th'] | False |
RepeatWordsTeacher.build_corpus | (self) |
Override to repeat words.
|
Override to repeat words.
| def build_corpus(self):
"""
Override to repeat words.
"""
return [
[x for _ in range(l)]
for l in range(1, self.example_size)
for x in self.words
] | [
"def",
"build_corpus",
"(",
"self",
")",
":",
"return",
"[",
"[",
"x",
"for",
"_",
"in",
"range",
"(",
"l",
")",
"]",
"for",
"l",
"in",
"range",
"(",
"1",
",",
"self",
".",
"example_size",
")",
"for",
"x",
"in",
"self",
".",
"words",
"]"
] | [
323,
4
] | [
331,
9
] | python | en | ['en', 'error', 'th'] | False |
ImageTeacher.get_image_features_path | (self, task, image_model_name, dt) |
Return path dummy image features.
|
Return path dummy image features.
| def get_image_features_path(self, task, image_model_name, dt):
"""
Return path dummy image features.
"""
return self.image_features_path | [
"def",
"get_image_features_path",
"(",
"self",
",",
"task",
",",
"image_model_name",
",",
"dt",
")",
":",
"return",
"self",
".",
"image_features_path"
] | [
416,
4
] | [
420,
39
] | python | en | ['en', 'error', 'th'] | False |
ImageTeacher.image_id_to_image_path | (self, image_id) |
Return path to image on disk.
|
Return path to image on disk.
| def image_id_to_image_path(self, image_id):
"""
Return path to image on disk.
"""
return os.path.join(
self.opt['datapath'], 'ImageTeacher/images', f'{image_id}.jpg'
) | [
"def",
"image_id_to_image_path",
"(",
"self",
",",
"image_id",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opt",
"[",
"'datapath'",
"]",
",",
"'ImageTeacher/images'",
",",
"f'{image_id}.jpg'",
")"
] | [
422,
4
] | [
428,
9
] | python | en | ['en', 'error', 'th'] | False |
Marker.color | (self) |
Sets the marker color of selected points.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%... |
Sets the marker color of selected points.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%... | def color(self):
"""
Sets the marker color of selected points.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/h... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
65,
28
] | python | en | ['en', 'error', 'th'] | False |
Marker.opacity | (self) |
Sets the marker opacity of selected points.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
|
Sets the marker opacity of selected points.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1] | def opacity(self):
"""
Sets the marker opacity of selected points.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
"""
return self["opacity"] | [
"def",
"opacity",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"opacity\"",
"]"
] | [
74,
4
] | [
85,
30
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.