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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
TestSearchBase.test_search_distance_substructure_flat_index | (self, connect, substructure_collection) |
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
|
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
| def test_search_distance_substructure_flat_index(self, connect, substructure_collection):
'''
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed... | [
"def",
"test_search_distance_substructure_flat_index",
"(",
"self",
",",
"connect",
",",
"substructure_collection",
")",
":",
"# from scipy.spatial import distance",
"nprobe",
"=",
"512",
"int_vectors",
",",
"vectors",
",",
"ids",
"=",
"self",
".",
"init_binary_data",
"... | [
647,
4
] | [
670,
34
] | python | en | ['en', 'error', 'th'] | False |
TestSearchBase.test_search_distance_substructure_flat_index_B | (self, connect, substructure_collection) |
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with SUB
expected: the return distance equals to the computed value
|
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with SUB
expected: the return distance equals to the computed value
| def test_search_distance_substructure_flat_index_B(self, connect, substructure_collection):
'''
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with SUB
expected: the return distance equals to the computed value
... | [
"def",
"test_search_distance_substructure_flat_index_B",
"(",
"self",
",",
"connect",
",",
"substructure_collection",
")",
":",
"# from scipy.spatial import distance",
"top_k",
"=",
"3",
"nprobe",
"=",
"512",
"int_vectors",
",",
"vectors",
",",
"ids",
"=",
"self",
"."... | [
672,
4
] | [
699,
40
] | python | en | ['en', 'error', 'th'] | False |
TestSearchBase.test_search_distance_superstructure_flat_index | (self, connect, superstructure_collection) |
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
|
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
| def test_search_distance_superstructure_flat_index(self, connect, superstructure_collection):
'''
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the comp... | [
"def",
"test_search_distance_superstructure_flat_index",
"(",
"self",
",",
"connect",
",",
"superstructure_collection",
")",
":",
"# from scipy.spatial import distance",
"nprobe",
"=",
"512",
"int_vectors",
",",
"vectors",
",",
"ids",
"=",
"self",
".",
"init_binary_data",... | [
701,
4
] | [
724,
34
] | python | en | ['en', 'error', 'th'] | False |
TestSearchBase.test_search_distance_superstructure_flat_index_B | (self, connect, superstructure_collection) |
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with SUPER
expected: the return distance equals to the computed value
|
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with SUPER
expected: the return distance equals to the computed value
| def test_search_distance_superstructure_flat_index_B(self, connect, superstructure_collection):
'''
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with SUPER
expected: the return distance equals to the computed v... | [
"def",
"test_search_distance_superstructure_flat_index_B",
"(",
"self",
",",
"connect",
",",
"superstructure_collection",
")",
":",
"# from scipy.spatial import distance",
"top_k",
"=",
"3",
"nprobe",
"=",
"512",
"int_vectors",
",",
"vectors",
",",
"ids",
"=",
"self",
... | [
726,
4
] | [
753,
47
] | python | en | ['en', 'error', 'th'] | False |
TestSearchBase.test_search_distance_tanimoto_flat_index | (self, connect, tanimoto_collection) |
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
|
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
| def test_search_distance_tanimoto_flat_index(self, connect, tanimoto_collection):
'''
target: search ip_collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
... | [
"def",
"test_search_distance_tanimoto_flat_index",
"(",
"self",
",",
"connect",
",",
"tanimoto_collection",
")",
":",
"# from scipy.spatial import distance",
"nprobe",
"=",
"512",
"int_vectors",
",",
"vectors",
",",
"ids",
"=",
"self",
".",
"init_binary_data",
"(",
"c... | [
755,
4
] | [
778,
82
] | python | en | ['en', 'error', 'th'] | False |
TestSearchBase.test_search_distance_ip_index_params | (self, connect, ip_collection, get_index) |
target: search collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
|
target: search collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
| def test_search_distance_ip_index_params(self, connect, ip_collection, get_index):
'''
target: search collection, and check the result: distance
method: compare the return distance value with value computed with Inner product
expected: the return distance equals to the computed value
... | [
"def",
"test_search_distance_ip_index_params",
"(",
"self",
",",
"connect",
",",
"ip_collection",
",",
"get_index",
")",
":",
"top_k",
"=",
"2",
"nprobe",
"=",
"1",
"index_param",
"=",
"get_index",
"[",
"\"index_param\"",
"]",
"index_type",
"=",
"get_index",
"["... | [
780,
4
] | [
802,
112
] | python | en | ['en', 'error', 'th'] | False |
TestSearchBase.test_search_concurrent_multithreads | (self, args) |
target: test concurrent search with multiprocessess
method: search with 10 processes, each process uses dependent connection
expected: status ok and the returned vectors should be query_records
|
target: test concurrent search with multiprocessess
method: search with 10 processes, each process uses dependent connection
expected: status ok and the returned vectors should be query_records
| def test_search_concurrent_multithreads(self, args):
'''
target: test concurrent search with multiprocessess
method: search with 10 processes, each process uses dependent connection
expected: status ok and the returned vectors should be query_records
'''
nb = 100
... | [
"def",
"test_search_concurrent_multithreads",
"(",
"self",
",",
"args",
")",
":",
"nb",
"=",
"100",
"top_k",
"=",
"10",
"threads_num",
"=",
"4",
"threads",
"=",
"[",
"]",
"collection",
"=",
"gen_unique_str",
"(",
"\"test_search_concurrent_multiprocessing\"",
")",
... | [
829,
4
] | [
864,
20
] | python | en | ['en', 'error', 'th'] | False |
TestSearchBase._test_search_concurrent_multiprocessing | (self, args) |
target: test concurrent search with multiprocessess
method: search with 10 processes, each process uses dependent connection
expected: status ok and the returned vectors should be query_records
|
target: test concurrent search with multiprocessess
method: search with 10 processes, each process uses dependent connection
expected: status ok and the returned vectors should be query_records
| def _test_search_concurrent_multiprocessing(self, args):
'''
target: test concurrent search with multiprocessess
method: search with 10 processes, each process uses dependent connection
expected: status ok and the returned vectors should be query_records
'''
nb = 100
... | [
"def",
"_test_search_concurrent_multiprocessing",
"(",
"self",
",",
"args",
")",
":",
"nb",
"=",
"100",
"top_k",
"=",
"10",
"process_num",
"=",
"4",
"processes",
"=",
"[",
"]",
"collection",
"=",
"gen_unique_str",
"(",
"\"test_search_concurrent_multiprocessing\"",
... | [
868,
4
] | [
903,
20
] | python | en | ['en', 'error', 'th'] | False |
TestSearchBase.test_search_multi_collection_L2 | (search, args) |
target: test search multi collections of L2
method: add vectors into 10 collections, and search
expected: search status ok, the length of result
|
target: test search multi collections of L2
method: add vectors into 10 collections, and search
expected: search status ok, the length of result
| def test_search_multi_collection_L2(search, args):
'''
target: test search multi collections of L2
method: add vectors into 10 collections, and search
expected: search status ok, the length of result
'''
num = 10
top_k = 10
collections = []
idx = [... | [
"def",
"test_search_multi_collection_L2",
"(",
"search",
",",
"args",
")",
":",
"num",
"=",
"10",
"top_k",
"=",
"10",
"collections",
"=",
"[",
"]",
"idx",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"num",
")",
":",
"collection",
"=",
"gen_unique_st... | [
905,
4
] | [
943,
62
] | python | en | ['en', 'error', 'th'] | False |
TestSearchBase.test_search_multi_collection_IP | (search, args) |
target: test search multi collections of IP
method: add vectors into 10 collections, and search
expected: search status ok, the length of result
|
target: test search multi collections of IP
method: add vectors into 10 collections, and search
expected: search status ok, the length of result
| def test_search_multi_collection_IP(search, args):
'''
target: test search multi collections of IP
method: add vectors into 10 collections, and search
expected: search status ok, the length of result
'''
num = 10
top_k = 10
collections = []
idx = [... | [
"def",
"test_search_multi_collection_IP",
"(",
"search",
",",
"args",
")",
":",
"num",
"=",
"10",
"top_k",
"=",
"10",
"collections",
"=",
"[",
"]",
"idx",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"num",
")",
":",
"collection",
"=",
"gen_unique_st... | [
945,
4
] | [
983,
62
] | python | en | ['en', 'error', 'th'] | False |
TestSearchParamsInvalid.init_data | (self, connect, collection, nb=6000) |
Generate vectors and add it in collection, before search vectors
|
Generate vectors and add it in collection, before search vectors
| def init_data(self, connect, collection, nb=6000):
'''
Generate vectors and add it in collection, before search vectors
'''
global vectors
if nb == 6000:
insert = vectors
else:
insert = gen_vectors(nb, dim)
status, ids = connect.insert(co... | [
"def",
"init_data",
"(",
"self",
",",
"connect",
",",
"collection",
",",
"nb",
"=",
"6000",
")",
":",
"global",
"vectors",
"if",
"nb",
"==",
"6000",
":",
"insert",
"=",
"vectors",
"else",
":",
"insert",
"=",
"gen_vectors",
"(",
"nb",
",",
"dim",
")",... | [
997,
4
] | [
1008,
26
] | python | en | ['en', 'error', 'th'] | False |
TestSearchParamsInvalid.test_search_with_invalid_top_k | (self, connect, collection, get_top_k) |
target: test search fuction, with the wrong top_k
method: search with top_k
expected: raise an error, and the connection is normal
|
target: test search fuction, with the wrong top_k
method: search with top_k
expected: raise an error, and the connection is normal
| def test_search_with_invalid_top_k(self, connect, collection, get_top_k):
'''
target: test search fuction, with the wrong top_k
method: search with top_k
expected: raise an error, and the connection is normal
'''
top_k = get_top_k
logging.getLogger().info(top_k)
... | [
"def",
"test_search_with_invalid_top_k",
"(",
"self",
",",
"connect",
",",
"collection",
",",
"get_top_k",
")",
":",
"top_k",
"=",
"get_top_k",
"logging",
".",
"getLogger",
"(",
")",
".",
"info",
"(",
"top_k",
")",
"nprobe",
"=",
"1",
"query_vecs",
"=",
"g... | [
1056,
4
] | [
1071,
78
] | python | en | ['en', 'error', 'th'] | False |
TestSearchParamsInvalid.test_search_with_invalid_top_k_ip | (self, connect, ip_collection, get_top_k) |
target: test search fuction, with the wrong top_k
method: search with top_k
expected: raise an error, and the connection is normal
|
target: test search fuction, with the wrong top_k
method: search with top_k
expected: raise an error, and the connection is normal
| def test_search_with_invalid_top_k_ip(self, connect, ip_collection, get_top_k):
'''
target: test search fuction, with the wrong top_k
method: search with top_k
expected: raise an error, and the connection is normal
'''
top_k = get_top_k
logging.getLogger().info(to... | [
"def",
"test_search_with_invalid_top_k_ip",
"(",
"self",
",",
"connect",
",",
"ip_collection",
",",
"get_top_k",
")",
":",
"top_k",
"=",
"get_top_k",
"logging",
".",
"getLogger",
"(",
")",
".",
"info",
"(",
"top_k",
")",
"nprobe",
"=",
"1",
"query_vecs",
"="... | [
1074,
4
] | [
1089,
81
] | python | en | ['en', 'error', 'th'] | False |
TestSearchParamsInvalid.test_search_with_invalid_nprobe | (self, connect, collection, get_nprobes) |
target: test search fuction, with the wrong nprobe
method: search with nprobe
expected: raise an error, and the connection is normal
|
target: test search fuction, with the wrong nprobe
method: search with nprobe
expected: raise an error, and the connection is normal
| def test_search_with_invalid_nprobe(self, connect, collection, get_nprobes):
'''
target: test search fuction, with the wrong nprobe
method: search with nprobe
expected: raise an error, and the connection is normal
'''
index_type = IndexType.IVF_SQ8
index_param = {... | [
"def",
"test_search_with_invalid_nprobe",
"(",
"self",
",",
"connect",
",",
"collection",
",",
"get_nprobes",
")",
":",
"index_type",
"=",
"IndexType",
".",
"IVF_SQ8",
"index_param",
"=",
"{",
"\"nlist\"",
":",
"16384",
"}",
"connect",
".",
"create_index",
"(",
... | [
1101,
4
] | [
1116,
30
] | python | en | ['en', 'error', 'th'] | False |
TestSearchParamsInvalid.test_search_with_invalid_nprobe_ip | (self, connect, ip_collection, get_nprobes) |
target: test search fuction, with the wrong top_k
method: search with top_k
expected: raise an error, and the connection is normal
|
target: test search fuction, with the wrong top_k
method: search with top_k
expected: raise an error, and the connection is normal
| def test_search_with_invalid_nprobe_ip(self, connect, ip_collection, get_nprobes):
'''
target: test search fuction, with the wrong top_k
method: search with top_k
expected: raise an error, and the connection is normal
'''
index_type = IndexType.IVF_SQ8
index_param... | [
"def",
"test_search_with_invalid_nprobe_ip",
"(",
"self",
",",
"connect",
",",
"ip_collection",
",",
"get_nprobes",
")",
":",
"index_type",
"=",
"IndexType",
".",
"IVF_SQ8",
"index_param",
"=",
"{",
"\"nlist\"",
":",
"16384",
"}",
"connect",
".",
"create_index",
... | [
1122,
4
] | [
1138,
30
] | python | en | ['en', 'error', 'th'] | False |
TestSearchParamsInvalid.test_search_with_empty_params | (self, connect, collection, args, get_simple_index) |
target: test search fuction, with empty search params
method: search with params
expected: search status not ok, and the connection is normal
|
target: test search fuction, with empty search params
method: search with params
expected: search status not ok, and the connection is normal
| def test_search_with_empty_params(self, connect, collection, args, get_simple_index):
'''
target: test search fuction, with empty search params
method: search with params
expected: search status not ok, and the connection is normal
'''
if args["handler"] == "HTTP":
... | [
"def",
"test_search_with_empty_params",
"(",
"self",
",",
"connect",
",",
"collection",
",",
"args",
",",
"get_simple_index",
")",
":",
"if",
"args",
"[",
"\"handler\"",
"]",
"==",
"\"HTTP\"",
":",
"pytest",
".",
"skip",
"(",
"\"skip in http mode\"",
")",
"ind... | [
1156,
4
] | [
1173,
34
] | python | en | ['en', 'error', 'th'] | False |
TestSearchParamsInvalid.test_search_with_invalid_params | (self, connect, collection, get_invalid_search_param) |
target: test search fuction, with invalid search params
method: search with params
expected: search status not ok, and the connection is normal
|
target: test search fuction, with invalid search params
method: search with params
expected: search status not ok, and the connection is normal
| def test_search_with_invalid_params(self, connect, collection, get_invalid_search_param):
'''
target: test search fuction, with invalid search params
method: search with params
expected: search status not ok, and the connection is normal
'''
index_type = get_invalid_searc... | [
"def",
"test_search_with_invalid_params",
"(",
"self",
",",
"connect",
",",
"collection",
",",
"get_invalid_search_param",
")",
":",
"index_type",
"=",
"get_invalid_search_param",
"[",
"\"index_type\"",
"]",
"search_param",
"=",
"get_invalid_search_param",
"[",
"\"search_... | [
1188,
4
] | [
1201,
30
] | python | en | ['en', 'error', 'th'] | False |
privilege_granted_directly_or_via_role | (self, node=None) | Check that user is only able to execute CREATE DICTIONARY when they have required privilege, either directly or via role.
| Check that user is only able to execute CREATE DICTIONARY when they have required privilege, either directly or via role.
| def privilege_granted_directly_or_via_role(self, node=None):
"""Check that user is only able to execute CREATE DICTIONARY when they have required privilege, either directly or via role.
"""
role_name = f"role_{getuid()}"
user_name = f"user_{getuid()}"
if node is None:
node = self.context.no... | [
"def",
"privilege_granted_directly_or_via_role",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"role_name",
"=",
"f\"role_{getuid()}\"",
"user_name",
"=",
"f\"user_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node... | [
5,
0
] | [
27,
92
] | python | en | ['en', 'en', 'en'] | True |
privilege_check | (grant_target_name, user_name, node=None) | Run scenarios to check the user's access with different privileges.
| Run scenarios to check the user's access with different privileges.
| def privilege_check(grant_target_name, user_name, node=None):
"""Run scenarios to check the user's access with different privileges.
"""
exitcode, message = errors.not_enough_privileges(name=f"{user_name}")
with Scenario("user without privilege"):
dict_name = f"dict_{getuid()}"
try:
... | [
"def",
"privilege_check",
"(",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"f\"{user_name}\"",
")",
"with",
"Scenario",
"(",
"\"user without... | [
29,
0
] | [
115,
68
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1", stress=None, parallel=None) | Check the RBAC functionality of CREATE DICTIONARY.
| Check the RBAC functionality of CREATE DICTIONARY.
| def feature(self, node="clickhouse1", stress=None, parallel=None):
"""Check the RBAC functionality of CREATE DICTIONARY.
"""
self.context.node = self.context.cluster.node(node)
if parallel is not None:
self.context.parallel = parallel
if stress is not None:
self.context.stress = str... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
",",
"stress",
"=",
"None",
",",
"parallel",
"=",
"None",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
... | [
124,
0
] | [
135,
48
] | python | en | ['en', 'en', 'en'] | True |
UserTestCase.test_reset_password | (self) | this will test if user can reset password | this will test if user can reset password | def test_reset_password(self):
"""this will test if user can reset password"""
msg = self.user.register("emmanuel@abc.com", "djgjdbk432", "sgdsghds95", "role=admin")
self.assertEqual(msg, {"message":"Password do not match"}) | [
"def",
"test_reset_password",
"(",
"self",
")",
":",
"msg",
"=",
"self",
".",
"user",
".",
"register",
"(",
"\"emmanuel@abc.com\"",
",",
"\"djgjdbk432\"",
",",
"\"sgdsghds95\"",
",",
"\"role=admin\"",
")",
"self",
".",
"assertEqual",
"(",
"msg",
",",
"{",
"\... | [
53,
4
] | [
57,
66
] | python | en | ['en', 'en', 'en'] | True |
UserTestCase.test_api_can_validate_email | (self) | this will test if user cannot register with an invalid email address | this will test if user cannot register with an invalid email address | def test_api_can_validate_email(self):
"""this will test if user cannot register with an invalid email address"""
msg = self.user.register("emmanuel@abc.sfd@&com", "djgjdbk432", "sgdsghds95", "role=admin")
self.assertEqual(msg, {"message":"Please a provide a valid email"}) | [
"def",
"test_api_can_validate_email",
"(",
"self",
")",
":",
"msg",
"=",
"self",
".",
"user",
".",
"register",
"(",
"\"emmanuel@abc.sfd@&com\"",
",",
"\"djgjdbk432\"",
",",
"\"sgdsghds95\"",
",",
"\"role=admin\"",
")",
"self",
".",
"assertEqual",
"(",
"msg",
","... | [
59,
4
] | [
62,
75
] | python | en | ['en', 'en', 'en'] | True |
UserTestCase.test_api_validate_email_address | (self) | this will test if user with empty username will register | this will test if user with empty username will register | def test_api_validate_email_address(self):
"""this will test if user with empty username will register"""
msg = self.user.register("", "djgjdbk432", "sgdsghds95", "role=admin")
self.assertEqual(msg, {"message":"Please a provide a valid email"}) | [
"def",
"test_api_validate_email_address",
"(",
"self",
")",
":",
"msg",
"=",
"self",
".",
"user",
".",
"register",
"(",
"\"\"",
",",
"\"djgjdbk432\"",
",",
"\"sgdsghds95\"",
",",
"\"role=admin\"",
")",
"self",
".",
"assertEqual",
"(",
"msg",
",",
"{",
"\"mes... | [
64,
4
] | [
67,
75
] | python | en | ['en', 'en', 'en'] | True |
UserTestCase.test_user_is_able_to_register | (self) | Test that user is able to register
ensure that a valid post request to /api/v1/auth/register
registers a user
| Test that user is able to register
ensure that a valid post request to /api/v1/auth/register
registers a user
| def test_user_is_able_to_register(self):
"""Test that user is able to register
ensure that a valid post request to /api/v1/auth/register
registers a user
"""
new_user = {
"email": "abc@abc.com30",
"password": "123456789030",
"confirm_password"... | [
"def",
"test_user_is_able_to_register",
"(",
"self",
")",
":",
"new_user",
"=",
"{",
"\"email\"",
":",
"\"abc@abc.com30\"",
",",
"\"password\"",
":",
"\"123456789030\"",
",",
"\"confirm_password\"",
":",
"\"123456307890\"",
",",
"\"role\"",
":",
"\"admin\"",
"}",
"r... | [
69,
4
] | [
81,
52
] | python | en | ['en', 'en', 'en'] | True |
UserTestCase.test_login | (self) | Tests that user is able to login | Tests that user is able to login | def test_login(self):
"""Tests that user is able to login"""
new_user = {"email": "abc@abc.com", "password": "1234567890"}
response = self.client.post('/api/v1/auth/login', data=json.dumps(new_user), content_type='application/json')
self.assertEquals(response.status_code, 200) | [
"def",
"test_login",
"(",
"self",
")",
":",
"new_user",
"=",
"{",
"\"email\"",
":",
"\"abc@abc.com\"",
",",
"\"password\"",
":",
"\"1234567890\"",
"}",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"'/api/v1/auth/login'",
",",
"data",
"=",
"json"... | [
83,
4
] | [
88,
52
] | python | en | ['en', 'en', 'en'] | True |
UserTestCase.test_len_password_register | (self) | Test if password length is more than 8 characters | Test if password length is more than 8 characters | def test_len_password_register(self):
"""Test if password length is more than 8 characters"""
new_user = {
"email": "abc@abc.com",
"password": "",
"confirm_password": "1234567890",
"role": "admin"
}
response = self.client.post('/api/v1... | [
"def",
"test_len_password_register",
"(",
"self",
")",
":",
"new_user",
"=",
"{",
"\"email\"",
":",
"\"abc@abc.com\"",
",",
"\"password\"",
":",
"\"\"",
",",
"\"confirm_password\"",
":",
"\"1234567890\"",
",",
"\"role\"",
":",
"\"admin\"",
"}",
"response",
"=",
... | [
90,
4
] | [
101,
67
] | python | en | ['en', 'en', 'en'] | True |
UserTestCase.test_password_match_register | (self) | Tests if password and confirmation password match | Tests if password and confirmation password match | def test_password_match_register(self):
"""Tests if password and confirmation password match"""
new_user = {
"email": "abc@abc.com",
"password": "1234567890",
"confirm_password": "10",
"role": "admin"
}
response = self.client.post('/ap... | [
"def",
"test_password_match_register",
"(",
"self",
")",
":",
"new_user",
"=",
"{",
"\"email\"",
":",
"\"abc@abc.com\"",
",",
"\"password\"",
":",
"\"1234567890\"",
",",
"\"confirm_password\"",
":",
"\"10\"",
",",
"\"role\"",
":",
"\"admin\"",
"}",
"response",
"="... | [
103,
4
] | [
113,
67
] | python | en | ['en', 'en', 'en'] | True |
UserTestCase.test_role_register | (self) | Tests if user has defined a role | Tests if user has defined a role | def test_role_register(self):
"""Tests if user has defined a role"""
new_user = {
"email": "abc@abc.com",
"password": "1234567890",
"confirm_password": "1234567890",
"role": ""
}
response = self.client.post('/api/v1/auth/register', data... | [
"def",
"test_role_register",
"(",
"self",
")",
":",
"new_user",
"=",
"{",
"\"email\"",
":",
"\"abc@abc.com\"",
",",
"\"password\"",
":",
"\"1234567890\"",
",",
"\"confirm_password\"",
":",
"\"1234567890\"",
",",
"\"role\"",
":",
"\"\"",
"}",
"response",
"=",
"se... | [
115,
4
] | [
124,
75
] | python | en | ['en', 'en', 'en'] | True |
UserTestCase.tearDown | (self) | Teardown Users Class test case | Teardown Users Class test case | def tearDown(self):
""" Teardown Users Class test case """
del self.user | [
"def",
"tearDown",
"(",
"self",
")",
":",
"del",
"self",
".",
"user"
] | [
126,
4
] | [
128,
21
] | python | en | ['en', 'fy', 'en'] | True |
assign_query | (dbFuncs,
ref_db,
q_files,
output,
qc_dict,
update_db,
write_references,
distances,
threads,
overwrite,
plot_fit,
graph_weights,
... | Code for assign query mode. Written as a separate function so it can be called
by web APIs | Code for assign query mode. Written as a separate function so it can be called
by web APIs | def assign_query(dbFuncs,
ref_db,
q_files,
output,
qc_dict,
update_db,
write_references,
distances,
threads,
overwrite,
plot_fit,
gra... | [
"def",
"assign_query",
"(",
"dbFuncs",
",",
"ref_db",
",",
"q_files",
",",
"output",
",",
"qc_dict",
",",
"update_db",
",",
"write_references",
",",
"distances",
",",
"threads",
",",
"overwrite",
",",
"plot_fit",
",",
"graph_weights",
",",
"max_a_dist",
",",
... | [
26,
0
] | [
404,
29
] | python | en | ['en', 'en', 'en'] | True |
main | () | Main function. Parses cmd line args and runs in the specified mode.
| Main function. Parses cmd line args and runs in the specified mode.
| def main():
"""Main function. Parses cmd line args and runs in the specified mode.
"""
#******************************#
#* *#
#* Check command options *#
#* *#
#******************************#
args = get_options()
# May jus... | [
"def",
"main",
"(",
")",
":",
"#******************************#",
"#* *#",
"#* Check command options *#",
"#* *#",
"#******************************#",
"args",
"=",
"get_options",
"(",
")",
"# May just want to print the citation... | [
511,
0
] | [
616,
32
] | python | en | ['en', 'en', 'en'] | True |
generate_tsne | (seqLabels, accMat, perplexity, outPrefix, overwrite, verbosity = 0, use_gpu = False) | Generate t-SNE projection using accessory distances
Writes a plot of t-SNE clustering of accessory distances (.dot)
Args:
seqLabels (list)
Processed names of sequences being analysed.
accMat (numpy.array)
n x n array of accessory distances for n samples.
perplex... | Generate t-SNE projection using accessory distances | def generate_tsne(seqLabels, accMat, perplexity, outPrefix, overwrite, verbosity = 0, use_gpu = False):
"""Generate t-SNE projection using accessory distances
Writes a plot of t-SNE clustering of accessory distances (.dot)
Args:
seqLabels (list)
Processed names of sequences being analy... | [
"def",
"generate_tsne",
"(",
"seqLabels",
",",
"accMat",
",",
"perplexity",
",",
"outPrefix",
",",
"overwrite",
",",
"verbosity",
"=",
"0",
",",
"use_gpu",
"=",
"False",
")",
":",
"# generate accessory genome distance representation",
"tsne_filename",
"=",
"outPrefi... | [
25,
0
] | [
67,
87
] | python | en | ['en', 'en', 'en'] | True |
DukeEnergyGatewayUsageDataUpdateCoordinator.__init__ | (
self,
hass: HomeAssistant,
client: DukeEnergyClient,
realtime: DukeEnergyRealtime,
realtime_interval: timedelta,
) | Initialize. | Initialize. | def __init__(
self,
hass: HomeAssistant,
client: DukeEnergyClient,
realtime: DukeEnergyRealtime,
realtime_interval: timedelta,
) -> None:
"""Initialize."""
self.client = client
self.realtime = realtime
self.realtime_interval = realtime_interval... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"client",
":",
"DukeEnergyClient",
",",
"realtime",
":",
"DukeEnergyRealtime",
",",
"realtime_interval",
":",
"timedelta",
",",
")",
"->",
"None",
":",
"self",
".",
"client",
"=",
"clien... | [
30,
4
] | [
48,
83
] | python | en | ['en', 'en', 'it'] | False |
DukeEnergyGatewayUsageDataUpdateCoordinator._async_update_data | (self) | Update data via library to get last day of minute-by-minute usage data. | Update data via library to get last day of minute-by-minute usage data. | async def _async_update_data(self):
"""Update data via library to get last day of minute-by-minute usage data."""
try:
today_start = dt.start_of_local_day()
today_end = today_start + timedelta(days=1)
return await self.client.get_gateway_usage(today_start, today_end)
... | [
"async",
"def",
"_async_update_data",
"(",
"self",
")",
":",
"try",
":",
"today_start",
"=",
"dt",
".",
"start_of_local_day",
"(",
")",
"today_end",
"=",
"today_start",
"+",
"timedelta",
"(",
"days",
"=",
"1",
")",
"return",
"await",
"self",
".",
"client",... | [
50,
4
] | [
59,
28
] | python | en | ['en', 'en', 'en'] | True |
DukeEnergyGatewayUsageDataUpdateCoordinator.realtime_initialize | (self) | Setup callbacks, connect, and subscribe to the real-time usage MQTT stream. | Setup callbacks, connect, and subscribe to the real-time usage MQTT stream. | def realtime_initialize(self):
"""Setup callbacks, connect, and subscribe to the real-time usage MQTT stream."""
try:
self.realtime.on_message = self._realtime_on_message
self.realtime_task = asyncio.create_task(
self.realtime.connect_and_subscribe_forever()
... | [
"def",
"realtime_initialize",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"realtime",
".",
"on_message",
"=",
"self",
".",
"_realtime_on_message",
"self",
".",
"realtime_task",
"=",
"asyncio",
".",
"create_task",
"(",
"self",
".",
"realtime",
".",
"conne... | [
61,
4
] | [
74,
17
] | python | en | ['en', 'en', 'en'] | True |
DukeEnergyGatewayUsageDataUpdateCoordinator.realtime_cancel | (self) | Cancel the real-time usage MQTT stream, which will unsubscribe. | Cancel the real-time usage MQTT stream, which will unsubscribe. | def realtime_cancel(self):
"""Cancel the real-time usage MQTT stream, which will unsubscribe."""
if self.realtime_task:
self.realtime_task.cancel()
self.realtime_task = None
_LOGGER.debug("Cancelled real-time async task") | [
"def",
"realtime_cancel",
"(",
"self",
")",
":",
"if",
"self",
".",
"realtime_task",
":",
"self",
".",
"realtime_task",
".",
"cancel",
"(",
")",
"self",
".",
"realtime_task",
"=",
"None",
"_LOGGER",
".",
"debug",
"(",
"\"Cancelled real-time async task\"",
")"
... | [
76,
4
] | [
81,
59
] | python | en | ['en', 'en', 'en'] | True |
DukeEnergyGatewayUsageDataUpdateCoordinator._realtime_on_message | (self, msg) | Handler for the real-time usage MQTT messages. | Handler for the real-time usage MQTT messages. | def _realtime_on_message(self, msg):
"""Handler for the real-time usage MQTT messages."""
try:
measurement = self.realtime.msg_to_usage_measurement(msg)
except (ValueError, TypeError) as exception:
_LOGGER.error(
"Error while parsing real-time usage messag... | [
"def",
"_realtime_on_message",
"(",
"self",
",",
"msg",
")",
":",
"try",
":",
"measurement",
"=",
"self",
".",
"realtime",
".",
"msg_to_usage_measurement",
"(",
"msg",
")",
"except",
"(",
"ValueError",
",",
"TypeError",
")",
"as",
"exception",
":",
"_LOGGER"... | [
83,
4
] | [
108,
17
] | python | en | ['en', 'en', 'en'] | True |
DukeEnergyGatewayUsageDataUpdateCoordinator.async_realtime_subscribe_to_dispatcher | (
self, source: str, target: Callable[[RealtimeUsageMeasurement], Any]
) | Setup a subscriber to receive new real-time measurements. | Setup a subscriber to receive new real-time measurements. | def async_realtime_subscribe_to_dispatcher(
self, source: str, target: Callable[[RealtimeUsageMeasurement], Any]
):
"""Setup a subscriber to receive new real-time measurements."""
# If this source is already subscribed, re-use the existing one
if source in self.async_realtime_remove_... | [
"def",
"async_realtime_subscribe_to_dispatcher",
"(",
"self",
",",
"source",
":",
"str",
",",
"target",
":",
"Callable",
"[",
"[",
"RealtimeUsageMeasurement",
"]",
",",
"Any",
"]",
")",
":",
"# If this source is already subscribed, re-use the existing one",
"if",
"sourc... | [
110,
4
] | [
126,
71
] | python | en | ['en', 'en', 'en'] | True |
DukeEnergyGatewayUsageDataUpdateCoordinator.async_realtime_unsubscribe_from_dispatcher | (self, source: str) | Remove a subscriber from the dispatch. | Remove a subscriber from the dispatch. | def async_realtime_unsubscribe_from_dispatcher(self, source: str):
"""Remove a subscriber from the dispatch."""
if source in self.async_realtime_remove_subscriber_funcs_by_source:
_LOGGER.debug("Removing subscribers to dispatcher for %s", source)
self.async_realtime_remove_subscr... | [
"def",
"async_realtime_unsubscribe_from_dispatcher",
"(",
"self",
",",
"source",
":",
"str",
")",
":",
"if",
"source",
"in",
"self",
".",
"async_realtime_remove_subscriber_funcs_by_source",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Removing subscribers to dispatcher for %s\"",
... | [
128,
4
] | [
133,
77
] | python | en | ['en', 'en', 'en'] | True |
DukeEnergyGatewayUsageDataUpdateCoordinator.async_realtime_unsubscribe_all_from_dispatcher | (self) | Remove all subscribers from the dispatch. | Remove all subscribers from the dispatch. | def async_realtime_unsubscribe_all_from_dispatcher(self):
"""Remove all subscribers from the dispatch."""
sources = self.async_realtime_remove_subscriber_funcs_by_source.keys()
for source in sources:
self.async_realtime_unsubscribe_from_dispatcher(source) | [
"def",
"async_realtime_unsubscribe_all_from_dispatcher",
"(",
"self",
")",
":",
"sources",
"=",
"self",
".",
"async_realtime_remove_subscriber_funcs_by_source",
".",
"keys",
"(",
")",
"for",
"source",
"in",
"sources",
":",
"self",
".",
"async_realtime_unsubscribe_from_dis... | [
135,
4
] | [
139,
67
] | python | en | ['en', 'en', 'en'] | True |
TestApply.test_apply_operation_single_wire_no_parameters | (
self, qubit_device_1_wire, tol, operation, input, expected_output
) | Tests that applying an operation yields the expected output state for single wire
operations that have no parameters. | Tests that applying an operation yields the expected output state for single wire
operations that have no parameters. | def test_apply_operation_single_wire_no_parameters(
self, qubit_device_1_wire, tol, operation, input, expected_output
):
"""Tests that applying an operation yields the expected output state for single wire
operations that have no parameters."""
qubit_device_1_wire._state = np.array(... | [
"def",
"test_apply_operation_single_wire_no_parameters",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
",",
"operation",
",",
"input",
",",
"expected_output",
")",
":",
"qubit_device_1_wire",
".",
"_state",
"=",
"np",
".",
"array",
"(",
"input",
")",
".",
... | [
113,
4
] | [
122,
99
] | python | en | ['en', 'en', 'en'] | True |
TestApply.test_apply_operation_two_wires_no_parameters | (
self, qubit_device_2_wires, tol, operation, input, expected_output
) | Tests that applying an operation yields the expected output state for two wire
operations that have no parameters. | Tests that applying an operation yields the expected output state for two wire
operations that have no parameters. | def test_apply_operation_two_wires_no_parameters(
self, qubit_device_2_wires, tol, operation, input, expected_output
):
"""Tests that applying an operation yields the expected output state for two wire
operations that have no parameters."""
qubit_device_2_wires._state = np.array(inpu... | [
"def",
"test_apply_operation_two_wires_no_parameters",
"(",
"self",
",",
"qubit_device_2_wires",
",",
"tol",
",",
"operation",
",",
"input",
",",
"expected_output",
")",
":",
"qubit_device_2_wires",
".",
"_state",
"=",
"np",
".",
"array",
"(",
"input",
")",
".",
... | [
149,
4
] | [
157,
99
] | python | en | ['en', 'en', 'en'] | True |
TestApply.test_apply_operation_three_wires_no_parameters | (
self, qubit_device_3_wires, tol, operation, input, expected_output
) | Tests that applying an operation yields the expected output state for three wire
operations that have no parameters. | Tests that applying an operation yields the expected output state for three wire
operations that have no parameters. | def test_apply_operation_three_wires_no_parameters(
self, qubit_device_3_wires, tol, operation, input, expected_output
):
"""Tests that applying an operation yields the expected output state for three wire
operations that have no parameters."""
qubit_device_3_wires._state = np.array... | [
"def",
"test_apply_operation_three_wires_no_parameters",
"(",
"self",
",",
"qubit_device_3_wires",
",",
"tol",
",",
"operation",
",",
"input",
",",
"expected_output",
")",
":",
"qubit_device_3_wires",
".",
"_state",
"=",
"np",
".",
"array",
"(",
"input",
")",
".",... | [
170,
4
] | [
179,
99
] | python | en | ['en', 'en', 'en'] | True |
TestApply.test_apply_operation_state_preparation | (
self, qubit_device_2_wires, tol, operation, expected_output, par
) | Tests that applying an operation yields the expected output state for single wire
operations that have no parameters. | Tests that applying an operation yields the expected output state for single wire
operations that have no parameters. | def test_apply_operation_state_preparation(
self, qubit_device_2_wires, tol, operation, expected_output, par
):
"""Tests that applying an operation yields the expected output state for single wire
operations that have no parameters."""
par = np.array(par)
qubit_device_2_wire... | [
"def",
"test_apply_operation_state_preparation",
"(",
"self",
",",
"qubit_device_2_wires",
",",
"tol",
",",
"operation",
",",
"expected_output",
",",
"par",
")",
":",
"par",
"=",
"np",
".",
"array",
"(",
"par",
")",
"qubit_device_2_wires",
".",
"reset",
"(",
"... | [
202,
4
] | [
212,
99
] | python | en | ['en', 'en', 'en'] | True |
TestApply.test_apply_operation_single_wire_with_parameters | (
self, qubit_device_1_wire, tol, operation, input, expected_output, par
) | Tests that applying an operation yields the expected output state for single wire
operations that have parameters. | Tests that applying an operation yields the expected output state for single wire
operations that have parameters. | def test_apply_operation_single_wire_with_parameters(
self, qubit_device_1_wire, tol, operation, input, expected_output, par
):
"""Tests that applying an operation yields the expected output state for single wire
operations that have parameters."""
qubit_device_1_wire._state = np.ar... | [
"def",
"test_apply_operation_single_wire_with_parameters",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
",",
"operation",
",",
"input",
",",
"expected_output",
",",
"par",
")",
":",
"qubit_device_1_wire",
".",
"_state",
"=",
"np",
".",
"array",
"(",
"input... | [
267,
4
] | [
277,
98
] | python | en | ['en', 'en', 'en'] | True |
TestApply.test_apply_operation_two_wires_with_parameters | (
self, qubit_device_2_wires, tol, operation, input, expected_output, par
) | Tests that applying an operation yields the expected output state for two wire
operations that have parameters. | Tests that applying an operation yields the expected output state for two wire
operations that have parameters. | def test_apply_operation_two_wires_with_parameters(
self, qubit_device_2_wires, tol, operation, input, expected_output, par
):
"""Tests that applying an operation yields the expected output state for two wire
operations that have parameters."""
qubit_device_2_wires._state = np.array... | [
"def",
"test_apply_operation_two_wires_with_parameters",
"(",
"self",
",",
"qubit_device_2_wires",
",",
"tol",
",",
"operation",
",",
"input",
",",
"expected_output",
",",
"par",
")",
":",
"qubit_device_2_wires",
".",
"_state",
"=",
"np",
".",
"array",
"(",
"input... | [
334,
4
] | [
343,
99
] | python | en | ['en', 'en', 'en'] | True |
TestApply.test_apply_errors_qubit_state_vector | (self, qubit_device_2_wires) | Test that apply fails for incorrect state preparation, and > 2 qubit gates | Test that apply fails for incorrect state preparation, and > 2 qubit gates | def test_apply_errors_qubit_state_vector(self, qubit_device_2_wires):
"""Test that apply fails for incorrect state preparation, and > 2 qubit gates"""
with pytest.raises(ValueError, match="Sum of amplitudes-squared does not equal one."):
qubit_device_2_wires.apply([qml.QubitStateVector(np.ar... | [
"def",
"test_apply_errors_qubit_state_vector",
"(",
"self",
",",
"qubit_device_2_wires",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
",",
"match",
"=",
"\"Sum of amplitudes-squared does not equal one.\"",
")",
":",
"qubit_device_2_wires",
".",
"apply",
... | [
345,
4
] | [
361,
13
] | python | en | ['en', 'en', 'en'] | True |
TestExpval.test_expval_single_wire_no_parameters | (
self, qubit_device_1_wire, tol, operation, input, expected_output
) | Tests that expectation values are properly calculated for single-wire observables without parameters. | Tests that expectation values are properly calculated for single-wire observables without parameters. | def test_expval_single_wire_no_parameters(
self, qubit_device_1_wire, tol, operation, input, expected_output
):
"""Tests that expectation values are properly calculated for single-wire observables without parameters."""
obs = operation(wires=[0])
qubit_device_1_wire.reset()
... | [
"def",
"test_expval_single_wire_no_parameters",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
",",
"operation",
",",
"input",
",",
"expected_output",
")",
":",
"obs",
"=",
"operation",
"(",
"wires",
"=",
"[",
"0",
"]",
")",
"qubit_device_1_wire",
".",
"... | [
407,
4
] | [
420,
65
] | python | en | ['en', 'en', 'en'] | True |
TestExpval.test_expval_estimate | (self) | Test that the expectation value is not analytically calculated | Test that the expectation value is not analytically calculated | def test_expval_estimate(self):
"""Test that the expectation value is not analytically calculated"""
dev = qml.device("lightning.qubit", wires=1, shots=3)
@qml.qnode(dev)
def circuit():
return qml.expval(qml.PauliX(0))
expval = circuit()
# With 3 samples we... | [
"def",
"test_expval_estimate",
"(",
"self",
")",
":",
"dev",
"=",
"qml",
".",
"device",
"(",
"\"lightning.qubit\"",
",",
"wires",
"=",
"1",
",",
"shots",
"=",
"3",
")",
"@",
"qml",
".",
"qnode",
"(",
"dev",
")",
"def",
"circuit",
"(",
")",
":",
"re... | [
422,
4
] | [
434,
28
] | python | en | ['en', 'en', 'en'] | True |
TestVar.test_var_single_wire_no_parameters | (
self, qubit_device_1_wire, tol, operation, input, expected_output
) | Tests that variances are properly calculated for single-wire observables without parameters. | Tests that variances are properly calculated for single-wire observables without parameters. | def test_var_single_wire_no_parameters(
self, qubit_device_1_wire, tol, operation, input, expected_output
):
"""Tests that variances are properly calculated for single-wire observables without parameters."""
obs = operation(wires=[0])
qubit_device_1_wire.reset()
qubit_devic... | [
"def",
"test_var_single_wire_no_parameters",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
",",
"operation",
",",
"input",
",",
"expected_output",
")",
":",
"obs",
"=",
"operation",
"(",
"wires",
"=",
"[",
"0",
"]",
")",
"qubit_device_1_wire",
".",
"res... | [
460,
4
] | [
473,
65
] | python | en | ['en', 'en', 'en'] | True |
TestVar.test_var_estimate | (self) | Test that the variance is not analytically calculated | Test that the variance is not analytically calculated | def test_var_estimate(self):
"""Test that the variance is not analytically calculated"""
dev = qml.device("lightning.qubit", wires=1, shots=3)
@qml.qnode(dev)
def circuit():
return qml.var(qml.PauliX(0))
var = circuit()
# With 3 samples we are guaranteed t... | [
"def",
"test_var_estimate",
"(",
"self",
")",
":",
"dev",
"=",
"qml",
".",
"device",
"(",
"\"lightning.qubit\"",
",",
"wires",
"=",
"1",
",",
"shots",
"=",
"3",
")",
"@",
"qml",
".",
"qnode",
"(",
"dev",
")",
"def",
"circuit",
"(",
")",
":",
"retur... | [
475,
4
] | [
488,
25
] | python | en | ['en', 'en', 'en'] | True |
TestSample.test_sample_dimensions | (self, qubit_device_2_wires) | Tests if the samples returned by the sample function have
the correct dimensions
| Tests if the samples returned by the sample function have
the correct dimensions
| def test_sample_dimensions(self, qubit_device_2_wires):
"""Tests if the samples returned by the sample function have
the correct dimensions
"""
# Explicitly resetting is necessary as the internal
# state is set to None in __init__ and only properly
# initialized during r... | [
"def",
"test_sample_dimensions",
"(",
"self",
",",
"qubit_device_2_wires",
")",
":",
"# Explicitly resetting is necessary as the internal",
"# state is set to None in __init__ and only properly",
"# initialized during reset",
"qubit_device_2_wires",
".",
"reset",
"(",
")",
"qubit_dev... | [
494,
4
] | [
524,
46
] | python | en | ['en', 'en', 'en'] | True |
TestSample.test_sample_values | (self, qubit_device_2_wires, tol) | Tests if the samples returned by sample have
the correct values
| Tests if the samples returned by sample have
the correct values
| def test_sample_values(self, qubit_device_2_wires, tol):
"""Tests if the samples returned by sample have
the correct values
"""
# Explicitly resetting is necessary as the internal
# state is set to None in __init__ and only properly
# initialized during reset
qub... | [
"def",
"test_sample_values",
"(",
"self",
",",
"qubit_device_2_wires",
",",
"tol",
")",
":",
"# Explicitly resetting is necessary as the internal",
"# state is set to None in __init__ and only properly",
"# initialized during reset",
"qubit_device_2_wires",
".",
"reset",
"(",
")",
... | [
526,
4
] | [
544,
56
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_load_default_qubit_device | (self) | Test that the default plugin loads correctly | Test that the default plugin loads correctly | def test_load_default_qubit_device(self):
"""Test that the default plugin loads correctly"""
dev = qml.device("lightning.qubit", wires=2)
assert dev.num_wires == 2
assert dev.shots is None
assert dev.short_name == "lightning.qubit" | [
"def",
"test_load_default_qubit_device",
"(",
"self",
")",
":",
"dev",
"=",
"qml",
".",
"device",
"(",
"\"lightning.qubit\"",
",",
"wires",
"=",
"2",
")",
"assert",
"dev",
".",
"num_wires",
"==",
"2",
"assert",
"dev",
".",
"shots",
"is",
"None",
"assert",
... | [
551,
4
] | [
557,
50
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_no_backprop | (self) | Test that lightning.qubit does not support the backprop
differentiation method. | Test that lightning.qubit does not support the backprop
differentiation method. | def test_no_backprop(self):
"""Test that lightning.qubit does not support the backprop
differentiation method."""
dev = qml.device("lightning.qubit", wires=2)
def circuit():
"""Simple quantum function."""
return qml.expval(qml.PauliZ(0))
with pytest.rais... | [
"def",
"test_no_backprop",
"(",
"self",
")",
":",
"dev",
"=",
"qml",
".",
"device",
"(",
"\"lightning.qubit\"",
",",
"wires",
"=",
"2",
")",
"def",
"circuit",
"(",
")",
":",
"\"\"\"Simple quantum function.\"\"\"",
"return",
"qml",
".",
"expval",
"(",
"qml",
... | [
559,
4
] | [
569,
59
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_best_gets_lightning | (self) | Test that the best differentiation method returns lightning
qubit. | Test that the best differentiation method returns lightning
qubit. | def test_best_gets_lightning(self):
"""Test that the best differentiation method returns lightning
qubit."""
dev = qml.device("lightning.qubit", wires=2)
def circuit():
"""Simple quantum function."""
return qml.expval(qml.PauliZ(0))
qnode = qml.QNode(circ... | [
"def",
"test_best_gets_lightning",
"(",
"self",
")",
":",
"dev",
"=",
"qml",
".",
"device",
"(",
"\"lightning.qubit\"",
",",
"wires",
"=",
"2",
")",
"def",
"circuit",
"(",
")",
":",
"\"\"\"Simple quantum function.\"\"\"",
"return",
"qml",
".",
"expval",
"(",
... | [
571,
4
] | [
580,
55
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_args | (self) | Test that the plugin requires correct arguments | Test that the plugin requires correct arguments | def test_args(self):
"""Test that the plugin requires correct arguments"""
with pytest.raises(TypeError, match="missing 1 required positional argument: 'wires'"):
qml.device("lightning.qubit") | [
"def",
"test_args",
"(",
"self",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"TypeError",
",",
"match",
"=",
"\"missing 1 required positional argument: 'wires'\"",
")",
":",
"qml",
".",
"device",
"(",
"\"lightning.qubit\"",
")"
] | [
582,
4
] | [
586,
41
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_qubit_circuit | (self, qubit_device_1_wire, tol) | Test that the default qubit plugin provides correct result for a simple circuit | Test that the default qubit plugin provides correct result for a simple circuit | def test_qubit_circuit(self, qubit_device_1_wire, tol):
"""Test that the default qubit plugin provides correct result for a simple circuit"""
p = 0.543
@qml.qnode(qubit_device_1_wire)
def circuit(x):
qml.RX(x, wires=0)
return qml.expval(qml.PauliY(0))
e... | [
"def",
"test_qubit_circuit",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
")",
":",
"p",
"=",
"0.543",
"@",
"qml",
".",
"qnode",
"(",
"qubit_device_1_wire",
")",
"def",
"circuit",
"(",
"x",
")",
":",
"qml",
".",
"RX",
"(",
"x",
",",
"wires",
... | [
588,
4
] | [
600,
65
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_qubit_identity | (self, qubit_device_1_wire, tol) | Test that the default qubit plugin provides correct result for the Identity expectation | Test that the default qubit plugin provides correct result for the Identity expectation | def test_qubit_identity(self, qubit_device_1_wire, tol):
"""Test that the default qubit plugin provides correct result for the Identity expectation"""
p = 0.543
@qml.qnode(qubit_device_1_wire)
def circuit(x):
"""Test quantum function"""
qml.RX(x, wires=0)
... | [
"def",
"test_qubit_identity",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
")",
":",
"p",
"=",
"0.543",
"@",
"qml",
".",
"qnode",
"(",
"qubit_device_1_wire",
")",
"def",
"circuit",
"(",
"x",
")",
":",
"\"\"\"Test quantum function\"\"\"",
"qml",
".",
... | [
602,
4
] | [
613,
58
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_nonzero_shots | (self, tol) | Test that the default qubit plugin provides correct result for high shot number | Test that the default qubit plugin provides correct result for high shot number | def test_nonzero_shots(self, tol):
"""Test that the default qubit plugin provides correct result for high shot number"""
shots = 10 ** 4
dev = qml.device("lightning.qubit", wires=1, shots=shots)
p = 0.543
@qml.qnode(dev)
def circuit(x):
"""Test quantum func... | [
"def",
"test_nonzero_shots",
"(",
"self",
",",
"tol",
")",
":",
"shots",
"=",
"10",
"**",
"4",
"dev",
"=",
"qml",
".",
"device",
"(",
"\"lightning.qubit\"",
",",
"wires",
"=",
"1",
",",
"shots",
"=",
"shots",
")",
"p",
"=",
"0.543",
"@",
"qml",
"."... | [
615,
4
] | [
633,
71
] | python | en | ['en', 'da', 'en'] | True |
TestLightningQubitIntegration.test_supported_gate_single_wire_no_parameters | (
self, qubit_device_1_wire, tol, name, expected_output
) | Tests supported gates that act on a single wire that are not parameterized | Tests supported gates that act on a single wire that are not parameterized | def test_supported_gate_single_wire_no_parameters(
self, qubit_device_1_wire, tol, name, expected_output
):
"""Tests supported gates that act on a single wire that are not parameterized"""
op = getattr(qml.ops, name)
assert qubit_device_1_wire.supports_operation(name)
@qml... | [
"def",
"test_supported_gate_single_wire_no_parameters",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
",",
"name",
",",
"expected_output",
")",
":",
"op",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"assert",
"qubit_device_1_wire",
".",
"sup... | [
645,
4
] | [
659,
71
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_supported_gate_two_wires_no_parameters | (
self, qubit_device_2_wires, tol, name, expected_output
) | Tests supported gates that act on two wires that are not parameterized | Tests supported gates that act on two wires that are not parameterized | def test_supported_gate_two_wires_no_parameters(
self, qubit_device_2_wires, tol, name, expected_output
):
"""Tests supported gates that act on two wires that are not parameterized"""
op = getattr(qml.ops, name)
assert qubit_device_2_wires.supports_operation(name)
@qml.qno... | [
"def",
"test_supported_gate_two_wires_no_parameters",
"(",
"self",
",",
"qubit_device_2_wires",
",",
"tol",
",",
"name",
",",
"expected_output",
")",
":",
"op",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"assert",
"qubit_device_2_wires",
".",
"sup... | [
670,
4
] | [
685,
72
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_supported_gate_three_wires_no_parameters | (
self, qubit_device_3_wires, tol, name, expected_output
) | Tests supported gates that act on three wires that are not parameterized | Tests supported gates that act on three wires that are not parameterized | def test_supported_gate_three_wires_no_parameters(
self, qubit_device_3_wires, tol, name, expected_output
):
"""Tests supported gates that act on three wires that are not parameterized"""
op = getattr(qml.ops, name)
assert qubit_device_3_wires.supports_operation(name)
@qml... | [
"def",
"test_supported_gate_three_wires_no_parameters",
"(",
"self",
",",
"qubit_device_3_wires",
",",
"tol",
",",
"name",
",",
"expected_output",
")",
":",
"op",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"assert",
"qubit_device_3_wires",
".",
"s... | [
693,
4
] | [
708,
72
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_supported_state_preparation | (
self, qubit_device_2_wires, tol, name, par, expected_output
) | Tests supported state preparations | Tests supported state preparations | def test_supported_state_preparation(
self, qubit_device_2_wires, tol, name, par, expected_output
):
"""Tests supported state preparations"""
op = getattr(qml.ops, name)
assert qubit_device_2_wires.supports_operation(name)
@qml.qnode(qubit_device_2_wires)
def circu... | [
"def",
"test_supported_state_preparation",
"(",
"self",
",",
"qubit_device_2_wires",
",",
"tol",
",",
"name",
",",
"par",
",",
"expected_output",
")",
":",
"op",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"assert",
"qubit_device_2_wires",
".",
... | [
722,
4
] | [
736,
72
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_basis_state_2_qubit_subset | (
self, qubit_device_2_wires, tol, name, par, wires, expected_output
) | Tests qubit basis state preparation on subsets of qubits | Tests qubit basis state preparation on subsets of qubits | def test_basis_state_2_qubit_subset(
self, qubit_device_2_wires, tol, name, par, wires, expected_output
):
"""Tests qubit basis state preparation on subsets of qubits"""
op = getattr(qml.ops, name)
@qml.qnode(qubit_device_2_wires)
def circuit():
op(np.array(par)... | [
"def",
"test_basis_state_2_qubit_subset",
"(",
"self",
",",
"qubit_device_2_wires",
",",
"tol",
",",
"name",
",",
"par",
",",
"wires",
",",
"expected_output",
")",
":",
"op",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"@",
"qml",
".",
"qno... | [
747,
4
] | [
759,
72
] | python | en | ['en', 'da', 'en'] | True |
TestLightningQubitIntegration.test_state_vector_2_qubit_subset | (
self, qubit_device_2_wires, tol, name, par, wires, expected_output
) | Tests qubit state vector preparation on subsets of 2 qubits | Tests qubit state vector preparation on subsets of 2 qubits | def test_state_vector_2_qubit_subset(
self, qubit_device_2_wires, tol, name, par, wires, expected_output
):
"""Tests qubit state vector preparation on subsets of 2 qubits"""
op = getattr(qml.ops, name)
par = np.array(par)
@qml.qnode(qubit_device_2_wires)
def circui... | [
"def",
"test_state_vector_2_qubit_subset",
"(",
"self",
",",
"qubit_device_2_wires",
",",
"tol",
",",
"name",
",",
"par",
",",
"wires",
",",
"expected_output",
")",
":",
"op",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"par",
"=",
"np",
".... | [
772,
4
] | [
786,
72
] | python | en | ['en', 'da', 'en'] | True |
TestLightningQubitIntegration.test_state_vector_3_qubit_subset | (
self, qubit_device_3_wires, tol, name, par, wires, expected_output
) | Tests qubit state vector preparation on subsets of 3 qubits | Tests qubit state vector preparation on subsets of 3 qubits | def test_state_vector_3_qubit_subset(
self, qubit_device_3_wires, tol, name, par, wires, expected_output
):
"""Tests qubit state vector preparation on subsets of 3 qubits"""
op = getattr(qml.ops, name)
par = np.array(par)
@qml.qnode(qubit_device_3_wires)
def circui... | [
"def",
"test_state_vector_3_qubit_subset",
"(",
"self",
",",
"qubit_device_3_wires",
",",
"tol",
",",
"name",
",",
"par",
",",
"wires",
",",
"expected_output",
")",
":",
"op",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"par",
"=",
"np",
".... | [
806,
4
] | [
820,
72
] | python | en | ['en', 'da', 'en'] | True |
TestLightningQubitIntegration.test_supported_gate_single_wire_with_parameters | (
self, qubit_device_1_wire, tol, name, par, expected_output
) | Tests supported gates that act on a single wire that are parameterized | Tests supported gates that act on a single wire that are parameterized | def test_supported_gate_single_wire_with_parameters(
self, qubit_device_1_wire, tol, name, par, expected_output
):
"""Tests supported gates that act on a single wire that are parameterized"""
op = getattr(qml.ops, name)
assert qubit_device_1_wire.supports_operation(name)
@... | [
"def",
"test_supported_gate_single_wire_with_parameters",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
",",
"name",
",",
"par",
",",
"expected_output",
")",
":",
"op",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"assert",
"qubit_device_1_wi... | [
842,
4
] | [
856,
71
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_supported_gate_two_wires_with_parameters | (
self, qubit_device_2_wires, tol, name, par, expected_output
) | Tests supported gates that act on two wires wires that are parameterized | Tests supported gates that act on two wires wires that are parameterized | def test_supported_gate_two_wires_with_parameters(
self, qubit_device_2_wires, tol, name, par, expected_output
):
"""Tests supported gates that act on two wires wires that are parameterized"""
op = getattr(qml.ops, name)
assert qubit_device_2_wires.supports_operation(name)
... | [
"def",
"test_supported_gate_two_wires_with_parameters",
"(",
"self",
",",
"qubit_device_2_wires",
",",
"tol",
",",
"name",
",",
"par",
",",
"expected_output",
")",
":",
"op",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"assert",
"qubit_device_2_wir... | [
879,
4
] | [
894,
72
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_supported_observable_single_wire_no_parameters | (
self, qubit_device_1_wire, tol, name, state, expected_output
) | Tests supported observables on single wires without parameters. | Tests supported observables on single wires without parameters. | def test_supported_observable_single_wire_no_parameters(
self, qubit_device_1_wire, tol, name, state, expected_output
):
"""Tests supported observables on single wires without parameters."""
obs = getattr(qml.ops, name)
assert qubit_device_1_wire.supports_observable(name)
... | [
"def",
"test_supported_observable_single_wire_no_parameters",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
",",
"name",
",",
"state",
",",
"expected_output",
")",
":",
"obs",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"assert",
"qubit_devi... | [
913,
4
] | [
927,
71
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_supported_observable_single_wire_with_parameters | (
self, qubit_device_1_wire, tol, name, state, expected_output, par
) | Tests supported observables on single wires with parameters. | Tests supported observables on single wires with parameters. | def test_supported_observable_single_wire_with_parameters(
self, qubit_device_1_wire, tol, name, state, expected_output, par
):
"""Tests supported observables on single wires with parameters."""
obs = getattr(qml.ops, name)
assert qubit_device_1_wire.supports_observable(name)
... | [
"def",
"test_supported_observable_single_wire_with_parameters",
"(",
"self",
",",
"qubit_device_1_wire",
",",
"tol",
",",
"name",
",",
"state",
",",
"expected_output",
",",
"par",
")",
":",
"obs",
"=",
"getattr",
"(",
"qml",
".",
"ops",
",",
"name",
")",
"asse... | [
937,
4
] | [
951,
71
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_multi_samples_return_correlated_results | (self, qubit_device_2_wires) | Tests if the samples returned by the sample function have
the correct dimensions
| Tests if the samples returned by the sample function have
the correct dimensions
| def test_multi_samples_return_correlated_results(self, qubit_device_2_wires):
"""Tests if the samples returned by the sample function have
the correct dimensions
"""
dev = qubit_device_2_wires
@qml.qnode(dev)
def circuit():
qml.Hadamard(0)
qml.CN... | [
"def",
"test_multi_samples_return_correlated_results",
"(",
"self",
",",
"qubit_device_2_wires",
")",
":",
"dev",
"=",
"qubit_device_2_wires",
"@",
"qml",
".",
"qnode",
"(",
"dev",
")",
"def",
"circuit",
"(",
")",
":",
"qml",
".",
"Hadamard",
"(",
"0",
")",
... | [
953,
4
] | [
968,
55
] | python | en | ['en', 'en', 'en'] | True |
TestLightningQubitIntegration.test_multi_samples_return_correlated_results_more_wires_than_size_of_observable | (
self, num_wires
) | Tests if the samples returned by the sample function have
the correct dimensions
| Tests if the samples returned by the sample function have
the correct dimensions
| def test_multi_samples_return_correlated_results_more_wires_than_size_of_observable(
self, num_wires
):
"""Tests if the samples returned by the sample function have
the correct dimensions
"""
dev = qml.device("lightning.qubit", wires=num_wires)
@qml.qnode(dev)
... | [
"def",
"test_multi_samples_return_correlated_results_more_wires_than_size_of_observable",
"(",
"self",
",",
"num_wires",
")",
":",
"dev",
"=",
"qml",
".",
"device",
"(",
"\"lightning.qubit\"",
",",
"wires",
"=",
"num_wires",
")",
"@",
"qml",
".",
"qnode",
"(",
"dev"... | [
971,
4
] | [
988,
55
] | python | en | ['en', 'en', 'en'] | True |
dictionary | (name, node, mysql_node, secret_type) | Create a table in MySQL and use it a source for a dictionary.
| Create a table in MySQL and use it a source for a dictionary.
| def dictionary(name, node, mysql_node, secret_type):
"""Create a table in MySQL and use it a source for a dictionary.
"""
try:
with Given("table in MySQL"):
sql = f"""
CREATE TABLE {name}(
id INT NOT NULL AUTO_INCREMENT,
date DATE,
... | [
"def",
"dictionary",
"(",
"name",
",",
"node",
",",
"mysql_node",
",",
"secret_type",
")",
":",
"try",
":",
"with",
"Given",
"(",
"\"table in MySQL\"",
")",
":",
"sql",
"=",
"f\"\"\"\n CREATE TABLE {name}(\n id INT NOT NULL AUTO_INCREMENT... | [
10,
0
] | [
61,
121
] | python | en | ['en', 'en', 'en'] | True |
parameters_dictionary | (name, node, mysql_node) | Create a table in MySQL and use it a source for a dictionary
that stores parameters for the encryption functions.
| Create a table in MySQL and use it a source for a dictionary
that stores parameters for the encryption functions.
| def parameters_dictionary(name, node, mysql_node):
"""Create a table in MySQL and use it a source for a dictionary
that stores parameters for the encryption functions.
"""
try:
with Given("table in MySQL"):
sql = f"""
CREATE TABLE {name}(
`id` INT ... | [
"def",
"parameters_dictionary",
"(",
"name",
",",
"node",
",",
"mysql_node",
")",
":",
"try",
":",
"with",
"Given",
"(",
"\"table in MySQL\"",
")",
":",
"sql",
"=",
"f\"\"\"\n CREATE TABLE {name}(\n `id` INT NOT NULL AUTO_INCREMENT,\n ... | [
64,
0
] | [
120,
121
] | python | en | ['en', 'en', 'en'] | True |
parameter_values | (self) | Check that we can use a dictionary that uses MySQL table as a source
can be used as a parameters store for the `encrypt`, `decrypt`, and
`aes_encrypt_mysql`, `aes_decrypt_mysql` functions.
| Check that we can use a dictionary that uses MySQL table as a source
can be used as a parameters store for the `encrypt`, `decrypt`, and
`aes_encrypt_mysql`, `aes_decrypt_mysql` functions.
| def parameter_values(self):
"""Check that we can use a dictionary that uses MySQL table as a source
can be used as a parameters store for the `encrypt`, `decrypt`, and
`aes_encrypt_mysql`, `aes_decrypt_mysql` functions.
"""
node = self.context.node
mysql_node = self.context.mysql_node
mode =... | [
"def",
"parameter_values",
"(",
"self",
")",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"mysql_node",
"=",
"self",
".",
"context",
".",
"mysql_node",
"mode",
"=",
"\"'aes-128-cbc'\"",
"key",
"=",
"f\"'{'1' * 16}'\"",
"iv",
"=",
"f\"'{'2' * 16}'\"",... | [
123,
0
] | [
164,
62
] | python | en | ['en', 'en', 'en'] | True |
decrypt | (self, mysql_datatype) | Check that when using a dictionary that uses MySQL table as a source and
contains a data encrypted in MySQL and stored using specified data type
that we can decrypt data from the dictionary using
the `aes_decrypt_mysql` or `decrypt` functions in the select query.
| Check that when using a dictionary that uses MySQL table as a source and
contains a data encrypted in MySQL and stored using specified data type
that we can decrypt data from the dictionary using
the `aes_decrypt_mysql` or `decrypt` functions in the select query.
| def decrypt(self, mysql_datatype):
"""Check that when using a dictionary that uses MySQL table as a source and
contains a data encrypted in MySQL and stored using specified data type
that we can decrypt data from the dictionary using
the `aes_decrypt_mysql` or `decrypt` functions in the select query.
... | [
"def",
"decrypt",
"(",
"self",
",",
"mysql_datatype",
")",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"mysql_node",
"=",
"self",
".",
"context",
".",
"mysql_node",
"key",
"=",
"f\"{'1' * 64}\"",
"iv",
"=",
"f\"{'2' * 64}\"",
"for",
"func",
"in"... | [
173,
0
] | [
234,
63
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1", mysql_node="mysql1") | Check usage of encryption functions with [MySQL dictionary].
[MySQL dictionary]: https://clickhouse.tech/docs/en/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources/#dicts-external_dicts_dict_sources-mysql
| Check usage of encryption functions with [MySQL dictionary]. | def feature(self, node="clickhouse1", mysql_node="mysql1"):
"""Check usage of encryption functions with [MySQL dictionary].
[MySQL dictionary]: https://clickhouse.tech/docs/en/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources/#dicts-external_dicts_dict_sources-mysql
"""
self.... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
",",
"mysql_node",
"=",
"\"mysql1\"",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
"self",
".",
"context",... | [
241,
0
] | [
250,
40
] | python | en | ['en', 'en', 'en'] | True |
privilege_granted_directly_or_via_role | (self, table_type, privilege, node=None) | Check that user is only able to execute ALTER FREEZE PARTITION when they have required privilege, either directly or via role.
| Check that user is only able to execute ALTER FREEZE PARTITION when they have required privilege, either directly or via role.
| def privilege_granted_directly_or_via_role(self, table_type, privilege, node=None):
"""Check that user is only able to execute ALTER FREEZE PARTITION when they have required privilege, either directly or via role.
"""
role_name = f"role_{getuid()}"
user_name = f"user_{getuid()}"
if node is None:
... | [
"def",
"privilege_granted_directly_or_via_role",
"(",
"self",
",",
"table_type",
",",
"privilege",
",",
"node",
"=",
"None",
")",
":",
"role_name",
"=",
"f\"role_{getuid()}\"",
"user_name",
"=",
"f\"user_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",... | [
10,
0
] | [
29,
136
] | python | en | ['en', 'en', 'en'] | True |
privilege_check | (grant_target_name, user_name, table_type, privilege, node=None) | Run scenarios to check the user's access with different privileges.
| Run scenarios to check the user's access with different privileges.
| def privilege_check(grant_target_name, user_name, table_type, privilege, node=None):
"""Run scenarios to check the user's access with different privileges.
"""
exitcode, message = errors.not_enough_privileges(name=f"{user_name}")
with Scenario("user without privilege", setup=instrument_clickhouse_serve... | [
"def",
"privilege_check",
"(",
"grant_target_name",
",",
"user_name",
",",
"table_type",
",",
"privilege",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"f\"{user_name}\"",
")",
"... | [
31,
0
] | [
74,
55
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1", stress=None, parallel=None) | Check the RBAC functionality of ALTER FREEZE.
| Check the RBAC functionality of ALTER FREEZE.
| def feature(self, node="clickhouse1", stress=None, parallel=None):
"""Check the RBAC functionality of ALTER FREEZE.
"""
self.context.node = self.context.cluster.node(node)
if parallel is not None:
self.context.parallel = parallel
if stress is not None:
self.context.stress = stress
... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
",",
"stress",
"=",
"None",
",",
"parallel",
"=",
"None",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
... | [
86,
0
] | [
105,
98
] | python | en | ['en', 'en', 'en'] | True |
UI_EdgeTpuDevBoard.setLED | (self, index, state) | Abstracts away mix of GPIO and PWM LEDs. | Abstracts away mix of GPIO and PWM LEDs. | def setLED(self, index, state):
"""Abstracts away mix of GPIO and PWM LEDs."""
if isinstance(self._LEDs[index], GPIO): self._LEDs[index].write(not state)
else: self._LEDs[index].duty_cycle = 0.0 if state else 1.0 | [
"def",
"setLED",
"(",
"self",
",",
"index",
",",
"state",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_LEDs",
"[",
"index",
"]",
",",
"GPIO",
")",
":",
"self",
".",
"_LEDs",
"[",
"index",
"]",
".",
"write",
"(",
"not",
"state",
")",
"else",
... | [
182,
2
] | [
185,
62
] | python | en | ['en', 'en', 'en'] | True |
privileges_granted_directly | (self, node=None) | Check that a user is able to execute `SHOW ROW POLICIES` with privileges are granted directly.
| Check that a user is able to execute `SHOW ROW POLICIES` with privileges are granted directly.
| def privileges_granted_directly(self, node=None):
"""Check that a user is able to execute `SHOW ROW POLICIES` with privileges are granted directly.
"""
user_name = f"user_{getuid()}"
if node is None:
node = self.context.node
with user(node, f"{user_name}"):
Suite(run=check_privil... | [
"def",
"privileges_granted_directly",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"user_name",
"=",
"f\"user_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"user",
"(",
"node",
",",
"f\"{user_... | [
20,
0
] | [
34,
74
] | python | en | ['en', 'en', 'en'] | True |
privileges_granted_via_role | (self, node=None) | Check that a user is able to execute `SHOW ROW POLICIES` with privileges are granted through a role.
| Check that a user is able to execute `SHOW ROW POLICIES` with privileges are granted through a role.
| def privileges_granted_via_role(self, node=None):
"""Check that a user is able to execute `SHOW ROW POLICIES` with privileges are granted through a role.
"""
user_name = f"user_{getuid()}"
role_name = f"role_{getuid()}"
if node is None:
node = self.context.node
with user(node, f"{user... | [
"def",
"privileges_granted_via_role",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"user_name",
"=",
"f\"user_{getuid()}\"",
"role_name",
"=",
"f\"role_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with"... | [
37,
0
] | [
55,
74
] | python | en | ['en', 'en', 'en'] | True |
check_privilege | (self, privilege, grant_target_name, user_name, node=None) | Run checks for commands that require SHOW ROW POLICIES privilege.
| Run checks for commands that require SHOW ROW POLICIES privilege.
| def check_privilege(self, privilege, grant_target_name, user_name, node=None):
"""Run checks for commands that require SHOW ROW POLICIES privilege.
"""
if node is None:
node = self.context.node
Suite(test=show_row_policies)(privilege=privilege, grant_target_name=grant_target_name, user_name=us... | [
"def",
"check_privilege",
"(",
"self",
",",
"privilege",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"Suite",
"(",
"test",
"=",
"show... | [
67,
0
] | [
75,
106
] | python | en | ['en', 'en', 'en'] | True |
show_row_policies | (self, privilege, grant_target_name, user_name, node=None) | Check that user is only able to execute `SHOW ROW POLICIES` when they have the necessary privilege.
| Check that user is only able to execute `SHOW ROW POLICIES` when they have the necessary privilege.
| def show_row_policies(self, privilege, grant_target_name, user_name, node=None):
"""Check that user is only able to execute `SHOW ROW POLICIES` when they have the necessary privilege.
"""
exitcode, message = errors.not_enough_privileges(name=user_name)
if node is None:
node = self.context.node
... | [
"def",
"show_row_policies",
"(",
"self",
",",
"privilege",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"user_name",
")",
"if",
"nod... | [
81,
0
] | [
119,
51
] | python | en | ['en', 'en', 'en'] | True |
show_create | (self, privilege, grant_target_name, user_name, node=None) | Check that user is only able to execute `SHOW CREATE ROW POLICY` when they have the necessary privilege.
| Check that user is only able to execute `SHOW CREATE ROW POLICY` when they have the necessary privilege.
| def show_create(self, privilege, grant_target_name, user_name, node=None):
"""Check that user is only able to execute `SHOW CREATE ROW POLICY` when they have the necessary privilege.
"""
exitcode, message = errors.not_enough_privileges(name=user_name)
if node is None:
node = self.context.node
... | [
"def",
"show_create",
"(",
"self",
",",
"privilege",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"user_name",
")",
"if",
"node",
... | [
125,
0
] | [
175,
55
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1") | Check the RBAC functionality of SHOW ROW POLICYS.
| Check the RBAC functionality of SHOW ROW POLICYS.
| def feature(self, node="clickhouse1"):
"""Check the RBAC functionality of SHOW ROW POLICYS.
"""
self.context.node = self.context.cluster.node(node)
Suite(run=privileges_granted_directly, setup=instrument_clickhouse_server_log)
Suite(run=privileges_granted_via_role, setup=instrument_clickhouse_serve... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
"Suite",
"(",
"run",
"=",
"privileges_granted_directly",
",",
... | [
184,
0
] | [
190,
82
] | python | en | ['en', 'en', 'en'] | True |
KuduImpalaInterface.connect | (self, host_or_hosts, port_or_ports=7051,
rpc_timeout=None, admin_timeout=None) |
Pass-through connection interface to the Kudu client
Parameters
----------
host_or_hosts : string or list of strings
If you have multiple Kudu masters for HA, pass a list
port_or_ports : int or list of int, default 7051
If you pass multiple host names, pass ... |
Pass-through connection interface to the Kudu client | def connect(self, host_or_hosts, port_or_ports=7051,
rpc_timeout=None, admin_timeout=None):
"""
Pass-through connection interface to the Kudu client
Parameters
----------
host_or_hosts : string or list of strings
If you have multiple Kudu masters for HA... | [
"def",
"connect",
"(",
"self",
",",
"host_or_hosts",
",",
"port_or_ports",
"=",
"7051",
",",
"rpc_timeout",
"=",
"None",
",",
"admin_timeout",
"=",
"None",
")",
":",
"self",
".",
"client",
"=",
"kudu",
".",
"connect",
"(",
"host_or_hosts",
",",
"port_or_po... | [
57,
4
] | [
79,
66
] | python | en | ['en', 'error', 'th'] | False |
KuduImpalaInterface.create_table | (self, impala_name, kudu_name, primary_keys=None,
obj=None, schema=None, database=None,
external=False, force=False) |
Create an Kudu-backed table in the connected Impala cluster. For
non-external tables, this will create a Kudu table with a compatible
storage schema.
This function is patterned after the ImpalaClient.create_table function
designed for physical filesystems (like HDFS).
... |
Create an Kudu-backed table in the connected Impala cluster. For
non-external tables, this will create a Kudu table with a compatible
storage schema. | def create_table(self, impala_name, kudu_name, primary_keys=None,
obj=None, schema=None, database=None,
external=False, force=False):
"""
Create an Kudu-backed table in the connected Impala cluster. For
non-external tables, this will create a Kudu table ... | [
"def",
"create_table",
"(",
"self",
",",
"impala_name",
",",
"kudu_name",
",",
"primary_keys",
"=",
"None",
",",
"obj",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"database",
"=",
"None",
",",
"external",
"=",
"False",
",",
"force",
"=",
"False",
")... | [
91,
4
] | [
162,
41
] | python | en | ['en', 'error', 'th'] | False |
KuduImpalaInterface.table | (self, kudu_name, name=None, database=None, persist=False,
external=True) |
Convenience to expose an existing Kudu table (using CREATE TABLE) as an
Impala table. To create a new table both in the Hive Metastore with
storage in Kudu, use create_table.
Note: all tables created are EXTERNAL for now. Creates a temporary
table (like parquet_file and others)... |
Convenience to expose an existing Kudu table (using CREATE TABLE) as an
Impala table. To create a new table both in the Hive Metastore with
storage in Kudu, use create_table. | def table(self, kudu_name, name=None, database=None, persist=False,
external=True):
"""
Convenience to expose an existing Kudu table (using CREATE TABLE) as an
Impala table. To create a new table both in the Hive Metastore with
storage in Kudu, use create_table.
No... | [
"def",
"table",
"(",
"self",
",",
"kudu_name",
",",
"name",
"=",
"None",
",",
"database",
"=",
"None",
",",
"persist",
"=",
"False",
",",
"external",
"=",
"True",
")",
":",
"# Law of demeter, but OK for now because internal class coupling",
"name",
",",
"databas... | [
164,
4
] | [
203,
74
] | python | en | ['en', 'error', 'th'] | False |
register_option | (key, defval, doc='', validator=None, cb=None) | Register an option in the package-wide ibis config object
Parameters
----------
key - a fully-qualified key, e.g. "x.y.option - z".
defval - the default value of the option
doc - a string description of the option
validator - a function of a single argument, should raise `ValueErr... | Register an option in the package-wide ibis config object
Parameters
----------
key - a fully-qualified key, e.g. "x.y.option - z".
defval - the default value of the option
doc - a string description of the option
validator - a function of a single argument, should raise `ValueErr... | def register_option(key, defval, doc='', validator=None, cb=None):
"""Register an option in the package-wide ibis config object
Parameters
----------
key - a fully-qualified key, e.g. "x.y.option - z".
defval - the default value of the option
doc - a string description of the opti... | [
"def",
"register_option",
"(",
"key",
",",
"defval",
",",
"doc",
"=",
"''",
",",
"validator",
"=",
"None",
",",
"cb",
"=",
"None",
")",
":",
"import",
"tokenize",
"import",
"keyword",
"key",
"=",
"key",
".",
"lower",
"(",
")",
"if",
"key",
"in",
"_... | [
363,
0
] | [
422,
54
] | python | en | ['en', 'en', 'en'] | True |
deprecate_option | (key, msg=None, rkey=None, removal_ver=None) |
Mark option `key` as deprecated, if code attempts to access this option,
a warning will be produced, using `msg` if given, or a default message
if not.
if `rkey` is given, any access to the key will be re-routed to `rkey`.
Neither the existence of `key` nor that if `rkey` is checked. If they
do... |
Mark option `key` as deprecated, if code attempts to access this option,
a warning will be produced, using `msg` if given, or a default message
if not.
if `rkey` is given, any access to the key will be re-routed to `rkey`.
Neither the existence of `key` nor that if `rkey` is checked. If they
do... | def deprecate_option(key, msg=None, rkey=None, removal_ver=None):
"""
Mark option `key` as deprecated, if code attempts to access this option,
a warning will be produced, using `msg` if given, or a default message
if not.
if `rkey` is given, any access to the key will be re-routed to `rkey`.
Nei... | [
"def",
"deprecate_option",
"(",
"key",
",",
"msg",
"=",
"None",
",",
"rkey",
"=",
"None",
",",
"removal_ver",
"=",
"None",
")",
":",
"key",
"=",
"key",
".",
"lower",
"(",
")",
"if",
"key",
"in",
"_deprecated_options",
":",
"raise",
"OptionError",
"(",
... | [
425,
0
] | [
462,
76
] | python | en | ['en', 'error', 'th'] | False |
_select_options | (pat) | returns a list of keys matching `pat`
if pat=="all", returns all registered options
| returns a list of keys matching `pat`
if pat=="all", returns all registered options
| def _select_options(pat):
"""returns a list of keys matching `pat`
if pat=="all", returns all registered options
"""
# short-circuit for exact key
if pat in _registered_options:
return [pat]
# else look through all of them
keys = sorted(_registered_options.keys())
if pat == 'al... | [
"def",
"_select_options",
"(",
"pat",
")",
":",
"# short-circuit for exact key",
"if",
"pat",
"in",
"_registered_options",
":",
"return",
"[",
"pat",
"]",
"# else look through all of them",
"keys",
"=",
"sorted",
"(",
"_registered_options",
".",
"keys",
"(",
")",
... | [
468,
0
] | [
482,
55
] | python | en | ['en', 'lb', 'en'] | True |
_is_deprecated | (key) | Returns True if the given option has been deprecated | Returns True if the given option has been deprecated | def _is_deprecated(key):
""" Returns True if the given option has been deprecated """
key = key.lower()
return key in _deprecated_options | [
"def",
"_is_deprecated",
"(",
"key",
")",
":",
"key",
"=",
"key",
".",
"lower",
"(",
")",
"return",
"key",
"in",
"_deprecated_options"
] | [
493,
0
] | [
497,
37
] | python | en | ['en', 'en', 'en'] | True |
_get_deprecated_option | (key) |
Retrieves the metadata for a deprecated option, if `key` is deprecated.
Returns
-------
DeprecatedOption (namedtuple) if key is deprecated, None otherwise
|
Retrieves the metadata for a deprecated option, if `key` is deprecated.
Returns
-------
DeprecatedOption (namedtuple) if key is deprecated, None otherwise
| def _get_deprecated_option(key):
"""
Retrieves the metadata for a deprecated option, if `key` is deprecated.
Returns
-------
DeprecatedOption (namedtuple) if key is deprecated, None otherwise
"""
try:
d = _deprecated_options[key]
except KeyError:
return None
else:
... | [
"def",
"_get_deprecated_option",
"(",
"key",
")",
":",
"try",
":",
"d",
"=",
"_deprecated_options",
"[",
"key",
"]",
"except",
"KeyError",
":",
"return",
"None",
"else",
":",
"return",
"d"
] | [
500,
0
] | [
513,
16
] | python | en | ['en', 'error', 'th'] | False |
_get_registered_option | (key) |
Retrieves the option metadata if `key` is a registered option.
Returns
-------
RegisteredOption (namedtuple) if key is deprecated, None otherwise
|
Retrieves the option metadata if `key` is a registered option.
Returns
-------
RegisteredOption (namedtuple) if key is deprecated, None otherwise
| def _get_registered_option(key):
"""
Retrieves the option metadata if `key` is a registered option.
Returns
-------
RegisteredOption (namedtuple) if key is deprecated, None otherwise
"""
return _registered_options.get(key) | [
"def",
"_get_registered_option",
"(",
"key",
")",
":",
"return",
"_registered_options",
".",
"get",
"(",
"key",
")"
] | [
516,
0
] | [
523,
39
] | python | en | ['en', 'error', 'th'] | False |
_translate_key | (key) |
if key id deprecated and a replacement key defined, will return the
replacement key, otherwise returns `key` as - is
|
if key id deprecated and a replacement key defined, will return the
replacement key, otherwise returns `key` as - is
| def _translate_key(key):
"""
if key id deprecated and a replacement key defined, will return the
replacement key, otherwise returns `key` as - is
"""
d = _get_deprecated_option(key)
if d:
return d.rkey or key
else:
return key | [
"def",
"_translate_key",
"(",
"key",
")",
":",
"d",
"=",
"_get_deprecated_option",
"(",
"key",
")",
"if",
"d",
":",
"return",
"d",
".",
"rkey",
"or",
"key",
"else",
":",
"return",
"key"
] | [
526,
0
] | [
536,
18
] | python | en | ['en', 'error', 'th'] | False |
_warn_if_deprecated | (key) |
Checks if `key` is a deprecated option and if so, prints a warning.
Returns
-------
bool - True if `key` is deprecated, False otherwise.
|
Checks if `key` is a deprecated option and if so, prints a warning.
Returns
-------
bool - True if `key` is deprecated, False otherwise.
| def _warn_if_deprecated(key):
"""
Checks if `key` is a deprecated option and if so, prints a warning.
Returns
-------
bool - True if `key` is deprecated, False otherwise.
"""
d = _get_deprecated_option(key)
if d:
if d.msg:
print(d.msg)
warnings.warn(d.msg... | [
"def",
"_warn_if_deprecated",
"(",
"key",
")",
":",
"d",
"=",
"_get_deprecated_option",
"(",
"key",
")",
"if",
"d",
":",
"if",
"d",
".",
"msg",
":",
"print",
"(",
"d",
".",
"msg",
")",
"warnings",
".",
"warn",
"(",
"d",
".",
"msg",
",",
"Deprecatio... | [
539,
0
] | [
563,
16
] | python | en | ['en', 'error', 'th'] | False |
_build_option_description | (k) | Builds a formatted description of a registered option and prints it | Builds a formatted description of a registered option and prints it | def _build_option_description(k):
""" Builds a formatted description of a registered option and prints it """
o = _get_registered_option(k)
d = _get_deprecated_option(k)
s = u('%s ') % k
if o.doc:
s += '\n'.join(o.doc.strip().split('\n'))
else:
s += 'No description available.'... | [
"def",
"_build_option_description",
"(",
"k",
")",
":",
"o",
"=",
"_get_registered_option",
"(",
"k",
")",
"d",
"=",
"_get_deprecated_option",
"(",
"k",
")",
"s",
"=",
"u",
"(",
"'%s '",
")",
"%",
"k",
"if",
"o",
".",
"doc",
":",
"s",
"+=",
"'\\n'",
... | [
566,
0
] | [
589,
12
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.