repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
uberVU/mongo-pool | mongo_pool/mongo_pool.py | MongoPool._validate_config | def _validate_config(config):
"""Validate that the provided configurtion is valid.
Each dictionary in the configuration list must have the following
mandatory entries :
{label: {host(string), port(int), dbpath(string|list of strings)}}
It can also contain 1 optional key:
... | python | def _validate_config(config):
"""Validate that the provided configurtion is valid.
Each dictionary in the configuration list must have the following
mandatory entries :
{label: {host(string), port(int), dbpath(string|list of strings)}}
It can also contain 1 optional key:
... | [
"def",
"_validate_config",
"(",
"config",
")",
":",
"if",
"not",
"isinstance",
"(",
"config",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"'Config must be a list'",
")",
"for",
"config_dict",
"in",
"config",
":",
"if",
"not",
"isinstance",
"(",
"config... | Validate that the provided configurtion is valid.
Each dictionary in the configuration list must have the following
mandatory entries :
{label: {host(string), port(int), dbpath(string|list of strings)}}
It can also contain 1 optional key:
{read_preference(string)}
... | [
"Validate",
"that",
"the",
"provided",
"configurtion",
"is",
"valid",
"."
] | 286d1d8e0b3c17d5d7d4860487fe69358941067d | https://github.com/uberVU/mongo-pool/blob/286d1d8e0b3c17d5d7d4860487fe69358941067d/mongo_pool/mongo_pool.py#L45-L98 | train |
uberVU/mongo-pool | mongo_pool/mongo_pool.py | MongoPool._parse_configs | def _parse_configs(self, config):
"""Builds a dict with information to connect to Clusters.
Parses the list of configuration dictionaries passed by the user and
builds an internal dict (_clusters) that holds information for creating
Clients connecting to Clusters and matching database n... | python | def _parse_configs(self, config):
"""Builds a dict with information to connect to Clusters.
Parses the list of configuration dictionaries passed by the user and
builds an internal dict (_clusters) that holds information for creating
Clients connecting to Clusters and matching database n... | [
"def",
"_parse_configs",
"(",
"self",
",",
"config",
")",
":",
"for",
"config_dict",
"in",
"config",
":",
"label",
"=",
"config_dict",
".",
"keys",
"(",
")",
"[",
"0",
"]",
"cfg",
"=",
"config_dict",
"[",
"label",
"]",
"# Transform dbpath to something digest... | Builds a dict with information to connect to Clusters.
Parses the list of configuration dictionaries passed by the user and
builds an internal dict (_clusters) that holds information for creating
Clients connecting to Clusters and matching database names.
Args:
config: A li... | [
"Builds",
"a",
"dict",
"with",
"information",
"to",
"connect",
"to",
"Clusters",
"."
] | 286d1d8e0b3c17d5d7d4860487fe69358941067d | https://github.com/uberVU/mongo-pool/blob/286d1d8e0b3c17d5d7d4860487fe69358941067d/mongo_pool/mongo_pool.py#L100-L139 | train |
uberVU/mongo-pool | mongo_pool/mongo_pool.py | MongoPool._parse_dbpath | def _parse_dbpath(dbpath):
"""Converts the dbpath to a regexp pattern.
Transforms dbpath from a string or an array of strings to a
regexp pattern which will be used to match database names.
Args:
dbpath: a string or an array containing the databases to be matched
... | python | def _parse_dbpath(dbpath):
"""Converts the dbpath to a regexp pattern.
Transforms dbpath from a string or an array of strings to a
regexp pattern which will be used to match database names.
Args:
dbpath: a string or an array containing the databases to be matched
... | [
"def",
"_parse_dbpath",
"(",
"dbpath",
")",
":",
"if",
"isinstance",
"(",
"dbpath",
",",
"list",
")",
":",
"# Support dbpath param as an array.",
"dbpath",
"=",
"'|'",
".",
"join",
"(",
"dbpath",
")",
"# Append $ (end of string) so that twit will not match twitter!",
... | Converts the dbpath to a regexp pattern.
Transforms dbpath from a string or an array of strings to a
regexp pattern which will be used to match database names.
Args:
dbpath: a string or an array containing the databases to be matched
from a cluster.
Returns... | [
"Converts",
"the",
"dbpath",
"to",
"a",
"regexp",
"pattern",
"."
] | 286d1d8e0b3c17d5d7d4860487fe69358941067d | https://github.com/uberVU/mongo-pool/blob/286d1d8e0b3c17d5d7d4860487fe69358941067d/mongo_pool/mongo_pool.py#L142-L164 | train |
uberVU/mongo-pool | mongo_pool/mongo_pool.py | MongoPool._get_read_preference | def _get_read_preference(read_preference):
"""Converts read_preference from string to pymongo.ReadPreference value.
Args:
read_preference: string containig the read_preference from the
config file
Returns:
A value from the pymongo.Read... | python | def _get_read_preference(read_preference):
"""Converts read_preference from string to pymongo.ReadPreference value.
Args:
read_preference: string containig the read_preference from the
config file
Returns:
A value from the pymongo.Read... | [
"def",
"_get_read_preference",
"(",
"read_preference",
")",
":",
"read_preference",
"=",
"getattr",
"(",
"pymongo",
".",
"ReadPreference",
",",
"read_preference",
",",
"None",
")",
"if",
"read_preference",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Invalid r... | Converts read_preference from string to pymongo.ReadPreference value.
Args:
read_preference: string containig the read_preference from the
config file
Returns:
A value from the pymongo.ReadPreference enum
Raises:
E... | [
"Converts",
"read_preference",
"from",
"string",
"to",
"pymongo",
".",
"ReadPreference",
"value",
"."
] | 286d1d8e0b3c17d5d7d4860487fe69358941067d | https://github.com/uberVU/mongo-pool/blob/286d1d8e0b3c17d5d7d4860487fe69358941067d/mongo_pool/mongo_pool.py#L167-L181 | train |
uberVU/mongo-pool | mongo_pool/mongo_pool.py | MongoPool.set_timeout | def set_timeout(self, network_timeout):
"""Set the timeout for existing and future Clients.
Close all current connections. This will cause future operations to
create new Clients with the network_timeout passed through
socketTimeoutMS optional parameter.
Args:
netwo... | python | def set_timeout(self, network_timeout):
"""Set the timeout for existing and future Clients.
Close all current connections. This will cause future operations to
create new Clients with the network_timeout passed through
socketTimeoutMS optional parameter.
Args:
netwo... | [
"def",
"set_timeout",
"(",
"self",
",",
"network_timeout",
")",
":",
"# Do nothing if attempting to set the same timeout twice.",
"if",
"network_timeout",
"==",
"self",
".",
"_network_timeout",
":",
"return",
"self",
".",
"_network_timeout",
"=",
"network_timeout",
"self"... | Set the timeout for existing and future Clients.
Close all current connections. This will cause future operations to
create new Clients with the network_timeout passed through
socketTimeoutMS optional parameter.
Args:
network_timeout: The new value in milliseconds for the t... | [
"Set",
"the",
"timeout",
"for",
"existing",
"and",
"future",
"Clients",
"."
] | 286d1d8e0b3c17d5d7d4860487fe69358941067d | https://github.com/uberVU/mongo-pool/blob/286d1d8e0b3c17d5d7d4860487fe69358941067d/mongo_pool/mongo_pool.py#L183-L197 | train |
uberVU/mongo-pool | mongo_pool/mongo_pool.py | MongoPool._disconnect | def _disconnect(self):
"""Disconnect from all MongoDB Clients."""
for cluster in self._clusters:
if 'connection' in cluster:
connection = cluster.pop('connection')
connection.close()
# Remove all attributes that are database names so that next time
... | python | def _disconnect(self):
"""Disconnect from all MongoDB Clients."""
for cluster in self._clusters:
if 'connection' in cluster:
connection = cluster.pop('connection')
connection.close()
# Remove all attributes that are database names so that next time
... | [
"def",
"_disconnect",
"(",
"self",
")",
":",
"for",
"cluster",
"in",
"self",
".",
"_clusters",
":",
"if",
"'connection'",
"in",
"cluster",
":",
"connection",
"=",
"cluster",
".",
"pop",
"(",
"'connection'",
")",
"connection",
".",
"close",
"(",
")",
"# R... | Disconnect from all MongoDB Clients. | [
"Disconnect",
"from",
"all",
"MongoDB",
"Clients",
"."
] | 286d1d8e0b3c17d5d7d4860487fe69358941067d | https://github.com/uberVU/mongo-pool/blob/286d1d8e0b3c17d5d7d4860487fe69358941067d/mongo_pool/mongo_pool.py#L199-L210 | train |
uberVU/mongo-pool | mongo_pool/mongo_pool.py | MongoPool._get_connection | def _get_connection(self, cluster):
"""Return a connection to a Cluster.
Return a MongoClient or a MongoReplicaSetClient for the given Cluster.
This is done in a lazy manner (if there is already a Client connected to
the Cluster, it is returned and no other Client is created).
... | python | def _get_connection(self, cluster):
"""Return a connection to a Cluster.
Return a MongoClient or a MongoReplicaSetClient for the given Cluster.
This is done in a lazy manner (if there is already a Client connected to
the Cluster, it is returned and no other Client is created).
... | [
"def",
"_get_connection",
"(",
"self",
",",
"cluster",
")",
":",
"# w=1 because:",
"# http://stackoverflow.com/questions/14798552/is-mongodb-2-x-write-concern-w-1-truly-equals-to-safe-true",
"if",
"'connection'",
"not",
"in",
"cluster",
":",
"cluster",
"[",
"'connection'",
"]",... | Return a connection to a Cluster.
Return a MongoClient or a MongoReplicaSetClient for the given Cluster.
This is done in a lazy manner (if there is already a Client connected to
the Cluster, it is returned and no other Client is created).
Args:
cluster: A dict containing in... | [
"Return",
"a",
"connection",
"to",
"a",
"Cluster",
"."
] | 286d1d8e0b3c17d5d7d4860487fe69358941067d | https://github.com/uberVU/mongo-pool/blob/286d1d8e0b3c17d5d7d4860487fe69358941067d/mongo_pool/mongo_pool.py#L212-L235 | train |
uberVU/mongo-pool | mongo_pool/mongo_pool.py | MongoPool._match_dbname | def _match_dbname(self, dbname):
"""Map a database name to the Cluster that holds the database.
Args:
dbname: A database name.
Returns:
A dict containing the information about the Cluster that holds the
database.
"""
for config in self._clust... | python | def _match_dbname(self, dbname):
"""Map a database name to the Cluster that holds the database.
Args:
dbname: A database name.
Returns:
A dict containing the information about the Cluster that holds the
database.
"""
for config in self._clust... | [
"def",
"_match_dbname",
"(",
"self",
",",
"dbname",
")",
":",
"for",
"config",
"in",
"self",
".",
"_clusters",
":",
"if",
"re",
".",
"match",
"(",
"config",
"[",
"'pattern'",
"]",
",",
"dbname",
")",
":",
"return",
"config",
"raise",
"Exception",
"(",
... | Map a database name to the Cluster that holds the database.
Args:
dbname: A database name.
Returns:
A dict containing the information about the Cluster that holds the
database. | [
"Map",
"a",
"database",
"name",
"to",
"the",
"Cluster",
"that",
"holds",
"the",
"database",
"."
] | 286d1d8e0b3c17d5d7d4860487fe69358941067d | https://github.com/uberVU/mongo-pool/blob/286d1d8e0b3c17d5d7d4860487fe69358941067d/mongo_pool/mongo_pool.py#L237-L250 | train |
MacHu-GWU/single_file_module-project | sfm/flow.py | try_ntime | def try_ntime(max_try, func, *args, **kwargs):
"""
Try execute a function n times, until no exception raised or tried
``max_try`` times.
**中文文档**
反复尝试执行一个函数若干次。直到成功为止或是重复尝试 ``max_try`` 次。期间
只要有一次成功, 就正常返回。如果一次都没有成功, 则行为跟最后一次执行了
``func(*args, **kwargs)`` 一样。
"""
if max_try < 1:
... | python | def try_ntime(max_try, func, *args, **kwargs):
"""
Try execute a function n times, until no exception raised or tried
``max_try`` times.
**中文文档**
反复尝试执行一个函数若干次。直到成功为止或是重复尝试 ``max_try`` 次。期间
只要有一次成功, 就正常返回。如果一次都没有成功, 则行为跟最后一次执行了
``func(*args, **kwargs)`` 一样。
"""
if max_try < 1:
... | [
"def",
"try_ntime",
"(",
"max_try",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"max_try",
"<",
"1",
":",
"raise",
"ValueError",
"for",
"i",
"in",
"range",
"(",
"max_try",
")",
":",
"try",
":",
"return",
"func",
"(",
"... | Try execute a function n times, until no exception raised or tried
``max_try`` times.
**中文文档**
反复尝试执行一个函数若干次。直到成功为止或是重复尝试 ``max_try`` 次。期间
只要有一次成功, 就正常返回。如果一次都没有成功, 则行为跟最后一次执行了
``func(*args, **kwargs)`` 一样。 | [
"Try",
"execute",
"a",
"function",
"n",
"times",
"until",
"no",
"exception",
"raised",
"or",
"tried",
"max_try",
"times",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/flow.py#L9-L29 | train |
MounirMesselmeni/django-highlightjs | highlightjs/templatetags/highlightjs.py | highlightjs_javascript | def highlightjs_javascript(jquery=None):
"""
Return HTML for highlightjs JavaScript.
Adjust url in settings. If no url is returned, we don't want this statement to return any HTML.
This is intended behavior.
Default value: ``None``
This value is configurable, see Settings section
**Tag n... | python | def highlightjs_javascript(jquery=None):
"""
Return HTML for highlightjs JavaScript.
Adjust url in settings. If no url is returned, we don't want this statement to return any HTML.
This is intended behavior.
Default value: ``None``
This value is configurable, see Settings section
**Tag n... | [
"def",
"highlightjs_javascript",
"(",
"jquery",
"=",
"None",
")",
":",
"javascript",
"=",
"''",
"# See if we have to include jQuery",
"if",
"jquery",
"is",
"None",
":",
"jquery",
"=",
"get_highlightjs_setting",
"(",
"'include_jquery'",
",",
"False",
")",
"if",
"jq... | Return HTML for highlightjs JavaScript.
Adjust url in settings. If no url is returned, we don't want this statement to return any HTML.
This is intended behavior.
Default value: ``None``
This value is configurable, see Settings section
**Tag name**::
highlightjs_javascript
**Parame... | [
"Return",
"HTML",
"for",
"highlightjs",
"JavaScript",
"."
] | 3758cae67ed15f38641fb51a71ca9ed85af78345 | https://github.com/MounirMesselmeni/django-highlightjs/blob/3758cae67ed15f38641fb51a71ca9ed85af78345/highlightjs/templatetags/highlightjs.py#L39-L79 | train |
ariebovenberg/snug | tutorial/composed0.py | repo | def repo(name: str, owner: str) -> snug.Query[dict]:
"""a repository lookup by owner and name"""
return json.loads((yield f'/repos/{owner}/{name}').content) | python | def repo(name: str, owner: str) -> snug.Query[dict]:
"""a repository lookup by owner and name"""
return json.loads((yield f'/repos/{owner}/{name}').content) | [
"def",
"repo",
"(",
"name",
":",
"str",
",",
"owner",
":",
"str",
")",
"->",
"snug",
".",
"Query",
"[",
"dict",
"]",
":",
"return",
"json",
".",
"loads",
"(",
"(",
"yield",
"f'/repos/{owner}/{name}'",
")",
".",
"content",
")"
] | a repository lookup by owner and name | [
"a",
"repository",
"lookup",
"by",
"owner",
"and",
"name"
] | 4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef | https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/tutorial/composed0.py#L13-L15 | train |
ariebovenberg/snug | tutorial/executing_queries.py | repo | def repo(name: str, owner: str) -> snug.Query[dict]:
"""a repo lookup by owner and name"""
request = snug.GET(f'https://api.github.com/repos/{owner}/{name}')
response = yield request
return json.loads(response.content) | python | def repo(name: str, owner: str) -> snug.Query[dict]:
"""a repo lookup by owner and name"""
request = snug.GET(f'https://api.github.com/repos/{owner}/{name}')
response = yield request
return json.loads(response.content) | [
"def",
"repo",
"(",
"name",
":",
"str",
",",
"owner",
":",
"str",
")",
"->",
"snug",
".",
"Query",
"[",
"dict",
"]",
":",
"request",
"=",
"snug",
".",
"GET",
"(",
"f'https://api.github.com/repos/{owner}/{name}'",
")",
"response",
"=",
"yield",
"request",
... | a repo lookup by owner and name | [
"a",
"repo",
"lookup",
"by",
"owner",
"and",
"name"
] | 4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef | https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/tutorial/executing_queries.py#L6-L10 | train |
ariebovenberg/snug | tutorial/executing_queries.py | follow | def follow(name: str) -> snug.Query[bool]:
"""follow another user"""
request = snug.PUT(f'https://api.github.com/user/following/{name}')
response = yield request
return response.status_code == 204 | python | def follow(name: str) -> snug.Query[bool]:
"""follow another user"""
request = snug.PUT(f'https://api.github.com/user/following/{name}')
response = yield request
return response.status_code == 204 | [
"def",
"follow",
"(",
"name",
":",
"str",
")",
"->",
"snug",
".",
"Query",
"[",
"bool",
"]",
":",
"request",
"=",
"snug",
".",
"PUT",
"(",
"f'https://api.github.com/user/following/{name}'",
")",
"response",
"=",
"yield",
"request",
"return",
"response",
".",... | follow another user | [
"follow",
"another",
"user"
] | 4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef | https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/tutorial/executing_queries.py#L13-L17 | train |
envi-idl/envipyengine | envipyengine/taskengine/task.py | Task.taskinfo | def taskinfo(self):
""" Retrieve the Task Information
"""
task_input = {'taskName': 'QueryTask',
'inputParameters': {"Task_Name": self._name}}
info = taskengine.execute(task_input, self._engine, cwd=self._cwd)
task_def = info['outputParameters']['DEFINITI... | python | def taskinfo(self):
""" Retrieve the Task Information
"""
task_input = {'taskName': 'QueryTask',
'inputParameters': {"Task_Name": self._name}}
info = taskengine.execute(task_input, self._engine, cwd=self._cwd)
task_def = info['outputParameters']['DEFINITI... | [
"def",
"taskinfo",
"(",
"self",
")",
":",
"task_input",
"=",
"{",
"'taskName'",
":",
"'QueryTask'",
",",
"'inputParameters'",
":",
"{",
"\"Task_Name\"",
":",
"self",
".",
"_name",
"}",
"}",
"info",
"=",
"taskengine",
".",
"execute",
"(",
"task_input",
",",... | Retrieve the Task Information | [
"Retrieve",
"the",
"Task",
"Information"
] | 567b639d6592deec3289f6122a9e3d18f2f98432 | https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/taskengine/task.py#L57-L133 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | despeckle_simple | def despeckle_simple(B, th2=2):
"""Single-chromosome despeckling
Simple speckle removing function on a single chromomsome. It also works
for multiple chromosomes but trends may be disrupted.
Parameters
----------
B : array_like
The input matrix to despeckle
th2 : float
The ... | python | def despeckle_simple(B, th2=2):
"""Single-chromosome despeckling
Simple speckle removing function on a single chromomsome. It also works
for multiple chromosomes but trends may be disrupted.
Parameters
----------
B : array_like
The input matrix to despeckle
th2 : float
The ... | [
"def",
"despeckle_simple",
"(",
"B",
",",
"th2",
"=",
"2",
")",
":",
"A",
"=",
"np",
".",
"copy",
"(",
"B",
")",
"n1",
"=",
"A",
".",
"shape",
"[",
"0",
"]",
"dist",
"=",
"{",
"u",
":",
"np",
".",
"diag",
"(",
"A",
",",
"u",
")",
"for",
... | Single-chromosome despeckling
Simple speckle removing function on a single chromomsome. It also works
for multiple chromosomes but trends may be disrupted.
Parameters
----------
B : array_like
The input matrix to despeckle
th2 : float
The number of standard deviations above the... | [
"Single",
"-",
"chromosome",
"despeckling"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L32-L70 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | bin_sparse | def bin_sparse(M, subsampling_factor=3):
"""Perform the bin_dense procedure for sparse matrices. Remaining rows
and cols are lumped with the rest at the end.
"""
try:
from scipy.sparse import coo_matrix
except ImportError as e:
print(str(e))
print("I am peforming dense binni... | python | def bin_sparse(M, subsampling_factor=3):
"""Perform the bin_dense procedure for sparse matrices. Remaining rows
and cols are lumped with the rest at the end.
"""
try:
from scipy.sparse import coo_matrix
except ImportError as e:
print(str(e))
print("I am peforming dense binni... | [
"def",
"bin_sparse",
"(",
"M",
",",
"subsampling_factor",
"=",
"3",
")",
":",
"try",
":",
"from",
"scipy",
".",
"sparse",
"import",
"coo_matrix",
"except",
"ImportError",
"as",
"e",
":",
"print",
"(",
"str",
"(",
"e",
")",
")",
"print",
"(",
"\"I am pe... | Perform the bin_dense procedure for sparse matrices. Remaining rows
and cols are lumped with the rest at the end. | [
"Perform",
"the",
"bin_dense",
"procedure",
"for",
"sparse",
"matrices",
".",
"Remaining",
"rows",
"and",
"cols",
"are",
"lumped",
"with",
"the",
"rest",
"at",
"the",
"end",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L174-L205 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | bin_matrix | def bin_matrix(M, subsampling_factor=3):
"""Bin either sparse or dense matrices.
"""
try:
from scipy.sparse import issparse
if issparse(M):
return bin_sparse(M, subsampling_factor=subsampling_factor)
else:
raise ImportError
except ImportError:
ret... | python | def bin_matrix(M, subsampling_factor=3):
"""Bin either sparse or dense matrices.
"""
try:
from scipy.sparse import issparse
if issparse(M):
return bin_sparse(M, subsampling_factor=subsampling_factor)
else:
raise ImportError
except ImportError:
ret... | [
"def",
"bin_matrix",
"(",
"M",
",",
"subsampling_factor",
"=",
"3",
")",
":",
"try",
":",
"from",
"scipy",
".",
"sparse",
"import",
"issparse",
"if",
"issparse",
"(",
"M",
")",
":",
"return",
"bin_sparse",
"(",
"M",
",",
"subsampling_factor",
"=",
"subsa... | Bin either sparse or dense matrices. | [
"Bin",
"either",
"sparse",
"or",
"dense",
"matrices",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L208-L219 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | bin_annotation | def bin_annotation(annotation=None, subsampling_factor=3):
"""Perform binning on genome annotations such as contig information or bin
positions.
"""
if annotation is None:
annotation = np.array([])
n = len(annotation)
binned_positions = [annotation[i] for i in range(n) if
... | python | def bin_annotation(annotation=None, subsampling_factor=3):
"""Perform binning on genome annotations such as contig information or bin
positions.
"""
if annotation is None:
annotation = np.array([])
n = len(annotation)
binned_positions = [annotation[i] for i in range(n) if
... | [
"def",
"bin_annotation",
"(",
"annotation",
"=",
"None",
",",
"subsampling_factor",
"=",
"3",
")",
":",
"if",
"annotation",
"is",
"None",
":",
"annotation",
"=",
"np",
".",
"array",
"(",
"[",
"]",
")",
"n",
"=",
"len",
"(",
"annotation",
")",
"binned_p... | Perform binning on genome annotations such as contig information or bin
positions. | [
"Perform",
"binning",
"on",
"genome",
"annotations",
"such",
"as",
"contig",
"information",
"or",
"bin",
"positions",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L222-L234 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | build_pyramid | def build_pyramid(M, subsampling_factor=3):
"""Iterate over a given number of times on matrix M
so as to compute smaller and smaller matrices with bin_dense.
"""
subs = int(subsampling_factor)
if subs < 1:
raise ValueError(
"Subsampling factor needs to be an integer greater than... | python | def build_pyramid(M, subsampling_factor=3):
"""Iterate over a given number of times on matrix M
so as to compute smaller and smaller matrices with bin_dense.
"""
subs = int(subsampling_factor)
if subs < 1:
raise ValueError(
"Subsampling factor needs to be an integer greater than... | [
"def",
"build_pyramid",
"(",
"M",
",",
"subsampling_factor",
"=",
"3",
")",
":",
"subs",
"=",
"int",
"(",
"subsampling_factor",
")",
"if",
"subs",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"Subsampling factor needs to be an integer greater than 1.\"",
")",
"N",... | Iterate over a given number of times on matrix M
so as to compute smaller and smaller matrices with bin_dense. | [
"Iterate",
"over",
"a",
"given",
"number",
"of",
"times",
"on",
"matrix",
"M",
"so",
"as",
"to",
"compute",
"smaller",
"and",
"smaller",
"matrices",
"with",
"bin_dense",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L251-L263 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | bin_exact_kb_dense | def bin_exact_kb_dense(M, positions, length=10):
"""Perform the kb-binning procedure with total bin lengths being exactly
set to that of the specified input. Fragments overlapping two potential
bins will be split and related contact counts will be divided according
to overlap proportions in each bin.
... | python | def bin_exact_kb_dense(M, positions, length=10):
"""Perform the kb-binning procedure with total bin lengths being exactly
set to that of the specified input. Fragments overlapping two potential
bins will be split and related contact counts will be divided according
to overlap proportions in each bin.
... | [
"def",
"bin_exact_kb_dense",
"(",
"M",
",",
"positions",
",",
"length",
"=",
"10",
")",
":",
"unit",
"=",
"10",
"**",
"3",
"ul",
"=",
"unit",
"*",
"length",
"units",
"=",
"positions",
"/",
"ul",
"n",
"=",
"len",
"(",
"positions",
")",
"idx",
"=",
... | Perform the kb-binning procedure with total bin lengths being exactly
set to that of the specified input. Fragments overlapping two potential
bins will be split and related contact counts will be divided according
to overlap proportions in each bin. | [
"Perform",
"the",
"kb",
"-",
"binning",
"procedure",
"with",
"total",
"bin",
"lengths",
"being",
"exactly",
"set",
"to",
"that",
"of",
"the",
"specified",
"input",
".",
"Fragments",
"overlapping",
"two",
"potential",
"bins",
"will",
"be",
"split",
"and",
"re... | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L290-L311 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | bin_kb_sparse | def bin_kb_sparse(M, positions, length=10):
"""Perform the exact kb-binning procedure on a sparse matrix.
"""
try:
from scipy.sparse import coo_matrix
except ImportError as e:
print(str(e))
print("I am peforming dense normalization by default.")
return bin_kb_dense(M.tod... | python | def bin_kb_sparse(M, positions, length=10):
"""Perform the exact kb-binning procedure on a sparse matrix.
"""
try:
from scipy.sparse import coo_matrix
except ImportError as e:
print(str(e))
print("I am peforming dense normalization by default.")
return bin_kb_dense(M.tod... | [
"def",
"bin_kb_sparse",
"(",
"M",
",",
"positions",
",",
"length",
"=",
"10",
")",
":",
"try",
":",
"from",
"scipy",
".",
"sparse",
"import",
"coo_matrix",
"except",
"ImportError",
"as",
"e",
":",
"print",
"(",
"str",
"(",
"e",
")",
")",
"print",
"("... | Perform the exact kb-binning procedure on a sparse matrix. | [
"Perform",
"the",
"exact",
"kb",
"-",
"binning",
"procedure",
"on",
"a",
"sparse",
"matrix",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L314-L334 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | trim_sparse | def trim_sparse(M, n_std=3, s_min=None, s_max=None):
"""Apply the trimming procedure to a sparse matrix.
"""
try:
from scipy.sparse import coo_matrix
except ImportError as e:
print(str(e))
print("I am peforming dense normalization by default.")
return trim_dense(M.todens... | python | def trim_sparse(M, n_std=3, s_min=None, s_max=None):
"""Apply the trimming procedure to a sparse matrix.
"""
try:
from scipy.sparse import coo_matrix
except ImportError as e:
print(str(e))
print("I am peforming dense normalization by default.")
return trim_dense(M.todens... | [
"def",
"trim_sparse",
"(",
"M",
",",
"n_std",
"=",
"3",
",",
"s_min",
"=",
"None",
",",
"s_max",
"=",
"None",
")",
":",
"try",
":",
"from",
"scipy",
".",
"sparse",
"import",
"coo_matrix",
"except",
"ImportError",
"as",
"e",
":",
"print",
"(",
"str",
... | Apply the trimming procedure to a sparse matrix. | [
"Apply",
"the",
"trimming",
"procedure",
"to",
"a",
"sparse",
"matrix",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L361-L386 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | normalize_dense | def normalize_dense(M, norm="frag", order=1, iterations=3):
"""Apply one of the many normalization types to input dense
matrix. Will also apply any callable norms such as a user-made
or a lambda function.
"""
s = np.array(M, np.float64)
floatorder = np.float64(order)
if norm == "SCN":
... | python | def normalize_dense(M, norm="frag", order=1, iterations=3):
"""Apply one of the many normalization types to input dense
matrix. Will also apply any callable norms such as a user-made
or a lambda function.
"""
s = np.array(M, np.float64)
floatorder = np.float64(order)
if norm == "SCN":
... | [
"def",
"normalize_dense",
"(",
"M",
",",
"norm",
"=",
"\"frag\"",
",",
"order",
"=",
"1",
",",
"iterations",
"=",
"3",
")",
":",
"s",
"=",
"np",
".",
"array",
"(",
"M",
",",
"np",
".",
"float64",
")",
"floatorder",
"=",
"np",
".",
"float64",
"(",... | Apply one of the many normalization types to input dense
matrix. Will also apply any callable norms such as a user-made
or a lambda function. | [
"Apply",
"one",
"of",
"the",
"many",
"normalization",
"types",
"to",
"input",
"dense",
"matrix",
".",
"Will",
"also",
"apply",
"any",
"callable",
"norms",
"such",
"as",
"a",
"user",
"-",
"made",
"or",
"a",
"lambda",
"function",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L389-L440 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | normalize_sparse | def normalize_sparse(M, norm="frag", order=1, iterations=3):
"""Applies a normalization type to a sparse matrix.
"""
try:
from scipy.sparse import csr_matrix
except ImportError as e:
print(str(e))
print("I am peforming dense normalization by default.")
return normalize_d... | python | def normalize_sparse(M, norm="frag", order=1, iterations=3):
"""Applies a normalization type to a sparse matrix.
"""
try:
from scipy.sparse import csr_matrix
except ImportError as e:
print(str(e))
print("I am peforming dense normalization by default.")
return normalize_d... | [
"def",
"normalize_sparse",
"(",
"M",
",",
"norm",
"=",
"\"frag\"",
",",
"order",
"=",
"1",
",",
"iterations",
"=",
"3",
")",
":",
"try",
":",
"from",
"scipy",
".",
"sparse",
"import",
"csr_matrix",
"except",
"ImportError",
"as",
"e",
":",
"print",
"(",... | Applies a normalization type to a sparse matrix. | [
"Applies",
"a",
"normalization",
"type",
"to",
"a",
"sparse",
"matrix",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L443-L476 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | GC_wide | def GC_wide(genome, window=1000):
"""Compute GC across a window of given length.
:note: Requires Biopython
"""
GC = []
from Bio import SeqIO
with open(genome) as handle:
sequence = "".join([str(record.seq)
for record in SeqIO.parse(handle, "fasta")])
n ... | python | def GC_wide(genome, window=1000):
"""Compute GC across a window of given length.
:note: Requires Biopython
"""
GC = []
from Bio import SeqIO
with open(genome) as handle:
sequence = "".join([str(record.seq)
for record in SeqIO.parse(handle, "fasta")])
n ... | [
"def",
"GC_wide",
"(",
"genome",
",",
"window",
"=",
"1000",
")",
":",
"GC",
"=",
"[",
"]",
"from",
"Bio",
"import",
"SeqIO",
"with",
"open",
"(",
"genome",
")",
"as",
"handle",
":",
"sequence",
"=",
"\"\"",
".",
"join",
"(",
"[",
"str",
"(",
"re... | Compute GC across a window of given length.
:note: Requires Biopython | [
"Compute",
"GC",
"across",
"a",
"window",
"of",
"given",
"length",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L492-L509 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | to_dade_matrix | def to_dade_matrix(M, annotations="", filename=None):
"""Returns a Dade matrix from input numpy matrix. Any annotations are added
as header. If filename is provided and valid, said matrix is also saved
as text.
"""
n, m = M.shape
A = np.zeros((n + 1, m + 1))
A[1:, 1:] = M
if not annotat... | python | def to_dade_matrix(M, annotations="", filename=None):
"""Returns a Dade matrix from input numpy matrix. Any annotations are added
as header. If filename is provided and valid, said matrix is also saved
as text.
"""
n, m = M.shape
A = np.zeros((n + 1, m + 1))
A[1:, 1:] = M
if not annotat... | [
"def",
"to_dade_matrix",
"(",
"M",
",",
"annotations",
"=",
"\"\"",
",",
"filename",
"=",
"None",
")",
":",
"n",
",",
"m",
"=",
"M",
".",
"shape",
"A",
"=",
"np",
".",
"zeros",
"(",
"(",
"n",
"+",
"1",
",",
"m",
"+",
"1",
")",
")",
"A",
"["... | Returns a Dade matrix from input numpy matrix. Any annotations are added
as header. If filename is provided and valid, said matrix is also saved
as text. | [
"Returns",
"a",
"Dade",
"matrix",
"from",
"input",
"numpy",
"matrix",
".",
"Any",
"annotations",
"are",
"added",
"as",
"header",
".",
"If",
"filename",
"is",
"provided",
"and",
"valid",
"said",
"matrix",
"is",
"also",
"saved",
"as",
"text",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L678-L701 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | largest_connected_component | def largest_connected_component(matrix):
"""Compute the adjacency matrix of the largest connected component of the
graph whose input matrix is adjacent.
"""
try:
import scipy.sparse
n, components = scipy.sparse.csgraph.connected_components(
matrix, directed=False)
pr... | python | def largest_connected_component(matrix):
"""Compute the adjacency matrix of the largest connected component of the
graph whose input matrix is adjacent.
"""
try:
import scipy.sparse
n, components = scipy.sparse.csgraph.connected_components(
matrix, directed=False)
pr... | [
"def",
"largest_connected_component",
"(",
"matrix",
")",
":",
"try",
":",
"import",
"scipy",
".",
"sparse",
"n",
",",
"components",
"=",
"scipy",
".",
"sparse",
".",
"csgraph",
".",
"connected_components",
"(",
"matrix",
",",
"directed",
"=",
"False",
")",
... | Compute the adjacency matrix of the largest connected component of the
graph whose input matrix is adjacent. | [
"Compute",
"the",
"adjacency",
"matrix",
"of",
"the",
"largest",
"connected",
"component",
"of",
"the",
"graph",
"whose",
"input",
"matrix",
"is",
"adjacent",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L736-L756 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | to_structure | def to_structure(matrix, alpha=1):
"""Compute best matching 3D genome structure from underlying input matrix
using ShRec3D-derived method from Lesne et al., 2014.
Link: https://www.ncbi.nlm.nih.gov/pubmed/25240436
The method performs two steps: first compute distance matrix by treating
contact dat... | python | def to_structure(matrix, alpha=1):
"""Compute best matching 3D genome structure from underlying input matrix
using ShRec3D-derived method from Lesne et al., 2014.
Link: https://www.ncbi.nlm.nih.gov/pubmed/25240436
The method performs two steps: first compute distance matrix by treating
contact dat... | [
"def",
"to_structure",
"(",
"matrix",
",",
"alpha",
"=",
"1",
")",
":",
"connected",
"=",
"largest_connected_component",
"(",
"matrix",
")",
"distances",
"=",
"to_distance",
"(",
"connected",
",",
"alpha",
")",
"n",
",",
"m",
"=",
"connected",
".",
"shape"... | Compute best matching 3D genome structure from underlying input matrix
using ShRec3D-derived method from Lesne et al., 2014.
Link: https://www.ncbi.nlm.nih.gov/pubmed/25240436
The method performs two steps: first compute distance matrix by treating
contact data as an adjacency graph (of weights equal ... | [
"Compute",
"best",
"matching",
"3D",
"genome",
"structure",
"from",
"underlying",
"input",
"matrix",
"using",
"ShRec3D",
"-",
"derived",
"method",
"from",
"Lesne",
"et",
"al",
".",
"2014",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L759-L798 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | get_missing_bins | def get_missing_bins(original, trimmed):
"""Retrieve indices of a trimmed matrix with respect to the original matrix.
Fairly fast but is only correct if diagonal values are different, which is
always the case in practice.
"""
original_diag = np.diag(original)
trimmed_diag = np.diag(trimmed)
... | python | def get_missing_bins(original, trimmed):
"""Retrieve indices of a trimmed matrix with respect to the original matrix.
Fairly fast but is only correct if diagonal values are different, which is
always the case in practice.
"""
original_diag = np.diag(original)
trimmed_diag = np.diag(trimmed)
... | [
"def",
"get_missing_bins",
"(",
"original",
",",
"trimmed",
")",
":",
"original_diag",
"=",
"np",
".",
"diag",
"(",
"original",
")",
"trimmed_diag",
"=",
"np",
".",
"diag",
"(",
"trimmed",
")",
"index",
"=",
"[",
"]",
"m",
"=",
"min",
"(",
"original",
... | Retrieve indices of a trimmed matrix with respect to the original matrix.
Fairly fast but is only correct if diagonal values are different, which is
always the case in practice. | [
"Retrieve",
"indices",
"of",
"a",
"trimmed",
"matrix",
"with",
"respect",
"to",
"the",
"original",
"matrix",
".",
"Fairly",
"fast",
"but",
"is",
"only",
"correct",
"if",
"diagonal",
"values",
"are",
"different",
"which",
"is",
"always",
"the",
"case",
"in",
... | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L801-L816 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | distance_to_contact | def distance_to_contact(D, alpha=1):
"""Compute contact matrix from input distance matrix. Distance values of
zeroes are given the largest contact count otherwise inferred non-zero
distance values.
"""
if callable(alpha):
distance_function = alpha
else:
try:
a = np.f... | python | def distance_to_contact(D, alpha=1):
"""Compute contact matrix from input distance matrix. Distance values of
zeroes are given the largest contact count otherwise inferred non-zero
distance values.
"""
if callable(alpha):
distance_function = alpha
else:
try:
a = np.f... | [
"def",
"distance_to_contact",
"(",
"D",
",",
"alpha",
"=",
"1",
")",
":",
"if",
"callable",
"(",
"alpha",
")",
":",
"distance_function",
"=",
"alpha",
"else",
":",
"try",
":",
"a",
"=",
"np",
".",
"float64",
"(",
"alpha",
")",
"def",
"distance_function... | Compute contact matrix from input distance matrix. Distance values of
zeroes are given the largest contact count otherwise inferred non-zero
distance values. | [
"Compute",
"contact",
"matrix",
"from",
"input",
"distance",
"matrix",
".",
"Distance",
"values",
"of",
"zeroes",
"are",
"given",
"the",
"largest",
"contact",
"count",
"otherwise",
"inferred",
"non",
"-",
"zero",
"distance",
"values",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L918-L942 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | pdb_to_structure | def pdb_to_structure(filename):
"""Import a structure object from a PDB file.
"""
try:
from Bio.PDB import PDB
except ImportError:
print("I can't import Biopython which is needed to handle PDB files.")
raise
p = PDB.PDBParser()
structure = p.get_structure('S', filename)
... | python | def pdb_to_structure(filename):
"""Import a structure object from a PDB file.
"""
try:
from Bio.PDB import PDB
except ImportError:
print("I can't import Biopython which is needed to handle PDB files.")
raise
p = PDB.PDBParser()
structure = p.get_structure('S', filename)
... | [
"def",
"pdb_to_structure",
"(",
"filename",
")",
":",
"try",
":",
"from",
"Bio",
".",
"PDB",
"import",
"PDB",
"except",
"ImportError",
":",
"print",
"(",
"\"I can't import Biopython which is needed to handle PDB files.\"",
")",
"raise",
"p",
"=",
"PDB",
".",
"PDBP... | Import a structure object from a PDB file. | [
"Import",
"a",
"structure",
"object",
"from",
"a",
"PDB",
"file",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L980-L993 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | positions_to_contigs | def positions_to_contigs(positions):
"""Flattens and converts a positions array to a contigs array, if applicable.
"""
if isinstance(positions, np.ndarray):
flattened_positions = positions.flatten()
else:
try:
flattened_positions = np.array(
[pos for contig i... | python | def positions_to_contigs(positions):
"""Flattens and converts a positions array to a contigs array, if applicable.
"""
if isinstance(positions, np.ndarray):
flattened_positions = positions.flatten()
else:
try:
flattened_positions = np.array(
[pos for contig i... | [
"def",
"positions_to_contigs",
"(",
"positions",
")",
":",
"if",
"isinstance",
"(",
"positions",
",",
"np",
".",
"ndarray",
")",
":",
"flattened_positions",
"=",
"positions",
".",
"flatten",
"(",
")",
"else",
":",
"try",
":",
"flattened_positions",
"=",
"np"... | Flattens and converts a positions array to a contigs array, if applicable. | [
"Flattens",
"and",
"converts",
"a",
"positions",
"array",
"to",
"a",
"contigs",
"array",
"if",
"applicable",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L1005-L1031 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | distance_diagonal_law | def distance_diagonal_law(matrix, positions=None):
"""Compute a distance law trend using the contact averages of equal distances.
Specific positions can be supplied if needed.
"""
n = min(matrix.shape)
if positions is None:
return np.array([np.average(np.diagonal(matrix, j)) for j in range(... | python | def distance_diagonal_law(matrix, positions=None):
"""Compute a distance law trend using the contact averages of equal distances.
Specific positions can be supplied if needed.
"""
n = min(matrix.shape)
if positions is None:
return np.array([np.average(np.diagonal(matrix, j)) for j in range(... | [
"def",
"distance_diagonal_law",
"(",
"matrix",
",",
"positions",
"=",
"None",
")",
":",
"n",
"=",
"min",
"(",
"matrix",
".",
"shape",
")",
"if",
"positions",
"is",
"None",
":",
"return",
"np",
".",
"array",
"(",
"[",
"np",
".",
"average",
"(",
"np",
... | Compute a distance law trend using the contact averages of equal distances.
Specific positions can be supplied if needed. | [
"Compute",
"a",
"distance",
"law",
"trend",
"using",
"the",
"contact",
"averages",
"of",
"equal",
"distances",
".",
"Specific",
"positions",
"can",
"be",
"supplied",
"if",
"needed",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L1034-L1066 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | rippe_parameters | def rippe_parameters(matrix, positions, lengths=None, init=None, circ=False):
"""Estimate parameters from the model described in Rippe et al., 2001.
"""
n, _ = matrix.shape
if lengths is None:
lengths = np.abs(np.diff(positions))
measurements, bins = [], []
for i in range(n):
... | python | def rippe_parameters(matrix, positions, lengths=None, init=None, circ=False):
"""Estimate parameters from the model described in Rippe et al., 2001.
"""
n, _ = matrix.shape
if lengths is None:
lengths = np.abs(np.diff(positions))
measurements, bins = [], []
for i in range(n):
... | [
"def",
"rippe_parameters",
"(",
"matrix",
",",
"positions",
",",
"lengths",
"=",
"None",
",",
"init",
"=",
"None",
",",
"circ",
"=",
"False",
")",
":",
"n",
",",
"_",
"=",
"matrix",
".",
"shape",
"if",
"lengths",
"is",
"None",
":",
"lengths",
"=",
... | Estimate parameters from the model described in Rippe et al., 2001. | [
"Estimate",
"parameters",
"from",
"the",
"model",
"described",
"in",
"Rippe",
"et",
"al",
".",
"2001",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L1069-L1095 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | scalogram | def scalogram(M, circ=False):
"""Computes so-called 'scalograms' used to easily
visualize contacts at different distance scales.
Edge cases have been painstakingly taken
care of.
"""
# Sanity checks
if not type(M) is np.ndarray:
M = np.array(M)
if M.shape[0] != M.shape[1]:
... | python | def scalogram(M, circ=False):
"""Computes so-called 'scalograms' used to easily
visualize contacts at different distance scales.
Edge cases have been painstakingly taken
care of.
"""
# Sanity checks
if not type(M) is np.ndarray:
M = np.array(M)
if M.shape[0] != M.shape[1]:
... | [
"def",
"scalogram",
"(",
"M",
",",
"circ",
"=",
"False",
")",
":",
"# Sanity checks",
"if",
"not",
"type",
"(",
"M",
")",
"is",
"np",
".",
"ndarray",
":",
"M",
"=",
"np",
".",
"array",
"(",
"M",
")",
"if",
"M",
".",
"shape",
"[",
"0",
"]",
"!... | Computes so-called 'scalograms' used to easily
visualize contacts at different distance scales.
Edge cases have been painstakingly taken
care of. | [
"Computes",
"so",
"-",
"called",
"scalograms",
"used",
"to",
"easily",
"visualize",
"contacts",
"at",
"different",
"distance",
"scales",
".",
"Edge",
"cases",
"have",
"been",
"painstakingly",
"taken",
"care",
"of",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L1288-L1321 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | asd | def asd(M1, M2):
"""Compute a Fourier transform based distance
between two matrices.
Inspired from Galiez et al., 2015
(https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4535829/)
"""
from scipy.fftpack import fft2
spectra1 = np.abs(fft2(M1))
spectra2 = np.abs(fft2(M2))
return np.linal... | python | def asd(M1, M2):
"""Compute a Fourier transform based distance
between two matrices.
Inspired from Galiez et al., 2015
(https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4535829/)
"""
from scipy.fftpack import fft2
spectra1 = np.abs(fft2(M1))
spectra2 = np.abs(fft2(M2))
return np.linal... | [
"def",
"asd",
"(",
"M1",
",",
"M2",
")",
":",
"from",
"scipy",
".",
"fftpack",
"import",
"fft2",
"spectra1",
"=",
"np",
".",
"abs",
"(",
"fft2",
"(",
"M1",
")",
")",
"spectra2",
"=",
"np",
".",
"abs",
"(",
"fft2",
"(",
"M2",
")",
")",
"return",... | Compute a Fourier transform based distance
between two matrices.
Inspired from Galiez et al., 2015
(https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4535829/) | [
"Compute",
"a",
"Fourier",
"transform",
"based",
"distance",
"between",
"two",
"matrices",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L1324-L1336 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | remove_intra | def remove_intra(M, contigs):
"""Remove intrachromosomal contacts
Given a contact map and a list attributing each position
to a given chromosome, set all contacts within each
chromosome or contig to zero. Useful to perform
calculations on interchromosomal contacts only.
Parameters
--------... | python | def remove_intra(M, contigs):
"""Remove intrachromosomal contacts
Given a contact map and a list attributing each position
to a given chromosome, set all contacts within each
chromosome or contig to zero. Useful to perform
calculations on interchromosomal contacts only.
Parameters
--------... | [
"def",
"remove_intra",
"(",
"M",
",",
"contigs",
")",
":",
"N",
"=",
"np",
".",
"copy",
"(",
"M",
")",
"n",
"=",
"len",
"(",
"N",
")",
"assert",
"n",
"==",
"len",
"(",
"contigs",
")",
"# Naive implmentation for now",
"for",
"(",
"i",
",",
"j",
")... | Remove intrachromosomal contacts
Given a contact map and a list attributing each position
to a given chromosome, set all contacts within each
chromosome or contig to zero. Useful to perform
calculations on interchromosomal contacts only.
Parameters
----------
M : array_like
The ini... | [
"Remove",
"intrachromosomal",
"contacts"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L1378-L1412 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | positions_to_contigs | def positions_to_contigs(positions):
"""Label contigs according to relative positions
Given a list of positions, return an ordered list
of labels reflecting where the positions array started
over (and presumably a new contig began).
Parameters
----------
positions : list or array_like
... | python | def positions_to_contigs(positions):
"""Label contigs according to relative positions
Given a list of positions, return an ordered list
of labels reflecting where the positions array started
over (and presumably a new contig began).
Parameters
----------
positions : list or array_like
... | [
"def",
"positions_to_contigs",
"(",
"positions",
")",
":",
"contig_labels",
"=",
"np",
".",
"zeros_like",
"(",
"positions",
")",
"contig_index",
"=",
"0",
"for",
"i",
",",
"p",
"in",
"enumerate",
"(",
"positions",
")",
":",
"if",
"p",
"==",
"0",
":",
"... | Label contigs according to relative positions
Given a list of positions, return an ordered list
of labels reflecting where the positions array started
over (and presumably a new contig began).
Parameters
----------
positions : list or array_like
A piece-wise ordered list of integers re... | [
"Label",
"contigs",
"according",
"to",
"relative",
"positions"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L1452-L1480 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | contigs_to_positions | def contigs_to_positions(contigs, binning=10000):
"""Build positions from contig labels
From a list of contig labels and a binning parameter,
build a list of positions that's essentially a
concatenation of linspaces with step equal to the
binning.
Parameters
----------
contigs : list o... | python | def contigs_to_positions(contigs, binning=10000):
"""Build positions from contig labels
From a list of contig labels and a binning parameter,
build a list of positions that's essentially a
concatenation of linspaces with step equal to the
binning.
Parameters
----------
contigs : list o... | [
"def",
"contigs_to_positions",
"(",
"contigs",
",",
"binning",
"=",
"10000",
")",
":",
"positions",
"=",
"np",
".",
"zeros_like",
"(",
"contigs",
")",
"index",
"=",
"0",
"for",
"_",
",",
"chunk",
"in",
"itertools",
".",
"groubpy",
"(",
"contigs",
")",
... | Build positions from contig labels
From a list of contig labels and a binning parameter,
build a list of positions that's essentially a
concatenation of linspaces with step equal to the
binning.
Parameters
----------
contigs : list or array_like
The list of contig labels, must be s... | [
"Build",
"positions",
"from",
"contig",
"labels"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L1482-L1511 | train |
koszullab/metaTOR | metator/scripts/hicstuff.py | split_matrix | def split_matrix(M, contigs):
"""Split multiple chromosome matrix
Split a labeled matrix with multiple chromosomes
into unlabeled single-chromosome matrices. Inter chromosomal
contacts are discarded.
Parameters
----------
M : array_like
The multiple chromosome matrix to be split
... | python | def split_matrix(M, contigs):
"""Split multiple chromosome matrix
Split a labeled matrix with multiple chromosomes
into unlabeled single-chromosome matrices. Inter chromosomal
contacts are discarded.
Parameters
----------
M : array_like
The multiple chromosome matrix to be split
... | [
"def",
"split_matrix",
"(",
"M",
",",
"contigs",
")",
":",
"index",
"=",
"0",
"for",
"_",
",",
"chunk",
"in",
"itertools",
".",
"groubpy",
"(",
"contigs",
")",
":",
"l",
"=",
"len",
"(",
"chunk",
")",
"yield",
"M",
"[",
"index",
":",
"index",
"+"... | Split multiple chromosome matrix
Split a labeled matrix with multiple chromosomes
into unlabeled single-chromosome matrices. Inter chromosomal
contacts are discarded.
Parameters
----------
M : array_like
The multiple chromosome matrix to be split
contigs : list or array_like
... | [
"Split",
"multiple",
"chromosome",
"matrix"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/hicstuff.py#L1514-L1533 | train |
MacHu-GWU/single_file_module-project | sfm/binarysearch.py | find_nearest | def find_nearest(sorted_list, x):
"""
Find the nearest item of x from sorted array.
:type array: list
:param array: an iterable object that support inex
:param x: a comparable value
note: for finding the nearest item from a descending array, I recommend
find_nearest(sorted_list[::-1], x).... | python | def find_nearest(sorted_list, x):
"""
Find the nearest item of x from sorted array.
:type array: list
:param array: an iterable object that support inex
:param x: a comparable value
note: for finding the nearest item from a descending array, I recommend
find_nearest(sorted_list[::-1], x).... | [
"def",
"find_nearest",
"(",
"sorted_list",
",",
"x",
")",
":",
"if",
"x",
"<=",
"sorted_list",
"[",
"0",
"]",
":",
"return",
"sorted_list",
"[",
"0",
"]",
"elif",
"x",
">=",
"sorted_list",
"[",
"-",
"1",
"]",
":",
"return",
"sorted_list",
"[",
"-",
... | Find the nearest item of x from sorted array.
:type array: list
:param array: an iterable object that support inex
:param x: a comparable value
note: for finding the nearest item from a descending array, I recommend
find_nearest(sorted_list[::-1], x). Because the built-in list[::-1] method
is... | [
"Find",
"the",
"nearest",
"item",
"of",
"x",
"from",
"sorted",
"array",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/binarysearch.py#L146-L178 | train |
MacHu-GWU/single_file_module-project | sfm/matplot_mate.py | format_x_tick | def format_x_tick(axis,
major_locator=None,
major_formatter=None,
minor_locator=None,
minor_formatter=None):
"""Set x axis's format.
This method is designed for time axis.
**中文文档**
设置X轴格式。
"""
if major_locator:
ax... | python | def format_x_tick(axis,
major_locator=None,
major_formatter=None,
minor_locator=None,
minor_formatter=None):
"""Set x axis's format.
This method is designed for time axis.
**中文文档**
设置X轴格式。
"""
if major_locator:
ax... | [
"def",
"format_x_tick",
"(",
"axis",
",",
"major_locator",
"=",
"None",
",",
"major_formatter",
"=",
"None",
",",
"minor_locator",
"=",
"None",
",",
"minor_formatter",
"=",
"None",
")",
":",
"if",
"major_locator",
":",
"axis",
".",
"xaxis",
".",
"set_major_l... | Set x axis's format.
This method is designed for time axis.
**中文文档**
设置X轴格式。 | [
"Set",
"x",
"axis",
"s",
"format",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/matplot_mate.py#L60-L85 | train |
MacHu-GWU/single_file_module-project | sfm/matplot_mate.py | set_legend | def set_legend(axis, lines, legend):
"""Set line legend.
**中文文档**
设置图例。
"""
try:
if legend:
axis.legend(lines, legend)
except Exception as e:
raise ValueError("invalid 'legend', Error: %s" % e) | python | def set_legend(axis, lines, legend):
"""Set line legend.
**中文文档**
设置图例。
"""
try:
if legend:
axis.legend(lines, legend)
except Exception as e:
raise ValueError("invalid 'legend', Error: %s" % e) | [
"def",
"set_legend",
"(",
"axis",
",",
"lines",
",",
"legend",
")",
":",
"try",
":",
"if",
"legend",
":",
"axis",
".",
"legend",
"(",
"lines",
",",
"legend",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"ValueError",
"(",
"\"invalid 'legend', Err... | Set line legend.
**中文文档**
设置图例。 | [
"Set",
"line",
"legend",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/matplot_mate.py#L119-L130 | train |
MacHu-GWU/single_file_module-project | sfm/matplot_mate.py | get_max | def get_max(array):
"""Get maximum value of an array. Automatically ignore invalid data.
**中文文档**
获得最大值。
"""
largest = -np.inf
for i in array:
try:
if i > largest:
largest = i
except:
pass
if np.isinf(largest):
raise ValueErro... | python | def get_max(array):
"""Get maximum value of an array. Automatically ignore invalid data.
**中文文档**
获得最大值。
"""
largest = -np.inf
for i in array:
try:
if i > largest:
largest = i
except:
pass
if np.isinf(largest):
raise ValueErro... | [
"def",
"get_max",
"(",
"array",
")",
":",
"largest",
"=",
"-",
"np",
".",
"inf",
"for",
"i",
"in",
"array",
":",
"try",
":",
"if",
"i",
">",
"largest",
":",
"largest",
"=",
"i",
"except",
":",
"pass",
"if",
"np",
".",
"isinf",
"(",
"largest",
"... | Get maximum value of an array. Automatically ignore invalid data.
**中文文档**
获得最大值。 | [
"Get",
"maximum",
"value",
"of",
"an",
"array",
".",
"Automatically",
"ignore",
"invalid",
"data",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/matplot_mate.py#L133-L150 | train |
MacHu-GWU/single_file_module-project | sfm/matplot_mate.py | get_min | def get_min(array):
"""Get minimum value of an array. Automatically ignore invalid data.
**中文文档**
获得最小值。
"""
smallest = np.inf
for i in array:
try:
if i < smallest:
smallest = i
except:
pass
if np.isinf(smallest):
raise ValueE... | python | def get_min(array):
"""Get minimum value of an array. Automatically ignore invalid data.
**中文文档**
获得最小值。
"""
smallest = np.inf
for i in array:
try:
if i < smallest:
smallest = i
except:
pass
if np.isinf(smallest):
raise ValueE... | [
"def",
"get_min",
"(",
"array",
")",
":",
"smallest",
"=",
"np",
".",
"inf",
"for",
"i",
"in",
"array",
":",
"try",
":",
"if",
"i",
"<",
"smallest",
":",
"smallest",
"=",
"i",
"except",
":",
"pass",
"if",
"np",
".",
"isinf",
"(",
"smallest",
")",... | Get minimum value of an array. Automatically ignore invalid data.
**中文文档**
获得最小值。 | [
"Get",
"minimum",
"value",
"of",
"an",
"array",
".",
"Automatically",
"ignore",
"invalid",
"data",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/matplot_mate.py#L153-L170 | train |
MacHu-GWU/single_file_module-project | sfm/matplot_mate.py | get_yAxis_limit | def get_yAxis_limit(y, lower=0.05, upper=0.2):
"""Find optimal y_min and y_max that guarantee enough space for legend and
plot.
**中文文档**
计算y坐标轴的最小和最大坐标。
:params lower: ymin为 y的最小值再减去gap的一定倍率
:params upper: ymax为 y的最大值再加上gap的一定倍率
"""
smallest = get_min(y)
largest = get_max(y)
... | python | def get_yAxis_limit(y, lower=0.05, upper=0.2):
"""Find optimal y_min and y_max that guarantee enough space for legend and
plot.
**中文文档**
计算y坐标轴的最小和最大坐标。
:params lower: ymin为 y的最小值再减去gap的一定倍率
:params upper: ymax为 y的最大值再加上gap的一定倍率
"""
smallest = get_min(y)
largest = get_max(y)
... | [
"def",
"get_yAxis_limit",
"(",
"y",
",",
"lower",
"=",
"0.05",
",",
"upper",
"=",
"0.2",
")",
":",
"smallest",
"=",
"get_min",
"(",
"y",
")",
"largest",
"=",
"get_max",
"(",
"y",
")",
"gap",
"=",
"largest",
"-",
"smallest",
"if",
"gap",
">=",
"0.00... | Find optimal y_min and y_max that guarantee enough space for legend and
plot.
**中文文档**
计算y坐标轴的最小和最大坐标。
:params lower: ymin为 y的最小值再减去gap的一定倍率
:params upper: ymax为 y的最大值再加上gap的一定倍率 | [
"Find",
"optimal",
"y_min",
"and",
"y_max",
"that",
"guarantee",
"enough",
"space",
"for",
"legend",
"and",
"plot",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/matplot_mate.py#L173-L193 | train |
MacHu-GWU/single_file_module-project | sfm/matplot_mate.py | create_figure | def create_figure(width=20, height=10):
"""Create a figure instance.
:params width: figure width
:params height: figure height
"""
figure = plt.figure(figsize=(width, height))
axis = figure.add_subplot(1, 1, 1)
return figure, axis | python | def create_figure(width=20, height=10):
"""Create a figure instance.
:params width: figure width
:params height: figure height
"""
figure = plt.figure(figsize=(width, height))
axis = figure.add_subplot(1, 1, 1)
return figure, axis | [
"def",
"create_figure",
"(",
"width",
"=",
"20",
",",
"height",
"=",
"10",
")",
":",
"figure",
"=",
"plt",
".",
"figure",
"(",
"figsize",
"=",
"(",
"width",
",",
"height",
")",
")",
"axis",
"=",
"figure",
".",
"add_subplot",
"(",
"1",
",",
"1",
"... | Create a figure instance.
:params width: figure width
:params height: figure height | [
"Create",
"a",
"figure",
"instance",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/matplot_mate.py#L196-L204 | train |
MacHu-GWU/single_file_module-project | sfm/matplot_mate.py | preprocess_x_y | def preprocess_x_y(x, y):
"""Preprocess x, y input data. Returns list of list style.
**中文文档**
预处理输入的x, y数据。
"""
def is_iterable_slicable(a):
if hasattr(a, "__iter__") and hasattr(a, "__getitem__"):
return True
else:
return False
if is_iterable_slicable(... | python | def preprocess_x_y(x, y):
"""Preprocess x, y input data. Returns list of list style.
**中文文档**
预处理输入的x, y数据。
"""
def is_iterable_slicable(a):
if hasattr(a, "__iter__") and hasattr(a, "__getitem__"):
return True
else:
return False
if is_iterable_slicable(... | [
"def",
"preprocess_x_y",
"(",
"x",
",",
"y",
")",
":",
"def",
"is_iterable_slicable",
"(",
"a",
")",
":",
"if",
"hasattr",
"(",
"a",
",",
"\"__iter__\"",
")",
"and",
"hasattr",
"(",
"a",
",",
"\"__getitem__\"",
")",
":",
"return",
"True",
"else",
":",
... | Preprocess x, y input data. Returns list of list style.
**中文文档**
预处理输入的x, y数据。 | [
"Preprocess",
"x",
"y",
"input",
"data",
".",
"Returns",
"list",
"of",
"list",
"style",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/matplot_mate.py#L207-L226 | train |
envi-idl/envipyengine | envipyengine/taskengine/taskengine.py | execute | def execute(input_params, engine, cwd=None):
"""
Execute a task with the provided input parameters
:param input_params: Python dictionary containg all input parameters.
This will be converted to JSON before being passed
to the task engine.
:param engine... | python | def execute(input_params, engine, cwd=None):
"""
Execute a task with the provided input parameters
:param input_params: Python dictionary containg all input parameters.
This will be converted to JSON before being passed
to the task engine.
:param engine... | [
"def",
"execute",
"(",
"input_params",
",",
"engine",
",",
"cwd",
"=",
"None",
")",
":",
"try",
":",
"taskengine_exe",
"=",
"config",
".",
"get",
"(",
"'engine'",
")",
"except",
"NoConfigOptionError",
":",
"raise",
"TaskEngineNotFoundError",
"(",
"\"Task Engin... | Execute a task with the provided input parameters
:param input_params: Python dictionary containg all input parameters.
This will be converted to JSON before being passed
to the task engine.
:param engine: String specifying Task Engine type to run (ENVI, IDL, e... | [
"Execute",
"a",
"task",
"with",
"the",
"provided",
"input",
"parameters"
] | 567b639d6592deec3289f6122a9e3d18f2f98432 | https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/taskengine/taskengine.py#L17-L84 | train |
Godley/MuseParse | MuseParse/classes/Output/LilypondOutput.py | LilypondRenderer.run | def run(self, wrappers=["", ""]):
'''
run the lilypond script on the hierarchy class
:param wrappers: this is useful for testing: use wrappers to put something around the outputted "lilypond string" from the hierarchy class.
For example if you're testing a pitch, you might put \relative... | python | def run(self, wrappers=["", ""]):
'''
run the lilypond script on the hierarchy class
:param wrappers: this is useful for testing: use wrappers to put something around the outputted "lilypond string" from the hierarchy class.
For example if you're testing a pitch, you might put \relative... | [
"def",
"run",
"(",
"self",
",",
"wrappers",
"=",
"[",
"\"\"",
",",
"\"\"",
"]",
")",
":",
"opened_file",
"=",
"open",
"(",
"self",
".",
"lyfile",
",",
"'w'",
")",
"lilystring",
"=",
"self",
".",
"piece_obj",
".",
"toLily",
"(",
")",
"opened_file",
... | run the lilypond script on the hierarchy class
:param wrappers: this is useful for testing: use wrappers to put something around the outputted "lilypond string" from the hierarchy class.
For example if you're testing a pitch, you might put \relative c {} around the note so that lilypond handles it prop... | [
"run",
"the",
"lilypond",
"script",
"on",
"the",
"hierarchy",
"class"
] | 23cecafa1fdc0f2d6a87760553572b459f3c9904 | https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/Output/LilypondOutput.py#L42-L64 | train |
koszullab/metaTOR | metator/scripts/bins.py | extract_fasta | def extract_fasta(
partition_file,
fasta_file,
output_dir,
chunk_size=DEFAULT_CHUNK_SIZE,
max_cores=DEFAULT_MAX_CORES,
):
"""Extract sequences from bins
Identify bins, extract chunks belonging to each bins and gather them
in a single FASTA file.
Parameters
----------
parti... | python | def extract_fasta(
partition_file,
fasta_file,
output_dir,
chunk_size=DEFAULT_CHUNK_SIZE,
max_cores=DEFAULT_MAX_CORES,
):
"""Extract sequences from bins
Identify bins, extract chunks belonging to each bins and gather them
in a single FASTA file.
Parameters
----------
parti... | [
"def",
"extract_fasta",
"(",
"partition_file",
",",
"fasta_file",
",",
"output_dir",
",",
"chunk_size",
"=",
"DEFAULT_CHUNK_SIZE",
",",
"max_cores",
"=",
"DEFAULT_MAX_CORES",
",",
")",
":",
"genome",
"=",
"{",
"record",
".",
"id",
":",
"record",
".",
"seq",
... | Extract sequences from bins
Identify bins, extract chunks belonging to each bins and gather them
in a single FASTA file.
Parameters
----------
partition_file : file, str or pathlib.Path
The file containing, for each chunk, the communities it was
assigned to at each iteration.
f... | [
"Extract",
"sequences",
"from",
"bins"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/bins.py#L183-L243 | train |
koszullab/metaTOR | metator/scripts/bins.py | merge_fasta | def merge_fasta(fasta_file, output_dir):
"""Merge chunks into complete FASTA bins
Merge bin chunks by appending consecutive chunks to one another.
Parameters
----------
fasta_file : file, str or pathlib.Path
The FASTA file containing the chunks to merge.
output_dir : str or pathlib.Pa... | python | def merge_fasta(fasta_file, output_dir):
"""Merge chunks into complete FASTA bins
Merge bin chunks by appending consecutive chunks to one another.
Parameters
----------
fasta_file : file, str or pathlib.Path
The FASTA file containing the chunks to merge.
output_dir : str or pathlib.Pa... | [
"def",
"merge_fasta",
"(",
"fasta_file",
",",
"output_dir",
")",
":",
"# First, define some functions for ordering chunks and detecting",
"# consecutive chunk sequences",
"def",
"chunk_lexicographic_order",
"(",
"chunk",
")",
":",
"\"\"\"A quick callback to sort chunk ids lexicog... | Merge chunks into complete FASTA bins
Merge bin chunks by appending consecutive chunks to one another.
Parameters
----------
fasta_file : file, str or pathlib.Path
The FASTA file containing the chunks to merge.
output_dir : str or pathlib.Path
The output directory to write the merg... | [
"Merge",
"chunks",
"into",
"complete",
"FASTA",
"bins"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/bins.py#L246-L327 | train |
nugget/python-anthemav | anthemav/tools.py | monitor | def monitor():
"""Wrapper to call console with a loop."""
log = logging.getLogger(__name__)
loop = asyncio.get_event_loop()
asyncio.ensure_future(console(loop, log))
loop.run_forever() | python | def monitor():
"""Wrapper to call console with a loop."""
log = logging.getLogger(__name__)
loop = asyncio.get_event_loop()
asyncio.ensure_future(console(loop, log))
loop.run_forever() | [
"def",
"monitor",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"asyncio",
".",
"ensure_future",
"(",
"console",
"(",
"loop",
",",
"log",
")",
")",
"loop",
".",
... | Wrapper to call console with a loop. | [
"Wrapper",
"to",
"call",
"console",
"with",
"a",
"loop",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/tools.py#L60-L65 | train |
eclipse/unide.python | src/unide/schema.py | make_object | def make_object(cls, data):
"""Creates an API object of class `cls`, setting its `_data` to
data. Subclasses of `Object` are required to use this to build a
new, empty instance without using their constructor.
"""
if issubclass(cls, Object):
self = object.__new__(cls)
self._data = da... | python | def make_object(cls, data):
"""Creates an API object of class `cls`, setting its `_data` to
data. Subclasses of `Object` are required to use this to build a
new, empty instance without using their constructor.
"""
if issubclass(cls, Object):
self = object.__new__(cls)
self._data = da... | [
"def",
"make_object",
"(",
"cls",
",",
"data",
")",
":",
"if",
"issubclass",
"(",
"cls",
",",
"Object",
")",
":",
"self",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"self",
".",
"_data",
"=",
"data",
"else",
":",
"self",
"=",
"data",
"return",... | Creates an API object of class `cls`, setting its `_data` to
data. Subclasses of `Object` are required to use this to build a
new, empty instance without using their constructor. | [
"Creates",
"an",
"API",
"object",
"of",
"class",
"cls",
"setting",
"its",
"_data",
"to",
"data",
".",
"Subclasses",
"of",
"Object",
"are",
"required",
"to",
"use",
"this",
"to",
"build",
"a",
"new",
"empty",
"instance",
"without",
"using",
"their",
"constr... | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L296-L306 | train |
eclipse/unide.python | src/unide/schema.py | String | def String(length=None, **kwargs):
"""A string valued property with max. `length`."""
return Property(
length=length,
types=stringy_types,
convert=to_string,
**kwargs
) | python | def String(length=None, **kwargs):
"""A string valued property with max. `length`."""
return Property(
length=length,
types=stringy_types,
convert=to_string,
**kwargs
) | [
"def",
"String",
"(",
"length",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Property",
"(",
"length",
"=",
"length",
",",
"types",
"=",
"stringy_types",
",",
"convert",
"=",
"to_string",
",",
"*",
"*",
"kwargs",
")"
] | A string valued property with max. `length`. | [
"A",
"string",
"valued",
"property",
"with",
"max",
".",
"length",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L365-L372 | train |
eclipse/unide.python | src/unide/schema.py | Datetime | def Datetime(null=True, **kwargs):
"""A datetime property."""
return Property(
types=datetime.datetime,
convert=util.local_timezone,
load=dateutil.parser.parse,
null=null,
**kwargs
) | python | def Datetime(null=True, **kwargs):
"""A datetime property."""
return Property(
types=datetime.datetime,
convert=util.local_timezone,
load=dateutil.parser.parse,
null=null,
**kwargs
) | [
"def",
"Datetime",
"(",
"null",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Property",
"(",
"types",
"=",
"datetime",
".",
"datetime",
",",
"convert",
"=",
"util",
".",
"local_timezone",
",",
"load",
"=",
"dateutil",
".",
"parser",
".",
... | A datetime property. | [
"A",
"datetime",
"property",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L395-L403 | train |
eclipse/unide.python | src/unide/schema.py | InstanceOf | def InstanceOf(cls, **kwargs):
"""A property that is an instance of `cls`."""
return Property(types=cls, load=cls.load, **kwargs) | python | def InstanceOf(cls, **kwargs):
"""A property that is an instance of `cls`."""
return Property(types=cls, load=cls.load, **kwargs) | [
"def",
"InstanceOf",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Property",
"(",
"types",
"=",
"cls",
",",
"load",
"=",
"cls",
".",
"load",
",",
"*",
"*",
"kwargs",
")"
] | A property that is an instance of `cls`. | [
"A",
"property",
"that",
"is",
"an",
"instance",
"of",
"cls",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L406-L408 | train |
eclipse/unide.python | src/unide/schema.py | ListOf | def ListOf(cls, **kwargs):
"""A property that is a list of `cls`."""
def _list_load(value):
return [cls.load(d) for d in value]
return Property(types=list, load=_list_load, default=list, **kwargs) | python | def ListOf(cls, **kwargs):
"""A property that is a list of `cls`."""
def _list_load(value):
return [cls.load(d) for d in value]
return Property(types=list, load=_list_load, default=list, **kwargs) | [
"def",
"ListOf",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_list_load",
"(",
"value",
")",
":",
"return",
"[",
"cls",
".",
"load",
"(",
"d",
")",
"for",
"d",
"in",
"value",
"]",
"return",
"Property",
"(",
"types",
"=",
"list",
",",
... | A property that is a list of `cls`. | [
"A",
"property",
"that",
"is",
"a",
"list",
"of",
"cls",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L411-L417 | train |
eclipse/unide.python | src/unide/schema.py | HasDimensions.add_dimension | def add_dimension(self, name, data=None):
"""Add a named dimension to this entity."""
self.dimensions.add(name)
if data is None:
valobj = self.__dimtype__()
else:
valobj = make_object(self.__dimtype__, data)
self._data[name] = valobj
setattr(self, ... | python | def add_dimension(self, name, data=None):
"""Add a named dimension to this entity."""
self.dimensions.add(name)
if data is None:
valobj = self.__dimtype__()
else:
valobj = make_object(self.__dimtype__, data)
self._data[name] = valobj
setattr(self, ... | [
"def",
"add_dimension",
"(",
"self",
",",
"name",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"dimensions",
".",
"add",
"(",
"name",
")",
"if",
"data",
"is",
"None",
":",
"valobj",
"=",
"self",
".",
"__dimtype__",
"(",
")",
"else",
":",
"valob... | Add a named dimension to this entity. | [
"Add",
"a",
"named",
"dimension",
"to",
"this",
"entity",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L323-L332 | train |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile.print_block | def print_block(self, section_key, f=sys.stdout, file_format="mwtab"):
"""Print `mwtab` section into a file or stdout.
:param str section_key: Section name.
:param io.StringIO f: writable file-like stream.
:param str file_format: Format to use: `mwtab` or `json`.
:return: None
... | python | def print_block(self, section_key, f=sys.stdout, file_format="mwtab"):
"""Print `mwtab` section into a file or stdout.
:param str section_key: Section name.
:param io.StringIO f: writable file-like stream.
:param str file_format: Format to use: `mwtab` or `json`.
:return: None
... | [
"def",
"print_block",
"(",
"self",
",",
"section_key",
",",
"f",
"=",
"sys",
".",
"stdout",
",",
"file_format",
"=",
"\"mwtab\"",
")",
":",
"if",
"file_format",
"==",
"\"mwtab\"",
":",
"for",
"key",
",",
"value",
"in",
"self",
"[",
"section_key",
"]",
... | Print `mwtab` section into a file or stdout.
:param str section_key: Section name.
:param io.StringIO f: writable file-like stream.
:param str file_format: Format to use: `mwtab` or `json`.
:return: None
:rtype: :py:obj:`None` | [
"Print",
"mwtab",
"section",
"into",
"a",
"file",
"or",
"stdout",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L233-L293 | train |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile._is_mwtab | def _is_mwtab(string):
"""Test if input string is in `mwtab` format.
:param string: Input string.
:type string: :py:class:`str` or :py:class:`bytes`
:return: Input string if in mwTab format or False otherwise.
:rtype: :py:class:`str` or :py:obj:`False`
"""
if isi... | python | def _is_mwtab(string):
"""Test if input string is in `mwtab` format.
:param string: Input string.
:type string: :py:class:`str` or :py:class:`bytes`
:return: Input string if in mwTab format or False otherwise.
:rtype: :py:class:`str` or :py:obj:`False`
"""
if isi... | [
"def",
"_is_mwtab",
"(",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"str",
")",
":",
"lines",
"=",
"string",
".",
"split",
"(",
"\"\\n\"",
")",
"elif",
"isinstance",
"(",
"string",
",",
"bytes",
")",
":",
"lines",
"=",
"string",
".",... | Test if input string is in `mwtab` format.
:param string: Input string.
:type string: :py:class:`str` or :py:class:`bytes`
:return: Input string if in mwTab format or False otherwise.
:rtype: :py:class:`str` or :py:obj:`False` | [
"Test",
"if",
"input",
"string",
"is",
"in",
"mwtab",
"format",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L314-L334 | train |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceIdsBySpanName | def getTraceIdsBySpanName(self, service_name, span_name, end_ts, limit, order):
"""
Fetch trace ids by service and span name.
Gets "limit" number of entries from before the "end_ts".
Span name is optional.
Timestamps are in microseconds.
Parameters:
- service_name
- span_name
- ... | python | def getTraceIdsBySpanName(self, service_name, span_name, end_ts, limit, order):
"""
Fetch trace ids by service and span name.
Gets "limit" number of entries from before the "end_ts".
Span name is optional.
Timestamps are in microseconds.
Parameters:
- service_name
- span_name
- ... | [
"def",
"getTraceIdsBySpanName",
"(",
"self",
",",
"service_name",
",",
"span_name",
",",
"end_ts",
",",
"limit",
",",
"order",
")",
":",
"self",
".",
"send_getTraceIdsBySpanName",
"(",
"service_name",
",",
"span_name",
",",
"end_ts",
",",
"limit",
",",
"order"... | Fetch trace ids by service and span name.
Gets "limit" number of entries from before the "end_ts".
Span name is optional.
Timestamps are in microseconds.
Parameters:
- service_name
- span_name
- end_ts
- limit
- order | [
"Fetch",
"trace",
"ids",
"by",
"service",
"and",
"span",
"name",
".",
"Gets",
"limit",
"number",
"of",
"entries",
"from",
"before",
"the",
"end_ts",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L286-L302 | train |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceIdsByServiceName | def getTraceIdsByServiceName(self, service_name, end_ts, limit, order):
"""
Fetch trace ids by service name.
Gets "limit" number of entries from before the "end_ts".
Timestamps are in microseconds.
Parameters:
- service_name
- end_ts
- limit
- order
"""
self.send_getTra... | python | def getTraceIdsByServiceName(self, service_name, end_ts, limit, order):
"""
Fetch trace ids by service name.
Gets "limit" number of entries from before the "end_ts".
Timestamps are in microseconds.
Parameters:
- service_name
- end_ts
- limit
- order
"""
self.send_getTra... | [
"def",
"getTraceIdsByServiceName",
"(",
"self",
",",
"service_name",
",",
"end_ts",
",",
"limit",
",",
"order",
")",
":",
"self",
".",
"send_getTraceIdsByServiceName",
"(",
"service_name",
",",
"end_ts",
",",
"limit",
",",
"order",
")",
"return",
"self",
".",
... | Fetch trace ids by service name.
Gets "limit" number of entries from before the "end_ts".
Timestamps are in microseconds.
Parameters:
- service_name
- end_ts
- limit
- order | [
"Fetch",
"trace",
"ids",
"by",
"service",
"name",
".",
"Gets",
"limit",
"number",
"of",
"entries",
"from",
"before",
"the",
"end_ts",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L332-L346 | train |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceIdsByAnnotation | def getTraceIdsByAnnotation(self, service_name, annotation, value, end_ts, limit, order):
"""
Fetch trace ids with a particular annotation.
Gets "limit" number of entries from before the "end_ts".
When requesting based on time based annotations only pass in the first parameter, "annotation" and leave o... | python | def getTraceIdsByAnnotation(self, service_name, annotation, value, end_ts, limit, order):
"""
Fetch trace ids with a particular annotation.
Gets "limit" number of entries from before the "end_ts".
When requesting based on time based annotations only pass in the first parameter, "annotation" and leave o... | [
"def",
"getTraceIdsByAnnotation",
"(",
"self",
",",
"service_name",
",",
"annotation",
",",
"value",
",",
"end_ts",
",",
"limit",
",",
"order",
")",
":",
"self",
".",
"send_getTraceIdsByAnnotation",
"(",
"service_name",
",",
"annotation",
",",
"value",
",",
"e... | Fetch trace ids with a particular annotation.
Gets "limit" number of entries from before the "end_ts".
When requesting based on time based annotations only pass in the first parameter, "annotation" and leave out
the second "value". If looking for a key-value binary annotation provide both, "annotation" is ... | [
"Fetch",
"trace",
"ids",
"with",
"a",
"particular",
"annotation",
".",
"Gets",
"limit",
"number",
"of",
"entries",
"from",
"before",
"the",
"end_ts",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L375-L395 | train |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTracesByIds | def getTracesByIds(self, trace_ids, adjust):
"""
Get the full traces associated with the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Parameters:
- trace_ids
- adjust
"""
self.send_getTracesByIds(trace_ids, a... | python | def getTracesByIds(self, trace_ids, adjust):
"""
Get the full traces associated with the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Parameters:
- trace_ids
- adjust
"""
self.send_getTracesByIds(trace_ids, a... | [
"def",
"getTracesByIds",
"(",
"self",
",",
"trace_ids",
",",
"adjust",
")",
":",
"self",
".",
"send_getTracesByIds",
"(",
"trace_ids",
",",
"adjust",
")",
"return",
"self",
".",
"recv_getTracesByIds",
"(",
")"
] | Get the full traces associated with the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Parameters:
- trace_ids
- adjust | [
"Get",
"the",
"full",
"traces",
"associated",
"with",
"the",
"given",
"trace",
"ids",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L460-L472 | train |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceSummariesByIds | def getTraceSummariesByIds(self, trace_ids, adjust):
"""
Fetch trace summaries for the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Note that if one of the trace ids does not have any data associated with it, it will not be
... | python | def getTraceSummariesByIds(self, trace_ids, adjust):
"""
Fetch trace summaries for the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Note that if one of the trace ids does not have any data associated with it, it will not be
... | [
"def",
"getTraceSummariesByIds",
"(",
"self",
",",
"trace_ids",
",",
"adjust",
")",
":",
"self",
".",
"send_getTraceSummariesByIds",
"(",
"trace_ids",
",",
"adjust",
")",
"return",
"self",
".",
"recv_getTraceSummariesByIds",
"(",
")"
] | Fetch trace summaries for the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Note that if one of the trace ids does not have any data associated with it, it will not be
represented in the output list.
Parameters:
- trace_i... | [
"Fetch",
"trace",
"summaries",
"for",
"the",
"given",
"trace",
"ids",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L543-L558 | train |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceCombosByIds | def getTraceCombosByIds(self, trace_ids, adjust):
"""
Not content with just one of traces, summaries or timelines? Want it all? This is the method for you.
Parameters:
- trace_ids
- adjust
"""
self.send_getTraceCombosByIds(trace_ids, adjust)
return self.recv_getTraceCombosByIds() | python | def getTraceCombosByIds(self, trace_ids, adjust):
"""
Not content with just one of traces, summaries or timelines? Want it all? This is the method for you.
Parameters:
- trace_ids
- adjust
"""
self.send_getTraceCombosByIds(trace_ids, adjust)
return self.recv_getTraceCombosByIds() | [
"def",
"getTraceCombosByIds",
"(",
"self",
",",
"trace_ids",
",",
"adjust",
")",
":",
"self",
".",
"send_getTraceCombosByIds",
"(",
"trace_ids",
",",
"adjust",
")",
"return",
"self",
".",
"recv_getTraceCombosByIds",
"(",
")"
] | Not content with just one of traces, summaries or timelines? Want it all? This is the method for you.
Parameters:
- trace_ids
- adjust | [
"Not",
"content",
"with",
"just",
"one",
"of",
"traces",
"summaries",
"or",
"timelines?",
"Want",
"it",
"all?",
"This",
"is",
"the",
"method",
"for",
"you",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L585-L594 | train |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.setTraceTimeToLive | def setTraceTimeToLive(self, trace_id, ttl_seconds):
"""
Change the TTL of a trace. If we find an interesting trace we want to keep around for further
investigation.
Parameters:
- trace_id
- ttl_seconds
"""
self.send_setTraceTimeToLive(trace_id, ttl_seconds)
self.recv_setTraceTime... | python | def setTraceTimeToLive(self, trace_id, ttl_seconds):
"""
Change the TTL of a trace. If we find an interesting trace we want to keep around for further
investigation.
Parameters:
- trace_id
- ttl_seconds
"""
self.send_setTraceTimeToLive(trace_id, ttl_seconds)
self.recv_setTraceTime... | [
"def",
"setTraceTimeToLive",
"(",
"self",
",",
"trace_id",
",",
"ttl_seconds",
")",
":",
"self",
".",
"send_setTraceTimeToLive",
"(",
"trace_id",
",",
"ttl_seconds",
")",
"self",
".",
"recv_setTraceTimeToLive",
"(",
")"
] | Change the TTL of a trace. If we find an interesting trace we want to keep around for further
investigation.
Parameters:
- trace_id
- ttl_seconds | [
"Change",
"the",
"TTL",
"of",
"a",
"trace",
".",
"If",
"we",
"find",
"an",
"interesting",
"trace",
"we",
"want",
"to",
"keep",
"around",
"for",
"further",
"investigation",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L685-L695 | train |
camptocamp/Studio | studio/lib/datasource_discovery.py | discover_datasource_columns | def discover_datasource_columns(datastore_str, datasource_id):
""" Loop through the datastore's datasources to find
the datasource identified by datasource_id, return
the matching datasource's columns. """
datastore = DataStore(datastore_str)
datasource = datastore.get_datasource(datasource_id)
... | python | def discover_datasource_columns(datastore_str, datasource_id):
""" Loop through the datastore's datasources to find
the datasource identified by datasource_id, return
the matching datasource's columns. """
datastore = DataStore(datastore_str)
datasource = datastore.get_datasource(datasource_id)
... | [
"def",
"discover_datasource_columns",
"(",
"datastore_str",
",",
"datasource_id",
")",
":",
"datastore",
"=",
"DataStore",
"(",
"datastore_str",
")",
"datasource",
"=",
"datastore",
".",
"get_datasource",
"(",
"datasource_id",
")",
"if",
"datasource",
".",
"type",
... | Loop through the datastore's datasources to find
the datasource identified by datasource_id, return
the matching datasource's columns. | [
"Loop",
"through",
"the",
"datastore",
"s",
"datasources",
"to",
"find",
"the",
"datasource",
"identified",
"by",
"datasource_id",
"return",
"the",
"matching",
"datasource",
"s",
"columns",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/datasource_discovery.py#L58-L67 | train |
camptocamp/Studio | studio/lib/datasource_discovery.py | OgrDataSource._get_column_type | def _get_column_type(self,column):
""" Return 'numeric' if the column is of type integer or
real, otherwise return 'string'. """
ctype = column.GetType()
if ctype in [ogr.OFTInteger, ogr.OFTReal]:
return 'numeric'
else:
return 'string' | python | def _get_column_type(self,column):
""" Return 'numeric' if the column is of type integer or
real, otherwise return 'string'. """
ctype = column.GetType()
if ctype in [ogr.OFTInteger, ogr.OFTReal]:
return 'numeric'
else:
return 'string' | [
"def",
"_get_column_type",
"(",
"self",
",",
"column",
")",
":",
"ctype",
"=",
"column",
".",
"GetType",
"(",
")",
"if",
"ctype",
"in",
"[",
"ogr",
".",
"OFTInteger",
",",
"ogr",
".",
"OFTReal",
"]",
":",
"return",
"'numeric'",
"else",
":",
"return",
... | Return 'numeric' if the column is of type integer or
real, otherwise return 'string'. | [
"Return",
"numeric",
"if",
"the",
"column",
"is",
"of",
"type",
"integer",
"or",
"real",
"otherwise",
"return",
"string",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/datasource_discovery.py#L269-L276 | train |
camptocamp/Studio | studio/lib/datasource_discovery.py | OgrDataSource._get_default_mapfile_excerpt | def _get_default_mapfile_excerpt(self):
""" Given an OGR string, an OGR connection and an OGR layer, create and
return a representation of a MapFile LAYER block. """
layerobj = self._get_layer_stub()
classobj = mapscript.classObj()
layerobj.insertClass(classobj)
... | python | def _get_default_mapfile_excerpt(self):
""" Given an OGR string, an OGR connection and an OGR layer, create and
return a representation of a MapFile LAYER block. """
layerobj = self._get_layer_stub()
classobj = mapscript.classObj()
layerobj.insertClass(classobj)
... | [
"def",
"_get_default_mapfile_excerpt",
"(",
"self",
")",
":",
"layerobj",
"=",
"self",
".",
"_get_layer_stub",
"(",
")",
"classobj",
"=",
"mapscript",
".",
"classObj",
"(",
")",
"layerobj",
".",
"insertClass",
"(",
"classobj",
")",
"styleobj",
"=",
"self",
"... | Given an OGR string, an OGR connection and an OGR layer, create and
return a representation of a MapFile LAYER block. | [
"Given",
"an",
"OGR",
"string",
"an",
"OGR",
"connection",
"and",
"an",
"OGR",
"layer",
"create",
"and",
"return",
"a",
"representation",
"of",
"a",
"MapFile",
"LAYER",
"block",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/datasource_discovery.py#L285-L295 | train |
camptocamp/Studio | studio/lib/datasource_discovery.py | OgrDataSource._get_layer_stub | def _get_layer_stub(self):
""" builds a minimal mapscript layerobj, with no styling """
layerobj = mapscript.layerObj()
layerobj.name = self.name
layerobj.status = mapscript.MS_ON
projection = self.ogr_layer.GetSpatialRef()
featureIdColumn = self._get_featureId_column()
... | python | def _get_layer_stub(self):
""" builds a minimal mapscript layerobj, with no styling """
layerobj = mapscript.layerObj()
layerobj.name = self.name
layerobj.status = mapscript.MS_ON
projection = self.ogr_layer.GetSpatialRef()
featureIdColumn = self._get_featureId_column()
... | [
"def",
"_get_layer_stub",
"(",
"self",
")",
":",
"layerobj",
"=",
"mapscript",
".",
"layerObj",
"(",
")",
"layerobj",
".",
"name",
"=",
"self",
".",
"name",
"layerobj",
".",
"status",
"=",
"mapscript",
".",
"MS_ON",
"projection",
"=",
"self",
".",
"ogr_l... | builds a minimal mapscript layerobj, with no styling | [
"builds",
"a",
"minimal",
"mapscript",
"layerobj",
"with",
"no",
"styling"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/datasource_discovery.py#L303-L341 | train |
cocaine/cocaine-tools | cocaine/proxy/mds_direct.py | MDSDirect.reelect_app | def reelect_app(self, request, app):
"""tries to connect to the same app on differnet host from dist-info"""
# disconnect app explicitly to break possibly existing connection
app.disconnect()
endpoints_size = len(app.locator.endpoints)
# try x times, where x is the number of di... | python | def reelect_app(self, request, app):
"""tries to connect to the same app on differnet host from dist-info"""
# disconnect app explicitly to break possibly existing connection
app.disconnect()
endpoints_size = len(app.locator.endpoints)
# try x times, where x is the number of di... | [
"def",
"reelect_app",
"(",
"self",
",",
"request",
",",
"app",
")",
":",
"# disconnect app explicitly to break possibly existing connection",
"app",
".",
"disconnect",
"(",
")",
"endpoints_size",
"=",
"len",
"(",
"app",
".",
"locator",
".",
"endpoints",
")",
"# tr... | tries to connect to the same app on differnet host from dist-info | [
"tries",
"to",
"connect",
"to",
"the",
"same",
"app",
"on",
"differnet",
"host",
"from",
"dist",
"-",
"info"
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/proxy/mds_direct.py#L69-L116 | train |
tropo/tropo-webapi-python | samples/appengine/main.py | RecordHelloWorld | def RecordHelloWorld(handler, t):
"""
Demonstration of recording a message.
"""
url = "%s/receive_recording.py" % THIS_URL
t.startRecording(url)
t.say ("Hello, World.")
t.stopRecording()
json = t.RenderJson()
logging.info ("RecordHelloWorld json: %s" % json)
handler.response.out.... | python | def RecordHelloWorld(handler, t):
"""
Demonstration of recording a message.
"""
url = "%s/receive_recording.py" % THIS_URL
t.startRecording(url)
t.say ("Hello, World.")
t.stopRecording()
json = t.RenderJson()
logging.info ("RecordHelloWorld json: %s" % json)
handler.response.out.... | [
"def",
"RecordHelloWorld",
"(",
"handler",
",",
"t",
")",
":",
"url",
"=",
"\"%s/receive_recording.py\"",
"%",
"THIS_URL",
"t",
".",
"startRecording",
"(",
"url",
")",
"t",
".",
"say",
"(",
"\"Hello, World.\"",
")",
"t",
".",
"stopRecording",
"(",
")",
"js... | Demonstration of recording a message. | [
"Demonstration",
"of",
"recording",
"a",
"message",
"."
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/samples/appengine/main.py#L69-L79 | train |
tropo/tropo-webapi-python | samples/appengine/main.py | RedirectDemo | def RedirectDemo(handler, t):
"""
Demonstration of redirecting to another number.
"""
# t.say ("One moment please.")
t.redirect(SIP_PHONE)
json = t.RenderJson()
logging.info ("RedirectDemo json: %s" % json)
handler.response.out.write(json) | python | def RedirectDemo(handler, t):
"""
Demonstration of redirecting to another number.
"""
# t.say ("One moment please.")
t.redirect(SIP_PHONE)
json = t.RenderJson()
logging.info ("RedirectDemo json: %s" % json)
handler.response.out.write(json) | [
"def",
"RedirectDemo",
"(",
"handler",
",",
"t",
")",
":",
"# t.say (\"One moment please.\")",
"t",
".",
"redirect",
"(",
"SIP_PHONE",
")",
"json",
"=",
"t",
".",
"RenderJson",
"(",
")",
"logging",
".",
"info",
"(",
"\"RedirectDemo json: %s\"",
"%",
"json",
... | Demonstration of redirecting to another number. | [
"Demonstration",
"of",
"redirecting",
"to",
"another",
"number",
"."
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/samples/appengine/main.py#L81-L89 | train |
tropo/tropo-webapi-python | samples/appengine/main.py | TransferDemo | def TransferDemo(handler, t):
"""
Demonstration of transfering to another number
"""
t.say ("One moment please.")
t.transfer(MY_PHONE)
t.say("Hi. I am a robot")
json = t.RenderJson()
logging.info ("TransferDemo json: %s" % json)
handler.response.out.write(json) | python | def TransferDemo(handler, t):
"""
Demonstration of transfering to another number
"""
t.say ("One moment please.")
t.transfer(MY_PHONE)
t.say("Hi. I am a robot")
json = t.RenderJson()
logging.info ("TransferDemo json: %s" % json)
handler.response.out.write(json) | [
"def",
"TransferDemo",
"(",
"handler",
",",
"t",
")",
":",
"t",
".",
"say",
"(",
"\"One moment please.\"",
")",
"t",
".",
"transfer",
"(",
"MY_PHONE",
")",
"t",
".",
"say",
"(",
"\"Hi. I am a robot\"",
")",
"json",
"=",
"t",
".",
"RenderJson",
"(",
")"... | Demonstration of transfering to another number | [
"Demonstration",
"of",
"transfering",
"to",
"another",
"number"
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/samples/appengine/main.py#L91-L100 | train |
uw-it-aca/uw-restclients-core | restclients_core/util/retry.py | retry | def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, status_codes=[],
logger=None):
"""
Decorator function for retrying the decorated function,
using an exponential or fixed backoff.
Original: https://wiki.python.org/moin/PythonDecoratorLibrary#Retry
ExceptionToCheck: the exception t... | python | def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, status_codes=[],
logger=None):
"""
Decorator function for retrying the decorated function,
using an exponential or fixed backoff.
Original: https://wiki.python.org/moin/PythonDecoratorLibrary#Retry
ExceptionToCheck: the exception t... | [
"def",
"retry",
"(",
"ExceptionToCheck",
",",
"tries",
"=",
"4",
",",
"delay",
"=",
"3",
",",
"backoff",
"=",
"2",
",",
"status_codes",
"=",
"[",
"]",
",",
"logger",
"=",
"None",
")",
":",
"if",
"backoff",
"is",
"None",
"or",
"backoff",
"<=",
"0",
... | Decorator function for retrying the decorated function,
using an exponential or fixed backoff.
Original: https://wiki.python.org/moin/PythonDecoratorLibrary#Retry
ExceptionToCheck: the exception to check. Can be a tuple of
exceptions to check
tries: number of times to try (not retry) before gi... | [
"Decorator",
"function",
"for",
"retrying",
"the",
"decorated",
"function",
"using",
"an",
"exponential",
"or",
"fixed",
"backoff",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/util/retry.py#L6-L58 | train |
uw-it-aca/uw-restclients-core | restclients_core/dao.py | DAO._custom_response_edit | def _custom_response_edit(self, method, url, headers, body, response):
"""
This method allows a service to edit a response.
If you want to do this, you probably really want to use
_edit_mock_response - this method will operate on Live resources.
"""
if self.get_implement... | python | def _custom_response_edit(self, method, url, headers, body, response):
"""
This method allows a service to edit a response.
If you want to do this, you probably really want to use
_edit_mock_response - this method will operate on Live resources.
"""
if self.get_implement... | [
"def",
"_custom_response_edit",
"(",
"self",
",",
"method",
",",
"url",
",",
"headers",
",",
"body",
",",
"response",
")",
":",
"if",
"self",
".",
"get_implementation",
"(",
")",
".",
"is_mock",
"(",
")",
":",
"delay",
"=",
"self",
".",
"get_setting",
... | This method allows a service to edit a response.
If you want to do this, you probably really want to use
_edit_mock_response - this method will operate on Live resources. | [
"This",
"method",
"allows",
"a",
"service",
"to",
"edit",
"a",
"response",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/dao.py#L64-L74 | train |
uw-it-aca/uw-restclients-core | restclients_core/dao.py | DAO.postURL | def postURL(self, url, headers={}, body=None):
"""
Request a URL using the HTTP method POST.
"""
return self._load_resource("POST", url, headers, body) | python | def postURL(self, url, headers={}, body=None):
"""
Request a URL using the HTTP method POST.
"""
return self._load_resource("POST", url, headers, body) | [
"def",
"postURL",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"{",
"}",
",",
"body",
"=",
"None",
")",
":",
"return",
"self",
".",
"_load_resource",
"(",
"\"POST\"",
",",
"url",
",",
"headers",
",",
"body",
")"
] | Request a URL using the HTTP method POST. | [
"Request",
"a",
"URL",
"using",
"the",
"HTTP",
"method",
"POST",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/dao.py#L100-L104 | train |
uw-it-aca/uw-restclients-core | restclients_core/dao.py | DAO.putURL | def putURL(self, url, headers, body=None):
"""
Request a URL using the HTTP method PUT.
"""
return self._load_resource("PUT", url, headers, body) | python | def putURL(self, url, headers, body=None):
"""
Request a URL using the HTTP method PUT.
"""
return self._load_resource("PUT", url, headers, body) | [
"def",
"putURL",
"(",
"self",
",",
"url",
",",
"headers",
",",
"body",
"=",
"None",
")",
":",
"return",
"self",
".",
"_load_resource",
"(",
"\"PUT\"",
",",
"url",
",",
"headers",
",",
"body",
")"
] | Request a URL using the HTTP method PUT. | [
"Request",
"a",
"URL",
"using",
"the",
"HTTP",
"method",
"PUT",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/dao.py#L106-L110 | train |
uw-it-aca/uw-restclients-core | restclients_core/dao.py | DAO.patchURL | def patchURL(self, url, headers, body):
"""
Request a URL using the HTTP method PATCH.
"""
return self._load_resource("PATCH", url, headers, body) | python | def patchURL(self, url, headers, body):
"""
Request a URL using the HTTP method PATCH.
"""
return self._load_resource("PATCH", url, headers, body) | [
"def",
"patchURL",
"(",
"self",
",",
"url",
",",
"headers",
",",
"body",
")",
":",
"return",
"self",
".",
"_load_resource",
"(",
"\"PATCH\"",
",",
"url",
",",
"headers",
",",
"body",
")"
] | Request a URL using the HTTP method PATCH. | [
"Request",
"a",
"URL",
"using",
"the",
"HTTP",
"method",
"PATCH",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/dao.py#L112-L116 | train |
mete0r/hypua2jamo | setup.py | setup_dir | def setup_dir(f):
''' Decorate f to run inside the directory where setup.py resides.
'''
setup_dir = os.path.dirname(os.path.abspath(__file__))
def wrapped(*args, **kwargs):
with chdir(setup_dir):
return f(*args, **kwargs)
return wrapped | python | def setup_dir(f):
''' Decorate f to run inside the directory where setup.py resides.
'''
setup_dir = os.path.dirname(os.path.abspath(__file__))
def wrapped(*args, **kwargs):
with chdir(setup_dir):
return f(*args, **kwargs)
return wrapped | [
"def",
"setup_dir",
"(",
"f",
")",
":",
"setup_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"chdir"... | Decorate f to run inside the directory where setup.py resides. | [
"Decorate",
"f",
"to",
"run",
"inside",
"the",
"directory",
"where",
"setup",
".",
"py",
"resides",
"."
] | caceb33a26c27645703d659a82bb1152deef1469 | https://github.com/mete0r/hypua2jamo/blob/caceb33a26c27645703d659a82bb1152deef1469/setup.py#L33-L42 | train |
bitlabstudio/django-feedback-form | feedback_form/templatetags/feedback_tags.py | feedback_form | def feedback_form(context):
"""Template tag to render a feedback form."""
user = None
url = None
if context.get('request'):
url = context['request'].path
if context['request'].user.is_authenticated():
user = context['request'].user
return {
'form': FeedbackForm(ur... | python | def feedback_form(context):
"""Template tag to render a feedback form."""
user = None
url = None
if context.get('request'):
url = context['request'].path
if context['request'].user.is_authenticated():
user = context['request'].user
return {
'form': FeedbackForm(ur... | [
"def",
"feedback_form",
"(",
"context",
")",
":",
"user",
"=",
"None",
"url",
"=",
"None",
"if",
"context",
".",
"get",
"(",
"'request'",
")",
":",
"url",
"=",
"context",
"[",
"'request'",
"]",
".",
"path",
"if",
"context",
"[",
"'request'",
"]",
"."... | Template tag to render a feedback form. | [
"Template",
"tag",
"to",
"render",
"a",
"feedback",
"form",
"."
] | e3b5acbbde37caddab2da65f0fd5d7f3a8c8c597 | https://github.com/bitlabstudio/django-feedback-form/blob/e3b5acbbde37caddab2da65f0fd5d7f3a8c8c597/feedback_form/templatetags/feedback_tags.py#L11-L24 | train |
nickelkr/yfi | yfi/yql.py | Yql.select | def select(self, *itms):
"""Joins the items to be selected and inserts the current table name"""
if not itms:
itms = ['*']
self.terms.append("select %s from %s" % (', '.join(itms), self.table))
return self | python | def select(self, *itms):
"""Joins the items to be selected and inserts the current table name"""
if not itms:
itms = ['*']
self.terms.append("select %s from %s" % (', '.join(itms), self.table))
return self | [
"def",
"select",
"(",
"self",
",",
"*",
"itms",
")",
":",
"if",
"not",
"itms",
":",
"itms",
"=",
"[",
"'*'",
"]",
"self",
".",
"terms",
".",
"append",
"(",
"\"select %s from %s\"",
"%",
"(",
"', '",
".",
"join",
"(",
"itms",
")",
",",
"self",
"."... | Joins the items to be selected and inserts the current table name | [
"Joins",
"the",
"items",
"to",
"be",
"selected",
"and",
"inserts",
"the",
"current",
"table",
"name"
] | 720773ea311abe01be83982f26a61ef744f9f648 | https://github.com/nickelkr/yfi/blob/720773ea311abe01be83982f26a61ef744f9f648/yfi/yql.py#L45-L50 | train |
nickelkr/yfi | yfi/yql.py | Yql._in | def _in(self, *lst):
"""Build out the in clause. Using _in due to shadowing for in"""
self.terms.append('in (%s)' % ', '.join(['"%s"' % x for x in lst]))
return self | python | def _in(self, *lst):
"""Build out the in clause. Using _in due to shadowing for in"""
self.terms.append('in (%s)' % ', '.join(['"%s"' % x for x in lst]))
return self | [
"def",
"_in",
"(",
"self",
",",
"*",
"lst",
")",
":",
"self",
".",
"terms",
".",
"append",
"(",
"'in (%s)'",
"%",
"', '",
".",
"join",
"(",
"[",
"'\"%s\"'",
"%",
"x",
"for",
"x",
"in",
"lst",
"]",
")",
")",
"return",
"self"
] | Build out the in clause. Using _in due to shadowing for in | [
"Build",
"out",
"the",
"in",
"clause",
".",
"Using",
"_in",
"due",
"to",
"shadowing",
"for",
"in"
] | 720773ea311abe01be83982f26a61ef744f9f648 | https://github.com/nickelkr/yfi/blob/720773ea311abe01be83982f26a61ef744f9f648/yfi/yql.py#L57-L60 | train |
nickelkr/yfi | yfi/yql.py | Yql.compile | def compile(self):
"""Take all of the 'parts' components and build the complete query to be passed
to Yahoo YQL"""
cs = ""
for term in self.terms:
if cs:
cs += " "
cs += term
self.compiled_str = urllib.parse.quote(cs)
return self | python | def compile(self):
"""Take all of the 'parts' components and build the complete query to be passed
to Yahoo YQL"""
cs = ""
for term in self.terms:
if cs:
cs += " "
cs += term
self.compiled_str = urllib.parse.quote(cs)
return self | [
"def",
"compile",
"(",
"self",
")",
":",
"cs",
"=",
"\"\"",
"for",
"term",
"in",
"self",
".",
"terms",
":",
"if",
"cs",
":",
"cs",
"+=",
"\" \"",
"cs",
"+=",
"term",
"self",
".",
"compiled_str",
"=",
"urllib",
".",
"parse",
".",
"quote",
"(",
"cs... | Take all of the 'parts' components and build the complete query to be passed
to Yahoo YQL | [
"Take",
"all",
"of",
"the",
"parts",
"components",
"and",
"build",
"the",
"complete",
"query",
"to",
"be",
"passed",
"to",
"Yahoo",
"YQL"
] | 720773ea311abe01be83982f26a61ef744f9f648 | https://github.com/nickelkr/yfi/blob/720773ea311abe01be83982f26a61ef744f9f648/yfi/yql.py#L69-L78 | train |
MoseleyBioinformaticsLab/mwtab | mwtab/fileio.py | read_files | def read_files(*sources, **kwds):
"""Construct a generator that yields file instances.
:param sources: One or more strings representing path to file(s).
"""
filenames = _generate_filenames(sources)
filehandles = _generate_handles(filenames)
for fh, source in filehandles:
try:
... | python | def read_files(*sources, **kwds):
"""Construct a generator that yields file instances.
:param sources: One or more strings representing path to file(s).
"""
filenames = _generate_filenames(sources)
filehandles = _generate_handles(filenames)
for fh, source in filehandles:
try:
... | [
"def",
"read_files",
"(",
"*",
"sources",
",",
"*",
"*",
"kwds",
")",
":",
"filenames",
"=",
"_generate_filenames",
"(",
"sources",
")",
"filehandles",
"=",
"_generate_handles",
"(",
"filenames",
")",
"for",
"fh",
",",
"source",
"in",
"filehandles",
":",
"... | Construct a generator that yields file instances.
:param sources: One or more strings representing path to file(s). | [
"Construct",
"a",
"generator",
"that",
"yields",
"file",
"instances",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/fileio.py#L90-L115 | train |
MoseleyBioinformaticsLab/mwtab | mwtab/fileio.py | GenericFilePath.is_url | def is_url(path):
"""Test if path represents a valid URL.
:param str path: Path to file.
:return: True if path is valid url string, False otherwise.
:rtype: :py:obj:`True` or :py:obj:`False`
"""
try:
parse_result = urlparse(path)
return all((parse... | python | def is_url(path):
"""Test if path represents a valid URL.
:param str path: Path to file.
:return: True if path is valid url string, False otherwise.
:rtype: :py:obj:`True` or :py:obj:`False`
"""
try:
parse_result = urlparse(path)
return all((parse... | [
"def",
"is_url",
"(",
"path",
")",
":",
"try",
":",
"parse_result",
"=",
"urlparse",
"(",
"path",
")",
"return",
"all",
"(",
"(",
"parse_result",
".",
"scheme",
",",
"parse_result",
".",
"netloc",
",",
"parse_result",
".",
"path",
")",
")",
"except",
"... | Test if path represents a valid URL.
:param str path: Path to file.
:return: True if path is valid url string, False otherwise.
:rtype: :py:obj:`True` or :py:obj:`False` | [
"Test",
"if",
"path",
"represents",
"a",
"valid",
"URL",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/fileio.py#L208-L219 | train |
camptocamp/Studio | studio/lib/auth.py | AuthMiddleware | def AuthMiddleware(app):
"""
Add authentication and authorization middleware to the ``app``.
"""
# url_for mustn't be used here because AuthMiddleware is built once at startup,
# url path can be reconstructed only on http requests (based on environ)
basic_redirect_form = BasicRedirectFormPlugin(... | python | def AuthMiddleware(app):
"""
Add authentication and authorization middleware to the ``app``.
"""
# url_for mustn't be used here because AuthMiddleware is built once at startup,
# url path can be reconstructed only on http requests (based on environ)
basic_redirect_form = BasicRedirectFormPlugin(... | [
"def",
"AuthMiddleware",
"(",
"app",
")",
":",
"# url_for mustn't be used here because AuthMiddleware is built once at startup,",
"# url path can be reconstructed only on http requests (based on environ)",
"basic_redirect_form",
"=",
"BasicRedirectFormPlugin",
"(",
"login_form_url",
"=",
... | Add authentication and authorization middleware to the ``app``. | [
"Add",
"authentication",
"and",
"authorization",
"middleware",
"to",
"the",
"app",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/auth.py#L154-L183 | train |
camptocamp/Studio | studio/lib/auth.py | BasicRedirectFormPlugin._get_full_path | def _get_full_path(self, path, environ):
"""
Return the full path to ``path`` by prepending the SCRIPT_NAME.
If ``path`` is a URL, do nothing.
"""
if path.startswith('/'):
path = environ.get('SCRIPT_NAME', '') + path
return path | python | def _get_full_path(self, path, environ):
"""
Return the full path to ``path`` by prepending the SCRIPT_NAME.
If ``path`` is a URL, do nothing.
"""
if path.startswith('/'):
path = environ.get('SCRIPT_NAME', '') + path
return path | [
"def",
"_get_full_path",
"(",
"self",
",",
"path",
",",
"environ",
")",
":",
"if",
"path",
".",
"startswith",
"(",
"'/'",
")",
":",
"path",
"=",
"environ",
".",
"get",
"(",
"'SCRIPT_NAME'",
",",
"''",
")",
"+",
"path",
"return",
"path"
] | Return the full path to ``path`` by prepending the SCRIPT_NAME.
If ``path`` is a URL, do nothing. | [
"Return",
"the",
"full",
"path",
"to",
"path",
"by",
"prepending",
"the",
"SCRIPT_NAME",
".",
"If",
"path",
"is",
"a",
"URL",
"do",
"nothing",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/auth.py#L130-L139 | train |
camptocamp/Studio | studio/lib/auth.py | BasicRedirectFormPlugin._replace_qs | def _replace_qs(self, url, qs):
"""
Replace the query string of ``url`` with ``qs`` and return the new URL.
"""
url_parts = list(urlparse(url))
url_parts[4] = qs
return urlunparse(url_parts) | python | def _replace_qs(self, url, qs):
"""
Replace the query string of ``url`` with ``qs`` and return the new URL.
"""
url_parts = list(urlparse(url))
url_parts[4] = qs
return urlunparse(url_parts) | [
"def",
"_replace_qs",
"(",
"self",
",",
"url",
",",
"qs",
")",
":",
"url_parts",
"=",
"list",
"(",
"urlparse",
"(",
"url",
")",
")",
"url_parts",
"[",
"4",
"]",
"=",
"qs",
"return",
"urlunparse",
"(",
"url_parts",
")"
] | Replace the query string of ``url`` with ``qs`` and return the new URL. | [
"Replace",
"the",
"query",
"string",
"of",
"url",
"with",
"qs",
"and",
"return",
"the",
"new",
"URL",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/auth.py#L141-L148 | train |
pjamesjoyce/lcopt | lcopt/settings.py | LcoptSettings.write | def write(self):
"""write the current settings to the config file"""
with open(storage.config_file, 'w') as cfg:
yaml.dump(self.as_dict(), cfg, default_flow_style=False)
storage.refresh() | python | def write(self):
"""write the current settings to the config file"""
with open(storage.config_file, 'w') as cfg:
yaml.dump(self.as_dict(), cfg, default_flow_style=False)
storage.refresh() | [
"def",
"write",
"(",
"self",
")",
":",
"with",
"open",
"(",
"storage",
".",
"config_file",
",",
"'w'",
")",
"as",
"cfg",
":",
"yaml",
".",
"dump",
"(",
"self",
".",
"as_dict",
"(",
")",
",",
"cfg",
",",
"default_flow_style",
"=",
"False",
")",
"sto... | write the current settings to the config file | [
"write",
"the",
"current",
"settings",
"to",
"the",
"config",
"file"
] | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/settings.py#L98-L103 | train |
camptocamp/Studio | studio/lib/sa_types.py | JsonString.process_bind_param | def process_bind_param(self, value, dialect):
"""convert value from python object to json"""
if value is not None:
value = simplejson.dumps(value)
return value | python | def process_bind_param(self, value, dialect):
"""convert value from python object to json"""
if value is not None:
value = simplejson.dumps(value)
return value | [
"def",
"process_bind_param",
"(",
"self",
",",
"value",
",",
"dialect",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"value",
"=",
"simplejson",
".",
"dumps",
"(",
"value",
")",
"return",
"value"
] | convert value from python object to json | [
"convert",
"value",
"from",
"python",
"object",
"to",
"json"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/sa_types.py#L26-L30 | train |
camptocamp/Studio | studio/lib/sa_types.py | JsonString.process_result_value | def process_result_value(self, value, dialect):
"""convert value from json to a python object"""
if value is not None:
value = simplejson.loads(value)
return value | python | def process_result_value(self, value, dialect):
"""convert value from json to a python object"""
if value is not None:
value = simplejson.loads(value)
return value | [
"def",
"process_result_value",
"(",
"self",
",",
"value",
",",
"dialect",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"value",
"=",
"simplejson",
".",
"loads",
"(",
"value",
")",
"return",
"value"
] | convert value from json to a python object | [
"convert",
"value",
"from",
"json",
"to",
"a",
"python",
"object"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/sa_types.py#L32-L36 | train |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | getBriefModuleInfoFromFile | def getBriefModuleInfoFromFile(fileName):
"""Builds the brief module info from file"""
modInfo = BriefModuleInfo()
_cdmpyparser.getBriefModuleInfoFromFile(modInfo, fileName)
modInfo.flush()
return modInfo | python | def getBriefModuleInfoFromFile(fileName):
"""Builds the brief module info from file"""
modInfo = BriefModuleInfo()
_cdmpyparser.getBriefModuleInfoFromFile(modInfo, fileName)
modInfo.flush()
return modInfo | [
"def",
"getBriefModuleInfoFromFile",
"(",
"fileName",
")",
":",
"modInfo",
"=",
"BriefModuleInfo",
"(",
")",
"_cdmpyparser",
".",
"getBriefModuleInfoFromFile",
"(",
"modInfo",
",",
"fileName",
")",
"modInfo",
".",
"flush",
"(",
")",
"return",
"modInfo"
] | Builds the brief module info from file | [
"Builds",
"the",
"brief",
"module",
"info",
"from",
"file"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L609-L614 | train |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | getBriefModuleInfoFromMemory | def getBriefModuleInfoFromMemory(content):
"""Builds the brief module info from memory"""
modInfo = BriefModuleInfo()
_cdmpyparser.getBriefModuleInfoFromMemory(modInfo, content)
modInfo.flush()
return modInfo | python | def getBriefModuleInfoFromMemory(content):
"""Builds the brief module info from memory"""
modInfo = BriefModuleInfo()
_cdmpyparser.getBriefModuleInfoFromMemory(modInfo, content)
modInfo.flush()
return modInfo | [
"def",
"getBriefModuleInfoFromMemory",
"(",
"content",
")",
":",
"modInfo",
"=",
"BriefModuleInfo",
"(",
")",
"_cdmpyparser",
".",
"getBriefModuleInfoFromMemory",
"(",
"modInfo",
",",
"content",
")",
"modInfo",
".",
"flush",
"(",
")",
"return",
"modInfo"
] | Builds the brief module info from memory | [
"Builds",
"the",
"brief",
"module",
"info",
"from",
"memory"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L617-L622 | train |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | ImportWhat.getDisplayName | def getDisplayName(self):
"""Provides a name for display purpose respecting the alias"""
if self.alias == "":
return self.name
return self.name + " as " + self.alias | python | def getDisplayName(self):
"""Provides a name for display purpose respecting the alias"""
if self.alias == "":
return self.name
return self.name + " as " + self.alias | [
"def",
"getDisplayName",
"(",
"self",
")",
":",
"if",
"self",
".",
"alias",
"==",
"\"\"",
":",
"return",
"self",
".",
"name",
"return",
"self",
".",
"name",
"+",
"\" as \"",
"+",
"self",
".",
"alias"
] | Provides a name for display purpose respecting the alias | [
"Provides",
"a",
"name",
"for",
"display",
"purpose",
"respecting",
"the",
"alias"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L124-L128 | train |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo.flush | def flush(self):
"""Flushes the collected information"""
self.__flushLevel(0)
if self.__lastImport is not None:
self.imports.append(self.__lastImport) | python | def flush(self):
"""Flushes the collected information"""
self.__flushLevel(0)
if self.__lastImport is not None:
self.imports.append(self.__lastImport) | [
"def",
"flush",
"(",
"self",
")",
":",
"self",
".",
"__flushLevel",
"(",
"0",
")",
"if",
"self",
".",
"__lastImport",
"is",
"not",
"None",
":",
"self",
".",
"imports",
".",
"append",
"(",
"self",
".",
"__lastImport",
")"
] | Flushes the collected information | [
"Flushes",
"the",
"collected",
"information"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L456-L460 | train |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo.__flushLevel | def __flushLevel(self, level):
"""Merge the found objects to the required level"""
objectsCount = len(self.objectsStack)
while objectsCount > level:
lastIndex = objectsCount - 1
if lastIndex == 0:
# We have exactly one element in the stack
... | python | def __flushLevel(self, level):
"""Merge the found objects to the required level"""
objectsCount = len(self.objectsStack)
while objectsCount > level:
lastIndex = objectsCount - 1
if lastIndex == 0:
# We have exactly one element in the stack
... | [
"def",
"__flushLevel",
"(",
"self",
",",
"level",
")",
":",
"objectsCount",
"=",
"len",
"(",
"self",
".",
"objectsStack",
")",
"while",
"objectsCount",
">",
"level",
":",
"lastIndex",
"=",
"objectsCount",
"-",
"1",
"if",
"lastIndex",
"==",
"0",
":",
"# W... | Merge the found objects to the required level | [
"Merge",
"the",
"found",
"objects",
"to",
"the",
"required",
"level"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L462-L486 | train |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onEncoding | def _onEncoding(self, encString, line, pos, absPosition):
"""Memorizes module encoding"""
self.encoding = Encoding(encString, line, pos, absPosition) | python | def _onEncoding(self, encString, line, pos, absPosition):
"""Memorizes module encoding"""
self.encoding = Encoding(encString, line, pos, absPosition) | [
"def",
"_onEncoding",
"(",
"self",
",",
"encString",
",",
"line",
",",
"pos",
",",
"absPosition",
")",
":",
"self",
".",
"encoding",
"=",
"Encoding",
"(",
"encString",
",",
"line",
",",
"pos",
",",
"absPosition",
")"
] | Memorizes module encoding | [
"Memorizes",
"module",
"encoding"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L488-L490 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.