repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_updatereplication | def do_updatereplication(self, line):
"""updatereplication <identifier> [identifier ...] Update the Replication Policy
on one or more existing Science Data Objects."""
pids = self._split_args(line, 1, -1)
self._command_processor.update_replication_policy(pids)
self._print_info_if... | python | def do_updatereplication(self, line):
"""updatereplication <identifier> [identifier ...] Update the Replication Policy
on one or more existing Science Data Objects."""
pids = self._split_args(line, 1, -1)
self._command_processor.update_replication_policy(pids)
self._print_info_if... | [
"def",
"do_updatereplication",
"(",
"self",
",",
"line",
")",
":",
"pids",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"-",
"1",
")",
"self",
".",
"_command_processor",
".",
"update_replication_policy",
"(",
"pids",
")",
"self",
".",
"_p... | updatereplication <identifier> [identifier ...] Update the Replication Policy
on one or more existing Science Data Objects. | [
"updatereplication",
"<identifier",
">",
"[",
"identifier",
"...",
"]",
"Update",
"the",
"Replication",
"Policy",
"on",
"one",
"or",
"more",
"existing",
"Science",
"Data",
"Objects",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L441-L450 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_search | def do_search(self, line):
"""search [query] Comprehensive search for Science Data Objects across all
available MNs.
See https://releases.dataone.org/online/api-
documentation-v2.0.1/design/SearchMetadata.html for the available search terms.
"""
args = self._split_args(... | python | def do_search(self, line):
"""search [query] Comprehensive search for Science Data Objects across all
available MNs.
See https://releases.dataone.org/online/api-
documentation-v2.0.1/design/SearchMetadata.html for the available search terms.
"""
args = self._split_args(... | [
"def",
"do_search",
"(",
"self",
",",
"line",
")",
":",
"args",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"-",
"1",
")",
"query",
"=",
"\" \"",
".",
"join",
"(",
"[",
"_f",
"for",
"_f",
"in",
"args",
"if",
"_f",
"]",
")",
"... | search [query] Comprehensive search for Science Data Objects across all
available MNs.
See https://releases.dataone.org/online/api-
documentation-v2.0.1/design/SearchMetadata.html for the available search terms. | [
"search",
"[",
"query",
"]",
"Comprehensive",
"search",
"for",
"Science",
"Data",
"Objects",
"across",
"all",
"available",
"MNs",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L466-L476 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_ping | def do_ping(self, line):
"""ping [base-url ...] Check if a server responds to the DataONE ping() API
method ping (no arguments): Ping the CN and MN that is specified in the session
ping <base-url> [base-url ...]: Ping each CN or MN.
If an incomplete base-url is provided, default CN and ... | python | def do_ping(self, line):
"""ping [base-url ...] Check if a server responds to the DataONE ping() API
method ping (no arguments): Ping the CN and MN that is specified in the session
ping <base-url> [base-url ...]: Ping each CN or MN.
If an incomplete base-url is provided, default CN and ... | [
"def",
"do_ping",
"(",
"self",
",",
"line",
")",
":",
"hosts",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"99",
",",
"pad",
"=",
"False",
")",
"self",
".",
"_command_processor",
".",
"ping",
"(",
"hosts",
")"
] | ping [base-url ...] Check if a server responds to the DataONE ping() API
method ping (no arguments): Ping the CN and MN that is specified in the session
ping <base-url> [base-url ...]: Ping each CN or MN.
If an incomplete base-url is provided, default CN and MN base URLs at the given
ur... | [
"ping",
"[",
"base",
"-",
"url",
"...",
"]",
"Check",
"if",
"a",
"server",
"responds",
"to",
"the",
"DataONE",
"ping",
"()",
"API",
"method",
"ping",
"(",
"no",
"arguments",
")",
":",
"Ping",
"the",
"CN",
"and",
"MN",
"that",
"is",
"specified",
"in",... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L478-L488 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_queue | def do_queue(self, line):
"""queue Print the queue of write operations."""
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().display() | python | def do_queue(self, line):
"""queue Print the queue of write operations."""
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().display() | [
"def",
"do_queue",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_operation_queue",
"(",
")",
".",
"display",
"(",
")"
] | queue Print the queue of write operations. | [
"queue",
"Print",
"the",
"queue",
"of",
"write",
"operations",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L494-L497 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_run | def do_run(self, line):
"""run Perform each operation in the queue of write operations."""
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().execute()
self._print_info_if_verbose(
"All operations in the write queue were successfully executed"
... | python | def do_run(self, line):
"""run Perform each operation in the queue of write operations."""
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().execute()
self._print_info_if_verbose(
"All operations in the write queue were successfully executed"
... | [
"def",
"do_run",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_operation_queue",
"(",
")",
".",
"execute",
"(",
")",
"self",
".",
"_print_info_if_verbose... | run Perform each operation in the queue of write operations. | [
"run",
"Perform",
"each",
"operation",
"in",
"the",
"queue",
"of",
"write",
"operations",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L499-L505 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_edit | def do_edit(self, line):
"""edit Edit the queue of write operations."""
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().edit()
self._print_info_if_verbose("The write operation queue was successfully edited") | python | def do_edit(self, line):
"""edit Edit the queue of write operations."""
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().edit()
self._print_info_if_verbose("The write operation queue was successfully edited") | [
"def",
"do_edit",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_operation_queue",
"(",
")",
".",
"edit",
"(",
")",
"self",
".",
"_print_info_if_verbose",... | edit Edit the queue of write operations. | [
"edit",
"Edit",
"the",
"queue",
"of",
"write",
"operations",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L507-L511 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_clearqueue | def do_clearqueue(self, line):
"""clearqueue Remove the operations in the queue of write operations without
performing them."""
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().clear()
self._print_info_if_verbose("All operations in the write queue were c... | python | def do_clearqueue(self, line):
"""clearqueue Remove the operations in the queue of write operations without
performing them."""
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().clear()
self._print_info_if_verbose("All operations in the write queue were c... | [
"def",
"do_clearqueue",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_operation_queue",
"(",
")",
".",
"clear",
"(",
")",
"self",
".",
"_print_info_if_ve... | clearqueue Remove the operations in the queue of write operations without
performing them. | [
"clearqueue",
"Remove",
"the",
"operations",
"in",
"the",
"queue",
"of",
"write",
"operations",
"without",
"performing",
"them",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L513-L518 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI._print_help | def _print_help(self):
"""Custom help message to group commands by functionality."""
msg = """Commands (type help <command> for details)
CLI: help history exit quit
Session, General: set load save reset
Session, Access Control: allowaccess denyaccess clearaccess
Session, Repl... | python | def _print_help(self):
"""Custom help message to group commands by functionality."""
msg = """Commands (type help <command> for details)
CLI: help history exit quit
Session, General: set load save reset
Session, Access Control: allowaccess denyaccess clearaccess
Session, Repl... | [
"def",
"_print_help",
"(",
"self",
")",
":",
"msg",
"=",
"\"\"\"Commands (type help <command> for details)\n\nCLI: help history exit quit\nSession, General: set load save reset\nSession, Access Control: allowaccess denyaccess clearaccess\nSession, Replication: allowrep ... | Custom help message to group commands by functionality. | [
"Custom",
"help",
"message",
"to",
"group",
"commands",
"by",
"functionality",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L565-L587 |
genialis/resolwe | resolwe/permissions/shortcuts.py | get_groups_with_perms | def get_groups_with_perms(obj, attach_perms=False):
"""Return queryset of all ``Group`` objects with *any* object permissions for the given ``obj``."""
ctype = get_content_type(obj)
group_model = get_group_obj_perms_model(obj)
if not attach_perms:
# It's much easier without attached perms so we... | python | def get_groups_with_perms(obj, attach_perms=False):
"""Return queryset of all ``Group`` objects with *any* object permissions for the given ``obj``."""
ctype = get_content_type(obj)
group_model = get_group_obj_perms_model(obj)
if not attach_perms:
# It's much easier without attached perms so we... | [
"def",
"get_groups_with_perms",
"(",
"obj",
",",
"attach_perms",
"=",
"False",
")",
":",
"ctype",
"=",
"get_content_type",
"(",
"obj",
")",
"group_model",
"=",
"get_group_obj_perms_model",
"(",
"obj",
")",
"if",
"not",
"attach_perms",
":",
"# It's much easier with... | Return queryset of all ``Group`` objects with *any* object permissions for the given ``obj``. | [
"Return",
"queryset",
"of",
"all",
"Group",
"objects",
"with",
"*",
"any",
"*",
"object",
"permissions",
"for",
"the",
"given",
"obj",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/shortcuts.py#L31-L58 |
genialis/resolwe | resolwe/permissions/shortcuts.py | _group_groups | def _group_groups(perm_list):
"""Group permissions by group.
Input is list of tuples of length 3, where each tuple is in
following format::
(<group_id>, <group_name>, <single_permission>)
Permissions are regrouped and returned in such way that there is
only one tuple for each group::
... | python | def _group_groups(perm_list):
"""Group permissions by group.
Input is list of tuples of length 3, where each tuple is in
following format::
(<group_id>, <group_name>, <single_permission>)
Permissions are regrouped and returned in such way that there is
only one tuple for each group::
... | [
"def",
"_group_groups",
"(",
"perm_list",
")",
":",
"perm_list",
"=",
"sorted",
"(",
"perm_list",
",",
"key",
"=",
"lambda",
"tup",
":",
"tup",
"[",
"0",
"]",
")",
"grouped_perms",
"=",
"[",
"]",
"for",
"key",
",",
"group",
"in",
"groupby",
"(",
"per... | Group permissions by group.
Input is list of tuples of length 3, where each tuple is in
following format::
(<group_id>, <group_name>, <single_permission>)
Permissions are regrouped and returned in such way that there is
only one tuple for each group::
(<group_id>, <group_name>, [<fir... | [
"Group",
"permissions",
"by",
"group",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/shortcuts.py#L61-L85 |
genialis/resolwe | resolwe/permissions/shortcuts.py | get_user_group_perms | def get_user_group_perms(user_or_group, obj):
"""Get permissins for user groups.
Based on guardian.core.ObjectPermissionChecker.
"""
user, group = get_identity(user_or_group)
if user and not user.is_active:
return [], []
user_model = get_user_model()
ctype = ContentType.objects.ge... | python | def get_user_group_perms(user_or_group, obj):
"""Get permissins for user groups.
Based on guardian.core.ObjectPermissionChecker.
"""
user, group = get_identity(user_or_group)
if user and not user.is_active:
return [], []
user_model = get_user_model()
ctype = ContentType.objects.ge... | [
"def",
"get_user_group_perms",
"(",
"user_or_group",
",",
"obj",
")",
":",
"user",
",",
"group",
"=",
"get_identity",
"(",
"user_or_group",
")",
"if",
"user",
"and",
"not",
"user",
".",
"is_active",
":",
"return",
"[",
"]",
",",
"[",
"]",
"user_model",
"... | Get permissins for user groups.
Based on guardian.core.ObjectPermissionChecker. | [
"Get",
"permissins",
"for",
"user",
"groups",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/shortcuts.py#L88-L143 |
genialis/resolwe | resolwe/permissions/shortcuts.py | get_object_perms | def get_object_perms(obj, user=None):
"""Return permissions for given object in Resolwe specific format.
Function returns permissions for given object ``obj`` in following
format::
{
"type": "group"/"user"/"public",
"id": <group_or_user_id>,
"name": <group_or_user_n... | python | def get_object_perms(obj, user=None):
"""Return permissions for given object in Resolwe specific format.
Function returns permissions for given object ``obj`` in following
format::
{
"type": "group"/"user"/"public",
"id": <group_or_user_id>,
"name": <group_or_user_n... | [
"def",
"get_object_perms",
"(",
"obj",
",",
"user",
"=",
"None",
")",
":",
"def",
"format_permissions",
"(",
"perms",
")",
":",
"\"\"\"Remove model name from permission.\"\"\"",
"ctype",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"obj",
")",
... | Return permissions for given object in Resolwe specific format.
Function returns permissions for given object ``obj`` in following
format::
{
"type": "group"/"user"/"public",
"id": <group_or_user_id>,
"name": <group_or_user_name>,
"permissions": [<first_permi... | [
"Return",
"permissions",
"for",
"given",
"object",
"in",
"Resolwe",
"specific",
"format",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/shortcuts.py#L146-L235 |
genialis/resolwe | resolwe/permissions/shortcuts.py | get_objects_for_user | def get_objects_for_user(user, perms, klass=None, use_groups=True, any_perm=False,
with_superuser=True, accept_global_perms=True, perms_filter='pk__in'):
"""Return queryset with required permissions."""
if isinstance(perms, str):
perms = [perms]
ctype = None
app_label =... | python | def get_objects_for_user(user, perms, klass=None, use_groups=True, any_perm=False,
with_superuser=True, accept_global_perms=True, perms_filter='pk__in'):
"""Return queryset with required permissions."""
if isinstance(perms, str):
perms = [perms]
ctype = None
app_label =... | [
"def",
"get_objects_for_user",
"(",
"user",
",",
"perms",
",",
"klass",
"=",
"None",
",",
"use_groups",
"=",
"True",
",",
"any_perm",
"=",
"False",
",",
"with_superuser",
"=",
"True",
",",
"accept_global_perms",
"=",
"True",
",",
"perms_filter",
"=",
"'pk__i... | Return queryset with required permissions. | [
"Return",
"queryset",
"with",
"required",
"permissions",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/shortcuts.py#L239-L394 |
genialis/resolwe | resolwe/permissions/shortcuts.py | get_users_with_permission | def get_users_with_permission(obj, permission):
"""Return users with specific permission on object.
:param obj: Object to return users for
:param permission: Permission codename
"""
user_model = get_user_model()
return user_model.objects.filter(
userobjectpermission__object_pk=obj.pk,
... | python | def get_users_with_permission(obj, permission):
"""Return users with specific permission on object.
:param obj: Object to return users for
:param permission: Permission codename
"""
user_model = get_user_model()
return user_model.objects.filter(
userobjectpermission__object_pk=obj.pk,
... | [
"def",
"get_users_with_permission",
"(",
"obj",
",",
"permission",
")",
":",
"user_model",
"=",
"get_user_model",
"(",
")",
"return",
"user_model",
".",
"objects",
".",
"filter",
"(",
"userobjectpermission__object_pk",
"=",
"obj",
".",
"pk",
",",
"userobjectpermis... | Return users with specific permission on object.
:param obj: Object to return users for
:param permission: Permission codename | [
"Return",
"users",
"with",
"specific",
"permission",
"on",
"object",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/shortcuts.py#L397-L407 |
genialis/resolwe | resolwe/flow/consumers.py | PurgeConsumer.purge_run | def purge_run(self, event):
"""Run purge for the object with ``location_id`` specified in ``event`` argument."""
location_id = event['location_id']
verbosity = event['verbosity']
try:
logger.info(__("Running purge for location id {}.", location_id))
location_purg... | python | def purge_run(self, event):
"""Run purge for the object with ``location_id`` specified in ``event`` argument."""
location_id = event['location_id']
verbosity = event['verbosity']
try:
logger.info(__("Running purge for location id {}.", location_id))
location_purg... | [
"def",
"purge_run",
"(",
"self",
",",
"event",
")",
":",
"location_id",
"=",
"event",
"[",
"'location_id'",
"]",
"verbosity",
"=",
"event",
"[",
"'verbosity'",
"]",
"try",
":",
"logger",
".",
"info",
"(",
"__",
"(",
"\"Running purge for location id {}.\"",
"... | Run purge for the object with ``location_id`` specified in ``event`` argument. | [
"Run",
"purge",
"for",
"the",
"object",
"with",
"location_id",
"specified",
"in",
"event",
"argument",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/consumers.py#L15-L24 |
genialis/resolwe | resolwe/flow/models/process.py | Process.get_resource_limits | def get_resource_limits(self):
"""Get the core count and memory usage limits for this process.
:return: A dictionary with the resource limits, containing the
following keys:
- ``memory``: Memory usage limit, in MB. Defaults to 4096 if
not otherwise specified in th... | python | def get_resource_limits(self):
"""Get the core count and memory usage limits for this process.
:return: A dictionary with the resource limits, containing the
following keys:
- ``memory``: Memory usage limit, in MB. Defaults to 4096 if
not otherwise specified in th... | [
"def",
"get_resource_limits",
"(",
"self",
")",
":",
"# Get limit defaults and overrides.",
"limit_defaults",
"=",
"getattr",
"(",
"settings",
",",
"'FLOW_PROCESS_RESOURCE_DEFAULTS'",
",",
"{",
"}",
")",
"limit_overrides",
"=",
"getattr",
"(",
"settings",
",",
"'FLOW_... | Get the core count and memory usage limits for this process.
:return: A dictionary with the resource limits, containing the
following keys:
- ``memory``: Memory usage limit, in MB. Defaults to 4096 if
not otherwise specified in the resource requirements.
- ``c... | [
"Get",
"the",
"core",
"count",
"and",
"memory",
"usage",
"limits",
"for",
"this",
"process",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/process.py#L167-L202 |
genialis/resolwe | resolwe/flow/filters.py | CheckQueryParamsMixin.validate_query_params | def validate_query_params(self):
"""Ensure no unsupported query params were used."""
allowed_params = set(self.get_filters().keys())
allowed_params.update(self.get_always_allowed_arguments())
unallowed = set(self.request.query_params.keys()) - allowed_params
if unallowed:
... | python | def validate_query_params(self):
"""Ensure no unsupported query params were used."""
allowed_params = set(self.get_filters().keys())
allowed_params.update(self.get_always_allowed_arguments())
unallowed = set(self.request.query_params.keys()) - allowed_params
if unallowed:
... | [
"def",
"validate_query_params",
"(",
"self",
")",
":",
"allowed_params",
"=",
"set",
"(",
"self",
".",
"get_filters",
"(",
")",
".",
"keys",
"(",
")",
")",
"allowed_params",
".",
"update",
"(",
"self",
".",
"get_always_allowed_arguments",
"(",
")",
")",
"u... | Ensure no unsupported query params were used. | [
"Ensure",
"no",
"unsupported",
"query",
"params",
"were",
"used",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/filters.py#L59-L71 |
wilson-eft/wilson | wilson/classes.py | ConfigurableClass.set_default_option | def set_default_option(cls, key, value):
"""Class method. Set the default value of the option `key` (string)
to `value` for all future instances of the class.
Note that this does not affect existing instances or the instance
called from."""
cls._default_options.update(cls._optio... | python | def set_default_option(cls, key, value):
"""Class method. Set the default value of the option `key` (string)
to `value` for all future instances of the class.
Note that this does not affect existing instances or the instance
called from."""
cls._default_options.update(cls._optio... | [
"def",
"set_default_option",
"(",
"cls",
",",
"key",
",",
"value",
")",
":",
"cls",
".",
"_default_options",
".",
"update",
"(",
"cls",
".",
"_option_schema",
"(",
"{",
"key",
":",
"value",
"}",
")",
")"
] | Class method. Set the default value of the option `key` (string)
to `value` for all future instances of the class.
Note that this does not affect existing instances or the instance
called from. | [
"Class",
"method",
".",
"Set",
"the",
"default",
"value",
"of",
"the",
"option",
"key",
"(",
"string",
")",
"to",
"value",
"for",
"all",
"future",
"instances",
"of",
"the",
"class",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L43-L49 |
wilson-eft/wilson | wilson/classes.py | ConfigurableClass.set_option | def set_option(self, key, value):
"""Set the option `key` (string) to `value`.
Instance method, affects only current instance.
This will clear the cache."""
self._options.update(self._option_schema({key: value}))
self.clear_cache() | python | def set_option(self, key, value):
"""Set the option `key` (string) to `value`.
Instance method, affects only current instance.
This will clear the cache."""
self._options.update(self._option_schema({key: value}))
self.clear_cache() | [
"def",
"set_option",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_options",
".",
"update",
"(",
"self",
".",
"_option_schema",
"(",
"{",
"key",
":",
"value",
"}",
")",
")",
"self",
".",
"clear_cache",
"(",
")"
] | Set the option `key` (string) to `value`.
Instance method, affects only current instance.
This will clear the cache. | [
"Set",
"the",
"option",
"key",
"(",
"string",
")",
"to",
"value",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L51-L57 |
wilson-eft/wilson | wilson/classes.py | ConfigurableClass.get_option | def get_option(self, key):
"""Return the current value of the option `key` (string).
Instance method, only refers to current instance."""
return self._options.get(key, self._default_options[key]) | python | def get_option(self, key):
"""Return the current value of the option `key` (string).
Instance method, only refers to current instance."""
return self._options.get(key, self._default_options[key]) | [
"def",
"get_option",
"(",
"self",
",",
"key",
")",
":",
"return",
"self",
".",
"_options",
".",
"get",
"(",
"key",
",",
"self",
".",
"_default_options",
"[",
"key",
"]",
")"
] | Return the current value of the option `key` (string).
Instance method, only refers to current instance. | [
"Return",
"the",
"current",
"value",
"of",
"the",
"option",
"key",
"(",
"string",
")",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L59-L63 |
wilson-eft/wilson | wilson/classes.py | Wilson.from_wc | def from_wc(cls, wc):
"""Return a `Wilson` instance initialized by a `wcxf.WC` instance"""
return cls(wcdict=wc.dict, scale=wc.scale, eft=wc.eft, basis=wc.basis) | python | def from_wc(cls, wc):
"""Return a `Wilson` instance initialized by a `wcxf.WC` instance"""
return cls(wcdict=wc.dict, scale=wc.scale, eft=wc.eft, basis=wc.basis) | [
"def",
"from_wc",
"(",
"cls",
",",
"wc",
")",
":",
"return",
"cls",
"(",
"wcdict",
"=",
"wc",
".",
"dict",
",",
"scale",
"=",
"wc",
".",
"scale",
",",
"eft",
"=",
"wc",
".",
"eft",
",",
"basis",
"=",
"wc",
".",
"basis",
")"
] | Return a `Wilson` instance initialized by a `wcxf.WC` instance | [
"Return",
"a",
"Wilson",
"instance",
"initialized",
"by",
"a",
"wcxf",
".",
"WC",
"instance"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L132-L134 |
wilson-eft/wilson | wilson/classes.py | Wilson.load_wc | def load_wc(cls, stream):
"""Return a `Wilson` instance initialized by a WCxf file-like object"""
wc = wcxf.WC.load(stream)
return cls.from_wc(wc) | python | def load_wc(cls, stream):
"""Return a `Wilson` instance initialized by a WCxf file-like object"""
wc = wcxf.WC.load(stream)
return cls.from_wc(wc) | [
"def",
"load_wc",
"(",
"cls",
",",
"stream",
")",
":",
"wc",
"=",
"wcxf",
".",
"WC",
".",
"load",
"(",
"stream",
")",
"return",
"cls",
".",
"from_wc",
"(",
"wc",
")"
] | Return a `Wilson` instance initialized by a WCxf file-like object | [
"Return",
"a",
"Wilson",
"instance",
"initialized",
"by",
"a",
"WCxf",
"file",
"-",
"like",
"object"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L137-L140 |
wilson-eft/wilson | wilson/classes.py | Wilson.match_run | def match_run(self, scale, eft, basis, sectors='all'):
"""Run the Wilson coefficients to a different scale
(and possibly different EFT)
and return them as `wcxf.WC` instance.
Parameters:
- `scale`: output scale in GeV
- `eft`: output EFT
- `basis`: output basis
... | python | def match_run(self, scale, eft, basis, sectors='all'):
"""Run the Wilson coefficients to a different scale
(and possibly different EFT)
and return them as `wcxf.WC` instance.
Parameters:
- `scale`: output scale in GeV
- `eft`: output EFT
- `basis`: output basis
... | [
"def",
"match_run",
"(",
"self",
",",
"scale",
",",
"eft",
",",
"basis",
",",
"sectors",
"=",
"'all'",
")",
":",
"cached",
"=",
"self",
".",
"_get_from_cache",
"(",
"sector",
"=",
"sectors",
",",
"scale",
"=",
"scale",
",",
"eft",
"=",
"eft",
",",
... | Run the Wilson coefficients to a different scale
(and possibly different EFT)
and return them as `wcxf.WC` instance.
Parameters:
- `scale`: output scale in GeV
- `eft`: output EFT
- `basis`: output basis
- `sectors`: in the case of WET (or WET-4 or WET-3), a tup... | [
"Run",
"the",
"Wilson",
"coefficients",
"to",
"a",
"different",
"scale",
"(",
"and",
"possibly",
"different",
"EFT",
")",
"and",
"return",
"them",
"as",
"wcxf",
".",
"WC",
"instance",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L163-L240 |
wilson-eft/wilson | wilson/classes.py | Wilson._get_from_cache | def _get_from_cache(self, sector, scale, eft, basis):
"""Try to load a set of Wilson coefficients from the cache, else return
None."""
try:
return self._cache[eft][scale][basis][sector]
except KeyError:
return None | python | def _get_from_cache(self, sector, scale, eft, basis):
"""Try to load a set of Wilson coefficients from the cache, else return
None."""
try:
return self._cache[eft][scale][basis][sector]
except KeyError:
return None | [
"def",
"_get_from_cache",
"(",
"self",
",",
"sector",
",",
"scale",
",",
"eft",
",",
"basis",
")",
":",
"try",
":",
"return",
"self",
".",
"_cache",
"[",
"eft",
"]",
"[",
"scale",
"]",
"[",
"basis",
"]",
"[",
"sector",
"]",
"except",
"KeyError",
":... | Try to load a set of Wilson coefficients from the cache, else return
None. | [
"Try",
"to",
"load",
"a",
"set",
"of",
"Wilson",
"coefficients",
"from",
"the",
"cache",
"else",
"return",
"None",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L245-L251 |
wilson-eft/wilson | wilson/classes.py | RGsolution.plotdata | def plotdata(self, key, part='re', scale='log', steps=50):
"""Return a tuple of arrays x, y that can be fed to plt.plot,
where x is the scale in GeV and y is the parameter of interest.
Parameters:
- key: dicionary key of the parameter to be plotted (e.g. a WCxf
coefficient na... | python | def plotdata(self, key, part='re', scale='log', steps=50):
"""Return a tuple of arrays x, y that can be fed to plt.plot,
where x is the scale in GeV and y is the parameter of interest.
Parameters:
- key: dicionary key of the parameter to be plotted (e.g. a WCxf
coefficient na... | [
"def",
"plotdata",
"(",
"self",
",",
"key",
",",
"part",
"=",
"'re'",
",",
"scale",
"=",
"'log'",
",",
"steps",
"=",
"50",
")",
":",
"if",
"scale",
"==",
"'log'",
":",
"x",
"=",
"np",
".",
"logspace",
"(",
"log",
"(",
"self",
".",
"scale_min",
... | Return a tuple of arrays x, y that can be fed to plt.plot,
where x is the scale in GeV and y is the parameter of interest.
Parameters:
- key: dicionary key of the parameter to be plotted (e.g. a WCxf
coefficient name or a SM parameter like 'g')
- part: plot the real part 're'... | [
"Return",
"a",
"tuple",
"of",
"arrays",
"x",
"y",
"that",
"can",
"be",
"fed",
"to",
"plt",
".",
"plot",
"where",
"x",
"is",
"the",
"scale",
"in",
"GeV",
"and",
"y",
"is",
"the",
"parameter",
"of",
"interest",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L281-L308 |
wilson-eft/wilson | wilson/classes.py | RGsolution.plot | def plot(self, key, part='re', scale='log', steps=50, legend=True, plotargs={}):
"""Plot the RG evolution of parameter `key`.
Parameters:
- part, scale, steps: see `plotdata`
- legend: boolean, show the legend (default: True)
- plotargs: dictionary of arguments to be passed to ... | python | def plot(self, key, part='re', scale='log', steps=50, legend=True, plotargs={}):
"""Plot the RG evolution of parameter `key`.
Parameters:
- part, scale, steps: see `plotdata`
- legend: boolean, show the legend (default: True)
- plotargs: dictionary of arguments to be passed to ... | [
"def",
"plot",
"(",
"self",
",",
"key",
",",
"part",
"=",
"'re'",
",",
"scale",
"=",
"'log'",
",",
"steps",
"=",
"50",
",",
"legend",
"=",
"True",
",",
"plotargs",
"=",
"{",
"}",
")",
":",
"try",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
... | Plot the RG evolution of parameter `key`.
Parameters:
- part, scale, steps: see `plotdata`
- legend: boolean, show the legend (default: True)
- plotargs: dictionary of arguments to be passed to plt.plot | [
"Plot",
"the",
"RG",
"evolution",
"of",
"parameter",
"key",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L310-L328 |
genialis/resolwe | resolwe/flow/managers/consumer.py | run_consumer | async def run_consumer(timeout=None, dry_run=False):
"""Run the consumer until it finishes processing.
:param timeout: Set maximum execution time before cancellation, or
``None`` (default) for unlimited.
:param dry_run: If ``True``, don't actually dispatch messages, just
dequeue them. Defau... | python | async def run_consumer(timeout=None, dry_run=False):
"""Run the consumer until it finishes processing.
:param timeout: Set maximum execution time before cancellation, or
``None`` (default) for unlimited.
:param dry_run: If ``True``, don't actually dispatch messages, just
dequeue them. Defau... | [
"async",
"def",
"run_consumer",
"(",
"timeout",
"=",
"None",
",",
"dry_run",
"=",
"False",
")",
":",
"channel",
"=",
"state",
".",
"MANAGER_CONTROL_CHANNEL",
"scope",
"=",
"{",
"'type'",
":",
"'control_event'",
",",
"'channel'",
":",
"channel",
",",
"}",
"... | Run the consumer until it finishes processing.
:param timeout: Set maximum execution time before cancellation, or
``None`` (default) for unlimited.
:param dry_run: If ``True``, don't actually dispatch messages, just
dequeue them. Defaults to ``False``. | [
"Run",
"the",
"consumer",
"until",
"it",
"finishes",
"processing",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/consumer.py#L32-L70 |
genialis/resolwe | resolwe/elastic/composer.py | Composer.discover_extensions | def discover_extensions(self):
"""Discover available extensions."""
if self._discovery_done:
return
try:
previous_state = self._extensions.copy()
for app_config in apps.get_app_configs():
indexes_path = '{}.extensions'.format(app_config.name)... | python | def discover_extensions(self):
"""Discover available extensions."""
if self._discovery_done:
return
try:
previous_state = self._extensions.copy()
for app_config in apps.get_app_configs():
indexes_path = '{}.extensions'.format(app_config.name)... | [
"def",
"discover_extensions",
"(",
"self",
")",
":",
"if",
"self",
".",
"_discovery_done",
":",
"return",
"try",
":",
"previous_state",
"=",
"self",
".",
"_extensions",
".",
"copy",
"(",
")",
"for",
"app_config",
"in",
"apps",
".",
"get_app_configs",
"(",
... | Discover available extensions. | [
"Discover",
"available",
"extensions",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/composer.py#L16-L35 |
genialis/resolwe | resolwe/elastic/composer.py | Composer._get_class_path | def _get_class_path(self, klass_or_instance):
"""Return class path for a given class.
:param klass_or_instance: Class or instance of given class
:return: String containing the class path
"""
if inspect.isclass(klass_or_instance):
klass = '{}.{}'.format(klass_or_insta... | python | def _get_class_path(self, klass_or_instance):
"""Return class path for a given class.
:param klass_or_instance: Class or instance of given class
:return: String containing the class path
"""
if inspect.isclass(klass_or_instance):
klass = '{}.{}'.format(klass_or_insta... | [
"def",
"_get_class_path",
"(",
"self",
",",
"klass_or_instance",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"klass_or_instance",
")",
":",
"klass",
"=",
"'{}.{}'",
".",
"format",
"(",
"klass_or_instance",
".",
"__module__",
",",
"klass_or_instance",
".",
... | Return class path for a given class.
:param klass_or_instance: Class or instance of given class
:return: String containing the class path | [
"Return",
"class",
"path",
"for",
"a",
"given",
"class",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/composer.py#L37-L51 |
genialis/resolwe | resolwe/elastic/composer.py | Composer.add_extension | def add_extension(self, klass, extension):
"""Register an extension for a class.
:param klass: Class to register an extension for
:param extension: Extension (arbitrary type)
"""
klass = self._get_class_path(klass)
# TODO: Take order into account.
self._extensio... | python | def add_extension(self, klass, extension):
"""Register an extension for a class.
:param klass: Class to register an extension for
:param extension: Extension (arbitrary type)
"""
klass = self._get_class_path(klass)
# TODO: Take order into account.
self._extensio... | [
"def",
"add_extension",
"(",
"self",
",",
"klass",
",",
"extension",
")",
":",
"klass",
"=",
"self",
".",
"_get_class_path",
"(",
"klass",
")",
"# TODO: Take order into account.",
"self",
".",
"_extensions",
".",
"setdefault",
"(",
"klass",
",",
"[",
"]",
")... | Register an extension for a class.
:param klass: Class to register an extension for
:param extension: Extension (arbitrary type) | [
"Register",
"an",
"extension",
"for",
"a",
"class",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/composer.py#L53-L62 |
genialis/resolwe | resolwe/elastic/composer.py | Composer.get_extensions | def get_extensions(self, klass):
"""Return all registered extensions of a class.
:param klass: Class to get registered extensions for
:return: All registered extensions for given class
"""
self.discover_extensions()
return self._extensions.get(self._get_class_path(klass... | python | def get_extensions(self, klass):
"""Return all registered extensions of a class.
:param klass: Class to get registered extensions for
:return: All registered extensions for given class
"""
self.discover_extensions()
return self._extensions.get(self._get_class_path(klass... | [
"def",
"get_extensions",
"(",
"self",
",",
"klass",
")",
":",
"self",
".",
"discover_extensions",
"(",
")",
"return",
"self",
".",
"_extensions",
".",
"get",
"(",
"self",
".",
"_get_class_path",
"(",
"klass",
")",
",",
"[",
"]",
")"
] | Return all registered extensions of a class.
:param klass: Class to get registered extensions for
:return: All registered extensions for given class | [
"Return",
"all",
"registered",
"extensions",
"of",
"a",
"class",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/composer.py#L64-L72 |
wilson-eft/wilson | wilson/run/wet/classes.py | WETrunner._get_running_parameters | def _get_running_parameters(self, scale, f, loop=3):
"""Get the running parameters (e.g. quark masses and the strong
coupling at a given scale."""
p = {}
p['alpha_s'] = qcd.alpha_s(scale, self.f, self.parameters['alpha_s'], loop=loop)
p['m_b'] = qcd.m_b(self.parameters['m_b'], sc... | python | def _get_running_parameters(self, scale, f, loop=3):
"""Get the running parameters (e.g. quark masses and the strong
coupling at a given scale."""
p = {}
p['alpha_s'] = qcd.alpha_s(scale, self.f, self.parameters['alpha_s'], loop=loop)
p['m_b'] = qcd.m_b(self.parameters['m_b'], sc... | [
"def",
"_get_running_parameters",
"(",
"self",
",",
"scale",
",",
"f",
",",
"loop",
"=",
"3",
")",
":",
"p",
"=",
"{",
"}",
"p",
"[",
"'alpha_s'",
"]",
"=",
"qcd",
".",
"alpha_s",
"(",
"scale",
",",
"self",
".",
"f",
",",
"self",
".",
"parameters... | Get the running parameters (e.g. quark masses and the strong
coupling at a given scale. | [
"Get",
"the",
"running",
"parameters",
"(",
"e",
".",
"g",
".",
"quark",
"masses",
"and",
"the",
"strong",
"coupling",
"at",
"a",
"given",
"scale",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/wet/classes.py#L55-L70 |
wilson-eft/wilson | wilson/run/wet/classes.py | WETrunner.run | def run(self, scale_out, sectors='all'):
"""Evolve the Wilson coefficients to the scale `scale_out`.
Parameters:
- scale_out: output scale
- sectors: optional. If provided, must be a tuple of strings
corresponding to WCxf sector names. Only Wilson coefficients
belon... | python | def run(self, scale_out, sectors='all'):
"""Evolve the Wilson coefficients to the scale `scale_out`.
Parameters:
- scale_out: output scale
- sectors: optional. If provided, must be a tuple of strings
corresponding to WCxf sector names. Only Wilson coefficients
belon... | [
"def",
"run",
"(",
"self",
",",
"scale_out",
",",
"sectors",
"=",
"'all'",
")",
":",
"C_out",
"=",
"self",
".",
"_run_dict",
"(",
"scale_out",
",",
"sectors",
"=",
"sectors",
")",
"all_wcs",
"=",
"set",
"(",
"wcxf",
".",
"Basis",
"[",
"self",
".",
... | Evolve the Wilson coefficients to the scale `scale_out`.
Parameters:
- scale_out: output scale
- sectors: optional. If provided, must be a tuple of strings
corresponding to WCxf sector names. Only Wilson coefficients
belonging to these sectors will be present in the output.... | [
"Evolve",
"the",
"Wilson",
"coefficients",
"to",
"the",
"scale",
"scale_out",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/wet/classes.py#L86-L104 |
DataONEorg/d1_python | lib_common/src/d1_common/iter/stream.py | StreamIterator.size | def size(self):
"""Returns:
int : The total number of bytes that will be returned by the iterator.
"""
if hasattr(self._stream, 'len'):
return len(self._stream)
elif hasattr(self._stream, 'fileno'):
return os.fstat(self._stream.fileno()).st_size
el... | python | def size(self):
"""Returns:
int : The total number of bytes that will be returned by the iterator.
"""
if hasattr(self._stream, 'len'):
return len(self._stream)
elif hasattr(self._stream, 'fileno'):
return os.fstat(self._stream.fileno()).st_size
el... | [
"def",
"size",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"_stream",
",",
"'len'",
")",
":",
"return",
"len",
"(",
"self",
".",
"_stream",
")",
"elif",
"hasattr",
"(",
"self",
".",
"_stream",
",",
"'fileno'",
")",
":",
"return",
"os"... | Returns:
int : The total number of bytes that will be returned by the iterator. | [
"Returns",
":",
"int",
":",
"The",
"total",
"number",
"of",
"bytes",
"that",
"will",
"be",
"returned",
"by",
"the",
"iterator",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/iter/stream.py#L62-L74 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/middleware/session_jwt.py | _get_cn_cert | def _get_cn_cert():
"""Get the public TLS/SSL X.509 certificate from the root CN of the DataONE
environment. The certificate is used for validating the signature of the JWTs.
If certificate retrieval fails, a new attempt to retrieve the certificate
is performed after the cache expires (settings.CACHES.... | python | def _get_cn_cert():
"""Get the public TLS/SSL X.509 certificate from the root CN of the DataONE
environment. The certificate is used for validating the signature of the JWTs.
If certificate retrieval fails, a new attempt to retrieve the certificate
is performed after the cache expires (settings.CACHES.... | [
"def",
"_get_cn_cert",
"(",
")",
":",
"try",
":",
"cert_obj",
"=",
"django",
".",
"core",
".",
"cache",
".",
"cache",
".",
"cn_cert_obj",
"d1_common",
".",
"cert",
".",
"x509",
".",
"log_cert_info",
"(",
"logging",
".",
"debug",
",",
"'Using cached CN cert... | Get the public TLS/SSL X.509 certificate from the root CN of the DataONE
environment. The certificate is used for validating the signature of the JWTs.
If certificate retrieval fails, a new attempt to retrieve the certificate
is performed after the cache expires (settings.CACHES.default.TIMEOUT).
If s... | [
"Get",
"the",
"public",
"TLS",
"/",
"SSL",
"X",
".",
"509",
"certificate",
"from",
"the",
"root",
"CN",
"of",
"the",
"DataONE",
"environment",
".",
"The",
"certificate",
"is",
"used",
"for",
"validating",
"the",
"signature",
"of",
"the",
"JWTs",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/middleware/session_jwt.py#L54-L73 |
joshua-stone/DerPyBooru | derpibooru/search.py | Search.key | def key(self, key=""):
"""
Takes a user's API key string which applies content settings. API keys can
be found at <https://derpibooru.org/users/edit>.
"""
params = join_params(self.parameters, {"key": key})
return self.__class__(**params) | python | def key(self, key=""):
"""
Takes a user's API key string which applies content settings. API keys can
be found at <https://derpibooru.org/users/edit>.
"""
params = join_params(self.parameters, {"key": key})
return self.__class__(**params) | [
"def",
"key",
"(",
"self",
",",
"key",
"=",
"\"\"",
")",
":",
"params",
"=",
"join_params",
"(",
"self",
".",
"parameters",
",",
"{",
"\"key\"",
":",
"key",
"}",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"params",
")"
] | Takes a user's API key string which applies content settings. API keys can
be found at <https://derpibooru.org/users/edit>. | [
"Takes",
"a",
"user",
"s",
"API",
"key",
"string",
"which",
"applies",
"content",
"settings",
".",
"API",
"keys",
"can",
"be",
"found",
"at",
"<https",
":",
"//",
"derpibooru",
".",
"org",
"/",
"users",
"/",
"edit",
">",
"."
] | train | https://github.com/joshua-stone/DerPyBooru/blob/75aec19488042ba89115ff002b4d696ad87fb03f/derpibooru/search.py#L92-L99 |
joshua-stone/DerPyBooru | derpibooru/search.py | Search.query | def query(self, *q):
"""
Takes one or more strings for searching by tag and/or metadata.
"""
params = join_params(self.parameters, {"q": q})
return self.__class__(**params) | python | def query(self, *q):
"""
Takes one or more strings for searching by tag and/or metadata.
"""
params = join_params(self.parameters, {"q": q})
return self.__class__(**params) | [
"def",
"query",
"(",
"self",
",",
"*",
"q",
")",
":",
"params",
"=",
"join_params",
"(",
"self",
".",
"parameters",
",",
"{",
"\"q\"",
":",
"q",
"}",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"params",
")"
] | Takes one or more strings for searching by tag and/or metadata. | [
"Takes",
"one",
"or",
"more",
"strings",
"for",
"searching",
"by",
"tag",
"and",
"/",
"or",
"metadata",
"."
] | train | https://github.com/joshua-stone/DerPyBooru/blob/75aec19488042ba89115ff002b4d696ad87fb03f/derpibooru/search.py#L101-L107 |
joshua-stone/DerPyBooru | derpibooru/search.py | Search.sort_by | def sort_by(self, sf):
"""
Determines how to sort search results. Available sorting methods are
sort.SCORE, sort.COMMENTS, sort.HEIGHT, sort.RELEVANCE, sort.CREATED_AT,
and sort.RANDOM; default is sort.CREATED_AT.
"""
params = join_params(self.parameters, {"sf": sf})
return self.__class__(*... | python | def sort_by(self, sf):
"""
Determines how to sort search results. Available sorting methods are
sort.SCORE, sort.COMMENTS, sort.HEIGHT, sort.RELEVANCE, sort.CREATED_AT,
and sort.RANDOM; default is sort.CREATED_AT.
"""
params = join_params(self.parameters, {"sf": sf})
return self.__class__(*... | [
"def",
"sort_by",
"(",
"self",
",",
"sf",
")",
":",
"params",
"=",
"join_params",
"(",
"self",
".",
"parameters",
",",
"{",
"\"sf\"",
":",
"sf",
"}",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"params",
")"
] | Determines how to sort search results. Available sorting methods are
sort.SCORE, sort.COMMENTS, sort.HEIGHT, sort.RELEVANCE, sort.CREATED_AT,
and sort.RANDOM; default is sort.CREATED_AT. | [
"Determines",
"how",
"to",
"sort",
"search",
"results",
".",
"Available",
"sorting",
"methods",
"are",
"sort",
".",
"SCORE",
"sort",
".",
"COMMENTS",
"sort",
".",
"HEIGHT",
"sort",
".",
"RELEVANCE",
"sort",
".",
"CREATED_AT",
"and",
"sort",
".",
"RANDOM",
... | train | https://github.com/joshua-stone/DerPyBooru/blob/75aec19488042ba89115ff002b4d696ad87fb03f/derpibooru/search.py#L109-L117 |
joshua-stone/DerPyBooru | derpibooru/search.py | Search.limit | def limit(self, limit):
"""
Set absolute limit on number of images to return, or set to None to return
as many results as needed; default 50 posts.
"""
params = join_params(self.parameters, {"limit": limit})
return self.__class__(**params) | python | def limit(self, limit):
"""
Set absolute limit on number of images to return, or set to None to return
as many results as needed; default 50 posts.
"""
params = join_params(self.parameters, {"limit": limit})
return self.__class__(**params) | [
"def",
"limit",
"(",
"self",
",",
"limit",
")",
":",
"params",
"=",
"join_params",
"(",
"self",
".",
"parameters",
",",
"{",
"\"limit\"",
":",
"limit",
"}",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"params",
")"
] | Set absolute limit on number of images to return, or set to None to return
as many results as needed; default 50 posts. | [
"Set",
"absolute",
"limit",
"on",
"number",
"of",
"images",
"to",
"return",
"or",
"set",
"to",
"None",
"to",
"return",
"as",
"many",
"results",
"as",
"needed",
";",
"default",
"50",
"posts",
"."
] | train | https://github.com/joshua-stone/DerPyBooru/blob/75aec19488042ba89115ff002b4d696ad87fb03f/derpibooru/search.py#L135-L142 |
joshua-stone/DerPyBooru | derpibooru/search.py | Search.filter | def filter(self, filter_id=""):
"""
Takes a filter's ID to be used in the current search context. Filter IDs can
be found at <https://derpibooru.org/filters/> by inspecting the URL parameters.
If no filter is provided, the user's current filter will be used.
"""
params = join_params(self.pa... | python | def filter(self, filter_id=""):
"""
Takes a filter's ID to be used in the current search context. Filter IDs can
be found at <https://derpibooru.org/filters/> by inspecting the URL parameters.
If no filter is provided, the user's current filter will be used.
"""
params = join_params(self.pa... | [
"def",
"filter",
"(",
"self",
",",
"filter_id",
"=",
"\"\"",
")",
":",
"params",
"=",
"join_params",
"(",
"self",
".",
"parameters",
",",
"{",
"\"filter_id\"",
":",
"filter_id",
"}",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"params",
")"... | Takes a filter's ID to be used in the current search context. Filter IDs can
be found at <https://derpibooru.org/filters/> by inspecting the URL parameters.
If no filter is provided, the user's current filter will be used. | [
"Takes",
"a",
"filter",
"s",
"ID",
"to",
"be",
"used",
"in",
"the",
"current",
"search",
"context",
".",
"Filter",
"IDs",
"can",
"be",
"found",
"at",
"<https",
":",
"//",
"derpibooru",
".",
"org",
"/",
"filters",
"/",
">",
"by",
"inspecting",
"the",
... | train | https://github.com/joshua-stone/DerPyBooru/blob/75aec19488042ba89115ff002b4d696ad87fb03f/derpibooru/search.py#L144-L153 |
joshua-stone/DerPyBooru | derpibooru/search.py | Search.faves | def faves(self, option):
"""
Set whether to filter by a user's faves list. Options available are
user.ONLY, user.NOT, and None; default is None.
"""
params = join_params(self.parameters, {"faves": option})
return self.__class__(**params) | python | def faves(self, option):
"""
Set whether to filter by a user's faves list. Options available are
user.ONLY, user.NOT, and None; default is None.
"""
params = join_params(self.parameters, {"faves": option})
return self.__class__(**params) | [
"def",
"faves",
"(",
"self",
",",
"option",
")",
":",
"params",
"=",
"join_params",
"(",
"self",
".",
"parameters",
",",
"{",
"\"faves\"",
":",
"option",
"}",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"params",
")"
] | Set whether to filter by a user's faves list. Options available are
user.ONLY, user.NOT, and None; default is None. | [
"Set",
"whether",
"to",
"filter",
"by",
"a",
"user",
"s",
"faves",
"list",
".",
"Options",
"available",
"are",
"user",
".",
"ONLY",
"user",
".",
"NOT",
"and",
"None",
";",
"default",
"is",
"None",
"."
] | train | https://github.com/joshua-stone/DerPyBooru/blob/75aec19488042ba89115ff002b4d696ad87fb03f/derpibooru/search.py#L156-L163 |
joshua-stone/DerPyBooru | derpibooru/search.py | Search.upvotes | def upvotes(self, option):
"""
Set whether to filter by a user's upvoted list. Options available are
user.ONLY, user.NOT, and None; default is None.
"""
params = join_params(self.parameters, {"upvotes": option})
return self.__class__(**params) | python | def upvotes(self, option):
"""
Set whether to filter by a user's upvoted list. Options available are
user.ONLY, user.NOT, and None; default is None.
"""
params = join_params(self.parameters, {"upvotes": option})
return self.__class__(**params) | [
"def",
"upvotes",
"(",
"self",
",",
"option",
")",
":",
"params",
"=",
"join_params",
"(",
"self",
".",
"parameters",
",",
"{",
"\"upvotes\"",
":",
"option",
"}",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"params",
")"
] | Set whether to filter by a user's upvoted list. Options available are
user.ONLY, user.NOT, and None; default is None. | [
"Set",
"whether",
"to",
"filter",
"by",
"a",
"user",
"s",
"upvoted",
"list",
".",
"Options",
"available",
"are",
"user",
".",
"ONLY",
"user",
".",
"NOT",
"and",
"None",
";",
"default",
"is",
"None",
"."
] | train | https://github.com/joshua-stone/DerPyBooru/blob/75aec19488042ba89115ff002b4d696ad87fb03f/derpibooru/search.py#L165-L172 |
joshua-stone/DerPyBooru | derpibooru/search.py | Search.uploads | def uploads(self, option):
"""
Set whether to filter by a user's uploads list. Options available are
user.ONLY, user.NOT, and None; default is None.
"""
params = join_params(self.parameters, {"uploads": option})
return self.__class__(**params) | python | def uploads(self, option):
"""
Set whether to filter by a user's uploads list. Options available are
user.ONLY, user.NOT, and None; default is None.
"""
params = join_params(self.parameters, {"uploads": option})
return self.__class__(**params) | [
"def",
"uploads",
"(",
"self",
",",
"option",
")",
":",
"params",
"=",
"join_params",
"(",
"self",
".",
"parameters",
",",
"{",
"\"uploads\"",
":",
"option",
"}",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"params",
")"
] | Set whether to filter by a user's uploads list. Options available are
user.ONLY, user.NOT, and None; default is None. | [
"Set",
"whether",
"to",
"filter",
"by",
"a",
"user",
"s",
"uploads",
"list",
".",
"Options",
"available",
"are",
"user",
".",
"ONLY",
"user",
".",
"NOT",
"and",
"None",
";",
"default",
"is",
"None",
"."
] | train | https://github.com/joshua-stone/DerPyBooru/blob/75aec19488042ba89115ff002b4d696ad87fb03f/derpibooru/search.py#L174-L181 |
joshua-stone/DerPyBooru | derpibooru/search.py | Search.watched | def watched(self, option):
"""
Set whether to filter by a user's watchlist. Options available are
user.ONLY, user.NOT, and None; default is None.
"""
params = join_params(self.parameters, {"watched": option})
return self.__class__(**params) | python | def watched(self, option):
"""
Set whether to filter by a user's watchlist. Options available are
user.ONLY, user.NOT, and None; default is None.
"""
params = join_params(self.parameters, {"watched": option})
return self.__class__(**params) | [
"def",
"watched",
"(",
"self",
",",
"option",
")",
":",
"params",
"=",
"join_params",
"(",
"self",
".",
"parameters",
",",
"{",
"\"watched\"",
":",
"option",
"}",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"params",
")"
] | Set whether to filter by a user's watchlist. Options available are
user.ONLY, user.NOT, and None; default is None. | [
"Set",
"whether",
"to",
"filter",
"by",
"a",
"user",
"s",
"watchlist",
".",
"Options",
"available",
"are",
"user",
".",
"ONLY",
"user",
".",
"NOT",
"and",
"None",
";",
"default",
"is",
"None",
"."
] | train | https://github.com/joshua-stone/DerPyBooru/blob/75aec19488042ba89115ff002b4d696ad87fb03f/derpibooru/search.py#L183-L190 |
genialis/resolwe | resolwe/flow/views/mixins.py | ResolweCreateModelMixin.define_contributor | def define_contributor(self, request):
"""Define contributor by adding it to request.data."""
request.data['contributor'] = self.resolve_user(request.user).pk | python | def define_contributor(self, request):
"""Define contributor by adding it to request.data."""
request.data['contributor'] = self.resolve_user(request.user).pk | [
"def",
"define_contributor",
"(",
"self",
",",
"request",
")",
":",
"request",
".",
"data",
"[",
"'contributor'",
"]",
"=",
"self",
".",
"resolve_user",
"(",
"request",
".",
"user",
")",
".",
"pk"
] | Define contributor by adding it to request.data. | [
"Define",
"contributor",
"by",
"adding",
"it",
"to",
"request",
".",
"data",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/mixins.py#L30-L32 |
genialis/resolwe | resolwe/flow/views/mixins.py | ResolweCreateModelMixin.create | def create(self, request, *args, **kwargs):
"""Create a resource."""
self.define_contributor(request)
try:
return super().create(request, *args, **kwargs)
except IntegrityError as ex:
return Response({'error': str(ex)}, status=status.HTTP_409_CONFLICT) | python | def create(self, request, *args, **kwargs):
"""Create a resource."""
self.define_contributor(request)
try:
return super().create(request, *args, **kwargs)
except IntegrityError as ex:
return Response({'error': str(ex)}, status=status.HTTP_409_CONFLICT) | [
"def",
"create",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"define_contributor",
"(",
"request",
")",
"try",
":",
"return",
"super",
"(",
")",
".",
"create",
"(",
"request",
",",
"*",
"args",
","... | Create a resource. | [
"Create",
"a",
"resource",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/mixins.py#L34-L42 |
genialis/resolwe | resolwe/flow/views/mixins.py | ResolweCreateModelMixin.perform_create | def perform_create(self, serializer):
"""Create a resource."""
with transaction.atomic():
instance = serializer.save()
# Assign all permissions to the object contributor.
assign_contributor_permissions(instance) | python | def perform_create(self, serializer):
"""Create a resource."""
with transaction.atomic():
instance = serializer.save()
# Assign all permissions to the object contributor.
assign_contributor_permissions(instance) | [
"def",
"perform_create",
"(",
"self",
",",
"serializer",
")",
":",
"with",
"transaction",
".",
"atomic",
"(",
")",
":",
"instance",
"=",
"serializer",
".",
"save",
"(",
")",
"# Assign all permissions to the object contributor.",
"assign_contributor_permissions",
"(",
... | Create a resource. | [
"Create",
"a",
"resource",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/mixins.py#L44-L50 |
genialis/resolwe | resolwe/flow/views/mixins.py | ResolweUpdateModelMixin.update | def update(self, request, *args, **kwargs):
"""Update a resource."""
# NOTE: Use the original method instead when support for locking is added:
# https://github.com/encode/django-rest-framework/issues/4675
# return super().update(request, *args, **kwargs)
with transaction.a... | python | def update(self, request, *args, **kwargs):
"""Update a resource."""
# NOTE: Use the original method instead when support for locking is added:
# https://github.com/encode/django-rest-framework/issues/4675
# return super().update(request, *args, **kwargs)
with transaction.a... | [
"def",
"update",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# NOTE: Use the original method instead when support for locking is added:",
"# https://github.com/encode/django-rest-framework/issues/4675",
"# return super().update(request, ... | Update a resource. | [
"Update",
"a",
"resource",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/mixins.py#L59-L65 |
genialis/resolwe | resolwe/flow/views/mixins.py | ResolweUpdateModelMixin._update | def _update(self, request, *args, **kwargs):
"""Update a resource."""
partial = kwargs.pop('partial', False)
# NOTE: The line below was changed.
instance = self.get_object_with_lock()
serializer = self.get_serializer(instance, data=request.data, partial=partial)
serialize... | python | def _update(self, request, *args, **kwargs):
"""Update a resource."""
partial = kwargs.pop('partial', False)
# NOTE: The line below was changed.
instance = self.get_object_with_lock()
serializer = self.get_serializer(instance, data=request.data, partial=partial)
serialize... | [
"def",
"_update",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"partial",
"=",
"kwargs",
".",
"pop",
"(",
"'partial'",
",",
"False",
")",
"# NOTE: The line below was changed.",
"instance",
"=",
"self",
".",
"get_object_... | Update a resource. | [
"Update",
"a",
"resource",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/mixins.py#L72-L86 |
genialis/resolwe | resolwe/flow/views/mixins.py | ResolweCheckSlugMixin.slug_exists | def slug_exists(self, request):
"""Check if given url slug exists.
Check if slug given in query parameter ``name`` exists. Return
``True`` if slug already exists and ``False`` otherwise.
"""
if not request.user.is_authenticated:
return Response(status=status.HTTP_40... | python | def slug_exists(self, request):
"""Check if given url slug exists.
Check if slug given in query parameter ``name`` exists. Return
``True`` if slug already exists and ``False`` otherwise.
"""
if not request.user.is_authenticated:
return Response(status=status.HTTP_40... | [
"def",
"slug_exists",
"(",
"self",
",",
"request",
")",
":",
"if",
"not",
"request",
".",
"user",
".",
"is_authenticated",
":",
"return",
"Response",
"(",
"status",
"=",
"status",
".",
"HTTP_401_UNAUTHORIZED",
")",
"if",
"'name'",
"not",
"in",
"request",
"... | Check if given url slug exists.
Check if slug given in query parameter ``name`` exists. Return
``True`` if slug already exists and ``False`` otherwise. | [
"Check",
"if",
"given",
"url",
"slug",
"exists",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/mixins.py#L121-L137 |
genialis/resolwe | resolwe/flow/views/mixins.py | ParametersMixin.get_ids | def get_ids(self, request_data, parameter_name='ids'):
"""Extract a list of integers from request data."""
if parameter_name not in request_data:
raise ParseError("`{}` parameter is required".format(parameter_name))
ids = request_data.get(parameter_name)
if not isinstance(id... | python | def get_ids(self, request_data, parameter_name='ids'):
"""Extract a list of integers from request data."""
if parameter_name not in request_data:
raise ParseError("`{}` parameter is required".format(parameter_name))
ids = request_data.get(parameter_name)
if not isinstance(id... | [
"def",
"get_ids",
"(",
"self",
",",
"request_data",
",",
"parameter_name",
"=",
"'ids'",
")",
":",
"if",
"parameter_name",
"not",
"in",
"request_data",
":",
"raise",
"ParseError",
"(",
"\"`{}` parameter is required\"",
".",
"format",
"(",
"parameter_name",
")",
... | Extract a list of integers from request data. | [
"Extract",
"a",
"list",
"of",
"integers",
"from",
"request",
"data",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/mixins.py#L143-L158 |
genialis/resolwe | resolwe/flow/views/mixins.py | ParametersMixin.get_id | def get_id(self, request_data, parameter_name='id'):
"""Extract an integer from request data."""
if parameter_name not in request_data:
raise ParseError("`{}` parameter is required".format(parameter_name))
id_parameter = request_data.get(parameter_name, None)
if not isinstan... | python | def get_id(self, request_data, parameter_name='id'):
"""Extract an integer from request data."""
if parameter_name not in request_data:
raise ParseError("`{}` parameter is required".format(parameter_name))
id_parameter = request_data.get(parameter_name, None)
if not isinstan... | [
"def",
"get_id",
"(",
"self",
",",
"request_data",
",",
"parameter_name",
"=",
"'id'",
")",
":",
"if",
"parameter_name",
"not",
"in",
"request_data",
":",
"raise",
"ParseError",
"(",
"\"`{}` parameter is required\"",
".",
"format",
"(",
"parameter_name",
")",
")... | Extract an integer from request data. | [
"Extract",
"an",
"integer",
"from",
"request",
"data",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/mixins.py#L160-L169 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | deserialize | def deserialize(dataone_exception_xml):
"""Deserialize a DataONE Exception XML doc."""
# logging.debug('dataone_exception_xml="{}"'
# .format(d1_common.xml.pretty_xml(dataone_exception_xml)))
try:
dataone_exception_pyxb = d1_common.xml.deserialize_d1_exception(
dataone_exception_xml
... | python | def deserialize(dataone_exception_xml):
"""Deserialize a DataONE Exception XML doc."""
# logging.debug('dataone_exception_xml="{}"'
# .format(d1_common.xml.pretty_xml(dataone_exception_xml)))
try:
dataone_exception_pyxb = d1_common.xml.deserialize_d1_exception(
dataone_exception_xml
... | [
"def",
"deserialize",
"(",
"dataone_exception_xml",
")",
":",
"# logging.debug('dataone_exception_xml=\"{}\"'",
"# .format(d1_common.xml.pretty_xml(dataone_exception_xml)))",
"try",
":",
"dataone_exception_pyxb",
"=",
"d1_common",
".",
"xml",
".",
"deserialize_d1_exception",
"(",
... | Deserialize a DataONE Exception XML doc. | [
"Deserialize",
"a",
"DataONE",
"Exception",
"XML",
"doc",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L97-L125 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | deserialize_from_headers | def deserialize_from_headers(headers):
"""Deserialize a DataONE Exception that is stored in a map of HTTP headers (used in
responses to HTTP HEAD requests)."""
return create_exception_by_name(
_get_header(headers, 'DataONE-Exception-Name'),
_get_header(headers, 'DataONE-Exception-DetailCode'... | python | def deserialize_from_headers(headers):
"""Deserialize a DataONE Exception that is stored in a map of HTTP headers (used in
responses to HTTP HEAD requests)."""
return create_exception_by_name(
_get_header(headers, 'DataONE-Exception-Name'),
_get_header(headers, 'DataONE-Exception-DetailCode'... | [
"def",
"deserialize_from_headers",
"(",
"headers",
")",
":",
"return",
"create_exception_by_name",
"(",
"_get_header",
"(",
"headers",
",",
"'DataONE-Exception-Name'",
")",
",",
"_get_header",
"(",
"headers",
",",
"'DataONE-Exception-DetailCode'",
")",
",",
"_get_header... | Deserialize a DataONE Exception that is stored in a map of HTTP headers (used in
responses to HTTP HEAD requests). | [
"Deserialize",
"a",
"DataONE",
"Exception",
"that",
"is",
"stored",
"in",
"a",
"map",
"of",
"HTTP",
"headers",
"(",
"used",
"in",
"responses",
"to",
"HTTP",
"HEAD",
"requests",
")",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L128-L138 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | create_exception_by_name | def create_exception_by_name(
name,
detailCode='0',
description='',
traceInformation=None,
identifier=None,
nodeId=None,
):
"""Create a DataONEException based object by name.
Args:
name: str
The type name of a DataONE Exception. E.g. NotFound.
If an unknown type n... | python | def create_exception_by_name(
name,
detailCode='0',
description='',
traceInformation=None,
identifier=None,
nodeId=None,
):
"""Create a DataONEException based object by name.
Args:
name: str
The type name of a DataONE Exception. E.g. NotFound.
If an unknown type n... | [
"def",
"create_exception_by_name",
"(",
"name",
",",
"detailCode",
"=",
"'0'",
",",
"description",
"=",
"''",
",",
"traceInformation",
"=",
"None",
",",
"identifier",
"=",
"None",
",",
"nodeId",
"=",
"None",
",",
")",
":",
"try",
":",
"dataone_exception",
... | Create a DataONEException based object by name.
Args:
name: str
The type name of a DataONE Exception. E.g. NotFound.
If an unknown type name is used, it is automatically set to ServiceFailure. As
the XML Schema for DataONE Exceptions does not restrict the type names, this
may... | [
"Create",
"a",
"DataONEException",
"based",
"object",
"by",
"name",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L155-L186 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | create_exception_by_error_code | def create_exception_by_error_code(
errorCode,
detailCode='0',
description='',
traceInformation=None,
identifier=None,
nodeId=None,
):
"""Create a DataONE Exception object by errorCode.
See Also: For args, see: ``DataONEException()``
"""
try:
dataone_exception = ERROR... | python | def create_exception_by_error_code(
errorCode,
detailCode='0',
description='',
traceInformation=None,
identifier=None,
nodeId=None,
):
"""Create a DataONE Exception object by errorCode.
See Also: For args, see: ``DataONEException()``
"""
try:
dataone_exception = ERROR... | [
"def",
"create_exception_by_error_code",
"(",
"errorCode",
",",
"detailCode",
"=",
"'0'",
",",
"description",
"=",
"''",
",",
"traceInformation",
"=",
"None",
",",
"identifier",
"=",
"None",
",",
"nodeId",
"=",
"None",
",",
")",
":",
"try",
":",
"dataone_exc... | Create a DataONE Exception object by errorCode.
See Also: For args, see: ``DataONEException()`` | [
"Create",
"a",
"DataONE",
"Exception",
"object",
"by",
"errorCode",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L190-L209 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | DataONEException._fmt | def _fmt(self, tag, msg):
"""Format a string for inclusion in the exception's string representation.
If msg is None, format to empty string. If msg has a single line, format to:
tag: msg If msg has multiple lines, format to: tag: line 1 line 2 Msg is
truncated to 1024 chars.
... | python | def _fmt(self, tag, msg):
"""Format a string for inclusion in the exception's string representation.
If msg is None, format to empty string. If msg has a single line, format to:
tag: msg If msg has multiple lines, format to: tag: line 1 line 2 Msg is
truncated to 1024 chars.
... | [
"def",
"_fmt",
"(",
"self",
",",
"tag",
",",
"msg",
")",
":",
"msg",
"=",
"msg",
"or",
"'<unset>'",
"msg",
"=",
"str",
"(",
"msg",
")",
"msg",
"=",
"msg",
".",
"strip",
"(",
")",
"if",
"not",
"msg",
":",
"return",
"if",
"len",
"(",
"msg",
")"... | Format a string for inclusion in the exception's string representation.
If msg is None, format to empty string. If msg has a single line, format to:
tag: msg If msg has multiple lines, format to: tag: line 1 line 2 Msg is
truncated to 1024 chars. | [
"Format",
"a",
"string",
"for",
"inclusion",
"in",
"the",
"exception",
"s",
"string",
"representation",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L298-L316 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | DataONEException.friendly_format | def friendly_format(self):
"""Serialize to a format more suitable for displaying to end users."""
if self.description is not None:
msg = self.description
else:
msg = 'errorCode: {} / detailCode: {}'.format(
self.errorCode, self.detailCode
)
... | python | def friendly_format(self):
"""Serialize to a format more suitable for displaying to end users."""
if self.description is not None:
msg = self.description
else:
msg = 'errorCode: {} / detailCode: {}'.format(
self.errorCode, self.detailCode
)
... | [
"def",
"friendly_format",
"(",
"self",
")",
":",
"if",
"self",
".",
"description",
"is",
"not",
"None",
":",
"msg",
"=",
"self",
".",
"description",
"else",
":",
"msg",
"=",
"'errorCode: {} / detailCode: {}'",
".",
"format",
"(",
"self",
".",
"errorCode",
... | Serialize to a format more suitable for displaying to end users. | [
"Serialize",
"to",
"a",
"format",
"more",
"suitable",
"for",
"displaying",
"to",
"end",
"users",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L318-L326 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | DataONEException.serialize_to_transport | def serialize_to_transport(self, encoding='utf-8', xslt_url=None):
"""Serialize to XML ``bytes`` with prolog.
Args:
encoding: str
Encoding to use for XML doc bytes
xslt_url: str
If specified, add a processing instruction to the XML doc that specifies the
... | python | def serialize_to_transport(self, encoding='utf-8', xslt_url=None):
"""Serialize to XML ``bytes`` with prolog.
Args:
encoding: str
Encoding to use for XML doc bytes
xslt_url: str
If specified, add a processing instruction to the XML doc that specifies the
... | [
"def",
"serialize_to_transport",
"(",
"self",
",",
"encoding",
"=",
"'utf-8'",
",",
"xslt_url",
"=",
"None",
")",
":",
"assert",
"encoding",
"in",
"(",
"'utf-8'",
",",
"'UTF-8'",
")",
"dataone_exception_pyxb",
"=",
"self",
".",
"get_pyxb",
"(",
")",
"return"... | Serialize to XML ``bytes`` with prolog.
Args:
encoding: str
Encoding to use for XML doc bytes
xslt_url: str
If specified, add a processing instruction to the XML doc that specifies the
download location for an XSLT stylesheet.
Returns:
... | [
"Serialize",
"to",
"XML",
"bytes",
"with",
"prolog",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L328-L346 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | DataONEException.serialize_to_display | def serialize_to_display(self, xslt_url=None):
"""Serialize to a pretty printed Unicode str, suitable for display.
Args: xslt_url: url Optional link to an XSLT stylesheet. If provided, a
processing instruction for the stylesheet is included in the XML prolog.
"""
retu... | python | def serialize_to_display(self, xslt_url=None):
"""Serialize to a pretty printed Unicode str, suitable for display.
Args: xslt_url: url Optional link to an XSLT stylesheet. If provided, a
processing instruction for the stylesheet is included in the XML prolog.
"""
retu... | [
"def",
"serialize_to_display",
"(",
"self",
",",
"xslt_url",
"=",
"None",
")",
":",
"return",
"d1_common",
".",
"xml",
".",
"serialize_to_xml_str",
"(",
"self",
".",
"get_pyxb",
"(",
")",
",",
"pretty",
"=",
"True",
",",
"xslt_url",
"=",
"xslt_url",
")"
] | Serialize to a pretty printed Unicode str, suitable for display.
Args: xslt_url: url Optional link to an XSLT stylesheet. If provided, a
processing instruction for the stylesheet is included in the XML prolog. | [
"Serialize",
"to",
"a",
"pretty",
"printed",
"Unicode",
"str",
"suitable",
"for",
"display",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L348-L357 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | DataONEException.serialize_to_headers | def serialize_to_headers(self):
"""Serialize to a dict of HTTP headers.
Used in responses to HTTP HEAD requests. As with regular HTTP GET requests, HEAD
requests may return DataONE Exceptions. Since a response to a HEAD request
cannot include a body, the error is returned as a set of HT... | python | def serialize_to_headers(self):
"""Serialize to a dict of HTTP headers.
Used in responses to HTTP HEAD requests. As with regular HTTP GET requests, HEAD
requests may return DataONE Exceptions. Since a response to a HEAD request
cannot include a body, the error is returned as a set of HT... | [
"def",
"serialize_to_headers",
"(",
"self",
")",
":",
"return",
"{",
"'DataONE-Exception-Name'",
":",
"self",
".",
"__class__",
".",
"__name__",
",",
"'DataONE-Exception-ErrorCode'",
":",
"self",
".",
"_format_header",
"(",
"self",
".",
"errorCode",
")",
",",
"'... | Serialize to a dict of HTTP headers.
Used in responses to HTTP HEAD requests. As with regular HTTP GET requests, HEAD
requests may return DataONE Exceptions. Since a response to a HEAD request
cannot include a body, the error is returned as a set of HTTP headers instead of
an XML docume... | [
"Serialize",
"to",
"a",
"dict",
"of",
"HTTP",
"headers",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L363-L382 |
DataONEorg/d1_python | lib_common/src/d1_common/types/exceptions.py | DataONEException.get_pyxb | def get_pyxb(self):
"""Generate a DataONE Exception PyXB object.
The PyXB object supports directly reading and writing the individual values that
may be included in a DataONE Exception.
"""
dataone_exception_pyxb = dataoneErrors.error()
dataone_exception_pyxb.name = sel... | python | def get_pyxb(self):
"""Generate a DataONE Exception PyXB object.
The PyXB object supports directly reading and writing the individual values that
may be included in a DataONE Exception.
"""
dataone_exception_pyxb = dataoneErrors.error()
dataone_exception_pyxb.name = sel... | [
"def",
"get_pyxb",
"(",
"self",
")",
":",
"dataone_exception_pyxb",
"=",
"dataoneErrors",
".",
"error",
"(",
")",
"dataone_exception_pyxb",
".",
"name",
"=",
"self",
".",
"__class__",
".",
"__name__",
"dataone_exception_pyxb",
".",
"errorCode",
"=",
"self",
".",... | Generate a DataONE Exception PyXB object.
The PyXB object supports directly reading and writing the individual values that
may be included in a DataONE Exception. | [
"Generate",
"a",
"DataONE",
"Exception",
"PyXB",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/exceptions.py#L384-L402 |
genialis/resolwe | resolwe/flow/migrations/0012_recreate_empty_parents.py | recreate_parent_dependencies | def recreate_parent_dependencies(apps, schema_editor):
"""Create empty dependency relation if parent has been deleted."""
Data = apps.get_model('flow', 'Data')
DataDependency = apps.get_model('flow', 'DataDependency')
def process_dependency(data, parent):
if not Data.objects.filter(pk=parent).e... | python | def recreate_parent_dependencies(apps, schema_editor):
"""Create empty dependency relation if parent has been deleted."""
Data = apps.get_model('flow', 'Data')
DataDependency = apps.get_model('flow', 'DataDependency')
def process_dependency(data, parent):
if not Data.objects.filter(pk=parent).e... | [
"def",
"recreate_parent_dependencies",
"(",
"apps",
",",
"schema_editor",
")",
":",
"Data",
"=",
"apps",
".",
"get_model",
"(",
"'flow'",
",",
"'Data'",
")",
"DataDependency",
"=",
"apps",
".",
"get_model",
"(",
"'flow'",
",",
"'DataDependency'",
")",
"def",
... | Create empty dependency relation if parent has been deleted. | [
"Create",
"empty",
"dependency",
"relation",
"if",
"parent",
"has",
"been",
"deleted",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/migrations/0012_recreate_empty_parents.py#L10-L31 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/db_filter.py | add_access_policy_filter | def add_access_policy_filter(request, query, column_name):
"""Filter records that do not have ``read`` or better access for one or more of the
active subjects.
Since ``read`` is the lowest access level that a subject can have, this method only
has to filter on the presence of the subject.
"""
... | python | def add_access_policy_filter(request, query, column_name):
"""Filter records that do not have ``read`` or better access for one or more of the
active subjects.
Since ``read`` is the lowest access level that a subject can have, this method only
has to filter on the presence of the subject.
"""
... | [
"def",
"add_access_policy_filter",
"(",
"request",
",",
"query",
",",
"column_name",
")",
":",
"q",
"=",
"d1_gmn",
".",
"app",
".",
"models",
".",
"Subject",
".",
"objects",
".",
"filter",
"(",
"subject__in",
"=",
"request",
".",
"all_subjects_set",
")",
"... | Filter records that do not have ``read`` or better access for one or more of the
active subjects.
Since ``read`` is the lowest access level that a subject can have, this method only
has to filter on the presence of the subject. | [
"Filter",
"records",
"that",
"do",
"not",
"have",
"read",
"or",
"better",
"access",
"for",
"one",
"or",
"more",
"of",
"the",
"active",
"subjects",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/db_filter.py#L46-L58 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/db_filter.py | add_redact_annotation | def add_redact_annotation(request, query):
"""Flag LogEntry records that require ``ipAddress`` and ``subject`` fields to be
redacted before being returned to the client.
Only trusted subjects and subjects with ``write`` or ``changePermission`` on a
SciObj receive unredacted ``ipAddress`` and ``subject`... | python | def add_redact_annotation(request, query):
"""Flag LogEntry records that require ``ipAddress`` and ``subject`` fields to be
redacted before being returned to the client.
Only trusted subjects and subjects with ``write`` or ``changePermission`` on a
SciObj receive unredacted ``ipAddress`` and ``subject`... | [
"def",
"add_redact_annotation",
"(",
"request",
",",
"query",
")",
":",
"return",
"query",
".",
"annotate",
"(",
"redact",
"=",
"django",
".",
"db",
".",
"models",
".",
"Exists",
"(",
"d1_gmn",
".",
"app",
".",
"models",
".",
"Permission",
".",
"objects"... | Flag LogEntry records that require ``ipAddress`` and ``subject`` fields to be
redacted before being returned to the client.
Only trusted subjects and subjects with ``write`` or ``changePermission`` on a
SciObj receive unredacted ``ipAddress`` and ``subject`` in LogEntry records for the
associated SciOb... | [
"Flag",
"LogEntry",
"records",
"that",
"require",
"ipAddress",
"and",
"subject",
"fields",
"to",
"be",
"redacted",
"before",
"being",
"returned",
"to",
"the",
"client",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/db_filter.py#L61-L81 |
genialis/resolwe | resolwe/flow/migrations/0006_add_total_size.py | calculate_total_size | def calculate_total_size(apps, schema_editor):
"""Add ``total_size`` field to all file/dir-type outputs."""
Data = apps.get_model('flow', 'Data')
for data in Data.objects.all():
hydrate_size(data, force=True)
data.save() | python | def calculate_total_size(apps, schema_editor):
"""Add ``total_size`` field to all file/dir-type outputs."""
Data = apps.get_model('flow', 'Data')
for data in Data.objects.all():
hydrate_size(data, force=True)
data.save() | [
"def",
"calculate_total_size",
"(",
"apps",
",",
"schema_editor",
")",
":",
"Data",
"=",
"apps",
".",
"get_model",
"(",
"'flow'",
",",
"'Data'",
")",
"for",
"data",
"in",
"Data",
".",
"objects",
".",
"all",
"(",
")",
":",
"hydrate_size",
"(",
"data",
"... | Add ``total_size`` field to all file/dir-type outputs. | [
"Add",
"total_size",
"field",
"to",
"all",
"file",
"/",
"dir",
"-",
"type",
"outputs",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/migrations/0006_add_total_size.py#L11-L16 |
genialis/resolwe | resolwe/flow/migrations/0006_add_total_size.py | remove_total_size | def remove_total_size(apps, schema_editor):
"""Remove ``total_size`` field from all file/dir-type outputs."""
Data = apps.get_model('flow', 'Data')
for data in Data.objects.all():
for field_schema, fields in iterate_fields(data.output, data.process.output_schema):
name = field_schema['na... | python | def remove_total_size(apps, schema_editor):
"""Remove ``total_size`` field from all file/dir-type outputs."""
Data = apps.get_model('flow', 'Data')
for data in Data.objects.all():
for field_schema, fields in iterate_fields(data.output, data.process.output_schema):
name = field_schema['na... | [
"def",
"remove_total_size",
"(",
"apps",
",",
"schema_editor",
")",
":",
"Data",
"=",
"apps",
".",
"get_model",
"(",
"'flow'",
",",
"'Data'",
")",
"for",
"data",
"in",
"Data",
".",
"objects",
".",
"all",
"(",
")",
":",
"for",
"field_schema",
",",
"fiel... | Remove ``total_size`` field from all file/dir-type outputs. | [
"Remove",
"total_size",
"field",
"from",
"all",
"file",
"/",
"dir",
"-",
"type",
"outputs",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/migrations/0006_add_total_size.py#L19-L37 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/assert_db.py | is_valid_pid_for_create | def is_valid_pid_for_create(did):
"""Assert that ``did`` can be used as a PID for creating a new object with
MNStorage.create() or MNStorage.update()."""
if not d1_gmn.app.did.is_valid_pid_for_create(did):
raise d1_common.types.exceptions.IdentifierNotUnique(
0,
'Identifier i... | python | def is_valid_pid_for_create(did):
"""Assert that ``did`` can be used as a PID for creating a new object with
MNStorage.create() or MNStorage.update()."""
if not d1_gmn.app.did.is_valid_pid_for_create(did):
raise d1_common.types.exceptions.IdentifierNotUnique(
0,
'Identifier i... | [
"def",
"is_valid_pid_for_create",
"(",
"did",
")",
":",
"if",
"not",
"d1_gmn",
".",
"app",
".",
"did",
".",
"is_valid_pid_for_create",
"(",
"did",
")",
":",
"raise",
"d1_common",
".",
"types",
".",
"exceptions",
".",
"IdentifierNotUnique",
"(",
"0",
",",
"... | Assert that ``did`` can be used as a PID for creating a new object with
MNStorage.create() or MNStorage.update(). | [
"Assert",
"that",
"did",
"can",
"be",
"used",
"as",
"a",
"PID",
"for",
"creating",
"a",
"new",
"object",
"with",
"MNStorage",
".",
"create",
"()",
"or",
"MNStorage",
".",
"update",
"()",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/assert_db.py#L55-L65 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/assert_db.py | is_valid_pid_to_be_updated | def is_valid_pid_to_be_updated(did):
"""Assert that ``did`` is the PID of an object that can be updated (obsoleted) with
MNStorage.update()"""
if not d1_gmn.app.did.is_valid_pid_to_be_updated(did):
raise d1_common.types.exceptions.InvalidRequest(
0,
'Object cannot be updated ... | python | def is_valid_pid_to_be_updated(did):
"""Assert that ``did`` is the PID of an object that can be updated (obsoleted) with
MNStorage.update()"""
if not d1_gmn.app.did.is_valid_pid_to_be_updated(did):
raise d1_common.types.exceptions.InvalidRequest(
0,
'Object cannot be updated ... | [
"def",
"is_valid_pid_to_be_updated",
"(",
"did",
")",
":",
"if",
"not",
"d1_gmn",
".",
"app",
".",
"did",
".",
"is_valid_pid_to_be_updated",
"(",
"did",
")",
":",
"raise",
"d1_common",
".",
"types",
".",
"exceptions",
".",
"InvalidRequest",
"(",
"0",
",",
... | Assert that ``did`` is the PID of an object that can be updated (obsoleted) with
MNStorage.update() | [
"Assert",
"that",
"did",
"is",
"the",
"PID",
"of",
"an",
"object",
"that",
"can",
"be",
"updated",
"(",
"obsoleted",
")",
"with",
"MNStorage",
".",
"update",
"()"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/assert_db.py#L68-L79 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/assert_db.py | post_has_mime_parts | def post_has_mime_parts(request, parts):
"""Validate that a MMP POST contains all required sections.
:param request: Django Request
:param parts: [(part_type, part_name), ...]
:return: None or raises exception.
Where information is stored in the request:
part_type header: request.META['HTTP_<U... | python | def post_has_mime_parts(request, parts):
"""Validate that a MMP POST contains all required sections.
:param request: Django Request
:param parts: [(part_type, part_name), ...]
:return: None or raises exception.
Where information is stored in the request:
part_type header: request.META['HTTP_<U... | [
"def",
"post_has_mime_parts",
"(",
"request",
",",
"parts",
")",
":",
"missing",
"=",
"[",
"]",
"for",
"part_type",
",",
"part_name",
"in",
"parts",
":",
"if",
"part_type",
"==",
"'header'",
":",
"if",
"'HTTP_'",
"+",
"part_name",
".",
"upper",
"(",
")",... | Validate that a MMP POST contains all required sections.
:param request: Django Request
:param parts: [(part_type, part_name), ...]
:return: None or raises exception.
Where information is stored in the request:
part_type header: request.META['HTTP_<UPPER CASE NAME>']
part_type file: request.FI... | [
"Validate",
"that",
"a",
"MMP",
"POST",
"contains",
"all",
"required",
"sections",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/assert_db.py#L139-L175 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/resolver/time_period.py | Resolver._decade_ranges_in_date_range | def _decade_ranges_in_date_range(self, begin_date, end_date):
"""Return a list of decades which is covered by date range."""
begin_dated = begin_date.year / 10
end_dated = end_date.year / 10
decades = []
for d in range(begin_dated, end_dated + 1):
decades.append('{}-{... | python | def _decade_ranges_in_date_range(self, begin_date, end_date):
"""Return a list of decades which is covered by date range."""
begin_dated = begin_date.year / 10
end_dated = end_date.year / 10
decades = []
for d in range(begin_dated, end_dated + 1):
decades.append('{}-{... | [
"def",
"_decade_ranges_in_date_range",
"(",
"self",
",",
"begin_date",
",",
"end_date",
")",
":",
"begin_dated",
"=",
"begin_date",
".",
"year",
"/",
"10",
"end_dated",
"=",
"end_date",
".",
"year",
"/",
"10",
"decades",
"=",
"[",
"]",
"for",
"d",
"in",
... | Return a list of decades which is covered by date range. | [
"Return",
"a",
"list",
"of",
"decades",
"which",
"is",
"covered",
"by",
"date",
"range",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/resolver/time_period.py#L160-L167 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/resolver/time_period.py | Resolver._years_in_date_range_within_decade | def _years_in_date_range_within_decade(self, decade, begin_date, end_date):
"""Return a list of years in one decade which is covered by date range."""
begin_year = begin_date.year
end_year = end_date.year
if begin_year < decade:
begin_year = decade
if end_year > decad... | python | def _years_in_date_range_within_decade(self, decade, begin_date, end_date):
"""Return a list of years in one decade which is covered by date range."""
begin_year = begin_date.year
end_year = end_date.year
if begin_year < decade:
begin_year = decade
if end_year > decad... | [
"def",
"_years_in_date_range_within_decade",
"(",
"self",
",",
"decade",
",",
"begin_date",
",",
"end_date",
")",
":",
"begin_year",
"=",
"begin_date",
".",
"year",
"end_year",
"=",
"end_date",
".",
"year",
"if",
"begin_year",
"<",
"decade",
":",
"begin_year",
... | Return a list of years in one decade which is covered by date range. | [
"Return",
"a",
"list",
"of",
"years",
"in",
"one",
"decade",
"which",
"is",
"covered",
"by",
"date",
"range",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/resolver/time_period.py#L172-L180 |
wilson-eft/wilson | wilson/run/smeft/rge.py | smeft_evolve_leadinglog | def smeft_evolve_leadinglog(C_in, scale_in, scale_out, newphys=True):
"""Solve the SMEFT RGEs in the leading log approximation.
Input C_in and output C_out are dictionaries of arrays."""
C_out = deepcopy(C_in)
b = beta.beta(C_out, newphys=newphys)
for k, C in C_out.items():
C_out[k] = C + b... | python | def smeft_evolve_leadinglog(C_in, scale_in, scale_out, newphys=True):
"""Solve the SMEFT RGEs in the leading log approximation.
Input C_in and output C_out are dictionaries of arrays."""
C_out = deepcopy(C_in)
b = beta.beta(C_out, newphys=newphys)
for k, C in C_out.items():
C_out[k] = C + b... | [
"def",
"smeft_evolve_leadinglog",
"(",
"C_in",
",",
"scale_in",
",",
"scale_out",
",",
"newphys",
"=",
"True",
")",
":",
"C_out",
"=",
"deepcopy",
"(",
"C_in",
")",
"b",
"=",
"beta",
".",
"beta",
"(",
"C_out",
",",
"newphys",
"=",
"newphys",
")",
"for"... | Solve the SMEFT RGEs in the leading log approximation.
Input C_in and output C_out are dictionaries of arrays. | [
"Solve",
"the",
"SMEFT",
"RGEs",
"in",
"the",
"leading",
"log",
"approximation",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/rge.py#L12-L20 |
wilson-eft/wilson | wilson/run/smeft/rge.py | _smeft_evolve | def _smeft_evolve(C_in, scale_in, scale_out, newphys=True, **kwargs):
"""Axuliary function used in `smeft_evolve` and `smeft_evolve_continuous`"""
def fun(t0, y):
return beta.beta_array(C=C_array2dict(y.view(complex)),
newphys=newphys).view(float) / (16 * pi**2)
y0 = C... | python | def _smeft_evolve(C_in, scale_in, scale_out, newphys=True, **kwargs):
"""Axuliary function used in `smeft_evolve` and `smeft_evolve_continuous`"""
def fun(t0, y):
return beta.beta_array(C=C_array2dict(y.view(complex)),
newphys=newphys).view(float) / (16 * pi**2)
y0 = C... | [
"def",
"_smeft_evolve",
"(",
"C_in",
",",
"scale_in",
",",
"scale_out",
",",
"newphys",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"fun",
"(",
"t0",
",",
"y",
")",
":",
"return",
"beta",
".",
"beta_array",
"(",
"C",
"=",
"C_array2dict",
... | Axuliary function used in `smeft_evolve` and `smeft_evolve_continuous` | [
"Axuliary",
"function",
"used",
"in",
"smeft_evolve",
"and",
"smeft_evolve_continuous"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/rge.py#L23-L32 |
wilson-eft/wilson | wilson/run/smeft/rge.py | smeft_evolve | def smeft_evolve(C_in, scale_in, scale_out, newphys=True, **kwargs):
"""Solve the SMEFT RGEs by numeric integration.
Input C_in and output C_out are dictionaries of arrays."""
sol = _smeft_evolve(C_in, scale_in, scale_out, newphys=newphys, **kwargs)
return C_array2dict(sol.y[:, -1].view(complex)) | python | def smeft_evolve(C_in, scale_in, scale_out, newphys=True, **kwargs):
"""Solve the SMEFT RGEs by numeric integration.
Input C_in and output C_out are dictionaries of arrays."""
sol = _smeft_evolve(C_in, scale_in, scale_out, newphys=newphys, **kwargs)
return C_array2dict(sol.y[:, -1].view(complex)) | [
"def",
"smeft_evolve",
"(",
"C_in",
",",
"scale_in",
",",
"scale_out",
",",
"newphys",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"sol",
"=",
"_smeft_evolve",
"(",
"C_in",
",",
"scale_in",
",",
"scale_out",
",",
"newphys",
"=",
"newphys",
",",
"*"... | Solve the SMEFT RGEs by numeric integration.
Input C_in and output C_out are dictionaries of arrays. | [
"Solve",
"the",
"SMEFT",
"RGEs",
"by",
"numeric",
"integration",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/rge.py#L35-L40 |
wilson-eft/wilson | wilson/run/smeft/rge.py | smeft_evolve_continuous | def smeft_evolve_continuous(C_in, scale_in, scale_out, newphys=True, **kwargs):
"""Solve the SMEFT RGEs by numeric integration, returning a function that
allows to compute an interpolated solution at arbitrary intermediate
scales."""
sol = _smeft_evolve(C_in, scale_in, scale_out, newphys=newphys,
... | python | def smeft_evolve_continuous(C_in, scale_in, scale_out, newphys=True, **kwargs):
"""Solve the SMEFT RGEs by numeric integration, returning a function that
allows to compute an interpolated solution at arbitrary intermediate
scales."""
sol = _smeft_evolve(C_in, scale_in, scale_out, newphys=newphys,
... | [
"def",
"smeft_evolve_continuous",
"(",
"C_in",
",",
"scale_in",
",",
"scale_out",
",",
"newphys",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"sol",
"=",
"_smeft_evolve",
"(",
"C_in",
",",
"scale_in",
",",
"scale_out",
",",
"newphys",
"=",
"newphys",
... | Solve the SMEFT RGEs by numeric integration, returning a function that
allows to compute an interpolated solution at arbitrary intermediate
scales. | [
"Solve",
"the",
"SMEFT",
"RGEs",
"by",
"numeric",
"integration",
"returning",
"a",
"function",
"that",
"allows",
"to",
"compute",
"an",
"interpolated",
"solution",
"at",
"arbitrary",
"intermediate",
"scales",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/rge.py#L43-L59 |
genialis/resolwe | resolwe/elastic/mixins.py | ElasticIndexFilterMixin.invalid_index | def invalid_index(self, name):
"""Show an invalid index error message."""
self.stderr.write("Unknown index: {}".format(name))
self.stderr.write("Supported indices are:")
for index in index_builder.indexes:
self.stderr.write(" * {}".format(index.__class__.__name__)) | python | def invalid_index(self, name):
"""Show an invalid index error message."""
self.stderr.write("Unknown index: {}".format(name))
self.stderr.write("Supported indices are:")
for index in index_builder.indexes:
self.stderr.write(" * {}".format(index.__class__.__name__)) | [
"def",
"invalid_index",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"stderr",
".",
"write",
"(",
"\"Unknown index: {}\"",
".",
"format",
"(",
"name",
")",
")",
"self",
".",
"stderr",
".",
"write",
"(",
"\"Supported indices are:\"",
")",
"for",
"index"... | Show an invalid index error message. | [
"Show",
"an",
"invalid",
"index",
"error",
"message",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/mixins.py#L22-L27 |
genialis/resolwe | resolwe/elastic/mixins.py | ElasticIndexFilterMixin.filter_indices | def filter_indices(self, options, verbosity, *args, **kwargs):
"""Filter indices and execute an action for each index."""
index_name_map = {
index.__class__.__name__: index
for index in index_builder.indexes
}
# Process includes.
if options['index']:
... | python | def filter_indices(self, options, verbosity, *args, **kwargs):
"""Filter indices and execute an action for each index."""
index_name_map = {
index.__class__.__name__: index
for index in index_builder.indexes
}
# Process includes.
if options['index']:
... | [
"def",
"filter_indices",
"(",
"self",
",",
"options",
",",
"verbosity",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"index_name_map",
"=",
"{",
"index",
".",
"__class__",
".",
"__name__",
":",
"index",
"for",
"index",
"in",
"index_builder",
".",... | Filter indices and execute an action for each index. | [
"Filter",
"indices",
"and",
"execute",
"an",
"action",
"for",
"each",
"index",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/mixins.py#L36-L67 |
genialis/resolwe | resolwe/flow/elastic_indexes/base.py | BaseIndexMixin.get_contributor_sort_value | def get_contributor_sort_value(self, obj):
"""Generate display name for contributor."""
user = obj.contributor
if user.first_name or user.last_name:
contributor = user.get_full_name()
else:
contributor = user.username
return contributor.strip().lower() | python | def get_contributor_sort_value(self, obj):
"""Generate display name for contributor."""
user = obj.contributor
if user.first_name or user.last_name:
contributor = user.get_full_name()
else:
contributor = user.username
return contributor.strip().lower() | [
"def",
"get_contributor_sort_value",
"(",
"self",
",",
"obj",
")",
":",
"user",
"=",
"obj",
".",
"contributor",
"if",
"user",
".",
"first_name",
"or",
"user",
".",
"last_name",
":",
"contributor",
"=",
"user",
".",
"get_full_name",
"(",
")",
"else",
":",
... | Generate display name for contributor. | [
"Generate",
"display",
"name",
"for",
"contributor",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/elastic_indexes/base.py#L31-L40 |
genialis/resolwe | resolwe/flow/elastic_indexes/base.py | BaseIndexMixin._get_user | def _get_user(self, user):
"""Generate user filtering tokens."""
return ' '.join([user.username, user.first_name, user.last_name]) | python | def _get_user(self, user):
"""Generate user filtering tokens."""
return ' '.join([user.username, user.first_name, user.last_name]) | [
"def",
"_get_user",
"(",
"self",
",",
"user",
")",
":",
"return",
"' '",
".",
"join",
"(",
"[",
"user",
".",
"username",
",",
"user",
".",
"first_name",
",",
"user",
".",
"last_name",
"]",
")"
] | Generate user filtering tokens. | [
"Generate",
"user",
"filtering",
"tokens",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/elastic_indexes/base.py#L42-L44 |
genialis/resolwe | resolwe/flow/elastic_indexes/base.py | BaseIndexMixin.get_owner_ids_value | def get_owner_ids_value(self, obj):
"""Extract owners' ids."""
return [
user.pk
for user in get_users_with_permission(obj, get_full_perm('owner', obj))
] | python | def get_owner_ids_value(self, obj):
"""Extract owners' ids."""
return [
user.pk
for user in get_users_with_permission(obj, get_full_perm('owner', obj))
] | [
"def",
"get_owner_ids_value",
"(",
"self",
",",
"obj",
")",
":",
"return",
"[",
"user",
".",
"pk",
"for",
"user",
"in",
"get_users_with_permission",
"(",
"obj",
",",
"get_full_perm",
"(",
"'owner'",
",",
"obj",
")",
")",
"]"
] | Extract owners' ids. | [
"Extract",
"owners",
"ids",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/elastic_indexes/base.py#L54-L59 |
genialis/resolwe | resolwe/flow/elastic_indexes/base.py | BaseIndexMixin.get_owner_names_value | def get_owner_names_value(self, obj):
"""Extract owners' names."""
return [
self._get_user(user)
for user in get_users_with_permission(obj, get_full_perm('owner', obj))
] | python | def get_owner_names_value(self, obj):
"""Extract owners' names."""
return [
self._get_user(user)
for user in get_users_with_permission(obj, get_full_perm('owner', obj))
] | [
"def",
"get_owner_names_value",
"(",
"self",
",",
"obj",
")",
":",
"return",
"[",
"self",
".",
"_get_user",
"(",
"user",
")",
"for",
"user",
"in",
"get_users_with_permission",
"(",
"obj",
",",
"get_full_perm",
"(",
"'owner'",
",",
"obj",
")",
")",
"]"
] | Extract owners' names. | [
"Extract",
"owners",
"names",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/elastic_indexes/base.py#L61-L66 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/slice.py | _get_and_assert_slice_param | def _get_and_assert_slice_param(url_dict, param_name, default_int):
"""Return ``param_str`` converted to an int.
If str cannot be converted to int or int is not zero or positive, raise
InvalidRequest.
"""
param_str = url_dict['query'].get(param_name, default_int)
try:
n = int(param_str... | python | def _get_and_assert_slice_param(url_dict, param_name, default_int):
"""Return ``param_str`` converted to an int.
If str cannot be converted to int or int is not zero or positive, raise
InvalidRequest.
"""
param_str = url_dict['query'].get(param_name, default_int)
try:
n = int(param_str... | [
"def",
"_get_and_assert_slice_param",
"(",
"url_dict",
",",
"param_name",
",",
"default_int",
")",
":",
"param_str",
"=",
"url_dict",
"[",
"'query'",
"]",
".",
"get",
"(",
"param_name",
",",
"default_int",
")",
"try",
":",
"n",
"=",
"int",
"(",
"param_str",
... | Return ``param_str`` converted to an int.
If str cannot be converted to int or int is not zero or positive, raise
InvalidRequest. | [
"Return",
"param_str",
"converted",
"to",
"an",
"int",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/slice.py#L79-L103 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/slice.py | _assert_valid_start | def _assert_valid_start(start_int, count_int, total_int):
"""Assert that the number of objects visible to the active subject is higher than
the requested start position for the slice.
This ensures that it's possible to create a valid slice.
"""
if total_int and start_int >= total_int:
rais... | python | def _assert_valid_start(start_int, count_int, total_int):
"""Assert that the number of objects visible to the active subject is higher than
the requested start position for the slice.
This ensures that it's possible to create a valid slice.
"""
if total_int and start_int >= total_int:
rais... | [
"def",
"_assert_valid_start",
"(",
"start_int",
",",
"count_int",
",",
"total_int",
")",
":",
"if",
"total_int",
"and",
"start_int",
">=",
"total_int",
":",
"raise",
"d1_common",
".",
"types",
".",
"exceptions",
".",
"InvalidRequest",
"(",
"0",
",",
"'Requeste... | Assert that the number of objects visible to the active subject is higher than
the requested start position for the slice.
This ensures that it's possible to create a valid slice. | [
"Assert",
"that",
"the",
"number",
"of",
"objects",
"visible",
"to",
"the",
"active",
"subject",
"is",
"higher",
"than",
"the",
"requested",
"start",
"position",
"for",
"the",
"slice",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/slice.py#L106-L119 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/slice.py | _adjust_count_if_required | def _adjust_count_if_required(start_int, count_int, total_int):
"""Adjust requested object count down if there are not enough objects visible to the
active subjects to cover the requested slice start and count.
Preconditions: start is verified to be lower than the number of visible objects,
making it p... | python | def _adjust_count_if_required(start_int, count_int, total_int):
"""Adjust requested object count down if there are not enough objects visible to the
active subjects to cover the requested slice start and count.
Preconditions: start is verified to be lower than the number of visible objects,
making it p... | [
"def",
"_adjust_count_if_required",
"(",
"start_int",
",",
"count_int",
",",
"total_int",
")",
":",
"if",
"start_int",
"+",
"count_int",
">",
"total_int",
":",
"count_int",
"=",
"total_int",
"-",
"start_int",
"count_int",
"=",
"min",
"(",
"count_int",
",",
"dj... | Adjust requested object count down if there are not enough objects visible to the
active subjects to cover the requested slice start and count.
Preconditions: start is verified to be lower than the number of visible objects,
making it possible to create a valid slice by adjusting count. | [
"Adjust",
"requested",
"object",
"count",
"down",
"if",
"there",
"are",
"not",
"enough",
"objects",
"visible",
"to",
"the",
"active",
"subjects",
"to",
"cover",
"the",
"requested",
"slice",
"start",
"and",
"count",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/slice.py#L122-L133 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/slice.py | _add_fallback_slice_filter | def _add_fallback_slice_filter(query, start_int, count_int, total_int):
"""Create a slice of a query based on request start and count parameters.
This adds `OFFSET <start> LIMIT <count>` to the SQL query, which causes slicing to
run very slowly on large result sets.
"""
logging.debug(
'Add... | python | def _add_fallback_slice_filter(query, start_int, count_int, total_int):
"""Create a slice of a query based on request start and count parameters.
This adds `OFFSET <start> LIMIT <count>` to the SQL query, which causes slicing to
run very slowly on large result sets.
"""
logging.debug(
'Add... | [
"def",
"_add_fallback_slice_filter",
"(",
"query",
",",
"start_int",
",",
"count_int",
",",
"total_int",
")",
":",
"logging",
".",
"debug",
"(",
"'Adding fallback slice filter. start={} count={} total={} '",
".",
"format",
"(",
"start_int",
",",
"count_int",
",",
"tot... | Create a slice of a query based on request start and count parameters.
This adds `OFFSET <start> LIMIT <count>` to the SQL query, which causes slicing to
run very slowly on large result sets. | [
"Create",
"a",
"slice",
"of",
"a",
"query",
"based",
"on",
"request",
"start",
"and",
"count",
"parameters",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/slice.py#L155-L170 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/slice.py | _cache_get_last_in_slice | def _cache_get_last_in_slice(url_dict, start_int, total_int, authn_subj_list):
"""Return None if cache entry does not exist."""
key_str = _gen_cache_key_for_slice(url_dict, start_int, total_int, authn_subj_list)
# TODO: Django docs state that cache.get() should return None on unknown key.
try:
l... | python | def _cache_get_last_in_slice(url_dict, start_int, total_int, authn_subj_list):
"""Return None if cache entry does not exist."""
key_str = _gen_cache_key_for_slice(url_dict, start_int, total_int, authn_subj_list)
# TODO: Django docs state that cache.get() should return None on unknown key.
try:
l... | [
"def",
"_cache_get_last_in_slice",
"(",
"url_dict",
",",
"start_int",
",",
"total_int",
",",
"authn_subj_list",
")",
":",
"key_str",
"=",
"_gen_cache_key_for_slice",
"(",
"url_dict",
",",
"start_int",
",",
"total_int",
",",
"authn_subj_list",
")",
"# TODO: Django docs... | Return None if cache entry does not exist. | [
"Return",
"None",
"if",
"cache",
"entry",
"does",
"not",
"exist",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/slice.py#L173-L182 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/slice.py | _gen_cache_key_for_slice | def _gen_cache_key_for_slice(url_dict, start_int, total_int, authn_subj_list):
"""Generate cache key for the REST URL the client is currently accessing or is
expected to access in order to get the slice starting at the given ``start_int`` of
a multi-slice result set.
When used for finding the key to ch... | python | def _gen_cache_key_for_slice(url_dict, start_int, total_int, authn_subj_list):
"""Generate cache key for the REST URL the client is currently accessing or is
expected to access in order to get the slice starting at the given ``start_int`` of
a multi-slice result set.
When used for finding the key to ch... | [
"def",
"_gen_cache_key_for_slice",
"(",
"url_dict",
",",
"start_int",
",",
"total_int",
",",
"authn_subj_list",
")",
":",
"# logging.debug('Gen key. result_record_count={}'.format(result_record_count))",
"key_url_dict",
"=",
"copy",
".",
"deepcopy",
"(",
"url_dict",
")",
"k... | Generate cache key for the REST URL the client is currently accessing or is
expected to access in order to get the slice starting at the given ``start_int`` of
a multi-slice result set.
When used for finding the key to check in the current call, ``start_int`` is
0, or the start that was passed in the c... | [
"Generate",
"cache",
"key",
"for",
"the",
"REST",
"URL",
"the",
"client",
"is",
"currently",
"accessing",
"or",
"is",
"expected",
"to",
"access",
"in",
"order",
"to",
"get",
"the",
"slice",
"starting",
"at",
"the",
"given",
"start_int",
"of",
"a",
"multi",... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/slice.py#L185-L230 |
wilson-eft/wilson | wilson/translate/smeft.py | smeft_toarray | def smeft_toarray(wc_name, wc_dict):
"""Construct a numpy array with Wilson coefficient values from a
dictionary of label-value pairs corresponding to the non-redundant
elements."""
shape = smeftutil.C_keys_shape[wc_name]
C = np.zeros(shape, dtype=complex)
for k, v in wc_dict.items():
if... | python | def smeft_toarray(wc_name, wc_dict):
"""Construct a numpy array with Wilson coefficient values from a
dictionary of label-value pairs corresponding to the non-redundant
elements."""
shape = smeftutil.C_keys_shape[wc_name]
C = np.zeros(shape, dtype=complex)
for k, v in wc_dict.items():
if... | [
"def",
"smeft_toarray",
"(",
"wc_name",
",",
"wc_dict",
")",
":",
"shape",
"=",
"smeftutil",
".",
"C_keys_shape",
"[",
"wc_name",
"]",
"C",
"=",
"np",
".",
"zeros",
"(",
"shape",
",",
"dtype",
"=",
"complex",
")",
"for",
"k",
",",
"v",
"in",
"wc_dict... | Construct a numpy array with Wilson coefficient values from a
dictionary of label-value pairs corresponding to the non-redundant
elements. | [
"Construct",
"a",
"numpy",
"array",
"with",
"Wilson",
"coefficient",
"values",
"from",
"a",
"dictionary",
"of",
"label",
"-",
"value",
"pairs",
"corresponding",
"to",
"the",
"non",
"-",
"redundant",
"elements",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/smeft.py#L10-L23 |
wilson-eft/wilson | wilson/translate/smeft.py | warsaw_to_warsawmass | def warsaw_to_warsawmass(C, parameters=None, sectors=None):
"""Translate from the Warsaw basis to the 'Warsaw mass' basis.
Parameters used:
- `Vus`, `Vub`, `Vcb`, `gamma`: elements of the unitary CKM matrix (defined
as the mismatch between left-handed quark mass matrix diagonalization
matrices)... | python | def warsaw_to_warsawmass(C, parameters=None, sectors=None):
"""Translate from the Warsaw basis to the 'Warsaw mass' basis.
Parameters used:
- `Vus`, `Vub`, `Vcb`, `gamma`: elements of the unitary CKM matrix (defined
as the mismatch between left-handed quark mass matrix diagonalization
matrices)... | [
"def",
"warsaw_to_warsawmass",
"(",
"C",
",",
"parameters",
"=",
"None",
",",
"sectors",
"=",
"None",
")",
":",
"p",
"=",
"default_parameters",
".",
"copy",
"(",
")",
"if",
"parameters",
"is",
"not",
"None",
":",
"# if parameters are passed in, overwrite the def... | Translate from the Warsaw basis to the 'Warsaw mass' basis.
Parameters used:
- `Vus`, `Vub`, `Vcb`, `gamma`: elements of the unitary CKM matrix (defined
as the mismatch between left-handed quark mass matrix diagonalization
matrices). | [
"Translate",
"from",
"the",
"Warsaw",
"basis",
"to",
"the",
"Warsaw",
"mass",
"basis",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/smeft.py#L35-L63 |
wilson-eft/wilson | wilson/translate/smeft.py | warsaw_up_to_warsaw | def warsaw_up_to_warsaw(C, parameters=None, sectors=None):
"""Translate from the 'Warsaw up' basis to the Warsaw basis.
Parameters used:
- `Vus`, `Vub`, `Vcb`, `gamma`: elements of the unitary CKM matrix (defined
as the mismatch between left-handed quark mass matrix diagonalization
matrices).
... | python | def warsaw_up_to_warsaw(C, parameters=None, sectors=None):
"""Translate from the 'Warsaw up' basis to the Warsaw basis.
Parameters used:
- `Vus`, `Vub`, `Vcb`, `gamma`: elements of the unitary CKM matrix (defined
as the mismatch between left-handed quark mass matrix diagonalization
matrices).
... | [
"def",
"warsaw_up_to_warsaw",
"(",
"C",
",",
"parameters",
"=",
"None",
",",
"sectors",
"=",
"None",
")",
":",
"C_in",
"=",
"smeftutil",
".",
"wcxf2arrays_symmetrized",
"(",
"C",
")",
"p",
"=",
"default_parameters",
".",
"copy",
"(",
")",
"if",
"parameters... | Translate from the 'Warsaw up' basis to the Warsaw basis.
Parameters used:
- `Vus`, `Vub`, `Vcb`, `gamma`: elements of the unitary CKM matrix (defined
as the mismatch between left-handed quark mass matrix diagonalization
matrices). | [
"Translate",
"from",
"the",
"Warsaw",
"up",
"basis",
"to",
"the",
"Warsaw",
"basis",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/smeft.py#L89-L109 |
DataONEorg/d1_python | lib_common/src/d1_common/replication_policy.py | sysmeta_add_preferred | def sysmeta_add_preferred(sysmeta_pyxb, node_urn):
"""Add a remote Member Node to the list of preferred replication targets to this
System Metadata object.
Also remove the target MN from the list of blocked Member Nodes if present.
If the target MN is already in the preferred list and not in the block... | python | def sysmeta_add_preferred(sysmeta_pyxb, node_urn):
"""Add a remote Member Node to the list of preferred replication targets to this
System Metadata object.
Also remove the target MN from the list of blocked Member Nodes if present.
If the target MN is already in the preferred list and not in the block... | [
"def",
"sysmeta_add_preferred",
"(",
"sysmeta_pyxb",
",",
"node_urn",
")",
":",
"if",
"not",
"has_replication_policy",
"(",
"sysmeta_pyxb",
")",
":",
"sysmeta_set_default_rp",
"(",
"sysmeta_pyxb",
")",
"rp_pyxb",
"=",
"sysmeta_pyxb",
".",
"replicationPolicy",
"_add_no... | Add a remote Member Node to the list of preferred replication targets to this
System Metadata object.
Also remove the target MN from the list of blocked Member Nodes if present.
If the target MN is already in the preferred list and not in the blocked list, this
function is a no-op.
Args:
sy... | [
"Add",
"a",
"remote",
"Member",
"Node",
"to",
"the",
"list",
"of",
"preferred",
"replication",
"targets",
"to",
"this",
"System",
"Metadata",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/replication_policy.py#L54-L80 |
DataONEorg/d1_python | lib_common/src/d1_common/replication_policy.py | normalize | def normalize(rp_pyxb):
"""Normalize a ReplicationPolicy PyXB type in place.
The preferred and blocked lists are sorted alphabetically. As blocked nodes
override preferred nodes, and any node present in both lists is removed from the
preferred list.
Args:
rp_pyxb : ReplicationPolicy PyXB obj... | python | def normalize(rp_pyxb):
"""Normalize a ReplicationPolicy PyXB type in place.
The preferred and blocked lists are sorted alphabetically. As blocked nodes
override preferred nodes, and any node present in both lists is removed from the
preferred list.
Args:
rp_pyxb : ReplicationPolicy PyXB obj... | [
"def",
"normalize",
"(",
"rp_pyxb",
")",
":",
"# noinspection PyMissingOrEmptyDocstring",
"def",
"sort",
"(",
"r",
",",
"a",
")",
":",
"d1_common",
".",
"xml",
".",
"sort_value_list_pyxb",
"(",
"_get_attr_or_list",
"(",
"r",
",",
"a",
")",
")",
"rp_pyxb",
".... | Normalize a ReplicationPolicy PyXB type in place.
The preferred and blocked lists are sorted alphabetically. As blocked nodes
override preferred nodes, and any node present in both lists is removed from the
preferred list.
Args:
rp_pyxb : ReplicationPolicy PyXB object
The object will be ... | [
"Normalize",
"a",
"ReplicationPolicy",
"PyXB",
"type",
"in",
"place",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/replication_policy.py#L136-L157 |
DataONEorg/d1_python | lib_common/src/d1_common/replication_policy.py | are_equivalent_xml | def are_equivalent_xml(a_xml, b_xml):
"""Check if two ReplicationPolicy XML docs are semantically equivalent.
The ReplicationPolicy XML docs are normalized before comparison.
Args:
a_xml, b_xml: ReplicationPolicy XML docs to compare
Returns:
bool: ``True`` if the resulting policies for th... | python | def are_equivalent_xml(a_xml, b_xml):
"""Check if two ReplicationPolicy XML docs are semantically equivalent.
The ReplicationPolicy XML docs are normalized before comparison.
Args:
a_xml, b_xml: ReplicationPolicy XML docs to compare
Returns:
bool: ``True`` if the resulting policies for th... | [
"def",
"are_equivalent_xml",
"(",
"a_xml",
",",
"b_xml",
")",
":",
"return",
"are_equivalent_pyxb",
"(",
"d1_common",
".",
"xml",
".",
"deserialize",
"(",
"a_xml",
")",
",",
"d1_common",
".",
"xml",
".",
"deserialize",
"(",
"b_xml",
")",
")"
] | Check if two ReplicationPolicy XML docs are semantically equivalent.
The ReplicationPolicy XML docs are normalized before comparison.
Args:
a_xml, b_xml: ReplicationPolicy XML docs to compare
Returns:
bool: ``True`` if the resulting policies for the two objects are semantically
equivale... | [
"Check",
"if",
"two",
"ReplicationPolicy",
"XML",
"docs",
"are",
"semantically",
"equivalent",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/replication_policy.py#L214-L229 |
DataONEorg/d1_python | lib_common/src/d1_common/replication_policy.py | pyxb_to_dict | def pyxb_to_dict(rp_pyxb):
"""Convert ReplicationPolicy PyXB object to a normalized dict.
Args:
rp_pyxb: ReplicationPolicy to convert.
Returns:
dict : Replication Policy as normalized dict.
Example::
{
'allowed': True,
'num': 3,
'blockedMemberNode': {'urn:... | python | def pyxb_to_dict(rp_pyxb):
"""Convert ReplicationPolicy PyXB object to a normalized dict.
Args:
rp_pyxb: ReplicationPolicy to convert.
Returns:
dict : Replication Policy as normalized dict.
Example::
{
'allowed': True,
'num': 3,
'blockedMemberNode': {'urn:... | [
"def",
"pyxb_to_dict",
"(",
"rp_pyxb",
")",
":",
"return",
"{",
"'allowed'",
":",
"bool",
"(",
"_get_attr_or_list",
"(",
"rp_pyxb",
",",
"'allowed'",
")",
")",
",",
"'num'",
":",
"_get_as_int",
"(",
"rp_pyxb",
")",
",",
"'block'",
":",
"_get_as_set",
"(",
... | Convert ReplicationPolicy PyXB object to a normalized dict.
Args:
rp_pyxb: ReplicationPolicy to convert.
Returns:
dict : Replication Policy as normalized dict.
Example::
{
'allowed': True,
'num': 3,
'blockedMemberNode': {'urn:node:NODE1', 'urn:node:NODE2', 'ur... | [
"Convert",
"ReplicationPolicy",
"PyXB",
"object",
"to",
"a",
"normalized",
"dict",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/replication_policy.py#L274-L298 |
DataONEorg/d1_python | lib_common/src/d1_common/replication_policy.py | dict_to_pyxb | def dict_to_pyxb(rp_dict):
"""Convert dict to ReplicationPolicy PyXB object.
Args:
rp_dict: Native Python structure representing a Replication Policy.
Example::
{
'allowed': True,
'num': 3,
'blockedMemberNode': {'urn:node:NODE1', 'urn:node:NODE2', 'urn:node:NODE3'},
... | python | def dict_to_pyxb(rp_dict):
"""Convert dict to ReplicationPolicy PyXB object.
Args:
rp_dict: Native Python structure representing a Replication Policy.
Example::
{
'allowed': True,
'num': 3,
'blockedMemberNode': {'urn:node:NODE1', 'urn:node:NODE2', 'urn:node:NODE3'},
... | [
"def",
"dict_to_pyxb",
"(",
"rp_dict",
")",
":",
"rp_pyxb",
"=",
"d1_common",
".",
"types",
".",
"dataoneTypes",
".",
"replicationPolicy",
"(",
")",
"rp_pyxb",
".",
"replicationAllowed",
"=",
"rp_dict",
"[",
"'allowed'",
"]",
"rp_pyxb",
".",
"numberReplicas",
... | Convert dict to ReplicationPolicy PyXB object.
Args:
rp_dict: Native Python structure representing a Replication Policy.
Example::
{
'allowed': True,
'num': 3,
'blockedMemberNode': {'urn:node:NODE1', 'urn:node:NODE2', 'urn:node:NODE3'},
'preferredMemberNode': {'urn... | [
"Convert",
"dict",
"to",
"ReplicationPolicy",
"PyXB",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/replication_policy.py#L301-L326 |
DataONEorg/d1_python | lib_common/src/d1_common/replication_policy.py | _ensure_allow_rp | def _ensure_allow_rp(rp_pyxb):
"""Ensure that RP allows replication."""
if not rp_pyxb.replicationAllowed:
rp_pyxb.replicationAllowed = True
if not rp_pyxb.numberReplicas:
rp_pyxb.numberReplicas = 3 | python | def _ensure_allow_rp(rp_pyxb):
"""Ensure that RP allows replication."""
if not rp_pyxb.replicationAllowed:
rp_pyxb.replicationAllowed = True
if not rp_pyxb.numberReplicas:
rp_pyxb.numberReplicas = 3 | [
"def",
"_ensure_allow_rp",
"(",
"rp_pyxb",
")",
":",
"if",
"not",
"rp_pyxb",
".",
"replicationAllowed",
":",
"rp_pyxb",
".",
"replicationAllowed",
"=",
"True",
"if",
"not",
"rp_pyxb",
".",
"numberReplicas",
":",
"rp_pyxb",
".",
"numberReplicas",
"=",
"3"
] | Ensure that RP allows replication. | [
"Ensure",
"that",
"RP",
"allows",
"replication",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/replication_policy.py#L340-L345 |
genialis/resolwe | resolwe/flow/utils/stats.py | _display_interval | def _display_interval(i):
"""Convert a time interval into a human-readable string.
:param i: The interval to convert, in seconds.
"""
sigils = ["d", "h", "m", "s"]
factors = [24 * 60 * 60, 60 * 60, 60, 1]
remain = int(i)
result = ""
for fac, sig in zip(factors, sigils):
if remai... | python | def _display_interval(i):
"""Convert a time interval into a human-readable string.
:param i: The interval to convert, in seconds.
"""
sigils = ["d", "h", "m", "s"]
factors = [24 * 60 * 60, 60 * 60, 60, 1]
remain = int(i)
result = ""
for fac, sig in zip(factors, sigils):
if remai... | [
"def",
"_display_interval",
"(",
"i",
")",
":",
"sigils",
"=",
"[",
"\"d\"",
",",
"\"h\"",
",",
"\"m\"",
",",
"\"s\"",
"]",
"factors",
"=",
"[",
"24",
"*",
"60",
"*",
"60",
",",
"60",
"*",
"60",
",",
"60",
",",
"1",
"]",
"remain",
"=",
"int",
... | Convert a time interval into a human-readable string.
:param i: The interval to convert, in seconds. | [
"Convert",
"a",
"time",
"interval",
"into",
"a",
"human",
"-",
"readable",
"string",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/stats.py#L59-L73 |
genialis/resolwe | resolwe/flow/utils/stats.py | NumberSeriesShape.update | def update(self, num):
"""Update metrics with the new number."""
num = float(num)
self.count += 1
self.low = min(self.low, num)
self.high = max(self.high, num)
# Welford's online mean and variance algorithm.
delta = num - self.mean
self.mean = self.mean +... | python | def update(self, num):
"""Update metrics with the new number."""
num = float(num)
self.count += 1
self.low = min(self.low, num)
self.high = max(self.high, num)
# Welford's online mean and variance algorithm.
delta = num - self.mean
self.mean = self.mean +... | [
"def",
"update",
"(",
"self",
",",
"num",
")",
":",
"num",
"=",
"float",
"(",
"num",
")",
"self",
".",
"count",
"+=",
"1",
"self",
".",
"low",
"=",
"min",
"(",
"self",
".",
"low",
",",
"num",
")",
"self",
".",
"high",
"=",
"max",
"(",
"self",... | Update metrics with the new number. | [
"Update",
"metrics",
"with",
"the",
"new",
"number",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/stats.py#L30-L46 |
genialis/resolwe | resolwe/flow/utils/stats.py | NumberSeriesShape.to_dict | def to_dict(self):
"""Pack the stats computed into a dictionary."""
return {
'high': self.high,
'low': self.low,
'mean': self.mean,
'count': self.count,
'deviation': self.deviation,
} | python | def to_dict(self):
"""Pack the stats computed into a dictionary."""
return {
'high': self.high,
'low': self.low,
'mean': self.mean,
'count': self.count,
'deviation': self.deviation,
} | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'high'",
":",
"self",
".",
"high",
",",
"'low'",
":",
"self",
".",
"low",
",",
"'mean'",
":",
"self",
".",
"mean",
",",
"'count'",
":",
"self",
".",
"count",
",",
"'deviation'",
":",
"self",
... | Pack the stats computed into a dictionary. | [
"Pack",
"the",
"stats",
"computed",
"into",
"a",
"dictionary",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/stats.py#L48-L56 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.