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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
partition_clause | (self) | Check window specification that only contains partition clause.
| Check window specification that only contains partition clause.
| def partition_clause(self):
"""Check window specification that only contains partition clause.
"""
expected = convert_output("""
sum
-------
25100
25100
25100
25100
25100
7400
7400
14600
14600
14600
""")
execute_query(
"SELECT sum(salary) OV... | [
"def",
"partition_clause",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum \n -------\n 25100\n 25100\n 25100\n 25100\n 25100\n 7400\n 7400\n 14600\n 14600\n 14600\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT sum(sal... | [
5,
0
] | [
26,
5
] | python | en | ['en', 'en', 'en'] | True |
orderby_clause | (self) | Check window specification that only contains order by clause.
| Check window specification that only contains order by clause.
| def orderby_clause(self):
"""Check window specification that only contains order by clause.
"""
expected = convert_output("""
sum
-------
25100
25100
25100
25100
25100
32500
32500
47100
47100
47100
""")
execute_query(
"SELECT sum(salary) OVE... | [
"def",
"orderby_clause",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum \n -------\n 25100\n 25100\n 25100\n 25100\n 25100\n 32500\n 32500\n 47100\n 47100\n 47100\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT sum(sal... | [
29,
0
] | [
50,
5
] | python | en | ['en', 'en', 'en'] | True |
frame_clause | (self) | Check window specification that only contains frame clause.
| Check window specification that only contains frame clause.
| def frame_clause(self):
"""Check window specification that only contains frame clause.
"""
expected = convert_output("""
sum
-------
5000
3900
4800
4800
3500
4200
6000
4500
5200
5200
""")
execute_query(
"SELECT sum(salary) OVER w AS sum FROM... | [
"def",
"frame_clause",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum \n -------\n 5000\n 3900\n 4800\n 4800\n 3500\n 4200\n 6000\n 4500\n 5200\n 5200\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT sum(salary) OVER w ... | [
53,
0
] | [
74,
5
] | python | en | ['en', 'en', 'en'] | True |
partition_with_order_by | (self) | Check window specification that contains partition and order by clauses.
| Check window specification that contains partition and order by clauses.
| def partition_with_order_by(self):
"""Check window specification that contains partition and order by clauses.
"""
expected = convert_output("""
sum
-------
4200
8700
19100
19100
25100
3500
7400
9600
9600
14600
""")
execute_query(
... | [
"def",
"partition_with_order_by",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum \n -------\n 4200\n 8700\n 19100\n 19100\n 25100\n 3500\n 7400\n 9600\n 9600\n 14600\n \"\"\"",
")",
"execute_query",
"(",
"\"S... | [
77,
0
] | [
98,
5
] | python | en | ['en', 'en', 'en'] | True |
partition_with_frame | (self) | Check window specification that contains partition and frame clauses.
| Check window specification that contains partition and frame clauses.
| def partition_with_frame(self):
"""Check window specification that contains partition and frame clauses.
"""
expected = convert_output("""
sum
-------
4200
6000
4500
5200
5200
3900
3500
5000
4800
4800
""")
execute_query(
"SELECT sum(salary) ... | [
"def",
"partition_with_frame",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum \n -------\n 4200\n 6000\n 4500\n 5200\n 5200\n 3900\n 3500\n 5000\n 4800\n 4800\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT sum(salary)... | [
101,
0
] | [
122,
5
] | python | en | ['en', 'en', 'en'] | True |
order_by_with_frame | (self) | Check window specification that contains order by and frame clauses.
| Check window specification that contains order by and frame clauses.
| def order_by_with_frame(self):
"""Check window specification that contains order by and frame clauses.
"""
expected = convert_output("""
sum
-------
4200
10200
10500
9700
10400
9100
7400
8500
9800
9600
""")
execute_query(
"SELECT sum(salary)... | [
"def",
"order_by_with_frame",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum \n -------\n 4200\n 10200\n 10500\n 9700\n 10400\n 9100\n 7400\n 8500\n 9800\n 9600\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT sum(salar... | [
125,
0
] | [
146,
5
] | python | en | ['en', 'en', 'en'] | True |
partition_with_order_by_and_frame | (self) | Check window specification that contains all clauses.
| Check window specification that contains all clauses.
| def partition_with_order_by_and_frame(self):
"""Check window specification that contains all clauses.
"""
expected = convert_output("""
sum
-------
4200
8700
9700
10400
11200
3500
7400
4800
9600
9800
""")
execute_query(
"SELECT sum(salary) O... | [
"def",
"partition_with_order_by_and_frame",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum \n -------\n 4200\n 8700\n 9700\n 10400\n 11200\n 3500\n 7400\n 4800\n 9600\n 9800\n \"\"\"",
")",
"execute_query",
"(",
"\"SEL... | [
149,
0
] | [
170,
5
] | python | en | ['en', 'en', 'en'] | True |
empty | (self) | Check defining an empty window specification.
| Check defining an empty window specification.
| def empty(self):
"""Check defining an empty window specification.
"""
expected = convert_output("""
sum
-------
47100
47100
47100
47100
47100
47100
47100
47100
47100
47100
""")
execute_query(
"SELECT sum(salary) OVER w AS sum FROM ... | [
"def",
"empty",
"(",
"self",
")",
":",
"expected",
"=",
"convert_output",
"(",
"\"\"\"\n sum \n -------\n 47100\n 47100\n 47100\n 47100\n 47100\n 47100\n 47100\n 47100\n 47100\n 47100\n \"\"\"",
")",
"execute_query",
"(",
"\"SELECT sum(sa... | [
173,
0
] | [
194,
5
] | python | en | ['en', 'en', 'en'] | True |
feature | (self) | Check defining window specifications.
| Check defining window specifications.
| def feature(self):
"""Check defining window specifications.
"""
for scenario in loads(current_module(), Scenario):
Scenario(run=scenario, flags=TE) | [
"def",
"feature",
"(",
"self",
")",
":",
"for",
"scenario",
"in",
"loads",
"(",
"current_module",
"(",
")",
",",
"Scenario",
")",
":",
"Scenario",
"(",
"run",
"=",
"scenario",
",",
"flags",
"=",
"TE",
")"
] | [
201,
0
] | [
205,
40
] | python | en | ['en', 'en', 'en'] | True |
TestWalBase.test_wal_insert | (self, connect, collection) |
target: add vectors in WAL
method: add vectors and flush when WAL is enabled
expected: status ok, vectors added
|
target: add vectors in WAL
method: add vectors and flush when WAL is enabled
expected: status ok, vectors added
| def test_wal_insert(self, connect, collection):
'''
target: add vectors in WAL
method: add vectors and flush when WAL is enabled
expected: status ok, vectors added
'''
vectors = gen_vector(nb, dim)
status, ids = connect.insert(collection, vectors)
assert s... | [
"def",
"test_wal_insert",
"(",
"self",
",",
"connect",
",",
"collection",
")",
":",
"vectors",
"=",
"gen_vector",
"(",
"nb",
",",
"dim",
")",
"status",
",",
"ids",
"=",
"connect",
".",
"insert",
"(",
"collection",
",",
"vectors",
")",
"assert",
"status",... | [
23,
4
] | [
40,
47
] | python | en | ['en', 'error', 'th'] | False |
TestWalBase.test_wal_delete_vectors | (self, connect, collection) |
target: delete vectors in WAL
method: delete vectors and flush when WAL is enabled
expected: status ok, vectors deleted
|
target: delete vectors in WAL
method: delete vectors and flush when WAL is enabled
expected: status ok, vectors deleted
| def test_wal_delete_vectors(self, connect, collection):
'''
target: delete vectors in WAL
method: delete vectors and flush when WAL is enabled
expected: status ok, vectors deleted
'''
vectors = gen_vector(nb, dim)
status, ids = connect.insert(collection, vectors)
... | [
"def",
"test_wal_delete_vectors",
"(",
"self",
",",
"connect",
",",
"collection",
")",
":",
"vectors",
"=",
"gen_vector",
"(",
"nb",
",",
"dim",
")",
"status",
",",
"ids",
"=",
"connect",
".",
"insert",
"(",
"collection",
",",
"vectors",
")",
"assert",
"... | [
43,
4
] | [
61,
23
] | python | en | ['en', 'error', 'th'] | False |
TestWalBase.test_wal_invalid_operation | (self, connect, collection) |
target: invalid operation in WAL
method: add vectors, delete with non-existent ids and flush when WAL is enabled
expected: status ok, search with vector have result
|
target: invalid operation in WAL
method: add vectors, delete with non-existent ids and flush when WAL is enabled
expected: status ok, search with vector have result
| def test_wal_invalid_operation(self, connect, collection):
'''
target: invalid operation in WAL
method: add vectors, delete with non-existent ids and flush when WAL is enabled
expected: status ok, search with vector have result
'''
vector = gen_single_vector(dim)
... | [
"def",
"test_wal_invalid_operation",
"(",
"self",
",",
"connect",
",",
"collection",
")",
":",
"vector",
"=",
"gen_single_vector",
"(",
"dim",
")",
"status",
",",
"ids",
"=",
"connect",
".",
"insert",
"(",
"collection",
",",
"vector",
")",
"assert",
"status"... | [
64,
4
] | [
79,
23
] | python | en | ['en', 'error', 'th'] | False |
TestWalBase.test_wal_invalid_operation_B | (self, connect, collection) |
target: invalid operation in WAL
method: add vectors, delete with not existed collection name when WAL is enabled
expected: status not ok
|
target: invalid operation in WAL
method: add vectors, delete with not existed collection name when WAL is enabled
expected: status not ok
| def test_wal_invalid_operation_B(self, connect, collection):
'''
target: invalid operation in WAL
method: add vectors, delete with not existed collection name when WAL is enabled
expected: status not ok
'''
vectors = gen_vector(nb, dim)
status, ids = connect.inser... | [
"def",
"test_wal_invalid_operation_B",
"(",
"self",
",",
"connect",
",",
"collection",
")",
":",
"vectors",
"=",
"gen_vector",
"(",
"nb",
",",
"dim",
")",
"status",
",",
"ids",
"=",
"connect",
".",
"insert",
"(",
"collection",
",",
"vectors",
")",
"assert"... | [
82,
4
] | [
101,
24
] | python | en | ['en', 'error', 'th'] | False |
TestWalBase.test_wal_server_crashed_recovery | (self, connect, collection) |
target: test wal when server crashed unexpectedly and restarted
method: add vectors, server killed before flush, restarted server and flush
expected: status ok, add request is recovered and vectors added
|
target: test wal when server crashed unexpectedly and restarted
method: add vectors, server killed before flush, restarted server and flush
expected: status ok, add request is recovered and vectors added
| def test_wal_server_crashed_recovery(self, connect, collection):
'''
target: test wal when server crashed unexpectedly and restarted
method: add vectors, server killed before flush, restarted server and flush
expected: status ok, add request is recovered and vectors added
'''
... | [
"def",
"test_wal_server_crashed_recovery",
"(",
"self",
",",
"connect",
",",
"collection",
")",
":",
"vector",
"=",
"gen_single_vector",
"(",
"dim",
")",
"status",
",",
"ids",
"=",
"connect",
".",
"insert",
"(",
"collection",
",",
"vector",
")",
"assert",
"s... | [
104,
4
] | [
128,
46
] | python | en | ['en', 'error', 'th'] | False |
eval_fhmap | (cfg: EvalFhmapConfig) | Evalutate Fourier heat map. The result is saved under outpus/eval_fhmap.
Note:
Currently, we only supports the input of even-sized images.
Args:
cfg (EvalFhmapConfig): The config of Fourier heat map evaluation.
| Evalutate Fourier heat map. The result is saved under outpus/eval_fhmap. | def eval_fhmap(cfg: EvalFhmapConfig) -> None:
"""Evalutate Fourier heat map. The result is saved under outpus/eval_fhmap.
Note:
Currently, we only supports the input of even-sized images.
Args:
cfg (EvalFhmapConfig): The config of Fourier heat map evaluation.
"""
# Make config rea... | [
"def",
"eval_fhmap",
"(",
"cfg",
":",
"EvalFhmapConfig",
")",
"->",
"None",
":",
"# Make config read only.",
"# without this, config values might be changed accidentally.",
"OmegaConf",
".",
"set_readonly",
"(",
"cfg",
",",
"True",
")",
"# type: ignore",
"logger",
".",
... | [
65,
0
] | [
112,
5
] | python | en | ['en', 'en', 'en'] | True |
UvwConan._required_EXACT_libuv_version | (self) | Return *EXACT* libuv version to use with this uvw library | Return *EXACT* libuv version to use with this uvw library | def _required_EXACT_libuv_version(self):
""" Return *EXACT* libuv version to use with this uvw library """
match = re.match(r".*libuv[_-]v([0-9]+\.[0-9]+).*", self.conan_data["sources"][self.version]["url"])
if not match:
raise ConanException("uvw recipe does not know what version of... | [
"def",
"_required_EXACT_libuv_version",
"(",
"self",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r\".*libuv[_-]v([0-9]+\\.[0-9]+).*\"",
",",
"self",
".",
"conan_data",
"[",
"\"sources\"",
"]",
"[",
"self",
".",
"version",
"]",
"[",
"\"url\"",
"]",
")",
... | [
49,
4
] | [
54,
44
] | python | en | ['en', 'en', 'en'] | True |
privilege_granted_directly_or_via_role | (self, node=None) | Check that user is only able to execute CREATE TEMPORARY TABLE when they have required privilege, either directly or via role.
| Check that user is only able to execute CREATE TEMPORARY TABLE 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 TEMPORARY TABLE 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.conte... | [
"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"):
temp_table_name = f"temp_table_{getuid()}"
... | [
"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
] | [
114,
79
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1", stress=None, parallel=None) | Check the RBAC functionality of CREATE TEMPORARY TABLE.
| Check the RBAC functionality of CREATE TEMPORARY TABLE.
| def feature(self, node="clickhouse1", stress=None, parallel=None):
"""Check the RBAC functionality of CREATE TEMPORARY TABLE.
"""
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 ... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
",",
"stress",
"=",
"None",
",",
"parallel",
"=",
"None",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
... | [
123,
0
] | [
134,
48
] | python | en | ['en', 'en', 'en'] | True |
pushd | (directory: str) | A with-context that encapsulates pushd/popd. | A with-context that encapsulates pushd/popd. | def pushd(directory: str) -> Iterator[str]:
"""A with-context that encapsulates pushd/popd."""
cwd = os.getcwd()
os.chdir(directory)
try:
yield directory
finally:
os.chdir(cwd) | [
"def",
"pushd",
"(",
"directory",
":",
"str",
")",
"->",
"Iterator",
"[",
"str",
"]",
":",
"cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"directory",
")",
"try",
":",
"yield",
"directory",
"finally",
":",
"os",
".",
"chdir",
... | [
8,
0
] | [
15,
21
] | python | en | ['en', 'en', 'en'] | True |
find_names | (node) | Return the unique :class:`ast.Name` instances in an AST.
Parameters
----------
node : ast.AST
Returns
-------
unique_names : List[ast.Name]
Examples
--------
>>> import ast
>>> node = ast.parse('a + b')
>>> names = find_names(node)
>>> names # doctest: +ELLIPSIS
[... | Return the unique :class:`ast.Name` instances in an AST. | def find_names(node):
"""Return the unique :class:`ast.Name` instances in an AST.
Parameters
----------
node : ast.AST
Returns
-------
unique_names : List[ast.Name]
Examples
--------
>>> import ast
>>> node = ast.parse('a + b')
>>> names = find_names(node)
>>> name... | [
"def",
"find_names",
"(",
"node",
")",
":",
"return",
"list",
"(",
"toolz",
".",
"unique",
"(",
"filter",
"(",
"None",
",",
"NameFinder",
"(",
")",
".",
"find",
"(",
"node",
")",
")",
",",
"key",
"=",
"lambda",
"node",
":",
"(",
"node",
".",
"id"... | [
43,
0
] | [
69,
6
] | python | en | ['en', 'en', 'en'] | True |
check_output | (*popenargs, **kwargs) | r"""Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
>>> check_output(['/usr/bin/python', '--version'])
Python 2.6.2
| r"""Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
>>> check_output(['/usr/bin/python', '--version'])
Python 2.6.2
| def check_output(*popenargs, **kwargs):
r"""Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
>>> check_output(['/usr/bin/python', '--version'])
Python 2.6.2
"""
process = subprocess.Popen(stdout=subprocess.PIPE, *pope... | [
"def",
"check_output",
"(",
"*",
"popenargs",
",",
"*",
"*",
"kwargs",
")",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"*",
"popenargs",
",",
"*",
"*",
"kwargs",
")",
"output",
",",
"_",
"=",
... | [
42,
0
] | [
58,
15
] | python | en | ['en', 'en', 'en'] | True |
get_repo_dir | () | Return the path to the top of the repo. | Return the path to the top of the repo. | def get_repo_dir():
""" Return the path to the top of the repo. """
dirname, _ = os.path.split(os.path.abspath(__file__))
return os.path.join(dirname, "../..") | [
"def",
"get_repo_dir",
"(",
")",
":",
"dirname",
",",
"_",
"=",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"dirname",
",",
"\"../..\"",
")"
] | [
60,
0
] | [
63,
39
] | python | en | ['en', 'en', 'en'] | True |
get_scratch_dir | () | Return the path to the scratch dir that we build within. | Return the path to the scratch dir that we build within. | def get_scratch_dir():
""" Return the path to the scratch dir that we build within. """
scratch_dir = os.path.join(get_repo_dir(), "target", "compat-check")
if not os.path.exists(scratch_dir):
os.makedirs(scratch_dir)
return scratch_dir | [
"def",
"get_scratch_dir",
"(",
")",
":",
"scratch_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"get_repo_dir",
"(",
")",
",",
"\"target\"",
",",
"\"compat-check\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"scratch_dir",
")",
":",
"o... | [
65,
0
] | [
70,
20
] | python | en | ['en', 'en', 'en'] | True |
get_java_acc_dir | () | Return the path where we check out the Java API Compliance Checker. | Return the path where we check out the Java API Compliance Checker. | def get_java_acc_dir():
""" Return the path where we check out the Java API Compliance Checker. """
return os.path.join(get_repo_dir(), "target", "java-acc") | [
"def",
"get_java_acc_dir",
"(",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"get_repo_dir",
"(",
")",
",",
"\"target\"",
",",
"\"java-acc\"",
")"
] | [
72,
0
] | [
74,
59
] | python | en | ['en', 'en', 'en'] | True |
clean_scratch_dir | (scratch_dir) | Clean up and re-create the scratch directory. | Clean up and re-create the scratch directory. | def clean_scratch_dir(scratch_dir):
""" Clean up and re-create the scratch directory. """
if os.path.exists(scratch_dir):
logging.info("Removing scratch dir %s...", scratch_dir)
shutil.rmtree(scratch_dir)
logging.info("Creating empty scratch dir %s...", scratch_dir)
os.makedirs(scratch_dir) | [
"def",
"clean_scratch_dir",
"(",
"scratch_dir",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"scratch_dir",
")",
":",
"logging",
".",
"info",
"(",
"\"Removing scratch dir %s...\"",
",",
"scratch_dir",
")",
"shutil",
".",
"rmtree",
"(",
"scratch_dir",... | [
77,
0
] | [
83,
26
] | python | en | ['en', 'en', 'en'] | True |
checkout_java_tree | (rev, path) | Check out the Java source tree for the given revision into
the given path. | Check out the Java source tree for the given revision into
the given path. | def checkout_java_tree(rev, path):
""" Check out the Java source tree for the given revision into
the given path. """
logging.info("Checking out %s in %s", rev, path)
os.makedirs(path)
# Extract java source
subprocess.check_call(["bash", '-o', 'pipefail', "-c",
("git archive --forma... | [
"def",
"checkout_java_tree",
"(",
"rev",
",",
"path",
")",
":",
"logging",
".",
"info",
"(",
"\"Checking out %s in %s\"",
",",
"rev",
",",
"path",
")",
"os",
".",
"makedirs",
"(",
"path",
")",
"# Extract java source",
"subprocess",
".",
"check_call",
"(",
"[... | [
86,
0
] | [
95,
43
] | python | en | ['en', 'en', 'en'] | True |
get_git_hash | (revname) | Convert 'revname' to its SHA-1 hash. | Convert 'revname' to its SHA-1 hash. | def get_git_hash(revname):
""" Convert 'revname' to its SHA-1 hash. """
return check_output(["git", "rev-parse", revname],
cwd=get_repo_dir()).strip() | [
"def",
"get_git_hash",
"(",
"revname",
")",
":",
"return",
"check_output",
"(",
"[",
"\"git\"",
",",
"\"rev-parse\"",
",",
"revname",
"]",
",",
"cwd",
"=",
"get_repo_dir",
"(",
")",
")",
".",
"strip",
"(",
")"
] | [
97,
0
] | [
100,
49
] | python | en | ['en', 'ca', 'en'] | True |
get_repo_name | () | Get the name of the repo based on the git remote. | Get the name of the repo based on the git remote. | def get_repo_name():
"""Get the name of the repo based on the git remote."""
remotes = check_output(["git", "remote", "-v"],
cwd=get_repo_dir()).strip().split("\n")
# Example output:
# origin https://github.com/apache/hadoop.git (fetch)
# origin https://github.com/apache/hadoop.git (p... | [
"def",
"get_repo_name",
"(",
")",
":",
"remotes",
"=",
"check_output",
"(",
"[",
"\"git\"",
",",
"\"remote\"",
",",
"\"-v\"",
"]",
",",
"cwd",
"=",
"get_repo_dir",
"(",
")",
")",
".",
"strip",
"(",
")",
".",
"split",
"(",
"\"\\n\"",
")",
"# Example out... | [
102,
0
] | [
113,
15
] | python | en | ['en', 'en', 'en'] | True |
build_tree | (java_path) | Run the Java build within 'path'. | Run the Java build within 'path'. | def build_tree(java_path):
""" Run the Java build within 'path'. """
logging.info("Building in %s...", java_path)
subprocess.check_call(["mvn", "-DskipTests", "-Dmaven.javadoc.skip=true",
"package"],
cwd=java_path) | [
"def",
"build_tree",
"(",
"java_path",
")",
":",
"logging",
".",
"info",
"(",
"\"Building in %s...\"",
",",
"java_path",
")",
"subprocess",
".",
"check_call",
"(",
"[",
"\"mvn\"",
",",
"\"-DskipTests\"",
",",
"\"-Dmaven.javadoc.skip=true\"",
",",
"\"package\"",
"]... | [
115,
0
] | [
120,
38
] | python | en | ['en', 'en', 'en'] | True |
checkout_java_acc | (force) |
Check out the Java API Compliance Checker. If 'force' is true, will
re-download even if the directory exists.
|
Check out the Java API Compliance Checker. If 'force' is true, will
re-download even if the directory exists.
| def checkout_java_acc(force):
"""
Check out the Java API Compliance Checker. If 'force' is true, will
re-download even if the directory exists.
"""
acc_dir = get_java_acc_dir()
if os.path.exists(acc_dir):
logging.info("Java ACC is already downloaded.")
if not force:
return
logging.info("Fo... | [
"def",
"checkout_java_acc",
"(",
"force",
")",
":",
"acc_dir",
"=",
"get_java_acc_dir",
"(",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"acc_dir",
")",
":",
"logging",
".",
"info",
"(",
"\"Java ACC is already downloaded.\"",
")",
"if",
"not",
"force",... | [
123,
0
] | [
149,
36
] | python | en | ['en', 'error', 'th'] | False |
find_jars | (path) | Return a list of jars within 'path' to be checked for compatibility. | Return a list of jars within 'path' to be checked for compatibility. | def find_jars(path):
""" Return a list of jars within 'path' to be checked for compatibility. """
all_jars = set(check_output(["find", path, "-name", "*.jar"]).splitlines())
return [j for j in all_jars if (
"-tests" not in j and
"-sources" not in j and
"-with-dependencies" not in j)] | [
"def",
"find_jars",
"(",
"path",
")",
":",
"all_jars",
"=",
"set",
"(",
"check_output",
"(",
"[",
"\"find\"",
",",
"path",
",",
"\"-name\"",
",",
"\"*.jar\"",
"]",
")",
".",
"splitlines",
"(",
")",
")",
"return",
"[",
"j",
"for",
"j",
"in",
"all_jars... | [
152,
0
] | [
159,
37
] | python | en | ['en', 'en', 'en'] | True |
write_xml_file | (path, version, jars) | Write the XML manifest file for JACC. | Write the XML manifest file for JACC. | def write_xml_file(path, version, jars):
"""Write the XML manifest file for JACC."""
with open(path, "wt") as f:
f.write("<version>" + version + "</version>\n")
f.write("<archives>")
for j in jars:
f.write(j + "\n")
f.write("</archives>") | [
"def",
"write_xml_file",
"(",
"path",
",",
"version",
",",
"jars",
")",
":",
"with",
"open",
"(",
"path",
",",
"\"wt\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"\"<version>\"",
"+",
"version",
"+",
"\"</version>\\n\"",
")",
"f",
".",
"write",
"... | [
161,
0
] | [
168,
26
] | python | en | ['en', 'en', 'en'] | True |
run_java_acc | (src_name, src_jars, dst_name, dst_jars, annotations) | Run the compliance checker to compare 'src' and 'dst'. | Run the compliance checker to compare 'src' and 'dst'. | def run_java_acc(src_name, src_jars, dst_name, dst_jars, annotations):
""" Run the compliance checker to compare 'src' and 'dst'. """
logging.info("Will check compatibility between original jars:\n\t%s\n" +
"and new jars:\n\t%s",
"\n\t".join(src_jars),
"\n\t".join(dst_ja... | [
"def",
"run_java_acc",
"(",
"src_name",
",",
"src_jars",
",",
"dst_name",
",",
"dst_jars",
",",
"annotations",
")",
":",
"logging",
".",
"info",
"(",
"\"Will check compatibility between original jars:\\n\\t%s\\n\"",
"+",
"\"and new jars:\\n\\t%s\"",
",",
"\"\\n\\t\"",
"... | [
170,
0
] | [
199,
29
] | python | en | ['en', 'en', 'en'] | True |
filter_jars | (jars, include_filters, exclude_filters) | Filter the list of JARs based on include and exclude filters. | Filter the list of JARs based on include and exclude filters. | def filter_jars(jars, include_filters, exclude_filters):
"""Filter the list of JARs based on include and exclude filters."""
filtered = []
# Apply include filters
for j in jars:
found = False
basename = os.path.basename(j)
for f in include_filters:
if f.match(basename):
found = True
... | [
"def",
"filter_jars",
"(",
"jars",
",",
"include_filters",
",",
"exclude_filters",
")",
":",
"filtered",
"=",
"[",
"]",
"# Apply include filters",
"for",
"j",
"in",
"jars",
":",
"found",
"=",
"False",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(... | [
201,
0
] | [
230,
25
] | python | en | ['en', 'en', 'en'] | True |
main | () | Main function. | Main function. | def main():
"""Main function."""
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser(
description="Run Java API Compliance Checker.")
parser.add_argument("-f", "--force-download",
action="store_true",
help="Download dependencies (i.e. Java J... | [
"def",
"main",
"(",
")",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Run Java API Compliance Checker.\"",
")",
"parser",
".",
"add_argument",
... | [
233,
0
] | [
340,
46
] | python | en | ['en', 'ja', 'en'] | False |
privileges_granted_directly | (self, node=None) | Check that a user is able to execute `DROP ROW POLICY` with privileges are granted directly.
| Check that a user is able to execute `DROP ROW POLICY` with privileges are granted directly.
| def privileges_granted_directly(self, node=None):
"""Check that a user is able to execute `DROP ROW POLICY` 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=drop_row_polic... | [
"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_... | [
8,
0
] | [
22,
74
] | python | en | ['en', 'en', 'en'] | True |
privileges_granted_via_role | (self, node=None) | Check that a user is able to execute `DROP ROW POLICY` with privileges are granted through a role.
| Check that a user is able to execute `DROP ROW POLICY` with privileges are granted through a role.
| def privileges_granted_via_role(self, node=None):
"""Check that a user is able to execute `DROP ROW POLICY` 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_n... | [
"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"... | [
25,
0
] | [
43,
74
] | python | en | ['en', 'en', 'en'] | True |
drop_row_policy | (self, privilege, grant_target_name, user_name, node=None) | Check that user is only able to execute `DROP ROW POLICY` when they have the necessary privilege.
| Check that user is only able to execute `DROP ROW POLICY` when they have the necessary privilege.
| def drop_row_policy(self, privilege, grant_target_name, user_name, node=None):
"""Check that user is only able to execute `DROP 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",
"drop_row_policy",
"(",
"self",
",",
"privilege",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"user_name",
")",
"if",
"node"... | [
52,
0
] | [
137,
95
] | python | en | ['en', 'en', 'en'] | True |
drop_all_pol_with_conditions | (self, node=None) | Check that when all policies with conditions are dropped, the table becomes unrestricted.
| Check that when all policies with conditions are dropped, the table becomes unrestricted.
| def drop_all_pol_with_conditions(self, node=None):
"""Check that when all policies with conditions are dropped, the table becomes unrestricted.
"""
if node is None:
node = self.context.node
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
with table(node, table_name):
... | [
"def",
"drop_all_pol_with_conditions",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"with... | [
143,
0
] | [
173,
59
] | python | en | ['en', 'en', 'en'] | True |
drop_on | (self, node=None) | Check that when a row policy is dropped, users are able to access rows restricted by that policy.
| Check that when a row policy is dropped, users are able to access rows restricted by that policy.
| def drop_on(self, node=None):
"""Check that when a row policy is dropped, users are able to access rows restricted by that policy.
"""
if node is None:
node = self.context.node
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
with table(node, table_name):
with Gi... | [
"def",
"drop_on",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"with",
"table",
"(",
... | [
179,
0
] | [
209,
59
] | python | en | ['en', 'en', 'en'] | True |
drop_on_cluster | (self, node=None) | Check that when a row policy is dropped on a cluster, it works on all nodes.
| Check that when a row policy is dropped on a cluster, it works on all nodes.
| def drop_on_cluster(self, node=None):
"""Check that when a row policy is dropped on a cluster, it works on all nodes.
"""
if node is None:
node = self.context.node
node2 = self.context.node2
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
try:
with Given(... | [
"def",
"drop_on_cluster",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"node2",
"=",
"self",
".",
"context",
".",
"node2",
"table_name",
"=",
"f\"table_{getuid()}\"",
... | [
215,
0
] | [
255,
77
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1") | Check the RBAC functionality of DROP ROW POLICY.
| Check the RBAC functionality of DROP ROW POLICY.
| def feature(self, node="clickhouse1"):
"""Check the RBAC functionality of DROP ROW POLICY.
"""
self.context.node = self.context.cluster.node(node)
self.context.node2 = self.context.cluster.node("clickhouse2")
Suite(run=privileges_granted_directly, setup=instrument_clickhouse_server_log)
Suite(r... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
"self",
".",
"context",
".",
"node2",
"=",
"self",
".",
"... | [
264,
0
] | [
275,
73
] | python | en | ['en', 'en', 'en'] | True |
reassign_centroids | (hassign, centroids, rs=None) | reassign centroids when some of them collapse | reassign centroids when some of them collapse | def reassign_centroids(hassign, centroids, rs=None):
""" reassign centroids when some of them collapse """
if rs is None:
rs = np.random
k, d = centroids.shape
nsplit = 0
empty_cents = np.where(hassign == 0)[0]
if empty_cents.size == 0:
return 0
fac = np.ones(d)
fac[::2... | [
"def",
"reassign_centroids",
"(",
"hassign",
",",
"centroids",
",",
"rs",
"=",
"None",
")",
":",
"if",
"rs",
"is",
"None",
":",
"rs",
"=",
"np",
".",
"random",
"k",
",",
"d",
"=",
"centroids",
".",
"shape",
"nsplit",
"=",
"0",
"empty_cents",
"=",
"... | [
142,
0
] | [
181,
17
] | python | en | ['en', 'en', 'en'] | True |
kmeans | (k, data, niter=25, seed=1234, checkpoint=None) | Pure python kmeans implementation. Follows the Faiss C++ version
quite closely, but takes a DatasetAssign instead of a training data
matrix. Also redo is not implemented. | Pure python kmeans implementation. Follows the Faiss C++ version
quite closely, but takes a DatasetAssign instead of a training data
matrix. Also redo is not implemented. | def kmeans(k, data, niter=25, seed=1234, checkpoint=None):
"""Pure python kmeans implementation. Follows the Faiss C++ version
quite closely, but takes a DatasetAssign instead of a training data
matrix. Also redo is not implemented. """
n, d = data.count(), data.dim()
print(("Clustering %d points i... | [
"def",
"kmeans",
"(",
"k",
",",
"data",
",",
"niter",
"=",
"25",
",",
"seed",
"=",
"1234",
",",
"checkpoint",
"=",
"None",
")",
":",
"n",
",",
"d",
"=",
"data",
".",
"count",
"(",
")",
",",
"data",
".",
"dim",
"(",
")",
"print",
"(",
"(",
"... | [
184,
0
] | [
238,
20
] | python | en | ['en', 'fr', 'en'] | True |
regression | (self, local, clickhouse_binary_path, stress=None, parallel=None) | ClickHouse LDAP external user directory regression module.
| ClickHouse LDAP external user directory regression module.
| def regression(self, local, clickhouse_binary_path, stress=None, parallel=None):
"""ClickHouse LDAP external user directory regression module.
"""
top().terminating = False
nodes = {
"clickhouse": ("clickhouse1", "clickhouse2", "clickhouse3"),
}
if stress is not None:
self.conte... | [
"def",
"regression",
"(",
"self",
",",
"local",
",",
"clickhouse_binary_path",
",",
"stress",
"=",
"None",
",",
"parallel",
"=",
"None",
")",
":",
"top",
"(",
")",
".",
"terminating",
"=",
"False",
"nodes",
"=",
"{",
"\"clickhouse\"",
":",
"(",
"\"clickh... | [
39,
0
] | [
63,
80
] | python | en | ['en', 'lb', 'en'] | True |
serve | (model, port=16118, debug=True, **fit_kwargs) |
:param model: Sklearn-compatible model, that is pickleable and has interface for .fit(X, y) and .predict_proba(X)
:param port: specify localhost port where the model will be served
:param debug: whether to start at debug mode
:return:
|
:param model: Sklearn-compatible model, that is pickleable and has interface for .fit(X, y) and .predict_proba(X)
:param port: specify localhost port where the model will be served
:param debug: whether to start at debug mode
:return:
| def serve(model, port=16118, debug=True, **fit_kwargs):
"""
:param model: Sklearn-compatible model, that is pickleable and has interface for .fit(X, y) and .predict_proba(X)
:param port: specify localhost port where the model will be served
:param debug: whether to start at debug mode
:return:
"... | [
"def",
"serve",
"(",
"model",
",",
"port",
"=",
"16118",
",",
"debug",
"=",
"True",
",",
"*",
"*",
"fit_kwargs",
")",
":",
"init_model_server",
"(",
"create_model_func",
"=",
"partial",
"(",
"SklearnTextClassifier",
",",
"model",
"=",
"model",
")",
",",
... | [
61,
0
] | [
77,
53
] | python | en | ['en', 'error', 'th'] | False |
convert_im_to_float | (im) | r"""Convert image from saved data type to float
Images are saved as either 8 or 16 bit integers, and for our
purposes we generally want them to be floats that lie between 0 and
1. In order to properly convert them, we divide the image by the
maximum value its dtype can take (255 for 8 bit, 65535 for 16... | r"""Convert image from saved data type to float | def convert_im_to_float(im):
r"""Convert image from saved data type to float
Images are saved as either 8 or 16 bit integers, and for our
purposes we generally want them to be floats that lie between 0 and
1. In order to properly convert them, we divide the image by the
maximum value its dtype can ... | [
"def",
"convert_im_to_float",
"(",
"im",
")",
":",
"return",
"im",
"/",
"np",
".",
"iinfo",
"(",
"im",
".",
"dtype",
")",
".",
"max"
] | [
17,
0
] | [
41,
38
] | python | en | ['en', 'en', 'en'] | True |
convert_im_to_int | (im, dtype=np.uint8) | r"""Convert image from float to 8 or 16 bit image
We work with float images that lie between 0 and 1, but for saving
them (either as png or in a numpy array), we want to convert them to
8 or 16 bit integers. This function does that by multiplying it by
the max value for the target dtype (255 for 8 bit ... | r"""Convert image from float to 8 or 16 bit image | def convert_im_to_int(im, dtype=np.uint8):
r"""Convert image from float to 8 or 16 bit image
We work with float images that lie between 0 and 1, but for saving
them (either as png or in a numpy array), we want to convert them to
8 or 16 bit integers. This function does that by multiplying it by
the... | [
"def",
"convert_im_to_int",
"(",
"im",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
":",
"if",
"im",
".",
"max",
"(",
")",
">",
"1",
":",
"if",
"im",
".",
"max",
"(",
")",
"-",
"1",
"<",
"1e-4",
":",
"warnings",
".",
"warn",
"(",
"\"There was a ... | [
44,
0
] | [
83,
51
] | python | en | ['en', 'en', 'en'] | True |
get_gpu_id | (get_gid=True, n_gpus=4, on_cluster=False) | get next available GPU and lock it
Note that the lock file created will be at
/tmp/LCK_gpu_{allocated_gid}.lock
This is based on the solution proposed at
https://github.com/snakemake/snakemake/issues/281#issuecomment-610796104
and then modified slightly
Parameters
----------
get_gid :... | get next available GPU and lock it | def get_gpu_id(get_gid=True, n_gpus=4, on_cluster=False):
"""get next available GPU and lock it
Note that the lock file created will be at
/tmp/LCK_gpu_{allocated_gid}.lock
This is based on the solution proposed at
https://github.com/snakemake/snakemake/issues/281#issuecomment-610796104
and th... | [
"def",
"get_gpu_id",
"(",
"get_gid",
"=",
"True",
",",
"n_gpus",
"=",
"4",
",",
"on_cluster",
"=",
"False",
")",
":",
"allocated_gid",
"=",
"None",
"if",
"not",
"get_gid",
":",
"avail_gpus",
"=",
"[",
"]",
"else",
":",
"avail_gpus",
"=",
"GPUtil",
".",... | [
87,
0
] | [
134,
70
] | python | en | ['en', 'en', 'en'] | True |
_find_img_size | (image_name) | use regex to grab size from image_name
We look for the pattern "_size-([0-9]+,[0-9]+)", grab the first one,
and will raise an exception if no matches are found
Parameters
----------
image_name : str
name of the reference image, as used in the Snakefile. will contain the
base image,... | use regex to grab size from image_name | def _find_img_size(image_name):
"""use regex to grab size from image_name
We look for the pattern "_size-([0-9]+,[0-9]+)", grab the first one,
and will raise an exception if no matches are found
Parameters
----------
image_name : str
name of the reference image, as used in the Snakefil... | [
"def",
"_find_img_size",
"(",
"image_name",
")",
":",
"image_size",
"=",
"re",
".",
"findall",
"(",
"\"_size-([0-9]+,[0-9]+)\"",
",",
"image_name",
")",
"[",
"0",
"]",
"return",
"np",
".",
"array",
"(",
"image_size",
".",
"split",
"(",
"','",
")",
")",
"... | [
137,
0
] | [
156,
54
] | python | en | ['en', 'en', 'en'] | True |
find_attempts | (wildcards, increment=False, extra_iter=None, gpu_split=.09) | Find most recently-generated metamer with specified wilcards.
We allow for the possibility of continuing metamer synthesis, and so need a
way to find the last synthesis attempt. This uses the wildcards dictionary
(which specifies the desired metamer) and searches for the existing metamer
with the highe... | Find most recently-generated metamer with specified wilcards. | def find_attempts(wildcards, increment=False, extra_iter=None, gpu_split=.09):
"""Find most recently-generated metamer with specified wilcards.
We allow for the possibility of continuing metamer synthesis, and so need a
way to find the last synthesis attempt. This uses the wildcards dictionary
(which s... | [
"def",
"find_attempts",
"(",
"wildcards",
",",
"increment",
"=",
"False",
",",
"extra_iter",
"=",
"None",
",",
"gpu_split",
"=",
".09",
")",
":",
"with",
"open",
"(",
"op",
".",
"join",
"(",
"op",
".",
"dirname",
"(",
"op",
".",
"realpath",
"(",
"__f... | [
159,
0
] | [
239,
41
] | python | en | ['en', 'en', 'en'] | True |
get_ref_image_full_path | (image_name,
preproc_methods=['full', 'gamma-corrected',
'range', 'degamma',
'downsample'],
downsample=False) | check whether image is in ref_image or ref_image_preproc dir
Parameters
----------
image_name : str
name of the (e.g., like those seen in `config.yml:
DEFAULT_METAMERS: image_name`)
preproc_methods : list, optional
list of preproc methods we may have applied. probably shouldn't
... | check whether image is in ref_image or ref_image_preproc dir | def get_ref_image_full_path(image_name,
preproc_methods=['full', 'gamma-corrected',
'range', 'degamma',
'downsample'],
downsample=False):
"""check whether image is in ref... | [
"def",
"get_ref_image_full_path",
"(",
"image_name",
",",
"preproc_methods",
"=",
"[",
"'full'",
",",
"'gamma-corrected'",
",",
"'range'",
",",
"'degamma'",
",",
"'downsample'",
"]",
",",
"downsample",
"=",
"False",
")",
":",
"with",
"open",
"(",
"op",
".",
... | [
242,
0
] | [
289,
48
] | python | en | ['en', 'en', 'en'] | True |
get_gamma_corrected_ref_image | (image_name) | get name of gamma-corrected reference image
Parameters
----------
image_name : str
name of the (e.g., like those seen in `config.yml:
DEFAULT_METAMERS: image_name`)
Returns
-------
path : str
full path to the gamma-corrected reference image
| get name of gamma-corrected reference image | def get_gamma_corrected_ref_image(image_name):
"""get name of gamma-corrected reference image
Parameters
----------
image_name : str
name of the (e.g., like those seen in `config.yml:
DEFAULT_METAMERS: image_name`)
Returns
-------
path : str
full path to the gamma-c... | [
"def",
"get_gamma_corrected_ref_image",
"(",
"image_name",
")",
":",
"image_name",
"=",
"image_name",
".",
"split",
"(",
"'_'",
")",
"target_i",
"=",
"0",
"# these two are special: if either are present, we want gamma-corrected to",
"# be inserted right before it",
"if",
"any... | [
292,
0
] | [
322,
38
] | python | en | ['en', 'en', 'en'] | True |
generate_image_names | (ref_image=None, preproc=None, size=None) | Generate image names in a programmatic way
This generates image names, to be passed to
generate_metamer_paths. This is much more constrained than that
template-following, as we only allow three fields: ref_image,
preproc, and size. The template path is `IMAGE_NAME: template`, as
found in config.yml... | Generate image names in a programmatic way | def generate_image_names(ref_image=None, preproc=None, size=None):
"""Generate image names in a programmatic way
This generates image names, to be passed to
generate_metamer_paths. This is much more constrained than that
template-following, as we only allow three fields: ref_image,
preproc, and siz... | [
"def",
"generate_image_names",
"(",
"ref_image",
"=",
"None",
",",
"preproc",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"with",
"open",
"(",
"op",
".",
"join",
"(",
"op",
".",
"dirname",
"(",
"op",
".",
"realpath",
"(",
"__file__",
")",
")",
... | [
325,
0
] | [
364,
22
] | python | en | ['en', 'en', 'en'] | True |
generate_metamer_seeds_dict | (model_name) | Generate dictionary giving mapping to random seed.
For each (model_name, image, scaling), we want unique seeds. This generates a
dictionary that does that in a reasonable manner: the model must be
specified, and it has (image, scaling) as keys (based on the config.yml
file), with lists of n_seeds possi... | Generate dictionary giving mapping to random seed. | def generate_metamer_seeds_dict(model_name):
"""Generate dictionary giving mapping to random seed.
For each (model_name, image, scaling), we want unique seeds. This generates a
dictionary that does that in a reasonable manner: the model must be
specified, and it has (image, scaling) as keys (based on t... | [
"def",
"generate_metamer_seeds_dict",
"(",
"model_name",
")",
":",
"# separate each model_name by 1 million, image_name by 10k, each scaling value",
"# by 100, which allows us to have up to 100 images, 100 scaling vaules, 100",
"# seeds.",
"model_name_sep",
"=",
"1000000",
"image_name_sep",
... | [
367,
0
] | [
440,
16
] | python | en | ['en', 'en', 'en'] | True |
generate_natural_init | (image_name, scaling) | Generate the natural images to use for initialization in comp=ref-natural and met-natural.
Pick 3 other natural images to use for initializing this metamer. Seed is
based on image_name and scaling.
Parameters
----------
image_name : str
name of the (e.g., like those seen in `config.yml:
... | Generate the natural images to use for initialization in comp=ref-natural and met-natural. | def generate_natural_init(image_name, scaling):
"""Generate the natural images to use for initialization in comp=ref-natural and met-natural.
Pick 3 other natural images to use for initializing this metamer. Seed is
based on image_name and scaling.
Parameters
----------
image_name : str
... | [
"def",
"generate_natural_init",
"(",
"image_name",
",",
"scaling",
")",
":",
"with",
"open",
"(",
"op",
".",
"join",
"(",
"op",
".",
"dirname",
"(",
"op",
".",
"realpath",
"(",
"__file__",
")",
")",
",",
"'..'",
",",
"'config.yml'",
")",
")",
"as",
"... | [
443,
0
] | [
475,
64
] | python | en | ['en', 'en', 'en'] | True |
generate_metamer_paths | (model_name, increment=False, extra_iter=None,
gamma_corrected=False, comp='ref',
seed_n=None, **kwargs) | Generate metamer paths in a programmatic way
This generates paths to the metamer.png files found in the
metamer_display folder in a programmatic way. The intended use case
is to call this script from the command-line and pipe the output to
snakemake.
We use the values found in config.yml, which gi... | Generate metamer paths in a programmatic way | def generate_metamer_paths(model_name, increment=False, extra_iter=None,
gamma_corrected=False, comp='ref',
seed_n=None, **kwargs):
"""Generate metamer paths in a programmatic way
This generates paths to the metamer.png files found in the
metamer_displa... | [
"def",
"generate_metamer_paths",
"(",
"model_name",
",",
"increment",
"=",
"False",
",",
"extra_iter",
"=",
"None",
",",
"gamma_corrected",
"=",
"False",
",",
"comp",
"=",
"'ref'",
",",
"seed_n",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not... | [
478,
0
] | [
665,
16
] | python | en | ['en', 'af', 'en'] | True |
feature | (self, node="clickhouse1") | Check grant query syntax.
```sql
GRANT ON CLUSTER [cluster_name] role [,...] TO {user | another_role | CURRENT_USER} [,...] [WITH ADMIN OPTION]
```
| Check grant query syntax. | def feature(self, node="clickhouse1"):
"""Check grant query syntax.
```sql
GRANT ON CLUSTER [cluster_name] role [,...] TO {user | another_role | CURRENT_USER} [,...] [WITH ADMIN OPTION]
```
"""
node = self.context.cluster.node(node)
@contextmanager
def setup(users=0,roles=0):
t... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
")",
":",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
"@",
"contextmanager",
"def",
"setup",
"(",
"users",
"=",
"0",
",",
"roles",
"=",
"0",
... | [
10,
0
] | [
114,
110
] | python | en | ['fr', 'en', 'en'] | True |
simple_get | (url) |
Attempts to get the content at `url` by making an HTTP GET request.
If the content-type of response is some kind of HTML/XML, return the
text content, otherwise return None.
|
Attempts to get the content at `url` by making an HTTP GET request.
If the content-type of response is some kind of HTML/XML, return the
text content, otherwise return None.
| def simple_get(url):
"""
Attempts to get the content at `url` by making an HTTP GET request.
If the content-type of response is some kind of HTML/XML, return the
text content, otherwise return None.
"""
try:
with closing(get(url, stream=True)) as resp:
if is_good_response(res... | [
"def",
"simple_get",
"(",
"url",
")",
":",
"try",
":",
"with",
"closing",
"(",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
")",
")",
"as",
"resp",
":",
"if",
"is_good_response",
"(",
"resp",
")",
":",
"return",
"resp",
".",
"content",
"else",
":... | [
23,
0
] | [
38,
19
] | python | en | ['en', 'error', 'th'] | False |
is_good_response | (resp) |
Returns True if the response seems to be HTML, False otherwise.
|
Returns True if the response seems to be HTML, False otherwise.
| def is_good_response(resp):
"""
Returns True if the response seems to be HTML, False otherwise.
"""
content_type = resp.headers['Content-Type'].lower()
return (resp.status_code == 200
and content_type is not None
and content_type.find('html') > -1) | [
"def",
"is_good_response",
"(",
"resp",
")",
":",
"content_type",
"=",
"resp",
".",
"headers",
"[",
"'Content-Type'",
"]",
".",
"lower",
"(",
")",
"return",
"(",
"resp",
".",
"status_code",
"==",
"200",
"and",
"content_type",
"is",
"not",
"None",
"and",
... | [
41,
0
] | [
48,
47
] | python | en | ['en', 'error', 'th'] | False |
create_user_granted_directly | (self, node=None) | Check that a user is able to execute `CREATE USER` with privileges are granted directly.
| Check that a user is able to execute `CREATE USER` with privileges are granted directly.
| def create_user_granted_directly(self, node=None):
"""Check that a user is able to execute `CREATE USER` 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=create_user,
... | [
"def",
"create_user_granted_directly",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"user_name",
"=",
"f\"user_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"user",
"(",
"node",
",",
"f\"{user... | [
8,
0
] | [
22,
80
] | python | en | ['en', 'en', 'en'] | True |
create_user_granted_via_role | (self, node=None) | Check that a user is able to execute `CREATE USER` with privileges are granted through a role.
| Check that a user is able to execute `CREATE USER` with privileges are granted through a role.
| def create_user_granted_via_role(self, node=None):
"""Check that a user is able to execute `CREATE USER` 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_name... | [
"def",
"create_user_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... | [
25,
0
] | [
43,
80
] | python | en | ['en', 'en', 'en'] | True |
create_user | (self, privilege, grant_target_name, user_name, node=None) | Check that user is only able to execute `CREATE USER` when they have the necessary privilege.
| Check that user is only able to execute `CREATE USER` when they have the necessary privilege.
| def create_user(self, privilege, grant_target_name, user_name, node=None):
"""Check that user is only able to execute `CREATE USER` when they have the necessary privilege.
"""
exitcode, message = errors.not_enough_privileges(name=user_name)
if node is None:
node = self.context.node
with Sc... | [
"def",
"create_user",
"(",
"self",
",",
"privilege",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"user_name",
")",
"if",
"node",
... | [
51,
0
] | [
122,
69
] | python | en | ['en', 'en', 'en'] | True |
default_role_granted_directly | (self, node=None) | Check that a user is able to execute `CREATE USER` with `DEFAULT ROLE` with privileges are granted directly.
| Check that a user is able to execute `CREATE USER` with `DEFAULT ROLE` with privileges are granted directly.
| def default_role_granted_directly(self, node=None):
"""Check that a user is able to execute `CREATE USER` with `DEFAULT ROLE` 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(... | [
"def",
"default_role_granted_directly",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"user_name",
"=",
"f\"user_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"user",
"(",
"node",
",",
"f\"{use... | [
125,
0
] | [
136,
82
] | python | en | ['en', 'en', 'en'] | True |
default_role_granted_via_role | (self, node=None) | Check that a user is able to execute `CREATE USER` with `DEFAULT ROLE` with privileges are granted through a role.
| Check that a user is able to execute `CREATE USER` with `DEFAULT ROLE` with privileges are granted through a role.
| def default_role_granted_via_role(self, node=None):
"""Check that a user is able to execute `CREATE USER` with `DEFAULT ROLE` 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 us... | [
"def",
"default_role_granted_via_role",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"user_name",
"=",
"f\"user_{getuid()}\"",
"role_name",
"=",
"f\"role_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"wit... | [
139,
0
] | [
154,
82
] | python | en | ['en', 'en', 'en'] | True |
default_role | (self, grant_target_name, user_name, node=None) | Check that user is only able to execute `CREATE USER` with `DEFAULT ROLE` if and only if the user has
`CREATE USER` privilege and the role with `ADMIN OPTION`.
| Check that user is only able to execute `CREATE USER` with `DEFAULT ROLE` if and only if the user has
`CREATE USER` privilege and the role with `ADMIN OPTION`.
| def default_role(self, grant_target_name, user_name, node=None):
"""Check that user is only able to execute `CREATE USER` with `DEFAULT ROLE` if and only if the user has
`CREATE USER` privilege and the role with `ADMIN OPTION`.
"""
exitcode, message = errors.not_enough_privileges(name=user_name)
if... | [
"def",
"default_role",
"(",
"self",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"user_name",
")",
"if",
"node",
"is",
"None",
":"... | [
160,
0
] | [
267,
73
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1") | Check the RBAC functionality of CREATE USER.
| Check the RBAC functionality of CREATE USER.
| def feature(self, node="clickhouse1"):
"""Check the RBAC functionality of CREATE USER.
"""
self.context.node = self.context.cluster.node(node)
Suite(run=create_user_granted_directly, setup=instrument_clickhouse_server_log)
Suite(run=create_user_granted_via_role, setup=instrument_clickhouse_server_l... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
"Suite",
"(",
"run",
"=",
"create_user_granted_directly",
",",
... | [
276,
0
] | [
284,
84
] | python | en | ['en', 'en', 'en'] | True |
to_time_zone | (self) | Check the toTimeZone() function with DateTime64 extended range.
| Check the toTimeZone() function with DateTime64 extended range.
| def to_time_zone(self):
"""Check the toTimeZone() function with DateTime64 extended range.
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I select datetimes in {year}"):
datetimes = select_dates_in_year(year=yea... | [
"def",
"to_time_zone",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I select dat... | [
16,
0
] | [
37,
77
] | python | en | ['en', 'en', 'en'] | True |
to_date_part | (self, py_func, ch_func) | Check the toYear/toMonth/toQuarter functions with DateTime64 extended range.
| Check the toYear/toMonth/toQuarter functions with DateTime64 extended range.
| def to_date_part(self, py_func, ch_func):
"""Check the toYear/toMonth/toQuarter functions with DateTime64 extended range.
"""
stress = self.context.stress
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(year=year, stress... | [
"def",
"to_date_part",
"(",
"self",
",",
"py_func",
",",
"ch_func",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choose datetimes in {year}\"",
")",
... | [
41,
0
] | [
67,
77
] | python | en | ['en', 'en', 'en'] | True |
to_year | (self) | Check the toYear() and toRelativeYearNum() [which is just an alias for toYear]
function with DateTime64 extended range.
| Check the toYear() and toRelativeYearNum() [which is just an alias for toYear]
function with DateTime64 extended range.
| def to_year(self):
"""Check the toYear() and toRelativeYearNum() [which is just an alias for toYear]
function with DateTime64 extended range.
"""
to_date_part(py_func="year)", ch_func="toYear") | [
"def",
"to_year",
"(",
"self",
")",
":",
"to_date_part",
"(",
"py_func",
"=",
"\"year)\"",
",",
"ch_func",
"=",
"\"toYear\"",
")"
] | [
75,
0
] | [
79,
51
] | python | en | ['en', 'en', 'en'] | True |
to_month | (self) | Check the toMonth() function with DateTime64 extended range.
| Check the toMonth() function with DateTime64 extended range.
| def to_month(self):
"""Check the toMonth() function with DateTime64 extended range.
"""
to_date_part(py_func="month)", ch_func="toMonth") | [
"def",
"to_month",
"(",
"self",
")",
":",
"to_date_part",
"(",
"py_func",
"=",
"\"month)\"",
",",
"ch_func",
"=",
"\"toMonth\"",
")"
] | [
86,
0
] | [
89,
53
] | python | en | ['en', 'en', 'en'] | True |
to_quarter | (self) | Check the toQuarter() function with DateTime64 extended range
by comparing the output of the toQuarter() function with
the value of the 'month' attribute of the datetime object
divided by 3 (because each quarter has 3 month) plus 1
(because we starting the count from 1).
| Check the toQuarter() function with DateTime64 extended range
by comparing the output of the toQuarter() function with
the value of the 'month' attribute of the datetime object
divided by 3 (because each quarter has 3 month) plus 1
(because we starting the count from 1).
| def to_quarter(self):
"""Check the toQuarter() function with DateTime64 extended range
by comparing the output of the toQuarter() function with
the value of the 'month' attribute of the datetime object
divided by 3 (because each quarter has 3 month) plus 1
(because we starting the count from 1).
... | [
"def",
"to_quarter",
"(",
"self",
")",
":",
"to_date_part",
"(",
"py_func",
"=",
"\"month - 1)//3 + 1\"",
",",
"ch_func",
"=",
"\"toQuarter\"",
")"
] | [
96,
0
] | [
103,
66
] | python | en | ['en', 'en', 'en'] | True |
to_day_of | (self, py_func, ch_func) | Check the toDayOf....() functions with DateTime64 extended range.
| Check the toDayOf....() functions with DateTime64 extended range.
| def to_day_of(self, py_func, ch_func):
"""Check the toDayOf....() functions with DateTime64 extended range.
"""
stress = self.context.stress
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(year=year, stress=stress)
... | [
"def",
"to_day_of",
"(",
"self",
",",
"py_func",
",",
"ch_func",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choose datetimes in {year}\"",
")",
":... | [
107,
0
] | [
132,
77
] | python | en | ['en', 'en', 'en'] | True |
to_day_of_year | (self) | Check toDayOfYear() function with DateTime64 extended range date time.
| Check toDayOfYear() function with DateTime64 extended range date time.
| def to_day_of_year(self):
"""Check toDayOfYear() function with DateTime64 extended range date time.
"""
to_day_of(py_func="tm_yday", ch_func="toDayOfYear") | [
"def",
"to_day_of_year",
"(",
"self",
")",
":",
"to_day_of",
"(",
"py_func",
"=",
"\"tm_yday\"",
",",
"ch_func",
"=",
"\"toDayOfYear\"",
")"
] | [
139,
0
] | [
142,
55
] | python | en | ['en', 'en', 'en'] | True |
to_day_of_month | (self) | Check toDayOfMonth() function with DateTime64 extended range date time.
| Check toDayOfMonth() function with DateTime64 extended range date time.
| def to_day_of_month(self):
"""Check toDayOfMonth() function with DateTime64 extended range date time.
"""
to_day_of(py_func="tm_mday", ch_func="toDayOfMonth") | [
"def",
"to_day_of_month",
"(",
"self",
")",
":",
"to_day_of",
"(",
"py_func",
"=",
"\"tm_mday\"",
",",
"ch_func",
"=",
"\"toDayOfMonth\"",
")"
] | [
149,
0
] | [
152,
56
] | python | en | ['en', 'en', 'en'] | True |
to_day_of_week | (self) | Check toDayOfWeek() function with DateTime64 extended range date time.
| Check toDayOfWeek() function with DateTime64 extended range date time.
| def to_day_of_week(self):
"""Check toDayOfWeek() function with DateTime64 extended range date time.
"""
to_day_of(py_func="tm_wday", ch_func="toDayOfWeek") | [
"def",
"to_day_of_week",
"(",
"self",
")",
":",
"to_day_of",
"(",
"py_func",
"=",
"\"tm_wday\"",
",",
"ch_func",
"=",
"\"toDayOfWeek\"",
")"
] | [
159,
0
] | [
162,
55
] | python | en | ['en', 'en', 'en'] | True |
to_time_part | (self, py_func, ch_func) | Check the functions like toHour/toMinute/toSecond with DateTime64 extended range.
| Check the functions like toHour/toMinute/toSecond with DateTime64 extended range.
| def to_time_part(self, py_func, ch_func):
"""Check the functions like toHour/toMinute/toSecond with DateTime64 extended range.
"""
stress = self.context.stress
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(year=year, s... | [
"def",
"to_time_part",
"(",
"self",
",",
"py_func",
",",
"ch_func",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choose datetimes in {year}\"",
")",
... | [
166,
0
] | [
189,
77
] | python | en | ['en', 'en', 'en'] | True |
to_hour | (self) | Check toHour() function with DateTime64 extended range date time.
| Check toHour() function with DateTime64 extended range date time.
| def to_hour(self):
"""Check toHour() function with DateTime64 extended range date time.
"""
to_time_part(py_func="hour", ch_func="toHour") | [
"def",
"to_hour",
"(",
"self",
")",
":",
"to_time_part",
"(",
"py_func",
"=",
"\"hour\"",
",",
"ch_func",
"=",
"\"toHour\"",
")"
] | [
196,
0
] | [
199,
50
] | python | en | ['en', 'en', 'en'] | True |
to_minute | (self) | Check toMinute() function with DateTime64 extended range date time.
| Check toMinute() function with DateTime64 extended range date time.
| def to_minute(self):
"""Check toMinute() function with DateTime64 extended range date time.
"""
to_time_part(py_func="minute", ch_func="toMinute") | [
"def",
"to_minute",
"(",
"self",
")",
":",
"to_time_part",
"(",
"py_func",
"=",
"\"minute\"",
",",
"ch_func",
"=",
"\"toMinute\"",
")"
] | [
206,
0
] | [
209,
54
] | python | en | ['en', 'en', 'en'] | True |
to_second | (self) | Check toSecond() function with DateTime64 extended range date time.
| Check toSecond() function with DateTime64 extended range date time.
| def to_second(self):
"""Check toSecond() function with DateTime64 extended range date time.
"""
to_time_part(py_func="second", ch_func="toSecond") | [
"def",
"to_second",
"(",
"self",
")",
":",
"to_time_part",
"(",
"py_func",
"=",
"\"second\"",
",",
"ch_func",
"=",
"\"toSecond\"",
")"
] | [
216,
0
] | [
219,
54
] | python | en | ['en', 'en', 'en'] | True |
to_unix_timestamp | (self) | Check the toUnixTimestamp() function with DateTime64 extended range
| Check the toUnixTimestamp() function with DateTime64 extended range
| def to_unix_timestamp(self):
"""Check the toUnixTimestamp() function with DateTime64 extended range
"""
stress = self.context.stress
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(year=year, stress=stress)
t... | [
"def",
"to_unix_timestamp",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choose datetimes in {year}\"",
")",
":",
"datetimes",
"=",
"sele... | [
226,
0
] | [
246,
72
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_year | (self) | Check the functions toStartOfYear with DateTime64 extended range. | Check the functions toStartOfYear with DateTime64 extended range. | def to_start_of_year(self):
"""Check the functions toStartOfYear with DateTime64 extended range."""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(year=ye... | [
"def",
"to_start_of_year",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choose... | [
253,
0
] | [
274,
77
] | python | en | ['en', 'en', 'en'] | True |
iso_year_start | (dt) | Helper to find the beginning of iso year. | Helper to find the beginning of iso year. | def iso_year_start(dt):
"""Helper to find the beginning of iso year."""
dt_s = datetime.datetime(dt.year-1, 12, 23, 0, 0, 0)
while dt_s.isocalendar()[0] != dt.year:
dt_s += datetime.timedelta(days=1)
return dt_s | [
"def",
"iso_year_start",
"(",
"dt",
")",
":",
"dt_s",
"=",
"datetime",
".",
"datetime",
"(",
"dt",
".",
"year",
"-",
"1",
",",
"12",
",",
"23",
",",
"0",
",",
"0",
",",
"0",
")",
"while",
"dt_s",
".",
"isocalendar",
"(",
")",
"[",
"0",
"]",
"... | [
277,
0
] | [
282,
15
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_iso_year | (self) | Check the functions toStartOfISOYear with DateTime64 extended range. | Check the functions toStartOfISOYear with DateTime64 extended range. | def to_start_of_iso_year(self):
"""Check the functions toStartOfISOYear with DateTime64 extended range."""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(... | [
"def",
"to_start_of_iso_year",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I ch... | [
289,
0
] | [
308,
98
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_quarter | (self) | Check the functions toStartOfQuarter with
DateTime64 extended range.
| Check the functions toStartOfQuarter with
DateTime64 extended range.
| def to_start_of_quarter(self):
"""Check the functions toStartOfQuarter with
DateTime64 extended range.
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_... | [
"def",
"to_start_of_quarter",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I cho... | [
315,
0
] | [
338,
77
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_month | (self) | Check the functions toStartOfMonth with
DateTime64 extended range.
| Check the functions toStartOfMonth with
DateTime64 extended range.
| def to_start_of_month(self):
"""Check the functions toStartOfMonth with
DateTime64 extended range.
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress=stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dat... | [
"def",
"to_start_of_month",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
"=",
"stress",
")",
":",
"with",
"Given",
... | [
345,
0
] | [
368,
77
] | python | en | ['en', 'en', 'en'] | True |
to_monday | (self) | Check the functions toMonday with
DateTime64 extended range.
| Check the functions toMonday with
DateTime64 extended range.
| def to_monday(self):
"""Check the functions toMonday with
DateTime64 extended range.
"""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(year=year,... | [
"def",
"to_monday",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choose dateti... | [
375,
0
] | [
399,
77
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_week | (self) | Check the functions toStartOfWeek with DateTime64 extended range. | Check the functions toStartOfWeek with DateTime64 extended range. | def to_start_of_week(self):
"""Check the functions toStartOfWeek with DateTime64 extended range."""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(year=ye... | [
"def",
"to_start_of_week",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choose... | [
406,
0
] | [
430,
81
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_day | (self) | Check the functions toStartOfDay with DateTime64 extended range. | Check the functions toStartOfDay with DateTime64 extended range. | def to_start_of_day(self):
"""Check the functions toStartOfDay with DateTime64 extended range."""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(year=year... | [
"def",
"to_start_of_day",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choose ... | [
437,
0
] | [
456,
77
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_hour | (self) | Check the functions toStartOfHour with DateTime64 extended range. | Check the functions toStartOfHour with DateTime64 extended range. | def to_start_of_hour(self):
"""Check the functions toStartOfHour with DateTime64 extended range."""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(year=ye... | [
"def",
"to_start_of_hour",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choose... | [
463,
0
] | [
482,
77
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_minute | (self) | Check the functions toStartOfMinute with DateTime64 extended range. | Check the functions toStartOfMinute with DateTime64 extended range. | def to_start_of_minute(self):
"""Check the functions toStartOfMinute with DateTime64 extended range."""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_year(yea... | [
"def",
"to_start_of_minute",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
")",
":",
"with",
"Given",
"(",
"f\"I choo... | [
489,
0
] | [
508,
77
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_second | (self) | Check the functions toStartOfSecond with DateTime64 extended range. | Check the functions toStartOfSecond with DateTime64 extended range. | def to_start_of_second(self):
"""Check the functions toStartOfSecond with DateTime64 extended range."""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress=stress):
with Given(f"I choose datetimes in {year}"):
datetimes = select_dates_in_y... | [
"def",
"to_start_of_second",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
"=",
"stress",
")",
":",
"with",
"Given",
... | [
515,
0
] | [
534,
77
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_minutes_interval | (self, interval, func) | Check the functions like toStartOf....Minute with DateTime64 extended range. | Check the functions like toStartOf....Minute with DateTime64 extended range. | def to_start_of_minutes_interval(self, interval, func):
"""Check the functions like toStartOf....Minute with DateTime64 extended range."""
stress = self.context.stress
timezones = timezones_range(stress)
for year in years_range(stress=stress):
with Given(f"I choose datetimes in {year}"):
... | [
"def",
"to_start_of_minutes_interval",
"(",
"self",
",",
"interval",
",",
"func",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"for",
"year",
"in",
"years_range",
"(",
"stress",
"=",... | [
538,
0
] | [
558,
77
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_five_minute | (self) | Check the toStartOfFiveMinute with DateTime64 extended range. | Check the toStartOfFiveMinute with DateTime64 extended range. | def to_start_of_five_minute(self):
"""Check the toStartOfFiveMinute with DateTime64 extended range."""
to_start_of_minutes_interval(interval=5, func="toStartOfFiveMinute") | [
"def",
"to_start_of_five_minute",
"(",
"self",
")",
":",
"to_start_of_minutes_interval",
"(",
"interval",
"=",
"5",
",",
"func",
"=",
"\"toStartOfFiveMinute\"",
")"
] | [
565,
0
] | [
567,
72
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_ten_minutes | (self) | Check the toStartOfTenMinutes with DateTime64 extended range. | Check the toStartOfTenMinutes with DateTime64 extended range. | def to_start_of_ten_minutes(self):
"""Check the toStartOfTenMinutes with DateTime64 extended range."""
to_start_of_minutes_interval(interval=10, func="toStartOfTenMinutes") | [
"def",
"to_start_of_ten_minutes",
"(",
"self",
")",
":",
"to_start_of_minutes_interval",
"(",
"interval",
"=",
"10",
",",
"func",
"=",
"\"toStartOfTenMinutes\"",
")"
] | [
574,
0
] | [
576,
73
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_fifteen_minutes | (self) | Check the toStartOfFifteenMinutes with DateTime64 extended range. | Check the toStartOfFifteenMinutes with DateTime64 extended range. | def to_start_of_fifteen_minutes(self):
"""Check the toStartOfFifteenMinutes with DateTime64 extended range."""
to_start_of_minutes_interval(interval=15, func="toStartOfFifteenMinutes") | [
"def",
"to_start_of_fifteen_minutes",
"(",
"self",
")",
":",
"to_start_of_minutes_interval",
"(",
"interval",
"=",
"15",
",",
"func",
"=",
"\"toStartOfFifteenMinutes\"",
")"
] | [
583,
0
] | [
585,
77
] | python | en | ['en', 'en', 'en'] | True |
time_slot | (self) | Check the timeSlot with DateTime64 extended range. | Check the timeSlot with DateTime64 extended range. | def time_slot(self):
"""Check the timeSlot with DateTime64 extended range."""
to_start_of_minutes_interval(interval=30, func="timeSlot") | [
"def",
"time_slot",
"(",
"self",
")",
":",
"to_start_of_minutes_interval",
"(",
"interval",
"=",
"30",
",",
"func",
"=",
"\"timeSlot\"",
")"
] | [
592,
0
] | [
594,
62
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_interval_helper | (dt: datetime.datetime, interval_type, interval_value) | A helper to switch through all possible intervals. Computes the interval beginning depending on
interval_type and interval_value, returns string expected to be returned by ClickHouse.
:param dt: datetime to be checked, datetime.datetime
:param interval_type: interval type selector, String
:param interva... | A helper to switch through all possible intervals. Computes the interval beginning depending on
interval_type and interval_value, returns string expected to be returned by ClickHouse.
:param dt: datetime to be checked, datetime.datetime
:param interval_type: interval type selector, String
:param interva... | def to_start_of_interval_helper(dt: datetime.datetime, interval_type, interval_value):
"""A helper to switch through all possible intervals. Computes the interval beginning depending on
interval_type and interval_value, returns string expected to be returned by ClickHouse.
:param dt: datetime to be checked,... | [
"def",
"to_start_of_interval_helper",
"(",
"dt",
":",
"datetime",
".",
"datetime",
",",
"interval_type",
",",
"interval_value",
")",
":",
"intervals_in_seconds",
"=",
"{",
"\"SECOND\"",
":",
"1",
",",
"\"MINUTE\"",
":",
"60",
",",
"\"HOUR\"",
":",
"3600",
",",... | [
597,
0
] | [
627,
89
] | python | en | ['en', 'en', 'en'] | True |
to_start_of_interval | (self) | Check the toStartOfInterval with DateTime64 extended range.
| Check the toStartOfInterval with DateTime64 extended range.
| def to_start_of_interval(self):
"""Check the toStartOfInterval with DateTime64 extended range.
"""
stress = self.context.stress
timezones = timezones_range(stress)
intervals_testing_ranges = {"SECOND": range(1, 15), "MINUTE": range(1, 15), "HOUR": range(1, 10), "DAY": (1, 5, 10),
... | [
"def",
"to_start_of_interval",
"(",
"self",
")",
":",
"stress",
"=",
"self",
".",
"context",
".",
"stress",
"timezones",
"=",
"timezones_range",
"(",
"stress",
")",
"intervals_testing_ranges",
"=",
"{",
"\"SECOND\"",
":",
"range",
"(",
"1",
",",
"15",
")",
... | [
634,
0
] | [
659,
85
] | 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.