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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
precision_recall_curve | (
preds: torch.Tensor,
target: torch.Tensor,
num_classes: Optional[int] = None,
pos_label: Optional[int] = None,
sample_weights: Optional[Sequence] = None,
) |
Computes precision-recall pairs for different thresholds.
Args:
preds: predictions from model (probabilities)
target: ground truth labels
num_classes: integer with number of classes. Not nessesary to provide
for binary problems.
pos_label: integer determining the po... |
Computes precision-recall pairs for different thresholds. | def precision_recall_curve(
preds: torch.Tensor,
target: torch.Tensor,
num_classes: Optional[int] = None,
pos_label: Optional[int] = None,
sample_weights: Optional[Sequence] = None,
) -> Union[Tuple[torch.Tensor, torch.Tensor, torch.Tensor], Tuple[List[torch.Tensor], List[torch.Tensor],
... | [
"def",
"precision_recall_curve",
"(",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"num_classes",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"pos_label",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
... | [
150,
0
] | [
217,
97
] | python | en | ['en', 'error', 'th'] | False |
align | (stack, **kwargs) |
Use these keyword arguments:
algorithm={"ecc"}
roi: defines a ROI, which can be any shape (circle, rectangle...).
Defaults to 15% rectangular cutoff
for ecc:
trafo={"translation","rigid","affine"} (default=translation)
max_iter=int maximum iterations, default: 500
e... |
Use these keyword arguments:
algorithm={"ecc"}
roi: defines a ROI, which can be any shape (circle, rectangle...).
Defaults to 15% rectangular cutoff
for ecc:
trafo={"translation","rigid","affine"} (default=translation)
max_iter=int maximum iterations, default: 500
e... | def align(stack, **kwargs):
"""
Use these keyword arguments:
algorithm={"ecc"}
roi: defines a ROI, which can be any shape (circle, rectangle...).
Defaults to 15% rectangular cutoff
for ecc:
trafo={"translation","rigid","affine"} (default=translation)
max_iter=int maximum... | [
"def",
"align",
"(",
"stack",
",",
"*",
"*",
"kwargs",
")",
":",
"stack",
"=",
"stackify",
"(",
"stack",
")",
"alignment",
"=",
"find_alignment_matrices",
"(",
"stack",
",",
"*",
"*",
"kwargs",
")",
"stack",
"=",
"apply_alignment_matrices",
"(",
"stack",
... | [
59,
0
] | [
76,
27
] | python | en | ['en', 'error', 'th'] | False |
test_against_sklearn | (similarity, reduction) | Compare PL metrics to sklearn version. | Compare PL metrics to sklearn version. | def test_against_sklearn(similarity, reduction):
"""Compare PL metrics to sklearn version."""
device = 'cuda' if torch.cuda.is_available() else 'cpu'
batch = torch.randn(5, 10, device=device) # 100 samples in 10 dimensions
pl_dist = embedding_similarity(batch, similarity=similarity, reduction=reducti... | [
"def",
"test_against_sklearn",
"(",
"similarity",
",",
"reduction",
")",
":",
"device",
"=",
"'cuda'",
"if",
"torch",
".",
"cuda",
".",
"is_available",
"(",
")",
"else",
"'cpu'",
"batch",
"=",
"torch",
".",
"randn",
"(",
"5",
",",
"10",
",",
"device",
... | [
9,
0
] | [
31,
43
] | python | en | ['en', 'en', 'en'] | True |
single_gpu_test | (model, data_loader) | Test model with a single gpu.
This method tests model with a single gpu and displays test progress bar.
Args:
model (nn.Module): Model to be tested.
data_loader (nn.Dataloader): Pytorch data loader.
Returns:
list: The prediction results.
| Test model with a single gpu. | def single_gpu_test(model, data_loader):
"""Test model with a single gpu.
This method tests model with a single gpu and displays test progress bar.
Args:
model (nn.Module): Model to be tested.
data_loader (nn.Dataloader): Pytorch data loader.
Returns:
list: The prediction res... | [
"def",
"single_gpu_test",
"(",
"model",
",",
"data_loader",
")",
":",
"model",
".",
"eval",
"(",
")",
"results",
"=",
"[",
"]",
"dataset",
"=",
"data_loader",
".",
"dataset",
"prog_bar",
"=",
"mmcv",
".",
"ProgressBar",
"(",
"len",
"(",
"dataset",
")",
... | [
11,
0
] | [
38,
18
] | python | en | ['en', 'haw', 'en'] | True |
multi_gpu_test | (model, data_loader, tmpdir=None, gpu_collect=False) | Test model with multiple gpus.
This method tests model with multiple gpus and collects the results
under two different modes: gpu and cpu modes. By setting 'gpu_collect=True'
it encodes results to gpu tensors and use gpu communication for results
collection. On cpu mode it saves the results on differen... | Test model with multiple gpus. | def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False):
"""Test model with multiple gpus.
This method tests model with multiple gpus and collects the results
under two different modes: gpu and cpu modes. By setting 'gpu_collect=True'
it encodes results to gpu tensors and use gpu communi... | [
"def",
"multi_gpu_test",
"(",
"model",
",",
"data_loader",
",",
"tmpdir",
"=",
"None",
",",
"gpu_collect",
"=",
"False",
")",
":",
"model",
".",
"eval",
"(",
")",
"results",
"=",
"[",
"]",
"dataset",
"=",
"data_loader",
".",
"dataset",
"rank",
",",
"wo... | [
41,
0
] | [
82,
18
] | python | en | ['en', 'en', 'en'] | True |
collect_results_cpu | (result_part, size, tmpdir=None) | Collect results in cpu mode.
It saves the results on different gpus to 'tmpdir' and collects
them by the rank 0 worker.
Args:
result_part (list): Results to be collected
size (int): Result size.
tmpdir (str): Path of directory to save the temporary results from
differen... | Collect results in cpu mode. | def collect_results_cpu(result_part, size, tmpdir=None):
"""Collect results in cpu mode.
It saves the results on different gpus to 'tmpdir' and collects
them by the rank 0 worker.
Args:
result_part (list): Results to be collected
size (int): Result size.
tmpdir (str): Path of d... | [
"def",
"collect_results_cpu",
"(",
"result_part",
",",
"size",
",",
"tmpdir",
"=",
"None",
")",
":",
"rank",
",",
"world_size",
"=",
"get_dist_info",
"(",
")",
"# create a tmp dir if it is not specified",
"if",
"tmpdir",
"is",
"None",
":",
"MAX_LEN",
"=",
"512",... | [
85,
0
] | [
138,
26
] | python | en | ['en', 'en', 'en'] | True |
collect_results_gpu | (result_part, size) | Collect results in gpu mode.
It encodes results to gpu tensors and use gpu communication for results
collection.
Args:
result_part (list): Results to be collected
size (int): Result size.
Returns:
list: Ordered results.
| Collect results in gpu mode. | def collect_results_gpu(result_part, size):
"""Collect results in gpu mode.
It encodes results to gpu tensors and use gpu communication for results
collection.
Args:
result_part (list): Results to be collected
size (int): Result size.
Returns:
list: Ordered results.
""... | [
"def",
"collect_results_gpu",
"(",
"result_part",
",",
"size",
")",
":",
"rank",
",",
"world_size",
"=",
"get_dist_info",
"(",
")",
"# dump result part to tensor with pickle",
"part_tensor",
"=",
"torch",
".",
"tensor",
"(",
"bytearray",
"(",
"pickle",
".",
"dumps... | [
141,
0
] | [
185,
15
] | python | en | ['en', 'en', 'en'] | True |
HumanPoseDetectionStub.__init__ | (self, channel) | Constructor.
Args:
channel: A grpc.Channel.
| Constructor. | def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.Ping = channel.unary_unary(
'/com.porsche.realtery.humanpose.HumanPoseDetection/Ping',
request_serializer=hp3d_dot_rpc_dot_human__pose__detection__service__pb... | [
"def",
"__init__",
"(",
"self",
",",
"channel",
")",
":",
"self",
".",
"Ping",
"=",
"channel",
".",
"unary_unary",
"(",
"'/com.porsche.realtery.humanpose.HumanPoseDetection/Ping'",
",",
"request_serializer",
"=",
"hp3d_dot_rpc_dot_human__pose__detection__service__pb2",
".",... | [
10,
4
] | [
35,
17
] | python | en | ['en', 'en', 'en'] | False |
HumanPoseDetectionServicer.Ping | (self, request, context) | Missing associated documentation comment in .proto file. | Missing associated documentation comment in .proto file. | def Ping(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"Ping",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedError",
"... | [
41,
4
] | [
45,
60
] | python | en | ['en', 'en', 'en'] | True |
HumanPoseDetectionServicer.StartSession | (self, request, context) | Missing associated documentation comment in .proto file. | Missing associated documentation comment in .proto file. | def StartSession(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"StartSession",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErr... | [
47,
4
] | [
51,
60
] | python | en | ['en', 'en', 'en'] | True |
HumanPoseDetectionServicer.Detect | (self, request, context) | Missing associated documentation comment in .proto file. | Missing associated documentation comment in .proto file. | def Detect(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"Detect",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedError",
... | [
53,
4
] | [
57,
60
] | python | en | ['en', 'en', 'en'] | True |
HumanPoseDetectionServicer.StopSession | (self, request, context) | Missing associated documentation comment in .proto file. | Missing associated documentation comment in .proto file. | def StopSession(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"StopSession",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErro... | [
59,
4
] | [
63,
60
] | python | en | ['en', 'en', 'en'] | True |
TestcaseController.__init__ | (self,
path_to_tc_table,
adp_sock,
ctrl_reg,
logger=False,
tcs_to_run_path = None
) | Constructor
| Constructor
| def __init__(self,
path_to_tc_table,
adp_sock,
ctrl_reg,
logger=False,
tcs_to_run_path = None
):
""" Constructor
"""
self._logger = logger or logging.getLogger(__name__)
self._logger.info("Initialising Testcase_Contr... | [
"def",
"__init__",
"(",
"self",
",",
"path_to_tc_table",
",",
"adp_sock",
",",
"ctrl_reg",
",",
"logger",
"=",
"False",
",",
"tcs_to_run_path",
"=",
"None",
")",
":",
"self",
".",
"_logger",
"=",
"logger",
"or",
"logging",
".",
"getLogger",
"(",
"__name__"... | [
49,
4
] | [
65,
49
] | python | en | ['en', 'en', 'pt'] | False |
TestcaseController.tcs_to_run | (self) | Returns the list of testcases to run, one-after-another (if set)
:return: The testcases list to be run
:rtype: list containing str elements
| Returns the list of testcases to run, one-after-another (if set)
:return: The testcases list to be run
:rtype: list containing str elements
| def tcs_to_run(self):
"""Returns the list of testcases to run, one-after-another (if set)
:return: The testcases list to be run
:rtype: list containing str elements
"""
return self._tcs_to_run | [
"def",
"tcs_to_run",
"(",
"self",
")",
":",
"return",
"self",
".",
"_tcs_to_run"
] | [
82,
4
] | [
88,
31
] | python | en | ['en', 'en', 'en'] | True |
TestcaseController.get_testcase_list | (self) | Returns the names of the testcases in the testcase database (e.g. loaded from the testcase-list.csv)
:return List of testcases in the embedded software that can be run
| Returns the names of the testcases in the testcase database (e.g. loaded from the testcase-list.csv) | def get_testcase_list(self):
"""Returns the names of the testcases in the testcase database (e.g. loaded from the testcase-list.csv)
:return List of testcases in the embedded software that can be run
"""
return self._db['data']['Testcase_Enum'] | [
"def",
"get_testcase_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_db",
"[",
"'data'",
"]",
"[",
"'Testcase_Enum'",
"]"
] | [
90,
4
] | [
95,
48
] | python | en | ['en', 'en', 'en'] | True |
TestcaseController.get_testcase_id | (self,name) | Gets the ID of a testcase from its name. This is what is sent to the chip to command it to run the testcase. Derived from the position of the testcase in the testcase list.
:param name: Name of the testcase (e.g. "HELLO", "EN_D_SLEEP") to find the ID of
:type name: str
:return: The ID
... | Gets the ID of a testcase from its name. This is what is sent to the chip to command it to run the testcase. Derived from the position of the testcase in the testcase list. | def get_testcase_id(self,name):
"""Gets the ID of a testcase from its name. This is what is sent to the chip to command it to run the testcase. Derived from the position of the testcase in the testcase list.
:param name: Name of the testcase (e.g. "HELLO", "EN_D_SLEEP") to find the ID of
:type... | [
"def",
"get_testcase_id",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"_db",
"[",
"'data'",
"]",
"[",
"'Testcase_Enum'",
"]",
".",
"index",
"(",
"name",
")"
] | [
97,
4
] | [
105,
60
] | python | en | ['en', 'en', 'en'] | True |
TestcaseController.set_wakeup_testcase | (self,tc,repeat_delay=None) | Sets a testcase to be executed after wakeup (requires specific embedded software support and is for internal testing only)
| Sets a testcase to be executed after wakeup (requires specific embedded software support and is for internal testing only)
| def set_wakeup_testcase(self,tc,repeat_delay=None):
""" Sets a testcase to be executed after wakeup (requires specific embedded software support and is for internal testing only)
"""
if not isinstance(tc,str):
raise ValueError("Testcase name must be a string")
if not repeat_d... | [
"def",
"set_wakeup_testcase",
"(",
"self",
",",
"tc",
",",
"repeat_delay",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"tc",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"\"Testcase name must be a string\"",
")",
"if",
"not",
"repeat_delay",
... | [
115,
4
] | [
142,
9
] | python | en | ['en', 'en', 'en'] | True |
TestcaseController.run_testcase | (
self,
tc,
wait_for_output=None,
regex_funcs=[regex_lib.testcase_result_decode],
measure_funcs=None,
repeat_delay=None,
timeout=1) | Commands a specific testcase in the embedded software in the chip to run a testcase (the embedded software must be waiting in a specific "wait_for_adp" loop to receive this command)
:param tc: The name of the testcase to run, or the ID of the testcase to run
:type tc: str, int
:param wait_for_o... | Commands a specific testcase in the embedded software in the chip to run a testcase (the embedded software must be waiting in a specific "wait_for_adp" loop to receive this command) | def run_testcase(
self,
tc,
wait_for_output=None,
regex_funcs=[regex_lib.testcase_result_decode],
measure_funcs=None,
repeat_delay=None,
timeout=1):
"""Commands a specific testcase in the embedded sof... | [
"def",
"run_testcase",
"(",
"self",
",",
"tc",
",",
"wait_for_output",
"=",
"None",
",",
"regex_funcs",
"=",
"[",
"regex_lib",
".",
"testcase_result_decode",
"]",
",",
"measure_funcs",
"=",
"None",
",",
"repeat_delay",
"=",
"None",
",",
"timeout",
"=",
"1",
... | [
147,
4
] | [
273,
18
] | python | en | ['en', 'en', 'en'] | True |
XLADeviceUtils._fetch_xla_device_type | (device: torch.device) |
Returns XLA device type
Args:
device: (:class:`~torch.device`): Accepts a torch.device type with a XLA device format i.e xla:0
Return:
Returns a str of the device hardware type. i.e TPU
|
Returns XLA device type | def _fetch_xla_device_type(device: torch.device) -> str:
"""
Returns XLA device type
Args:
device: (:class:`~torch.device`): Accepts a torch.device type with a XLA device format i.e xla:0
Return:
Returns a str of the device hardware type. i.e TPU
"""
... | [
"def",
"_fetch_xla_device_type",
"(",
"device",
":",
"torch",
".",
"device",
")",
"->",
"str",
":",
"if",
"_XLA_AVAILABLE",
":",
"return",
"xm",
".",
"xla_device_hw",
"(",
"device",
")"
] | [
60,
4
] | [
71,
43
] | python | en | ['en', 'error', 'th'] | False |
XLADeviceUtils._is_device_tpu | () |
Check if device is TPU
Return:
A boolean value indicating if the xla device is a TPU device or not
|
Check if device is TPU | def _is_device_tpu() -> bool:
"""
Check if device is TPU
Return:
A boolean value indicating if the xla device is a TPU device or not
"""
if _XLA_AVAILABLE:
device = xm.xla_device()
device_type = XLADeviceUtils._fetch_xla_device_type(device)
... | [
"def",
"_is_device_tpu",
"(",
")",
"->",
"bool",
":",
"if",
"_XLA_AVAILABLE",
":",
"device",
"=",
"xm",
".",
"xla_device",
"(",
")",
"device_type",
"=",
"XLADeviceUtils",
".",
"_fetch_xla_device_type",
"(",
"device",
")",
"return",
"device_type",
"==",
"\"TPU\... | [
74,
4
] | [
84,
39
] | python | en | ['en', 'error', 'th'] | False |
XLADeviceUtils.xla_available | () |
Check if XLA library is installed
Return:
A boolean value indicating if a XLA is installed
|
Check if XLA library is installed | def xla_available() -> bool:
"""
Check if XLA library is installed
Return:
A boolean value indicating if a XLA is installed
"""
return _XLA_AVAILABLE | [
"def",
"xla_available",
"(",
")",
"->",
"bool",
":",
"return",
"_XLA_AVAILABLE"
] | [
87,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
XLADeviceUtils.tpu_device_exists | () |
Runs XLA device check within a separate process
Return:
A boolean value indicating if a TPU device exists on the system
|
Runs XLA device check within a separate process | def tpu_device_exists() -> bool:
"""
Runs XLA device check within a separate process
Return:
A boolean value indicating if a TPU device exists on the system
"""
if XLADeviceUtils.TPU_AVAILABLE is None and _XLA_AVAILABLE:
XLADeviceUtils.TPU_AVAILABLE = pl_... | [
"def",
"tpu_device_exists",
"(",
")",
"->",
"bool",
":",
"if",
"XLADeviceUtils",
".",
"TPU_AVAILABLE",
"is",
"None",
"and",
"_XLA_AVAILABLE",
":",
"XLADeviceUtils",
".",
"TPU_AVAILABLE",
"=",
"pl_multi_process",
"(",
"XLADeviceUtils",
".",
"_is_device_tpu",
")",
"... | [
97,
4
] | [
106,
43
] | python | en | ['en', 'error', 'th'] | False |
modify_envoy_config | (config_path, perf, output_directory) | Modify Envoy config to support gathering logs, etc.
Args:
config_path: the command-line specified Envoy config path.
perf: boolean indicating whether in performance mode.
output_directory: directory path for additional generated files.
Returns:
(modified Envoy config path, list ... | Modify Envoy config to support gathering logs, etc. | def modify_envoy_config(config_path, perf, output_directory):
"""Modify Envoy config to support gathering logs, etc.
Args:
config_path: the command-line specified Envoy config path.
perf: boolean indicating whether in performance mode.
output_directory: directory path for additional gen... | [
"def",
"modify_envoy_config",
"(",
"config_path",
",",
"perf",
",",
"output_directory",
")",
":",
"# No modifications yet when in performance profiling mode.",
"if",
"perf",
":",
"return",
"config_path",
",",
"[",
"]",
"# Load original Envoy config.",
"with",
"open",
"(",... | [
65,
0
] | [
102,
55
] | python | en | ['en', 'en', 'en'] | True |
run_envoy | (envoy_shcmd_args, envoy_log_path, admin_address_path, dump_handlers_paths) | Run Envoy subprocess and trigger admin endpoint gathering on SIGINT.
Args:
envoy_shcmd_args: list of Envoy subprocess args.
envoy_log_path: path to write Envoy stderr log to.
admin_address_path: path to where admin address is written by Envoy.
dump_handlers_paths: map from admin end... | Run Envoy subprocess and trigger admin endpoint gathering on SIGINT. | def run_envoy(envoy_shcmd_args, envoy_log_path, admin_address_path, dump_handlers_paths):
"""Run Envoy subprocess and trigger admin endpoint gathering on SIGINT.
Args:
envoy_shcmd_args: list of Envoy subprocess args.
envoy_log_path: path to write Envoy stderr log to.
admin_address_path:... | [
"def",
"run_envoy",
"(",
"envoy_shcmd_args",
",",
"envoy_log_path",
",",
"admin_address_path",
",",
"dump_handlers_paths",
")",
":",
"envoy_shcmd",
"=",
"' '",
".",
"join",
"(",
"map",
"(",
"pipes",
".",
"quote",
",",
"envoy_shcmd_args",
")",
")",
"print",
"("... | [
105,
0
] | [
149,
32
] | python | en | ['en', 'en', 'en'] | True |
envoy_collect | (parse_result, unknown_args) | Run Envoy and collect its artifacts.
Args:
parse_result: Namespace object with envoy_collect.py's args.
unknown_args: list of remaining args to pass to Envoy binary.
| Run Envoy and collect its artifacts. | def envoy_collect(parse_result, unknown_args):
"""Run Envoy and collect its artifacts.
Args:
parse_result: Namespace object with envoy_collect.py's args.
unknown_args: list of remaining args to pass to Envoy binary.
"""
# Are we in performance mode? Otherwise, debug.
perf = parse_re... | [
"def",
"envoy_collect",
"(",
"parse_result",
",",
"unknown_args",
")",
":",
"# Are we in performance mode? Otherwise, debug.",
"perf",
"=",
"parse_result",
".",
"performance",
"return_code",
"=",
"1",
"# Non-zero default return.",
"envoy_tmpdir",
"=",
"tempfile",
".",
"mk... | [
152,
0
] | [
219,
22
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_val_dataloader | (tmpdir) | Verify multiple val_dataloader. | Verify multiple val_dataloader. | def test_multiple_val_dataloader(tmpdir):
"""Verify multiple val_dataloader."""
model = EvalModelTemplate()
model.val_dataloader = model.val_dataloader__multiple
model.validation_step = model.validation_step__multiple_dataloaders
model.validation_epoch_end = model.validation_epoch_end__multiple_dat... | [
"def",
"test_multiple_val_dataloader",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"val_dataloader",
"=",
"model",
".",
"val_dataloader__multiple",
"model",
".",
"validation_step",
"=",
"model",
".",
"validation_step__multiple_d... | [
106,
0
] | [
132,
93
] | python | en | ['en', 'no', 'en'] | True |
test_multiple_test_dataloader | (tmpdir, ckpt_path) | Verify multiple test_dataloader. | Verify multiple test_dataloader. | def test_multiple_test_dataloader(tmpdir, ckpt_path):
"""Verify multiple test_dataloader."""
model_template = EvalModelTemplate()
class MultipleTestDataloaderModel(EvalModelTemplate):
def test_dataloader(self):
return [self.dataloader(train=False), self.dataloader(train=False)]
... | [
"def",
"test_multiple_test_dataloader",
"(",
"tmpdir",
",",
"ckpt_path",
")",
":",
"model_template",
"=",
"EvalModelTemplate",
"(",
")",
"class",
"MultipleTestDataloaderModel",
"(",
"EvalModelTemplate",
")",
":",
"def",
"test_dataloader",
"(",
"self",
")",
":",
"ret... | [
136,
0
] | [
171,
37
] | python | en | ['en', 'no', 'en'] | True |
test_train_dataloader_passed_to_fit | (tmpdir) | Verify that train dataloader can be passed to fit | Verify that train dataloader can be passed to fit | def test_train_dataloader_passed_to_fit(tmpdir):
"""Verify that train dataloader can be passed to fit """
# only train passed to fit
model = EvalModelTemplate()
trainer = Trainer(
default_root_dir=tmpdir,
max_epochs=1,
limit_val_batches=0.1,
limit_train_batches=0.2,
... | [
"def",
"test_train_dataloader_passed_to_fit",
"(",
"tmpdir",
")",
":",
"# only train passed to fit",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"max_epochs",
"=",
"1",
",",
"limit_val_batches",
... | [
174,
0
] | [
188,
90
] | python | en | ['en', 'en', 'en'] | True |
test_train_val_dataloaders_passed_to_fit | (tmpdir) | Verify that train & val dataloader can be passed to fit | Verify that train & val dataloader can be passed to fit | def test_train_val_dataloaders_passed_to_fit(tmpdir):
""" Verify that train & val dataloader can be passed to fit """
# train, val passed to fit
model = EvalModelTemplate()
trainer = Trainer(
default_root_dir=tmpdir,
max_epochs=1,
limit_val_batches=0.1,
limit_train_batch... | [
"def",
"test_train_val_dataloaders_passed_to_fit",
"(",
"tmpdir",
")",
":",
"# train, val passed to fit",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"max_epochs",
"=",
"1",
",",
"limit_val_batch... | [
191,
0
] | [
207,
82
] | python | en | ['en', 'en', 'en'] | True |
test_all_dataloaders_passed_to_fit | (tmpdir, ckpt_path) | Verify train, val & test dataloader(s) can be passed to fit and test method | Verify train, val & test dataloader(s) can be passed to fit and test method | def test_all_dataloaders_passed_to_fit(tmpdir, ckpt_path):
"""Verify train, val & test dataloader(s) can be passed to fit and test method"""
model = EvalModelTemplate()
# train, val and test passed to fit
trainer = Trainer(
default_root_dir=tmpdir,
max_epochs=1,
limit_val_batch... | [
"def",
"test_all_dataloaders_passed_to_fit",
"(",
"tmpdir",
",",
"ckpt_path",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"# train, val and test passed to fit",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"max_epochs",
"=",
"1",
... | [
211,
0
] | [
235,
83
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_dataloaders_passed_to_fit | (tmpdir, ckpt_path) | Verify that multiple val & test dataloaders can be passed to fit. | Verify that multiple val & test dataloaders can be passed to fit. | def test_multiple_dataloaders_passed_to_fit(tmpdir, ckpt_path):
"""Verify that multiple val & test dataloaders can be passed to fit."""
model = EvalModelTemplate()
model.validation_step = model.validation_step__multiple_dataloaders
model.validation_epoch_end = model.validation_epoch_end__multiple_datal... | [
"def",
"test_multiple_dataloaders_passed_to_fit",
"(",
"tmpdir",
",",
"ckpt_path",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"validation_step",
"=",
"model",
".",
"validation_step__multiple_dataloaders",
"model",
".",
"validation_epoch_end",
"... | [
239,
0
] | [
269,
93
] | python | en | ['en', 'en', 'en'] | True |
test_inf_dataloaders_with_limit_percent_batches | (tmpdir, limit_train_batches, limit_val_batches, limit_test_batches) | Verify inf train, val & test dataloaders (e.g. IterableDataset) passed with batch limit in percent | Verify inf train, val & test dataloaders (e.g. IterableDataset) passed with batch limit in percent | def test_inf_dataloaders_with_limit_percent_batches(tmpdir, limit_train_batches, limit_val_batches, limit_test_batches):
"""Verify inf train, val & test dataloaders (e.g. IterableDataset) passed with batch limit in percent"""
model = EvalModelTemplate()
model.train_dataloader = model.train_dataloader__infin... | [
"def",
"test_inf_dataloaders_with_limit_percent_batches",
"(",
"tmpdir",
",",
"limit_train_batches",
",",
"limit_val_batches",
",",
"limit_test_batches",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"train_dataloader",
"=",
"model",
".",
"train_d... | [
276,
0
] | [
297,
92
] | python | en | ['en', 'en', 'en'] | True |
test_inf_dataloaders_with_limit_num_batches | (tmpdir, limit_train_batches, limit_val_batches, limit_test_batches) | Verify inf train, val & test dataloaders (e.g. IterableDataset) passed with batch limit as number | Verify inf train, val & test dataloaders (e.g. IterableDataset) passed with batch limit as number | def test_inf_dataloaders_with_limit_num_batches(tmpdir, limit_train_batches, limit_val_batches, limit_test_batches):
"""Verify inf train, val & test dataloaders (e.g. IterableDataset) passed with batch limit as number"""
model = EvalModelTemplate()
model.train_dataloader = model.train_dataloader__infinite
... | [
"def",
"test_inf_dataloaders_with_limit_num_batches",
"(",
"tmpdir",
",",
"limit_train_batches",
",",
"limit_val_batches",
",",
"limit_test_batches",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"train_dataloader",
"=",
"model",
".",
"train_datal... | [
304,
0
] | [
325,
60
] | python | en | ['en', 'en', 'en'] | True |
test_dataloaders_with_limit_percent_batches | (tmpdir, limit_train_batches, limit_val_batches, limit_test_batches) | Verify num_batches for train, val & test dataloaders passed with batch limit in percent | Verify num_batches for train, val & test dataloaders passed with batch limit in percent | def test_dataloaders_with_limit_percent_batches(tmpdir, limit_train_batches, limit_val_batches, limit_test_batches):
"""Verify num_batches for train, val & test dataloaders passed with batch limit in percent"""
model = EvalModelTemplate()
model.val_dataloader = model.val_dataloader__multiple_mixed_length
... | [
"def",
"test_dataloaders_with_limit_percent_batches",
"(",
"tmpdir",
",",
"limit_train_batches",
",",
"limit_val_batches",
",",
"limit_test_batches",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"val_dataloader",
"=",
"model",
".",
"val_dataloade... | [
334,
0
] | [
360,
60
] | python | en | ['en', 'en', 'en'] | True |
test_dataloaders_with_limit_num_batches | (tmpdir, limit_train_batches, limit_val_batches, limit_test_batches) | Verify num_batches for train, val & test dataloaders passed with batch limit as number | Verify num_batches for train, val & test dataloaders passed with batch limit as number | def test_dataloaders_with_limit_num_batches(tmpdir, limit_train_batches, limit_val_batches, limit_test_batches):
"""Verify num_batches for train, val & test dataloaders passed with batch limit as number"""
model = EvalModelTemplate()
model.val_dataloader = model.val_dataloader__multiple_mixed_length
mo... | [
"def",
"test_dataloaders_with_limit_num_batches",
"(",
"tmpdir",
",",
"limit_train_batches",
",",
"limit_val_batches",
",",
"limit_test_batches",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"val_dataloader",
"=",
"model",
".",
"val_dataloader__m... | [
369,
0
] | [
422,
56
] | python | en | ['en', 'en', 'en'] | True |
test_dataloaders_with_fast_dev_run | (tmpdir, fast_dev_run) |
Verify num_batches for train, val & test dataloaders passed with fast_dev_run
|
Verify num_batches for train, val & test dataloaders passed with fast_dev_run
| def test_dataloaders_with_fast_dev_run(tmpdir, fast_dev_run):
"""
Verify num_batches for train, val & test dataloaders passed with fast_dev_run
"""
model = EvalModelTemplate()
model.val_dataloader = model.val_dataloader__multiple_mixed_length
model.test_dataloader = model.test_dataloader__multip... | [
"def",
"test_dataloaders_with_fast_dev_run",
"(",
"tmpdir",
",",
"fast_dev_run",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"val_dataloader",
"=",
"model",
".",
"val_dataloader__multiple_mixed_length",
"model",
".",
"test_dataloader",
"=",
"m... | [
427,
0
] | [
479,
119
] | python | en | ['en', 'error', 'th'] | False |
test_mixing_of_dataloader_options | (tmpdir, ckpt_path) | Verify that dataloaders can be passed to fit | Verify that dataloaders can be passed to fit | def test_mixing_of_dataloader_options(tmpdir, ckpt_path):
"""Verify that dataloaders can be passed to fit"""
model = EvalModelTemplate()
trainer_options = dict(
default_root_dir=tmpdir,
max_epochs=1,
limit_val_batches=0.1,
limit_train_batches=0.2,
)
# fit model
... | [
"def",
"test_mixing_of_dataloader_options",
"(",
"tmpdir",
",",
"ckpt_path",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"trainer_options",
"=",
"dict",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"max_epochs",
"=",
"1",
",",
"limit_val_batches",
"=",
... | [
483,
0
] | [
511,
84
] | python | en | ['en', 'en', 'en'] | True |
test_train_inf_dataloader_error | (tmpdir) | Test inf train data loader (e.g. IterableDataset) | Test inf train data loader (e.g. IterableDataset) | def test_train_inf_dataloader_error(tmpdir):
"""Test inf train data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.train_dataloader = model.train_dataloader__infinite
trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, val_check_interval=0.5)
with pytest.raises(Misconfigur... | [
"def",
"test_train_inf_dataloader_error",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"train_dataloader",
"=",
"model",
".",
"train_dataloader__infinite",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",... | [
514,
0
] | [
522,
26
] | python | en | ['en', 'da', 'en'] | True |
test_val_inf_dataloader_error | (tmpdir) | Test inf train data loader (e.g. IterableDataset) | Test inf train data loader (e.g. IterableDataset) | def test_val_inf_dataloader_error(tmpdir):
"""Test inf train data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.val_dataloader = model.val_dataloader__infinite
trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, limit_val_batches=0.5)
with pytest.raises(MisconfigurationEx... | [
"def",
"test_val_inf_dataloader_error",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"val_dataloader",
"=",
"model",
".",
"val_dataloader__infinite",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"ma... | [
525,
0
] | [
533,
26
] | python | en | ['en', 'da', 'en'] | True |
test_test_inf_dataloader_error | (tmpdir) | Test inf train data loader (e.g. IterableDataset) | Test inf train data loader (e.g. IterableDataset) | def test_test_inf_dataloader_error(tmpdir):
"""Test inf train data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.test_dataloader = model.test_dataloader__infinite
trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, limit_test_batches=0.5)
with pytest.raises(Misconfigurati... | [
"def",
"test_test_inf_dataloader_error",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"test_dataloader",
"=",
"model",
".",
"test_dataloader__infinite",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
... | [
536,
0
] | [
544,
27
] | python | en | ['en', 'da', 'en'] | True |
test_inf_train_dataloader | (tmpdir, check_interval) | Test inf train data loader (e.g. IterableDataset) | Test inf train data loader (e.g. IterableDataset) | def test_inf_train_dataloader(tmpdir, check_interval):
"""Test inf train data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.train_dataloader = model.train_dataloader__infinite
trainer = Trainer(
default_root_dir=tmpdir,
max_epochs=1,
val_check_interval=chec... | [
"def",
"test_inf_train_dataloader",
"(",
"tmpdir",
",",
"check_interval",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"train_dataloader",
"=",
"model",
".",
"train_dataloader__infinite",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=... | [
548,
0
] | [
561,
90
] | python | en | ['en', 'da', 'en'] | True |
test_inf_val_dataloader | (tmpdir, check_interval) | Test inf val data loader (e.g. IterableDataset) | Test inf val data loader (e.g. IterableDataset) | def test_inf_val_dataloader(tmpdir, check_interval):
"""Test inf val data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.val_dataloader = model.val_dataloader__infinite
# logger file to get meta
trainer = Trainer(
default_root_dir=tmpdir,
max_epochs=1,
v... | [
"def",
"test_inf_val_dataloader",
"(",
"tmpdir",
",",
"check_interval",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"val_dataloader",
"=",
"model",
".",
"val_dataloader__infinite",
"# logger file to get meta",
"trainer",
"=",
"Trainer",
"(",
... | [
565,
0
] | [
580,
90
] | python | da | ['es', 'da', 'nl'] | False |
test_error_on_zero_len_dataloader | (tmpdir) | Test that error is raised if a zero-length dataloader is defined | Test that error is raised if a zero-length dataloader is defined | def test_error_on_zero_len_dataloader(tmpdir):
""" Test that error is raised if a zero-length dataloader is defined """
model = EvalModelTemplate()
model.train_dataloader = model.train_dataloader__zero_length
# fit model
with pytest.raises(ValueError):
trainer = Trainer(
defaul... | [
"def",
"test_error_on_zero_len_dataloader",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"train_dataloader",
"=",
"model",
".",
"train_dataloader__zero_length",
"# fit model",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
... | [
583,
0
] | [
598,
26
] | python | en | ['en', 'en', 'en'] | True |
test_warning_with_few_workers | (mock, tmpdir, ckpt_path) | Test that error is raised if dataloader with only a few workers is used | Test that error is raised if dataloader with only a few workers is used | def test_warning_with_few_workers(mock, tmpdir, ckpt_path):
""" Test that error is raised if dataloader with only a few workers is used """
model = EvalModelTemplate()
# logger file to get meta
train_dl = model.dataloader(train=True)
train_dl.num_workers = 0
val_dl = model.dataloader(train=Fa... | [
"def",
"test_warning_with_few_workers",
"(",
"mock",
",",
"tmpdir",
",",
"ckpt_path",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"# logger file to get meta",
"train_dl",
"=",
"model",
".",
"dataloader",
"(",
"train",
"=",
"True",
")",
"train_dl",
"."... | [
604,
0
] | [
644,
36
] | python | en | ['en', 'en', 'en'] | True |
test_warning_with_few_workers_multi_loader | (mock, tmpdir, ckpt_path) | Test that error is raised if dataloader with only a few workers is used | Test that error is raised if dataloader with only a few workers is used | def test_warning_with_few_workers_multi_loader(mock, tmpdir, ckpt_path):
""" Test that error is raised if dataloader with only a few workers is used """
model = EvalModelTemplate()
model.training_step = model.training_step__multiple_dataloaders
model.validation_step = model.validation_step__multiple_da... | [
"def",
"test_warning_with_few_workers_multi_loader",
"(",
"mock",
",",
"tmpdir",
",",
"ckpt_path",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"training_step",
"=",
"model",
".",
"training_step__multiple_dataloaders",
"model",
".",
"validation... | [
650,
0
] | [
699,
36
] | python | en | ['en', 'en', 'en'] | True |
test_warning_with_iterable_dataset_and_len | (tmpdir) | Tests that a warning message is shown when an IterableDataset defines `__len__`. | Tests that a warning message is shown when an IterableDataset defines `__len__`. | def test_warning_with_iterable_dataset_and_len(tmpdir):
""" Tests that a warning message is shown when an IterableDataset defines `__len__`. """
model = EvalModelTemplate()
original_dataset = model.train_dataloader().dataset
class IterableWithLen(IterableDataset):
def __iter__(self):
... | [
"def",
"test_warning_with_iterable_dataset_and_len",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"original_dataset",
"=",
"model",
".",
"train_dataloader",
"(",
")",
".",
"dataset",
"class",
"IterableWithLen",
"(",
"IterableDataset",
")",
"... | [
702,
0
] | [
725,
58
] | python | en | ['en', 'en', 'en'] | True |
test_dataloader_distributed_sampler | (tmpdir) | Test DistributedSampler and it's arguments for DDP backend | Test DistributedSampler and it's arguments for DDP backend | def test_dataloader_distributed_sampler(tmpdir):
""" Test DistributedSampler and it's arguments for DDP backend """
model = EvalModelTemplate()
trainer = Trainer(
gpus=[0, 1],
num_nodes=1,
accelerator='ddp_spawn',
default_root_dir=tmpdir,
max_steps=1,
callbac... | [
"def",
"test_dataloader_distributed_sampler",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"trainer",
"=",
"Trainer",
"(",
"gpus",
"=",
"[",
"0",
",",
"1",
"]",
",",
"num_nodes",
"=",
"1",
",",
"accelerator",
"=",
"'ddp_spawn'",
",... | [
811,
0
] | [
824,
32
] | python | en | ['en', 'en', 'en'] | True |
test_dataloader_distributed_sampler_already_attached | (tmpdir) | Test DistributedSampler and it's arguments for DDP backend when DistSampler already included on dataloader | Test DistributedSampler and it's arguments for DDP backend when DistSampler already included on dataloader | def test_dataloader_distributed_sampler_already_attached(tmpdir):
""" Test DistributedSampler and it's arguments for DDP backend when DistSampler already included on dataloader """
model = ModelWithDataLoaderDistributedSampler()
trainer = Trainer(
gpus=[0, 1],
num_nodes=1,
accelerat... | [
"def",
"test_dataloader_distributed_sampler_already_attached",
"(",
"tmpdir",
")",
":",
"model",
"=",
"ModelWithDataLoaderDistributedSampler",
"(",
")",
"trainer",
"=",
"Trainer",
"(",
"gpus",
"=",
"[",
"0",
",",
"1",
"]",
",",
"num_nodes",
"=",
"1",
",",
"accel... | [
839,
0
] | [
853,
72
] | python | en | ['en', 'en', 'en'] | True |
test_fit_multiple_train_loaders | (tmpdir, multiple_trainloader_mode, num_training_batches) | Integration test for multple train loaders | Integration test for multple train loaders | def test_fit_multiple_train_loaders(tmpdir, multiple_trainloader_mode, num_training_batches):
"""Integration test for multple train loaders"""
model = EvalModelTemplate()
model.train_dataloader = model.train_dataloader__multiple_mapping
# todo: add also `train_dataloader__multiple_sequence`
model.t... | [
"def",
"test_fit_multiple_train_loaders",
"(",
"tmpdir",
",",
"multiple_trainloader_mode",
",",
"num_training_batches",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"train_dataloader",
"=",
"model",
".",
"train_dataloader__multiple_mapping",
"# tod... | [
912,
0
] | [
928,
63
] | python | en | ['en', 'da', 'en'] | True |
test_val_dataloader_not_implemented_error | (tmpdir, check_interval) | Test not_implemented_error data loader (e.g. IterableDataset) | Test not_implemented_error data loader (e.g. IterableDataset) | def test_val_dataloader_not_implemented_error(tmpdir, check_interval):
"""Test not_implemented_error data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.val_dataloader = model.val_dataloader__not_implemented_error
# logger file to get meta
trainer = Trainer(
default_roo... | [
"def",
"test_val_dataloader_not_implemented_error",
"(",
"tmpdir",
",",
"check_interval",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"val_dataloader",
"=",
"model",
".",
"val_dataloader__not_implemented_error",
"# logger file to get meta",
"trainer... | [
932,
0
] | [
947,
90
] | python | en | ['en', 'no', 'en'] | True |
test_train_dataloader_not_implemented_error | (tmpdir, check_interval) | Test not_implemented_error train data loader (e.g. IterableDataset) | Test not_implemented_error train data loader (e.g. IterableDataset) | def test_train_dataloader_not_implemented_error(tmpdir, check_interval):
"""Test not_implemented_error train data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.train_dataloader = model.train_dataloader__not_implemented_error
model.val_dataloader = model.val_dataloader__not_implemen... | [
"def",
"test_train_dataloader_not_implemented_error",
"(",
"tmpdir",
",",
"check_interval",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"train_dataloader",
"=",
"model",
".",
"train_dataloader__not_implemented_error",
"model",
".",
"val_dataloader... | [
951,
0
] | [
961,
90
] | python | en | ['en', 'no', 'en'] | True |
test_train_dataloader_not_implemented_error_failed | (tmpdir) | Test not_implemented_error train data loader (e.g. IterableDataset) | Test not_implemented_error train data loader (e.g. IterableDataset) | def test_train_dataloader_not_implemented_error_failed(tmpdir):
"""Test not_implemented_error train data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.train_dataloader = model.train_dataloader__not_implemented_error
trainer = Trainer(default_root_dir=tmpdir, max_steps=5, max_epochs... | [
"def",
"test_train_dataloader_not_implemented_error_failed",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"train_dataloader",
"=",
"model",
".",
"train_dataloader__not_implemented_error",
"trainer",
"=",
"Trainer",
"(",
"default_root... | [
964,
0
] | [
972,
26
] | python | en | ['en', 'no', 'en'] | True |
test_val_dataloader_not_implemented_error_failed | (tmpdir) | Test not_implemented_error train data loader (e.g. IterableDataset) | Test not_implemented_error train data loader (e.g. IterableDataset) | def test_val_dataloader_not_implemented_error_failed(tmpdir):
"""Test not_implemented_error train data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.val_dataloader = model.val_dataloader__not_implemented_error
trainer = Trainer(default_root_dir=tmpdir, max_steps=5, max_epochs=1, li... | [
"def",
"test_val_dataloader_not_implemented_error_failed",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"val_dataloader",
"=",
"model",
".",
"val_dataloader__not_implemented_error",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",... | [
975,
0
] | [
983,
26
] | python | en | ['en', 'no', 'en'] | True |
test_test_dataloader_not_implemented_error_failed | (tmpdir) | Test not_implemented_error train data loader (e.g. IterableDataset) | Test not_implemented_error train data loader (e.g. IterableDataset) | def test_test_dataloader_not_implemented_error_failed(tmpdir):
"""Test not_implemented_error train data loader (e.g. IterableDataset)"""
model = EvalModelTemplate()
model.test_dataloader = model.test_dataloader__not_implemented_error
trainer = Trainer(default_root_dir=tmpdir, max_steps=5, max_epochs=1,... | [
"def",
"test_test_dataloader_not_implemented_error_failed",
"(",
"tmpdir",
")",
":",
"model",
"=",
"EvalModelTemplate",
"(",
")",
"model",
".",
"test_dataloader",
"=",
"model",
".",
"test_dataloader__not_implemented_error",
"trainer",
"=",
"Trainer",
"(",
"default_root_di... | [
986,
0
] | [
994,
27
] | python | en | ['en', 'no', 'en'] | True |
test_replace_sampler_with_multiprocessing_context | (tmpdir) |
This test verifies that replace_sampler conserves multiprocessing context
|
This test verifies that replace_sampler conserves multiprocessing context
| def test_replace_sampler_with_multiprocessing_context(tmpdir):
"""
This test verifies that replace_sampler conserves multiprocessing context
"""
train = RandomDataset(32, 64)
context = 'spawn'
train = DataLoader(train, batch_size=32, num_workers=2, multiprocessing_context=context, shuffle=True)
... | [
"def",
"test_replace_sampler_with_multiprocessing_context",
"(",
"tmpdir",
")",
":",
"train",
"=",
"RandomDataset",
"(",
"32",
",",
"64",
")",
"context",
"=",
"'spawn'",
"train",
"=",
"DataLoader",
"(",
"train",
",",
"batch_size",
"=",
"32",
",",
"num_workers",
... | [
1214,
0
] | [
1234,
85
] | python | en | ['en', 'error', 'th'] | False |
set_ceid | (country="US", language="en") | Set the base country and language for the RSS Feed
Args:
country (str, optional): Country abbreviation. Defaults to "US".
language (str, optional): Country Language abbreviation. Defaults to "en".
Returns:
ceid (str): acceptable RSS feed query string.
| Set the base country and language for the RSS Feed | def set_ceid(country="US", language="en"):
"""Set the base country and language for the RSS Feed
Args:
country (str, optional): Country abbreviation. Defaults to "US".
language (str, optional): Country Language abbreviation. Defaults to "en".
Returns:
ceid (str): acceptable RSS fe... | [
"def",
"set_ceid",
"(",
"country",
"=",
"\"US\"",
",",
"language",
"=",
"\"en\"",
")",
":",
"ceid",
"=",
"\"?ceid={country}:{language}&hl={language}&gl={country}\"",
".",
"format",
"(",
"country",
"=",
"country",
",",
"language",
"=",
"language",
")",
"return",
... | [
10,
0
] | [
25,
15
] | python | en | ['en', 'en', 'en'] | True |
feed_parser | (feedURL) | Use Feedparser to Extract Feeds from the specified URL.
Args:
feedURL (str): URL to extract feeds from
Raises:
Exception: when feed is not available.
Returns:
dict: a dictionary object with feed and entries as keys.
| Use Feedparser to Extract Feeds from the specified URL. | def feed_parser(feedURL):
"""Use Feedparser to Extract Feeds from the specified URL.
Args:
feedURL (str): URL to extract feeds from
Raises:
Exception: when feed is not available.
Returns:
dict: a dictionary object with feed and entries as keys.
"""
# Check if it's a s... | [
"def",
"feed_parser",
"(",
"feedURL",
")",
":",
"# Check if it's a supported URL",
"request_feed",
"=",
"requests",
".",
"get",
"(",
"feedURL",
")",
"if",
"\"https://news.google.com/rss/unsupported\"",
"in",
"request_feed",
".",
"url",
":",
"raise",
"Exception",
"(",
... | [
28,
0
] | [
49,
60
] | python | en | ['en', 'en', 'en'] | True |
topStories_parser | (text_dict) | Extracts relevant infomation from feed Entries
Args:
text_dict (dict): feed Entity to extract information from.
Returns:
coverage (dict): a dictionary containing extracted information.
| Extracts relevant infomation from feed Entries | def topStories_parser(text_dict):
"""Extracts relevant infomation from feed Entries
Args:
text_dict (dict): feed Entity to extract information from.
Returns:
coverage (dict): a dictionary containing extracted information.
"""
summary = text_dict["summary"]
bs4_html = Beautiful... | [
"def",
"topStories_parser",
"(",
"text_dict",
")",
":",
"summary",
"=",
"text_dict",
"[",
"\"summary\"",
"]",
"bs4_html",
"=",
"BeautifulSoup",
"(",
"summary",
",",
"\"html.parser\"",
")",
"lis",
"=",
"bs4_html",
".",
"find_all",
"(",
"\"li\"",
")",
"# Create ... | [
52,
0
] | [
96,
19
] | python | en | ['en', 'en', 'en'] | True |
collect_coverage | (entries) | Extract sub news and collate them together.
Args:
entries (dict): feed entries
Returns:
entries_dict (dict): news coverage collection
| Extract sub news and collate them together. | def collect_coverage(entries):
"""Extract sub news and collate them together.
Args:
entries (dict): feed entries
Returns:
entries_dict (dict): news coverage collection
"""
entries_dict = dict()
for i, _ in enumerate(entries):
if "summary" in entries[i].keys():
... | [
"def",
"collect_coverage",
"(",
"entries",
")",
":",
"entries_dict",
"=",
"dict",
"(",
")",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"entries",
")",
":",
"if",
"\"summary\"",
"in",
"entries",
"[",
"i",
"]",
".",
"keys",
"(",
")",
":",
"# Use top... | [
99,
0
] | [
117,
23
] | python | en | ['en', 'en', 'en'] | True |
search_parser | (search_query) | Construct URL from search query
Args:
search_query (str): Search Querry supplied by user.
Returns:
parsed_url (str): Passed URL
| Construct URL from search query | def search_parser(search_query):
"""Construct URL from search query
Args:
search_query (str): Search Querry supplied by user.
Returns:
parsed_url (str): Passed URL
"""
parsed_url = urllib.parse.quote_plus(search_query)
return parsed_url | [
"def",
"search_parser",
"(",
"search_query",
")",
":",
"parsed_url",
"=",
"urllib",
".",
"parse",
".",
"quote_plus",
"(",
"search_query",
")",
"return",
"parsed_url"
] | [
120,
0
] | [
130,
21
] | python | en | ['en', 'en', 'en'] | True |
date_parser | (date=None) | Validate date and extract Year, Month and Day
Args:
date (str, optional): Date to be parsed. Defaults to None.
Raises:
Exception: When invalid date pattern is parsed
Returns:
valid_date (str): Extracted Date
| Validate date and extract Year, Month and Day | def date_parser(date=None):
"""Validate date and extract Year, Month and Day
Args:
date (str, optional): Date to be parsed. Defaults to None.
Raises:
Exception: When invalid date pattern is parsed
Returns:
valid_date (str): Extracted Date
"""
try:
valid_date = ... | [
"def",
"date_parser",
"(",
"date",
"=",
"None",
")",
":",
"try",
":",
"valid_date",
"=",
"dateparser",
".",
"parse",
"(",
"date",
")",
".",
"strftime",
"(",
"\"%Y-%m-%d\"",
")",
"return",
"str",
"(",
"valid_date",
")",
"except",
":",
"raise",
"Exception"... | [
133,
0
] | [
149,
47
] | python | en | ['en', 'en', 'en'] | True |
dos2unix | (file) | Replace CRLF with LF in argument files. Print names of changed files. | Replace CRLF with LF in argument files. Print names of changed files. | def dos2unix(file):
"Replace CRLF with LF in argument files. Print names of changed files."
if os.path.isdir(file):
print(file, "Directory!")
return
with open(file, "rb") as fp:
data = fp.read()
if '\0' in data:
print(file, "Binary!")
return
newdata = re.su... | [
"def",
"dos2unix",
"(",
"file",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"file",
")",
":",
"print",
"(",
"file",
",",
"\"Directory!\"",
")",
"return",
"with",
"open",
"(",
"file",
",",
"\"rb\"",
")",
"as",
"fp",
":",
"data",
"=",
"fp... | [
7,
0
] | [
26,
25
] | python | en | ['en', 'en', 'en'] | True |
unix2dos | (file) | Replace LF with CRLF in argument files. Print names of changed files. | Replace LF with CRLF in argument files. Print names of changed files. | def unix2dos(file):
"Replace LF with CRLF in argument files. Print names of changed files."
if os.path.isdir(file):
print(file, "Directory!")
return
with open(file, "rb") as fp:
data = fp.read()
if '\0' in data:
print(file, "Binary!")
return
newdata = re.sub... | [
"def",
"unix2dos",
"(",
"file",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"file",
")",
":",
"print",
"(",
"file",
",",
"\"Directory!\"",
")",
"return",
"with",
"open",
"(",
"file",
",",
"\"rb\"",
")",
"as",
"fp",
":",
"data",
"=",
"fp... | [
41,
0
] | [
60,
25
] | python | en | ['en', 'en', 'en'] | True |
Imitator.spawn | (self, obs_attrs: List[Auri], act_attrs: List[Auri]) | Define and register handlers in a new registry. | Define and register handlers in a new registry. | def spawn(self, obs_attrs: List[Auri], act_attrs: List[Auri]):
"""Define and register handlers in a new registry."""
self._registry = KopfRegistry()
# register handlers
for au in obs_attrs:
# TBD auri existence check
_gvr = (au.group, au.version, au.resource)
... | [
"def",
"spawn",
"(",
"self",
",",
"obs_attrs",
":",
"List",
"[",
"Auri",
"]",
",",
"act_attrs",
":",
"List",
"[",
"Auri",
"]",
")",
":",
"self",
".",
"_registry",
"=",
"KopfRegistry",
"(",
")",
"# register handlers",
"for",
"au",
"in",
"obs_attrs",
":"... | [
45,
4
] | [
86,
61
] | python | en | ['en', 'en', 'en'] | True |
build_dataset | (cfg, default_args=None) | Build a dataset from config dict.
Args:
cfg (dict): Config dict. It should at least contain the key "type".
default_args (dict, optional): Default initialization arguments.
Default: None.
Returns:
Dataset: The constructed dataset.
| Build a dataset from config dict. | def build_dataset(cfg, default_args=None):
"""Build a dataset from config dict.
Args:
cfg (dict): Config dict. It should at least contain the key "type".
default_args (dict, optional): Default initialization arguments.
Default: None.
Returns:
Dataset: The constructed da... | [
"def",
"build_dataset",
"(",
"cfg",
",",
"default_args",
"=",
"None",
")",
":",
"if",
"cfg",
"[",
"'type'",
"]",
"==",
"'RepeatDataset'",
":",
"dataset",
"=",
"RepeatDataset",
"(",
"build_dataset",
"(",
"cfg",
"[",
"'dataset'",
"]",
",",
"default_args",
")... | [
23,
0
] | [
39,
18
] | python | en | ['en', 'en', 'en'] | True |
build_dataloader | (dataset,
samples_per_gpu,
workers_per_gpu,
num_gpus=1,
dist=True,
shuffle=True,
seed=None,
drop_last=True,
pin_memory=True,
**kwar... | Build PyTorch DataLoader.
In distributed training, each GPU/process has a dataloader.
In non-distributed training, there is only one dataloader for all GPUs.
Args:
dataset (Dataset): A PyTorch dataset.
samples_per_gpu (int): Number of training samples on each GPU, i.e.,
batch s... | Build PyTorch DataLoader. | def build_dataloader(dataset,
samples_per_gpu,
workers_per_gpu,
num_gpus=1,
dist=True,
shuffle=True,
seed=None,
drop_last=True,
pin_memory=True,
... | [
"def",
"build_dataloader",
"(",
"dataset",
",",
"samples_per_gpu",
",",
"workers_per_gpu",
",",
"num_gpus",
"=",
"1",
",",
"dist",
"=",
"True",
",",
"shuffle",
"=",
"True",
",",
"seed",
"=",
"None",
",",
"drop_last",
"=",
"True",
",",
"pin_memory",
"=",
... | [
42,
0
] | [
105,
22
] | python | en | ['en', 'sv', 'en'] | True |
worker_init_fn | (worker_id, num_workers, rank, seed) | Init the random seed for various workers. | Init the random seed for various workers. | def worker_init_fn(worker_id, num_workers, rank, seed):
"""Init the random seed for various workers."""
# The seed of each worker equals to
# num_worker * rank + worker_id + user_seed
worker_seed = num_workers * rank + worker_id + seed
np.random.seed(worker_seed)
random.seed(worker_seed) | [
"def",
"worker_init_fn",
"(",
"worker_id",
",",
"num_workers",
",",
"rank",
",",
"seed",
")",
":",
"# The seed of each worker equals to",
"# num_worker * rank + worker_id + user_seed",
"worker_seed",
"=",
"num_workers",
"*",
"rank",
"+",
"worker_id",
"+",
"seed",
"np",
... | [
108,
0
] | [
114,
28
] | python | en | ['en', 'en', 'en'] | True |
main | () | Visualize the demo images. | Visualize the demo images. | def main():
"""Visualize the demo images."""
parser = ArgumentParser()
parser.add_argument('pose_config', help='Config file for pose')
parser.add_argument('pose_checkpoint', help='Checkpoint file for pose')
parser.add_argument('--video-path', type=str, help='Video path')
parser.add_argument(
... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'pose_config'",
",",
"help",
"=",
"'Config file for pose'",
")",
"parser",
".",
"add_argument",
"(",
"'pose_checkpoint'",
",",
"help",
"=",
"'Checkpoi... | [
9,
0
] | [
97,
27
] | python | en | ['en', 'en', 'en'] | True |
play | (folder, nb_eps, seed, save=False) |
Replaying script.
Parameters
----------
folder: str
path to result folder.
nb_eps: int
Number of episodes to be replayed.
seed: int
save: bool
Whether to save figures.
|
Replaying script. | def play(folder, nb_eps, seed, save=False):
"""
Replaying script.
Parameters
----------
folder: str
path to result folder.
nb_eps: int
Number of episodes to be replayed.
seed: int
save: bool
Whether to save figures.
"""
algorithm, cost_function, env, pa... | [
"def",
"play",
"(",
"folder",
",",
"nb_eps",
",",
"seed",
",",
"save",
"=",
"False",
")",
":",
"algorithm",
",",
"cost_function",
",",
"env",
",",
"params",
"=",
"setup_for_replay",
"(",
"folder",
",",
"seed",
")",
"goal",
"=",
"np",
".",
"array",
"(... | [
12,
0
] | [
65,
28
] | python | en | ['en', 'error', 'th'] | False |
get_class_id | (class_name) |
Given a class string, find the id of that class
This handles synonym lookup as well
:param class_name:
:return:
|
Given a class string, find the id of that class
This handles synonym lookup as well
:param class_name:
:return:
| def get_class_id(class_name):
"""
Given a class string, find the id of that class
This handles synonym lookup as well
:param class_name:
:return:
"""
class_name = class_name.lower()
if class_name in CLASS_IDS:
return CLASS_IDS[class_name]
elif class_name in SYNONYMS:
... | [
"def",
"get_class_id",
"(",
"class_name",
")",
":",
"class_name",
"=",
"class_name",
".",
"lower",
"(",
")",
"if",
"class_name",
"in",
"CLASS_IDS",
":",
"return",
"CLASS_IDS",
"[",
"class_name",
"]",
"elif",
"class_name",
"in",
"SYNONYMS",
":",
"return",
"CL... | [
70,
0
] | [
82,
15
] | python | en | ['en', 'error', 'th'] | False |
get_nearest_class | (potential_class_name) |
Given a string that might be a class name,
return a string that is definitely a class name.
Again, uses synonyms to map to known class names
:param potential_class_name:
:return:
|
Given a string that might be a class name,
return a string that is definitely a class name.
Again, uses synonyms to map to known class names | def get_nearest_class(potential_class_name):
"""
Given a string that might be a class name,
return a string that is definitely a class name.
Again, uses synonyms to map to known class names
:param potential_class_name:
:return:
"""
potential_class_name = potential_class_name.lower()
... | [
"def",
"get_nearest_class",
"(",
"potential_class_name",
")",
":",
"potential_class_name",
"=",
"potential_class_name",
".",
"lower",
"(",
")",
"if",
"potential_class_name",
"in",
"CLASS_IDS",
":",
"return",
"potential_class_name",
"elif",
"potential_class_name",
"in",
... | [
85,
0
] | [
99,
15
] | python | en | ['en', 'error', 'th'] | False |
search_single_scan | (index, xq, k, bs=128) | performs a search so that the inverted lists are accessed
sequentially by blocks of size bs | performs a search so that the inverted lists are accessed
sequentially by blocks of size bs | def search_single_scan(index, xq, k, bs=128):
"""performs a search so that the inverted lists are accessed
sequentially by blocks of size bs"""
# handle pretransform
if isinstance(index, faiss.IndexPreTransform):
xq = index.apply_py(xq)
index = faiss.downcast_index(index.index)
# c... | [
"def",
"search_single_scan",
"(",
"index",
",",
"xq",
",",
"k",
",",
"bs",
"=",
"128",
")",
":",
"# handle pretransform",
"if",
"isinstance",
"(",
"index",
",",
"faiss",
".",
"IndexPreTransform",
")",
":",
"xq",
"=",
"index",
".",
"apply_py",
"(",
"xq",
... | [
23,
0
] | [
56,
21
] | python | en | ['en', 'en', 'en'] | True |
NeuralNetwork.train | (self, features, targets) | Train the network on batch of features and targets.
Arguments
---------
features: 2D array, each row is one data record, each column is a feature
targets: 1D array of target values
| Train the network on batch of features and targets.
Arguments
---------
features: 2D array, each row is one data record, each column is a feature
targets: 1D array of target values
| def train(self, features, targets):
''' Train the network on batch of features and targets.
Arguments
---------
features: 2D array, each row is one data record, each column is a feature
targets: 1D array of target values
'''... | [
"def",
"train",
"(",
"self",
",",
"features",
",",
"targets",
")",
":",
"n_records",
"=",
"features",
".",
"shape",
"[",
"0",
"]",
"delta_weights_i_h",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"weights_input_to_hidden",
".",
"shape",
")",
"delta_weights_... | [
33,
4
] | [
52,
76
] | python | en | ['en', 'en', 'en'] | True |
NeuralNetwork.forward_pass_train | (self, X) | Implement forward pass here
Arguments
---------
X: features batch
| Implement forward pass here
Arguments
---------
X: features batch | def forward_pass_train(self, X):
''' Implement forward pass here
Arguments
---------
X: features batch
'''
#### Implement the forward pass here ####
### Forward pass ###
# TODO: Hidden layer - Replace these values with your calculat... | [
"def",
"forward_pass_train",
"(",
"self",
",",
"X",
")",
":",
"#### Implement the forward pass here ####",
"### Forward pass ###",
"# TODO: Hidden layer - Replace these values with your calculations.",
"hidden_inputs",
"=",
"None",
"# signals into hidden layer",
"hidden_outputs",
"="... | [
55,
4
] | [
73,
44
] | python | en | ['en', 'en', 'en'] | True |
NeuralNetwork.backpropagation | (self, final_outputs, hidden_outputs, X, y, delta_weights_i_h, delta_weights_h_o) | Implement backpropagation
Arguments
---------
final_outputs: output from forward pass
y: target (i.e. label) batch
delta_weights_i_h: change in weights from input to hidden layers
delta_weights_h_o: change in weights from hidden to outpu... | Implement backpropagation
Arguments
---------
final_outputs: output from forward pass
y: target (i.e. label) batch
delta_weights_i_h: change in weights from input to hidden layers
delta_weights_h_o: change in weights from hidden to outpu... | def backpropagation(self, final_outputs, hidden_outputs, X, y, delta_weights_i_h, delta_weights_h_o):
''' Implement backpropagation
Arguments
---------
final_outputs: output from forward pass
y: target (i.e. label) batch
delta_weights_i_h: ch... | [
"def",
"backpropagation",
"(",
"self",
",",
"final_outputs",
",",
"hidden_outputs",
",",
"X",
",",
"y",
",",
"delta_weights_i_h",
",",
"delta_weights_h_o",
")",
":",
"#### Implement the backward pass here ####",
"### Backward pass ###",
"# TODO: Output error - Replace this va... | [
75,
4
] | [
105,
51
] | python | en | ['lt', 'en', 'en'] | False |
NeuralNetwork.update_weights | (self, delta_weights_i_h, delta_weights_h_o, n_records) | Update weights on gradient descent step
Arguments
---------
delta_weights_i_h: change in weights from input to hidden layers
delta_weights_h_o: change in weights from hidden to output layers
n_records: number of records
| Update weights on gradient descent step
Arguments
---------
delta_weights_i_h: change in weights from input to hidden layers
delta_weights_h_o: change in weights from hidden to output layers
n_records: number of records | def update_weights(self, delta_weights_i_h, delta_weights_h_o, n_records):
''' Update weights on gradient descent step
Arguments
---------
delta_weights_i_h: change in weights from input to hidden layers
delta_weights_h_o: change in weights from hidden t... | [
"def",
"update_weights",
"(",
"self",
",",
"delta_weights_i_h",
",",
"delta_weights_h_o",
",",
"n_records",
")",
":",
"# TODO: Update the weights with gradient descent step",
"self",
".",
"weights_hidden_to_output",
"+=",
"None",
"# update hidden-to-output weights with gradient d... | [
107,
4
] | [
120,
44
] | python | en | ['en', 'de', 'en'] | True |
NeuralNetwork.run | (self, features) | Run a forward pass through the network with input features
Arguments
---------
features: 1D array of feature values
| Run a forward pass through the network with input features
Arguments
---------
features: 1D array of feature values
| def run(self, features):
''' Run a forward pass through the network with input features
Arguments
---------
features: 1D array of feature values
'''
#### Implement the forward pass here ####
# TODO: Hidden layer - replace these value... | [
"def",
"run",
"(",
"self",
",",
"features",
")",
":",
"#### Implement the forward pass here ####",
"# TODO: Hidden layer - replace these values with the appropriate calculations.",
"hidden_inputs",
"=",
"None",
"# signals into hidden layer",
"hidden_outputs",
"=",
"None",
"# signal... | [
122,
4
] | [
139,
28
] | python | en | ['en', 'en', 'en'] | True |
argparser | (parser) | Default argument parser for regressions.
| Default argument parser for regressions.
| def argparser(parser):
"""Default argument parser for regressions.
"""
parser.add_argument("--local",
action="store_true",
help="run regression in local mode", default=False)
parser.add_argument("--clickhouse-binary-path",
type=str, dest="clickhouse_binary_path",
help="p... | [
"def",
"argparser",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"\"--local\"",
",",
"action",
"=",
"\"store_true\"",
",",
"help",
"=",
"\"run regression in local mode\"",
",",
"default",
"=",
"False",
")",
"parser",
".",
"add_argument",
"(",
"... | [
9,
0
] | [
25,
60
] | python | da | ['da', 'da', 'en'] | True |
LibUSBCompatConan._iterate_lib_paths_win | (self, lib) | Return all possible library paths for lib | Return all possible library paths for lib | def _iterate_lib_paths_win(self, lib):
"""Return all possible library paths for lib"""
for lib_path in self.deps_cpp_info.lib_paths:
for prefix in "", "lib":
for suffix in "", ".a", ".dll.a", ".lib", ".dll.lib":
fn = os.path.join(lib_path, "{}{}{}".format(... | [
"def",
"_iterate_lib_paths_win",
"(",
"self",
",",
"lib",
")",
":",
"for",
"lib_path",
"in",
"self",
".",
"deps_cpp_info",
".",
"lib_paths",
":",
"for",
"prefix",
"in",
"\"\"",
",",
"\"lib\"",
":",
"for",
"suffix",
"in",
"\"\"",
",",
"\".a\"",
",",
"\".d... | [
69,
4
] | [
77,
28
] | python | en | ['en', 'en', 'en'] | True |
tol | () | Numerical tolerance for equality tests. | Numerical tolerance for equality tests. | def tol():
"""Numerical tolerance for equality tests."""
return float(os.environ.get("TOL", TOL)) | [
"def",
"tol",
"(",
")",
":",
"return",
"float",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"\"TOL\"",
",",
"TOL",
")",
")"
] | [
39,
0
] | [
41,
44
] | python | en | ['en', 'en', 'en'] | True |
n_subsystems | (request) | Number of qubits or qumodes. | Number of qubits or qumodes. | def n_subsystems(request):
"""Number of qubits or qumodes."""
return request.param | [
"def",
"n_subsystems",
"(",
"request",
")",
":",
"return",
"request",
".",
"param"
] | [
45,
0
] | [
47,
24
] | python | en | ['en', 'en', 'en'] | True |
EmbeddingEngine.__init__ | (self, model_path) | Creates a EmbeddingEngine with given model and labels.
Args:
model_path: String, path to TF-Lite Flatbuffer file.
Raises:
ValueError: An error occurred when model output is invalid.
| Creates a EmbeddingEngine with given model and labels. | def __init__(self, model_path):
"""Creates a EmbeddingEngine with given model and labels.
Args:
model_path: String, path to TF-Lite Flatbuffer file.
Raises:
ValueError: An error occurred when model output is invalid.
"""
BasicEngine.__init__(self, model_path)
output_tensors_sizes =... | [
"def",
"__init__",
"(",
"self",
",",
"model_path",
")",
":",
"BasicEngine",
".",
"__init__",
"(",
"self",
",",
"model_path",
")",
"output_tensors_sizes",
"=",
"self",
".",
"get_all_output_tensors_sizes",
"(",
")",
"if",
"output_tensors_sizes",
".",
"size",
"!=",... | [
25,
2
] | [
39,
67
] | python | en | ['en', 'en', 'en'] | True |
EmbeddingEngine.DetectWithImage | (self, img) | Calculates embedding from an image.
Args:
img: PIL image object.
Returns:
Embedding vector as np.float32
Raises:
RuntimeError: when model's input tensor format is invalid.
| Calculates embedding from an image. | def DetectWithImage(self, img):
"""Calculates embedding from an image.
Args:
img: PIL image object.
Returns:
Embedding vector as np.float32
Raises:
RuntimeError: when model's input tensor format is invalid.
"""
input_tensor_shape = self.get_input_tensor_shape()
if (input... | [
"def",
"DetectWithImage",
"(",
"self",
",",
"img",
")",
":",
"input_tensor_shape",
"=",
"self",
".",
"get_input_tensor_shape",
"(",
")",
"if",
"(",
"input_tensor_shape",
".",
"size",
"!=",
"4",
"or",
"input_tensor_shape",
"[",
"3",
"]",
"!=",
"3",
"or",
"i... | [
41,
2
] | [
61,
47
] | python | en | ['en', 'en', 'en'] | True |
KNNEmbeddingEngine.__init__ | (self, model_path, kNN=3) | Creates a EmbeddingEngine with given model and labels.
Args:
model_path: String, path to TF-Lite Flatbuffer file.
Raises:
ValueError: An error occurred when model output is invalid.
| Creates a EmbeddingEngine with given model and labels. | def __init__(self, model_path, kNN=3):
"""Creates a EmbeddingEngine with given model and labels.
Args:
model_path: String, path to TF-Lite Flatbuffer file.
Raises:
ValueError: An error occurred when model output is invalid.
"""
EmbeddingEngine.__init__(self, model_path)
self.clear(... | [
"def",
"__init__",
"(",
"self",
",",
"model_path",
",",
"kNN",
"=",
"3",
")",
":",
"EmbeddingEngine",
".",
"__init__",
"(",
"self",
",",
"model_path",
")",
"self",
".",
"clear",
"(",
")",
"self",
".",
"_kNN",
"=",
"kNN"
] | [
71,
2
] | [
82,
19
] | python | en | ['en', 'en', 'en'] | True |
KNNEmbeddingEngine.clear | (self) | Clear the store: forgets all stored embeddings. | Clear the store: forgets all stored embeddings. | def clear(self):
"""Clear the store: forgets all stored embeddings."""
self._labels = []
self._embedding_map = defaultdict(list)
self._embeddings = None | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"_labels",
"=",
"[",
"]",
"self",
".",
"_embedding_map",
"=",
"defaultdict",
"(",
"list",
")",
"self",
".",
"_embeddings",
"=",
"None"
] | [
84,
2
] | [
88,
27
] | python | en | ['en', 'en', 'en'] | True |
KNNEmbeddingEngine.addEmbedding | (self, emb, label) | Add an embedding vector to the store. | Add an embedding vector to the store. | def addEmbedding(self, emb, label):
"""Add an embedding vector to the store."""
normal = emb/np.sqrt((emb**2).sum()) # Normalize the vector
self._embedding_map[label].append(normal) # Add to store, under "label"
# Expand labelled blocks of embeddings for when we have less than kNN
# examples. Oth... | [
"def",
"addEmbedding",
"(",
"self",
",",
"emb",
",",
"label",
")",
":",
"normal",
"=",
"emb",
"/",
"np",
".",
"sqrt",
"(",
"(",
"emb",
"**",
"2",
")",
".",
"sum",
"(",
")",
")",
"# Normalize the vector",
"self",
".",
"_embedding_map",
"[",
"label",
... | [
90,
2
] | [
110,
57
] | python | en | ['en', 'en', 'en'] | True |
KNNEmbeddingEngine.kNNEmbedding | (self, query_emb) | Returns the self._kNN nearest neighbors to a query embedding. | Returns the self._kNN nearest neighbors to a query embedding. | def kNNEmbedding(self, query_emb):
"""Returns the self._kNN nearest neighbors to a query embedding."""
# If we have nothing stored, the answer is None
if self._embeddings is None: return None
# Normalize query embedding
query_emb = query_emb/np.sqrt((query_emb**2).sum())
# We want a cosine di... | [
"def",
"kNNEmbedding",
"(",
"self",
",",
"query_emb",
")",
":",
"# If we have nothing stored, the answer is None",
"if",
"self",
".",
"_embeddings",
"is",
"None",
":",
"return",
"None",
"# Normalize query embedding",
"query_emb",
"=",
"query_emb",
"/",
"np",
".",
"s... | [
112,
2
] | [
137,
28
] | python | en | ['en', 'ga', 'en'] | True |
KNNEmbeddingEngine.exampleCount | (self) | Just returns the size of the embedding store. | Just returns the size of the embedding store. | def exampleCount(self):
"""Just returns the size of the embedding store."""
return sum(len(v) for v in self._embedding_map.values()) | [
"def",
"exampleCount",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"len",
"(",
"v",
")",
"for",
"v",
"in",
"self",
".",
"_embedding_map",
".",
"values",
"(",
")",
")"
] | [
139,
2
] | [
141,
60
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1") | Check revoke query syntax.
```sql
REVOKE [ON CLUSTER cluster_name] [ADMIN OPTION FOR]
role [,...] FROM {user | role | CURRENT_USER} [,...]
| ALL | ALL EXCEPT {user_name | role_name | CURRENT_USER} [,...]
```
| Check revoke query syntax. | def feature(self, node="clickhouse1"):
"""Check revoke query syntax.
```sql
REVOKE [ON CLUSTER cluster_name] [ADMIN OPTION FOR]
role [,...] FROM {user | role | CURRENT_USER} [,...]
| ALL | ALL EXCEPT {user_name | role_name | CURRENT_USER} [,...]
```
"""
node = self.context.... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
")",
":",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
"@",
"contextmanager",
"def",
"setup",
"(",
"users",
"=",
"2",
",",
"roles",
"=",
"2",
... | [
10,
0
] | [
203,
84
] | python | en | ['es', 'sk', 'en'] | False |
missing_frame_extent | (self) | Check that when rows frame has missing frame extent then an error is returned.
| Check that when rows frame has missing frame extent then an error is returned.
| def missing_frame_extent(self):
"""Check that when rows frame has missing frame extent then an error is returned.
"""
exitcode, message = syntax_error()
self.context.node.query("SELECT number,sum(number) OVER (ORDER BY number ROWS) FROM numbers(1,3)",
exitcode=exitcode, message=message) | [
"def",
"missing_frame_extent",
"(",
"self",
")",
":",
"exitcode",
",",
"message",
"=",
"syntax_error",
"(",
")",
"self",
".",
"context",
".",
"node",
".",
"query",
"(",
"\"SELECT number,sum(number) OVER (ORDER BY number ROWS) FROM numbers(1,3)\"",
",",
"exitcode",
"="... | [
9,
0
] | [
15,
43
] | python | en | ['en', 'en', 'en'] | True |
invalid_frame_extent | (self) | Check that when rows frame has invalid frame extent then an error is returned.
| Check that when rows frame has invalid frame extent then an error is returned.
| def invalid_frame_extent(self):
"""Check that when rows frame has invalid frame extent then an error is returned.
"""
exitcode, message = frame_offset_nonnegative_error()
self.context.node.query("SELECT number,sum(number) OVER (ORDER BY number ROWS -1) FROM numbers(1,3)",
exitcode=exitcode, mes... | [
"def",
"invalid_frame_extent",
"(",
"self",
")",
":",
"exitcode",
",",
"message",
"=",
"frame_offset_nonnegative_error",
"(",
")",
"self",
".",
"context",
".",
"node",
".",
"query",
"(",
"\"SELECT number,sum(number) OVER (ORDER BY number ROWS -1) FROM numbers(1,3)\"",
","... | [
21,
0
] | [
27,
43
] | python | en | ['en', 'en', 'en'] | True |
start_current_row | (self) | Check rows current row frame.
| Check rows current row frame.
| def start_current_row(self):
"""Check rows current row frame.
"""
expected = convert_output("""
empno | salary | sum
--------+--------+-------
1 | 5000 | 5000
2 | 3900 | 3900
3 | 4800 | 4800
4 | 4800 | 4800
5 | 3500 | 3500
7 | ... | [
"def",
"start_current_row",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n empno | salary | sum\n --------+--------+-------\n 1 | 5000 | 5000\n 2 | 3900 | 3900\n 3 | 4800 | 4800\n 4 | 4800 | 4800\n 5 | 3500 ... | [
33,
0
] | [
54,
5
] | python | en | ['en', 'en', 'en'] | True |
start_unbounded_preceding | (self) | Check rows unbounded preceding frame.
| Check rows unbounded preceding frame.
| def start_unbounded_preceding(self):
"""Check rows unbounded preceding frame.
"""
expected = convert_output("""
empno | salary | sum
--------+--------+-------
1 | 5000 | 5000
2 | 3900 | 8900
3 | 4800 | 13700
4 | 4800 | 18500
5 | 3500 | 22... | [
"def",
"start_unbounded_preceding",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n empno | salary | sum\n --------+--------+-------\n 1 | 5000 | 5000\n 2 | 3900 | 8900\n 3 | 4800 | 13700\n 4 | 4800 | 18500\n 5 ... | [
60,
0
] | [
81,
5
] | python | en | ['en', 'en', 'en'] | True |
start_expr_preceding | (self) | Check rows expr preceding frame.
| Check rows expr preceding frame.
| def start_expr_preceding(self):
"""Check rows expr preceding frame.
"""
expected = convert_output("""
empno | salary | sum
--------+--------+--------
1 | 5000 | 5000
2 | 3900 | 8900
3 | 4800 | 8700
4 | 4800 | 9600
5 | 3500 | 8300
7... | [
"def",
"start_expr_preceding",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n empno | salary | sum\n --------+--------+--------\n 1 | 5000 | 5000\n 2 | 3900 | 8900\n 3 | 4800 | 8700\n 4 | 4800 | 9600\n 5 | 35... | [
87,
0
] | [
108,
5
] | python | en | ['en', 'gl', 'en'] | True |
start_unbounded_following_error | (self) | Check rows unbounded following frame returns an error.
| Check rows unbounded following frame returns an error.
| def start_unbounded_following_error(self):
"""Check rows unbounded following frame returns an error.
"""
exitcode, message = frame_start_error()
self.context.node.query(
"SELECT empno, salary, sum(salary) OVER (ROWS UNBOUNDED FOLLOWING) AS sum FROM empsalary ORDER BY empno",
exitcode=ex... | [
"def",
"start_unbounded_following_error",
"(",
"self",
")",
":",
"exitcode",
",",
"message",
"=",
"frame_start_error",
"(",
")",
"self",
".",
"context",
".",
"node",
".",
"query",
"(",
"\"SELECT empno, salary, sum(salary) OVER (ROWS UNBOUNDED FOLLOWING) AS sum FROM empsalar... | [
114,
0
] | [
121,
43
] | python | en | ['en', 'en', 'en'] | True |
start_expr_following_error | (self) | Check rows expr following frame returns an error.
| Check rows expr following frame returns an error.
| def start_expr_following_error(self):
"""Check rows expr following frame returns an error.
"""
exitcode, message = window_frame_error()
self.context.node.query(
"SELECT empno, salary, sum(salary) OVER (ROWS 1 FOLLOWING) AS sum FROM empsalary ORDER BY empno",
exitcode=exitcode, message=m... | [
"def",
"start_expr_following_error",
"(",
"self",
")",
":",
"exitcode",
",",
"message",
"=",
"window_frame_error",
"(",
")",
"self",
".",
"context",
".",
"node",
".",
"query",
"(",
"\"SELECT empno, salary, sum(salary) OVER (ROWS 1 FOLLOWING) AS sum FROM empsalary ORDER BY e... | [
127,
0
] | [
134,
43
] | python | en | ['en', 'gl', 'en'] | True |
between_current_row_and_current_row | (self) | Check rows between current row and current row frame.
| Check rows between current row and current row frame.
| def between_current_row_and_current_row(self):
"""Check rows between current row and current row frame.
"""
expected = convert_output("""
empno | salary | sum
--------+--------+--------
1 | 5000 | 5000
2 | 3900 | 3900
3 | 4800 | 4800
4 | 4800 | 4800
... | [
"def",
"between_current_row_and_current_row",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n empno | salary | sum\n --------+--------+--------\n 1 | 5000 | 5000\n 2 | 3900 | 3900\n 3 | 4800 | 4800\n 4 | 4800 | 4800\n ... | [
140,
0
] | [
161,
5
] | python | en | ['en', 'en', 'en'] | True |
between_current_row_and_expr_preceding_error | (self) | Check rows between current row and expr preceding returns an error.
| Check rows between current row and expr preceding returns an error.
| def between_current_row_and_expr_preceding_error(self):
"""Check rows between current row and expr preceding returns an error.
"""
exitcode, message = window_frame_error()
self.context.node.query("SELECT number,sum(number) OVER (ORDER BY number ROWS BETWEEN CURRENT ROW AND 1 PRECEDING) FROM numbers(1,3... | [
"def",
"between_current_row_and_expr_preceding_error",
"(",
"self",
")",
":",
"exitcode",
",",
"message",
"=",
"window_frame_error",
"(",
")",
"self",
".",
"context",
".",
"node",
".",
"query",
"(",
"\"SELECT number,sum(number) OVER (ORDER BY number ROWS BETWEEN CURRENT ROW... | [
167,
0
] | [
173,
43
] | python | en | ['en', 'en', 'en'] | True |
between_current_row_and_unbounded_preceding_error | (self) | Check rows between current row and unbounded preceding returns an error.
| Check rows between current row and unbounded preceding returns an error.
| def between_current_row_and_unbounded_preceding_error(self):
"""Check rows between current row and unbounded preceding returns an error.
"""
exitcode, message = frame_end_unbounded_preceding_error()
self.context.node.query("SELECT number,sum(number) OVER (ORDER BY number ROWS BETWEEN CURRENT ROW AND UN... | [
"def",
"between_current_row_and_unbounded_preceding_error",
"(",
"self",
")",
":",
"exitcode",
",",
"message",
"=",
"frame_end_unbounded_preceding_error",
"(",
")",
"self",
".",
"context",
".",
"node",
".",
"query",
"(",
"\"SELECT number,sum(number) OVER (ORDER BY number RO... | [
179,
0
] | [
185,
43
] | python | en | ['en', 'en', 'en'] | True |
between_current_row_and_unbounded_following | (self) | Check rows between current row and unbounded following.
| Check rows between current row and unbounded following.
| def between_current_row_and_unbounded_following(self):
"""Check rows between current row and unbounded following.
"""
expected = convert_output("""
sum | unique1 | four
-----+---------+------
45 | 0 | 0
45 | 1 | 1
44 | 2 | 2
42 ... | [
"def",
"between_current_row_and_unbounded_following",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum | unique1 | four\n -----+---------+------\n 45\t | 0 | 0\n 45\t | 1 | 1\n 44\t | 2 | 2\n 42\t ... | [
191,
0
] | [
214,
5
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.