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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
GroupedTableExpr.projection | (self, exprs) |
Like mutate, but do not include existing table columns
|
Like mutate, but do not include existing table columns
| def projection(self, exprs):
"""
Like mutate, but do not include existing table columns
"""
w = self._get_window()
windowed_exprs = []
exprs = self.table._resolve(exprs)
for expr in exprs:
expr = L.windowize_function(expr, w=w)
windowed_exp... | [
"def",
"projection",
"(",
"self",
",",
"exprs",
")",
":",
"w",
"=",
"self",
".",
"_get_window",
"(",
")",
"windowed_exprs",
"=",
"[",
"]",
"exprs",
"=",
"self",
".",
"table",
".",
"_resolve",
"(",
"exprs",
")",
"for",
"expr",
"in",
"exprs",
":",
"e... | [
216,
4
] | [
226,
52
] | python | en | ['en', 'error', 'th'] | False |
GroupedTableExpr.over | (self, window) |
Add a window clause to be applied to downstream analytic expressions
|
Add a window clause to be applied to downstream analytic expressions
| def over(self, window):
"""
Add a window clause to be applied to downstream analytic expressions
"""
return GroupedTableExpr(self.table, self.by, having=self._having,
order_by=self._order_by,
window=window) | [
"def",
"over",
"(",
"self",
",",
"window",
")",
":",
"return",
"GroupedTableExpr",
"(",
"self",
".",
"table",
",",
"self",
".",
"by",
",",
"having",
"=",
"self",
".",
"_having",
",",
"order_by",
"=",
"self",
".",
"_order_by",
",",
"window",
"=",
"win... | [
246,
4
] | [
252,
46
] | python | en | ['en', 'error', 'th'] | False |
GroupedTableExpr.count | (self, metric_name='count') |
Convenience function for computing the group sizes (number of rows per
group) given a grouped table.
Parameters
----------
metric_name : string, default 'count'
Name to use for the row count metric
Returns
-------
aggregated : TableExpr
... |
Convenience function for computing the group sizes (number of rows per
group) given a grouped table. | def count(self, metric_name='count'):
"""
Convenience function for computing the group sizes (number of rows per
group) given a grouped table.
Parameters
----------
metric_name : string, default 'count'
Name to use for the row count metric
Returns
... | [
"def",
"count",
"(",
"self",
",",
"metric_name",
"=",
"'count'",
")",
":",
"metric",
"=",
"self",
".",
"table",
".",
"count",
"(",
")",
".",
"name",
"(",
"metric_name",
")",
"return",
"self",
".",
"table",
".",
"aggregate",
"(",
"[",
"metric",
"]",
... | [
254,
4
] | [
270,
78
] | python | en | ['en', 'error', 'th'] | False |
MySQLClient.database | (self, name=None) | Connect to a database called `name`.
Parameters
----------
name : str, optional
The name of the database to connect to. If ``None``, return
the database named ``self.current_database``.
Returns
-------
db : MySQLDatabase
An :class:`ib... | Connect to a database called `name`. | def database(self, name=None):
"""Connect to a database called `name`.
Parameters
----------
name : str, optional
The name of the database to connect to. If ``None``, return
the database named ``self.current_database``.
Returns
-------
db... | [
"def",
"database",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"==",
"self",
".",
"current_database",
"or",
"(",
"name",
"is",
"None",
"and",
"name",
"!=",
"self",
".",
"current_database",
")",
":",
"return",
"self",
".",
"database_c... | [
92,
4
] | [
125,
56
] | python | en | ['en', 'en', 'en'] | True |
MySQLClient.schema | (self, name) | Get a schema object from the current database for the schema named `name`.
Parameters
----------
name : str
Returns
-------
schema : MySQLSchema
An :class:`ibis.sql.mysql.client.MySQLSchema` instance.
| Get a schema object from the current database for the schema named `name`. | def schema(self, name):
"""Get a schema object from the current database for the schema named `name`.
Parameters
----------
name : str
Returns
-------
schema : MySQLSchema
An :class:`ibis.sql.mysql.client.MySQLSchema` instance.
"""
r... | [
"def",
"schema",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"database",
"(",
")",
".",
"schema",
"(",
"name",
")"
] | [
127,
4
] | [
140,
43
] | python | en | ['en', 'en', 'en'] | True |
MySQLClient.current_database | (self) | The name of the current database this client is connected to. | The name of the current database this client is connected to. | def current_database(self):
"""The name of the current database this client is connected to."""
return self.database_name | [
"def",
"current_database",
"(",
"self",
")",
":",
"return",
"self",
".",
"database_name"
] | [
143,
4
] | [
145,
33
] | python | en | ['en', 'en', 'en'] | True |
MySQLClient.list_schemas | (self) | List all the schemas in the current database. | List all the schemas in the current database. | def list_schemas(self):
"""List all the schemas in the current database."""
return self.inspector.get_schema_names() | [
"def",
"list_schemas",
"(",
"self",
")",
":",
"return",
"self",
".",
"inspector",
".",
"get_schema_names",
"(",
")"
] | [
150,
4
] | [
152,
48
] | python | en | ['en', 'en', 'en'] | True |
MySQLClient.table | (self, name, database=None, schema=None) | Create a table expression that references a particular a table
called `name` in a MySQL database called `database`.
Parameters
----------
name : str
The name of the table to retrieve.
database : str, optional
The database in which the table referred to by... | Create a table expression that references a particular a table
called `name` in a MySQL database called `database`. | def table(self, name, database=None, schema=None):
"""Create a table expression that references a particular a table
called `name` in a MySQL database called `database`.
Parameters
----------
name : str
The name of the table to retrieve.
database : str, optio... | [
"def",
"table",
"(",
"self",
",",
"name",
",",
"database",
"=",
"None",
",",
"schema",
"=",
"None",
")",
":",
"if",
"database",
"is",
"not",
"None",
"and",
"database",
"!=",
"self",
".",
"current_database",
":",
"return",
"(",
"self",
".",
"database",
... | [
164,
4
] | [
192,
46
] | python | en | ['en', 'en', 'en'] | True |
privileges_granted_directly | (self, node=None) | Check that a user is able to execute `CREATE ROW POLICY` with privileges are granted directly.
| Check that a user is able to execute `CREATE ROW POLICY` with privileges are granted directly.
| def privileges_granted_directly(self, node=None):
"""Check that a user is able to execute `CREATE 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=create_row_p... | [
"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 `CREATE ROW POLICY` with privileges are granted through a role.
| Check that a user is able to execute `CREATE 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 `CREATE 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... | [
"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 |
create_row_policy | (self, privilege, grant_target_name, user_name, node=None) | Check that user is only able to execute `CREATE ROW POLICY` when they have the necessary privilege.
| Check that user is only able to execute `CREATE ROW POLICY` when they have the necessary privilege.
| def create_row_policy(self, privilege, grant_target_name, user_name, node=None):
"""Check that user is only able to execute `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",
"create_row_policy",
"(",
"self",
",",
"privilege",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"user_name",
")",
"if",
"nod... | [
52,
0
] | [
126,
97
] | python | en | ['en', 'en', 'en'] | True |
no_grants | (self, node=None) | Check that user is unable to select from a table without a row policy
after a row policy with a condition has been created on that table.
| Check that user is unable to select from a table without a row policy
after a row policy with a condition has been created on that table.
| def no_grants(self, node=None):
"""Check that user is unable to select from a table without a row policy
after a row policy with a condition has been created on that table.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
... | [
"def",
"no_grants",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"table",
"("... | [
132,
0
] | [
164,
83
] | python | en | ['en', 'en', 'en'] | True |
permissive | (self, node=None) | Check that user is able to see from a table when they have a PERMISSIVE policy.
| Check that user is able to see from a table when they have a PERMISSIVE policy.
| def permissive(self, node=None):
"""Check that user is able to see from a table when they have a PERMISSIVE policy.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_name):
try:
with G... | [
"def",
"permissive",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"table",
"(... | [
170,
0
] | [
194,
83
] | python | en | ['en', 'en', 'en'] | True |
restrictive | (self, node=None) | Check that user is able to see values they have a RESTRICTIVE policy for.
| Check that user is able to see values they have a RESTRICTIVE policy for.
| def restrictive(self, node=None):
"""Check that user is able to see values they have a RESTRICTIVE policy for.
"""
table_name = f"table_{getuid()}"
perm_pol_name = f"perm_pol_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_... | [
"def",
"restrictive",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"perm_pol_name",
"=",
"f\"perm_pol_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
"."... | [
200,
0
] | [
231,
88
] | python | en | ['en', 'en', 'en'] | True |
for_select | (self, node=None) | Check that user is able to see values allowed by the row policy condition in the FOR SELECT clause.
| Check that user is able to see values allowed by the row policy condition in the FOR SELECT clause.
| def for_select(self, node=None):
"""Check that user is able to see values allowed by the row policy condition in the FOR SELECT clause.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_name):
try... | [
"def",
"for_select",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"table",
"(... | [
237,
0
] | [
261,
83
] | python | en | ['en', 'en', 'en'] | True |
condition | (self, node=None) | Check that user is able to see values allowed by the row policy condition.
| Check that user is able to see values allowed by the row policy condition.
| def condition(self, node=None):
"""Check that user is able to see values allowed by the row policy condition.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_name):
try:
with Given("... | [
"def",
"condition",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"table",
"("... | [
267,
0
] | [
291,
83
] | python | en | ['en', 'en', 'en'] | True |
if_not_exists | (self, node=None) | Check that a row policy created using IF NOT EXISTS does not replace a row policy with the same name.
| Check that a row policy created using IF NOT EXISTS does not replace a row policy with the same name.
| def if_not_exists(self, node=None):
"""Check that a row policy created using IF NOT EXISTS does not replace a row policy with the same name.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_name):
... | [
"def",
"if_not_exists",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"table",
... | [
297,
0
] | [
328,
83
] | python | en | ['en', 'en', 'en'] | True |
or_replace | (self, node=None) | Check that a row policy created using OR REPLACE does replace the row policy with the same name.
| Check that a row policy created using OR REPLACE does replace the row policy with the same name.
| def or_replace(self, node=None):
"""Check that a row policy created using OR REPLACE does replace the row policy with the same name.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_name):
try:
... | [
"def",
"or_replace",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"table",
"(... | [
334,
0
] | [
365,
83
] | python | en | ['en', 'en', 'en'] | True |
on_cluster | (self, node=None) | Check that a row policy created using ON CLUSTER applies to the nodes of the cluster correctly.
| Check that a row policy created using ON CLUSTER applies to the nodes of the cluster correctly.
| def on_cluster(self, node=None):
"""Check that a row policy created using ON CLUSTER applies to the nodes of the cluster correctly.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
node2 = self.context.node2
try:
... | [
"def",
"on_cluster",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"node2",
"=",
"self... | [
371,
0
] | [
408,
77
] | python | en | ['en', 'en', 'en'] | True |
diff_policies_on_diff_nodes | (self, node=None) | Check that a row policy created on a node, does not effect a different node.
| Check that a row policy created on a node, does not effect a different node.
| def diff_policies_on_diff_nodes(self, node=None):
"""Check that a row policy created on a node, does not effect a different node.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
node2 = self.context.node2
try:
... | [
"def",
"diff_policies_on_diff_nodes",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"node2... | [
411,
0
] | [
448,
77
] | python | en | ['en', 'en', 'en'] | True |
assignment | (self, node=None) | Check that user is able to see rows from a table when they have PERMISSIVE policy assigned to them.
| Check that user is able to see rows from a table when they have PERMISSIVE policy assigned to them.
| def assignment(self, node=None):
"""Check that user is able to see rows from a table when they have PERMISSIVE policy assigned to them.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_name):
try... | [
"def",
"assignment",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"table",
"(... | [
454,
0
] | [
478,
83
] | python | en | ['en', 'en', 'en'] | True |
assignment_none | (self, node=None) | Check that no one is affected when a row policy is assigned to NONE.
| Check that no one is affected when a row policy is assigned to NONE.
| def assignment_none(self, node=None):
"""Check that no one is affected when a row policy is assigned to NONE.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_name):
try:
with Given("... | [
"def",
"assignment_none",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"table",... | [
484,
0
] | [
508,
83
] | python | en | ['en', 'en', 'en'] | True |
assignment_all | (self, node=None) | Check that everyone is effected with a row policy is assigned to ALL.
| Check that everyone is effected with a row policy is assigned to ALL.
| def assignment_all(self, node=None):
"""Check that everyone is effected with a row policy is assigned to ALL.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_name):
try:
with Given("... | [
"def",
"assignment_all",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"table",
... | [
514,
0
] | [
538,
83
] | python | en | ['en', 'en', 'en'] | True |
assignment_all_except | (self, node=None) | Check that everyone is except the specified user is effect by a row policy assigned to ALL EXCEPT.
| Check that everyone is except the specified user is effect by a row policy assigned to ALL EXCEPT.
| def assignment_all_except(self, node=None):
"""Check that everyone is except the specified user is effect by a row policy assigned to ALL EXCEPT.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with table(node, table_name):
... | [
"def",
"assignment_all_except",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"t... | [
544,
0
] | [
568,
83
] | python | en | ['en', 'en', 'en'] | True |
nested_view | (self, node=None) | Check that if a user has a row policy on a table and a view is created on that table,
the user is only able to select rows specified by the assigned policies from the view.
| Check that if a user has a row policy on a table and a view is created on that table,
the user is only able to select rows specified by the assigned policies from the view.
| def nested_view(self, node=None):
"""Check that if a user has a row policy on a table and a view is created on that table,
the user is only able to select rows specified by the assigned policies from the view.
"""
table_name = f"table_{getuid()}"
view_name = f"view_{getuid()}"
pol_name = f"pol_... | [
"def",
"nested_view",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"view_name",
"=",
"f\"view_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"con... | [
574,
0
] | [
606,
62
] | python | en | ['en', 'en', 'en'] | True |
nested_live_view_after_policy | (self, node=None) | Check that if a user has a row policy on a table and a live view is created on that table,
the user is only able to select rows specified by the assigned policies from the view.
| Check that if a user has a row policy on a table and a live view is created on that table,
the user is only able to select rows specified by the assigned policies from the view.
| def nested_live_view_after_policy(self, node=None):
"""Check that if a user has a row policy on a table and a live view is created on that table,
the user is only able to select rows specified by the assigned policies from the view.
"""
table_name = f"table_{getuid()}"
view_name = f"view_{getuid()}... | [
"def",
"nested_live_view_after_policy",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"view_name",
"=",
"f\"view_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"se... | [
612,
0
] | [
655,
28
] | python | en | ['en', 'en', 'en'] | True |
nested_live_view_before_policy | (self, node=None) | Check that if a live view exists on a table and then a row policy is created,
the user is only able to select rows specified by the assigned policies from the view.
| Check that if a live view exists on a table and then a row policy is created,
the user is only able to select rows specified by the assigned policies from the view.
| def nested_live_view_before_policy(self, node=None):
"""Check that if a live view exists on a table and then a row policy is created,
the user is only able to select rows specified by the assigned policies from the view.
"""
table_name = f"table_{getuid()}"
view_name = f"view_{getuid()}"
pol_na... | [
"def",
"nested_live_view_before_policy",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"view_name",
"=",
"f\"view_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"s... | [
661,
0
] | [
704,
28
] | python | en | ['en', 'en', 'en'] | True |
nested_mat_view_after_policy | (self, node=None) | Check that if a user has a row policy on a table and a materialized view is created on that table,
the user is only able to select rows specified by the assigned policies from the view.
| Check that if a user has a row policy on a table and a materialized view is created on that table,
the user is only able to select rows specified by the assigned policies from the view.
| def nested_mat_view_after_policy(self, node=None):
"""Check that if a user has a row policy on a table and a materialized view is created on that table,
the user is only able to select rows specified by the assigned policies from the view.
"""
table_name = f"table_{getuid()}"
view_name = f"view_{ge... | [
"def",
"nested_mat_view_after_policy",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"view_name",
"=",
"f\"view_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"sel... | [
710,
0
] | [
742,
62
] | python | en | ['en', 'en', 'en'] | True |
nested_mat_view_before_policy | (self, node=None) | Check that if a materialized view exists on a table and then a row policy is created,
the user is only able to select rows specified by the assigned policies from the view.
| Check that if a materialized view exists on a table and then a row policy is created,
the user is only able to select rows specified by the assigned policies from the view.
| def nested_mat_view_before_policy(self, node=None):
"""Check that if a materialized view exists on a table and then a row policy is created,
the user is only able to select rows specified by the assigned policies from the view.
"""
table_name = f"table_{getuid()}"
view_name = f"view_{getuid()}"
... | [
"def",
"nested_mat_view_before_policy",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"view_name",
"=",
"f\"view_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"se... | [
748,
0
] | [
780,
62
] | python | en | ['en', 'en', 'en'] | True |
populate_mat_view | (self, node=None) | Check that if a user has a row policy on a table and a materialized view is created using POPULATE from that table,
the user can only select the rows from the materialized view specified in the row policy.
| Check that if a user has a row policy on a table and a materialized view is created using POPULATE from that table,
the user can only select the rows from the materialized view specified in the row policy.
| def populate_mat_view(self, node=None):
"""Check that if a user has a row policy on a table and a materialized view is created using POPULATE from that table,
the user can only select the rows from the materialized view specified in the row policy.
"""
table_name = f"table_{getuid()}"
view_name = f... | [
"def",
"populate_mat_view",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"view_name",
"=",
"f\"view_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
... | [
783,
0
] | [
815,
62
] | python | en | ['en', 'en', 'en'] | True |
dist_table | (self, node=None) | Check that if a user has a row policy on a table and a distributed table is created on that table,
the user is only able to select rows specified by the assigned policies from the distributed table.
| Check that if a user has a row policy on a table and a distributed table is created on that table,
the user is only able to select rows specified by the assigned policies from the distributed table.
| def dist_table(self, node=None):
"""Check that if a user has a row policy on a table and a distributed table is created on that table,
the user is only able to select rows specified by the assigned policies from the distributed table.
"""
table_name = f"table_{getuid()}"
dist_table_name = f"dist_ta... | [
"def",
"dist_table",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"dist_table_name",
"=",
"f\"dist_table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
... | [
821,
0
] | [
859,
65
] | python | en | ['en', 'en', 'en'] | True |
dist_table_diff_policies_on_diff_nodes | (self, node=None) | Check that the user can only access the rows of the distributed table that are allowed
by row policies on the the source tables. The row policies are different on different nodes.
| Check that the user can only access the rows of the distributed table that are allowed
by row policies on the the source tables. The row policies are different on different nodes.
| def dist_table_diff_policies_on_diff_nodes(self, node=None):
"""Check that the user can only access the rows of the distributed table that are allowed
by row policies on the the source tables. The row policies are different on different nodes.
"""
table_name = f"table_{getuid()}"
dist_table_name = ... | [
"def",
"dist_table_diff_policies_on_diff_nodes",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"dist_table_name",
"=",
"f\"dist_table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
... | [
865,
0
] | [
906,
65
] | python | en | ['en', 'en', 'en'] | True |
dist_table_on_dist_table | (self, node=None) | Check that if a user has a row policy on a table and a distributed table is created on that table,
and another distributed table is created on top of that,
the user is only able to access rows on any of the tables specified by the assigned policies.
| Check that if a user has a row policy on a table and a distributed table is created on that table,
and another distributed table is created on top of that,
the user is only able to access rows on any of the tables specified by the assigned policies.
| def dist_table_on_dist_table(self, node=None):
"""Check that if a user has a row policy on a table and a distributed table is created on that table,
and another distributed table is created on top of that,
the user is only able to access rows on any of the tables specified by the assigned policies.
"""
... | [
"def",
"dist_table_on_dist_table",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"dist_table_name",
"=",
"f\"dist_table_{getuid()}\"",
"dist_table_2_name",
"=",
"f\"dist_table_2_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()... | [
912,
0
] | [
957,
67
] | python | en | ['en', 'en', 'en'] | True |
no_table | (self, node=None) | Check that row policy is not created when the table is not specified.
| Check that row policy is not created when the table is not specified.
| def no_table(self, node=None):
"""Check that row policy is not created when the table is not specified.
"""
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
with When("I try to create a row policy without a table"):
node.query(f"CREATE ROW POLICY {pol_name}",
... | [
"def",
"no_table",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"When",
"(",
"\"I try to create a row policy without a table\... | [
960,
0
] | [
974,
59
] | python | en | ['en', 'en', 'en'] | True |
policy_before_table | (self, node=None) | Check that if the policy is created before the table,
then it is still applied correctly.
| Check that if the policy is created before the table,
then it is still applied correctly.
| def policy_before_table(self, node=None):
"""Check that if the policy is created before the table,
then it is still applied correctly.
"""
table_name = f"table_{getuid()}"
pol_name = f"pol_{getuid()}"
if node is None:
node = self.context.node
try:
with Given("I have a row p... | [
"def",
"policy_before_table",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"try",
":",
... | [
977,
0
] | [
1001,
79
] | python | en | ['en', 'en', 'en'] | True |
dict | (self, node=None) | Check that if a user has a row policy on a table and a dictionary is created on that table,
the user is only able to select rows specified by the assigned policies from the dict.
| Check that if a user has a row policy on a table and a dictionary is created on that table,
the user is only able to select rows specified by the assigned policies from the dict.
| def dict(self, node=None):
"""Check that if a user has a row policy on a table and a dictionary is created on that table,
the user is only able to select rows specified by the assigned policies from the dict.
"""
table_name = f"table_{getuid()}"
dict_name = f"view_{getuid()}"
pol_name = f"pol_{... | [
"def",
"dict",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"table_name",
"=",
"f\"table_{getuid()}\"",
"dict_name",
"=",
"f\"view_{getuid()}\"",
"pol_name",
"=",
"f\"pol_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
... | [
1007,
0
] | [
1044,
60
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1") | Check the RBAC functionality of CREATE ROW POLICY.
| Check the RBAC functionality of CREATE ROW POLICY.
| def feature(self, node="clickhouse1"):
"""Check the RBAC functionality of CREATE 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... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
"self",
".",
"context",
".",
"node2",
"=",
"self",
".",
"... | [
1053,
0
] | [
1086,
62
] | python | en | ['en', 'en', 'en'] | True |
DeathToll.__init__ | (self,
id_cost,
ratio_death_to_R,
scale_factor=0.65 * 1e3,
range_constraints=(1000, 62000)) |
Economic cost computed as GDP recess due to diseased and dead people, as well as partial unemployment due to lock-downs.
GDP is expressed in billions.
Parameters
----------
id_cost: int
Identifier of the cost in the list of costs
ratio_death_to_R: flo... |
Economic cost computed as GDP recess due to diseased and dead people, as well as partial unemployment due to lock-downs.
GDP is expressed in billions. | def __init__(self,
id_cost,
ratio_death_to_R,
scale_factor=0.65 * 1e3,
range_constraints=(1000, 62000)):
"""
Economic cost computed as GDP recess due to diseased and dead people, as well as partial unemployment due to lock-downs.
... | [
"def",
"__init__",
"(",
"self",
",",
"id_cost",
",",
"ratio_death_to_R",
",",
"scale_factor",
"=",
"0.65",
"*",
"1e3",
",",
"range_constraints",
"=",
"(",
"1000",
",",
"62000",
")",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"scale_factor",
"=",
... | [
4,
4
] | [
32,
48
] | python | en | ['en', 'error', 'th'] | False |
DeathToll.compute_cost | (self, previous_state, state, label_to_id, action, others={}) |
Computes GDP loss since the last state.
Parameters
----------
previous_state: 2D nd.array
Previous model states (either 1D or 2D with first dimension # of states).
state: 2D nd.array
Current model states (either 1D or 2D with first dimension # of states)... |
Computes GDP loss since the last state. | def compute_cost(self, previous_state, state, label_to_id, action, others={}):
"""
Computes GDP loss since the last state.
Parameters
----------
previous_state: 2D nd.array
Previous model states (either 1D or 2D with first dimension # of states).
state: 2D nd... | [
"def",
"compute_cost",
"(",
"self",
",",
"previous_state",
",",
"state",
",",
"label_to_id",
",",
"action",
",",
"others",
"=",
"{",
"}",
")",
":",
"# compute new deaths and pib loss",
"new_deaths",
"=",
"(",
"(",
"state",
"[",
":",
",",
"label_to_id",
"[",
... | [
34,
4
] | [
57,
25
] | python | en | ['en', 'error', 'th'] | False |
DeathToll.compute_cumulative_cost | (self, previous_state, state, label_to_id, action, others={}) |
Compute cumulative costs since start of episode.
Parameters
----------
Parameters
----------
previous_state: 2D nd.array
Previous model states (either 1D or 2D with first dimension # of states).
state: 2D nd.array
Current model sta... |
Compute cumulative costs since start of episode. | def compute_cumulative_cost(self, previous_state, state, label_to_id, action, others={}):
"""
Compute cumulative costs since start of episode.
Parameters
----------
Parameters
----------
previous_state: 2D nd.array
Previous model states (either... | [
"def",
"compute_cumulative_cost",
"(",
"self",
",",
"previous_state",
",",
"state",
",",
"label_to_id",
",",
"action",
",",
"others",
"=",
"{",
"}",
")",
":",
"cumulative_cost",
"=",
"state",
"[",
":",
",",
"label_to_id",
"[",
"'cumulative_cost_{}'",
".",
"f... | [
59,
4
] | [
82,
30
] | python | en | ['en', 'error', 'th'] | False |
dns_cache_privileges_granted_directly | (self, node=None) | Check that a user is able to execute `SYSTEM DROP DNS CACHE` if and only if
they have `SYSTEM DROP DNS CACHE` privilege granted directly.
| Check that a user is able to execute `SYSTEM DROP DNS CACHE` if and only if
they have `SYSTEM DROP DNS CACHE` privilege granted directly.
| def dns_cache_privileges_granted_directly(self, node=None):
"""Check that a user is able to execute `SYSTEM DROP DNS CACHE` if and only if
they have `SYSTEM DROP DNS CACHE` privilege granted directly.
"""
user_name = f"user_{getuid()}"
if node is None:
node = self.context.node
with use... | [
"def",
"dns_cache_privileges_granted_directly",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"user_name",
"=",
"f\"user_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"user",
"(",
"node",
",",
... | [
8,
0
] | [
22,
80
] | python | en | ['en', 'en', 'en'] | True |
dns_cache_privileges_granted_via_role | (self, node=None) | Check that a user is able to execute `SYSTEM DROP DNS CACHE` if and only if
they have `SYSTEM DROP DNS CACHE` privilege granted via role.
| Check that a user is able to execute `SYSTEM DROP DNS CACHE` if and only if
they have `SYSTEM DROP DNS CACHE` privilege granted via role.
| def dns_cache_privileges_granted_via_role(self, node=None):
"""Check that a user is able to execute `SYSTEM DROP DNS CACHE` if and only if
they have `SYSTEM DROP DNS CACHE` privilege granted via role.
"""
user_name = f"user_{getuid()}"
role_name = f"role_{getuid()}"
if node is None:
nod... | [
"def",
"dns_cache_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"... | [
25,
0
] | [
43,
80
] | python | en | ['en', 'en', 'en'] | True |
dns_cache | (self, privilege, grant_target_name, user_name, node=None) | Run checks for `SYSTEM DROP DNS CACHE` privilege.
| Run checks for `SYSTEM DROP DNS CACHE` privilege.
| def dns_cache(self, privilege, grant_target_name, user_name, node=None):
"""Run checks for `SYSTEM DROP DNS CACHE` privilege.
"""
exitcode, message = errors.not_enough_privileges(name=user_name)
if node is None:
node = self.context.node
with Scenario("SYSTEM DROP DNS CACHE without privileg... | [
"def",
"dns_cache",
"(",
"self",
",",
"privilege",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"user_name",
")",
"if",
"node",
"i... | [
59,
0
] | [
97,
51
] | python | it | ['it', 'it', 'en'] | True |
mark_cache_privileges_granted_directly | (self, node=None) | Check that a user is able to execute `SYSTEM DROP MARK CACHE` if and only if
they have `SYSTEM DROP MARK CACHE` privilege granted directly.
| Check that a user is able to execute `SYSTEM DROP MARK CACHE` if and only if
they have `SYSTEM DROP MARK CACHE` privilege granted directly.
| def mark_cache_privileges_granted_directly(self, node=None):
"""Check that a user is able to execute `SYSTEM DROP MARK CACHE` if and only if
they have `SYSTEM DROP MARK CACHE` privilege granted directly.
"""
user_name = f"user_{getuid()}"
if node is None:
node = self.context.node
with ... | [
"def",
"mark_cache_privileges_granted_directly",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"user_name",
"=",
"f\"user_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"user",
"(",
"node",
",",
... | [
100,
0
] | [
114,
80
] | python | en | ['en', 'en', 'en'] | True |
mark_cache_privileges_granted_via_role | (self, node=None) | Check that a user is able to execute `SYSTEM DROP MARK CACHE` if and only if
they have `SYSTEM DROP MARK CACHE` privilege granted via role.
| Check that a user is able to execute `SYSTEM DROP MARK CACHE` if and only if
they have `SYSTEM DROP MARK CACHE` privilege granted via role.
| def mark_cache_privileges_granted_via_role(self, node=None):
"""Check that a user is able to execute `SYSTEM DROP MARK CACHE` if and only if
they have `SYSTEM DROP MARK CACHE` privilege granted via role.
"""
user_name = f"user_{getuid()}"
role_name = f"role_{getuid()}"
if node is None:
... | [
"def",
"mark_cache_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... | [
117,
0
] | [
135,
80
] | python | en | ['en', 'en', 'en'] | True |
mark_cache | (self, privilege, grant_target_name, user_name, node=None) | Run checks for `SYSTEM DROP MARK CACHE` privilege.
| Run checks for `SYSTEM DROP MARK CACHE` privilege.
| def mark_cache(self, privilege, grant_target_name, user_name, node=None):
"""Run checks for `SYSTEM DROP MARK CACHE` privilege.
"""
exitcode, message = errors.not_enough_privileges(name=user_name)
if node is None:
node = self.context.node
with Scenario("SYSTEM DROP MARK CACHE without privi... | [
"def",
"mark_cache",
"(",
"self",
",",
"privilege",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"user_name",
")",
"if",
"node",
"... | [
151,
0
] | [
189,
51
] | python | it | ['it', 'it', 'en'] | True |
uncompressed_cache_privileges_granted_directly | (self, node=None) | Check that a user is able to execute `SYSTEM DROP UNCOMPRESSED CACHE` if and only if
they have `SYSTEM DROP UNCOMPRESSED CACHE` privilege granted directly.
| Check that a user is able to execute `SYSTEM DROP UNCOMPRESSED CACHE` if and only if
they have `SYSTEM DROP UNCOMPRESSED CACHE` privilege granted directly.
| def uncompressed_cache_privileges_granted_directly(self, node=None):
"""Check that a user is able to execute `SYSTEM DROP UNCOMPRESSED CACHE` if and only if
they have `SYSTEM DROP UNCOMPRESSED CACHE` privilege granted directly.
"""
user_name = f"user_{getuid()}"
if node is None:
node = self... | [
"def",
"uncompressed_cache_privileges_granted_directly",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"user_name",
"=",
"f\"user_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"with",
"user",
"(",
"node",
... | [
192,
0
] | [
206,
80
] | python | en | ['en', 'en', 'en'] | True |
uncompressed_cache_privileges_granted_via_role | (self, node=None) | Check that a user is able to execute `SYSTEM DROP UNCOMPRESSED CACHE` if and only if
they have `SYSTEM DROP UNCOMPRESSED CACHE` privilege granted via role.
| Check that a user is able to execute `SYSTEM DROP UNCOMPRESSED CACHE` if and only if
they have `SYSTEM DROP UNCOMPRESSED CACHE` privilege granted via role.
| def uncompressed_cache_privileges_granted_via_role(self, node=None):
"""Check that a user is able to execute `SYSTEM DROP UNCOMPRESSED CACHE` if and only if
they have `SYSTEM DROP UNCOMPRESSED CACHE` privilege granted via role.
"""
user_name = f"user_{getuid()}"
role_name = f"role_{getuid()}"
i... | [
"def",
"uncompressed_cache_privileges_granted_via_role",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"user_name",
"=",
"f\"user_{getuid()}\"",
"role_name",
"=",
"f\"role_{getuid()}\"",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"self",
".",
"context",
".",... | [
209,
0
] | [
227,
80
] | python | en | ['en', 'en', 'en'] | True |
uncompressed_cache | (self, privilege, grant_target_name, user_name, node=None) | Run checks for `SYSTEM DROP UNCOMPRESSED CACHE` privilege.
| Run checks for `SYSTEM DROP UNCOMPRESSED CACHE` privilege.
| def uncompressed_cache(self, privilege, grant_target_name, user_name, node=None):
"""Run checks for `SYSTEM DROP UNCOMPRESSED CACHE` privilege.
"""
exitcode, message = errors.not_enough_privileges(name=user_name)
if node is None:
node = self.context.node
with Scenario("SYSTEM DROP UNCOMPRE... | [
"def",
"uncompressed_cache",
"(",
"self",
",",
"privilege",
",",
"grant_target_name",
",",
"user_name",
",",
"node",
"=",
"None",
")",
":",
"exitcode",
",",
"message",
"=",
"errors",
".",
"not_enough_privileges",
"(",
"name",
"=",
"user_name",
")",
"if",
"no... | [
243,
0
] | [
281,
51
] | python | it | ['it', 'it', 'en'] | True |
feature | (self, node="clickhouse1") | Check the RBAC functionality of SYSTEM DROP CACHE.
| Check the RBAC functionality of SYSTEM DROP CACHE.
| def feature(self, node="clickhouse1"):
"""Check the RBAC functionality of SYSTEM DROP CACHE.
"""
self.context.node = self.context.cluster.node(node)
Suite(run=dns_cache_privileges_granted_directly, setup=instrument_clickhouse_server_log)
Suite(run=dns_cache_privileges_granted_via_role, setup=instru... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
"Suite",
"(",
"run",
"=",
"dns_cache_privileges_granted_directly"... | [
290,
0
] | [
300,
101
] | python | en | ['en', 'en', 'en'] | True |
test_mysql_types | (started_cluster, case_name, mysql_type, expected_ch_type, mysql_values,
setting_mysql_datatypes_support_level) | Verify that values written to MySQL can be read on ClickHouse side via DB engine MySQL,
or Table engine MySQL, or mysql() table function.
Make sure that type is converted properly and values match exactly.
| Verify that values written to MySQL can be read on ClickHouse side via DB engine MySQL,
or Table engine MySQL, or mysql() table function.
Make sure that type is converted properly and values match exactly.
| def test_mysql_types(started_cluster, case_name, mysql_type, expected_ch_type, mysql_values,
setting_mysql_datatypes_support_level):
""" Verify that values written to MySQL can be read on ClickHouse side via DB engine MySQL,
or Table engine MySQL, or mysql() table function.
Make sure th... | [
"def",
"test_mysql_types",
"(",
"started_cluster",
",",
"case_name",
",",
"mysql_type",
",",
"expected_ch_type",
",",
"mysql_values",
",",
"setting_mysql_datatypes_support_level",
")",
":",
"substitutes",
"=",
"dict",
"(",
"mysql_db",
"=",
"'decimal_support'",
",",
"t... | [
303,
0
] | [
404,
61
] | python | en | ['en', 'en', 'en'] | True |
create_lookup_tables | (words) |
Create lookup tables for vocabulary
:param words: Input list of words
:return: Two dictionaries, vocab_to_int, int_to_vocab
|
Create lookup tables for vocabulary
:param words: Input list of words
:return: Two dictionaries, vocab_to_int, int_to_vocab
| def create_lookup_tables(words):
"""
Create lookup tables for vocabulary
:param words: Input list of words
:return: Two dictionaries, vocab_to_int, int_to_vocab
"""
word_counts = Counter(words)
# sorting the words from most to least frequent in text occurrence
sorted_vocab = sorted(word_... | [
"def",
"create_lookup_tables",
"(",
"words",
")",
":",
"word_counts",
"=",
"Counter",
"(",
"words",
")",
"# sorting the words from most to least frequent in text occurrence",
"sorted_vocab",
"=",
"sorted",
"(",
"word_counts",
",",
"key",
"=",
"word_counts",
".",
"get",
... | [
28,
0
] | [
41,
37
] | python | en | ['en', 'error', 'th'] | False |
datasetFiles | (request) |
Return a list all dataset files in the datasets directory, by looking for files ending
with .h5 suffix. eg. ['/Users/jarnyc/BioPyramid/data/datasets/lanner.1.0.h5']
|
Return a list all dataset files in the datasets directory, by looking for files ending
with .h5 suffix. eg. ['/Users/jarnyc/BioPyramid/data/datasets/lanner.1.0.h5']
| def datasetFiles(request):
"""
Return a list all dataset files in the datasets directory, by looking for files ending
with .h5 suffix. eg. ['/Users/jarnyc/BioPyramid/data/datasets/lanner.1.0.h5']
"""
# This is the dataset directory, set by the config file
datadir = request.registry.settings['biopyramid.model.data... | [
"def",
"datasetFiles",
"(",
"request",
")",
":",
"# This is the dataset directory, set by the config file",
"datadir",
"=",
"request",
".",
"registry",
".",
"settings",
"[",
"'biopyramid.model.datadir'",
"]",
"# Go through each file in the directory and fetch files with .h5 suffix"... | [
12,
0
] | [
25,
17
] | python | en | ['en', 'error', 'th'] | False |
datasetAttributes | (request) |
Return a list of dictionaries, where each dictionary contains the attributes of the dataset.
"filepath" key is also added to the final dictionary, so that it can be used to instantiate a BPDataset instance.
|
Return a list of dictionaries, where each dictionary contains the attributes of the dataset.
"filepath" key is also added to the final dictionary, so that it can be used to instantiate a BPDataset instance.
| def datasetAttributes(request):
"""
Return a list of dictionaries, where each dictionary contains the attributes of the dataset.
"filepath" key is also added to the final dictionary, so that it can be used to instantiate a BPDataset instance.
"""
return [bpdataset.datasetAttributes(filepath, includeFilepath=True) ... | [
"def",
"datasetAttributes",
"(",
"request",
")",
":",
"return",
"[",
"bpdataset",
".",
"datasetAttributes",
"(",
"filepath",
",",
"includeFilepath",
"=",
"True",
")",
"for",
"filepath",
"in",
"datasetFiles",
"(",
"request",
")",
"]"
] | [
27,
0
] | [
32,
107
] | python | en | ['en', 'error', 'th'] | False |
datasetFromName | (request, name) |
Return BPDataset instance based on name. Returns None if there is no matching dataset with the name.
|
Return BPDataset instance based on name. Returns None if there is no matching dataset with the name.
| def datasetFromName(request, name):
"""
Return BPDataset instance based on name. Returns None if there is no matching dataset with the name.
"""
for attribute in datasetAttributes(request):
if attribute['name']==name:
return bpdataset.BPDataset(attribute['filepath'])
return None | [
"def",
"datasetFromName",
"(",
"request",
",",
"name",
")",
":",
"for",
"attribute",
"in",
"datasetAttributes",
"(",
"request",
")",
":",
"if",
"attribute",
"[",
"'name'",
"]",
"==",
"name",
":",
"return",
"bpdataset",
".",
"BPDataset",
"(",
"attribute",
"... | [
34,
0
] | [
41,
12
] | python | en | ['en', 'error', 'th'] | False |
showPage | (request) | Shw the page when the URL is called.
Provide a list of datasets in json format.
| Shw the page when the URL is called.
Provide a list of datasets in json format.
| def showPage(request):
"""Shw the page when the URL is called.
Provide a list of datasets in json format.
"""
return {'datasets':datasetAttributes(request)} | [
"def",
"showPage",
"(",
"request",
")",
":",
"return",
"{",
"'datasets'",
":",
"datasetAttributes",
"(",
"request",
")",
"}"
] | [
49,
0
] | [
53,
47
] | python | en | ['en', 'en', 'en'] | True |
regression | (self, local, clickhouse_binary_path, stress=None, parallel=None) | Extended precision data type regression.
| Extended precision data type regression.
| def regression(self, local, clickhouse_binary_path, stress=None, parallel=None):
"""Extended precision data type regression.
"""
top().terminating = False
nodes = {
"clickhouse":
("clickhouse1",)
}
with Cluster(local, clickhouse_binary_path, nodes=nodes,
docker_... | [
"def",
"regression",
"(",
"self",
",",
"local",
",",
"clickhouse_binary_path",
",",
"stress",
"=",
"None",
",",
"parallel",
"=",
"None",
")",
":",
"top",
"(",
")",
".",
"terminating",
"=",
"False",
"nodes",
"=",
"{",
"\"clickhouse\"",
":",
"(",
"\"clickh... | [
29,
0
] | [
48,
83
] | python | en | ['en', 'en', 'en'] | True |
process_identifiers | (l) |
process_identifiers - process all identifiers and modify them to have
consistent names across all platforms; specifically across ELF and MachO.
For example, MachO inserts an additional understore at the beginning of
names. This function removes that.
|
process_identifiers - process all identifiers and modify them to have
consistent names across all platforms; specifically across ELF and MachO.
For example, MachO inserts an additional understore at the beginning of
names. This function removes that.
| def process_identifiers(l):
"""
process_identifiers - process all identifiers and modify them to have
consistent names across all platforms; specifically across ELF and MachO.
For example, MachO inserts an additional understore at the beginning of
names. This function removes that.
"""
parts... | [
"def",
"process_identifiers",
"(",
"l",
")",
":",
"parts",
"=",
"re",
".",
"split",
"(",
"r'([a-zA-Z0-9_]+)'",
",",
"l",
")",
"new_line",
"=",
"''",
"for",
"tk",
"in",
"parts",
":",
"if",
"is_identifier",
"(",
"tk",
")",
":",
"if",
"tk",
".",
"starts... | [
63,
0
] | [
80,
19
] | python | en | ['en', 'error', 'th'] | False |
process_asm | (asm) |
Strip the ASM of unwanted directives and lines
|
Strip the ASM of unwanted directives and lines
| def process_asm(asm):
"""
Strip the ASM of unwanted directives and lines
"""
new_contents = ''
asm = transform_labels(asm)
# TODO: Add more things we want to remove
discard_regexes = [
re.compile("\s+\..*$"), # directive
re.compile("\s*#(NO_APP|APP)$"), #inline ASM
r... | [
"def",
"process_asm",
"(",
"asm",
")",
":",
"new_contents",
"=",
"''",
"asm",
"=",
"transform_labels",
"(",
"asm",
")",
"# TODO: Add more things we want to remove",
"discard_regexes",
"=",
"[",
"re",
".",
"compile",
"(",
"\"\\s+\\..*$\"",
")",
",",
"# directive",
... | [
83,
0
] | [
120,
23
] | python | en | ['en', 'error', 'th'] | False |
read_json_file | (filename) | Read a JSON file as UTF-8 into a dictionary, discarding @metadata.
Args:
filename: The filename, which must end ".json".
Returns:
The dictionary.
Raises:
InputError: The filename did not end with ".json" or an error occurred
while opening or reading the file.
| Read a JSON file as UTF-8 into a dictionary, discarding @metadata. | def read_json_file(filename):
"""Read a JSON file as UTF-8 into a dictionary, discarding @metadata.
Args:
filename: The filename, which must end ".json".
Returns:
The dictionary.
Raises:
InputError: The filename did not end with ".json" or an error occurred
while opening or reading the fi... | [
"def",
"read_json_file",
"(",
"filename",
")",
":",
"if",
"not",
"filename",
".",
"endswith",
"(",
"'.json'",
")",
":",
"raise",
"InputError",
"(",
"filename",
",",
"'filenames must end with \".json\"'",
")",
"try",
":",
"# Read in file.",
"with",
"codecs",
".",... | [
39,
0
] | [
63,
38
] | python | en | ['en', 'en', 'en'] | True |
_create_qqq_file | (output_dir) | Creates a qqq.json file with message documentation for translatewiki.net.
The file consists of key-value pairs, where the keys are message ids and
the values are descriptions for the translators of the messages.
What documentation exists for the format can be found at:
http://translatewiki.net/wiki/Tra... | Creates a qqq.json file with message documentation for translatewiki.net. | def _create_qqq_file(output_dir):
"""Creates a qqq.json file with message documentation for translatewiki.net.
The file consists of key-value pairs, where the keys are message ids and
the values are descriptions for the translators of the messages.
What documentation exists for the format can be found ... | [
"def",
"_create_qqq_file",
"(",
"output_dir",
")",
":",
"qqq_file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"curdir",
",",
"output_dir",
",",
"'qqq.json'",
")",
"qqq_file",
"=",
"codecs",
".",
"open",
"(",
"qqq_file_name",
",",
"'w'",
"... | [
66,
0
] | [
89,
19
] | python | en | ['en', 'en', 'en'] | True |
_close_qqq_file | (qqq_file) | Closes a qqq.json file created and opened by _create_qqq_file().
This writes the final newlines and right brace.
Args:
qqq_file: A file created by _create_qqq_file().
Raises:
IOError: An error occurred while writing to or closing the file.
| Closes a qqq.json file created and opened by _create_qqq_file(). | def _close_qqq_file(qqq_file):
"""Closes a qqq.json file created and opened by _create_qqq_file().
This writes the final newlines and right brace.
Args:
qqq_file: A file created by _create_qqq_file().
Raises:
IOError: An error occurred while writing to or closing the file.
"""
... | [
"def",
"_close_qqq_file",
"(",
"qqq_file",
")",
":",
"qqq_file",
".",
"write",
"(",
"'\\n}\\n'",
")",
"qqq_file",
".",
"close",
"(",
")"
] | [
92,
0
] | [
104,
20
] | python | en | ['en', 'en', 'en'] | True |
_create_lang_file | (author, lang, output_dir) | Creates a <lang>.json file for translatewiki.net.
The file consists of metadata, followed by key-value pairs, where the keys
are message ids and the values are the messages in the language specified
by the corresponding command-line argument. The file should be closed by
_close_lang_file().
Args:... | Creates a <lang>.json file for translatewiki.net. | def _create_lang_file(author, lang, output_dir):
"""Creates a <lang>.json file for translatewiki.net.
The file consists of metadata, followed by key-value pairs, where the keys
are message ids and the values are the messages in the language specified
by the corresponding command-line argument. The fil... | [
"def",
"_create_lang_file",
"(",
"author",
",",
"lang",
",",
"output_dir",
")",
":",
"lang_file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"curdir",
",",
"output_dir",
",",
"lang",
"+",
"'.json'",
")",
"lang_file",
"=",
"codecs",
".",
... | [
107,
0
] | [
138,
20
] | python | en | ['en', 'en', 'en'] | True |
_close_lang_file | (lang_file) | Closes a <lang>.json file created with _create_lang_file().
This also writes the terminating left brace and newline.
Args:
lang_file: A file opened with _create_lang_file().
Raises:
IOError: An error occurred while writing to or closing the file.
| Closes a <lang>.json file created with _create_lang_file(). | def _close_lang_file(lang_file):
"""Closes a <lang>.json file created with _create_lang_file().
This also writes the terminating left brace and newline.
Args:
lang_file: A file opened with _create_lang_file().
Raises:
IOError: An error occurred while writing to or closing the file.
... | [
"def",
"_close_lang_file",
"(",
"lang_file",
")",
":",
"lang_file",
".",
"write",
"(",
"'\\n}\\n'",
")",
"lang_file",
".",
"close",
"(",
")"
] | [
141,
0
] | [
153,
21
] | python | en | ['en', 'en', 'en'] | True |
_create_key_file | (output_dir) | Creates a keys.json file mapping Closure keys to Blockly keys.
Args:
output_dir: Relative directory for output files.
Raises:
IOError: An error occurred while creating the file.
| Creates a keys.json file mapping Closure keys to Blockly keys. | def _create_key_file(output_dir):
"""Creates a keys.json file mapping Closure keys to Blockly keys.
Args:
output_dir: Relative directory for output files.
Raises:
IOError: An error occurred while creating the file.
"""
key_file_name = os.path.join(os.curdir, output_dir, 'keys.json'... | [
"def",
"_create_key_file",
"(",
"output_dir",
")",
":",
"key_file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"curdir",
",",
"output_dir",
",",
"'keys.json'",
")",
"key_file",
"=",
"open",
"(",
"key_file_name",
",",
"'w'",
")",
"key_file",
... | [
156,
0
] | [
169,
19
] | python | en | ['en', 'en', 'en'] | True |
_close_key_file | (key_file) | Closes a key file created and opened with _create_key_file().
Args:
key_file: A file created by _create_key_file().
Raises:
IOError: An error occurred while writing to or closing the file.
| Closes a key file created and opened with _create_key_file(). | def _close_key_file(key_file):
"""Closes a key file created and opened with _create_key_file().
Args:
key_file: A file created by _create_key_file().
Raises:
IOError: An error occurred while writing to or closing the file.
"""
key_file.write('\n}\n')
key_file.close() | [
"def",
"_close_key_file",
"(",
"key_file",
")",
":",
"key_file",
".",
"write",
"(",
"'\\n}\\n'",
")",
"key_file",
".",
"close",
"(",
")"
] | [
172,
0
] | [
182,
20
] | python | en | ['en', 'en', 'en'] | True |
write_files | (author, lang, output_dir, units, write_key_file) | Writes the output files for the given units.
There are three possible output files:
* lang_file: JSON file mapping meanings (e.g., Maze.turnLeft) to the
English text. The base name of the language file is specified by the
"lang" command-line argument.
* key_file: JSON file mapping meanings to ... | Writes the output files for the given units. | def write_files(author, lang, output_dir, units, write_key_file):
"""Writes the output files for the given units.
There are three possible output files:
* lang_file: JSON file mapping meanings (e.g., Maze.turnLeft) to the
English text. The base name of the language file is specified by the
"la... | [
"def",
"write_files",
"(",
"author",
",",
"lang",
",",
"output_dir",
",",
"units",
",",
"write_key_file",
")",
":",
"lang_file",
"=",
"_create_lang_file",
"(",
"author",
",",
"lang",
",",
"output_dir",
")",
"qqq_file",
"=",
"_create_qqq_file",
"(",
"output_dir... | [
185,
0
] | [
233,
29
] | python | en | ['en', 'en', 'en'] | True |
Argument.__init__ | (self, validator, default=_undefined) | Argument constructor
Parameters
----------
validator : Union[Callable[[arg], coerced], Type, Tuple[Type]]
Function which handles validation and/or coercion of the given
argument.
default : Union[Any, Callable[[], str]]
In case of missing (None) value for va... | Argument constructor | def __init__(self, validator, default=_undefined):
"""Argument constructor
Parameters
----------
validator : Union[Callable[[arg], coerced], Type, Tuple[Type]]
Function which handles validation and/or coercion of the given
argument.
default : Union[Any, Calla... | [
"def",
"__init__",
"(",
"self",
",",
"validator",
",",
"default",
"=",
"_undefined",
")",
":",
"if",
"PY2",
":",
"self",
".",
"_serial",
"=",
"next",
"(",
"self",
".",
"_counter",
")",
"self",
".",
"default",
"=",
"default",
"if",
"isinstance",
"(",
... | [
29,
4
] | [
57,
74
] | python | en | ['en', 'fr', 'en'] | False |
Argument.validate | (self, value=_undefined, name=None) |
Parameters
----------
value : Any, default undefined
Raises TypeError if argument is mandatory but not value has been
given.
name : Optional[str]
Argument name for error message
|
Parameters
----------
value : Any, default undefined
Raises TypeError if argument is mandatory but not value has been
given.
name : Optional[str]
Argument name for error message
| def validate(self, value=_undefined, name=None):
"""
Parameters
----------
value : Any, default undefined
Raises TypeError if argument is mandatory but not value has been
given.
name : Optional[str]
Argument name for error message
"""
... | [
"def",
"validate",
"(",
"self",
",",
"value",
"=",
"_undefined",
",",
"name",
"=",
"None",
")",
":",
"if",
"self",
".",
"optional",
":",
"if",
"value",
"is",
"_undefined",
"or",
"value",
"is",
"None",
":",
"if",
"self",
".",
"default",
"is",
"None",
... | [
69,
4
] | [
92,
36
] | python | en | ['en', 'error', 'th'] | False |
print_json | (o:object) | print object as json string
| print object as json string
| def print_json(o:object) -> None:
''' print object as json string
'''
print(json.dumps(o)) | [
"def",
"print_json",
"(",
"o",
":",
"object",
")",
"->",
"None",
":",
"print",
"(",
"json",
".",
"dumps",
"(",
"o",
")",
")"
] | [
36,
0
] | [
39,
24
] | python | en | ['en', 'en', 'en'] | True |
add_target_argumens | (parser: ArgumentParser) | add target CLI argeuments
| add target CLI argeuments
| def add_target_argumens(parser: ArgumentParser) -> ArgumentParser:
''' add target CLI argeuments
'''
parser.add_argument('--branch', type=str, nargs='?', default=None,
help='specify branch from CI tool')
parser.add_argument('--tag', type=str, nargs='?', default=None,
... | [
"def",
"add_target_argumens",
"(",
"parser",
":",
"ArgumentParser",
")",
"->",
"ArgumentParser",
":",
"parser",
".",
"add_argument",
"(",
"'--branch'",
",",
"type",
"=",
"str",
",",
"nargs",
"=",
"'?'",
",",
"default",
"=",
"None",
",",
"help",
"=",
"'spec... | [
184,
0
] | [
209,
17
] | python | en | ['en', 'en', 'hi'] | True |
handle_cli_commands | (args) | handle CLI commands
| handle CLI commands
| def handle_cli_commands(args):
''' handle CLI commands
'''
settings = Settings(args.settings)
if args.show_targets:
scanner = TargetScanner()
for target_path in sorted(scanner.run()):
print(f"- {target_path}")
elif args.info:
target = Target(args.info)
... | [
"def",
"handle_cli_commands",
"(",
"args",
")",
":",
"settings",
"=",
"Settings",
"(",
"args",
".",
"settings",
")",
"if",
"args",
".",
"show_targets",
":",
"scanner",
"=",
"TargetScanner",
"(",
")",
"for",
"target_path",
"in",
"sorted",
"(",
"scanner",
".... | [
212,
0
] | [
283,
42
] | python | en | ['en', 'ca', 'en'] | True |
Target.info | (self) | returns target metadata
| returns target metadata
| def info(self):
''' returns target metadata
'''
return self._metadata | [
"def",
"info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_metadata"
] | [
71,
4
] | [
74,
29
] | python | en | ['en', 'jv', 'en'] | True |
Target.name | (self) | return target name
| return target name
| def name(self) -> str:
''' return target name
'''
target_name = self._metadata.get('name', None)
if not target_name:
logger.error(f'Missed target name, target: {self.path}')
return target_name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"target_name",
"=",
"self",
".",
"_metadata",
".",
"get",
"(",
"'name'",
",",
"None",
")",
"if",
"not",
"target_name",
":",
"logger",
".",
"error",
"(",
"f'Missed target name, target: {self.path}'",
")",
"... | [
77,
4
] | [
83,
26
] | python | en | ['fi', 'id', 'en'] | False |
Target.version | (self) | return target version
| return target version
| def version(self) -> str:
''' return target version
'''
target_version = self._metadata.get('version', None)
if not target_version:
logger.error(f'Missed target version, target: {self.path}')
return target_version | [
"def",
"version",
"(",
"self",
")",
"->",
"str",
":",
"target_version",
"=",
"self",
".",
"_metadata",
".",
"get",
"(",
"'version'",
",",
"None",
")",
"if",
"not",
"target_version",
":",
"logger",
".",
"error",
"(",
"f'Missed target version, target: {self.path... | [
86,
4
] | [
92,
29
] | python | en | ['fi', 'jv', 'en'] | False |
Target.get_image_uri | (self, registry:str, branch:str) | returns image uri based on registry and branch info
| returns image uri based on registry and branch info
| def get_image_uri(self, registry:str, branch:str) -> str:
''' returns image uri based on registry and branch info
'''
if not registry or not branch:
logger.error(f'Missed registry or branch parameters, registry: {registry}, branch: {branch}')
return None
image_ur... | [
"def",
"get_image_uri",
"(",
"self",
",",
"registry",
":",
"str",
",",
"branch",
":",
"str",
")",
"->",
"str",
":",
"if",
"not",
"registry",
"or",
"not",
"branch",
":",
"logger",
".",
"error",
"(",
"f'Missed registry or branch parameters, registry: {registry}, b... | [
94,
4
] | [
102,
50
] | python | en | ['en', 'en', 'en'] | True |
Target.root_path | (filepath:Path) | return a roor path to target by file path
| return a roor path to target by file path
| def root_path(filepath:Path) -> Path:
''' return a roor path to target by file path
'''
path = filepath.parent
if str(path) == '.':
return None
if not path.joinpath('TARGET.yml').exists():
path = Target.root_path(path)
return path | [
"def",
"root_path",
"(",
"filepath",
":",
"Path",
")",
"->",
"Path",
":",
"path",
"=",
"filepath",
".",
"parent",
"if",
"str",
"(",
"path",
")",
"==",
"'.'",
":",
"return",
"None",
"if",
"not",
"path",
".",
"joinpath",
"(",
"'TARGET.yml'",
")",
".",
... | [
105,
4
] | [
114,
19
] | python | en | ['en', 'en', 'en'] | True |
TargetScanner.run | (self) | run scanning of targets in path
| run scanning of targets in path
| def run(self):
''' run scanning of targets in path
'''
for target_file in self._path.glob("**/TARGET.yml"):
target_path = target_file.relative_to(self._path).parent
yield target_path | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"target_file",
"in",
"self",
".",
"_path",
".",
"glob",
"(",
"\"**/TARGET.yml\"",
")",
":",
"target_path",
"=",
"target_file",
".",
"relative_to",
"(",
"self",
".",
"_path",
")",
".",
"parent",
"yield",
"target... | [
118,
4
] | [
123,
29
] | python | en | ['en', 'en', 'en'] | True |
TargetDeps.reverse | (self) | return a reversed dependency structure
where a key is target and a value is a list of child targets
| return a reversed dependency structure
where a key is target and a value is a list of child targets
| def reverse(self) -> dict:
''' return a reversed dependency structure
where a key is target and a value is a list of child targets
'''
targets = defaultdict(list)
for target, deps in self._deps.items():
if len(deps) == 0:
continue
for pare... | [
"def",
"reverse",
"(",
"self",
")",
"->",
"dict",
":",
"targets",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"target",
",",
"deps",
"in",
"self",
".",
"_deps",
".",
"items",
"(",
")",
":",
"if",
"len",
"(",
"deps",
")",
"==",
"0",
":",
"continu... | [
147,
4
] | [
162,
22
] | python | en | ['en', 'en', 'en'] | True |
TargetDeps.parents | (self, target:str) | return a list of target's parents
| return a list of target's parents
| def parents(self, target:str) -> list:
''' return a list of target's parents
'''
_parents = list()
for parent in self._deps.get(target, []):
_parents.append(parent)
_parents.extend(self.parents(parent))
return sorted(set(_parents)) | [
"def",
"parents",
"(",
"self",
",",
"target",
":",
"str",
")",
"->",
"list",
":",
"_parents",
"=",
"list",
"(",
")",
"for",
"parent",
"in",
"self",
".",
"_deps",
".",
"get",
"(",
"target",
",",
"[",
"]",
")",
":",
"_parents",
".",
"append",
"(",
... | [
164,
4
] | [
171,
36
] | python | en | ['en', 'fr', 'en'] | True |
TargetDeps.children | (self, target:str) | return a list of target's children
| return a list of target's children
| def children(self, target:str) -> list:
''' return a list of target's children
'''
children = list()
_deps = self.reverse()
for child in _deps.get(target, []):
children.append(child)
children.extend(self.children(child))
return sorted(set(children)... | [
"def",
"children",
"(",
"self",
",",
"target",
":",
"str",
")",
"->",
"list",
":",
"children",
"=",
"list",
"(",
")",
"_deps",
"=",
"self",
".",
"reverse",
"(",
")",
"for",
"child",
"in",
"_deps",
".",
"get",
"(",
"target",
",",
"[",
"]",
")",
... | [
173,
4
] | [
181,
36
] | python | en | ['en', 'lb', 'en'] | True |
table | (name, node, mysql_node, secret_type) | Create a table that can be accessed using MySQL database engine.
| Create a table that can be accessed using MySQL database engine.
| def table(name, node, mysql_node, secret_type):
"""Create a table that can be accessed using MySQL database engine.
"""
try:
with Given("table in MySQL"):
sql = f"""
CREATE TABLE {name}(
id INT NOT NULL AUTO_INCREMENT,
date DATE,
... | [
"def",
"table",
"(",
"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,\n ... | [
10,
0
] | [
45,
121
] | python | en | ['en', 'en', 'en'] | True |
decrypt | (self, mysql_datatype) | Check that when using a table provided by MySQL database engine that
contains a column encrypted in MySQL stored using specified data type
I can decrypt data in the column using the `decrypt` and `aes_decrypt_mysql`
functions in the select query.
| Check that when using a table provided by MySQL database engine that
contains a column encrypted in MySQL stored using specified data type
I can decrypt data in the column using the `decrypt` and `aes_decrypt_mysql`
functions in the select query.
| def decrypt(self, mysql_datatype):
"""Check that when using a table provided by MySQL database engine that
contains a column encrypted in MySQL stored using specified data type
I can decrypt data in the column using the `decrypt` and `aes_decrypt_mysql`
functions in the select query.
"""
node = ... | [
"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"... | [
54,
0
] | [
107,
63
] | python | en | ['en', 'en', 'en'] | True |
encrypt | (self, mysql_datatype) | Check that when using a table provided by MySQL database engine that
we can encrypt data during insert using the `aes_encrypt_mysql` function
and decrypt it in MySQL.
| Check that when using a table provided by MySQL database engine that
we can encrypt data during insert using the `aes_encrypt_mysql` function
and decrypt it in MySQL.
| def encrypt(self, mysql_datatype):
"""Check that when using a table provided by MySQL database engine that
we can encrypt data during insert using the `aes_encrypt_mysql` function
and decrypt it in MySQL.
"""
node = self.context.node
mysql_node = self.context.mysql_node
key = f"{'1' * 64}"
... | [
"def",
"encrypt",
"(",
"self",
",",
"mysql_datatype",
")",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"mysql_node",
"=",
"self",
".",
"context",
".",
"mysql_node",
"key",
"=",
"f\"{'1' * 64}\"",
"iv",
"=",
"f\"{'2' * 64}\"",
"for",
"func",
"in"... | [
116,
0
] | [
179,
63
] | python | en | ['en', 'en', 'en'] | True |
feature | (self, node="clickhouse1", mysql_node="mysql1") | Check usage of encryption functions with [MySQL database engine].
[MySQL database engine]: https://clickhouse.tech/docs/en/engines/database-engines/mysql/
| Check usage of encryption functions with [MySQL database engine]. | def feature(self, node="clickhouse1", mysql_node="mysql1"):
"""Check usage of encryption functions with [MySQL database engine].
[MySQL database engine]: https://clickhouse.tech/docs/en/engines/database-engines/mysql/
"""
self.context.node = self.context.cluster.node(node)
self.context.mysql_node =... | [
"def",
"feature",
"(",
"self",
",",
"node",
"=",
"\"clickhouse1\"",
",",
"mysql_node",
"=",
"\"mysql1\"",
")",
":",
"self",
".",
"context",
".",
"node",
"=",
"self",
".",
"context",
".",
"cluster",
".",
"node",
"(",
"node",
")",
"self",
".",
"context",... | [
186,
0
] | [
195,
40
] | python | en | ['en', 'en', 'en'] | True |
sql_like_to_regex | (pattern, escape=None) | Convert a SQL LIKE pattern to an equivalent Python regular expression.
Parameters
----------
pattern : str
A LIKE pattern with the following semantics:
* ``%`` matches zero or more characters
* ``_`` matches exactly one character
* To escape ``%`` and ``_`` (or to match the ... | Convert a SQL LIKE pattern to an equivalent Python regular expression. | def sql_like_to_regex(pattern, escape=None):
"""Convert a SQL LIKE pattern to an equivalent Python regular expression.
Parameters
----------
pattern : str
A LIKE pattern with the following semantics:
* ``%`` matches zero or more characters
* ``_`` matches exactly one character
... | [
"def",
"sql_like_to_regex",
"(",
"pattern",
",",
"escape",
"=",
"None",
")",
":",
"return",
"'^{}$'",
".",
"format",
"(",
"''",
".",
"join",
"(",
"_sql_like_to_regex",
"(",
"pattern",
",",
"escape",
")",
")",
")"
] | [
134,
0
] | [
166,
70
] | python | en | ['en', 'en', 'en'] | True |
distribute_weights | (weights, nbin) | assign a set of weights to a smaller set of bins to balance them | assign a set of weights to a smaller set of bins to balance them | def distribute_weights(weights, nbin):
""" assign a set of weights to a smaller set of bins to balance them """
nw = weights.size
o = weights.argsort()
bins = np.zeros(nbin)
assign = np.ones(nw, dtype=int)
for i in o[::-1]:
b = bins.argmin()
assign[i] = b
bins[b] += weigh... | [
"def",
"distribute_weights",
"(",
"weights",
",",
"nbin",
")",
":",
"nw",
"=",
"weights",
".",
"size",
"o",
"=",
"weights",
".",
"argsort",
"(",
")",
"bins",
"=",
"np",
".",
"zeros",
"(",
"nbin",
")",
"assign",
"=",
"np",
".",
"ones",
"(",
"nw",
... | [
98,
0
] | [
108,
23
] | python | en | ['en', 'en', 'en'] | True |
ResultHeap.__init__ | (self, nq, k) | nq: number of query vectors, k: number of results per query | nq: number of query vectors, k: number of results per query | def __init__(self, nq, k):
" nq: number of query vectors, k: number of results per query "
self.I = np.zeros((nq, k), dtype='int64')
self.D = np.zeros((nq, k), dtype='float32')
self.nq, self.k = nq, k
heaps = faiss.float_maxheap_array_t()
heaps.k = k
heaps.nh = nq... | [
"def",
"__init__",
"(",
"self",
",",
"nq",
",",
"k",
")",
":",
"self",
".",
"I",
"=",
"np",
".",
"zeros",
"(",
"(",
"nq",
",",
"k",
")",
",",
"dtype",
"=",
"'int64'",
")",
"self",
".",
"D",
"=",
"np",
".",
"zeros",
"(",
"(",
"nq",
",",
"k... | [
74,
4
] | [
85,
26
] | python | en | ['en', 'en', 'pt'] | True |
calculate_discriminability | (scaling, proportionality_factor, critical_scaling) | r"""Calculate disriminability at given scaling, for specified parameters.
This comes from the Online Methods section of [1]_, equation 17.
Parameters
----------
scaling : jnp.ndarray
Scaling value(s) to calculate discriminability for.
proportionality_factor : jnp.ndarray or float
T... | r"""Calculate disriminability at given scaling, for specified parameters. | def calculate_discriminability(scaling, proportionality_factor, critical_scaling):
r"""Calculate disriminability at given scaling, for specified parameters.
This comes from the Online Methods section of [1]_, equation 17.
Parameters
----------
scaling : jnp.ndarray
Scaling value(s) to calc... | [
"def",
"calculate_discriminability",
"(",
"scaling",
",",
"proportionality_factor",
",",
"critical_scaling",
")",
":",
"vals",
"=",
"proportionality_factor",
"*",
"(",
"1",
"-",
"(",
"critical_scaling",
"**",
"2",
"/",
"scaling",
"**",
"2",
")",
")",
"# this has... | [
16,
0
] | [
47,
23
] | python | en | ['en', 'en', 'en'] | True |
proportion_correct_curve | (scaling, proportionality_factor, critical_scaling) | r"""Compute the proportion correct curve, as function of parameters.
This comes from the Online Methods section of [1]_, equation 18.
Parameters
----------
scaling : jnp.ndarray
Scaling value(s) to calculate discriminability for.
proportionality_factor : jnp.ndarray or float
The "g... | r"""Compute the proportion correct curve, as function of parameters. | def proportion_correct_curve(scaling, proportionality_factor, critical_scaling):
r"""Compute the proportion correct curve, as function of parameters.
This comes from the Online Methods section of [1]_, equation 18.
Parameters
----------
scaling : jnp.ndarray
Scaling value(s) to calculate d... | [
"def",
"proportion_correct_curve",
"(",
"scaling",
",",
"proportionality_factor",
",",
"critical_scaling",
")",
":",
"norm",
"=",
"jsc",
".",
"stats",
".",
"norm",
"discrim",
"=",
"calculate_discriminability",
"(",
"scaling",
",",
"proportionality_factor",
",",
"cri... | [
50,
0
] | [
89,
78
] | python | en | ['en', 'en', 'en'] | True |
partially_pooled_response_model | (scaling, model='V1', observed_responses=None) | r"""Partially pooled probabilistic model of responses, with lapse rate.
This is "partially pooled" because of how we handle the image and subject
level effects on the two parameters of interest.
- Critical scaling ($s_0$) and proportionality factor / gain ($\alpha_0$)
are both modeled on a natural l... | r"""Partially pooled probabilistic model of responses, with lapse rate. | def partially_pooled_response_model(scaling, model='V1', observed_responses=None):
r"""Partially pooled probabilistic model of responses, with lapse rate.
This is "partially pooled" because of how we handle the image and subject
level effects on the two parameters of interest.
- Critical scaling ($s_0... | [
"def",
"partially_pooled_response_model",
"(",
"scaling",
",",
"model",
"=",
"'V1'",
",",
"observed_responses",
"=",
"None",
")",
":",
"# because this is a 2AFC task",
"chance_correct",
"=",
".5",
"# first get rid of model dim, since we're not using it here.",
"if",
"scaling"... | [
92,
0
] | [
293,
61
] | python | en | ['en', 'en', 'en'] | True |
unpooled_response_model | (scaling, model='V1', observed_responses=None) | r"""Probabilistic model of responses, with lapse rate.
This is "unpooled" because we model the parameters of interest
independently for each psychophysical curve (i.e., each image/subject)
- Critical scaling ($s_0$) and proportionality factor / gain ($\alpha_0$)
are both modeled on a natural log-sca... | r"""Probabilistic model of responses, with lapse rate. | def unpooled_response_model(scaling, model='V1', observed_responses=None):
r"""Probabilistic model of responses, with lapse rate.
This is "unpooled" because we model the parameters of interest
independently for each psychophysical curve (i.e., each image/subject)
- Critical scaling ($s_0$) and proport... | [
"def",
"unpooled_response_model",
"(",
"scaling",
",",
"model",
"=",
"'V1'",
",",
"observed_responses",
"=",
"None",
")",
":",
"# because this is a 2AFC task",
"chance_correct",
"=",
".5",
"# first get rid of model dim, since we're not using it here.",
"if",
"scaling",
".",... | [
296,
0
] | [
448,
65
] | python | en | ['en', 'en', 'en'] | True |
assemble_dataset_from_expt_df | (expt_df,
dep_variables=['subject_name', 'image_name',
'trial_type', 'model']) | Create Dataset from expt_df.
Creates the xarray Dataset necessary for using MCMC to fit psychophysical
curve to the expt_df, as created by `analysis.create_experiment_df` and
`analysis.add_response_info`.
Parameters
----------
expt_df : pd.DataFrame
DataFrame containing the results of ... | Create Dataset from expt_df. | def assemble_dataset_from_expt_df(expt_df,
dep_variables=['subject_name', 'image_name',
'trial_type', 'model']):
"""Create Dataset from expt_df.
Creates the xarray Dataset necessary for using MCMC to fit psychophysical
curve... | [
"def",
"assemble_dataset_from_expt_df",
"(",
"expt_df",
",",
"dep_variables",
"=",
"[",
"'subject_name'",
",",
"'image_name'",
",",
"'trial_type'",
",",
"'model'",
"]",
")",
":",
"expt_df",
"=",
"expt_df",
"[",
"dep_variables",
"+",
"[",
"'scaling'",
",",
"'hit_... | [
451,
0
] | [
486,
18
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (_hass: HomeAssistant, _config: Config) | Set up this integration using YAML is not supported. | Set up this integration using YAML is not supported. | async def async_setup(_hass: HomeAssistant, _config: Config):
"""Set up this integration using YAML is not supported."""
return True | [
"async",
"def",
"async_setup",
"(",
"_hass",
":",
"HomeAssistant",
",",
"_config",
":",
"Config",
")",
":",
"return",
"True"
] | [
30,
0
] | [
32,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up this integration using UI. | Set up this integration using UI. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up this integration using UI."""
if hass.data.get(DOMAIN) is None:
hass.data.setdefault(DOMAIN, {})
_LOGGER.info(STARTUP_MESSAGE)
email = entry.data.get(CONF_EMAIL)
password = entry.data.get(CONF_PASSWORD)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"if",
"hass",
".",
"data",
".",
"get",
"(",
"DOMAIN",
")",
"is",
"None",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
","... | [
35,
0
] | [
87,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Handle removal of an entry. | Handle removal of an entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Handle removal of an entry."""
coordinator: DukeEnergyGatewayUsageDataUpdateCoordinator = hass.data[DOMAIN][
entry.entry_id
]["coordinator"]
unloaded = all(
await asyncio.gather(
*[
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"coordinator",
":",
"DukeEnergyGatewayUsageDataUpdateCoordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",... | [
90,
0
] | [
113,
19
] | python | en | ['en', 'en', 'en'] | True |
async_reload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Reload config entry. | Reload config entry. | async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Reload config entry."""
await async_unload_entry(hass, entry)
await async_setup_entry(hass, entry) | [
"async",
"def",
"async_reload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"await",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
"await",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")"
] | [
116,
0
] | [
119,
40
] | python | da | ['da', 'da', 'en'] | True |
table | (name, node, mysql_node, secret_type) | Create a table that can be accessed using MySQL table function.
| Create a table that can be accessed using MySQL table function.
| def table(name, node, mysql_node, secret_type):
"""Create a table that can be accessed using MySQL table function.
"""
try:
with Given("table in MySQL"):
sql = f"""
CREATE TABLE {name}(
id INT NOT NULL AUTO_INCREMENT,
date DATE,
... | [
"def",
"table",
"(",
"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,\n ... | [
10,
0
] | [
32,
121
] | python | en | ['en', 'en', 'en'] | True |
decrypt | (self, mysql_datatype) | Check that when using a table accessed through MySQL table function that
contains a column encrypted in MySQL stored using specified data type
I can decrypt data in the column using the `decrypt` and `aes_decrypt_mysql`
functions in the select query.
| Check that when using a table accessed through MySQL table function that
contains a column encrypted in MySQL stored using specified data type
I can decrypt data in the column using the `decrypt` and `aes_decrypt_mysql`
functions in the select query.
| def decrypt(self, mysql_datatype):
"""Check that when using a table accessed through MySQL table function that
contains a column encrypted in MySQL stored using specified data type
I can decrypt data in the column using the `decrypt` and `aes_decrypt_mysql`
functions in the select query.
"""
nod... | [
"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"... | [
41,
0
] | [
94,
63
] | python | en | ['en', 'en', 'en'] | True |
encrypt | (self, mysql_datatype) | Check that when using a table accessed through MySQL table function that
we can encrypt data during insert using the `aes_encrypt_mysql` function
and decrypt it in MySQL.
| Check that when using a table accessed through MySQL table function that
we can encrypt data during insert using the `aes_encrypt_mysql` function
and decrypt it in MySQL.
| def encrypt(self, mysql_datatype):
"""Check that when using a table accessed through MySQL table function that
we can encrypt data during insert using the `aes_encrypt_mysql` function
and decrypt it in MySQL.
"""
node = self.context.node
mysql_node = self.context.mysql_node
key = f"{'1' * 64... | [
"def",
"encrypt",
"(",
"self",
",",
"mysql_datatype",
")",
":",
"node",
"=",
"self",
".",
"context",
".",
"node",
"mysql_node",
"=",
"self",
".",
"context",
".",
"mysql_node",
"key",
"=",
"f\"{'1' * 64}\"",
"iv",
"=",
"f\"{'2' * 64}\"",
"for",
"func",
"in"... | [
103,
0
] | [
166,
63
] | 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.