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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
WriteParams.test_with_repeat_calls | (self) |
Test when write_parameter() is called with same macro or expression.
:return:
|
Test when write_parameter() is called with same macro or expression.
:return:
| def test_with_repeat_calls(self):
"""
Test when write_parameter() is called with same macro or expression.
:return:
"""
stream = StringIOWrapper('test_suite_ut.data', '')
unique_expressions = []
expression_code = ''
expression_code += write_parameters(stre... | [
"def",
"test_with_repeat_calls",
"(",
"self",
")",
":",
"stream",
"=",
"StringIOWrapper",
"(",
"'test_suite_ut.data'",
",",
"''",
")",
"unique_expressions",
"=",
"[",
"]",
"expression_code",
"=",
"''",
"expression_code",
"+=",
"write_parameters",
"(",
"stream",
",... | [
1513,
4
] | [
1556,
63
] | python | en | ['en', 'error', 'th'] | False |
GenTestSuiteDependenciesChecks.test_empty_suite_dependencies | (self) |
Test with empty suite_dependencies list.
:return:
|
Test with empty suite_dependencies list. | def test_empty_suite_dependencies(self):
"""
Test with empty suite_dependencies list.
:return:
"""
dep_check_code, expression_code = \
gen_suite_dep_checks([], 'DEP_CHECK_CODE', 'EXPRESSION_CODE')
self.assertEqual(dep_check_code, 'DEP_CHECK_CODE')
sel... | [
"def",
"test_empty_suite_dependencies",
"(",
"self",
")",
":",
"dep_check_code",
",",
"expression_code",
"=",
"gen_suite_dep_checks",
"(",
"[",
"]",
",",
"'DEP_CHECK_CODE'",
",",
"'EXPRESSION_CODE'",
")",
"self",
".",
"assertEqual",
"(",
"dep_check_code",
",",
"'DEP... | [
1563,
4
] | [
1572,
60
] | python | en | ['en', 'error', 'th'] | False |
GenTestSuiteDependenciesChecks.test_suite_dependencies | (self) |
Test with suite_dependencies list.
:return:
|
Test with suite_dependencies list. | def test_suite_dependencies(self):
"""
Test with suite_dependencies list.
:return:
"""
dep_check_code, expression_code = \
gen_suite_dep_checks(['SUITE_DEP'], 'DEP_CHECK_CODE',
'EXPRESSION_CODE')
expected_dep_check_code = '''
... | [
"def",
"test_suite_dependencies",
"(",
"self",
")",
":",
"dep_check_code",
",",
"expression_code",
"=",
"gen_suite_dep_checks",
"(",
"[",
"'SUITE_DEP'",
"]",
",",
"'DEP_CHECK_CODE'",
",",
"'EXPRESSION_CODE'",
")",
"expected_dep_check_code",
"=",
"'''\n#if defined(SUITE_DE... | [
1574,
4
] | [
1594,
67
] | python | en | ['en', 'error', 'th'] | False |
GenTestSuiteDependenciesChecks.test_no_dep_no_exp | (self) |
Test when there are no dependency and expression code.
:return:
|
Test when there are no dependency and expression code.
:return:
| def test_no_dep_no_exp(self):
"""
Test when there are no dependency and expression code.
:return:
"""
dep_check_code, expression_code = gen_suite_dep_checks([], '', '')
self.assertEqual(dep_check_code, '')
self.assertEqual(expression_code, '') | [
"def",
"test_no_dep_no_exp",
"(",
"self",
")",
":",
"dep_check_code",
",",
"expression_code",
"=",
"gen_suite_dep_checks",
"(",
"[",
"]",
",",
"''",
",",
"''",
")",
"self",
".",
"assertEqual",
"(",
"dep_check_code",
",",
"''",
")",
"self",
".",
"assertEqual"... | [
1596,
4
] | [
1603,
45
] | python | en | ['en', 'error', 'th'] | False |
GenFromTestData.test_intermediate_data_file | (func_mock1,
write_parameters_mock,
write_dependencies_mock) |
Test that intermediate data file is written with expected data.
:return:
|
Test that intermediate data file is written with expected data.
:return:
| def test_intermediate_data_file(func_mock1,
write_parameters_mock,
write_dependencies_mock):
"""
Test that intermediate data file is written with expected data.
:return:
"""
data = '''
My test
depends_on:DEP1... | [
"def",
"test_intermediate_data_file",
"(",
"func_mock1",
",",
"write_parameters_mock",
",",
"write_dependencies_mock",
")",
":",
"data",
"=",
"'''\nMy test\ndepends_on:DEP1\nfunc1:0\n'''",
"data_f",
"=",
"StringIOWrapper",
"(",
"'test_suite_ut.data'",
",",
"data",
")",
"out... | [
1615,
4
] | [
1650,
60
] | python | en | ['en', 'error', 'th'] | False |
GenFromTestData.test_function_not_found | (self) |
Test that AssertError is raised when function info in not found.
:return:
|
Test that AssertError is raised when function info in not found.
:return:
| def test_function_not_found(self):
"""
Test that AssertError is raised when function info in not found.
:return:
"""
data = '''
My test
depends_on:DEP1
func1:0
'''
data_f = StringIOWrapper('test_suite_ut.data', data)
out_data_f = StringIOWrapper('test_suite_ut.dat... | [
"def",
"test_function_not_found",
"(",
"self",
")",
":",
"data",
"=",
"'''\nMy test\ndepends_on:DEP1\nfunc1:0\n'''",
"data_f",
"=",
"StringIOWrapper",
"(",
"'test_suite_ut.data'",
",",
"data",
")",
"out_data_f",
"=",
"StringIOWrapper",
"(",
"'test_suite_ut.datax'",
",",
... | [
1652,
4
] | [
1667,
76
] | python | en | ['en', 'error', 'th'] | False |
GenFromTestData.test_different_func_args | (self) |
Test that AssertError is raised when no. of parameters and
function args differ.
:return:
|
Test that AssertError is raised when no. of parameters and
function args differ.
:return:
| def test_different_func_args(self):
"""
Test that AssertError is raised when no. of parameters and
function args differ.
:return:
"""
data = '''
My test
depends_on:DEP1
func1:0
'''
data_f = StringIOWrapper('test_suite_ut.data', data)
out_data_f = StringIOW... | [
"def",
"test_different_func_args",
"(",
"self",
")",
":",
"data",
"=",
"'''\nMy test\ndepends_on:DEP1\nfunc1:0\n'''",
"data_f",
"=",
"StringIOWrapper",
"(",
"'test_suite_ut.data'",
",",
"data",
")",
"out_data_f",
"=",
"StringIOWrapper",
"(",
"'test_suite_ut.datax'",
",",
... | [
1669,
4
] | [
1685,
68
] | python | en | ['en', 'error', 'th'] | False |
GenFromTestData.test_output | (self) |
Test that intermediate data file is written with expected data.
:return:
|
Test that intermediate data file is written with expected data.
:return:
| def test_output(self):
"""
Test that intermediate data file is written with expected data.
:return:
"""
data = '''
My test 1
depends_on:DEP1
func1:0:0xfa:MACRO1:MACRO2
My test 2
depends_on:DEP1:DEP2
func2:"yahoo":88:MACRO1
'''
data_f = StringIOWrapper('test_suite_ut.data... | [
"def",
"test_output",
"(",
"self",
")",
":",
"data",
"=",
"'''\nMy test 1\ndepends_on:DEP1\nfunc1:0:0xfa:MACRO1:MACRO2\n\nMy test 2\ndepends_on:DEP1:DEP2\nfunc2:\"yahoo\":88:MACRO1\n'''",
"data_f",
"=",
"StringIOWrapper",
"(",
"'test_suite_ut.data'",
",",
"data",
")",
"out_data_f",... | [
1687,
4
] | [
1750,
67
] | python | en | ['en', 'error', 'th'] | False |
conv3x3 | (in_planes, out_planes, stride=1, groups=1, dilation=1) | 3x3 convolution with padding | 3x3 convolution with padding | def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
"""3x3 convolution with padding"""
return MetaConv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=dilation, groups=groups, bias=False, dilation=dilation) | [
"def",
"conv3x3",
"(",
"in_planes",
",",
"out_planes",
",",
"stride",
"=",
"1",
",",
"groups",
"=",
"1",
",",
"dilation",
"=",
"1",
")",
":",
"return",
"MetaConv2d",
"(",
"in_planes",
",",
"out_planes",
",",
"kernel_size",
"=",
"3",
",",
"stride",
"=",... | [
24,
0
] | [
27,
84
] | python | en | ['en', 'ja', 'en'] | True |
conv1x1 | (in_planes, out_planes, stride=1) | 1x1 convolution | 1x1 convolution | def conv1x1(in_planes, out_planes, stride=1):
"""1x1 convolution"""
return MetaConv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False) | [
"def",
"conv1x1",
"(",
"in_planes",
",",
"out_planes",
",",
"stride",
"=",
"1",
")",
":",
"return",
"MetaConv2d",
"(",
"in_planes",
",",
"out_planes",
",",
"kernel_size",
"=",
"1",
",",
"stride",
"=",
"stride",
",",
"bias",
"=",
"False",
")"
] | [
30,
0
] | [
32,
86
] | python | en | ['en', 'fa', 'it'] | False |
resnet18 | (pretrained=False, progress=True, **kwargs) | r"""ResNet-18 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
| r"""ResNet-18 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_ | def resnet18(pretrained=False, progress=True, **kwargs):
r"""ResNet-18 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress ... | [
"def",
"resnet18",
"(",
"pretrained",
"=",
"False",
",",
"progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_resnet",
"(",
"'resnet18'",
",",
"BasicBlock",
",",
"[",
"2",
",",
"2",
",",
"2",
",",
"2",
"]",
",",
"pretrained",
","... | [
228,
0
] | [
237,
28
] | python | en | ['en', 'no', 'en'] | True |
resnet34 | (pretrained=False, progress=True, **kwargs) | r"""ResNet-34 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
| r"""ResNet-34 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_ | def resnet34(pretrained=False, progress=True, **kwargs):
r"""ResNet-34 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress ... | [
"def",
"resnet34",
"(",
"pretrained",
"=",
"False",
",",
"progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_resnet",
"(",
"'resnet34'",
",",
"BasicBlock",
",",
"[",
"3",
",",
"4",
",",
"6",
",",
"3",
"]",
",",
"pretrained",
","... | [
240,
0
] | [
249,
28
] | python | en | ['en', 'no', 'en'] | True |
resnet50 | (pretrained=False, progress=True, **kwargs) | r"""ResNet-50 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
| r"""ResNet-50 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_ | def resnet50(pretrained=False, progress=True, **kwargs):
r"""ResNet-50 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress ... | [
"def",
"resnet50",
"(",
"pretrained",
"=",
"False",
",",
"progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_resnet",
"(",
"'resnet50'",
",",
"Bottleneck",
",",
"[",
"3",
",",
"4",
",",
"6",
",",
"3",
"]",
",",
"pretrained",
","... | [
252,
0
] | [
261,
28
] | python | en | ['en', 'no', 'en'] | True |
resnet101 | (pretrained=False, progress=True, **kwargs) | r"""ResNet-101 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
| r"""ResNet-101 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_ | def resnet101(pretrained=False, progress=True, **kwargs):
r"""ResNet-101 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progres... | [
"def",
"resnet101",
"(",
"pretrained",
"=",
"False",
",",
"progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_resnet",
"(",
"'resnet101'",
",",
"Bottleneck",
",",
"[",
"3",
",",
"4",
",",
"23",
",",
"3",
"]",
",",
"pretrained",
... | [
264,
0
] | [
273,
28
] | python | en | ['en', 'no', 'en'] | True |
resnet152 | (pretrained=False, progress=True, **kwargs) | r"""ResNet-152 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
| r"""ResNet-152 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_ | def resnet152(pretrained=False, progress=True, **kwargs):
r"""ResNet-152 model from
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progres... | [
"def",
"resnet152",
"(",
"pretrained",
"=",
"False",
",",
"progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_resnet",
"(",
"'resnet152'",
",",
"Bottleneck",
",",
"[",
"3",
",",
"8",
",",
"36",
",",
"3",
"]",
",",
"pretrained",
... | [
276,
0
] | [
285,
28
] | python | en | ['en', 'no', 'en'] | True |
resnext50_32x4d | (pretrained=False, progress=True, **kwargs) | r"""ResNeXt-50 32x4d model from
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
| r"""ResNeXt-50 32x4d model from
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_ | def resnext50_32x4d(pretrained=False, progress=True, **kwargs):
r"""ResNeXt-50 32x4d model from
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): ... | [
"def",
"resnext50_32x4d",
"(",
"pretrained",
"=",
"False",
",",
"progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'groups'",
"]",
"=",
"32",
"kwargs",
"[",
"'width_per_group'",
"]",
"=",
"4",
"return",
"_resnet",
"(",
"'resnext5... | [
288,
0
] | [
299,
50
] | python | en | ['en', 'en', 'en'] | True |
resnext101_32x8d | (pretrained=False, progress=True, **kwargs) | r"""ResNeXt-101 32x8d model from
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
| r"""ResNeXt-101 32x8d model from
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_ | def resnext101_32x8d(pretrained=False, progress=True, **kwargs):
r"""ResNeXt-101 32x8d model from
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool)... | [
"def",
"resnext101_32x8d",
"(",
"pretrained",
"=",
"False",
",",
"progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'groups'",
"]",
"=",
"32",
"kwargs",
"[",
"'width_per_group'",
"]",
"=",
"8",
"return",
"_resnet",
"(",
"'resnext... | [
302,
0
] | [
313,
50
] | python | en | ['en', 'en', 'en'] | True |
wide_resnet50_2 | (pretrained=False, progress=True, **kwargs) | r"""Wide ResNet-50-2 model from
`"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_
The model is the same as ResNet except for the bottleneck number of channels
which is twice larger in every block. The number of channels in outer 1x1
convolutions is the same, e.g. last block in ResNet-5... | r"""Wide ResNet-50-2 model from
`"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_ | def wide_resnet50_2(pretrained=False, progress=True, **kwargs):
r"""Wide ResNet-50-2 model from
`"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_
The model is the same as ResNet except for the bottleneck number of channels
which is twice larger in every block. The number of channels in... | [
"def",
"wide_resnet50_2",
"(",
"pretrained",
"=",
"False",
",",
"progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'width_per_group'",
"]",
"=",
"64",
"*",
"2",
"return",
"_resnet",
"(",
"'wide_resnet50_2'",
",",
"Bottleneck",
",",... | [
316,
0
] | [
331,
50
] | python | en | ['en', 'fy', 'en'] | True |
wide_resnet101_2 | (pretrained=False, progress=True, **kwargs) | r"""Wide ResNet-101-2 model from
`"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_
The model is the same as ResNet except for the bottleneck number of channels
which is twice larger in every block. The number of channels in outer 1x1
convolutions is the same, e.g. last block in ResNet-... | r"""Wide ResNet-101-2 model from
`"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_ | def wide_resnet101_2(pretrained=False, progress=True, **kwargs):
r"""Wide ResNet-101-2 model from
`"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_
The model is the same as ResNet except for the bottleneck number of channels
which is twice larger in every block. The number of channels ... | [
"def",
"wide_resnet101_2",
"(",
"pretrained",
"=",
"False",
",",
"progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'width_per_group'",
"]",
"=",
"64",
"*",
"2",
"return",
"_resnet",
"(",
"'wide_resnet101_2'",
",",
"Bottleneck",
",... | [
334,
0
] | [
349,
50
] | python | en | ['en', 'fy', 'en'] | True |
avatar_url_from_dict | (userdict: Dict[str, Any], medium: bool = False) |
DEPRECATED: We should start using
get_avatar_field to populate users,
particularly for codepaths where the
client can compute gravatar URLs
on the client side.
|
DEPRECATED: We should start using
get_avatar_field to populate users,
particularly for codepaths where the
client can compute gravatar URLs
on the client side.
| def avatar_url_from_dict(userdict: Dict[str, Any], medium: bool = False) -> str:
"""
DEPRECATED: We should start using
get_avatar_field to populate users,
particularly for codepaths where the
client can compute gravatar URLs
on the client side.
... | [
"def",
"avatar_url_from_dict",
"(",
"userdict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"medium",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"url",
"=",
"_get_unversioned_avatar_url",
"(",
"userdict",
"[",
"\"id\"",
"]",
",",
"userdict",
"[... | [
29,
0
] | [
45,
14
] | python | en | ['en', 'error', 'th'] | False |
get_avatar_field | (
user_id: int,
realm_id: int,
email: str,
avatar_source: str,
avatar_version: int,
medium: bool,
client_gravatar: bool,
) |
Most of the parameters to this function map to fields
by the same name in UserProfile (avatar_source, realm_id,
email, etc.).
Then there are these:
medium - This means we want a medium-sized avatar. This can
affect the "s" parameter for gravatar avatars, or it
can give... |
Most of the parameters to this function map to fields
by the same name in UserProfile (avatar_source, realm_id,
email, etc.). | def get_avatar_field(
user_id: int,
realm_id: int,
email: str,
avatar_source: str,
avatar_version: int,
medium: bool,
client_gravatar: bool,
) -> Optional[str]:
"""
Most of the parameters to this function map to fields
by the same name in UserProfile (avatar_source, realm_id,
... | [
"def",
"get_avatar_field",
"(",
"user_id",
":",
"int",
",",
"realm_id",
":",
"int",
",",
"email",
":",
"str",
",",
"avatar_source",
":",
"str",
",",
"avatar_version",
":",
"int",
",",
"medium",
":",
"bool",
",",
"client_gravatar",
":",
"bool",
",",
")",
... | [
48,
0
] | [
97,
14
] | python | en | ['en', 'error', 'th'] | False |
absolute_avatar_url | (user_profile: UserProfile) |
Absolute URLs are used to simplify logic for applications that
won't be served by browsers, such as rendering GCM notifications.
|
Absolute URLs are used to simplify logic for applications that
won't be served by browsers, such as rendering GCM notifications.
| def absolute_avatar_url(user_profile: UserProfile) -> str:
"""
Absolute URLs are used to simplify logic for applications that
won't be served by browsers, such as rendering GCM notifications.
"""
avatar = avatar_url(user_profile)
# avatar_url can return None if client_gravatar=True, however here... | [
"def",
"absolute_avatar_url",
"(",
"user_profile",
":",
"UserProfile",
")",
"->",
"str",
":",
"avatar",
"=",
"avatar_url",
"(",
"user_profile",
")",
"# avatar_url can return None if client_gravatar=True, however here we use the default value of False",
"assert",
"avatar",
"is",... | [
128,
0
] | [
136,
63
] | python | en | ['en', 'error', 'th'] | False |
flatpage | (request, url) |
Public interface to the flat page view.
Models: `flatpages.flatpages`
Templates: Uses the template defined by the ``template_name`` field,
or :template:`flatpages/default.html` if template_name is not defined.
Context:
flatpage
`flatpages.flatpages` object
|
Public interface to the flat page view. | def flatpage(request, url):
"""
Public interface to the flat page view.
Models: `flatpages.flatpages`
Templates: Uses the template defined by the ``template_name`` field,
or :template:`flatpages/default.html` if template_name is not defined.
Context:
flatpage
`flatpages.... | [
"def",
"flatpage",
"(",
"request",
",",
"url",
")",
":",
"if",
"not",
"url",
".",
"startswith",
"(",
"'/'",
")",
":",
"url",
"=",
"'/'",
"+",
"url",
"site_id",
"=",
"get_current_site",
"(",
"request",
")",
".",
"id",
"try",
":",
"f",
"=",
"get_obje... | [
21,
0
] | [
44,
38
] | python | en | ['en', 'error', 'th'] | False |
render_flatpage | (request, f) |
Internal interface to the flat page view.
|
Internal interface to the flat page view.
| def render_flatpage(request, f):
"""
Internal interface to the flat page view.
"""
# If registration is required for accessing this page, and the user isn't
# logged in, redirect to the login page.
if f.registration_required and not request.user.is_authenticated:
from django.contrib.auth... | [
"def",
"render_flatpage",
"(",
"request",
",",
"f",
")",
":",
"# If registration is required for accessing this page, and the user isn't",
"# logged in, redirect to the login page.",
"if",
"f",
".",
"registration_required",
"and",
"not",
"request",
".",
"user",
".",
"is_authe... | [
48,
0
] | [
69,
19
] | python | en | ['en', 'error', 'th'] | False |
send_all_first_reply | (
func: str, arg: Any, peers: List[WSKaleConnection], timeout=15
) | performs an API request to peers and returns the result of the first response and the peer that sent it. | performs an API request to peers and returns the result of the first response and the peer that sent it. | async def send_all_first_reply(
func: str, arg: Any, peers: List[WSKaleConnection], timeout=15
) -> Optional[Tuple[Any, WSKaleConnection]]:
"""performs an API request to peers and returns the result of the first response and the peer that sent it."""
async def do_func(peer_x: WSKaleConnection, func_x: str,... | [
"async",
"def",
"send_all_first_reply",
"(",
"func",
":",
"str",
",",
"arg",
":",
"Any",
",",
"peers",
":",
"List",
"[",
"WSKaleConnection",
"]",
",",
"timeout",
"=",
"15",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"Any",
",",
"WSKaleConnection",
"]",
... | [
7,
0
] | [
36,
19
] | python | en | ['en', 'en', 'en'] | True |
send_to_random | (func: str, arg: Any, peers: List[WSKaleConnection]) | performs an API request to peers and returns the result of the first response and the peer that sent it. | performs an API request to peers and returns the result of the first response and the peer that sent it. | async def send_to_random(func: str, arg: Any, peers: List[WSKaleConnection]) -> Optional[Tuple[Any, WSKaleConnection]]:
"""performs an API request to peers and returns the result of the first response and the peer that sent it."""
async def do_func(peer_x: WSKaleConnection, func_x: str, arg_x: Any):
me... | [
"async",
"def",
"send_to_random",
"(",
"func",
":",
"str",
",",
"arg",
":",
"Any",
",",
"peers",
":",
"List",
"[",
"WSKaleConnection",
"]",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"Any",
",",
"WSKaleConnection",
"]",
"]",
":",
"async",
"def",
"do_fun... | [
39,
0
] | [
65,
19
] | python | en | ['en', 'en', 'en'] | True |
get_locale_usage | (locale) |
Returns the number of pages and other objects that use a locale
|
Returns the number of pages and other objects that use a locale
| def get_locale_usage(locale):
"""
Returns the number of pages and other objects that use a locale
"""
num_pages = Page.objects.filter(locale=locale).exclude(depth=1).count()
num_others = 0
for model in get_translatable_models():
if model is Page:
continue
num_other... | [
"def",
"get_locale_usage",
"(",
"locale",
")",
":",
"num_pages",
"=",
"Page",
".",
"objects",
".",
"filter",
"(",
"locale",
"=",
"locale",
")",
".",
"exclude",
"(",
"depth",
"=",
"1",
")",
".",
"count",
"(",
")",
"num_others",
"=",
"0",
"for",
"model... | [
3,
0
] | [
17,
32
] | python | en | ['en', 'error', 'th'] | False |
_AddTool | (tool) | Adds a tool to the four dictionaries used to process settings.
This only defines the tool. Each setting also needs to be added.
Args:
tool: The _Tool object to be added.
| Adds a tool to the four dictionaries used to process settings. | def _AddTool(tool):
"""Adds a tool to the four dictionaries used to process settings.
This only defines the tool. Each setting also needs to be added.
Args:
tool: The _Tool object to be added.
"""
_msvs_validators[tool.msvs_name] = {}
_msbuild_validators[tool.msbuild_name] = {}
_msvs_to_msb... | [
"def",
"_AddTool",
"(",
"tool",
")",
":",
"_msvs_validators",
"[",
"tool",
".",
"msvs_name",
"]",
"=",
"{",
"}",
"_msbuild_validators",
"[",
"tool",
".",
"msbuild_name",
"]",
"=",
"{",
"}",
"_msvs_to_msbuild_converters",
"[",
"tool",
".",
"msvs_name",
"]",
... | [
51,
0
] | [
62,
61
] | python | en | ['en', 'en', 'en'] | True |
_GetMSBuildToolSettings | (msbuild_settings, tool) | Returns an MSBuild tool dictionary. Creates it if needed. | Returns an MSBuild tool dictionary. Creates it if needed. | def _GetMSBuildToolSettings(msbuild_settings, tool):
"""Returns an MSBuild tool dictionary. Creates it if needed."""
return msbuild_settings.setdefault(tool.msbuild_name, {}) | [
"def",
"_GetMSBuildToolSettings",
"(",
"msbuild_settings",
",",
"tool",
")",
":",
"return",
"msbuild_settings",
".",
"setdefault",
"(",
"tool",
".",
"msbuild_name",
",",
"{",
"}",
")"
] | [
65,
0
] | [
67,
61
] | python | en | ['en', 'en', 'en'] | True |
_Same | (tool, name, setting_type) | Defines a setting that has the same name in MSVS and MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
| Defines a setting that has the same name in MSVS and MSBuild. | def _Same(tool, name, setting_type):
"""Defines a setting that has the same name in MSVS and MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
_Renamed(tool, name, name, setting_typ... | [
"def",
"_Same",
"(",
"tool",
",",
"name",
",",
"setting_type",
")",
":",
"_Renamed",
"(",
"tool",
",",
"name",
",",
"name",
",",
"setting_type",
")"
] | [
237,
0
] | [
245,
44
] | python | en | ['en', 'en', 'en'] | True |
_Renamed | (tool, msvs_name, msbuild_name, setting_type) | Defines a setting for which the name has changed.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting.
msbuild_name: the name of the MSBuild setting.
setting_type: the type of this setting.
| Defines a setting for which the name has changed. | def _Renamed(tool, msvs_name, msbuild_name, setting_type):
"""Defines a setting for which the name has changed.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting.
msbuild_name: the name of the MSBuild setting.
setting_type: the... | [
"def",
"_Renamed",
"(",
"tool",
",",
"msvs_name",
",",
"msbuild_name",
",",
"setting_type",
")",
":",
"def",
"_Translate",
"(",
"value",
",",
"msbuild_settings",
")",
":",
"msbuild_tool_settings",
"=",
"_GetMSBuildToolSettings",
"(",
"msbuild_settings",
",",
"tool... | [
248,
0
] | [
264,
71
] | python | en | ['en', 'en', 'en'] | True |
_MovedAndRenamed | (
tool, msvs_settings_name, msbuild_tool_name, msbuild_settings_name, setting_type
) | Defines a setting that may have moved to a new section.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_settings_name: the MSVS name of the setting.
msbuild_tool_name: the name of the MSBuild tool to place the setting under.
msbuild_settings_name: the MSBuild name... | Defines a setting that may have moved to a new section. | def _MovedAndRenamed(
tool, msvs_settings_name, msbuild_tool_name, msbuild_settings_name, setting_type
):
"""Defines a setting that may have moved to a new section.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_settings_name: the MSVS name of the setting.
ms... | [
"def",
"_MovedAndRenamed",
"(",
"tool",
",",
"msvs_settings_name",
",",
"msbuild_tool_name",
",",
"msbuild_settings_name",
",",
"setting_type",
")",
":",
"def",
"_Translate",
"(",
"value",
",",
"msbuild_settings",
")",
":",
"tool_settings",
"=",
"msbuild_settings",
... | [
273,
0
] | [
293,
80
] | python | en | ['en', 'en', 'en'] | True |
_MSVSOnly | (tool, name, setting_type) | Defines a setting that is only found in MSVS.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
| Defines a setting that is only found in MSVS. | def _MSVSOnly(tool, name, setting_type):
"""Defines a setting that is only found in MSVS.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
def _Translate(unused_value, unused_msbuild_setti... | [
"def",
"_MSVSOnly",
"(",
"tool",
",",
"name",
",",
"setting_type",
")",
":",
"def",
"_Translate",
"(",
"unused_value",
",",
"unused_msbuild_settings",
")",
":",
"# Since this is for MSVS only settings, no translation will happen.",
"pass",
"_msvs_validators",
"[",
"tool",... | [
296,
0
] | [
310,
66
] | python | en | ['en', 'en', 'en'] | True |
_MSBuildOnly | (tool, name, setting_type) | Defines a setting that is only found in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
| Defines a setting that is only found in MSBuild. | def _MSBuildOnly(tool, name, setting_type):
"""Defines a setting that is only found in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
def _Translate(value, msbuild_settings):
... | [
"def",
"_MSBuildOnly",
"(",
"tool",
",",
"name",
",",
"setting_type",
")",
":",
"def",
"_Translate",
"(",
"value",
",",
"msbuild_settings",
")",
":",
"# Let msbuild-only properties get translated as-is from msvs_settings.",
"tool_settings",
"=",
"msbuild_settings",
".",
... | [
313,
0
] | [
328,
66
] | python | en | ['en', 'en', 'en'] | True |
_ConvertedToAdditionalOption | (tool, msvs_name, flag) | Defines a setting that's handled via a command line option in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting that if 'true' becomes a flag
flag: the flag to insert at the end of the AdditionalOptions
| Defines a setting that's handled via a command line option in MSBuild. | def _ConvertedToAdditionalOption(tool, msvs_name, flag):
"""Defines a setting that's handled via a command line option in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting that if 'true' becomes a flag
flag: the flag to in... | [
"def",
"_ConvertedToAdditionalOption",
"(",
"tool",
",",
"msvs_name",
",",
"flag",
")",
":",
"def",
"_Translate",
"(",
"value",
",",
"msbuild_settings",
")",
":",
"if",
"value",
"==",
"\"true\"",
":",
"tool_settings",
"=",
"_GetMSBuildToolSettings",
"(",
"msbuil... | [
331,
0
] | [
350,
71
] | python | en | ['en', 'en', 'en'] | True |
_ValidateExclusionSetting | (setting, settings, error_msg, stderr=sys.stderr) | Verify that 'setting' is valid if it is generated from an exclusion list.
If the setting appears to be generated from an exclusion list, the root name
is checked.
Args:
setting: A string that is the setting name to validate
settings: A dictionary where the keys are valid settings
error_msg:... | Verify that 'setting' is valid if it is generated from an exclusion list. | def _ValidateExclusionSetting(setting, settings, error_msg, stderr=sys.stderr):
"""Verify that 'setting' is valid if it is generated from an exclusion list.
If the setting appears to be generated from an exclusion list, the root name
is checked.
Args:
setting: A string that is the setting name to va... | [
"def",
"_ValidateExclusionSetting",
"(",
"setting",
",",
"settings",
",",
"error_msg",
",",
"stderr",
"=",
"sys",
".",
"stderr",
")",
":",
"# This may be unrecognized because it's an exclusion list. If the",
"# setting name has the _excluded suffix, then check the root name.",
"u... | [
387,
0
] | [
409,
37
] | python | en | ['en', 'en', 'en'] | True |
FixVCMacroSlashes | (s) | Replace macros which have excessive following slashes.
These macros are known to have a built-in trailing slash. Furthermore, many
scripts hiccup on processing paths with extra slashes in the middle.
This list is probably not exhaustive. Add as needed.
| Replace macros which have excessive following slashes. | def FixVCMacroSlashes(s):
"""Replace macros which have excessive following slashes.
These macros are known to have a built-in trailing slash. Furthermore, many
scripts hiccup on processing paths with extra slashes in the middle.
This list is probably not exhaustive. Add as needed.
"""
if "$" in s:
... | [
"def",
"FixVCMacroSlashes",
"(",
"s",
")",
":",
"if",
"\"$\"",
"in",
"s",
":",
"s",
"=",
"fix_vc_macro_slashes_regex",
".",
"sub",
"(",
"r\"\\1\"",
",",
"s",
")",
"return",
"s"
] | [
412,
0
] | [
422,
12
] | python | en | ['en', 'en', 'en'] | True |
ConvertVCMacrosToMSBuild | (s) | Convert the MSVS macros found in the string to the MSBuild equivalent.
This list is probably not exhaustive. Add as needed.
| Convert the MSVS macros found in the string to the MSBuild equivalent. | def ConvertVCMacrosToMSBuild(s):
"""Convert the MSVS macros found in the string to the MSBuild equivalent.
This list is probably not exhaustive. Add as needed.
"""
if "$" in s:
replace_map = {
"$(ConfigurationName)": "$(Configuration)",
"$(InputDir)": "%(RelativeDir)",
... | [
"def",
"ConvertVCMacrosToMSBuild",
"(",
"s",
")",
":",
"if",
"\"$\"",
"in",
"s",
":",
"replace_map",
"=",
"{",
"\"$(ConfigurationName)\"",
":",
"\"$(Configuration)\"",
",",
"\"$(InputDir)\"",
":",
"\"%(RelativeDir)\"",
",",
"\"$(InputExt)\"",
":",
"\"%(Extension)\"",
... | [
425,
0
] | [
445,
12
] | python | en | ['en', 'en', 'en'] | True |
ConvertToMSBuildSettings | (msvs_settings, stderr=sys.stderr) | Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+).
Args:
msvs_settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
Returns:
A dictionary of MSBui... | Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+). | def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
"""Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+).
Args:
msvs_settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The strea... | [
"def",
"ConvertToMSBuildSettings",
"(",
"msvs_settings",
",",
"stderr",
"=",
"sys",
".",
"stderr",
")",
":",
"msbuild_settings",
"=",
"{",
"}",
"for",
"msvs_tool_name",
",",
"msvs_tool_settings",
"in",
"msvs_settings",
".",
"items",
"(",
")",
":",
"if",
"msvs_... | [
448,
0
] | [
493,
27
] | python | en | ['en', 'en', 'en'] | True |
ValidateMSVSSettings | (settings, stderr=sys.stderr) | Validates that the names of the settings are valid for MSVS.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
| Validates that the names of the settings are valid for MSVS. | def ValidateMSVSSettings(settings, stderr=sys.stderr):
"""Validates that the names of the settings are valid for MSVS.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messag... | [
"def",
"ValidateMSVSSettings",
"(",
"settings",
",",
"stderr",
"=",
"sys",
".",
"stderr",
")",
":",
"_ValidateSettings",
"(",
"_msvs_validators",
",",
"settings",
",",
"stderr",
")"
] | [
496,
0
] | [
504,
57
] | python | en | ['en', 'en', 'en'] | True |
ValidateMSBuildSettings | (settings, stderr=sys.stderr) | Validates that the names of the settings are valid for MSBuild.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
| Validates that the names of the settings are valid for MSBuild. | def ValidateMSBuildSettings(settings, stderr=sys.stderr):
"""Validates that the names of the settings are valid for MSBuild.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error ... | [
"def",
"ValidateMSBuildSettings",
"(",
"settings",
",",
"stderr",
"=",
"sys",
".",
"stderr",
")",
":",
"_ValidateSettings",
"(",
"_msbuild_validators",
",",
"settings",
",",
"stderr",
")"
] | [
507,
0
] | [
515,
60
] | python | en | ['en', 'en', 'en'] | True |
_ValidateSettings | (validators, settings, stderr) | Validates that the settings are valid for MSBuild or MSVS.
We currently only validate the names of the settings, not their values.
Args:
validators: A dictionary of tools and their validators.
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of setti... | Validates that the settings are valid for MSBuild or MSVS. | def _ValidateSettings(validators, settings, stderr):
"""Validates that the settings are valid for MSBuild or MSVS.
We currently only validate the names of the settings, not their values.
Args:
validators: A dictionary of tools and their validators.
settings: A dictionary. The key is the tool name... | [
"def",
"_ValidateSettings",
"(",
"validators",
",",
"settings",
",",
"stderr",
")",
":",
"for",
"tool_name",
"in",
"settings",
":",
"if",
"tool_name",
"in",
"validators",
":",
"tool_validators",
"=",
"validators",
"[",
"tool_name",
"]",
"for",
"setting",
",",
... | [
518,
0
] | [
550,
77
] | python | en | ['en', 'en', 'en'] | True |
_Type.ValidateMSVS | (self, value) | Verifies that the value is legal for MSVS.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSVS.
| Verifies that the value is legal for MSVS. | def ValidateMSVS(self, value):
"""Verifies that the value is legal for MSVS.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSVS.
""" | [
"def",
"ValidateMSVS",
"(",
"self",
",",
"value",
")",
":"
] | [
73,
4
] | [
81,
7
] | python | en | ['en', 'en', 'en'] | True |
_Type.ValidateMSBuild | (self, value) | Verifies that the value is legal for MSBuild.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSBuild.
| Verifies that the value is legal for MSBuild. | def ValidateMSBuild(self, value):
"""Verifies that the value is legal for MSBuild.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSBuild.
""" | [
"def",
"ValidateMSBuild",
"(",
"self",
",",
"value",
")",
":"
] | [
83,
4
] | [
91,
7
] | python | en | ['en', 'en', 'en'] | True |
_Type.ConvertToMSBuild | (self, value) | Returns the MSBuild equivalent of the MSVS value given.
Args:
value: the MSVS value to convert.
Returns:
the MSBuild equivalent.
Raises:
ValueError if value is not valid.
| Returns the MSBuild equivalent of the MSVS value given. | def ConvertToMSBuild(self, value):
"""Returns the MSBuild equivalent of the MSVS value given.
Args:
value: the MSVS value to convert.
Returns:
the MSBuild equivalent.
Raises:
ValueError if value is not valid.
"""
return value | [
"def",
"ConvertToMSBuild",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
93,
4
] | [
105,
20
] | python | en | ['en', 'en', 'en'] | True |
TestExpire.setUp | (self) |
make a dataset with 10 images with 2 ligthcurves + one empty image
|
make a dataset with 10 images with 2 ligthcurves + one empty image
| def setUp(self):
"""
make a dataset with 10 images with 2 ligthcurves + one empty image
"""
self.session = self.database.Session()
self.dataset = gen_dataset('expiring runningcatalog test')
self.band = gen_band(dataset=self.dataset, central=150**6)
skyregion = gen... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"session",
"=",
"self",
".",
"database",
".",
"Session",
"(",
")",
"self",
".",
"dataset",
"=",
"gen_dataset",
"(",
"'expiring runningcatalog test'",
")",
"self",
".",
"band",
"=",
"gen_band",
"(",
"dat... | [
43,
4
] | [
88,
29
] | python | en | ['en', 'error', 'th'] | False |
TestExpire.test_nulldetections | (self) |
Check if get_nulldetections doesn't return expired runcats
|
Check if get_nulldetections doesn't return expired runcats
| def test_nulldetections(self):
"""
Check if get_nulldetections doesn't return expired runcats
"""
# get all runningcatalog entries, should be two
runcats = self.session.query(Runningcatalog). \
filter(Runningcatalog.dataset == self.dataset).all()
self.assertE... | [
"def",
"test_nulldetections",
"(",
"self",
")",
":",
"# get all runningcatalog entries, should be two",
"runcats",
"=",
"self",
".",
"session",
".",
"query",
"(",
"Runningcatalog",
")",
".",
"filter",
"(",
"Runningcatalog",
".",
"dataset",
"==",
"self",
".",
"data... | [
90,
4
] | [
110,
35
] | python | en | ['en', 'error', 'th'] | False |
TestExpire.test_associate_nd | (self) |
Check if associate_nd increments the forcedfits_count column
|
Check if associate_nd increments the forcedfits_count column
| def test_associate_nd(self):
"""
Check if associate_nd increments the forcedfits_count column
"""
e = Extractedsource(zone=1, ra=1, decl=1, uncertainty_ew=1, x=1, y=1,
z=1, uncertainty_ns=1, ra_err=1, decl_err=1,
ra_fit_err=1, decl_... | [
"def",
"test_associate_nd",
"(",
"self",
")",
":",
"e",
"=",
"Extractedsource",
"(",
"zone",
"=",
"1",
",",
"ra",
"=",
"1",
",",
"decl",
"=",
"1",
",",
"uncertainty_ew",
"=",
"1",
",",
"x",
"=",
"1",
",",
"y",
"=",
"1",
",",
"z",
"=",
"1",
",... | [
112,
4
] | [
131,
73
] | python | en | ['en', 'error', 'th'] | False |
TestExpire.test_reset | (self) |
Check if 1-to-1 association resets expiration counter to 0
|
Check if 1-to-1 association resets expiration counter to 0
| def test_reset(self):
"""
Check if 1-to-1 association resets expiration counter to 0
"""
e = Extractedsource(zone=1, ra=1, decl=1, uncertainty_ew=1, x=1, y=1,
z=1, uncertainty_ns=1, ra_err=1, decl_err=1,
ra_fit_err=1, decl_fit_err=1... | [
"def",
"test_reset",
"(",
"self",
")",
":",
"e",
"=",
"Extractedsource",
"(",
"zone",
"=",
"1",
",",
"ra",
"=",
"1",
",",
"decl",
"=",
"1",
",",
"uncertainty_ew",
"=",
"1",
",",
"x",
"=",
"1",
",",
"y",
"=",
"1",
",",
"z",
"=",
"1",
",",
"u... | [
133,
4
] | [
160,
66
] | python | en | ['en', 'error', 'th'] | False |
TemporaryUploadedFile.temporary_file_path | (self) |
Returns the full path of this file.
|
Returns the full path of this file.
| def temporary_file_path(self):
"""
Returns the full path of this file.
"""
return self.file.name | [
"def",
"temporary_file_path",
"(",
"self",
")",
":",
"return",
"self",
".",
"file",
".",
"name"
] | [
66,
4
] | [
70,
29
] | python | en | ['en', 'error', 'th'] | False |
SimpleUploadedFile.from_dict | (cls, file_dict) |
Creates a SimpleUploadedFile object from
a dictionary object with the following keys:
- filename
- content-type
- content
|
Creates a SimpleUploadedFile object from
a dictionary object with the following keys:
- filename
- content-type
- content
| def from_dict(cls, file_dict):
"""
Creates a SimpleUploadedFile object from
a dictionary object with the following keys:
- filename
- content-type
- content
"""
return cls(file_dict['filename'],
file_dict['content'],
... | [
"def",
"from_dict",
"(",
"cls",
",",
"file_dict",
")",
":",
"return",
"cls",
"(",
"file_dict",
"[",
"'filename'",
"]",
",",
"file_dict",
"[",
"'content'",
"]",
",",
"file_dict",
".",
"get",
"(",
"'content-type'",
",",
"'text/plain'",
")",
")"
] | [
113,
4
] | [
123,
63
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.add_derivation_paths | (self, records: List[DerivationRecord]) |
Insert many derivation paths into the database.
|
Insert many derivation paths into the database.
| async def add_derivation_paths(self, records: List[DerivationRecord]) -> None:
"""
Insert many derivation paths into the database.
"""
async with self.db_wrapper.lock:
sql_records = []
for record in records:
self.all_puzzle_hashes.add(record.puzzle... | [
"async",
"def",
"add_derivation_paths",
"(",
"self",
",",
"records",
":",
"List",
"[",
"DerivationRecord",
"]",
")",
"->",
"None",
":",
"async",
"with",
"self",
".",
"db_wrapper",
".",
"lock",
":",
"sql_records",
"=",
"[",
"]",
"for",
"record",
"in",
"re... | [
79,
4
] | [
104,
45
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.get_derivation_record | (self, index: uint32, wallet_id: uint32) |
Returns the derivation record by index and wallet id.
|
Returns the derivation record by index and wallet id.
| async def get_derivation_record(self, index: uint32, wallet_id: uint32) -> Optional[DerivationRecord]:
"""
Returns the derivation record by index and wallet id.
"""
cursor = await self.db_connection.execute(
"SELECT * FROM derivation_paths WHERE derivation_index=? and wallet_... | [
"async",
"def",
"get_derivation_record",
"(",
"self",
",",
"index",
":",
"uint32",
",",
"wallet_id",
":",
"uint32",
")",
"->",
"Optional",
"[",
"DerivationRecord",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"\"SELECT... | [
106,
4
] | [
129,
19
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.get_derivation_record_for_puzzle_hash | (self, puzzle_hash: str) |
Returns the derivation record by index and wallet id.
|
Returns the derivation record by index and wallet id.
| async def get_derivation_record_for_puzzle_hash(self, puzzle_hash: str) -> Optional[DerivationRecord]:
"""
Returns the derivation record by index and wallet id.
"""
cursor = await self.db_connection.execute(
"SELECT * FROM derivation_paths WHERE puzzle_hash=?;",
(... | [
"async",
"def",
"get_derivation_record_for_puzzle_hash",
"(",
"self",
",",
"puzzle_hash",
":",
"str",
")",
"->",
"Optional",
"[",
"DerivationRecord",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"\"SELECT * FROM derivation_pat... | [
131,
4
] | [
151,
19
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.set_used_up_to | (self, index: uint32, in_transaction=False) |
Sets a derivation path to used so we don't use it again.
|
Sets a derivation path to used so we don't use it again.
| async def set_used_up_to(self, index: uint32, in_transaction=False) -> None:
"""
Sets a derivation path to used so we don't use it again.
"""
if not in_transaction:
await self.db_wrapper.lock.acquire()
try:
cursor = await self.db_connection.execute(
... | [
"async",
"def",
"set_used_up_to",
"(",
"self",
",",
"index",
":",
"uint32",
",",
"in_transaction",
"=",
"False",
")",
"->",
"None",
":",
"if",
"not",
"in_transaction",
":",
"await",
"self",
".",
"db_wrapper",
".",
"lock",
".",
"acquire",
"(",
")",
"try",... | [
153,
4
] | [
169,
46
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.puzzle_hash_exists | (self, puzzle_hash: bytes32) |
Checks if passed puzzle_hash is present in the db.
|
Checks if passed puzzle_hash is present in the db.
| async def puzzle_hash_exists(self, puzzle_hash: bytes32) -> bool:
"""
Checks if passed puzzle_hash is present in the db.
"""
cursor = await self.db_connection.execute(
"SELECT * from derivation_paths WHERE puzzle_hash=?", (puzzle_hash.hex(),)
)
row = await cu... | [
"async",
"def",
"puzzle_hash_exists",
"(",
"self",
",",
"puzzle_hash",
":",
"bytes32",
")",
"->",
"bool",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"\"SELECT * from derivation_paths WHERE puzzle_hash=?\"",
",",
"(",
"puzzle_hash... | [
171,
4
] | [
182,
30
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.one_of_puzzle_hashes_exists | (self, puzzle_hashes: List[bytes32]) |
Checks if one of the passed puzzle_hashes is present in the db.
|
Checks if one of the passed puzzle_hashes is present in the db.
| async def one_of_puzzle_hashes_exists(self, puzzle_hashes: List[bytes32]) -> bool:
"""
Checks if one of the passed puzzle_hashes is present in the db.
"""
if len(puzzle_hashes) < 1:
return False
for ph in puzzle_hashes:
if ph in self.all_puzzle_hashes:
... | [
"async",
"def",
"one_of_puzzle_hashes_exists",
"(",
"self",
",",
"puzzle_hashes",
":",
"List",
"[",
"bytes32",
"]",
")",
"->",
"bool",
":",
"if",
"len",
"(",
"puzzle_hashes",
")",
"<",
"1",
":",
"return",
"False",
"for",
"ph",
"in",
"puzzle_hashes",
":",
... | [
184,
4
] | [
195,
20
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.index_for_pubkey | (self, pubkey: G1Element) |
Returns derivation paths for the given pubkey.
Returns None if not present.
|
Returns derivation paths for the given pubkey.
Returns None if not present.
| async def index_for_pubkey(self, pubkey: G1Element) -> Optional[uint32]:
"""
Returns derivation paths for the given pubkey.
Returns None if not present.
"""
cursor = await self.db_connection.execute(
"SELECT * from derivation_paths WHERE pubkey=?", (bytes(pubkey).hex... | [
"async",
"def",
"index_for_pubkey",
"(",
"self",
",",
"pubkey",
":",
"G1Element",
")",
"->",
"Optional",
"[",
"uint32",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"\"SELECT * from derivation_paths WHERE pubkey=?\"",
",",
... | [
197,
4
] | [
212,
19
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.index_for_puzzle_hash | (self, puzzle_hash: bytes32) |
Returns the derivation path for the puzzle_hash.
Returns None if not present.
|
Returns the derivation path for the puzzle_hash.
Returns None if not present.
| async def index_for_puzzle_hash(self, puzzle_hash: bytes32) -> Optional[uint32]:
"""
Returns the derivation path for the puzzle_hash.
Returns None if not present.
"""
cursor = await self.db_connection.execute(
"SELECT * from derivation_paths WHERE puzzle_hash=?", (puz... | [
"async",
"def",
"index_for_puzzle_hash",
"(",
"self",
",",
"puzzle_hash",
":",
"bytes32",
")",
"->",
"Optional",
"[",
"uint32",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"\"SELECT * from derivation_paths WHERE puzzle_hash=?... | [
214,
4
] | [
228,
19
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.index_for_puzzle_hash_and_wallet | (self, puzzle_hash: bytes32, wallet_id: uint32) |
Returns the derivation path for the puzzle_hash.
Returns None if not present.
|
Returns the derivation path for the puzzle_hash.
Returns None if not present.
| async def index_for_puzzle_hash_and_wallet(self, puzzle_hash: bytes32, wallet_id: uint32) -> Optional[uint32]:
"""
Returns the derivation path for the puzzle_hash.
Returns None if not present.
"""
cursor = await self.db_connection.execute(
"SELECT * from derivation_pa... | [
"async",
"def",
"index_for_puzzle_hash_and_wallet",
"(",
"self",
",",
"puzzle_hash",
":",
"bytes32",
",",
"wallet_id",
":",
"uint32",
")",
"->",
"Optional",
"[",
"uint32",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"... | [
230,
4
] | [
248,
19
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.wallet_info_for_puzzle_hash | (self, puzzle_hash: bytes32) |
Returns the derivation path for the puzzle_hash.
Returns None if not present.
|
Returns the derivation path for the puzzle_hash.
Returns None if not present.
| async def wallet_info_for_puzzle_hash(self, puzzle_hash: bytes32) -> Optional[Tuple[uint32, WalletType]]:
"""
Returns the derivation path for the puzzle_hash.
Returns None if not present.
"""
cursor = await self.db_connection.execute(
"SELECT * from derivation_paths ... | [
"async",
"def",
"wallet_info_for_puzzle_hash",
"(",
"self",
",",
"puzzle_hash",
":",
"bytes32",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"uint32",
",",
"WalletType",
"]",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
... | [
250,
4
] | [
265,
19
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.get_all_puzzle_hashes | (self) |
Return a set containing all puzzle_hashes we generated.
|
Return a set containing all puzzle_hashes we generated.
| async def get_all_puzzle_hashes(self) -> Set[bytes32]:
"""
Return a set containing all puzzle_hashes we generated.
"""
cursor = await self.db_connection.execute("SELECT * from derivation_paths")
rows = await cursor.fetchall()
await cursor.close()
result: Set[byte... | [
"async",
"def",
"get_all_puzzle_hashes",
"(",
"self",
")",
"->",
"Set",
"[",
"bytes32",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"\"SELECT * from derivation_paths\"",
")",
"rows",
"=",
"await",
"cursor",
".",
"fetcha... | [
267,
4
] | [
280,
21
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.get_last_derivation_path | (self) |
Returns the last derivation path by derivation_index.
|
Returns the last derivation path by derivation_index.
| async def get_last_derivation_path(self) -> Optional[uint32]:
"""
Returns the last derivation path by derivation_index.
"""
cursor = await self.db_connection.execute("SELECT MAX(derivation_index) FROM derivation_paths;")
row = await cursor.fetchone()
await cursor.close()... | [
"async",
"def",
"get_last_derivation_path",
"(",
"self",
")",
"->",
"Optional",
"[",
"uint32",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"\"SELECT MAX(derivation_index) FROM derivation_paths;\"",
")",
"row",
"=",
"await",
... | [
282,
4
] | [
294,
19
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.get_last_derivation_path_for_wallet | (self, wallet_id: int) |
Returns the last derivation path by derivation_index.
|
Returns the last derivation path by derivation_index.
| async def get_last_derivation_path_for_wallet(self, wallet_id: int) -> Optional[uint32]:
"""
Returns the last derivation path by derivation_index.
"""
cursor = await self.db_connection.execute(
f"SELECT MAX(derivation_index) FROM derivation_paths WHERE wallet_id={wallet_id};... | [
"async",
"def",
"get_last_derivation_path_for_wallet",
"(",
"self",
",",
"wallet_id",
":",
"int",
")",
"->",
"Optional",
"[",
"uint32",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"f\"SELECT MAX(derivation_index) FROM derivat... | [
296,
4
] | [
310,
19
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.get_current_derivation_record_for_wallet | (self, wallet_id: uint32) |
Returns the current derivation record by derivation_index.
|
Returns the current derivation record by derivation_index.
| async def get_current_derivation_record_for_wallet(self, wallet_id: uint32) -> Optional[DerivationRecord]:
"""
Returns the current derivation record by derivation_index.
"""
cursor = await self.db_connection.execute(
f"SELECT MAX(derivation_index) FROM derivation_paths WHERE... | [
"async",
"def",
"get_current_derivation_record_for_wallet",
"(",
"self",
",",
"wallet_id",
":",
"uint32",
")",
"->",
"Optional",
"[",
"DerivationRecord",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"f\"SELECT MAX(derivation_i... | [
312,
4
] | [
327,
19
] | python | en | ['en', 'error', 'th'] | False |
WalletPuzzleStore.get_unused_derivation_path | (self) |
Returns the first unused derivation path by derivation_index.
|
Returns the first unused derivation path by derivation_index.
| async def get_unused_derivation_path(self) -> Optional[uint32]:
"""
Returns the first unused derivation path by derivation_index.
"""
cursor = await self.db_connection.execute("SELECT MIN(derivation_index) FROM derivation_paths WHERE used=0;")
row = await cursor.fetchone()
... | [
"async",
"def",
"get_unused_derivation_path",
"(",
"self",
")",
"->",
"Optional",
"[",
"uint32",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db_connection",
".",
"execute",
"(",
"\"SELECT MIN(derivation_index) FROM derivation_paths WHERE used=0;\"",
")",
"row",
"=... | [
329,
4
] | [
340,
19
] | python | en | ['en', 'error', 'th'] | False |
TestGUIScreen.test_draw_screen | (self) |
:type: bzt.modules.screen.GUIScreen
|
:type: bzt.modules.screen.GUIScreen
| def test_draw_screen(self):
lines = [((x[0], None, "%s\n" % x[0]),) for x in TaurusConsole.palette]
canvas = TestCanvas(lines)
obj = Screen()
"""
:type: bzt.modules.screen.GUIScreen
"""
obj.register_palette(TaurusConsole.palette)
obj.start()
for... | [
"def",
"test_draw_screen",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"(",
"(",
"x",
"[",
"0",
"]",
",",
"None",
",",
"\"%s\\n\"",
"%",
"x",
"[",
"0",
"]",
")",
",",
")",
"for",
"x",
"in",
"TaurusConsole",
".",
"palette",
"]",
"canvas",
"=",
"Te... | [
32,
4
] | [
67,
18
] | python | en | ['en', 'error', 'th'] | False |
as_user | (v, username, password=None) | Context manager to allow running tests as an alternative login user. | Context manager to allow running tests as an alternative login user. | def as_user(v, username, password=None):
"""Context manager to allow running tests as an alternative login user."""
access_token = False
if not isinstance(v, api.client.Connection):
connection = v.connection
else:
connection = v
if isinstance(username, api.User):
password = ... | [
"def",
"as_user",
"(",
"v",
",",
"username",
",",
"password",
"=",
"None",
")",
":",
"access_token",
"=",
"False",
"if",
"not",
"isinstance",
"(",
"v",
",",
"api",
".",
"client",
".",
"Connection",
")",
":",
"connection",
"=",
"v",
".",
"connection",
... | [
73,
0
] | [
120,
51
] | python | en | ['en', 'en', 'en'] | True |
GoogleBenchmark.getBenchmarkTests | (self, path, litConfig, localConfig) | getBenchmarkTests(path) - [name]
Return the tests available in gtest executable.
Args:
path: String path to a gtest executable
litConfig: LitConfig instance
localConfig: TestingConfig instance | getBenchmarkTests(path) - [name] | def getBenchmarkTests(self, path, litConfig, localConfig):
"""getBenchmarkTests(path) - [name]
Return the tests available in gtest executable.
Args:
path: String path to a gtest executable
litConfig: LitConfig instance
localConfig: TestingConfig instance"""
... | [
"def",
"getBenchmarkTests",
"(",
"self",
",",
"path",
",",
"litConfig",
",",
"localConfig",
")",
":",
"# TODO: allow splitting tests according to the \"benchmark family\" so",
"# the output for a single family of tests all belongs to the same test",
"# target.",
"list_test_cmd",
"=",... | [
25,
4
] | [
69,
48
] | python | en | ['de', 'en', 'en'] | True |
remove_image_permissions | (apps, schema_editor) | Reverse the above additions of permissions. | Reverse the above additions of permissions. | def remove_image_permissions(apps, schema_editor):
"""Reverse the above additions of permissions."""
ContentType = apps.get_model('contenttypes.ContentType')
Permission = apps.get_model('auth.Permission')
image_content_type = ContentType.objects.get(
model='image',
app_label='wagtailimag... | [
"def",
"remove_image_permissions",
"(",
"apps",
",",
"schema_editor",
")",
":",
"ContentType",
"=",
"apps",
".",
"get_model",
"(",
"'contenttypes.ContentType'",
")",
"Permission",
"=",
"apps",
".",
"get_model",
"(",
"'auth.Permission'",
")",
"image_content_type",
"=... | [
46,
0
] | [
58,
14
] | python | en | ['en', 'en', 'en'] | True |
CXXCompiler.hasWarningFlag | (self, flag) |
hasWarningFlag - Test if the compiler supports a given warning flag.
Unlike addCompileFlagIfSupported, this function detects when
"-Wno-<warning>" flags are unsupported. If flag is a
"-Wno-<warning>" GCC will not emit an unknown option diagnostic unless
another error is triggere... |
hasWarningFlag - Test if the compiler supports a given warning flag.
Unlike addCompileFlagIfSupported, this function detects when
"-Wno-<warning>" flags are unsupported. If flag is a
"-Wno-<warning>" GCC will not emit an unknown option diagnostic unless
another error is triggere... | def hasWarningFlag(self, flag):
"""
hasWarningFlag - Test if the compiler supports a given warning flag.
Unlike addCompileFlagIfSupported, this function detects when
"-Wno-<warning>" flags are unsupported. If flag is a
"-Wno-<warning>" GCC will not emit an unknown option diagnost... | [
"def",
"hasWarningFlag",
"(",
"self",
",",
"flag",
")",
":",
"assert",
"isinstance",
"(",
"flag",
",",
"str",
")",
"assert",
"flag",
".",
"startswith",
"(",
"'-W'",
")",
"if",
"not",
"flag",
".",
"startswith",
"(",
"'-Wno-'",
")",
":",
"return",
"self"... | [
255,
4
] | [
283,
19
] | python | en | ['en', 'error', 'th'] | False |
substitute_inf | (value, sub="Infinity") |
If value is not infinite, return value. Otherwise, return sub.
|
If value is not infinite, return value. Otherwise, return sub.
| def substitute_inf(value, sub="Infinity"):
"""
If value is not infinite, return value. Otherwise, return sub.
"""
return substitute(value, sub, math.isinf) | [
"def",
"substitute_inf",
"(",
"value",
",",
"sub",
"=",
"\"Infinity\"",
")",
":",
"return",
"substitute",
"(",
"value",
",",
"sub",
",",
"math",
".",
"isinf",
")"
] | [
21,
0
] | [
25,
45
] | python | en | ['en', 'error', 'th'] | False |
substitute_nan | (value, sub=0.0) |
If value is not NaN, return value. Otherwise, return sub.
|
If value is not NaN, return value. Otherwise, return sub. | def substitute_nan(value, sub=0.0):
"""
If value is not NaN, return value. Otherwise, return sub.
"""
return substitute(value, sub, math.isnan) | [
"def",
"substitute_nan",
"(",
"value",
",",
"sub",
"=",
"0.0",
")",
":",
"return",
"substitute",
"(",
"value",
",",
"sub",
",",
"math",
".",
"isnan",
")"
] | [
28,
0
] | [
33,
45
] | python | en | ['en', 'error', 'th'] | False |
RecallPrecisionExperiment.__init__ | (self, N, vectors, coverage_ratio=0.2) |
Performs exact nearest neighbour search on the data set.
vectors can either be a numpy matrix with all the vectors
as columns OR a python array containing the individual
numpy vectors.
|
Performs exact nearest neighbour search on the data set. | def __init__(self, N, vectors, coverage_ratio=0.2):
"""
Performs exact nearest neighbour search on the data set.
vectors can either be a numpy matrix with all the vectors
as columns OR a python array containing the individual
numpy vectors.
"""
# We need a dict f... | [
"def",
"__init__",
"(",
"self",
",",
"N",
",",
"vectors",
",",
"coverage_ratio",
"=",
"0.2",
")",
":",
"# We need a dict from vector string representation to index",
"self",
".",
"vector_dict",
"=",
"{",
"}",
"self",
".",
"N",
"=",
"N",
"self",
".",
"coverage_... | [
52,
4
] | [
102,
75
] | python | en | ['en', 'error', 'th'] | False |
RecallPrecisionExperiment.perform_experiment | (self, engine_list) |
Performs nearest neighbour recall experiments with custom vector data
for all engines in the specified list.
Returns self.result contains list of (recall, precision, search_time)
tuple. All are the averaged values over all request vectors.
search_time is the average retrieval/s... |
Performs nearest neighbour recall experiments with custom vector data
for all engines in the specified list. | def perform_experiment(self, engine_list):
"""
Performs nearest neighbour recall experiments with custom vector data
for all engines in the specified list.
Returns self.result contains list of (recall, precision, search_time)
tuple. All are the averaged values over all request v... | [
"def",
"perform_experiment",
"(",
"self",
",",
"engine_list",
")",
":",
"# We will fill this array with measures for all the engines.",
"result",
"=",
"[",
"]",
"# For each engine, first index vectors and then retrieve neighbours",
"for",
"endine_idx",
",",
"engine",
"in",
"enu... | [
104,
4
] | [
199,
21
] | python | en | ['en', 'error', 'th'] | False |
RecallPrecisionExperiment.__vector_to_string | (self, vector) | Returns string representation of vector. | Returns string representation of vector. | def __vector_to_string(self, vector):
""" Returns string representation of vector. """
return numpy.array_str(numpy.round(unitvec(vector), decimals=3)) | [
"def",
"__vector_to_string",
"(",
"self",
",",
"vector",
")",
":",
"return",
"numpy",
".",
"array_str",
"(",
"numpy",
".",
"round",
"(",
"unitvec",
"(",
"vector",
")",
",",
"decimals",
"=",
"3",
")",
")"
] | [
201,
4
] | [
203,
72
] | python | en | ['en', 'sv', 'en'] | True |
RecallPrecisionExperiment.__index_of_vector | (self, vector) | Returns index of specified vector from test data set. | Returns index of specified vector from test data set. | def __index_of_vector(self, vector):
""" Returns index of specified vector from test data set. """
return self.vector_dict[self.__vector_to_string(vector)] | [
"def",
"__index_of_vector",
"(",
"self",
",",
"vector",
")",
":",
"return",
"self",
".",
"vector_dict",
"[",
"self",
".",
"__vector_to_string",
"(",
"vector",
")",
"]"
] | [
205,
4
] | [
207,
64
] | python | en | ['en', 'en', 'en'] | True |
AboutPageTest.test_split_by | (self) | Utility function primarily used in authors page | Utility function primarily used in authors page | def test_split_by(self) -> None:
"""Utility function primarily used in authors page"""
flat_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
expected_result = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
self.assertEqual(split_by(flat_list, 3, None), expected_result) | [
"def",
"test_split_by",
"(",
"self",
")",
"->",
"None",
":",
"flat_list",
"=",
"[",
"1",
",",
"2",
",",
"3",
",",
"4",
",",
"5",
",",
"6",
",",
"7",
",",
"8",
",",
"9",
"]",
"expected_result",
"=",
"[",
"[",
"1",
",",
"2",
",",
"3",
"]",
... | [
370,
4
] | [
374,
71
] | python | en | ['en', 'en', 'en'] | True |
test_auto_field_adjustments | (organization, inventory, team, alice) | Ensures the auto role reparenting is working correctly through non m2m fields | Ensures the auto role reparenting is working correctly through non m2m fields | def test_auto_field_adjustments(organization, inventory, team, alice):
'Ensures the auto role reparenting is working correctly through non m2m fields'
org2 = Organization.objects.create(name='Org 2', description='org 2')
org2.admin_role.members.add(alice)
assert alice not in inventory.admin_role
inv... | [
"def",
"test_auto_field_adjustments",
"(",
"organization",
",",
"inventory",
",",
"team",
",",
"alice",
")",
":",
"org2",
"=",
"Organization",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'Org 2'",
",",
"description",
"=",
"'org 2'",
")",
"org2",
".",
... | [
83,
0
] | [
93,
44
] | python | en | ['en', 'en', 'en'] | True |
test_implicit_deletes | (alice) | Ensures implicit resources and roles delete themselves | Ensures implicit resources and roles delete themselves | def test_implicit_deletes(alice):
'Ensures implicit resources and roles delete themselves'
delorg = Organization.objects.create(name='test-org')
child = Role.objects.create()
child.parents.add(delorg.admin_role)
delorg.admin_role.members.add(alice)
admin_role_id = delorg.admin_role.id
audit... | [
"def",
"test_implicit_deletes",
"(",
"alice",
")",
":",
"delorg",
"=",
"Organization",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'test-org'",
")",
"child",
"=",
"Role",
".",
"objects",
".",
"create",
"(",
")",
"child",
".",
"parents",
".",
"add",... | [
98,
0
] | [
121,
44
] | python | en | ['en', 'en', 'en'] | True |
test_content_object | (user) | Ensure our content_object stuf seems to be working | Ensure our content_object stuf seems to be working | def test_content_object(user):
'Ensure our content_object stuf seems to be working'
org = Organization.objects.create(name='test-org')
assert org.admin_role.content_object.id == org.id | [
"def",
"test_content_object",
"(",
"user",
")",
":",
"org",
"=",
"Organization",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'test-org'",
")",
"assert",
"org",
".",
"admin_role",
".",
"content_object",
".",
"id",
"==",
"org",
".",
"id"
] | [
125,
0
] | [
129,
53
] | python | en | ['en', 'en', 'en'] | True |
test_hierarchy_rebuilding_multi_path | () | Tests a subdtle cases around role hierarchy rebuilding when you have multiple paths to the same role of different length | Tests a subdtle cases around role hierarchy rebuilding when you have multiple paths to the same role of different length | def test_hierarchy_rebuilding_multi_path():
'Tests a subdtle cases around role hierarchy rebuilding when you have multiple paths to the same role of different length'
X = Role.objects.create()
A = Role.objects.create()
B = Role.objects.create()
C = Role.objects.create()
D = Role.objects.create(... | [
"def",
"test_hierarchy_rebuilding_multi_path",
"(",
")",
":",
"X",
"=",
"Role",
".",
"objects",
".",
"create",
"(",
")",
"A",
"=",
"Role",
".",
"objects",
".",
"create",
"(",
")",
"B",
"=",
"Role",
".",
"objects",
".",
"create",
"(",
")",
"C",
"=",
... | [
133,
0
] | [
158,
39
] | python | en | ['en', 'en', 'en'] | True |
label_bam | (bam_fn, output_bam_fn, nanopolish_polya_tsv_fn) |
Take TSV output from Nanopolish polya and use it to annotate a BAM file
using pA tag (float, original polyA length from nanopolish) and bA tag
(str, binned polyA length). Reads which are unmapped or QC filtered by
nanopolish are removed.
|
Take TSV output from Nanopolish polya and use it to annotate a BAM file
using pA tag (float, original polyA length from nanopolish) and bA tag
(str, binned polyA length). Reads which are unmapped or QC filtered by
nanopolish are removed.
| def label_bam(bam_fn, output_bam_fn, nanopolish_polya_tsv_fn):
'''
Take TSV output from Nanopolish polya and use it to annotate a BAM file
using pA tag (float, original polyA length from nanopolish) and bA tag
(str, binned polyA length). Reads which are unmapped or QC filtered by
nanopolish are remo... | [
"def",
"label_bam",
"(",
"bam_fn",
",",
"output_bam_fn",
",",
"nanopolish_polya_tsv_fn",
")",
":",
"add_pa_tag",
"(",
"bam_fn",
",",
"output_bam_fn",
",",
"nanopolish_polya_tsv_fn",
",",
"bins",
"=",
"BINS",
")"
] | [
39,
0
] | [
46,
73
] | python | en | ['en', 'error', 'th'] | False |
cached_classmethod.__get__ | (self, instance, owner) | Get the class_cache for this type when accessed | Get the class_cache for this type when accessed | def __get__(self, instance, owner):
""" Get the class_cache for this type when accessed """
return self[owner] | [
"def",
"__get__",
"(",
"self",
",",
"instance",
",",
"owner",
")",
":",
"return",
"self",
"[",
"owner",
"]"
] | [
26,
4
] | [
28,
26
] | python | en | ['en', 'en', 'en'] | True |
cached_classmethod.__missing__ | (self, cls) | Make a new class_cache on cache misses | Make a new class_cache on cache misses | def __missing__(self, cls):
""" Make a new class_cache on cache misses """
value = _cache(self, cls, self.fn)
self[cls] = value
return value | [
"def",
"__missing__",
"(",
"self",
",",
"cls",
")",
":",
"value",
"=",
"_cache",
"(",
"self",
",",
"cls",
",",
"self",
".",
"fn",
")",
"self",
"[",
"cls",
"]",
"=",
"value",
"return",
"value"
] | [
30,
4
] | [
34,
20
] | python | en | ['en', 'en', 'en'] | True |
_cache.value | (self) | Generate the cached value | Generate the cached value | def value(self):
""" Generate the cached value """
return self.fn(self.cls) | [
"def",
"value",
"(",
"self",
")",
":",
"return",
"self",
".",
"fn",
"(",
"self",
".",
"cls",
")"
] | [
46,
4
] | [
48,
32
] | python | en | ['en', 'en', 'en'] | True |
_cache.__call__ | (self) | Get the cached value | Get the cached value | def __call__(self):
""" Get the cached value """
return self.value | [
"def",
"__call__",
"(",
"self",
")",
":",
"return",
"self",
".",
"value"
] | [
50,
4
] | [
52,
25
] | python | en | ['en', 'en', 'en'] | True |
_cache.cache_clear | (self) | Clear the cached value. | Clear the cached value. | def cache_clear(self):
""" Clear the cached value. """
# Named after lru_cache.cache_clear
self.cache.pop(self.cls, None) | [
"def",
"cache_clear",
"(",
"self",
")",
":",
"# Named after lru_cache.cache_clear",
"self",
".",
"cache",
".",
"pop",
"(",
"self",
".",
"cls",
",",
"None",
")"
] | [
54,
4
] | [
57,
38
] | python | en | ['en', 'en', 'en'] | True |
repository | (urls = urls, log = EmptyLogger()) |
Downloads and parse mingw-build repository files and parses them
|
Downloads and parse mingw-build repository files and parses them
| def repository(urls = urls, log = EmptyLogger()):
'''
Downloads and parse mingw-build repository files and parses them
'''
log.info('getting mingw-builds repository')
versions = {}
re_sourceforge = re.compile(r'http://sourceforge.net/projects/([^/]+)/files')
re_sub = r'http://downloads.sourc... | [
"def",
"repository",
"(",
"urls",
"=",
"urls",
",",
"log",
"=",
"EmptyLogger",
"(",
")",
")",
":",
"log",
".",
"info",
"(",
"'getting mingw-builds repository'",
")",
"versions",
"=",
"{",
"}",
"re_sourceforge",
"=",
"re",
".",
"compile",
"(",
"r'http://sou... | [
54,
0
] | [
83,
19
] | python | en | ['en', 'error', 'th'] | False |
find_in_path | (file, path=None) |
Attempts to find an executable in the path
|
Attempts to find an executable in the path
| def find_in_path(file, path=None):
'''
Attempts to find an executable in the path
'''
if platform.system() == 'Windows':
file += '.exe'
if path is None:
path = os.environ.get('PATH', '')
if type(path) is type(''):
path = path.split(os.pathsep)
return list(filter(os.pa... | [
"def",
"find_in_path",
"(",
"file",
",",
"path",
"=",
"None",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Windows'",
":",
"file",
"+=",
"'.exe'",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
... | [
85,
0
] | [
96,
67
] | python | en | ['en', 'error', 'th'] | False |
find_7zip | (log = EmptyLogger()) |
Attempts to find 7zip for unpacking the mingw-build archives
|
Attempts to find 7zip for unpacking the mingw-build archives
| def find_7zip(log = EmptyLogger()):
'''
Attempts to find 7zip for unpacking the mingw-build archives
'''
log.info('finding 7zip')
path = find_in_path('7z')
if not path:
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\7-Zip')
path, _ = winreg.QueryValueEx(key, 'Path')
... | [
"def",
"find_7zip",
"(",
"log",
"=",
"EmptyLogger",
"(",
")",
")",
":",
"log",
".",
"info",
"(",
"'finding 7zip'",
")",
"path",
"=",
"find_in_path",
"(",
"'7z'",
")",
"if",
"not",
"path",
":",
"key",
"=",
"winreg",
".",
"OpenKey",
"(",
"winreg",
".",... | [
98,
0
] | [
109,
18
] | python | en | ['en', 'error', 'th'] | False |
unpack | (archive, location, log = EmptyLogger()) |
Unpacks a mingw-builds archive
|
Unpacks a mingw-builds archive
| def unpack(archive, location, log = EmptyLogger()):
'''
Unpacks a mingw-builds archive
'''
sevenzip = find_7zip(log)
log.info('unpacking %s', os.path.basename(archive))
cmd = [sevenzip, 'x', archive, '-o' + location, '-y']
log.debug(' - %r', cmd)
with open(os.devnull, 'w') as devnull:
... | [
"def",
"unpack",
"(",
"archive",
",",
"location",
",",
"log",
"=",
"EmptyLogger",
"(",
")",
")",
":",
"sevenzip",
"=",
"find_7zip",
"(",
"log",
")",
"log",
".",
"info",
"(",
"'unpacking %s'",
",",
"os",
".",
"path",
".",
"basename",
"(",
"archive",
"... | [
113,
0
] | [
122,
52
] | python | en | ['en', 'error', 'th'] | False |
download | (url, location, log = EmptyLogger()) |
Downloads and unpacks a mingw-builds archive
|
Downloads and unpacks a mingw-builds archive
| def download(url, location, log = EmptyLogger()):
'''
Downloads and unpacks a mingw-builds archive
'''
log.info('downloading MinGW')
log.debug(' - url: %s', url)
log.debug(' - location: %s', location)
re_content = re.compile(r'attachment;[ \t]*filename=(")?([^"]*)(")?[\r\n]*')
stream =... | [
"def",
"download",
"(",
"url",
",",
"location",
",",
"log",
"=",
"EmptyLogger",
"(",
")",
")",
":",
"log",
".",
"info",
"(",
"'downloading MinGW'",
")",
"log",
".",
"debug",
"(",
"' - url: %s'",
",",
"url",
")",
"log",
".",
"debug",
"(",
"' - location:... | [
124,
0
] | [
169,
19
] | python | en | ['en', 'error', 'th'] | False |
root | (location = None, arch = None, version = None, threading = None,
exceptions = None, revision = None, log = EmptyLogger()) |
Returns the root folder of a specific version of the mingw-builds variant
of gcc. Will download the compiler if needed
|
Returns the root folder of a specific version of the mingw-builds variant
of gcc. Will download the compiler if needed
| def root(location = None, arch = None, version = None, threading = None,
exceptions = None, revision = None, log = EmptyLogger()):
'''
Returns the root folder of a specific version of the mingw-builds variant
of gcc. Will download the compiler if needed
'''
# Get the repository if we don't ... | [
"def",
"root",
"(",
"location",
"=",
"None",
",",
"arch",
"=",
"None",
",",
"version",
"=",
"None",
",",
"threading",
"=",
"None",
",",
"exceptions",
"=",
"None",
",",
"revision",
"=",
"None",
",",
"log",
"=",
"EmptyLogger",
"(",
")",
")",
":",
"# ... | [
171,
0
] | [
245,
19
] | python | en | ['en', 'error', 'th'] | False |
str2ver | (string) |
Converts a version string into a tuple
|
Converts a version string into a tuple
| def str2ver(string):
'''
Converts a version string into a tuple
'''
try:
version = tuple(int(v) for v in string.split('.'))
if len(version) is not 3:
raise ValueError()
except ValueError:
raise argparse.ArgumentTypeError(
'please provide a three digit ... | [
"def",
"str2ver",
"(",
"string",
")",
":",
"try",
":",
"version",
"=",
"tuple",
"(",
"int",
"(",
"v",
")",
"for",
"v",
"in",
"string",
".",
"split",
"(",
"'.'",
")",
")",
"if",
"len",
"(",
"version",
")",
"is",
"not",
"3",
":",
"raise",
"ValueE... | [
247,
0
] | [
258,
18
] | python | en | ['en', 'error', 'th'] | False |
main | () |
Invoked when the script is run directly by the python interpreter
|
Invoked when the script is run directly by the python interpreter
| def main():
'''
Invoked when the script is run directly by the python interpreter
'''
parser = argparse.ArgumentParser(
description = 'Downloads a specific version of MinGW',
formatter_class = argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument('--location',
help... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Downloads a specific version of MinGW'",
",",
"formatter_class",
"=",
"argparse",
".",
"ArgumentDefaultsHelpFormatter",
")",
"parser",
".",
"add_argument",
"(",
... | [
260,
0
] | [
306,
60
] | python | en | ['en', 'error', 'th'] | False |
read_svgcoords | (svg_file) | Get the vertices coordinates out of a SVG file | Get the vertices coordinates out of a SVG file | def read_svgcoords(svg_file):
"""Get the vertices coordinates out of a SVG file"""
from xml.dom import minidom
doc = minidom.parse(svg_file)
coords = [path.getAttribute('d') for path
in doc.getElementsByTagName('path')]
doc.unlink()
_, _, coords = coords[0].partition('C')
x = ... | [
"def",
"read_svgcoords",
"(",
"svg_file",
")",
":",
"from",
"xml",
".",
"dom",
"import",
"minidom",
"doc",
"=",
"minidom",
".",
"parse",
"(",
"svg_file",
")",
"coords",
"=",
"[",
"path",
".",
"getAttribute",
"(",
"'d'",
")",
"for",
"path",
"in",
"doc",... | [
32,
0
] | [
52,
57
] | python | en | ['en', 'en', 'en'] | True |
get_muting_users | (muted_user_id: int) |
This is kind of the inverse of `get_user_mutes` above.
While `get_user_mutes` is mainly used for event system work,
this is used in the message send codepath, to get a list
of IDs of users who have muted a particular user.
The result will also include deactivated users.
|
This is kind of the inverse of `get_user_mutes` above.
While `get_user_mutes` is mainly used for event system work,
this is used in the message send codepath, to get a list
of IDs of users who have muted a particular user.
The result will also include deactivated users.
| def get_muting_users(muted_user_id: int) -> Set[int]:
"""
This is kind of the inverse of `get_user_mutes` above.
While `get_user_mutes` is mainly used for event system work,
this is used in the message send codepath, to get a list
of IDs of users who have muted a particular user.
The result will... | [
"def",
"get_muting_users",
"(",
"muted_user_id",
":",
"int",
")",
"->",
"Set",
"[",
"int",
"]",
":",
"rows",
"=",
"MutedUser",
".",
"objects",
".",
"filter",
"(",
"muted_user_id",
"=",
"muted_user_id",
",",
")",
".",
"values",
"(",
"\"user_profile_id\"",
"... | [
40,
0
] | [
51,
51
] | python | en | ['en', 'error', 'th'] | False |
make_sub_epoch_summary | (
constants: ConsensusConstants,
blocks: BlockchainInterface,
blocks_included_height: uint32,
prev_prev_block: BlockRecord,
new_difficulty: Optional[uint64],
new_sub_slot_iters: Optional[uint64],
) |
Creates a sub-epoch-summary object, assuming that the first block in the new sub-epoch is at height
"blocks_included_height". Prev_prev_b is the second to last block in the previous sub-epoch. On a new epoch,
new_difficulty and new_sub_slot_iters are also added.
Args:
constants: consensus cons... |
Creates a sub-epoch-summary object, assuming that the first block in the new sub-epoch is at height
"blocks_included_height". Prev_prev_b is the second to last block in the previous sub-epoch. On a new epoch,
new_difficulty and new_sub_slot_iters are also added. | def make_sub_epoch_summary(
constants: ConsensusConstants,
blocks: BlockchainInterface,
blocks_included_height: uint32,
prev_prev_block: BlockRecord,
new_difficulty: Optional[uint64],
new_sub_slot_iters: Optional[uint64],
) -> SubEpochSummary:
"""
Creates a sub-epoch-summary object, assu... | [
"def",
"make_sub_epoch_summary",
"(",
"constants",
":",
"ConsensusConstants",
",",
"blocks",
":",
"BlockchainInterface",
",",
"blocks_included_height",
":",
"uint32",
",",
"prev_prev_block",
":",
"BlockRecord",
",",
"new_difficulty",
":",
"Optional",
"[",
"uint64",
"]... | [
23,
0
] | [
68,
5
] | python | en | ['en', 'error', 'th'] | False |
next_sub_epoch_summary | (
constants: ConsensusConstants,
blocks: BlockchainInterface,
required_iters: uint64,
block: Union[UnfinishedBlock, FullBlock],
can_finish_soon: bool = False,
) |
Returns the sub-epoch summary that can be included in the block after block. If it should include one. Block
must be eligible to be the last block in the epoch. If not, returns None. Assumes that there is a new slot
ending after block.
Args:
constants: consensus constants being used for this c... |
Returns the sub-epoch summary that can be included in the block after block. If it should include one. Block
must be eligible to be the last block in the epoch. If not, returns None. Assumes that there is a new slot
ending after block. | def next_sub_epoch_summary(
constants: ConsensusConstants,
blocks: BlockchainInterface,
required_iters: uint64,
block: Union[UnfinishedBlock, FullBlock],
can_finish_soon: bool = False,
) -> Optional[SubEpochSummary]:
"""
Returns the sub-epoch summary that can be included in the block after b... | [
"def",
"next_sub_epoch_summary",
"(",
"constants",
":",
"ConsensusConstants",
",",
"blocks",
":",
"BlockchainInterface",
",",
"required_iters",
":",
"uint64",
",",
"block",
":",
"Union",
"[",
"UnfinishedBlock",
",",
"FullBlock",
"]",
",",
"can_finish_soon",
":",
"... | [
71,
0
] | [
202,
5
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.