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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
AMICleaner.reduce_candidates | (self, mapped_candidates_ami, keep_previous=0, ami_min_days=-1) |
Given a array of AMIs to clean this function return a subsequent
list by preserving a given number of them (history) based on creation
time and rotation_strategy param
|
Given a array of AMIs to clean this function return a subsequent
list by preserving a given number of them (history) based on creation
time and rotation_strategy param
| def reduce_candidates(self, mapped_candidates_ami, keep_previous=0, ami_min_days=-1):
"""
Given a array of AMIs to clean this function return a subsequent
list by preserving a given number of them (history) based on creation
time and rotation_strategy param
"""
result_a... | [
"def",
"reduce_candidates",
"(",
"self",
",",
"mapped_candidates_ami",
",",
"keep_previous",
"=",
"0",
",",
"ami_min_days",
"=",
"-",
"1",
")",
":",
"result_amis",
"=",
"[",
"]",
"result_amis",
".",
"extend",
"(",
"mapped_candidates_ami",
")",
"if",
"ami_min_d... | [
240,
4
] | [
273,
35
] | python | en | ['en', 'error', 'th'] | False |
check_random_directive | () |
>>> 2+2
<BadExample object at 0x084D05AC> #random: may vary on your system
|
>>> 2+2
<BadExample object at 0x084D05AC> #random: may vary on your system
| def check_random_directive():
'''
>>> 2+2
<BadExample object at 0x084D05AC> #random: may vary on your system
''' | [
"def",
"check_random_directive",
"(",
")",
":"
] | [
9,
0
] | [
13,
7
] | python | en | ['en', 'error', 'th'] | False |
check_implicit_np | () |
>>> np.array([1,2,3])
array([1, 2, 3])
|
>>> np.array([1,2,3])
array([1, 2, 3])
| def check_implicit_np():
'''
>>> np.array([1,2,3])
array([1, 2, 3])
''' | [
"def",
"check_implicit_np",
"(",
")",
":"
] | [
16,
0
] | [
20,
7
] | python | en | ['en', 'error', 'th'] | False |
check_whitespace_enabled | () |
# whitespace after the 3
>>> 1+2
3
# whitespace before the 7
>>> 3+4
7
|
# whitespace after the 3
>>> 1+2
3 | def check_whitespace_enabled():
'''
# whitespace after the 3
>>> 1+2
3
# whitespace before the 7
>>> 3+4
7
''' | [
"def",
"check_whitespace_enabled",
"(",
")",
":"
] | [
23,
0
] | [
32,
7
] | python | en | ['en', 'error', 'th'] | False |
check_empty_output | () | Check that no output does not cause an error.
This is related to nose bug 445; the numpy plugin changed the
doctest-result-variable default and therefore hit this bug:
http://code.google.com/p/python-nose/issues/detail?id=445
>>> a = 10
| Check that no output does not cause an error. | def check_empty_output():
""" Check that no output does not cause an error.
This is related to nose bug 445; the numpy plugin changed the
doctest-result-variable default and therefore hit this bug:
http://code.google.com/p/python-nose/issues/detail?id=445
>>> a = 10
""" | [
"def",
"check_empty_output",
"(",
")",
":"
] | [
34,
0
] | [
42,
7
] | python | en | ['en', 'en', 'en'] | True |
check_skip | () | Check skip directive
The test below should not run
>>> 1/0 #doctest: +SKIP
| Check skip directive | def check_skip():
""" Check skip directive
The test below should not run
>>> 1/0 #doctest: +SKIP
""" | [
"def",
"check_skip",
"(",
")",
":"
] | [
44,
0
] | [
50,
7
] | python | af | ['af', 'bg-Latn', 'en'] | False |
Visitor.visit_service | (self, service_proto, type_context) | Visit a service definition.
Args:
service_proto: ServiceDescriptorProto for service.
type_context: type_context.TypeContext for service type.
Returns:
Plugin specific output.
| Visit a service definition. | def visit_service(self, service_proto, type_context):
"""Visit a service definition.
Args:
service_proto: ServiceDescriptorProto for service.
type_context: type_context.TypeContext for service type.
Returns:
Plugin specific output.
"""
pass | [
"def",
"visit_service",
"(",
"self",
",",
"service_proto",
",",
"type_context",
")",
":",
"pass"
] | [
6,
4
] | [
16,
12
] | python | fr | ['fr', 'fr', 'en'] | True |
Visitor.visit_enum | (self, enum_proto, type_context) | Visit an enum definition.
Args:
enum_proto: EnumDescriptorProto for enum.
type_context: type_context.TypeContext for enum type.
Returns:
Plugin specific output.
| Visit an enum definition. | def visit_enum(self, enum_proto, type_context):
"""Visit an enum definition.
Args:
enum_proto: EnumDescriptorProto for enum.
type_context: type_context.TypeContext for enum type.
Returns:
Plugin specific output.
"""
pass | [
"def",
"visit_enum",
"(",
"self",
",",
"enum_proto",
",",
"type_context",
")",
":",
"pass"
] | [
18,
4
] | [
28,
12
] | python | br | ['br', 'fr', 'en'] | False |
Visitor.visit_message | (self, msg_proto, type_context, nested_msgs, nested_enums) | Visit a message definition.
Args:
msg_proto: DescriptorProto for message.
type_context: type_context.TypeContext for message type.
nested_msgs: a list of results from visiting nested messages.
nested_enums: a list of results from visiting nested enums.
Returns:
Plugin specific ou... | Visit a message definition. | def visit_message(self, msg_proto, type_context, nested_msgs, nested_enums):
"""Visit a message definition.
Args:
msg_proto: DescriptorProto for message.
type_context: type_context.TypeContext for message type.
nested_msgs: a list of results from visiting nested messages.
nested_enu... | [
"def",
"visit_message",
"(",
"self",
",",
"msg_proto",
",",
"type_context",
",",
"nested_msgs",
",",
"nested_enums",
")",
":",
"pass"
] | [
30,
4
] | [
42,
12
] | python | fr | ['fr', 'fr', 'en'] | True |
Visitor.visit_file | (self, file_proto, type_context, services, msgs, enums) | Visit a proto file definition.
Args:
file_proto: FileDescriptorProto for file.
type_context: type_context.TypeContext for file.
services: a list of results from visiting services.
msgs: a list of results from visiting messages.
enums: a list of results from visiting enums.
Return... | Visit a proto file definition. | def visit_file(self, file_proto, type_context, services, msgs, enums):
"""Visit a proto file definition.
Args:
file_proto: FileDescriptorProto for file.
type_context: type_context.TypeContext for file.
services: a list of results from visiting services.
msgs: a list of results from ... | [
"def",
"visit_file",
"(",
"self",
",",
"file_proto",
",",
"type_context",
",",
"services",
",",
"msgs",
",",
"enums",
")",
":",
"pass"
] | [
44,
4
] | [
57,
12
] | python | en | ['it', 'fr', 'en'] | False |
TestXORCipher.setUp | (self) |
The SetUp call with commented values in the event one needs
to instantiate mocked objects regarding the XORCipher class.
|
The SetUp call with commented values in the event one needs
to instantiate mocked objects regarding the XORCipher class.
| def setUp(self):
"""
The SetUp call with commented values in the event one needs
to instantiate mocked objects regarding the XORCipher class.
"""
# key = mock.MagicMock()
# self.XORCipher_1 = XORCipher(key)
pass | [
"def",
"setUp",
"(",
"self",
")",
":",
"# key = mock.MagicMock()",
"# self.XORCipher_1 = XORCipher(key)",
"pass"
] | [
25,
4
] | [
33,
12
] | python | en | ['en', 'error', 'th'] | False |
TestXORCipher.test__init__ | (self, mock__init__) |
Test the __init__ method with commented values in the event
one needs to instantiate mocked objects on the method.
|
Test the __init__ method with commented values in the event
one needs to instantiate mocked objects on the method.
| def test__init__(self, mock__init__):
"""
Test the __init__ method with commented values in the event
one needs to instantiate mocked objects on the method.
"""
# self.XORCipher_1.__init__ = mock.MagicMock()
XORCipher.__init__ = mock.MagicMock()
# self.XORCipher... | [
"def",
"test__init__",
"(",
"self",
",",
"mock__init__",
")",
":",
"# self.XORCipher_1.__init__ = mock.MagicMock()",
"XORCipher",
".",
"__init__",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"# self.XORCipher_1.__init__(1)",
"XORCipher",
".",
"__init__",
"(",
")",
"# sel... | [
36,
4
] | [
49,
42
] | python | en | ['en', 'error', 'th'] | False |
TestXORCipher.test_encrypt | (self, mock_encrypt) |
Test the encrypt method with mocked values.
|
Test the encrypt method with mocked values.
| def test_encrypt(self, mock_encrypt):
"""
Test the encrypt method with mocked values.
"""
ans = mock.MagicMock()
content = mock.MagicMock()
key = mock.MagicMock()
XORCipher.encrypt = mock.MagicMock(return_value=ans)
XORCipher.encrypt(content, key)
... | [
"def",
"test_encrypt",
"(",
"self",
",",
"mock_encrypt",
")",
":",
"ans",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"content",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"key",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"XORCipher",
".",
"encrypt",
"=",
"... | [
52,
4
] | [
63,
58
] | python | en | ['en', 'error', 'th'] | False |
TestXORCipher.test_decrypt | (self, mock_decrypt) |
Test the decrypt method with mocked values.
|
Test the decrypt method with mocked values.
| def test_decrypt(self, mock_decrypt):
"""
Test the decrypt method with mocked values.
"""
ans = mock.MagicMock()
content = mock.MagicMock()
key = mock.MagicMock()
XORCipher.decrypt = mock.MagicMock(return_value=ans)
XORCipher.decrypt(content, key)
... | [
"def",
"test_decrypt",
"(",
"self",
",",
"mock_decrypt",
")",
":",
"ans",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"content",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"key",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"XORCipher",
".",
"decrypt",
"=",
"... | [
66,
4
] | [
77,
58
] | python | en | ['en', 'error', 'th'] | False |
TestXORCipher.test_encrypt_string | (self, mock_encrypt_string) |
Test the encrypt_string method with mocked values.
|
Test the encrypt_string method with mocked values.
| def test_encrypt_string(self, mock_encrypt_string):
"""
Test the encrypt_string method with mocked values.
"""
ans = mock.MagicMock()
content = mock.MagicMock()
key = mock.MagicMock()
XORCipher.encrypt_string = mock.MagicMock(return_value=ans)
XORCipher.e... | [
"def",
"test_encrypt_string",
"(",
"self",
",",
"mock_encrypt_string",
")",
":",
"ans",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"content",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"key",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"XORCipher",
".",
"encryp... | [
80,
4
] | [
91,
65
] | python | en | ['en', 'error', 'th'] | False |
TestXORCipher.test_decrypt_string | (self, mock_decrypt_string) |
Test the decrypt_string method with mocked values.
|
Test the decrypt_string method with mocked values.
| def test_decrypt_string(self, mock_decrypt_string):
"""
Test the decrypt_string method with mocked values.
"""
ans = mock.MagicMock()
content = mock.MagicMock()
key = mock.MagicMock()
XORCipher.decrypt_string = mock.MagicMock(return_value=ans)
XORCipher.d... | [
"def",
"test_decrypt_string",
"(",
"self",
",",
"mock_decrypt_string",
")",
":",
"ans",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"content",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"key",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"XORCipher",
".",
"decryp... | [
94,
4
] | [
105,
65
] | python | en | ['en', 'error', 'th'] | False |
TestXORCipher.test_encrypt_file | (self, mock_encrypt_file) |
Test the encrypt_file method with mocked values.
|
Test the encrypt_file method with mocked values.
| def test_encrypt_file(self, mock_encrypt_file):
"""
Test the encrypt_file method with mocked values.
"""
file = mock.MagicMock()
key = mock.MagicMock()
XORCipher.encrypt_file = mock.MagicMock(return_value=True)
XORCipher.encrypt_file(file, key)
XORCipher... | [
"def",
"test_encrypt_file",
"(",
"self",
",",
"mock_encrypt_file",
")",
":",
"file",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"key",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"XORCipher",
".",
"encrypt_file",
"=",
"mock",
".",
"MagicMock",
"(",
"return_valu... | [
108,
4
] | [
118,
60
] | python | en | ['en', 'error', 'th'] | False |
TestXORCipher.test_decrypt_file | (self, mock_decrypt_file) |
Test the decrypt_file method with mocked values.
|
Test the decrypt_file method with mocked values.
| def test_decrypt_file(self, mock_decrypt_file):
"""
Test the decrypt_file method with mocked values.
"""
file = mock.MagicMock()
key = mock.MagicMock()
XORCipher.decrypt_string = mock.MagicMock(return_value=True)
XORCipher.decrypt_string(file, key)
XORCi... | [
"def",
"test_decrypt_file",
"(",
"self",
",",
"mock_decrypt_file",
")",
":",
"file",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"key",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"XORCipher",
".",
"decrypt_string",
"=",
"mock",
".",
"MagicMock",
"(",
"return_va... | [
121,
4
] | [
131,
62
] | python | en | ['en', 'error', 'th'] | False |
test_overfit_multiple_val_loaders | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test_overfit_multiple_val_loaders(tmpdir):
"""
Tests that only training_step can be used
"""
class TestModel(BoringModel):
def validation_step(self, batch, batch_idx, dataloader_idx):
output = self.layer(batch[0])
loss = self.loss(batch, output)
return {... | [
"def",
"test_overfit_multiple_val_loaders",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"validation_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
",",
"dataloader_idx",
")",
":",
"output",
"=",
"self",
".",
"layer"... | [
20,
0
] | [
50,
22
] | python | en | ['en', 'error', 'th'] | False |
test_overfit_basic | (tmpdir, overfit) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test_overfit_basic(tmpdir, overfit):
"""
Tests that only training_step can be used
"""
model = BoringModel()
trainer = Trainer(
default_root_dir=tmpdir,
max_epochs=1,
overfit_batches=overfit,
weights_summary=None,
)
trainer.fit(model) | [
"def",
"test_overfit_basic",
"(",
"tmpdir",
",",
"overfit",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"max_epochs",
"=",
"1",
",",
"overfit_batches",
"=",
"overfit",
",",
"weights... | [
54,
0
] | [
68,
22
] | python | en | ['en', 'error', 'th'] | False |
_c_string_literal | (s) |
Convert a python string into a literal suitable for inclusion into C code
|
Convert a python string into a literal suitable for inclusion into C code
| def _c_string_literal(s):
"""
Convert a python string into a literal suitable for inclusion into C code
"""
# only these three characters are forbidden in C strings
s = s.replace('\\', r'\\')
s = s.replace('"', r'\"')
s = s.replace('\n', r'\n')
return '"{}"'.format(s) | [
"def",
"_c_string_literal",
"(",
"s",
")",
":",
"# only these three characters are forbidden in C strings",
"s",
"=",
"s",
".",
"replace",
"(",
"'\\\\'",
",",
"r'\\\\'",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"'\"'",
",",
"r'\\\"'",
")",
"s",
"=",
"s",
"... | [
171,
0
] | [
179,
27
] | python | en | ['en', 'error', 'th'] | False |
libpaths | (paths, bits) | Return a list of library paths valid on 32 or 64 bit systems.
Inputs:
paths : sequence
A sequence of strings (typically paths)
bits : int
An integer, the only valid values are 32 or 64. A ValueError exception
is raised otherwise.
Examples:
Consider a list of directories... | Return a list of library paths valid on 32 or 64 bit systems. | def libpaths(paths, bits):
"""Return a list of library paths valid on 32 or 64 bit systems.
Inputs:
paths : sequence
A sequence of strings (typically paths)
bits : int
An integer, the only valid values are 32 or 64. A ValueError exception
is raised otherwise.
Examples:
... | [
"def",
"libpaths",
"(",
"paths",
",",
"bits",
")",
":",
"if",
"bits",
"not",
"in",
"(",
"32",
",",
"64",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid bit size in libpaths: 32 or 64 only\"",
")",
"# Handle 32bit case",
"if",
"bits",
"==",
"32",
":",
"retu... | [
182,
0
] | [
218,
14
] | python | en | ['en', 'en', 'en'] | True |
get_standard_file | (fname) | Returns a list of files named 'fname' from
1) System-wide directory (directory-location of this module)
2) Users HOME directory (os.environ['HOME'])
3) Local directory
| Returns a list of files named 'fname' from
1) System-wide directory (directory-location of this module)
2) Users HOME directory (os.environ['HOME'])
3) Local directory
| def get_standard_file(fname):
"""Returns a list of files named 'fname' from
1) System-wide directory (directory-location of this module)
2) Users HOME directory (os.environ['HOME'])
3) Local directory
"""
# System-wide file
filenames = []
try:
f = __file__
except NameError:
... | [
"def",
"get_standard_file",
"(",
"fname",
")",
":",
"# System-wide file",
"filenames",
"=",
"[",
"]",
"try",
":",
"f",
"=",
"__file__",
"except",
"NameError",
":",
"f",
"=",
"sys",
".",
"argv",
"[",
"0",
"]",
"else",
":",
"sysfile",
"=",
"os",
".",
"... | [
333,
0
] | [
366,
20
] | python | en | ['en', 'en', 'en'] | True |
get_info | (name, notfound_action=0) |
notfound_action:
0 - do nothing
1 - display warning message
2 - raise error
|
notfound_action:
0 - do nothing
1 - display warning message
2 - raise error
| def get_info(name, notfound_action=0):
"""
notfound_action:
0 - do nothing
1 - display warning message
2 - raise error
"""
cl = {'atlas': atlas_info, # use lapack_opt or blas_opt instead
'atlas_threads': atlas_threads_info, # ditto
'atlas_blas': atla... | [
"def",
"get_info",
"(",
"name",
",",
"notfound_action",
"=",
"0",
")",
":",
"cl",
"=",
"{",
"'atlas'",
":",
"atlas_info",
",",
"# use lapack_opt or blas_opt instead",
"'atlas_threads'",
":",
"atlas_threads_info",
",",
"# ditto",
"'atlas_blas'",
":",
"atlas_blas_info... | [
369,
0
] | [
443,
41
] | python | en | ['en', 'error', 'th'] | False |
combine_paths | (*args, **kws) | Return a list of existing paths composed by all combinations of
items from arguments.
| Return a list of existing paths composed by all combinations of
items from arguments.
| def combine_paths(*args, **kws):
""" Return a list of existing paths composed by all combinations of
items from arguments.
"""
r = []
for a in args:
if not a:
continue
if is_string(a):
a = [a]
r.append(a)
args = r
if not args:
retur... | [
"def",
"combine_paths",
"(",
"*",
"args",
",",
"*",
"*",
"kws",
")",
":",
"r",
"=",
"[",
"]",
"for",
"a",
"in",
"args",
":",
"if",
"not",
"a",
":",
"continue",
"if",
"is_string",
"(",
"a",
")",
":",
"a",
"=",
"[",
"a",
"]",
"r",
".",
"appen... | [
2706,
0
] | [
2730,
17
] | python | en | ['en', 'en', 'en'] | True |
system_info.get_option_single | (self, *options) | Ensure that only one of `options` are found in the section
Parameters
----------
*options : list of str
a list of options to be found in the section (``self.section``)
Returns
-------
str :
the option that is uniquely found in the section
... | Ensure that only one of `options` are found in the section | def get_option_single(self, *options):
""" Ensure that only one of `options` are found in the section
Parameters
----------
*options : list of str
a list of options to be found in the section (``self.section``)
Returns
-------
str :
the op... | [
"def",
"get_option_single",
"(",
"self",
",",
"*",
"options",
")",
":",
"found",
"=",
"map",
"(",
"lambda",
"opt",
":",
"self",
".",
"cp",
".",
"has_option",
"(",
"self",
".",
"section",
",",
"opt",
")",
",",
"options",
")",
"found",
"=",
"list",
"... | [
628,
4
] | [
658,
77
] | python | en | ['en', 'en', 'en'] | True |
system_info.calc_extra_info | (self) | Updates the information in the current information with
respect to these flags:
extra_compile_args
extra_link_args
| Updates the information in the current information with
respect to these flags:
extra_compile_args
extra_link_args
| def calc_extra_info(self):
""" Updates the information in the current information with
respect to these flags:
extra_compile_args
extra_link_args
"""
info = {}
for key in ['extra_compile_args', 'extra_link_args']:
# Get values
opt = sel... | [
"def",
"calc_extra_info",
"(",
"self",
")",
":",
"info",
"=",
"{",
"}",
"for",
"key",
"in",
"[",
"'extra_compile_args'",
",",
"'extra_link_args'",
"]",
":",
"# Get values",
"opt",
"=",
"self",
".",
"cp",
".",
"get",
"(",
"self",
".",
"section",
",",
"k... | [
664,
4
] | [
678,
19
] | python | en | ['en', 'en', 'en'] | True |
system_info.get_info | (self, notfound_action=0) | Return a dictonary with items that are compatible
with numpy.distutils.setup keyword arguments.
| Return a dictonary with items that are compatible
with numpy.distutils.setup keyword arguments.
| def get_info(self, notfound_action=0):
""" Return a dictonary with items that are compatible
with numpy.distutils.setup keyword arguments.
"""
flag = 0
if not self.has_info():
flag = 1
log.info(self.__class__.__name__ + ':')
if hasattr(self... | [
"def",
"get_info",
"(",
"self",
",",
"notfound_action",
"=",
"0",
")",
":",
"flag",
"=",
"0",
"if",
"not",
"self",
".",
"has_info",
"(",
")",
":",
"flag",
"=",
"1",
"log",
".",
"info",
"(",
"self",
".",
"__class__",
".",
"__name__",
"+",
"':'",
"... | [
680,
4
] | [
714,
33
] | python | en | ['en', 'en', 'en'] | True |
system_info.check_libs | (self, lib_dirs, libs, opt_libs=[]) | If static or shared libraries are available then return
their info dictionary.
Checks for all libraries as shared libraries first, then
static (or vice versa if self.search_static_first is True).
| If static or shared libraries are available then return
their info dictionary. | def check_libs(self, lib_dirs, libs, opt_libs=[]):
"""If static or shared libraries are available then return
their info dictionary.
Checks for all libraries as shared libraries first, then
static (or vice versa if self.search_static_first is True).
"""
exts = self.libra... | [
"def",
"check_libs",
"(",
"self",
",",
"lib_dirs",
",",
"libs",
",",
"opt_libs",
"=",
"[",
"]",
")",
":",
"exts",
"=",
"self",
".",
"library_extensions",
"(",
")",
"info",
"=",
"None",
"for",
"ext",
"in",
"exts",
":",
"info",
"=",
"self",
".",
"_ch... | [
821,
4
] | [
837,
19
] | python | en | ['en', 'en', 'en'] | True |
system_info.check_libs2 | (self, lib_dirs, libs, opt_libs=[]) | If static or shared libraries are available then return
their info dictionary.
Checks each library for shared or static.
| If static or shared libraries are available then return
their info dictionary. | def check_libs2(self, lib_dirs, libs, opt_libs=[]):
"""If static or shared libraries are available then return
their info dictionary.
Checks each library for shared or static.
"""
exts = self.library_extensions()
info = self._check_libs(lib_dirs, libs, opt_libs, exts)
... | [
"def",
"check_libs2",
"(",
"self",
",",
"lib_dirs",
",",
"libs",
",",
"opt_libs",
"=",
"[",
"]",
")",
":",
"exts",
"=",
"self",
".",
"library_extensions",
"(",
")",
"info",
"=",
"self",
".",
"_check_libs",
"(",
"lib_dirs",
",",
"libs",
",",
"opt_libs",... | [
839,
4
] | [
851,
19
] | python | en | ['en', 'en', 'en'] | True |
system_info._check_libs | (self, lib_dirs, libs, opt_libs, exts) | Find mandatory and optional libs in expected paths.
Missing optional libraries are silently forgotten.
| Find mandatory and optional libs in expected paths. | def _check_libs(self, lib_dirs, libs, opt_libs, exts):
"""Find mandatory and optional libs in expected paths.
Missing optional libraries are silently forgotten.
"""
if not is_sequence(lib_dirs):
lib_dirs = [lib_dirs]
# First, try to find the mandatory libraries
... | [
"def",
"_check_libs",
"(",
"self",
",",
"lib_dirs",
",",
"libs",
",",
"opt_libs",
",",
"exts",
")",
":",
"if",
"not",
"is_sequence",
"(",
"lib_dirs",
")",
":",
"lib_dirs",
"=",
"[",
"lib_dirs",
"]",
"# First, try to find the mandatory libraries",
"found_dirs",
... | [
891,
4
] | [
910,
23
] | python | en | ['en', 'en', 'en'] | True |
system_info.combine_paths | (self, *args) | Return a list of existing paths composed by all combinations
of items from the arguments.
| Return a list of existing paths composed by all combinations
of items from the arguments.
| def combine_paths(self, *args):
"""Return a list of existing paths composed by all combinations
of items from the arguments.
"""
return combine_paths(*args, **{'verbosity': self.verbosity}) | [
"def",
"combine_paths",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"combine_paths",
"(",
"*",
"args",
",",
"*",
"*",
"{",
"'verbosity'",
":",
"self",
".",
"verbosity",
"}",
")"
] | [
912,
4
] | [
916,
68
] | python | en | ['en', 'en', 'en'] | True |
fftw_info.calc_ver_info | (self, ver_param) | Returns True on successful version detection, else False | Returns True on successful version detection, else False | def calc_ver_info(self, ver_param):
"""Returns True on successful version detection, else False"""
lib_dirs = self.get_lib_dirs()
incl_dirs = self.get_include_dirs()
opt = self.get_option_single(self.section + '_libs', 'libraries')
libs = self.get_libs(opt, ver_param['libs'])
... | [
"def",
"calc_ver_info",
"(",
"self",
",",
"ver_param",
")",
":",
"lib_dirs",
"=",
"self",
".",
"get_lib_dirs",
"(",
")",
"incl_dirs",
"=",
"self",
".",
"get_include_dirs",
"(",
")",
"opt",
"=",
"self",
".",
"get_option_single",
"(",
"self",
".",
"section",... | [
947,
4
] | [
972,
24
] | python | en | ['es', 'fr', 'en'] | False |
blas_info.get_cblas_libs | (self, info) | Check whether we can link with CBLAS interface
This method will search through several combinations of libraries
to check whether CBLAS is present:
1. Libraries in ``info['libraries']``, as is
2. As 1. but also explicitly adding ``'cblas'`` as a library
3. As 1. but also expli... | Check whether we can link with CBLAS interface | def get_cblas_libs(self, info):
""" Check whether we can link with CBLAS interface
This method will search through several combinations of libraries
to check whether CBLAS is present:
1. Libraries in ``info['libraries']``, as is
2. As 1. but also explicitly adding ``'cblas'`` a... | [
"def",
"get_cblas_libs",
"(",
"self",
",",
"info",
")",
":",
"# primitive cblas check by looking for the header and trying to link",
"# cblas or blas",
"c",
"=",
"customized_ccompiler",
"(",
")",
"tmpdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"s",
"=",
"textwrap... | [
1848,
4
] | [
1913,
19
] | python | en | ['en', 'en', 'en'] | True |
flame_info.check_embedded_lapack | (self, info) | libflame does not necessarily have a wrapper for fortran LAPACK, we need to check | libflame does not necessarily have a wrapper for fortran LAPACK, we need to check | def check_embedded_lapack(self, info):
""" libflame does not necessarily have a wrapper for fortran LAPACK, we need to check """
c = customized_ccompiler()
tmpdir = tempfile.mkdtemp()
s = textwrap.dedent("""\
void zungqr_();
int main(int argc, const char *argv[])... | [
"def",
"check_embedded_lapack",
"(",
"self",
",",
"info",
")",
":",
"c",
"=",
"customized_ccompiler",
"(",
")",
"tmpdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"s",
"=",
"textwrap",
".",
"dedent",
"(",
"\"\"\"\\\n void zungqr_();\n int m... | [
2074,
4
] | [
2102,
33
] | python | en | ['en', 'en', 'en'] | True |
_merge | (old, new) | Concatenate two environment paths avoiding repeats.
Here `old` is the environment string before the base class initialize
function is called and `new` is the string after the call. The new string
will be a fixed string if it is not obtained from the current environment,
or the same as the old string if... | Concatenate two environment paths avoiding repeats. | def _merge(old, new):
"""Concatenate two environment paths avoiding repeats.
Here `old` is the environment string before the base class initialize
function is called and `new` is the string after the call. The new string
will be a fixed string if it is not obtained from the current environment,
or ... | [
"def",
"_merge",
"(",
"old",
",",
"new",
")",
":",
"if",
"not",
"new",
"or",
"new",
"in",
"old",
":",
"return",
"old",
"if",
"not",
"old",
"or",
"old",
"in",
"new",
":",
"return",
"new",
"# Neither new nor old is empty. Give old priority.",
"return",
"';'"... | [
8,
0
] | [
37,
31
] | python | en | ['en', 'en', 'en'] | True |
test_passing_env_variables | (tmpdir) | Testing overwriting trainer arguments | Testing overwriting trainer arguments | def test_passing_env_variables(tmpdir):
"""Testing overwriting trainer arguments """
trainer = Trainer()
assert trainer.logger is not None
assert trainer.max_steps is None
trainer = Trainer(False, max_steps=42)
assert trainer.logger is None
assert trainer.max_steps == 42
os.environ['PL_... | [
"def",
"test_passing_env_variables",
"(",
"tmpdir",
")",
":",
"trainer",
"=",
"Trainer",
"(",
")",
"assert",
"trainer",
".",
"logger",
"is",
"not",
"None",
"assert",
"trainer",
".",
"max_steps",
"is",
"None",
"trainer",
"=",
"Trainer",
"(",
"False",
",",
"... | [
18,
0
] | [
40,
42
] | python | en | ['en', 'en', 'en'] | True |
fizz_buzz_generator | (fizzbuzz, start=1, end=21) | Prints all of the answers for fizz, buzz or fizzbuzz between the specified interval | Prints all of the answers for fizz, buzz or fizzbuzz between the specified interval | def fizz_buzz_generator(fizzbuzz, start=1, end=21):
""" Prints all of the answers for fizz, buzz or fizzbuzz between the specified interval"""
def fizz(start, end):
for i in range(start,end):
if i % 3 == 0:
yield f"{i} : 'FIZZ!'"
def buzz(start, end):
for i in range(start,end):
... | [
"def",
"fizz_buzz_generator",
"(",
"fizzbuzz",
",",
"start",
"=",
"1",
",",
"end",
"=",
"21",
")",
":",
"def",
"fizz",
"(",
"start",
",",
"end",
")",
":",
"for",
"i",
"in",
"range",
"(",
"start",
",",
"end",
")",
":",
"if",
"i",
"%",
"3",
"==",... | [
0,
0
] | [
42,
10
] | python | en | ['en', 'en', 'en'] | True |
SuccessfulSignUpTests.test_form_inputs | (self) |
testing form input
:return:
|
testing form input
:return:
| def test_form_inputs(self):
"""
testing form input
:return:
"""
self.assertContains(self.response, '<input', 5)
self.assertContains(self.response, 'type="text"', 1)
self.assertContains(self.response, 'type="email"', 1)
self.assertContains(self.response, 't... | [
"def",
"test_form_inputs",
"(",
"self",
")",
":",
"self",
".",
"assertContains",
"(",
"self",
".",
"response",
",",
"'<input'",
",",
"5",
")",
"self",
".",
"assertContains",
"(",
"self",
".",
"response",
",",
"'type=\"text\"'",
",",
"1",
")",
"self",
"."... | [
66,
4
] | [
74,
64
] | python | en | ['en', 'error', 'th'] | False |
SuccessfulSignUpTests.test_redirection | (self) |
testing for redirection to profile edit page upon signup
|
testing for redirection to profile edit page upon signup
| def test_redirection(self):
"""
testing for redirection to profile edit page upon signup
"""
self.assertRedirects(self.response, self.edit_profile_url) | [
"def",
"test_redirection",
"(",
"self",
")",
":",
"self",
".",
"assertRedirects",
"(",
"self",
".",
"response",
",",
"self",
".",
"edit_profile_url",
")"
] | [
76,
4
] | [
80,
66
] | python | en | ['en', 'error', 'th'] | False |
SuccessfulSignUpTests.test_user_authentication | (self) |
test user authentication
|
test user authentication | def test_user_authentication(self):
"""
test user authentication
"""
response = self.client.get(self.edit_profile_url)
user = response.context.get('user')
self.assertTrue(user.is_authenticated) | [
"def",
"test_user_authentication",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"self",
".",
"edit_profile_url",
")",
"user",
"=",
"response",
".",
"context",
".",
"get",
"(",
"'user'",
")",
"self",
".",
"assertTrue",
"... | [
85,
4
] | [
92,
46
] | python | en | ['en', 'error', 'th'] | False |
InvalidSignUpTests.test_signup_status_code | (self) |
testing invalid form submission
|
testing invalid form submission
| def test_signup_status_code(self):
"""
testing invalid form submission
"""
self.assertEquals(self.response.status_code, 200) | [
"def",
"test_signup_status_code",
"(",
"self",
")",
":",
"self",
".",
"assertEquals",
"(",
"self",
".",
"response",
".",
"status_code",
",",
"200",
")"
] | [
104,
4
] | [
108,
57
] | python | en | ['en', 'error', 'th'] | False |
PasswordResetTests.test_form_inputs | (self) |
testing whether form contain csrf
:return:
|
testing whether form contain csrf
:return:
| def test_form_inputs(self):
"""
testing whether form contain csrf
:return:
"""
self.assertContains(self.response, '<input', 2)
self.assertContains(self.response, 'type="email"', 1) | [
"def",
"test_form_inputs",
"(",
"self",
")",
":",
"self",
".",
"assertContains",
"(",
"self",
".",
"response",
",",
"'<input'",
",",
"2",
")",
"self",
".",
"assertContains",
"(",
"self",
".",
"response",
",",
"'type=\"email\"'",
",",
"1",
")"
] | [
141,
4
] | [
147,
61
] | python | en | ['en', 'error', 'th'] | False |
SuccessfulPasswordResetTests.test_redirection | (self) |
testing redirection of users after password
|
testing redirection of users after password
| def test_redirection(self):
"""
testing redirection of users after password
"""
url = reverse('password_reset_done')
self.assertRedirects(self.response, url) | [
"def",
"test_redirection",
"(",
"self",
")",
":",
"url",
"=",
"reverse",
"(",
"'password_reset_done'",
")",
"self",
".",
"assertRedirects",
"(",
"self",
".",
"response",
",",
"url",
")"
] | [
158,
4
] | [
163,
48
] | python | en | ['en', 'error', 'th'] | False |
InvalidPasswordResetTests.test_redirection | (self) |
testing redirection after password reset
|
testing redirection after password reset
| def test_redirection(self):
"""
testing redirection after password reset
"""
url = reverse('password_reset_done')
self.assertRedirects(self.response, url) | [
"def",
"test_redirection",
"(",
"self",
")",
":",
"url",
"=",
"reverse",
"(",
"'password_reset_done'",
")",
"self",
".",
"assertRedirects",
"(",
"self",
".",
"response",
",",
"url",
")"
] | [
175,
4
] | [
180,
48
] | python | en | ['en', 'error', 'th'] | False |
PasswordResetConfirmTests.setUp | (self) |
test creating a valid reset password token
|
test creating a valid reset password token
| def setUp(self):
user = User.objects.create_user(username='eugene', email='eugenenziokim@gmail.com', password='123abcdef')
"""
test creating a valid reset password token
"""
self.uid = urlsafe_base64_encode(force_bytes(user.pk)).decode()
self.token = default_token_genera... | [
"def",
"setUp",
"(",
"self",
")",
":",
"user",
"=",
"User",
".",
"objects",
".",
"create_user",
"(",
"username",
"=",
"'eugene'",
",",
"email",
"=",
"'eugenenziokim@gmail.com'",
",",
"password",
"=",
"'123abcdef'",
")",
"self",
".",
"uid",
"=",
"urlsafe_ba... | [
227,
4
] | [
237,
57
] | python | en | ['en', 'error', 'th'] | False |
InvalidPasswordResetConfirmTests.setUp | (self) |
testing token invalidation by changing the password
|
testing token invalidation by changing the password
| def setUp(self):
user = User.objects.create_user(username='eugene', email='eugenenziokim@gmail.com', password='123abcdef')
uid = urlsafe_base64_encode(force_bytes(user.pk)).decode()
token = default_token_generator.make_token(user)
"""
testing token invalidation by changing the p... | [
"def",
"setUp",
"(",
"self",
")",
":",
"user",
"=",
"User",
".",
"objects",
".",
"create_user",
"(",
"username",
"=",
"'eugene'",
",",
"email",
"=",
"'eugenenziokim@gmail.com'",
",",
"password",
"=",
"'123abcdef'",
")",
"uid",
"=",
"urlsafe_base64_encode",
"... | [
260,
4
] | [
272,
44
] | python | en | ['en', 'error', 'th'] | False |
SuccessfulPasswordChangeTests.test_redirection | (self) |
testing user redirection after submitting password change form
:return:
|
testing user redirection after submitting password change form
:return:
| def test_redirection(self):
"""
testing user redirection after submitting password change form
:return:
"""
self.assertRedirects(self.response, reverse('password_change_done')) | [
"def",
"test_redirection",
"(",
"self",
")",
":",
"self",
".",
"assertRedirects",
"(",
"self",
".",
"response",
",",
"reverse",
"(",
"'password_change_done'",
")",
")"
] | [
319,
4
] | [
324,
76
] | python | en | ['en', 'error', 'th'] | False |
SuccessfulPasswordChangeTests.test_password_changed | (self) |
refreshing user instance to get new password
|
refreshing user instance to get new password
| def test_password_changed(self):
"""
refreshing user instance to get new password
"""
self.user.refresh_from_db()
self.assertTrue(self.user.check_password('new_password')) | [
"def",
"test_password_changed",
"(",
"self",
")",
":",
"self",
".",
"user",
".",
"refresh_from_db",
"(",
")",
"self",
".",
"assertTrue",
"(",
"self",
".",
"user",
".",
"check_password",
"(",
"'new_password'",
")",
")"
] | [
326,
4
] | [
331,
65
] | python | en | ['en', 'error', 'th'] | False |
SuccessfulPasswordChangeTests.test_user_authentication | (self) |
creating request to a random page upon successful authentication after password change
|
creating request to a random page upon successful authentication after password change | def test_user_authentication(self):
"""
creating request to a random page upon successful authentication after password change
"""
response = self.client.get(reverse('home'))
user = response.context.get('user')
self.assertTrue(user.is_authenticated) | [
"def",
"test_user_authentication",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'home'",
")",
")",
"user",
"=",
"response",
".",
"context",
".",
"get",
"(",
"'user'",
")",
"self",
".",
"assertTrue",
"... | [
333,
4
] | [
340,
46
] | python | en | ['en', 'error', 'th'] | False |
ModelThread.__init__ | (self, X_train:np.ndarray, t_train:np.ndarray, model:BaseEstimator, cv:int, scoring:dict, **kwargs) | Create an instance of the ModelThread class and set their attributes.
:param X_train: Characteristic matrix numpy array of the dataset which will be evaluated
:type X_train: np.ndarray
:param t_train: Vector labels numpy array of the dataset which will be evaluated
:type t_train: np.nda... | Create an instance of the ModelThread class and set their attributes. | def __init__(self, X_train:np.ndarray, t_train:np.ndarray, model:BaseEstimator, cv:int, scoring:dict, **kwargs):
"""Create an instance of the ModelThread class and set their attributes.
:param X_train: Characteristic matrix numpy array of the dataset which will be evaluated
:type X_train: np.nd... | [
"def",
"__init__",
"(",
"self",
",",
"X_train",
":",
"np",
".",
"ndarray",
",",
"t_train",
":",
"np",
".",
"ndarray",
",",
"model",
":",
"BaseEstimator",
",",
"cv",
":",
"int",
",",
"scoring",
":",
"dict",
",",
"*",
"*",
"kwargs",
")",
":",
"super"... | [
13,
4
] | [
33,
26
] | python | en | ['en', 'en', 'en'] | True |
ModelThread.run | (self) | Run the cv_multithread_model function in an isolated thread. | Run the cv_multithread_model function in an isolated thread. | def run(self):
"""Run the cv_multithread_model function in an isolated thread."""
self.cv_multithread_model() | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"cv_multithread_model",
"(",
")"
] | [
35,
4
] | [
37,
35
] | python | en | ['en', 'ga', 'en'] | True |
ModelThread.cv_multithread_model | (self) | Perform the cross validation using the class attributes. | Perform the cross validation using the class attributes. | def cv_multithread_model(self):
"""Perform the cross validation using the class attributes."""
self.scores = cross_validate(
self.model,
self.X_train,
self.t_train,
cv=self.cv,
scoring=self.scoring,
return_train_score=True,
... | [
"def",
"cv_multithread_model",
"(",
"self",
")",
":",
"self",
".",
"scores",
"=",
"cross_validate",
"(",
"self",
".",
"model",
",",
"self",
".",
"X_train",
",",
"self",
".",
"t_train",
",",
"cv",
"=",
"self",
".",
"cv",
",",
"scoring",
"=",
"self",
"... | [
39,
4
] | [
48,
9
] | python | en | ['en', 'en', 'en'] | True |
DnnThread.__init__ | (self, X_train:np.ndarray, t_train:np.ndarray, X_val:np.ndarray, t_val:np.ndarray, model:models.Sequential, epochs:int, batch_size:int, **kwargs) | Create an instance of the DnnThread class and set their attributes.
:param X_train: Characteristic matrix numpy array of the dataset which will be used for the training
:type X_train: np.ndarray
:param t_train: Vector labels numpy array of the dataset which will be used for the training
... | Create an instance of the DnnThread class and set their attributes. | def __init__(self, X_train:np.ndarray, t_train:np.ndarray, X_val:np.ndarray, t_val:np.ndarray, model:models.Sequential, epochs:int, batch_size:int, **kwargs):
"""Create an instance of the DnnThread class and set their attributes.
:param X_train: Characteristic matrix numpy array of the dataset which wi... | [
"def",
"__init__",
"(",
"self",
",",
"X_train",
":",
"np",
".",
"ndarray",
",",
"t_train",
":",
"np",
".",
"ndarray",
",",
"X_val",
":",
"np",
".",
"ndarray",
",",
"t_val",
":",
"np",
".",
"ndarray",
",",
"model",
":",
"models",
".",
"Sequential",
... | [
54,
4
] | [
80,
27
] | python | en | ['en', 'en', 'en'] | True |
DnnThread.run | (self) | Run the fit_dnn function in an isolated thread. | Run the fit_dnn function in an isolated thread. | def run(self):
"""Run the fit_dnn function in an isolated thread."""
self.fit_dnn() | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"fit_dnn",
"(",
")"
] | [
82,
4
] | [
84,
22
] | python | en | ['en', 'en', 'en'] | True |
DnnThread.fit_dnn | (self) | Train the model using the class attributes. | Train the model using the class attributes. | def fit_dnn(self):
"""Train the model using the class attributes."""
self.history = self.model.fit(
self.X_train,
self.t_train,
validation_data=(self.X_val, self.t_val),
epochs=self.epochs,
batch_size=self.batch_size,
verbose=0,
... | [
"def",
"fit_dnn",
"(",
"self",
")",
":",
"self",
".",
"history",
"=",
"self",
".",
"model",
".",
"fit",
"(",
"self",
".",
"X_train",
",",
"self",
".",
"t_train",
",",
"validation_data",
"=",
"(",
"self",
".",
"X_val",
",",
"self",
".",
"t_val",
")"... | [
86,
4
] | [
95,
9
] | python | en | ['en', 'en', 'en'] | True |
is_mul_of_15 | (num: int) |
check if num is multiples of 15.
:param num: the integer to check
the integer must not be larger than 100.
|
check if num is multiples of 15. | def is_mul_of_15(num: int) -> bool:
"""
check if num is multiples of 15.
:param num: the integer to check
the integer must not be larger than 100.
"""
for i in range(1, math.ceil(100/15)+1):
if num == i * 15:
return True
break
return False | [
"def",
"is_mul_of_15",
"(",
"num",
":",
"int",
")",
"->",
"bool",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"math",
".",
"ceil",
"(",
"100",
"/",
"15",
")",
"+",
"1",
")",
":",
"if",
"num",
"==",
"i",
"*",
"15",
":",
"return",
"True",
... | [
8,
0
] | [
19,
16
] | python | en | ['en', 'error', 'th'] | False |
fb | () |
Prints the required FizzBuzz
|
Prints the required FizzBuzz
| def fb() -> None:
"""
Prints the required FizzBuzz
"""
for i in range(1, 101):
s = str(i)
if is_mul_of_15(i):
print("FizzBuzz")
elif re.search('[05]$', s):
print("Buzz")
continue
elif sum((int(digit) for digit in s)) % 3 == 0:
... | [
"def",
"fb",
"(",
")",
"->",
"None",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"101",
")",
":",
"s",
"=",
"str",
"(",
"i",
")",
"if",
"is_mul_of_15",
"(",
"i",
")",
":",
"print",
"(",
"\"FizzBuzz\"",
")",
"elif",
"re",
".",
"search",
"("... | [
22,
0
] | [
36,
20
] | python | en | ['en', 'error', 'th'] | False |
test_non_contiguous_tensors | () | Test that gather_all operation works for non contiguous tensors | Test that gather_all operation works for non contiguous tensors | def test_non_contiguous_tensors():
""" Test that gather_all operation works for non contiguous tensors """
torch.multiprocessing.spawn(_test_non_contiguous_tensors, args=(2, ), nprocs=2) | [
"def",
"test_non_contiguous_tensors",
"(",
")",
":",
"torch",
".",
"multiprocessing",
".",
"spawn",
"(",
"_test_non_contiguous_tensors",
",",
"args",
"=",
"(",
"2",
",",
")",
",",
"nprocs",
"=",
"2",
")"
] | [
69,
0
] | [
71,
83
] | python | en | ['en', 'en', 'en'] | True |
_demo_mm_inputs | (input_shape=(1, 3, 256, 256), num_outputs=None) | Create a superset of inputs needed to run test or train batches.
Args:
input_shape (tuple):
input batch dimensions
| Create a superset of inputs needed to run test or train batches. | def _demo_mm_inputs(input_shape=(1, 3, 256, 256), num_outputs=None):
"""Create a superset of inputs needed to run test or train batches.
Args:
input_shape (tuple):
input batch dimensions
"""
(N, C, H, W) = input_shape
rng = np.random.RandomState(0)
imgs = rng.rand(*input_s... | [
"def",
"_demo_mm_inputs",
"(",
"input_shape",
"=",
"(",
"1",
",",
"3",
",",
"256",
",",
"256",
")",
",",
"num_outputs",
"=",
"None",
")",
":",
"(",
"N",
",",
"C",
",",
"H",
",",
"W",
")",
"=",
"input_shape",
"rng",
"=",
"np",
".",
"random",
"."... | [
185,
0
] | [
221,
20
] | python | en | ['en', 'en', 'en'] | True |
psnr | (
preds: torch.Tensor,
target: torch.Tensor,
data_range: Optional[float] = None,
base: float = 10.0,
reduction: str = 'elementwise_mean',
dim: Optional[Union[int, Tuple[int, ...]]] = None,
) |
Computes the peak signal-to-noise ratio
Args:
preds: estimated signal
target: groun truth signal
data_range:
the range of the data. If None, it is determined from the data (max - min). ``data_range`` must be given
when ``dim`` is not None.
base: a base o... |
Computes the peak signal-to-noise ratio | def psnr(
preds: torch.Tensor,
target: torch.Tensor,
data_range: Optional[float] = None,
base: float = 10.0,
reduction: str = 'elementwise_mean',
dim: Optional[Union[int, Tuple[int, ...]]] = None,
) -> torch.Tensor:
"""
Computes the peak signal-to-noise ratio
Args:
preds: es... | [
"def",
"psnr",
"(",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"data_range",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
",",
"base",
":",
"float",
"=",
"10.0",
",",
"reduction",
":",
"str",
"=",
"'e... | [
56,
0
] | [
107,
94
] | python | en | ['en', 'error', 'th'] | False |
test_model_checkpoint_score_and_ckpt | (tmpdir, validation_step, val_dataloaders, monitor, reduce_lr_on_plateau) |
Test that when a model checkpoint is saved, it saves with
the correct score appended to ckpt_path and checkpoint data
|
Test that when a model checkpoint is saved, it saves with
the correct score appended to ckpt_path and checkpoint data
| def test_model_checkpoint_score_and_ckpt(tmpdir, validation_step, val_dataloaders, monitor, reduce_lr_on_plateau):
"""
Test that when a model checkpoint is saved, it saves with
the correct score appended to ckpt_path and checkpoint data
"""
max_epochs = 3
limit_train_batches = 5
limit_val_ba... | [
"def",
"test_model_checkpoint_score_and_ckpt",
"(",
"tmpdir",
",",
"validation_step",
",",
"val_dataloaders",
",",
"monitor",
",",
"reduce_lr_on_plateau",
")",
":",
"max_epochs",
"=",
"3",
"limit_train_batches",
"=",
"5",
"limit_val_batches",
"=",
"7",
"lr",
"=",
"1... | [
61,
0
] | [
152,
102
] | python | en | ['en', 'error', 'th'] | False |
test_model_checkpoint_score_and_ckpt_val_check_interval | (tmpdir, val_check_interval, reduce_lr_on_plateau) |
Test that when a model checkpoint is saved, it saves with the correct
score appended to ckpt_path and checkpoint data with val_check_interval
|
Test that when a model checkpoint is saved, it saves with the correct
score appended to ckpt_path and checkpoint data with val_check_interval
| def test_model_checkpoint_score_and_ckpt_val_check_interval(tmpdir, val_check_interval, reduce_lr_on_plateau):
"""
Test that when a model checkpoint is saved, it saves with the correct
score appended to ckpt_path and checkpoint data with val_check_interval
"""
max_epochs = 3
limit_train_batches ... | [
"def",
"test_model_checkpoint_score_and_ckpt_val_check_interval",
"(",
"tmpdir",
",",
"val_check_interval",
",",
"reduce_lr_on_plateau",
")",
":",
"max_epochs",
"=",
"3",
"limit_train_batches",
"=",
"12",
"limit_val_batches",
"=",
"7",
"lr",
"=",
"1e-1",
"monitor",
"=",... | [
164,
0
] | [
257,
102
] | python | en | ['en', 'error', 'th'] | False |
test_model_checkpoint_with_non_string_input | (tmpdir, save_top_k) | Test that dirpath=None in checkpoint callback is valid and that ckpt_path is set correctly | Test that dirpath=None in checkpoint callback is valid and that ckpt_path is set correctly | def test_model_checkpoint_with_non_string_input(tmpdir, save_top_k):
"""Test that dirpath=None in checkpoint callback is valid and that ckpt_path is set correctly"""
tutils.reset_seed()
model = LogInTwoMethods()
checkpoint = ModelCheckpoint(monitor='early_stop_on', dirpath=None, filename='{epoch}', sav... | [
"def",
"test_model_checkpoint_with_non_string_input",
"(",
"tmpdir",
",",
"save_top_k",
")",
":",
"tutils",
".",
"reset_seed",
"(",
")",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"checkpoint",
"=",
"ModelCheckpoint",
"(",
"monitor",
"=",
"'early_stop_on'",
",",
"... | [
261,
0
] | [
281,
58
] | python | en | ['en', 'en', 'en'] | True |
test_model_checkpoint_to_yaml | (tmpdir, save_top_k) | Test that None in checkpoint callback is valid and that chkp_path is set correctly | Test that None in checkpoint callback is valid and that chkp_path is set correctly | def test_model_checkpoint_to_yaml(tmpdir, save_top_k):
""" Test that None in checkpoint callback is valid and that chkp_path is set correctly """
tutils.reset_seed()
model = LogInTwoMethods()
checkpoint = ModelCheckpoint(dirpath=tmpdir, monitor='early_stop_on', save_top_k=save_top_k)
trainer = Tra... | [
"def",
"test_model_checkpoint_to_yaml",
"(",
"tmpdir",
",",
"save_top_k",
")",
":",
"tutils",
".",
"reset_seed",
"(",
")",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"checkpoint",
"=",
"ModelCheckpoint",
"(",
"dirpath",
"=",
"tmpdir",
",",
"monitor",
"=",
"'ea... | [
285,
0
] | [
299,
22
] | python | en | ['en', 'en', 'en'] | True |
test_model_checkpoint_path | (tmpdir, logger_version, expected) | Test that "version_" prefix is only added when logger's version is an integer | Test that "version_" prefix is only added when logger's version is an integer | def test_model_checkpoint_path(tmpdir, logger_version, expected):
"""Test that "version_" prefix is only added when logger's version is an integer"""
tutils.reset_seed()
model = LogInTwoMethods()
logger = TensorBoardLogger(str(tmpdir), version=logger_version)
trainer = Trainer(
default_root... | [
"def",
"test_model_checkpoint_path",
"(",
"tmpdir",
",",
"logger_version",
",",
"expected",
")",
":",
"tutils",
".",
"reset_seed",
"(",
")",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"logger",
"=",
"TensorBoardLogger",
"(",
"str",
"(",
"tmpdir",
")",
",",
"... | [
306,
0
] | [
321,
35
] | python | en | ['en', 'en', 'en'] | True |
test_model_checkpoint_no_extraneous_invocations | (tmpdir) | Test to ensure that the model callback saves the checkpoints only once in distributed mode. | Test to ensure that the model callback saves the checkpoints only once in distributed mode. | def test_model_checkpoint_no_extraneous_invocations(tmpdir):
"""Test to ensure that the model callback saves the checkpoints only once in distributed mode."""
model = LogInTwoMethods()
num_epochs = 4
model_checkpoint = ModelCheckpointTestInvocations(monitor='early_stop_on', expected_count=num_epochs, sa... | [
"def",
"test_model_checkpoint_no_extraneous_invocations",
"(",
"tmpdir",
")",
":",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"num_epochs",
"=",
"4",
"model_checkpoint",
"=",
"ModelCheckpointTestInvocations",
"(",
"monitor",
"=",
"'early_stop_on'",
",",
"expected_count",
... | [
369,
0
] | [
382,
90
] | python | en | ['en', 'en', 'en'] | True |
test_model_checkpoint_file_extension | (tmpdir) |
Test ModelCheckpoint with different file extension.
|
Test ModelCheckpoint with different file extension.
| def test_model_checkpoint_file_extension(tmpdir):
"""
Test ModelCheckpoint with different file extension.
"""
model = LogInTwoMethods()
model_checkpoint = ModelCheckpointExtensionTest(
monitor='early_stop_on',
dirpath=tmpdir,
save_top_k=1,
save_last=True,
)
t... | [
"def",
"test_model_checkpoint_file_extension",
"(",
"tmpdir",
")",
":",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"model_checkpoint",
"=",
"ModelCheckpointExtensionTest",
"(",
"monitor",
"=",
"'early_stop_on'",
",",
"dirpath",
"=",
"tmpdir",
",",
"save_top_k",
"=",
... | [
433,
0
] | [
454,
51
] | python | en | ['en', 'error', 'th'] | False |
test_model_checkpoint_save_last | (tmpdir) | Tests that save_last produces only one last checkpoint. | Tests that save_last produces only one last checkpoint. | def test_model_checkpoint_save_last(tmpdir):
"""Tests that save_last produces only one last checkpoint."""
seed_everything()
model = LogInTwoMethods()
epochs = 3
ModelCheckpoint.CHECKPOINT_NAME_LAST = 'last-{epoch}'
model_checkpoint = ModelCheckpoint(monitor='early_stop_on', dirpath=tmpdir, save... | [
"def",
"test_model_checkpoint_save_last",
"(",
"tmpdir",
")",
":",
"seed_everything",
"(",
")",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"epochs",
"=",
"3",
"ModelCheckpoint",
".",
"CHECKPOINT_NAME_LAST",
"=",
"'last-{epoch}'",
"model_checkpoint",
"=",
"ModelCheckpo... | [
457,
0
] | [
481,
49
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_top_k | (tmpdir) | Make sure that a MisconfigurationException is raised for a negative save_top_k argument. | Make sure that a MisconfigurationException is raised for a negative save_top_k argument. | def test_invalid_top_k(tmpdir):
""" Make sure that a MisconfigurationException is raised for a negative save_top_k argument. """
with pytest.raises(MisconfigurationException, match=r'.*Must be None or >= -1'):
ModelCheckpoint(dirpath=tmpdir, save_top_k=-3) | [
"def",
"test_invalid_top_k",
"(",
"tmpdir",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"MisconfigurationException",
",",
"match",
"=",
"r'.*Must be None or >= -1'",
")",
":",
"ModelCheckpoint",
"(",
"dirpath",
"=",
"tmpdir",
",",
"save_top_k",
"=",
"-",
"3"... | [
484,
0
] | [
487,
54
] | python | en | ['en', 'en', 'en'] | True |
test_none_monitor_top_k | (tmpdir) | Test that a warning appears for positive top_k with monitor=None. | Test that a warning appears for positive top_k with monitor=None. | def test_none_monitor_top_k(tmpdir):
""" Test that a warning appears for positive top_k with monitor=None. """
with pytest.raises(
MisconfigurationException, match=r'ModelCheckpoint\(save_top_k=3, monitor=None\) is not a valid*'
):
ModelCheckpoint(dirpath=tmpdir, save_top_k=3)
# These sh... | [
"def",
"test_none_monitor_top_k",
"(",
"tmpdir",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"MisconfigurationException",
",",
"match",
"=",
"r'ModelCheckpoint\\(save_top_k=3, monitor=None\\) is not a valid*'",
")",
":",
"ModelCheckpoint",
"(",
"dirpath",
"=",
"tmpdir... | [
490,
0
] | [
499,
49
] | python | en | ['en', 'en', 'en'] | True |
test_none_monitor_save_last | (tmpdir) | Test that a warning appears for save_last=True with monitor=None. | Test that a warning appears for save_last=True with monitor=None. | def test_none_monitor_save_last(tmpdir):
""" Test that a warning appears for save_last=True with monitor=None. """
with pytest.warns(UserWarning, match=r'ModelCheckpoint\(save_last=True, monitor=None\) is a redundant.*'):
ModelCheckpoint(dirpath=tmpdir, save_last=True)
# These should not fail
Mo... | [
"def",
"test_none_monitor_save_last",
"(",
"tmpdir",
")",
":",
"with",
"pytest",
".",
"warns",
"(",
"UserWarning",
",",
"match",
"=",
"r'ModelCheckpoint\\(save_last=True, monitor=None\\) is a redundant.*'",
")",
":",
"ModelCheckpoint",
"(",
"dirpath",
"=",
"tmpdir",
","... | [
502,
0
] | [
508,
52
] | python | en | ['en', 'en', 'en'] | True |
test_model_checkpoint_none_monitor | (tmpdir) | Test that it is possible to save all checkpoints when monitor=None. | Test that it is possible to save all checkpoints when monitor=None. | def test_model_checkpoint_none_monitor(tmpdir):
""" Test that it is possible to save all checkpoints when monitor=None. """
seed_everything()
model = LogInTwoMethods()
epochs = 2
checkpoint_callback = ModelCheckpoint(monitor=None, dirpath=tmpdir, save_top_k=-1)
trainer = Trainer(
defaul... | [
"def",
"test_model_checkpoint_none_monitor",
"(",
"tmpdir",
")",
":",
"seed_everything",
"(",
")",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"epochs",
"=",
"2",
"checkpoint_callback",
"=",
"ModelCheckpoint",
"(",
"monitor",
"=",
"None",
",",
"dirpath",
"=",
"tm... | [
511,
0
] | [
537,
51
] | python | en | ['en', 'en', 'en'] | True |
test_model_checkpoint_topk_zero | (tmpdir) | Test that no checkpoints are saved when save_top_k=0. | Test that no checkpoints are saved when save_top_k=0. | def test_model_checkpoint_topk_zero(tmpdir):
""" Test that no checkpoints are saved when save_top_k=0. """
model = LogInTwoMethods()
checkpoint_callback = ModelCheckpoint(dirpath=tmpdir, save_top_k=0)
trainer = Trainer(
default_root_dir=tmpdir,
callbacks=[checkpoint_callback],
ma... | [
"def",
"test_model_checkpoint_topk_zero",
"(",
"tmpdir",
")",
":",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"checkpoint_callback",
"=",
"ModelCheckpoint",
"(",
"dirpath",
"=",
"tmpdir",
",",
"save_top_k",
"=",
"0",
")",
"trainer",
"=",
"Trainer",
"(",
"default... | [
561,
0
] | [
579,
39
] | python | en | ['en', 'en', 'en'] | True |
test_model_checkpoint_topk_all | (tmpdir) | Test that save_top_k=-1 tracks the best models when monitor key is provided. | Test that save_top_k=-1 tracks the best models when monitor key is provided. | def test_model_checkpoint_topk_all(tmpdir):
""" Test that save_top_k=-1 tracks the best models when monitor key is provided. """
seed_everything(1000)
epochs = 3
class CustomModel(LogInTwoMethods):
def validation_epoch_end(self, outputs):
return {'epoch': self.current_epoch}
m... | [
"def",
"test_model_checkpoint_topk_all",
"(",
"tmpdir",
")",
":",
"seed_everything",
"(",
"1000",
")",
"epochs",
"=",
"3",
"class",
"CustomModel",
"(",
"LogInTwoMethods",
")",
":",
"def",
"validation_epoch_end",
"(",
"self",
",",
"outputs",
")",
":",
"return",
... | [
582,
0
] | [
614,
77
] | python | en | ['en', 'en', 'en'] | True |
test_model_checkpoint_save_last_warning | (tmpdir, caplog, max_epochs, should_validate, save_last) | Tests 'Saving latest checkpoint...' log | Tests 'Saving latest checkpoint...' log | def test_model_checkpoint_save_last_warning(tmpdir, caplog, max_epochs, should_validate, save_last):
"""Tests 'Saving latest checkpoint...' log"""
model = LogInTwoMethods()
if not should_validate:
model.validation_step = None
trainer = Trainer(
default_root_dir=tmpdir,
callbacks=... | [
"def",
"test_model_checkpoint_save_last_warning",
"(",
"tmpdir",
",",
"caplog",
",",
"max_epochs",
",",
"should_validate",
",",
"save_last",
")",
":",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"if",
"not",
"should_validate",
":",
"model",
".",
"validation_step",
... | [
669,
0
] | [
680,
76
] | python | en | ['en', 'ceb', 'en'] | True |
test_model_checkpoint_save_last_checkpoint_contents | (tmpdir) | Tests that the save_last checkpoint contains the latest information. | Tests that the save_last checkpoint contains the latest information. | def test_model_checkpoint_save_last_checkpoint_contents(tmpdir):
""" Tests that the save_last checkpoint contains the latest information. """
seed_everything(100)
model = LogInTwoMethods()
num_epochs = 3
model_checkpoint = ModelCheckpoint(
monitor='early_stop_on', dirpath=tmpdir, filename="{... | [
"def",
"test_model_checkpoint_save_last_checkpoint_contents",
"(",
"tmpdir",
")",
":",
"seed_everything",
"(",
"100",
")",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"num_epochs",
"=",
"3",
"model_checkpoint",
"=",
"ModelCheckpoint",
"(",
"monitor",
"=",
"'early_stop_... | [
683,
0
] | [
714,
30
] | python | en | ['en', 'en', 'en'] | True |
test_checkpoint_repeated_strategy | (tmpdir) |
This test validates that the checkpoint can be called when provided to callbacks list
|
This test validates that the checkpoint can be called when provided to callbacks list
| def test_checkpoint_repeated_strategy(tmpdir):
"""
This test validates that the checkpoint can be called when provided to callbacks list
"""
checkpoint_callback = ModelCheckpoint(monitor='val_loss', dirpath=tmpdir, filename="{epoch:02d}")
class ExtendedBoringModel(BoringModel):
def validat... | [
"def",
"test_checkpoint_repeated_strategy",
"(",
"tmpdir",
")",
":",
"checkpoint_callback",
"=",
"ModelCheckpoint",
"(",
"monitor",
"=",
"'val_loss'",
",",
"dirpath",
"=",
"tmpdir",
",",
"filename",
"=",
"\"{epoch:02d}\"",
")",
"class",
"ExtendedBoringModel",
"(",
"... | [
744,
0
] | [
787,
95
] | python | en | ['en', 'error', 'th'] | False |
test_checkpoint_repeated_strategy_extended | (tmpdir) |
This test validates checkpoint can be called several times without
increasing internally its global step if nothing run.
|
This test validates checkpoint can be called several times without
increasing internally its global step if nothing run.
| def test_checkpoint_repeated_strategy_extended(tmpdir):
"""
This test validates checkpoint can be called several times without
increasing internally its global step if nothing run.
"""
class ExtendedBoringModel(BoringModel):
def validation_step(self, batch, batch_idx):
output =... | [
"def",
"test_checkpoint_repeated_strategy_extended",
"(",
"tmpdir",
")",
":",
"class",
"ExtendedBoringModel",
"(",
"BoringModel",
")",
":",
"def",
"validation_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"output",
"=",
"self",
".",
"layer",
"(",... | [
791,
0
] | [
872,
38
] | python | en | ['en', 'error', 'th'] | False |
test_configure_model_checkpoint | (tmpdir) | Test all valid and invalid ways a checkpoint callback can be passed to the Trainer. | Test all valid and invalid ways a checkpoint callback can be passed to the Trainer. | def test_configure_model_checkpoint(tmpdir):
""" Test all valid and invalid ways a checkpoint callback can be passed to the Trainer. """
kwargs = dict(default_root_dir=tmpdir)
callback1 = ModelCheckpoint()
callback2 = ModelCheckpoint()
# no callbacks
trainer = Trainer(checkpoint_callback=False,... | [
"def",
"test_configure_model_checkpoint",
"(",
"tmpdir",
")",
":",
"kwargs",
"=",
"dict",
"(",
"default_root_dir",
"=",
"tmpdir",
")",
"callback1",
"=",
"ModelCheckpoint",
"(",
")",
"callback2",
"=",
"ModelCheckpoint",
"(",
")",
"# no callbacks",
"trainer",
"=",
... | [
875,
0
] | [
912,
75
] | python | en | ['en', 'en', 'en'] | True |
test_val_check_interval_checkpoint_files | (tmpdir) | Test correct checkpoint naming when validating/checkpointing multiple times per epoch. | Test correct checkpoint naming when validating/checkpointing multiple times per epoch. | def test_val_check_interval_checkpoint_files(tmpdir):
""" Test correct checkpoint naming when validating/checkpointing multiple times per epoch. """
model = LogInTwoMethods()
model_checkpoint = ModelCheckpoint(
dirpath=tmpdir,
save_top_k=-1,
monitor="val_acc",
mode="max",
... | [
"def",
"test_val_check_interval_checkpoint_files",
"(",
"tmpdir",
")",
":",
"model",
"=",
"LogInTwoMethods",
"(",
")",
"model_checkpoint",
"=",
"ModelCheckpoint",
"(",
"dirpath",
"=",
"tmpdir",
",",
"save_top_k",
"=",
"-",
"1",
",",
"monitor",
"=",
"\"val_acc\"",
... | [
915,
0
] | [
936,
71
] | python | en | ['en', 'en', 'en'] | True |
test_current_score | (tmpdir) | Check that the current_score value is correct and was saved | Check that the current_score value is correct and was saved | def test_current_score(tmpdir):
""" Check that the current_score value is correct and was saved """
class TestModel(BoringModel):
def training_step(self, *args):
self.log("foo", (self.current_epoch + 1) / 10)
return super().training_step(*args)
model_checkpoint = ModelChec... | [
"def",
"test_current_score",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"\"foo\"",
",",
"(",
"self",
".",
"current_epoch",
"+",
... | [
939,
0
] | [
968,
77
] | python | en | ['en', 'en', 'en'] | True |
test_current_score_when_nan | (tmpdir, mode) | Check that ModelCheckpoint handles NaN values correctly | Check that ModelCheckpoint handles NaN values correctly | def test_current_score_when_nan(tmpdir, mode):
""" Check that ModelCheckpoint handles NaN values correctly """
class TestModel(BoringModel):
def training_step(self, *args):
self.log("foo", float("nan"))
return super().training_step(*args)
model_checkpoint = ModelCheckpoint... | [
"def",
"test_current_score_when_nan",
"(",
"tmpdir",
",",
"mode",
")",
":",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"\"foo\"",
",",
"float",
"(",
"\"nan... | [
972,
0
] | [
999,
53
] | python | en | ['en', 'en', 'en'] | True |
test_ckpt_version_after_rerun_new_trainer | (tmpdir) |
Check that previous checkpoints are renamed to have the correct
version suffix when new trainer instances are used
|
Check that previous checkpoints are renamed to have the correct
version suffix when new trainer instances are used
| def test_ckpt_version_after_rerun_new_trainer(tmpdir):
"""
Check that previous checkpoints are renamed to have the correct
version suffix when new trainer instances are used
"""
epochs = 2
for i in range(epochs):
mc = ModelCheckpoint(dirpath=tmpdir, save_top_k=-1, monitor="epoch", filena... | [
"def",
"test_ckpt_version_after_rerun_new_trainer",
"(",
"tmpdir",
")",
":",
"epochs",
"=",
"2",
"for",
"i",
"in",
"range",
"(",
"epochs",
")",
":",
"mc",
"=",
"ModelCheckpoint",
"(",
"dirpath",
"=",
"tmpdir",
",",
"save_top_k",
"=",
"-",
"1",
",",
"monito... | [
1037,
0
] | [
1067,
5
] | python | en | ['en', 'error', 'th'] | False |
test_ckpt_version_after_rerun_same_trainer | (tmpdir) |
Check that previous checkpoints are renamed to have the correct
version suffix when the same trainer instance is used
|
Check that previous checkpoints are renamed to have the correct
version suffix when the same trainer instance is used
| def test_ckpt_version_after_rerun_same_trainer(tmpdir):
"""
Check that previous checkpoints are renamed to have the correct
version suffix when the same trainer instance is used
"""
mc = ModelCheckpoint(dirpath=tmpdir, save_top_k=-1, monitor="epoch", filename="test")
mc.STARTING_VERSION = 9
... | [
"def",
"test_ckpt_version_after_rerun_same_trainer",
"(",
"tmpdir",
")",
":",
"mc",
"=",
"ModelCheckpoint",
"(",
"dirpath",
"=",
"tmpdir",
",",
"save_top_k",
"=",
"-",
"1",
",",
"monitor",
"=",
"\"epoch\"",
",",
"filename",
"=",
"\"test\"",
")",
"mc",
".",
"... | [
1070,
0
] | [
1096,
54
] | python | en | ['en', 'error', 'th'] | False |
THeaderTransport._flushHeaderMessage | (self, buf, wout, wsz) | Write a message for CLIENT_TYPE.HEADER
@param buf(StringIO): Buffer to write message to
@param wout(str): Payload
@param wsz(int): Payload length
| Write a message for CLIENT_TYPE.HEADER | def _flushHeaderMessage(self, buf, wout, wsz):
"""Write a message for CLIENT_TYPE.HEADER
@param buf(StringIO): Buffer to write message to
@param wout(str): Payload
@param wsz(int): Payload length
"""
transform_data = StringIO()
# For now, all transforms don't req... | [
"def",
"_flushHeaderMessage",
"(",
"self",
",",
"buf",
",",
"wout",
",",
"wsz",
")",
":",
"transform_data",
"=",
"StringIO",
"(",
")",
"# For now, all transforms don't require data.",
"num_transforms",
"=",
"len",
"(",
"self",
".",
"__write_transforms",
")",
"for"... | [
437,
4
] | [
493,
23
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase.has_samecoef | (self, other) | Check if coefficients match.
.. versionadded:: 1.6.0
Parameters
----------
other : class instance
The other class must have the ``coef`` attribute.
Returns
-------
bool : boolean
True if the coefficients are the same, False otherwise.
... | Check if coefficients match. | def has_samecoef(self, other):
"""Check if coefficients match.
.. versionadded:: 1.6.0
Parameters
----------
other : class instance
The other class must have the ``coef`` attribute.
Returns
-------
bool : boolean
True if the coef... | [
"def",
"has_samecoef",
"(",
"self",
",",
"other",
")",
":",
"if",
"len",
"(",
"self",
".",
"coef",
")",
"!=",
"len",
"(",
"other",
".",
"coef",
")",
":",
"return",
"False",
"elif",
"not",
"np",
".",
"all",
"(",
"self",
".",
"coef",
"==",
"other",... | [
151,
4
] | [
172,
23
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase.has_samedomain | (self, other) | Check if domains match.
.. versionadded:: 1.6.0
Parameters
----------
other : class instance
The other class must have the ``domain`` attribute.
Returns
-------
bool : boolean
True if the domains are the same, False otherwise.
| Check if domains match. | def has_samedomain(self, other):
"""Check if domains match.
.. versionadded:: 1.6.0
Parameters
----------
other : class instance
The other class must have the ``domain`` attribute.
Returns
-------
bool : boolean
True if the domai... | [
"def",
"has_samedomain",
"(",
"self",
",",
"other",
")",
":",
"return",
"np",
".",
"all",
"(",
"self",
".",
"domain",
"==",
"other",
".",
"domain",
")"
] | [
174,
4
] | [
190,
50
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase.has_samewindow | (self, other) | Check if windows match.
.. versionadded:: 1.6.0
Parameters
----------
other : class instance
The other class must have the ``window`` attribute.
Returns
-------
bool : boolean
True if the windows are the same, False otherwise.
| Check if windows match. | def has_samewindow(self, other):
"""Check if windows match.
.. versionadded:: 1.6.0
Parameters
----------
other : class instance
The other class must have the ``window`` attribute.
Returns
-------
bool : boolean
True if the windo... | [
"def",
"has_samewindow",
"(",
"self",
",",
"other",
")",
":",
"return",
"np",
".",
"all",
"(",
"self",
".",
"window",
"==",
"other",
".",
"window",
")"
] | [
192,
4
] | [
208,
50
] | python | en | ['en', 'zh', 'en'] | True |
ABCPolyBase.has_sametype | (self, other) | Check if types match.
.. versionadded:: 1.7.0
Parameters
----------
other : object
Class instance.
Returns
-------
bool : boolean
True if other is same class as self
| Check if types match. | def has_sametype(self, other):
"""Check if types match.
.. versionadded:: 1.7.0
Parameters
----------
other : object
Class instance.
Returns
-------
bool : boolean
True if other is same class as self
"""
return i... | [
"def",
"has_sametype",
"(",
"self",
",",
"other",
")",
":",
"return",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")"
] | [
210,
4
] | [
226,
48
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase._get_coefficients | (self, other) | Interpret other as polynomial coefficients.
The `other` argument is checked to see if it is of the same
class as self with identical domain and window. If so,
return its coefficients, otherwise return `other`.
.. versionadded:: 1.9.0
Parameters
----------
other... | Interpret other as polynomial coefficients. | def _get_coefficients(self, other):
"""Interpret other as polynomial coefficients.
The `other` argument is checked to see if it is of the same
class as self with identical domain and window. If so,
return its coefficients, otherwise return `other`.
.. versionadded:: 1.9.0
... | [
"def",
"_get_coefficients",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"ABCPolyBase",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"raise",
"TypeError",
"(",
"\"Polynomial type... | [
228,
4
] | [
262,
20
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase.copy | (self) | Return a copy.
Returns
-------
new_series : series
Copy of self.
| Return a copy. | def copy(self):
"""Return a copy.
Returns
-------
new_series : series
Copy of self.
"""
return self.__class__(self.coef, self.domain, self.window) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"coef",
",",
"self",
".",
"domain",
",",
"self",
".",
"window",
")"
] | [
537,
4
] | [
546,
66
] | python | ca | ['es', 'ca', 'en'] | False |
ABCPolyBase.degree | (self) | The degree of the series.
.. versionadded:: 1.5.0
Returns
-------
degree : int
Degree of the series, one less than the number of coefficients.
| The degree of the series. | def degree(self):
"""The degree of the series.
.. versionadded:: 1.5.0
Returns
-------
degree : int
Degree of the series, one less than the number of coefficients.
"""
return len(self) - 1 | [
"def",
"degree",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
")",
"-",
"1"
] | [
548,
4
] | [
559,
28
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase.cutdeg | (self, deg) | Truncate series to the given degree.
Reduce the degree of the series to `deg` by discarding the
high order terms. If `deg` is greater than the current degree a
copy of the current series is returned. This can be useful in least
squares where the coefficients of the high degree terms may... | Truncate series to the given degree. | def cutdeg(self, deg):
"""Truncate series to the given degree.
Reduce the degree of the series to `deg` by discarding the
high order terms. If `deg` is greater than the current degree a
copy of the current series is returned. This can be useful in least
squares where the coeffic... | [
"def",
"cutdeg",
"(",
"self",
",",
"deg",
")",
":",
"return",
"self",
".",
"truncate",
"(",
"deg",
"+",
"1",
")"
] | [
561,
4
] | [
584,
37
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase.trim | (self, tol=0) | Remove trailing coefficients
Remove trailing coefficients until a coefficient is reached whose
absolute value greater than `tol` or the beginning of the series is
reached. If all the coefficients would be removed the series is set
to ``[0]``. A new series instance is returned with the n... | Remove trailing coefficients | def trim(self, tol=0):
"""Remove trailing coefficients
Remove trailing coefficients until a coefficient is reached whose
absolute value greater than `tol` or the beginning of the series is
reached. If all the coefficients would be removed the series is set
to ``[0]``. A new seri... | [
"def",
"trim",
"(",
"self",
",",
"tol",
"=",
"0",
")",
":",
"coef",
"=",
"pu",
".",
"trimcoef",
"(",
"self",
".",
"coef",
",",
"tol",
")",
"return",
"self",
".",
"__class__",
"(",
"coef",
",",
"self",
".",
"domain",
",",
"self",
".",
"window",
... | [
586,
4
] | [
607,
61
] | python | en | ['es', 'en', 'en'] | True |
ABCPolyBase.truncate | (self, size) | Truncate series to length `size`.
Reduce the series to length `size` by discarding the high
degree terms. The value of `size` must be a positive integer. This
can be useful in least squares where the coefficients of the
high degree terms may be very small.
Parameters
--... | Truncate series to length `size`. | def truncate(self, size):
"""Truncate series to length `size`.
Reduce the series to length `size` by discarding the high
degree terms. The value of `size` must be a positive integer. This
can be useful in least squares where the coefficients of the
high degree terms may be very ... | [
"def",
"truncate",
"(",
"self",
",",
"size",
")",
":",
"isize",
"=",
"int",
"(",
"size",
")",
"if",
"isize",
"!=",
"size",
"or",
"isize",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"size must be a positive integer\"",
")",
"if",
"isize",
">=",
"len",
... | [
609,
4
] | [
636,
61
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase.convert | (self, domain=None, kind=None, window=None) | Convert series to a different kind and/or domain and/or window.
Parameters
----------
domain : array_like, optional
The domain of the converted series. If the value is None,
the default domain of `kind` is used.
kind : class, optional
The polynomial s... | Convert series to a different kind and/or domain and/or window. | def convert(self, domain=None, kind=None, window=None):
"""Convert series to a different kind and/or domain and/or window.
Parameters
----------
domain : array_like, optional
The domain of the converted series. If the value is None,
the default domain of `kind` i... | [
"def",
"convert",
"(",
"self",
",",
"domain",
"=",
"None",
",",
"kind",
"=",
"None",
",",
"window",
"=",
"None",
")",
":",
"if",
"kind",
"is",
"None",
":",
"kind",
"=",
"self",
".",
"__class__",
"if",
"domain",
"is",
"None",
":",
"domain",
"=",
"... | [
638,
4
] | [
676,
57
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase.mapparms | (self) | Return the mapping parameters.
The returned values define a linear map ``off + scl*x`` that is
applied to the input arguments before the series is evaluated. The
map depends on the ``domain`` and ``window``; if the current
``domain`` is equal to the ``window`` the resulting map is the
... | Return the mapping parameters. | def mapparms(self):
"""Return the mapping parameters.
The returned values define a linear map ``off + scl*x`` that is
applied to the input arguments before the series is evaluated. The
map depends on the ``domain`` and ``window``; if the current
``domain`` is equal to the ``wind... | [
"def",
"mapparms",
"(",
"self",
")",
":",
"return",
"pu",
".",
"mapparms",
"(",
"self",
".",
"domain",
",",
"self",
".",
"window",
")"
] | [
678,
4
] | [
705,
52
] | python | en | ['en', 'en', 'en'] | True |
ABCPolyBase.integ | (self, m=1, k=[], lbnd=None) | Integrate.
Return a series instance that is the definite integral of the
current series.
Parameters
----------
m : non-negative int
The number of integrations to perform.
k : array_like
Integration constants. The first constant is applied to the
... | Integrate. | def integ(self, m=1, k=[], lbnd=None):
"""Integrate.
Return a series instance that is the definite integral of the
current series.
Parameters
----------
m : non-negative int
The number of integrations to perform.
k : array_like
Integratio... | [
"def",
"integ",
"(",
"self",
",",
"m",
"=",
"1",
",",
"k",
"=",
"[",
"]",
",",
"lbnd",
"=",
"None",
")",
":",
"off",
",",
"scl",
"=",
"self",
".",
"mapparms",
"(",
")",
"if",
"lbnd",
"is",
"None",
":",
"lbnd",
"=",
"0",
"else",
":",
"lbnd",... | [
707,
4
] | [
738,
61
] | python | en | ['en', 'la', 'it'] | False |
ABCPolyBase.deriv | (self, m=1) | Differentiate.
Return a series instance of that is the derivative of the current
series.
Parameters
----------
m : non-negative int
Find the derivative of order `m`.
Returns
-------
new_series : series
A new series representing t... | Differentiate. | def deriv(self, m=1):
"""Differentiate.
Return a series instance of that is the derivative of the current
series.
Parameters
----------
m : non-negative int
Find the derivative of order `m`.
Returns
-------
new_series : series
... | [
"def",
"deriv",
"(",
"self",
",",
"m",
"=",
"1",
")",
":",
"off",
",",
"scl",
"=",
"self",
".",
"mapparms",
"(",
")",
"coef",
"=",
"self",
".",
"_der",
"(",
"self",
".",
"coef",
",",
"m",
",",
"scl",
")",
"return",
"self",
".",
"__class__",
"... | [
740,
4
] | [
760,
61
] | python | en | ['en', 'it', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.