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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
projectshift/shift-boiler | boiler/user/models.py | User.password_link_expired | def password_link_expired(self, now=None):
""" Check if password link expired """
if not now: now = datetime.datetime.utcnow()
return self.password_link_expires < now | python | def password_link_expired(self, now=None):
""" Check if password link expired """
if not now: now = datetime.datetime.utcnow()
return self.password_link_expires < now | [
"def",
"password_link_expired",
"(",
"self",
",",
"now",
"=",
"None",
")",
":",
"if",
"not",
"now",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"return",
"self",
".",
"password_link_expires",
"<",
"now"
] | Check if password link expired | [
"Check",
"if",
"password",
"link",
"expired"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/models.py#L346-L349 | train |
projectshift/shift-boiler | boiler/user/models.py | User.add_role | def add_role(self, role):
"""
Add role to user
Role must be valid and saved first, otherwise will
raise an exception.
"""
schema = RoleSchema()
ok = schema.process(role)
if not ok or not role.id:
err = 'Role must be valid and saved before addin... | python | def add_role(self, role):
"""
Add role to user
Role must be valid and saved first, otherwise will
raise an exception.
"""
schema = RoleSchema()
ok = schema.process(role)
if not ok or not role.id:
err = 'Role must be valid and saved before addin... | [
"def",
"add_role",
"(",
"self",
",",
"role",
")",
":",
"schema",
"=",
"RoleSchema",
"(",
")",
"ok",
"=",
"schema",
".",
"process",
"(",
"role",
")",
"if",
"not",
"ok",
"or",
"not",
"role",
".",
"id",
":",
"err",
"=",
"'Role must be valid and saved befo... | Add role to user
Role must be valid and saved first, otherwise will
raise an exception. | [
"Add",
"role",
"to",
"user",
"Role",
"must",
"be",
"valid",
"and",
"saved",
"first",
"otherwise",
"will",
"raise",
"an",
"exception",
"."
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/models.py#L363-L375 | train |
projectshift/shift-boiler | boiler/user/models.py | User.has_role | def has_role(self, role_or_handle):
""" Checks if user has role """
if not isinstance(role_or_handle, str):
return role_or_handle in self.roles
has_role = False
for role in self.roles:
if role.handle == role_or_handle:
has_role = True
... | python | def has_role(self, role_or_handle):
""" Checks if user has role """
if not isinstance(role_or_handle, str):
return role_or_handle in self.roles
has_role = False
for role in self.roles:
if role.handle == role_or_handle:
has_role = True
... | [
"def",
"has_role",
"(",
"self",
",",
"role_or_handle",
")",
":",
"if",
"not",
"isinstance",
"(",
"role_or_handle",
",",
"str",
")",
":",
"return",
"role_or_handle",
"in",
"self",
".",
"roles",
"has_role",
"=",
"False",
"for",
"role",
"in",
"self",
".",
"... | Checks if user has role | [
"Checks",
"if",
"user",
"has",
"role"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/models.py#L382-L393 | train |
ronhanson/python-tbx | fabfile/git.py | push | def push(remote='origin', branch='master'):
"""git push commit"""
print(cyan("Pulling changes from repo ( %s / %s)..." % (remote, branch)))
local("git push %s %s" % (remote, branch)) | python | def push(remote='origin', branch='master'):
"""git push commit"""
print(cyan("Pulling changes from repo ( %s / %s)..." % (remote, branch)))
local("git push %s %s" % (remote, branch)) | [
"def",
"push",
"(",
"remote",
"=",
"'origin'",
",",
"branch",
"=",
"'master'",
")",
":",
"print",
"(",
"cyan",
"(",
"\"Pulling changes from repo ( %s / %s)...\"",
"%",
"(",
"remote",
",",
"branch",
")",
")",
")",
"local",
"(",
"\"git push %s %s\"",
"%",
"(",... | git push commit | [
"git",
"push",
"commit"
] | 87f72ae0cadecafbcd144f1e930181fba77f6b83 | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/fabfile/git.py#L7-L10 | train |
ronhanson/python-tbx | fabfile/git.py | pull | def pull(remote='origin', branch='master'):
"""git pull commit"""
print(cyan("Pulling changes from repo ( %s / %s)..." % (remote, branch)))
local("git pull %s %s" % (remote, branch)) | python | def pull(remote='origin', branch='master'):
"""git pull commit"""
print(cyan("Pulling changes from repo ( %s / %s)..." % (remote, branch)))
local("git pull %s %s" % (remote, branch)) | [
"def",
"pull",
"(",
"remote",
"=",
"'origin'",
",",
"branch",
"=",
"'master'",
")",
":",
"print",
"(",
"cyan",
"(",
"\"Pulling changes from repo ( %s / %s)...\"",
"%",
"(",
"remote",
",",
"branch",
")",
")",
")",
"local",
"(",
"\"git pull %s %s\"",
"%",
"(",... | git pull commit | [
"git",
"pull",
"commit"
] | 87f72ae0cadecafbcd144f1e930181fba77f6b83 | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/fabfile/git.py#L14-L17 | train |
ronhanson/python-tbx | fabfile/git.py | sync | def sync(remote='origin', branch='master'):
"""git pull and push commit"""
pull(branch, remote)
push(branch, remote)
print(cyan("Git Synced!")) | python | def sync(remote='origin', branch='master'):
"""git pull and push commit"""
pull(branch, remote)
push(branch, remote)
print(cyan("Git Synced!")) | [
"def",
"sync",
"(",
"remote",
"=",
"'origin'",
",",
"branch",
"=",
"'master'",
")",
":",
"pull",
"(",
"branch",
",",
"remote",
")",
"push",
"(",
"branch",
",",
"remote",
")",
"print",
"(",
"cyan",
"(",
"\"Git Synced!\"",
")",
")"
] | git pull and push commit | [
"git",
"pull",
"and",
"push",
"commit"
] | 87f72ae0cadecafbcd144f1e930181fba77f6b83 | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/fabfile/git.py#L21-L25 | train |
ZEDGR/pychal | challonge/attachments.py | update | def update(tournament, match, attachment, **params):
"""Update the attributes of a match attachment."""
api.fetch(
"PUT",
"tournaments/%s/matches/%s/attachments/%s" % (tournament, match, attachment),
"match_attachment",
**params) | python | def update(tournament, match, attachment, **params):
"""Update the attributes of a match attachment."""
api.fetch(
"PUT",
"tournaments/%s/matches/%s/attachments/%s" % (tournament, match, attachment),
"match_attachment",
**params) | [
"def",
"update",
"(",
"tournament",
",",
"match",
",",
"attachment",
",",
"**",
"params",
")",
":",
"api",
".",
"fetch",
"(",
"\"PUT\"",
",",
"\"tournaments/%s/matches/%s/attachments/%s\"",
"%",
"(",
"tournament",
",",
"match",
",",
"attachment",
")",
",",
"... | Update the attributes of a match attachment. | [
"Update",
"the",
"attributes",
"of",
"a",
"match",
"attachment",
"."
] | 3600fa9e0557a2a14eb1ad0c0711d28dad3693d7 | https://github.com/ZEDGR/pychal/blob/3600fa9e0557a2a14eb1ad0c0711d28dad3693d7/challonge/attachments.py#L27-L33 | train |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/crud/selecting.py | count_row | def count_row(engine, table):
"""
Return number of rows in a table.
Example::
>>> count_row(engine, table_user)
3
**中文文档**
返回一个表中的行数。
"""
return engine.execute(select([func.count()]).select_from(table)).fetchone()[0] | python | def count_row(engine, table):
"""
Return number of rows in a table.
Example::
>>> count_row(engine, table_user)
3
**中文文档**
返回一个表中的行数。
"""
return engine.execute(select([func.count()]).select_from(table)).fetchone()[0] | [
"def",
"count_row",
"(",
"engine",
",",
"table",
")",
":",
"return",
"engine",
".",
"execute",
"(",
"select",
"(",
"[",
"func",
".",
"count",
"(",
")",
"]",
")",
".",
"select_from",
"(",
"table",
")",
")",
".",
"fetchone",
"(",
")",
"[",
"0",
"]"... | Return number of rows in a table.
Example::
>>> count_row(engine, table_user)
3
**中文文档**
返回一个表中的行数。 | [
"Return",
"number",
"of",
"rows",
"in",
"a",
"table",
"."
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/crud/selecting.py#L10-L23 | train |
projectshift/shift-boiler | boiler/user/util/oauth_providers.py | OauthProviders.get_providers | def get_providers(self):
"""
Get OAuth providers
Returns a dictionary of oauth applications ready to be registered with
flask oauth extension at application bootstrap.
"""
if self.providers:
return self.providers
providers = dict()
for provide... | python | def get_providers(self):
"""
Get OAuth providers
Returns a dictionary of oauth applications ready to be registered with
flask oauth extension at application bootstrap.
"""
if self.providers:
return self.providers
providers = dict()
for provide... | [
"def",
"get_providers",
"(",
"self",
")",
":",
"if",
"self",
".",
"providers",
":",
"return",
"self",
".",
"providers",
"providers",
"=",
"dict",
"(",
")",
"for",
"provider",
"in",
"self",
".",
"config",
":",
"configurator",
"=",
"provider",
".",
"lower"... | Get OAuth providers
Returns a dictionary of oauth applications ready to be registered with
flask oauth extension at application bootstrap. | [
"Get",
"OAuth",
"providers",
"Returns",
"a",
"dictionary",
"of",
"oauth",
"applications",
"ready",
"to",
"be",
"registered",
"with",
"flask",
"oauth",
"extension",
"at",
"application",
"bootstrap",
"."
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/util/oauth_providers.py#L21-L47 | train |
projectshift/shift-boiler | boiler/user/util/oauth_providers.py | OauthProviders.token_getter | def token_getter(provider, token=None):
""" Generic token getter for all the providers """
session_key = provider + '_token'
if token is None:
token = session.get(session_key)
return token | python | def token_getter(provider, token=None):
""" Generic token getter for all the providers """
session_key = provider + '_token'
if token is None:
token = session.get(session_key)
return token | [
"def",
"token_getter",
"(",
"provider",
",",
"token",
"=",
"None",
")",
":",
"session_key",
"=",
"provider",
"+",
"'_token'",
"if",
"token",
"is",
"None",
":",
"token",
"=",
"session",
".",
"get",
"(",
"session_key",
")",
"return",
"token"
] | Generic token getter for all the providers | [
"Generic",
"token",
"getter",
"for",
"all",
"the",
"providers"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/util/oauth_providers.py#L50-L55 | train |
projectshift/shift-boiler | boiler/user/util/oauth_providers.py | OauthProviders.register_token_getter | def register_token_getter(self, provider):
""" Register callback to retrieve token from session """
app = oauth.remote_apps[provider]
decorator = getattr(app, 'tokengetter')
def getter(token=None):
return self.token_getter(provider, token)
decorator(getter) | python | def register_token_getter(self, provider):
""" Register callback to retrieve token from session """
app = oauth.remote_apps[provider]
decorator = getattr(app, 'tokengetter')
def getter(token=None):
return self.token_getter(provider, token)
decorator(getter) | [
"def",
"register_token_getter",
"(",
"self",
",",
"provider",
")",
":",
"app",
"=",
"oauth",
".",
"remote_apps",
"[",
"provider",
"]",
"decorator",
"=",
"getattr",
"(",
"app",
",",
"'tokengetter'",
")",
"def",
"getter",
"(",
"token",
"=",
"None",
")",
":... | Register callback to retrieve token from session | [
"Register",
"callback",
"to",
"retrieve",
"token",
"from",
"session"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/util/oauth_providers.py#L57-L65 | train |
projectshift/shift-boiler | boiler/user/util/oauth_providers.py | OauthProviders.vkontakte_config | def vkontakte_config(self, id, secret, scope=None, offline=False, **_):
""" Get config dictionary for vkontakte oauth """
if scope is None: scope = 'email,offline'
if offline: scope += ',offline'
token_params = dict(scope=scope)
config = dict(
request_token_url=None,... | python | def vkontakte_config(self, id, secret, scope=None, offline=False, **_):
""" Get config dictionary for vkontakte oauth """
if scope is None: scope = 'email,offline'
if offline: scope += ',offline'
token_params = dict(scope=scope)
config = dict(
request_token_url=None,... | [
"def",
"vkontakte_config",
"(",
"self",
",",
"id",
",",
"secret",
",",
"scope",
"=",
"None",
",",
"offline",
"=",
"False",
",",
"**",
"_",
")",
":",
"if",
"scope",
"is",
"None",
":",
"scope",
"=",
"'email,offline'",
"if",
"offline",
":",
"scope",
"+=... | Get config dictionary for vkontakte oauth | [
"Get",
"config",
"dictionary",
"for",
"vkontakte",
"oauth"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/util/oauth_providers.py#L87-L102 | train |
projectshift/shift-boiler | boiler/user/util/oauth_providers.py | OauthProviders.instagram_config | def instagram_config(self, id, secret, scope=None, **_):
""" Get config dictionary for instagram oauth """
scope = scope if scope else 'basic'
token_params = dict(scope=scope)
config = dict(
# request_token_url=None,
access_token_url='/oauth/access_token/',
... | python | def instagram_config(self, id, secret, scope=None, **_):
""" Get config dictionary for instagram oauth """
scope = scope if scope else 'basic'
token_params = dict(scope=scope)
config = dict(
# request_token_url=None,
access_token_url='/oauth/access_token/',
... | [
"def",
"instagram_config",
"(",
"self",
",",
"id",
",",
"secret",
",",
"scope",
"=",
"None",
",",
"**",
"_",
")",
":",
"scope",
"=",
"scope",
"if",
"scope",
"else",
"'basic'",
"token_params",
"=",
"dict",
"(",
"scope",
"=",
"scope",
")",
"config",
"=... | Get config dictionary for instagram oauth | [
"Get",
"config",
"dictionary",
"for",
"instagram",
"oauth"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/util/oauth_providers.py#L123-L137 | train |
Kortemme-Lab/klab | klab/bio/relatrix.py | ResidueRelatrix.convert | def convert(self, chain_id, residue_id, from_scheme, to_scheme):
'''The API conversion function. This converts between the different residue ID schemes.'''
# At the cost of three function calls, we ignore the case of the scheme parameters to be more user-friendly.
from_scheme = from_scheme.lowe... | python | def convert(self, chain_id, residue_id, from_scheme, to_scheme):
'''The API conversion function. This converts between the different residue ID schemes.'''
# At the cost of three function calls, we ignore the case of the scheme parameters to be more user-friendly.
from_scheme = from_scheme.lowe... | [
"def",
"convert",
"(",
"self",
",",
"chain_id",
",",
"residue_id",
",",
"from_scheme",
",",
"to_scheme",
")",
":",
"from_scheme",
"=",
"from_scheme",
".",
"lower",
"(",
")",
"to_scheme",
"=",
"to_scheme",
".",
"lower",
"(",
")",
"assert",
"(",
"from_scheme... | The API conversion function. This converts between the different residue ID schemes. | [
"The",
"API",
"conversion",
"function",
".",
"This",
"converts",
"between",
"the",
"different",
"residue",
"ID",
"schemes",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/relatrix.py#L143-L151 | train |
Kortemme-Lab/klab | klab/bio/relatrix.py | ResidueRelatrix._convert | def _convert(self, chain_id, residue_id, from_scheme, to_scheme):
'''The actual 'private' conversion function.'''
# There are 12 valid combinations but rather than write them all out explicitly, we will use recursion, sacrificing speed for brevity
if from_scheme == 'rosetta':
atom_i... | python | def _convert(self, chain_id, residue_id, from_scheme, to_scheme):
'''The actual 'private' conversion function.'''
# There are 12 valid combinations but rather than write them all out explicitly, we will use recursion, sacrificing speed for brevity
if from_scheme == 'rosetta':
atom_i... | [
"def",
"_convert",
"(",
"self",
",",
"chain_id",
",",
"residue_id",
",",
"from_scheme",
",",
"to_scheme",
")",
":",
"if",
"from_scheme",
"==",
"'rosetta'",
":",
"atom_id",
"=",
"self",
".",
"rosetta_to_atom_sequence_maps",
".",
"get",
"(",
"chain_id",
",",
"... | The actual 'private' conversion function. | [
"The",
"actual",
"private",
"conversion",
"function",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/relatrix.py#L153-L186 | train |
Kortemme-Lab/klab | klab/bio/relatrix.py | ResidueRelatrix.convert_from_rosetta | def convert_from_rosetta(self, residue_id, to_scheme):
'''A simpler conversion function to convert from Rosetta numbering without requiring the chain identifier.'''
assert(type(residue_id) == types.IntType)
# Find the chain_id associated with the residue_id
# Scan *all* sequences witho... | python | def convert_from_rosetta(self, residue_id, to_scheme):
'''A simpler conversion function to convert from Rosetta numbering without requiring the chain identifier.'''
assert(type(residue_id) == types.IntType)
# Find the chain_id associated with the residue_id
# Scan *all* sequences witho... | [
"def",
"convert_from_rosetta",
"(",
"self",
",",
"residue_id",
",",
"to_scheme",
")",
":",
"assert",
"(",
"type",
"(",
"residue_id",
")",
"==",
"types",
".",
"IntType",
")",
"chain_id",
"=",
"None",
"for",
"c",
",",
"sequence",
"in",
"self",
".",
"rosett... | A simpler conversion function to convert from Rosetta numbering without requiring the chain identifier. | [
"A",
"simpler",
"conversion",
"function",
"to",
"convert",
"from",
"Rosetta",
"numbering",
"without",
"requiring",
"the",
"chain",
"identifier",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/relatrix.py#L189-L206 | train |
Kortemme-Lab/klab | klab/bio/relatrix.py | ResidueRelatrix._validate | def _validate(self):
'''Validate the mappings.'''
self._validate_fasta_vs_seqres()
self._validate_mapping_signature()
self._validate_id_types()
self._validate_residue_types() | python | def _validate(self):
'''Validate the mappings.'''
self._validate_fasta_vs_seqres()
self._validate_mapping_signature()
self._validate_id_types()
self._validate_residue_types() | [
"def",
"_validate",
"(",
"self",
")",
":",
"self",
".",
"_validate_fasta_vs_seqres",
"(",
")",
"self",
".",
"_validate_mapping_signature",
"(",
")",
"self",
".",
"_validate_id_types",
"(",
")",
"self",
".",
"_validate_residue_types",
"(",
")"
] | Validate the mappings. | [
"Validate",
"the",
"mappings",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/relatrix.py#L210-L216 | train |
Kortemme-Lab/klab | klab/bio/relatrix.py | ResidueRelatrix._validate_id_types | def _validate_id_types(self):
'''Check that the ID types are integers for Rosetta, SEQRES, and UniParc sequences and 6-character PDB IDs for the ATOM sequences.'''
for sequences in [self.uniparc_sequences, self.fasta_sequences, self.seqres_sequences, self.rosetta_sequences]:
for chain_id, s... | python | def _validate_id_types(self):
'''Check that the ID types are integers for Rosetta, SEQRES, and UniParc sequences and 6-character PDB IDs for the ATOM sequences.'''
for sequences in [self.uniparc_sequences, self.fasta_sequences, self.seqres_sequences, self.rosetta_sequences]:
for chain_id, s... | [
"def",
"_validate_id_types",
"(",
"self",
")",
":",
"for",
"sequences",
"in",
"[",
"self",
".",
"uniparc_sequences",
",",
"self",
".",
"fasta_sequences",
",",
"self",
".",
"seqres_sequences",
",",
"self",
".",
"rosetta_sequences",
"]",
":",
"for",
"chain_id",
... | Check that the ID types are integers for Rosetta, SEQRES, and UniParc sequences and 6-character PDB IDs for the ATOM sequences. | [
"Check",
"that",
"the",
"ID",
"types",
"are",
"integers",
"for",
"Rosetta",
"SEQRES",
"and",
"UniParc",
"sequences",
"and",
"6",
"-",
"character",
"PDB",
"IDs",
"for",
"the",
"ATOM",
"sequences",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/relatrix.py#L303-L317 | train |
Kortemme-Lab/klab | klab/bio/relatrix.py | ResidueRelatrix._validate_residue_types | def _validate_residue_types(self):
'''Make sure all the residue types map through translation.'''
for chain_id, sequence_map in self.rosetta_to_atom_sequence_maps.iteritems():
rosetta_sequence = self.rosetta_sequences[chain_id]
atom_sequence = self.atom_sequences[chain_id]
... | python | def _validate_residue_types(self):
'''Make sure all the residue types map through translation.'''
for chain_id, sequence_map in self.rosetta_to_atom_sequence_maps.iteritems():
rosetta_sequence = self.rosetta_sequences[chain_id]
atom_sequence = self.atom_sequences[chain_id]
... | [
"def",
"_validate_residue_types",
"(",
"self",
")",
":",
"for",
"chain_id",
",",
"sequence_map",
"in",
"self",
".",
"rosetta_to_atom_sequence_maps",
".",
"iteritems",
"(",
")",
":",
"rosetta_sequence",
"=",
"self",
".",
"rosetta_sequences",
"[",
"chain_id",
"]",
... | Make sure all the residue types map through translation. | [
"Make",
"sure",
"all",
"the",
"residue",
"types",
"map",
"through",
"translation",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/relatrix.py#L320-L343 | train |
Kortemme-Lab/klab | klab/bio/relatrix.py | ResidueRelatrix._create_sequences | def _create_sequences(self):
'''Get all of the Sequences - Rosetta, ATOM, SEQRES, FASTA, UniParc.'''
# Create the Rosetta sequences and the maps from the Rosetta sequences to the ATOM sequences
try:
self.pdb.construct_pdb_to_rosetta_residue_map(self.rosetta_scripts_path, rosetta_dat... | python | def _create_sequences(self):
'''Get all of the Sequences - Rosetta, ATOM, SEQRES, FASTA, UniParc.'''
# Create the Rosetta sequences and the maps from the Rosetta sequences to the ATOM sequences
try:
self.pdb.construct_pdb_to_rosetta_residue_map(self.rosetta_scripts_path, rosetta_dat... | [
"def",
"_create_sequences",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"pdb",
".",
"construct_pdb_to_rosetta_residue_map",
"(",
"self",
".",
"rosetta_scripts_path",
",",
"rosetta_database_path",
"=",
"self",
".",
"rosetta_database_path",
",",
"cache_dir",
"=",
... | Get all of the Sequences - Rosetta, ATOM, SEQRES, FASTA, UniParc. | [
"Get",
"all",
"of",
"the",
"Sequences",
"-",
"Rosetta",
"ATOM",
"SEQRES",
"FASTA",
"UniParc",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/relatrix.py#L505-L558 | train |
kkinder/NdbSearchableBase | NdbSearchableBase/SearchableModel.py | SearchableModel.search | def search(cls,
query_string,
options=None,
enable_facet_discovery=False,
return_facets=None,
facet_options=None,
facet_refinements=None,
deadline=None,
**kwargs):
"""
Searches the ind... | python | def search(cls,
query_string,
options=None,
enable_facet_discovery=False,
return_facets=None,
facet_options=None,
facet_refinements=None,
deadline=None,
**kwargs):
"""
Searches the ind... | [
"def",
"search",
"(",
"cls",
",",
"query_string",
",",
"options",
"=",
"None",
",",
"enable_facet_discovery",
"=",
"False",
",",
"return_facets",
"=",
"None",
",",
"facet_options",
"=",
"None",
",",
"facet_refinements",
"=",
"None",
",",
"deadline",
"=",
"No... | Searches the index. Conveniently searches only for documents that belong to instances of this class.
:param query_string: The query to match against documents in the index. See search.Query() for details.
:param options: A QueryOptions describing post-processing of search results.
:param enable... | [
"Searches",
"the",
"index",
".",
"Conveniently",
"searches",
"only",
"for",
"documents",
"that",
"belong",
"to",
"instances",
"of",
"this",
"class",
"."
] | 4f999336b464704a0929cec135c1f09fb1ddfb7c | https://github.com/kkinder/NdbSearchableBase/blob/4f999336b464704a0929cec135c1f09fb1ddfb7c/NdbSearchableBase/SearchableModel.py#L49-L94 | train |
kkinder/NdbSearchableBase | NdbSearchableBase/SearchableModel.py | SearchableModel.search_update_index | def search_update_index(self):
"""
Updates the search index for this instance.
This happens automatically on put.
"""
doc_id = self.search_get_document_id(self.key)
fields = [search.AtomField('class_name', name) for name in self.search_get_class_names()]
index ... | python | def search_update_index(self):
"""
Updates the search index for this instance.
This happens automatically on put.
"""
doc_id = self.search_get_document_id(self.key)
fields = [search.AtomField('class_name', name) for name in self.search_get_class_names()]
index ... | [
"def",
"search_update_index",
"(",
"self",
")",
":",
"doc_id",
"=",
"self",
".",
"search_get_document_id",
"(",
"self",
".",
"key",
")",
"fields",
"=",
"[",
"search",
".",
"AtomField",
"(",
"'class_name'",
",",
"name",
")",
"for",
"name",
"in",
"self",
"... | Updates the search index for this instance.
This happens automatically on put. | [
"Updates",
"the",
"search",
"index",
"for",
"this",
"instance",
"."
] | 4f999336b464704a0929cec135c1f09fb1ddfb7c | https://github.com/kkinder/NdbSearchableBase/blob/4f999336b464704a0929cec135c1f09fb1ddfb7c/NdbSearchableBase/SearchableModel.py#L96-L143 | train |
kkinder/NdbSearchableBase | NdbSearchableBase/SearchableModel.py | SearchableModel.search_get_class_names | def search_get_class_names(cls):
"""
Returns class names for use in document indexing.
"""
if hasattr(cls, '_class_key'):
class_names = []
for n in cls._class_key():
class_names.append(n)
return class_names
else:
ret... | python | def search_get_class_names(cls):
"""
Returns class names for use in document indexing.
"""
if hasattr(cls, '_class_key'):
class_names = []
for n in cls._class_key():
class_names.append(n)
return class_names
else:
ret... | [
"def",
"search_get_class_names",
"(",
"cls",
")",
":",
"if",
"hasattr",
"(",
"cls",
",",
"'_class_key'",
")",
":",
"class_names",
"=",
"[",
"]",
"for",
"n",
"in",
"cls",
".",
"_class_key",
"(",
")",
":",
"class_names",
".",
"append",
"(",
"n",
")",
"... | Returns class names for use in document indexing. | [
"Returns",
"class",
"names",
"for",
"use",
"in",
"document",
"indexing",
"."
] | 4f999336b464704a0929cec135c1f09fb1ddfb7c | https://github.com/kkinder/NdbSearchableBase/blob/4f999336b464704a0929cec135c1f09fb1ddfb7c/NdbSearchableBase/SearchableModel.py#L146-L156 | train |
kkinder/NdbSearchableBase | NdbSearchableBase/SearchableModel.py | SearchableModel.from_urlsafe | def from_urlsafe(cls, urlsafe):
"""
Returns an instance of the model from a urlsafe string.
:param urlsafe: urlsafe key
:return: Instance of cls
"""
try:
key = ndb.Key(urlsafe=urlsafe)
except:
return None
obj = key.get()
if... | python | def from_urlsafe(cls, urlsafe):
"""
Returns an instance of the model from a urlsafe string.
:param urlsafe: urlsafe key
:return: Instance of cls
"""
try:
key = ndb.Key(urlsafe=urlsafe)
except:
return None
obj = key.get()
if... | [
"def",
"from_urlsafe",
"(",
"cls",
",",
"urlsafe",
")",
":",
"try",
":",
"key",
"=",
"ndb",
".",
"Key",
"(",
"urlsafe",
"=",
"urlsafe",
")",
"except",
":",
"return",
"None",
"obj",
"=",
"key",
".",
"get",
"(",
")",
"if",
"obj",
"and",
"isinstance",... | Returns an instance of the model from a urlsafe string.
:param urlsafe: urlsafe key
:return: Instance of cls | [
"Returns",
"an",
"instance",
"of",
"the",
"model",
"from",
"a",
"urlsafe",
"string",
"."
] | 4f999336b464704a0929cec135c1f09fb1ddfb7c | https://github.com/kkinder/NdbSearchableBase/blob/4f999336b464704a0929cec135c1f09fb1ddfb7c/NdbSearchableBase/SearchableModel.py#L159-L172 | train |
kkinder/NdbSearchableBase | NdbSearchableBase/SearchableModel.py | SearchableModel.get_from_search_doc | def get_from_search_doc(cls, doc_id):
"""
Returns an instance of the model from a search document id.
:param doc_id: Search document id
:return: Instance of cls
"""
# If the document was passed instead of the doc_id, get the document.
if hasattr(doc_id, 'doc_id')... | python | def get_from_search_doc(cls, doc_id):
"""
Returns an instance of the model from a search document id.
:param doc_id: Search document id
:return: Instance of cls
"""
# If the document was passed instead of the doc_id, get the document.
if hasattr(doc_id, 'doc_id')... | [
"def",
"get_from_search_doc",
"(",
"cls",
",",
"doc_id",
")",
":",
"if",
"hasattr",
"(",
"doc_id",
",",
"'doc_id'",
")",
":",
"doc_id",
"=",
"doc_id",
".",
"doc_id",
"return",
"cls",
".",
"from_urlsafe",
"(",
"doc_id",
")"
] | Returns an instance of the model from a search document id.
:param doc_id: Search document id
:return: Instance of cls | [
"Returns",
"an",
"instance",
"of",
"the",
"model",
"from",
"a",
"search",
"document",
"id",
"."
] | 4f999336b464704a0929cec135c1f09fb1ddfb7c | https://github.com/kkinder/NdbSearchableBase/blob/4f999336b464704a0929cec135c1f09fb1ddfb7c/NdbSearchableBase/SearchableModel.py#L175-L185 | train |
kkinder/NdbSearchableBase | NdbSearchableBase/SearchableModel.py | SearchableModel._pre_delete_hook | def _pre_delete_hook(cls, key):
"""
Removes instance from index.
"""
if cls.searching_enabled:
doc_id = cls.search_get_document_id(key)
index = cls.search_get_index()
index.delete(doc_id) | python | def _pre_delete_hook(cls, key):
"""
Removes instance from index.
"""
if cls.searching_enabled:
doc_id = cls.search_get_document_id(key)
index = cls.search_get_index()
index.delete(doc_id) | [
"def",
"_pre_delete_hook",
"(",
"cls",
",",
"key",
")",
":",
"if",
"cls",
".",
"searching_enabled",
":",
"doc_id",
"=",
"cls",
".",
"search_get_document_id",
"(",
"key",
")",
"index",
"=",
"cls",
".",
"search_get_index",
"(",
")",
"index",
".",
"delete",
... | Removes instance from index. | [
"Removes",
"instance",
"from",
"index",
"."
] | 4f999336b464704a0929cec135c1f09fb1ddfb7c | https://github.com/kkinder/NdbSearchableBase/blob/4f999336b464704a0929cec135c1f09fb1ddfb7c/NdbSearchableBase/SearchableModel.py#L188-L195 | train |
adaptive-learning/proso-apps | proso/models/environment.py | Environment.process_answer | def process_answer(self, user, item, asked, answered, time, answer, response_time, guess, **kwargs):
"""
This method is used during the answer streaming and is called after the
predictive model for each answer.
Args:
user (int):
identifier of ther user answer... | python | def process_answer(self, user, item, asked, answered, time, answer, response_time, guess, **kwargs):
"""
This method is used during the answer streaming and is called after the
predictive model for each answer.
Args:
user (int):
identifier of ther user answer... | [
"def",
"process_answer",
"(",
"self",
",",
"user",
",",
"item",
",",
"asked",
",",
"answered",
",",
"time",
",",
"answer",
",",
"response_time",
",",
"guess",
",",
"**",
"kwargs",
")",
":",
"pass"
] | This method is used during the answer streaming and is called after the
predictive model for each answer.
Args:
user (int):
identifier of ther user answering the question
asked (int):
identifier of the asked item
answered (int):
... | [
"This",
"method",
"is",
"used",
"during",
"the",
"answer",
"streaming",
"and",
"is",
"called",
"after",
"the",
"predictive",
"model",
"for",
"each",
"answer",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso/models/environment.py#L18-L38 | train |
Apstra/aeon-venos | pylib/aeon/nxos/autoload/guestshell.py | _guestshell._get_sz_info | def _get_sz_info(self):
"""
Obtains the current resource allocations, assumes that the
guestshell is in an 'Activated' state
"""
if 'None' == self._state:
return None
cmd = 'show virtual-service detail name guestshell+'
got = self.cli(cmd)
got... | python | def _get_sz_info(self):
"""
Obtains the current resource allocations, assumes that the
guestshell is in an 'Activated' state
"""
if 'None' == self._state:
return None
cmd = 'show virtual-service detail name guestshell+'
got = self.cli(cmd)
got... | [
"def",
"_get_sz_info",
"(",
"self",
")",
":",
"if",
"'None'",
"==",
"self",
".",
"_state",
":",
"return",
"None",
"cmd",
"=",
"'show virtual-service detail name guestshell+'",
"got",
"=",
"self",
".",
"cli",
"(",
"cmd",
")",
"got",
"=",
"got",
"[",
"'TABLE... | Obtains the current resource allocations, assumes that the
guestshell is in an 'Activated' state | [
"Obtains",
"the",
"current",
"resource",
"allocations",
"assumes",
"that",
"the",
"guestshell",
"is",
"in",
"an",
"Activated",
"state"
] | 4d4f73d5904831ddc78c30922a8a226c90cf7d90 | https://github.com/Apstra/aeon-venos/blob/4d4f73d5904831ddc78c30922a8a226c90cf7d90/pylib/aeon/nxos/autoload/guestshell.py#L198-L215 | train |
assamite/creamas | creamas/image.py | fractal_dimension | def fractal_dimension(image):
'''Estimates the fractal dimension of an image with box counting.
Counts pixels with value 0 as empty and everything else as non-empty.
Input image has to be grayscale.
See, e.g `Wikipedia <https://en.wikipedia.org/wiki/Fractal_dimension>`_.
:param image: numpy.ndarra... | python | def fractal_dimension(image):
'''Estimates the fractal dimension of an image with box counting.
Counts pixels with value 0 as empty and everything else as non-empty.
Input image has to be grayscale.
See, e.g `Wikipedia <https://en.wikipedia.org/wiki/Fractal_dimension>`_.
:param image: numpy.ndarra... | [
"def",
"fractal_dimension",
"(",
"image",
")",
":",
"pixels",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"image",
".",
"shape",
"[",
"0",
"]",
")",
":",
"for",
"j",
"in",
"range",
"(",
"image",
".",
"shape",
"[",
"1",
"]",
")",
":",
"if",
... | Estimates the fractal dimension of an image with box counting.
Counts pixels with value 0 as empty and everything else as non-empty.
Input image has to be grayscale.
See, e.g `Wikipedia <https://en.wikipedia.org/wiki/Fractal_dimension>`_.
:param image: numpy.ndarray
:returns: estimation of fractal... | [
"Estimates",
"the",
"fractal",
"dimension",
"of",
"an",
"image",
"with",
"box",
"counting",
".",
"Counts",
"pixels",
"with",
"value",
"0",
"as",
"empty",
"and",
"everything",
"else",
"as",
"non",
"-",
"empty",
".",
"Input",
"image",
"has",
"to",
"be",
"g... | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/image.py#L11-L46 | train |
assamite/creamas | creamas/image.py | channel_portion | def channel_portion(image, channel):
'''Estimates the amount of a color relative to other colors.
:param image: numpy.ndarray
:param channel: int
:returns: portion of a channel in an image
:rtype: float
'''
# Separate color channels
rgb = []
for i in range(3):
rgb.append(im... | python | def channel_portion(image, channel):
'''Estimates the amount of a color relative to other colors.
:param image: numpy.ndarray
:param channel: int
:returns: portion of a channel in an image
:rtype: float
'''
# Separate color channels
rgb = []
for i in range(3):
rgb.append(im... | [
"def",
"channel_portion",
"(",
"image",
",",
"channel",
")",
":",
"rgb",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"3",
")",
":",
"rgb",
".",
"append",
"(",
"image",
"[",
":",
",",
":",
",",
"i",
"]",
".",
"astype",
"(",
"int",
")",
")",... | Estimates the amount of a color relative to other colors.
:param image: numpy.ndarray
:param channel: int
:returns: portion of a channel in an image
:rtype: float | [
"Estimates",
"the",
"amount",
"of",
"a",
"color",
"relative",
"to",
"other",
"colors",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/image.py#L49-L67 | train |
assamite/creamas | creamas/image.py | intensity | def intensity(image):
'''Calculates the average intensity of the pixels in an image.
Accepts both RGB and grayscale images.
:param image: numpy.ndarray
:returns: image intensity
:rtype: float
'''
if len(image.shape) > 2:
# Convert to grayscale
image = cv2.cvtColor(image, cv2... | python | def intensity(image):
'''Calculates the average intensity of the pixels in an image.
Accepts both RGB and grayscale images.
:param image: numpy.ndarray
:returns: image intensity
:rtype: float
'''
if len(image.shape) > 2:
# Convert to grayscale
image = cv2.cvtColor(image, cv2... | [
"def",
"intensity",
"(",
"image",
")",
":",
"if",
"len",
"(",
"image",
".",
"shape",
")",
">",
"2",
":",
"image",
"=",
"cv2",
".",
"cvtColor",
"(",
"image",
",",
"cv2",
".",
"COLOR_RGB2GRAY",
")",
"/",
"255",
"elif",
"issubclass",
"(",
"image",
"."... | Calculates the average intensity of the pixels in an image.
Accepts both RGB and grayscale images.
:param image: numpy.ndarray
:returns: image intensity
:rtype: float | [
"Calculates",
"the",
"average",
"intensity",
"of",
"the",
"pixels",
"in",
"an",
"image",
".",
"Accepts",
"both",
"RGB",
"and",
"grayscale",
"images",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/image.py#L70-L83 | train |
Kortemme-Lab/klab | klab/cloning/dna.py | sliding_window | def sliding_window(sequence, win_size, step=1):
"""
Returns a generator that will iterate through
the defined chunks of input sequence. Input sequence
must be iterable.
Credit: http://scipher.wordpress.com/2010/12/02/simple-sliding-window-iterator-in-python/
https://github.com/xguse/scipherPyP... | python | def sliding_window(sequence, win_size, step=1):
"""
Returns a generator that will iterate through
the defined chunks of input sequence. Input sequence
must be iterable.
Credit: http://scipher.wordpress.com/2010/12/02/simple-sliding-window-iterator-in-python/
https://github.com/xguse/scipherPyP... | [
"def",
"sliding_window",
"(",
"sequence",
",",
"win_size",
",",
"step",
"=",
"1",
")",
":",
"try",
":",
"it",
"=",
"iter",
"(",
"sequence",
")",
"except",
"TypeError",
":",
"raise",
"ValueError",
"(",
"\"sequence must be iterable.\"",
")",
"if",
"not",
"is... | Returns a generator that will iterate through
the defined chunks of input sequence. Input sequence
must be iterable.
Credit: http://scipher.wordpress.com/2010/12/02/simple-sliding-window-iterator-in-python/
https://github.com/xguse/scipherPyProj/blob/master/scipherSrc/defs/basicDefs.py | [
"Returns",
"a",
"generator",
"that",
"will",
"iterate",
"through",
"the",
"defined",
"chunks",
"of",
"input",
"sequence",
".",
"Input",
"sequence",
"must",
"be",
"iterable",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/cloning/dna.py#L103-L132 | train |
Kortemme-Lab/klab | klab/cloning/dna.py | dna_to_re | def dna_to_re(seq):
"""
Return a compiled regular expression that will match anything described by
the input sequence. For example, a sequence that contains a 'N' matched
any base at that position.
"""
seq = seq.replace('K', '[GT]')
seq = seq.replace('M', '[AC]')
seq = seq.replace('R... | python | def dna_to_re(seq):
"""
Return a compiled regular expression that will match anything described by
the input sequence. For example, a sequence that contains a 'N' matched
any base at that position.
"""
seq = seq.replace('K', '[GT]')
seq = seq.replace('M', '[AC]')
seq = seq.replace('R... | [
"def",
"dna_to_re",
"(",
"seq",
")",
":",
"seq",
"=",
"seq",
".",
"replace",
"(",
"'K'",
",",
"'[GT]'",
")",
"seq",
"=",
"seq",
".",
"replace",
"(",
"'M'",
",",
"'[AC]'",
")",
"seq",
"=",
"seq",
".",
"replace",
"(",
"'R'",
",",
"'[AG]'",
")",
"... | Return a compiled regular expression that will match anything described by
the input sequence. For example, a sequence that contains a 'N' matched
any base at that position. | [
"Return",
"a",
"compiled",
"regular",
"expression",
"that",
"will",
"match",
"anything",
"described",
"by",
"the",
"input",
"sequence",
".",
"For",
"example",
"a",
"sequence",
"that",
"contains",
"a",
"N",
"matched",
"any",
"base",
"at",
"that",
"position",
... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/cloning/dna.py#L139-L159 | train |
Kortemme-Lab/klab | klab/cloning/dna.py | case_highlight | def case_highlight(seq, subseq):
"""
Highlights all instances of subseq in seq by making them uppercase and
everything else lowercase.
"""
return re.subs(subseq.lower(), subseq.upper(), seq.lower()) | python | def case_highlight(seq, subseq):
"""
Highlights all instances of subseq in seq by making them uppercase and
everything else lowercase.
"""
return re.subs(subseq.lower(), subseq.upper(), seq.lower()) | [
"def",
"case_highlight",
"(",
"seq",
",",
"subseq",
")",
":",
"return",
"re",
".",
"subs",
"(",
"subseq",
".",
"lower",
"(",
")",
",",
"subseq",
".",
"upper",
"(",
")",
",",
"seq",
".",
"lower",
"(",
")",
")"
] | Highlights all instances of subseq in seq by making them uppercase and
everything else lowercase. | [
"Highlights",
"all",
"instances",
"of",
"subseq",
"in",
"seq",
"by",
"making",
"them",
"uppercase",
"and",
"everything",
"else",
"lowercase",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/cloning/dna.py#L161-L166 | train |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/indexers.py | index_relations | def index_relations(sender, pid_type, json=None,
record=None, index=None, **kwargs):
"""Add relations to the indexed record."""
if not json:
json = {}
pid = PersistentIdentifier.query.filter(
PersistentIdentifier.object_uuid == record.id,
PersistentIdentifier.pid_... | python | def index_relations(sender, pid_type, json=None,
record=None, index=None, **kwargs):
"""Add relations to the indexed record."""
if not json:
json = {}
pid = PersistentIdentifier.query.filter(
PersistentIdentifier.object_uuid == record.id,
PersistentIdentifier.pid_... | [
"def",
"index_relations",
"(",
"sender",
",",
"pid_type",
",",
"json",
"=",
"None",
",",
"record",
"=",
"None",
",",
"index",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"json",
":",
"json",
"=",
"{",
"}",
"pid",
"=",
"PersistentIdentifi... | Add relations to the indexed record. | [
"Add",
"relations",
"to",
"the",
"indexed",
"record",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/indexers.py#L37-L51 | train |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/indexers.py | index_siblings | def index_siblings(pid, include_pid=False, children=None,
neighbors_eager=False, eager=False, with_deposits=True):
"""Send sibling records of the passed pid for indexing.
Note: By default does not index the 'pid' itself,
only zero or more siblings.
:param pid: PID (recid) of w... | python | def index_siblings(pid, include_pid=False, children=None,
neighbors_eager=False, eager=False, with_deposits=True):
"""Send sibling records of the passed pid for indexing.
Note: By default does not index the 'pid' itself,
only zero or more siblings.
:param pid: PID (recid) of w... | [
"def",
"index_siblings",
"(",
"pid",
",",
"include_pid",
"=",
"False",
",",
"children",
"=",
"None",
",",
"neighbors_eager",
"=",
"False",
",",
"eager",
"=",
"False",
",",
"with_deposits",
"=",
"True",
")",
":",
"assert",
"not",
"(",
"neighbors_eager",
"an... | Send sibling records of the passed pid for indexing.
Note: By default does not index the 'pid' itself,
only zero or more siblings.
:param pid: PID (recid) of whose siblings are to be indexed.
:param children: Overrides children with a fixed list of PID.
Children should contain the 'pid' ... | [
"Send",
"sibling",
"records",
"of",
"the",
"passed",
"pid",
"for",
"indexing",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/indexers.py#L54-L124 | train |
brunato/lograptor | lograptor/filemap.py | GlobDict.iter_paths | def iter_paths(self, pathnames=None, mapfunc=None):
"""
Special iteration on paths. Yields couples of path and items. If a expanded path
doesn't match with any files a couple with path and `None` is returned.
:param pathnames: Iterable with a set of pathnames. If is `None` uses the all ... | python | def iter_paths(self, pathnames=None, mapfunc=None):
"""
Special iteration on paths. Yields couples of path and items. If a expanded path
doesn't match with any files a couple with path and `None` is returned.
:param pathnames: Iterable with a set of pathnames. If is `None` uses the all ... | [
"def",
"iter_paths",
"(",
"self",
",",
"pathnames",
"=",
"None",
",",
"mapfunc",
"=",
"None",
")",
":",
"pathnames",
"=",
"pathnames",
"or",
"self",
".",
"_pathnames",
"if",
"self",
".",
"recursive",
"and",
"not",
"pathnames",
":",
"pathnames",
"=",
"[",... | Special iteration on paths. Yields couples of path and items. If a expanded path
doesn't match with any files a couple with path and `None` is returned.
:param pathnames: Iterable with a set of pathnames. If is `None` uses the all \
the stored pathnames.
:param mapfunc: A mapping functi... | [
"Special",
"iteration",
"on",
"paths",
".",
"Yields",
"couples",
"of",
"path",
"and",
"items",
".",
"If",
"a",
"expanded",
"path",
"doesn",
"t",
"match",
"with",
"any",
"files",
"a",
"couple",
"with",
"path",
"and",
"None",
"is",
"returned",
"."
] | b1f09fe1b429ed15110610092704ef12d253f3c9 | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/filemap.py#L111-L154 | train |
brunato/lograptor | lograptor/filemap.py | FileMap.check_stat | def check_stat(self, path):
"""
Checks logfile stat information for excluding files not in datetime period.
On Linux it's possible to checks only modification time, because file creation info
are not available, so it's possible to exclude only older files.
In Unix BSD systems and... | python | def check_stat(self, path):
"""
Checks logfile stat information for excluding files not in datetime period.
On Linux it's possible to checks only modification time, because file creation info
are not available, so it's possible to exclude only older files.
In Unix BSD systems and... | [
"def",
"check_stat",
"(",
"self",
",",
"path",
")",
":",
"statinfo",
"=",
"os",
".",
"stat",
"(",
"path",
")",
"st_mtime",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"statinfo",
".",
"st_mtime",
")",
"if",
"platform",
".",
"system",
"(",
")",
"==",
... | Checks logfile stat information for excluding files not in datetime period.
On Linux it's possible to checks only modification time, because file creation info
are not available, so it's possible to exclude only older files.
In Unix BSD systems and windows information about file creation date an... | [
"Checks",
"logfile",
"stat",
"information",
"for",
"excluding",
"files",
"not",
"in",
"datetime",
"period",
".",
"On",
"Linux",
"it",
"s",
"possible",
"to",
"checks",
"only",
"modification",
"time",
"because",
"file",
"creation",
"info",
"are",
"not",
"availab... | b1f09fe1b429ed15110610092704ef12d253f3c9 | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/filemap.py#L192-L210 | train |
brunato/lograptor | lograptor/filemap.py | FileMap.add | def add(self, files, items):
"""
Add a list of files with a reference to a list of objects.
"""
if isinstance(files, (str, bytes)):
files = iter([files])
for pathname in files:
try:
values = self._filemap[pathname]
except KeyErr... | python | def add(self, files, items):
"""
Add a list of files with a reference to a list of objects.
"""
if isinstance(files, (str, bytes)):
files = iter([files])
for pathname in files:
try:
values = self._filemap[pathname]
except KeyErr... | [
"def",
"add",
"(",
"self",
",",
"files",
",",
"items",
")",
":",
"if",
"isinstance",
"(",
"files",
",",
"(",
"str",
",",
"bytes",
")",
")",
":",
"files",
"=",
"iter",
"(",
"[",
"files",
"]",
")",
"for",
"pathname",
"in",
"files",
":",
"try",
":... | Add a list of files with a reference to a list of objects. | [
"Add",
"a",
"list",
"of",
"files",
"with",
"a",
"reference",
"to",
"a",
"list",
"of",
"objects",
"."
] | b1f09fe1b429ed15110610092704ef12d253f3c9 | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/filemap.py#L212-L224 | train |
berkeley-cocosci/Wallace | examples/rogers/experiment.py | RogersExperiment.recruit | def recruit(self):
"""Recruit more participants."""
participants = Participant.query.\
with_entities(Participant.status).all()
# if all networks are full, close recruitment,
if not self.networks(full=False):
print "All networks are full, closing recruitment."
... | python | def recruit(self):
"""Recruit more participants."""
participants = Participant.query.\
with_entities(Participant.status).all()
# if all networks are full, close recruitment,
if not self.networks(full=False):
print "All networks are full, closing recruitment."
... | [
"def",
"recruit",
"(",
"self",
")",
":",
"participants",
"=",
"Participant",
".",
"query",
".",
"with_entities",
"(",
"Participant",
".",
"status",
")",
".",
"all",
"(",
")",
"if",
"not",
"self",
".",
"networks",
"(",
"full",
"=",
"False",
")",
":",
... | Recruit more participants. | [
"Recruit",
"more",
"participants",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/examples/rogers/experiment.py#L106-L127 | train |
berkeley-cocosci/Wallace | examples/rogers/experiment.py | RogersExperiment.data_check | def data_check(self, participant):
"""Check a participants data."""
participant_id = participant.uniqueid
nodes = Node.query.filter_by(participant_id=participant_id).all()
if len(nodes) != self.experiment_repeats + self.practice_repeats:
print("Error: Participant has {} nod... | python | def data_check(self, participant):
"""Check a participants data."""
participant_id = participant.uniqueid
nodes = Node.query.filter_by(participant_id=participant_id).all()
if len(nodes) != self.experiment_repeats + self.practice_repeats:
print("Error: Participant has {} nod... | [
"def",
"data_check",
"(",
"self",
",",
"participant",
")",
":",
"participant_id",
"=",
"participant",
".",
"uniqueid",
"nodes",
"=",
"Node",
".",
"query",
".",
"filter_by",
"(",
"participant_id",
"=",
"participant_id",
")",
".",
"all",
"(",
")",
"if",
"len... | Check a participants data. | [
"Check",
"a",
"participants",
"data",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/examples/rogers/experiment.py#L168-L194 | train |
berkeley-cocosci/Wallace | examples/rogers/experiment.py | RogersExperiment.add_node_to_network | def add_node_to_network(self, node, network):
"""Add participant's node to a network."""
network.add_node(node)
node.receive()
environment = network.nodes(type=Environment)[0]
environment.connect(whom=node)
gene = node.infos(type=LearningGene)[0].contents
if (ge... | python | def add_node_to_network(self, node, network):
"""Add participant's node to a network."""
network.add_node(node)
node.receive()
environment = network.nodes(type=Environment)[0]
environment.connect(whom=node)
gene = node.infos(type=LearningGene)[0].contents
if (ge... | [
"def",
"add_node_to_network",
"(",
"self",
",",
"node",
",",
"network",
")",
":",
"network",
".",
"add_node",
"(",
"node",
")",
"node",
".",
"receive",
"(",
")",
"environment",
"=",
"network",
".",
"nodes",
"(",
"type",
"=",
"Environment",
")",
"[",
"0... | Add participant's node to a network. | [
"Add",
"participant",
"s",
"node",
"to",
"a",
"network",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/examples/rogers/experiment.py#L196-L219 | train |
berkeley-cocosci/Wallace | examples/rogers/experiment.py | RogersEnvironment.create_state | def create_state(self, proportion):
"""Create an environmental state."""
if random.random() < 0.5:
proportion = 1 - proportion
State(origin=self, contents=proportion) | python | def create_state(self, proportion):
"""Create an environmental state."""
if random.random() < 0.5:
proportion = 1 - proportion
State(origin=self, contents=proportion) | [
"def",
"create_state",
"(",
"self",
",",
"proportion",
")",
":",
"if",
"random",
".",
"random",
"(",
")",
"<",
"0.5",
":",
"proportion",
"=",
"1",
"-",
"proportion",
"State",
"(",
"origin",
"=",
"self",
",",
"contents",
"=",
"proportion",
")"
] | Create an environmental state. | [
"Create",
"an",
"environmental",
"state",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/examples/rogers/experiment.py#L363-L367 | train |
berkeley-cocosci/Wallace | examples/rogers/experiment.py | RogersEnvironment.step | def step(self):
"""Prompt the environment to change."""
current_state = max(self.infos(type=State),
key=attrgetter('creation_time'))
current_contents = float(current_state.contents)
new_contents = 1 - current_contents
info_out = State(origin=self, cont... | python | def step(self):
"""Prompt the environment to change."""
current_state = max(self.infos(type=State),
key=attrgetter('creation_time'))
current_contents = float(current_state.contents)
new_contents = 1 - current_contents
info_out = State(origin=self, cont... | [
"def",
"step",
"(",
"self",
")",
":",
"current_state",
"=",
"max",
"(",
"self",
".",
"infos",
"(",
"type",
"=",
"State",
")",
",",
"key",
"=",
"attrgetter",
"(",
"'creation_time'",
")",
")",
"current_contents",
"=",
"float",
"(",
"current_state",
".",
... | Prompt the environment to change. | [
"Prompt",
"the",
"environment",
"to",
"change",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/examples/rogers/experiment.py#L369-L376 | train |
Kortemme-Lab/klab | klab/cluster/python_script_template.py | print_subprocess_output | def print_subprocess_output(subp):
'''Prints the stdout and stderr output.'''
if subp:
if subp.errorcode != 0:
print('<error errorcode="%s">' % str(subp.errorcode))
print(subp.stderr)
print("</error>")
print_tag('stdout', '\n%s\n' % subp.stdout)
el... | python | def print_subprocess_output(subp):
'''Prints the stdout and stderr output.'''
if subp:
if subp.errorcode != 0:
print('<error errorcode="%s">' % str(subp.errorcode))
print(subp.stderr)
print("</error>")
print_tag('stdout', '\n%s\n' % subp.stdout)
el... | [
"def",
"print_subprocess_output",
"(",
"subp",
")",
":",
"if",
"subp",
":",
"if",
"subp",
".",
"errorcode",
"!=",
"0",
":",
"print",
"(",
"'<error errorcode=\"%s\">'",
"%",
"str",
"(",
"subp",
".",
"errorcode",
")",
")",
"print",
"(",
"subp",
".",
"stder... | Prints the stdout and stderr output. | [
"Prints",
"the",
"stdout",
"and",
"stderr",
"output",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/cluster/python_script_template.py#L48-L58 | train |
Alveo/pyalveo | pyalveo/objects.py | ItemGroup.get_all | def get_all(self, force_download=False):
""" Retrieve the metadata for all items in this list from the server,
as Item objects
:rtype: List
:returns: a List of the corresponding Item objects
:type force_download: Boolean
:param force_download: True to download from the s... | python | def get_all(self, force_download=False):
""" Retrieve the metadata for all items in this list from the server,
as Item objects
:rtype: List
:returns: a List of the corresponding Item objects
:type force_download: Boolean
:param force_download: True to download from the s... | [
"def",
"get_all",
"(",
"self",
",",
"force_download",
"=",
"False",
")",
":",
"cl",
"=",
"self",
".",
"client",
"return",
"[",
"cl",
".",
"get_item",
"(",
"item",
",",
"force_download",
")",
"for",
"item",
"in",
"self",
".",
"item_urls",
"]"
] | Retrieve the metadata for all items in this list from the server,
as Item objects
:rtype: List
:returns: a List of the corresponding Item objects
:type force_download: Boolean
:param force_download: True to download from the server
regardless of the cache's contents
... | [
"Retrieve",
"the",
"metadata",
"for",
"all",
"items",
"in",
"this",
"list",
"from",
"the",
"server",
"as",
"Item",
"objects"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/objects.py#L170-L185 | train |
Alveo/pyalveo | pyalveo/objects.py | ItemGroup.get_item | def get_item(self, item_index, force_download=False):
""" Retrieve the metadata for a specific item in this ItemGroup
:type item_index: int
:param item_index: the index of the item
:type force_download: Boolean
:param force_download: True to download from the server
... | python | def get_item(self, item_index, force_download=False):
""" Retrieve the metadata for a specific item in this ItemGroup
:type item_index: int
:param item_index: the index of the item
:type force_download: Boolean
:param force_download: True to download from the server
... | [
"def",
"get_item",
"(",
"self",
",",
"item_index",
",",
"force_download",
"=",
"False",
")",
":",
"return",
"self",
".",
"client",
".",
"get_item",
"(",
"self",
".",
"item_urls",
"[",
"item_index",
"]",
",",
"force_download",
")"
] | Retrieve the metadata for a specific item in this ItemGroup
:type item_index: int
:param item_index: the index of the item
:type force_download: Boolean
:param force_download: True to download from the server
regardless of the cache's contents
:rtype: Item
:... | [
"Retrieve",
"the",
"metadata",
"for",
"a",
"specific",
"item",
"in",
"this",
"ItemGroup"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/objects.py#L230-L246 | train |
Alveo/pyalveo | pyalveo/objects.py | ItemList.refresh | def refresh(self):
""" Update this ItemList by re-downloading it from the server
:rtype: ItemList
:returns: this ItemList, after the refresh
:raises: APIError if the API request is not successful
"""
refreshed = self.client.get_item_list(self.url())
self.item_... | python | def refresh(self):
""" Update this ItemList by re-downloading it from the server
:rtype: ItemList
:returns: this ItemList, after the refresh
:raises: APIError if the API request is not successful
"""
refreshed = self.client.get_item_list(self.url())
self.item_... | [
"def",
"refresh",
"(",
"self",
")",
":",
"refreshed",
"=",
"self",
".",
"client",
".",
"get_item_list",
"(",
"self",
".",
"url",
"(",
")",
")",
"self",
".",
"item_urls",
"=",
"refreshed",
".",
"urls",
"(",
")",
"self",
".",
"list_name",
"=",
"refresh... | Update this ItemList by re-downloading it from the server
:rtype: ItemList
:returns: this ItemList, after the refresh
:raises: APIError if the API request is not successful | [
"Update",
"this",
"ItemList",
"by",
"re",
"-",
"downloading",
"it",
"from",
"the",
"server"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/objects.py#L345-L358 | train |
Alveo/pyalveo | pyalveo/objects.py | ItemList.append | def append(self, items):
""" Add some items to this ItemList and save the changes to the server
:param items: the items to add, either as a List of Item objects, an
ItemList, a List of item URLs as Strings, a single item URL as a
String, or a single Item object
:rtype: ... | python | def append(self, items):
""" Add some items to this ItemList and save the changes to the server
:param items: the items to add, either as a List of Item objects, an
ItemList, a List of item URLs as Strings, a single item URL as a
String, or a single Item object
:rtype: ... | [
"def",
"append",
"(",
"self",
",",
"items",
")",
":",
"resp",
"=",
"self",
".",
"client",
".",
"add_to_item_list",
"(",
"items",
",",
"self",
".",
"url",
"(",
")",
")",
"self",
".",
"refresh",
"(",
")",
"return",
"resp"
] | Add some items to this ItemList and save the changes to the server
:param items: the items to add, either as a List of Item objects, an
ItemList, a List of item URLs as Strings, a single item URL as a
String, or a single Item object
:rtype: String
:returns: the server s... | [
"Add",
"some",
"items",
"to",
"this",
"ItemList",
"and",
"save",
"the",
"changes",
"to",
"the",
"server"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/objects.py#L361-L377 | train |
Alveo/pyalveo | pyalveo/objects.py | Item.get_document | def get_document(self, index=0):
""" Return the metadata for the specified document, as a
Document object
:type index: int
:param index: the index of the document
:rtype: Document
:returns: the metadata for the specified document
"""
try:
r... | python | def get_document(self, index=0):
""" Return the metadata for the specified document, as a
Document object
:type index: int
:param index: the index of the document
:rtype: Document
:returns: the metadata for the specified document
"""
try:
r... | [
"def",
"get_document",
"(",
"self",
",",
"index",
"=",
"0",
")",
":",
"try",
":",
"return",
"Document",
"(",
"self",
".",
"metadata",
"(",
")",
"[",
"'alveo:documents'",
"]",
"[",
"index",
"]",
",",
"self",
".",
"client",
")",
"except",
"IndexError",
... | Return the metadata for the specified document, as a
Document object
:type index: int
:param index: the index of the document
:rtype: Document
:returns: the metadata for the specified document | [
"Return",
"the",
"metadata",
"for",
"the",
"specified",
"document",
"as",
"a",
"Document",
"object"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/objects.py#L462-L478 | train |
Alveo/pyalveo | pyalveo/objects.py | Item.get_primary_text | def get_primary_text(self, force_download=False):
""" Retrieve the primary text for this item from the server
:type force_download: Boolean
:param force_download: True to download from the server
regardless of the cache's contents
:rtype: String
:returns: the primar... | python | def get_primary_text(self, force_download=False):
""" Retrieve the primary text for this item from the server
:type force_download: Boolean
:param force_download: True to download from the server
regardless of the cache's contents
:rtype: String
:returns: the primar... | [
"def",
"get_primary_text",
"(",
"self",
",",
"force_download",
"=",
"False",
")",
":",
"return",
"self",
".",
"client",
".",
"get_primary_text",
"(",
"self",
".",
"url",
"(",
")",
",",
"force_download",
")"
] | Retrieve the primary text for this item from the server
:type force_download: Boolean
:param force_download: True to download from the server
regardless of the cache's contents
:rtype: String
:returns: the primary text
:raises: APIError if the API request is not su... | [
"Retrieve",
"the",
"primary",
"text",
"for",
"this",
"item",
"from",
"the",
"server"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/objects.py#L481-L495 | train |
Alveo/pyalveo | pyalveo/objects.py | Item.get_annotations | def get_annotations(self, atype=None, label=None):
""" Retrieve the annotations for this item from the server
:type atype: String
:param atype: return only results with a matching Type field
:type label: String
:param label: return only results with a matching Label field
... | python | def get_annotations(self, atype=None, label=None):
""" Retrieve the annotations for this item from the server
:type atype: String
:param atype: return only results with a matching Type field
:type label: String
:param label: return only results with a matching Label field
... | [
"def",
"get_annotations",
"(",
"self",
",",
"atype",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"return",
"self",
".",
"client",
".",
"get_item_annotations",
"(",
"self",
".",
"url",
"(",
")",
",",
"atype",
",",
"label",
")"
] | Retrieve the annotations for this item from the server
:type atype: String
:param atype: return only results with a matching Type field
:type label: String
:param label: return only results with a matching Label field
:rtype: String
:returns: the annotations as a JSON s... | [
"Retrieve",
"the",
"annotations",
"for",
"this",
"item",
"from",
"the",
"server"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/objects.py#L498-L513 | train |
Alveo/pyalveo | pyalveo/objects.py | Document.get_content | def get_content(self, force_download=False):
""" Retrieve the content for this Document from the server
:type force_download: Boolean
:param force_download: True to download from the server
regardless of the cache's contents
:rtype: String
:returns: the content data... | python | def get_content(self, force_download=False):
""" Retrieve the content for this Document from the server
:type force_download: Boolean
:param force_download: True to download from the server
regardless of the cache's contents
:rtype: String
:returns: the content data... | [
"def",
"get_content",
"(",
"self",
",",
"force_download",
"=",
"False",
")",
":",
"return",
"self",
".",
"client",
".",
"get_document",
"(",
"self",
".",
"url",
"(",
")",
",",
"force_download",
")"
] | Retrieve the content for this Document from the server
:type force_download: Boolean
:param force_download: True to download from the server
regardless of the cache's contents
:rtype: String
:returns: the content data
:raises: APIError if the API request is not suc... | [
"Retrieve",
"the",
"content",
"for",
"this",
"Document",
"from",
"the",
"server"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/objects.py#L702-L716 | train |
Alveo/pyalveo | pyalveo/objects.py | Document.download_content | def download_content(self, dir_path='', filename=None,
force_download=False):
""" Download the content for this document to a file
:type dir_path: String
:param dir_path: the path to which to write the data
:type filename: String
:param filename: filenam... | python | def download_content(self, dir_path='', filename=None,
force_download=False):
""" Download the content for this document to a file
:type dir_path: String
:param dir_path: the path to which to write the data
:type filename: String
:param filename: filenam... | [
"def",
"download_content",
"(",
"self",
",",
"dir_path",
"=",
"''",
",",
"filename",
"=",
"None",
",",
"force_download",
"=",
"False",
")",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"self",
".",
"get_filename",
"(",
")",
"path",
"=",
"... | Download the content for this document to a file
:type dir_path: String
:param dir_path: the path to which to write the data
:type filename: String
:param filename: filename to write to (if None, defaults to the document's
name, as specified by its metadata
:type for... | [
"Download",
"the",
"content",
"for",
"this",
"document",
"to",
"a",
"file"
] | 1e9eec22bc031bc9a08066f9966565a546e6242e | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/objects.py#L730-L756 | train |
peergradeio/flask-mongo-profiler | flask_mongo_profiler/contrib/flask_admin/formatters/polymorphic_relations.py | generic_ref_formatter | def generic_ref_formatter(view, context, model, name, lazy=False):
"""
For GenericReferenceField and LazyGenericReferenceField
See Also
--------
diff_formatter
"""
try:
if lazy:
rel_model = getattr(model, name).fetch()
else:
rel_model = getattr(model,... | python | def generic_ref_formatter(view, context, model, name, lazy=False):
"""
For GenericReferenceField and LazyGenericReferenceField
See Also
--------
diff_formatter
"""
try:
if lazy:
rel_model = getattr(model, name).fetch()
else:
rel_model = getattr(model,... | [
"def",
"generic_ref_formatter",
"(",
"view",
",",
"context",
",",
"model",
",",
"name",
",",
"lazy",
"=",
"False",
")",
":",
"try",
":",
"if",
"lazy",
":",
"rel_model",
"=",
"getattr",
"(",
"model",
",",
"name",
")",
".",
"fetch",
"(",
")",
"else",
... | For GenericReferenceField and LazyGenericReferenceField
See Also
--------
diff_formatter | [
"For",
"GenericReferenceField",
"and",
"LazyGenericReferenceField"
] | a267eeb49fea07c9a24fb370bd9d7a90ed313ccf | https://github.com/peergradeio/flask-mongo-profiler/blob/a267eeb49fea07c9a24fb370bd9d7a90ed313ccf/flask_mongo_profiler/contrib/flask_admin/formatters/polymorphic_relations.py#L27-L65 | train |
peergradeio/flask-mongo-profiler | flask_mongo_profiler/contrib/flask_admin/formatters/polymorphic_relations.py | generic_document_type_formatter | def generic_document_type_formatter(view, context, model, name):
"""Return AdminLog.document field wrapped in URL to its list view."""
_document_model = model.get('document').document_type
url = _document_model.get_admin_list_url()
return Markup('<a href="%s">%s</a>' % (url, _document_model.__name__)) | python | def generic_document_type_formatter(view, context, model, name):
"""Return AdminLog.document field wrapped in URL to its list view."""
_document_model = model.get('document').document_type
url = _document_model.get_admin_list_url()
return Markup('<a href="%s">%s</a>' % (url, _document_model.__name__)) | [
"def",
"generic_document_type_formatter",
"(",
"view",
",",
"context",
",",
"model",
",",
"name",
")",
":",
"_document_model",
"=",
"model",
".",
"get",
"(",
"'document'",
")",
".",
"document_type",
"url",
"=",
"_document_model",
".",
"get_admin_list_url",
"(",
... | Return AdminLog.document field wrapped in URL to its list view. | [
"Return",
"AdminLog",
".",
"document",
"field",
"wrapped",
"in",
"URL",
"to",
"its",
"list",
"view",
"."
] | a267eeb49fea07c9a24fb370bd9d7a90ed313ccf | https://github.com/peergradeio/flask-mongo-profiler/blob/a267eeb49fea07c9a24fb370bd9d7a90ed313ccf/flask_mongo_profiler/contrib/flask_admin/formatters/polymorphic_relations.py#L77-L81 | train |
berkeley-cocosci/Wallace | wallace/custom.py | return_page | def return_page(page):
"""Return a rendered template."""
try:
hit_id = request.args['hit_id']
assignment_id = request.args['assignment_id']
worker_id = request.args['worker_id']
mode = request.args['mode']
return render_template(
page,
hit_id=hit_i... | python | def return_page(page):
"""Return a rendered template."""
try:
hit_id = request.args['hit_id']
assignment_id = request.args['assignment_id']
worker_id = request.args['worker_id']
mode = request.args['mode']
return render_template(
page,
hit_id=hit_i... | [
"def",
"return_page",
"(",
"page",
")",
":",
"try",
":",
"hit_id",
"=",
"request",
".",
"args",
"[",
"'hit_id'",
"]",
"assignment_id",
"=",
"request",
".",
"args",
"[",
"'assignment_id'",
"]",
"worker_id",
"=",
"request",
".",
"args",
"[",
"'worker_id'",
... | Return a rendered template. | [
"Return",
"a",
"rendered",
"template",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/custom.py#L120-L139 | train |
berkeley-cocosci/Wallace | wallace/custom.py | quitter | def quitter():
"""Overide the psiTurk quitter route."""
exp = experiment(session)
exp.log("Quitter route was hit.")
return Response(
dumps({"status": "success"}),
status=200,
mimetype='application/json') | python | def quitter():
"""Overide the psiTurk quitter route."""
exp = experiment(session)
exp.log("Quitter route was hit.")
return Response(
dumps({"status": "success"}),
status=200,
mimetype='application/json') | [
"def",
"quitter",
"(",
")",
":",
"exp",
"=",
"experiment",
"(",
"session",
")",
"exp",
".",
"log",
"(",
"\"Quitter route was hit.\"",
")",
"return",
"Response",
"(",
"dumps",
"(",
"{",
"\"status\"",
":",
"\"success\"",
"}",
")",
",",
"status",
"=",
"200"... | Overide the psiTurk quitter route. | [
"Overide",
"the",
"psiTurk",
"quitter",
"route",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/custom.py#L228-L236 | train |
berkeley-cocosci/Wallace | wallace/custom.py | ad_address | def ad_address(mode, hit_id):
"""Get the address of the ad on AWS.
This is used at the end of the experiment to send participants
back to AWS where they can complete and submit the HIT.
"""
if mode == "debug":
address = '/complete'
elif mode in ["sandbox", "live"]:
username = os... | python | def ad_address(mode, hit_id):
"""Get the address of the ad on AWS.
This is used at the end of the experiment to send participants
back to AWS where they can complete and submit the HIT.
"""
if mode == "debug":
address = '/complete'
elif mode in ["sandbox", "live"]:
username = os... | [
"def",
"ad_address",
"(",
"mode",
",",
"hit_id",
")",
":",
"if",
"mode",
"==",
"\"debug\"",
":",
"address",
"=",
"'/complete'",
"elif",
"mode",
"in",
"[",
"\"sandbox\"",
",",
"\"live\"",
"]",
":",
"username",
"=",
"os",
".",
"getenv",
"(",
"'psiturk_acce... | Get the address of the ad on AWS.
This is used at the end of the experiment to send participants
back to AWS where they can complete and submit the HIT. | [
"Get",
"the",
"address",
"of",
"the",
"ad",
"on",
"AWS",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/custom.py#L248-L283 | train |
berkeley-cocosci/Wallace | wallace/custom.py | connect | def connect(node_id, other_node_id):
"""Connect to another node.
The ids of both nodes must be speficied in the url.
You can also pass direction (to/from/both) as an argument.
"""
exp = experiment(session)
# get the parameters
direction = request_parameter(parameter="direction", default="t... | python | def connect(node_id, other_node_id):
"""Connect to another node.
The ids of both nodes must be speficied in the url.
You can also pass direction (to/from/both) as an argument.
"""
exp = experiment(session)
# get the parameters
direction = request_parameter(parameter="direction", default="t... | [
"def",
"connect",
"(",
"node_id",
",",
"other_node_id",
")",
":",
"exp",
"=",
"experiment",
"(",
"session",
")",
"direction",
"=",
"request_parameter",
"(",
"parameter",
"=",
"\"direction\"",
",",
"default",
"=",
"\"to\"",
")",
"if",
"type",
"(",
"direction"... | Connect to another node.
The ids of both nodes must be speficied in the url.
You can also pass direction (to/from/both) as an argument. | [
"Connect",
"to",
"another",
"node",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/custom.py#L649-L692 | train |
berkeley-cocosci/Wallace | wallace/custom.py | get_info | def get_info(node_id, info_id):
"""Get a specific info.
Both the node and info id must be specified in the url.
"""
exp = experiment(session)
# check the node exists
node = models.Node.query.get(node_id)
if node is None:
return error_response(error_type="/info, node does not exist"... | python | def get_info(node_id, info_id):
"""Get a specific info.
Both the node and info id must be specified in the url.
"""
exp = experiment(session)
# check the node exists
node = models.Node.query.get(node_id)
if node is None:
return error_response(error_type="/info, node does not exist"... | [
"def",
"get_info",
"(",
"node_id",
",",
"info_id",
")",
":",
"exp",
"=",
"experiment",
"(",
"session",
")",
"node",
"=",
"models",
".",
"Node",
".",
"query",
".",
"get",
"(",
"node_id",
")",
"if",
"node",
"is",
"None",
":",
"return",
"error_response",
... | Get a specific info.
Both the node and info id must be specified in the url. | [
"Get",
"a",
"specific",
"info",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/custom.py#L696-L733 | train |
berkeley-cocosci/Wallace | wallace/custom.py | transformation_post | def transformation_post(node_id, info_in_id, info_out_id):
"""Transform an info.
The ids of the node, info in and info out must all be in the url.
You can also pass transformation_type.
"""
exp = experiment(session)
# Get the parameters.
transformation_type = request_parameter(parameter="t... | python | def transformation_post(node_id, info_in_id, info_out_id):
"""Transform an info.
The ids of the node, info in and info out must all be in the url.
You can also pass transformation_type.
"""
exp = experiment(session)
# Get the parameters.
transformation_type = request_parameter(parameter="t... | [
"def",
"transformation_post",
"(",
"node_id",
",",
"info_in_id",
",",
"info_out_id",
")",
":",
"exp",
"=",
"experiment",
"(",
"session",
")",
"transformation_type",
"=",
"request_parameter",
"(",
"parameter",
"=",
"\"transformation_type\"",
",",
"parameter_type",
"=... | Transform an info.
The ids of the node, info in and info out must all be in the url.
You can also pass transformation_type. | [
"Transform",
"an",
"info",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/custom.py#L1053-L1104 | train |
berkeley-cocosci/Wallace | wallace/custom.py | api_notifications | def api_notifications():
"""Receive MTurk REST notifications."""
event_type = request.values['Event.1.EventType']
assignment_id = request.values['Event.1.AssignmentId']
# Add the notification to the queue.
db.logger.debug('rq: Queueing %s with id: %s for worker_function',
event_... | python | def api_notifications():
"""Receive MTurk REST notifications."""
event_type = request.values['Event.1.EventType']
assignment_id = request.values['Event.1.AssignmentId']
# Add the notification to the queue.
db.logger.debug('rq: Queueing %s with id: %s for worker_function',
event_... | [
"def",
"api_notifications",
"(",
")",
":",
"event_type",
"=",
"request",
".",
"values",
"[",
"'Event.1.EventType'",
"]",
"assignment_id",
"=",
"request",
".",
"values",
"[",
"'Event.1.AssignmentId'",
"]",
"db",
".",
"logger",
".",
"debug",
"(",
"'rq: Queueing %s... | Receive MTurk REST notifications. | [
"Receive",
"MTurk",
"REST",
"notifications",
"."
] | 3650c0bc3b0804d0adb1d178c5eba9992babb1b0 | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/custom.py#L1108-L1120 | train |
uogbuji/versa | tools/py/writer/rdfs.py | process | def process(source, target, rdfsonly, base=None, logger=logging):
'''
Prepare a statement into a triple ready for rdflib graph
'''
for link in source.match():
s, p, o = link[:3]
#SKip docheader statements
if s == (base or '') + '@docheader': continue
if p in RESOURCE_MAP... | python | def process(source, target, rdfsonly, base=None, logger=logging):
'''
Prepare a statement into a triple ready for rdflib graph
'''
for link in source.match():
s, p, o = link[:3]
#SKip docheader statements
if s == (base or '') + '@docheader': continue
if p in RESOURCE_MAP... | [
"def",
"process",
"(",
"source",
",",
"target",
",",
"rdfsonly",
",",
"base",
"=",
"None",
",",
"logger",
"=",
"logging",
")",
":",
"for",
"link",
"in",
"source",
".",
"match",
"(",
")",
":",
"s",
",",
"p",
",",
"o",
"=",
"link",
"[",
":",
"3",... | Prepare a statement into a triple ready for rdflib graph | [
"Prepare",
"a",
"statement",
"into",
"a",
"triple",
"ready",
"for",
"rdflib",
"graph"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/writer/rdfs.py#L50-L83 | train |
uogbuji/versa | tools/py/writer/rdfs.py | write | def write(models, base=None, graph=None, rdfsonly=False, prefixes=None, logger=logging):
'''
See the command line help
'''
prefixes = prefixes or {}
g = graph or rdflib.Graph()
#g.bind('bf', BFNS)
#g.bind('bfc', BFCNS)
#g.bind('bfd', BFDNS)
g.bind('v', VNS)
for k, v in prefixes.i... | python | def write(models, base=None, graph=None, rdfsonly=False, prefixes=None, logger=logging):
'''
See the command line help
'''
prefixes = prefixes or {}
g = graph or rdflib.Graph()
#g.bind('bf', BFNS)
#g.bind('bfc', BFCNS)
#g.bind('bfd', BFDNS)
g.bind('v', VNS)
for k, v in prefixes.i... | [
"def",
"write",
"(",
"models",
",",
"base",
"=",
"None",
",",
"graph",
"=",
"None",
",",
"rdfsonly",
"=",
"False",
",",
"prefixes",
"=",
"None",
",",
"logger",
"=",
"logging",
")",
":",
"prefixes",
"=",
"prefixes",
"or",
"{",
"}",
"g",
"=",
"graph"... | See the command line help | [
"See",
"the",
"command",
"line",
"help"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/writer/rdfs.py#L86-L101 | train |
projectshift/shift-boiler | boiler/feature/routing.py | routing_feature | def routing_feature(app):
"""
Add routing feature
Allows to define application routes un urls.py file and use lazy views.
Additionally enables regular exceptions in route definitions
"""
# enable regex routes
app.url_map.converters['regex'] = RegexConverter
urls = app.name.rsplit('.', 1... | python | def routing_feature(app):
"""
Add routing feature
Allows to define application routes un urls.py file and use lazy views.
Additionally enables regular exceptions in route definitions
"""
# enable regex routes
app.url_map.converters['regex'] = RegexConverter
urls = app.name.rsplit('.', 1... | [
"def",
"routing_feature",
"(",
"app",
")",
":",
"app",
".",
"url_map",
".",
"converters",
"[",
"'regex'",
"]",
"=",
"RegexConverter",
"urls",
"=",
"app",
".",
"name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
"+",
"'.urls.urls'",
"try"... | Add routing feature
Allows to define application routes un urls.py file and use lazy views.
Additionally enables regular exceptions in route definitions | [
"Add",
"routing",
"feature",
"Allows",
"to",
"define",
"application",
"routes",
"un",
"urls",
".",
"py",
"file",
"and",
"use",
"lazy",
"views",
".",
"Additionally",
"enables",
"regular",
"exceptions",
"in",
"route",
"definitions"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/feature/routing.py#L5-L30 | train |
rosshamish/undoredo | undoredo.py | undoable | def undoable(method):
"""
Decorator undoable allows an instance method to be undone.
It does this by wrapping the method call as a Command, then calling self.do() on the command.
Classes which use this decorator should implement a do() method like such:
def do(self, command):
retu... | python | def undoable(method):
"""
Decorator undoable allows an instance method to be undone.
It does this by wrapping the method call as a Command, then calling self.do() on the command.
Classes which use this decorator should implement a do() method like such:
def do(self, command):
retu... | [
"def",
"undoable",
"(",
"method",
")",
":",
"def",
"undoable_method",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"self",
".",
"do",
"(",
"Command",
"(",
"self",
",",
"method",
",",
"*",
"args",
")",
")",
"return",
"undoable_method"
] | Decorator undoable allows an instance method to be undone.
It does this by wrapping the method call as a Command, then calling self.do() on the command.
Classes which use this decorator should implement a do() method like such:
def do(self, command):
return self.undo_manager.do(command) | [
"Decorator",
"undoable",
"allows",
"an",
"instance",
"method",
"to",
"be",
"undone",
"."
] | 634941181a74477b7ebafa43d9900e6f21fd0458 | https://github.com/rosshamish/undoredo/blob/634941181a74477b7ebafa43d9900e6f21fd0458/undoredo.py#L105-L118 | train |
projectshift/shift-boiler | boiler/migrations/config.py | MigrationsConfig.get_template_directory | def get_template_directory(self):
"""
Get path to migrations templates
This will get used when you run the db init command
"""
dir = os.path.join(os.path.dirname(__file__), 'templates')
return dir | python | def get_template_directory(self):
"""
Get path to migrations templates
This will get used when you run the db init command
"""
dir = os.path.join(os.path.dirname(__file__), 'templates')
return dir | [
"def",
"get_template_directory",
"(",
"self",
")",
":",
"dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'templates'",
")",
"return",
"dir"
] | Get path to migrations templates
This will get used when you run the db init command | [
"Get",
"path",
"to",
"migrations",
"templates",
"This",
"will",
"get",
"used",
"when",
"you",
"run",
"the",
"db",
"init",
"command"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/migrations/config.py#L23-L29 | train |
CodersOfTheNight/oshino | oshino/agents/__init__.py | Agent.pull_metrics | async def pull_metrics(self, event_fn, loop=None):
"""
Method called by core.
Should not be overwritten.
"""
if self.lazy and not self.ready:
return None
logger = self.get_logger()
ts = timer()
logger.trace("Waiting for process event")
... | python | async def pull_metrics(self, event_fn, loop=None):
"""
Method called by core.
Should not be overwritten.
"""
if self.lazy and not self.ready:
return None
logger = self.get_logger()
ts = timer()
logger.trace("Waiting for process event")
... | [
"async",
"def",
"pull_metrics",
"(",
"self",
",",
"event_fn",
",",
"loop",
"=",
"None",
")",
":",
"if",
"self",
".",
"lazy",
"and",
"not",
"self",
".",
"ready",
":",
"return",
"None",
"logger",
"=",
"self",
".",
"get_logger",
"(",
")",
"ts",
"=",
"... | Method called by core.
Should not be overwritten. | [
"Method",
"called",
"by",
"core",
".",
"Should",
"not",
"be",
"overwritten",
"."
] | 00f7e151e3ce1f3a7f43b353b695c4dba83c7f28 | https://github.com/CodersOfTheNight/oshino/blob/00f7e151e3ce1f3a7f43b353b695c4dba83c7f28/oshino/agents/__init__.py#L40-L55 | train |
CodersOfTheNight/oshino | oshino/agents/__init__.py | Agent.ready | def ready(self):
"""
Function used when agent is `lazy`.
It is being processed only when `ready` condition is satisfied
"""
logger = self.get_logger()
now = current_ts()
logger.trace("Current time: {0}".format(now))
logger.trace("Last Run: {0}".format(self... | python | def ready(self):
"""
Function used when agent is `lazy`.
It is being processed only when `ready` condition is satisfied
"""
logger = self.get_logger()
now = current_ts()
logger.trace("Current time: {0}".format(now))
logger.trace("Last Run: {0}".format(self... | [
"def",
"ready",
"(",
"self",
")",
":",
"logger",
"=",
"self",
".",
"get_logger",
"(",
")",
"now",
"=",
"current_ts",
"(",
")",
"logger",
".",
"trace",
"(",
"\"Current time: {0}\"",
".",
"format",
"(",
"now",
")",
")",
"logger",
".",
"trace",
"(",
"\"... | Function used when agent is `lazy`.
It is being processed only when `ready` condition is satisfied | [
"Function",
"used",
"when",
"agent",
"is",
"lazy",
".",
"It",
"is",
"being",
"processed",
"only",
"when",
"ready",
"condition",
"is",
"satisfied"
] | 00f7e151e3ce1f3a7f43b353b695c4dba83c7f28 | https://github.com/CodersOfTheNight/oshino/blob/00f7e151e3ce1f3a7f43b353b695c4dba83c7f28/oshino/agents/__init__.py#L66-L78 | train |
mardix/Mocha | mocha/contrib/auth/__init__.py | UserModel.create_jwt | def create_jwt(self, expires_in=None):
"""
Create a secure timed JWT token that can be passed. It save the user id,
which later will be used to retrieve the data
:param user: AuthUser, the user's object
:param expires_in: - time in second for the token to expire
:return:... | python | def create_jwt(self, expires_in=None):
"""
Create a secure timed JWT token that can be passed. It save the user id,
which later will be used to retrieve the data
:param user: AuthUser, the user's object
:param expires_in: - time in second for the token to expire
:return:... | [
"def",
"create_jwt",
"(",
"self",
",",
"expires_in",
"=",
"None",
")",
":",
"s",
"=",
"utils",
".",
"sign_jwt",
"(",
"data",
"=",
"{",
"\"id\"",
":",
"self",
".",
"user",
".",
"id",
"}",
",",
"secret_key",
"=",
"get_jwt_secret",
"(",
")",
",",
"sal... | Create a secure timed JWT token that can be passed. It save the user id,
which later will be used to retrieve the data
:param user: AuthUser, the user's object
:param expires_in: - time in second for the token to expire
:return: string | [
"Create",
"a",
"secure",
"timed",
"JWT",
"token",
"that",
"can",
"be",
"passed",
".",
"It",
"save",
"the",
"user",
"id",
"which",
"later",
"will",
"be",
"used",
"to",
"retrieve",
"the",
"data"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/__init__.py#L449-L462 | train |
Kortemme-Lab/klab | klab/comms/mail.py | MailServer.sendgmail | def sendgmail(self, subject, recipients, plaintext, htmltext=None, cc=None, debug=False, useMIMEMultipart=True, gmail_account = 'kortemmelab@gmail.com', pw_filepath = None):
'''For this function to work, the password for the gmail user must be colocated with this file or passed in.'''
smtpserver = smtpl... | python | def sendgmail(self, subject, recipients, plaintext, htmltext=None, cc=None, debug=False, useMIMEMultipart=True, gmail_account = 'kortemmelab@gmail.com', pw_filepath = None):
'''For this function to work, the password for the gmail user must be colocated with this file or passed in.'''
smtpserver = smtpl... | [
"def",
"sendgmail",
"(",
"self",
",",
"subject",
",",
"recipients",
",",
"plaintext",
",",
"htmltext",
"=",
"None",
",",
"cc",
"=",
"None",
",",
"debug",
"=",
"False",
",",
"useMIMEMultipart",
"=",
"True",
",",
"gmail_account",
"=",
"'kortemmelab@gmail.com'"... | For this function to work, the password for the gmail user must be colocated with this file or passed in. | [
"For",
"this",
"function",
"to",
"work",
"the",
"password",
"for",
"the",
"gmail",
"user",
"must",
"be",
"colocated",
"with",
"this",
"file",
"or",
"passed",
"in",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/comms/mail.py#L72-L95 | train |
adaptive-learning/proso-apps | proso_common/views.py | show_one | def show_one(request, post_process_fun, object_class, id, template='common_json.html'):
"""
Return object of the given type with the specified identifier.
GET parameters:
user:
identifier of the current user
stats:
turn on the enrichment of the objects by some statistics
h... | python | def show_one(request, post_process_fun, object_class, id, template='common_json.html'):
"""
Return object of the given type with the specified identifier.
GET parameters:
user:
identifier of the current user
stats:
turn on the enrichment of the objects by some statistics
h... | [
"def",
"show_one",
"(",
"request",
",",
"post_process_fun",
",",
"object_class",
",",
"id",
",",
"template",
"=",
"'common_json.html'",
")",
":",
"obj",
"=",
"get_object_or_404",
"(",
"object_class",
",",
"pk",
"=",
"id",
")",
"json",
"=",
"post_process_fun",
... | Return object of the given type with the specified identifier.
GET parameters:
user:
identifier of the current user
stats:
turn on the enrichment of the objects by some statistics
html
turn on the HTML version of the API | [
"Return",
"object",
"of",
"the",
"given",
"type",
"with",
"the",
"specified",
"identifier",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_common/views.py#L29-L43 | train |
adaptive-learning/proso-apps | proso_common/views.py | show_more | def show_more(request, post_process_fun, get_fun, object_class, should_cache=True, template='common_json.html', to_json_kwargs=None):
"""
Return list of objects of the given type.
GET parameters:
limit:
number of returned objects (default 10, maximum 100)
page:
current page numb... | python | def show_more(request, post_process_fun, get_fun, object_class, should_cache=True, template='common_json.html', to_json_kwargs=None):
"""
Return list of objects of the given type.
GET parameters:
limit:
number of returned objects (default 10, maximum 100)
page:
current page numb... | [
"def",
"show_more",
"(",
"request",
",",
"post_process_fun",
",",
"get_fun",
",",
"object_class",
",",
"should_cache",
"=",
"True",
",",
"template",
"=",
"'common_json.html'",
",",
"to_json_kwargs",
"=",
"None",
")",
":",
"if",
"not",
"should_cache",
"and",
"'... | Return list of objects of the given type.
GET parameters:
limit:
number of returned objects (default 10, maximum 100)
page:
current page number
filter_column:
column name used to filter the results
filter_value:
value for the specified column used to filter t... | [
"Return",
"list",
"of",
"objects",
"of",
"the",
"given",
"type",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_common/views.py#L46-L118 | train |
adaptive-learning/proso-apps | proso_common/views.py | log | def log(request):
"""
Log an event from the client to the server.
POST parameters (JSON keys):
message:
description (str) of the logged event
level:
debug|info|warn|error
data:
additional data (JSON) describing the logged event
"""
if request.method == "POS... | python | def log(request):
"""
Log an event from the client to the server.
POST parameters (JSON keys):
message:
description (str) of the logged event
level:
debug|info|warn|error
data:
additional data (JSON) describing the logged event
"""
if request.method == "POS... | [
"def",
"log",
"(",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"\"POST\"",
":",
"log_dict",
"=",
"json_body",
"(",
"request",
".",
"body",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
"if",
"'message'",
"not",
"in",
"log_dict",
":",
"retur... | Log an event from the client to the server.
POST parameters (JSON keys):
message:
description (str) of the logged event
level:
debug|info|warn|error
data:
additional data (JSON) describing the logged event | [
"Log",
"an",
"event",
"from",
"the",
"client",
"to",
"the",
"server",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_common/views.py#L122-L154 | train |
adaptive-learning/proso-apps | proso_common/views.py | custom_config | def custom_config(request):
"""
Save user-specific configuration property.
POST parameters (JSON keys):
app_name: application name for which the configuration property is
valid (e.g., proso_models)
key: name of the property (e.g., predictive_model.class)
value: value of ... | python | def custom_config(request):
"""
Save user-specific configuration property.
POST parameters (JSON keys):
app_name: application name for which the configuration property is
valid (e.g., proso_models)
key: name of the property (e.g., predictive_model.class)
value: value of ... | [
"def",
"custom_config",
"(",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"config_dict",
"=",
"json_body",
"(",
"request",
".",
"body",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"CustomConfig",
".",
"objects",
".",
"try_create",... | Save user-specific configuration property.
POST parameters (JSON keys):
app_name: application name for which the configuration property is
valid (e.g., proso_models)
key: name of the property (e.g., predictive_model.class)
value: value of the property (number, string, boolean, .... | [
"Save",
"user",
"-",
"specific",
"configuration",
"property",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_common/views.py#L158-L185 | train |
adaptive-learning/proso-apps | proso_common/views.py | languages | def languages(request):
"""
Returns languages that are available in the system.
Returns Dict: language_code -> domain
"""
return render_json(request,
settings.LANGUAGE_DOMAINS if hasattr(settings, 'LANGUAGE_DOMAINS') else
{"error": "Languages are not se... | python | def languages(request):
"""
Returns languages that are available in the system.
Returns Dict: language_code -> domain
"""
return render_json(request,
settings.LANGUAGE_DOMAINS if hasattr(settings, 'LANGUAGE_DOMAINS') else
{"error": "Languages are not se... | [
"def",
"languages",
"(",
"request",
")",
":",
"return",
"render_json",
"(",
"request",
",",
"settings",
".",
"LANGUAGE_DOMAINS",
"if",
"hasattr",
"(",
"settings",
",",
"'LANGUAGE_DOMAINS'",
")",
"else",
"{",
"\"error\"",
":",
"\"Languages are not set. (Set LANGUAGE_... | Returns languages that are available in the system.
Returns Dict: language_code -> domain | [
"Returns",
"languages",
"that",
"are",
"available",
"in",
"the",
"system",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_common/views.py#L192-L201 | train |
reillysiemens/layabout | examples/early-connection/example.py | channel_to_id | def channel_to_id(slack, channel):
""" Surely there's a better way to do this... """
channels = slack.api_call('channels.list').get('channels') or []
groups = slack.api_call('groups.list').get('groups') or []
if not channels and not groups:
raise RuntimeError("Couldn't get channels and groups."... | python | def channel_to_id(slack, channel):
""" Surely there's a better way to do this... """
channels = slack.api_call('channels.list').get('channels') or []
groups = slack.api_call('groups.list').get('groups') or []
if not channels and not groups:
raise RuntimeError("Couldn't get channels and groups."... | [
"def",
"channel_to_id",
"(",
"slack",
",",
"channel",
")",
":",
"channels",
"=",
"slack",
".",
"api_call",
"(",
"'channels.list'",
")",
".",
"get",
"(",
"'channels'",
")",
"or",
"[",
"]",
"groups",
"=",
"slack",
".",
"api_call",
"(",
"'groups.list'",
")"... | Surely there's a better way to do this... | [
"Surely",
"there",
"s",
"a",
"better",
"way",
"to",
"do",
"this",
"..."
] | a146c47f2558e66bb51cf708d39909b93eaea7f4 | https://github.com/reillysiemens/layabout/blob/a146c47f2558e66bb51cf708d39909b93eaea7f4/examples/early-connection/example.py#L15-L28 | train |
reillysiemens/layabout | examples/early-connection/example.py | send_message | def send_message(slack):
""" Prompt for and send a message to a channel. """
channel = input('Which channel would you like to message? ')
message = input('What should the message be? ')
channel_id = channel_to_id(slack, channel)
print(f"Sending message to #{channel} (id: {channel_id})!")
slack.... | python | def send_message(slack):
""" Prompt for and send a message to a channel. """
channel = input('Which channel would you like to message? ')
message = input('What should the message be? ')
channel_id = channel_to_id(slack, channel)
print(f"Sending message to #{channel} (id: {channel_id})!")
slack.... | [
"def",
"send_message",
"(",
"slack",
")",
":",
"channel",
"=",
"input",
"(",
"'Which channel would you like to message? '",
")",
"message",
"=",
"input",
"(",
"'What should the message be? '",
")",
"channel_id",
"=",
"channel_to_id",
"(",
"slack",
",",
"channel",
")... | Prompt for and send a message to a channel. | [
"Prompt",
"for",
"and",
"send",
"a",
"message",
"to",
"a",
"channel",
"."
] | a146c47f2558e66bb51cf708d39909b93eaea7f4 | https://github.com/reillysiemens/layabout/blob/a146c47f2558e66bb51cf708d39909b93eaea7f4/examples/early-connection/example.py#L31-L38 | train |
truveris/py-mdstat | mdstat/device.py | parse_device | def parse_device(lines):
"""Parse all the lines of a device block.
A device block is composed of a header line with the name of the device and
at least one extra line describing the device and its status. The extra
lines have a varying format depending on the status and personality of the
device (... | python | def parse_device(lines):
"""Parse all the lines of a device block.
A device block is composed of a header line with the name of the device and
at least one extra line describing the device and its status. The extra
lines have a varying format depending on the status and personality of the
device (... | [
"def",
"parse_device",
"(",
"lines",
")",
":",
"name",
",",
"status_line",
",",
"device",
"=",
"parse_device_header",
"(",
"lines",
".",
"pop",
"(",
"0",
")",
")",
"if",
"not",
"status_line",
":",
"status_line",
"=",
"lines",
".",
"pop",
"(",
"0",
")",... | Parse all the lines of a device block.
A device block is composed of a header line with the name of the device and
at least one extra line describing the device and its status. The extra
lines have a varying format depending on the status and personality of the
device (e.g. RAID1 vs RAID5, healthy vs ... | [
"Parse",
"all",
"the",
"lines",
"of",
"a",
"device",
"block",
"."
] | 881af99d1168694d2f38e606af377ef6cabe2297 | https://github.com/truveris/py-mdstat/blob/881af99d1168694d2f38e606af377ef6cabe2297/mdstat/device.py#L14-L51 | train |
trendels/rhino | rhino/http.py | match_etag | def match_etag(etag, header, weak=False):
"""Try to match an ETag against a header value.
If `weak` is True, uses the weak comparison function.
"""
if etag is None:
return False
m = etag_re.match(etag)
if not m:
raise ValueError("Not a well-formed ETag: '%s'" % etag)
(is_wea... | python | def match_etag(etag, header, weak=False):
"""Try to match an ETag against a header value.
If `weak` is True, uses the weak comparison function.
"""
if etag is None:
return False
m = etag_re.match(etag)
if not m:
raise ValueError("Not a well-formed ETag: '%s'" % etag)
(is_wea... | [
"def",
"match_etag",
"(",
"etag",
",",
"header",
",",
"weak",
"=",
"False",
")",
":",
"if",
"etag",
"is",
"None",
":",
"return",
"False",
"m",
"=",
"etag_re",
".",
"match",
"(",
"etag",
")",
"if",
"not",
"m",
":",
"raise",
"ValueError",
"(",
"\"Not... | Try to match an ETag against a header value.
If `weak` is True, uses the weak comparison function. | [
"Try",
"to",
"match",
"an",
"ETag",
"against",
"a",
"header",
"value",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/http.py#L60-L79 | train |
trendels/rhino | rhino/http.py | datetime_to_httpdate | def datetime_to_httpdate(dt):
"""Convert datetime.datetime or Unix timestamp to HTTP date."""
if isinstance(dt, (int, float)):
return format_date_time(dt)
elif isinstance(dt, datetime):
return format_date_time(datetime_to_timestamp(dt))
else:
raise TypeError("expected datetime.da... | python | def datetime_to_httpdate(dt):
"""Convert datetime.datetime or Unix timestamp to HTTP date."""
if isinstance(dt, (int, float)):
return format_date_time(dt)
elif isinstance(dt, datetime):
return format_date_time(datetime_to_timestamp(dt))
else:
raise TypeError("expected datetime.da... | [
"def",
"datetime_to_httpdate",
"(",
"dt",
")",
":",
"if",
"isinstance",
"(",
"dt",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"return",
"format_date_time",
"(",
"dt",
")",
"elif",
"isinstance",
"(",
"dt",
",",
"datetime",
")",
":",
"return",
"format... | Convert datetime.datetime or Unix timestamp to HTTP date. | [
"Convert",
"datetime",
".",
"datetime",
"or",
"Unix",
"timestamp",
"to",
"HTTP",
"date",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/http.py#L99-L107 | train |
trendels/rhino | rhino/http.py | timedelta_to_httpdate | def timedelta_to_httpdate(td):
"""Convert datetime.timedelta or number of seconds to HTTP date.
Returns an HTTP date in the future.
"""
if isinstance(td, (int, float)):
return format_date_time(time.time() + td)
elif isinstance(td, timedelta):
return format_date_time(time.time() + to... | python | def timedelta_to_httpdate(td):
"""Convert datetime.timedelta or number of seconds to HTTP date.
Returns an HTTP date in the future.
"""
if isinstance(td, (int, float)):
return format_date_time(time.time() + td)
elif isinstance(td, timedelta):
return format_date_time(time.time() + to... | [
"def",
"timedelta_to_httpdate",
"(",
"td",
")",
":",
"if",
"isinstance",
"(",
"td",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"return",
"format_date_time",
"(",
"time",
".",
"time",
"(",
")",
"+",
"td",
")",
"elif",
"isinstance",
"(",
"td",
",",
... | Convert datetime.timedelta or number of seconds to HTTP date.
Returns an HTTP date in the future. | [
"Convert",
"datetime",
".",
"timedelta",
"or",
"number",
"of",
"seconds",
"to",
"HTTP",
"date",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/http.py#L110-L121 | train |
trendels/rhino | rhino/http.py | cache_control | def cache_control(max_age=None, private=False, public=False, s_maxage=None,
must_revalidate=False, proxy_revalidate=False, no_cache=False,
no_store=False):
"""Generate the value for a Cache-Control header.
Example:
>>> from rhino.http import cache_control as cc
>>> from datetim... | python | def cache_control(max_age=None, private=False, public=False, s_maxage=None,
must_revalidate=False, proxy_revalidate=False, no_cache=False,
no_store=False):
"""Generate the value for a Cache-Control header.
Example:
>>> from rhino.http import cache_control as cc
>>> from datetim... | [
"def",
"cache_control",
"(",
"max_age",
"=",
"None",
",",
"private",
"=",
"False",
",",
"public",
"=",
"False",
",",
"s_maxage",
"=",
"None",
",",
"must_revalidate",
"=",
"False",
",",
"proxy_revalidate",
"=",
"False",
",",
"no_cache",
"=",
"False",
",",
... | Generate the value for a Cache-Control header.
Example:
>>> from rhino.http import cache_control as cc
>>> from datetime import timedelta
>>> cc(public=1, max_age=3600)
'public, max-age=3600'
>>> cc(public=1, max_age=timedelta(hours=1))
'public, max-age=3600'
... | [
"Generate",
"the",
"value",
"for",
"a",
"Cache",
"-",
"Control",
"header",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/http.py#L124-L156 | train |
chrillux/brottsplatskartan | brottsplatskartan/__init__.py | BrottsplatsKartan.get_incidents | def get_incidents(self) -> Union[list, bool]:
""" Get today's incidents. """
brotts_entries_left = True
incidents_today = []
url = self.url
while brotts_entries_left:
requests_response = requests.get(
url, params=self.parameters)
rate_li... | python | def get_incidents(self) -> Union[list, bool]:
""" Get today's incidents. """
brotts_entries_left = True
incidents_today = []
url = self.url
while brotts_entries_left:
requests_response = requests.get(
url, params=self.parameters)
rate_li... | [
"def",
"get_incidents",
"(",
"self",
")",
"->",
"Union",
"[",
"list",
",",
"bool",
"]",
":",
"brotts_entries_left",
"=",
"True",
"incidents_today",
"=",
"[",
"]",
"url",
"=",
"self",
".",
"url",
"while",
"brotts_entries_left",
":",
"requests_response",
"=",
... | Get today's incidents. | [
"Get",
"today",
"s",
"incidents",
"."
] | f38df4debd1799ddb384e467999d601cffbe9d94 | https://github.com/chrillux/brottsplatskartan/blob/f38df4debd1799ddb384e467999d601cffbe9d94/brottsplatskartan/__init__.py#L42-L92 | train |
TheGhouls/oct | oct/utilities/newproject.py | from_template | def from_template(args):
"""Create a new oct project from existing template
:param Namespace args: command line arguments
"""
project_name = args.name
template = args.template
with tarfile.open(template) as tar:
prefix = os.path.commonprefix(tar.getnames())
check_template(tar.g... | python | def from_template(args):
"""Create a new oct project from existing template
:param Namespace args: command line arguments
"""
project_name = args.name
template = args.template
with tarfile.open(template) as tar:
prefix = os.path.commonprefix(tar.getnames())
check_template(tar.g... | [
"def",
"from_template",
"(",
"args",
")",
":",
"project_name",
"=",
"args",
".",
"name",
"template",
"=",
"args",
".",
"template",
"with",
"tarfile",
".",
"open",
"(",
"template",
")",
"as",
"tar",
":",
"prefix",
"=",
"os",
".",
"path",
".",
"commonpre... | Create a new oct project from existing template
:param Namespace args: command line arguments | [
"Create",
"a",
"new",
"oct",
"project",
"from",
"existing",
"template"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/newproject.py#L39-L50 | train |
TheGhouls/oct | oct/utilities/newproject.py | from_oct | def from_oct(args):
"""Create a new oct project
:param Namespace args: the command line arguments
"""
project_name = args.name
env = Environment(loader=PackageLoader('oct.utilities', 'templates'))
config_content = env.get_template('configuration/config.json').render(script_name='v_user.py')
... | python | def from_oct(args):
"""Create a new oct project
:param Namespace args: the command line arguments
"""
project_name = args.name
env = Environment(loader=PackageLoader('oct.utilities', 'templates'))
config_content = env.get_template('configuration/config.json').render(script_name='v_user.py')
... | [
"def",
"from_oct",
"(",
"args",
")",
":",
"project_name",
"=",
"args",
".",
"name",
"env",
"=",
"Environment",
"(",
"loader",
"=",
"PackageLoader",
"(",
"'oct.utilities'",
",",
"'templates'",
")",
")",
"config_content",
"=",
"env",
".",
"get_template",
"(",
... | Create a new oct project
:param Namespace args: the command line arguments | [
"Create",
"a",
"new",
"oct",
"project"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/newproject.py#L53-L85 | train |
clement-alexandre/TotemBionet | totembionet/src/resource_table/resource_table_with_model.py | ResourceTableWithModel.as_data_frame | def as_data_frame(self) -> pandas.DataFrame:
""" Create a panda DataFrame representation of the resource table. """
header_gene = {}
header_multiplex = {}
headr_transitions = {}
for gene in self.influence_graph.genes:
header_gene[gene] = repr(gene)
header_... | python | def as_data_frame(self) -> pandas.DataFrame:
""" Create a panda DataFrame representation of the resource table. """
header_gene = {}
header_multiplex = {}
headr_transitions = {}
for gene in self.influence_graph.genes:
header_gene[gene] = repr(gene)
header_... | [
"def",
"as_data_frame",
"(",
"self",
")",
"->",
"pandas",
".",
"DataFrame",
":",
"header_gene",
"=",
"{",
"}",
"header_multiplex",
"=",
"{",
"}",
"headr_transitions",
"=",
"{",
"}",
"for",
"gene",
"in",
"self",
".",
"influence_graph",
".",
"genes",
":",
... | Create a panda DataFrame representation of the resource table. | [
"Create",
"a",
"panda",
"DataFrame",
"representation",
"of",
"the",
"resource",
"table",
"."
] | f37a2f9358c1ce49f21c4a868b904da5dcd4614f | https://github.com/clement-alexandre/TotemBionet/blob/f37a2f9358c1ce49f21c4a868b904da5dcd4614f/totembionet/src/resource_table/resource_table_with_model.py#L25-L43 | train |
assamite/creamas | creamas/examples/spiro/spiro_agent_mp.py | SpiroAgent.create | def create(self, r, r_, R=200):
'''Create new spirograph image with given arguments. Returned image is
scaled to agent's preferred image size.
'''
x, y = give_dots(R, r, r_, spins=20)
xy = np.array([x, y]).T
xy = np.array(np.around(xy), dtype=np.int64)
xy = xy[(xy... | python | def create(self, r, r_, R=200):
'''Create new spirograph image with given arguments. Returned image is
scaled to agent's preferred image size.
'''
x, y = give_dots(R, r, r_, spins=20)
xy = np.array([x, y]).T
xy = np.array(np.around(xy), dtype=np.int64)
xy = xy[(xy... | [
"def",
"create",
"(",
"self",
",",
"r",
",",
"r_",
",",
"R",
"=",
"200",
")",
":",
"x",
",",
"y",
"=",
"give_dots",
"(",
"R",
",",
"r",
",",
"r_",
",",
"spins",
"=",
"20",
")",
"xy",
"=",
"np",
".",
"array",
"(",
"[",
"x",
",",
"y",
"]"... | Create new spirograph image with given arguments. Returned image is
scaled to agent's preferred image size. | [
"Create",
"new",
"spirograph",
"image",
"with",
"given",
"arguments",
".",
"Returned",
"image",
"is",
"scaled",
"to",
"agent",
"s",
"preferred",
"image",
"size",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L140-L155 | train |
assamite/creamas | creamas/examples/spiro/spiro_agent_mp.py | SpiroAgent.hedonic_value | def hedonic_value(self, novelty):
'''Given the agent's desired novelty, how good the novelty value is.
Not used if *desired_novelty*=-1
'''
lmax = gaus_pdf(self.desired_novelty, self.desired_novelty, 4)
pdf = gaus_pdf(novelty, self.desired_novelty, 4)
return pdf / lmax | python | def hedonic_value(self, novelty):
'''Given the agent's desired novelty, how good the novelty value is.
Not used if *desired_novelty*=-1
'''
lmax = gaus_pdf(self.desired_novelty, self.desired_novelty, 4)
pdf = gaus_pdf(novelty, self.desired_novelty, 4)
return pdf / lmax | [
"def",
"hedonic_value",
"(",
"self",
",",
"novelty",
")",
":",
"lmax",
"=",
"gaus_pdf",
"(",
"self",
".",
"desired_novelty",
",",
"self",
".",
"desired_novelty",
",",
"4",
")",
"pdf",
"=",
"gaus_pdf",
"(",
"novelty",
",",
"self",
".",
"desired_novelty",
... | Given the agent's desired novelty, how good the novelty value is.
Not used if *desired_novelty*=-1 | [
"Given",
"the",
"agent",
"s",
"desired",
"novelty",
"how",
"good",
"the",
"novelty",
"value",
"is",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L170-L177 | train |
assamite/creamas | creamas/examples/spiro/spiro_agent_mp.py | SpiroAgent.evaluate | def evaluate(self, artifact):
'''Evaluate the artifact with respect to the agents short term memory.
Returns value in [0, 1].
'''
if self.desired_novelty > 0:
return self.hedonic_value(self.novelty(artifact.obj))
return self.novelty(artifact.obj) / self.img_size, Non... | python | def evaluate(self, artifact):
'''Evaluate the artifact with respect to the agents short term memory.
Returns value in [0, 1].
'''
if self.desired_novelty > 0:
return self.hedonic_value(self.novelty(artifact.obj))
return self.novelty(artifact.obj) / self.img_size, Non... | [
"def",
"evaluate",
"(",
"self",
",",
"artifact",
")",
":",
"if",
"self",
".",
"desired_novelty",
">",
"0",
":",
"return",
"self",
".",
"hedonic_value",
"(",
"self",
".",
"novelty",
"(",
"artifact",
".",
"obj",
")",
")",
"return",
"self",
".",
"novelty"... | Evaluate the artifact with respect to the agents short term memory.
Returns value in [0, 1]. | [
"Evaluate",
"the",
"artifact",
"with",
"respect",
"to",
"the",
"agents",
"short",
"term",
"memory",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L186-L193 | train |
assamite/creamas | creamas/examples/spiro/spiro_agent_mp.py | SpiroAgent.learn | def learn(self, spiro, iterations=1):
'''Train short term memory with given spirograph.
:param spiro:
:py:class:`SpiroArtifact` object
'''
for i in range(iterations):
self.stmem.train_cycle(spiro.obj.flatten()) | python | def learn(self, spiro, iterations=1):
'''Train short term memory with given spirograph.
:param spiro:
:py:class:`SpiroArtifact` object
'''
for i in range(iterations):
self.stmem.train_cycle(spiro.obj.flatten()) | [
"def",
"learn",
"(",
"self",
",",
"spiro",
",",
"iterations",
"=",
"1",
")",
":",
"for",
"i",
"in",
"range",
"(",
"iterations",
")",
":",
"self",
".",
"stmem",
".",
"train_cycle",
"(",
"spiro",
".",
"obj",
".",
"flatten",
"(",
")",
")"
] | Train short term memory with given spirograph.
:param spiro:
:py:class:`SpiroArtifact` object | [
"Train",
"short",
"term",
"memory",
"with",
"given",
"spirograph",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L292-L299 | train |
assamite/creamas | creamas/examples/spiro/spiro_agent_mp.py | SpiroAgent.plot_places | def plot_places(self):
'''Plot places where the agent has been and generated a spirograph.
'''
from matplotlib import pyplot as plt
fig, ax = plt.subplots()
x = []
y = []
if len(self.arg_history) > 1:
xs = []
ys = []
for p in s... | python | def plot_places(self):
'''Plot places where the agent has been and generated a spirograph.
'''
from matplotlib import pyplot as plt
fig, ax = plt.subplots()
x = []
y = []
if len(self.arg_history) > 1:
xs = []
ys = []
for p in s... | [
"def",
"plot_places",
"(",
"self",
")",
":",
"from",
"matplotlib",
"import",
"pyplot",
"as",
"plt",
"fig",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
")",
"x",
"=",
"[",
"]",
"y",
"=",
"[",
"]",
"if",
"len",
"(",
"self",
".",
"arg_history",
")"... | Plot places where the agent has been and generated a spirograph. | [
"Plot",
"places",
"where",
"the",
"agent",
"has",
"been",
"and",
"generated",
"a",
"spirograph",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L398-L445 | train |
assamite/creamas | creamas/examples/spiro/spiro_agent_mp.py | SpiroMultiEnvironment.destroy | def destroy(self, folder=None):
'''Destroy the environment and the subprocesses.
'''
ameans = [(0, 0, 0) for _ in range(3)]
ret = [self.save_info(folder, ameans)]
aiomas.run(until=self.stop_slaves(folder))
# Close and join the process pool nicely.
self._pool.close... | python | def destroy(self, folder=None):
'''Destroy the environment and the subprocesses.
'''
ameans = [(0, 0, 0) for _ in range(3)]
ret = [self.save_info(folder, ameans)]
aiomas.run(until=self.stop_slaves(folder))
# Close and join the process pool nicely.
self._pool.close... | [
"def",
"destroy",
"(",
"self",
",",
"folder",
"=",
"None",
")",
":",
"ameans",
"=",
"[",
"(",
"0",
",",
"0",
",",
"0",
")",
"for",
"_",
"in",
"range",
"(",
"3",
")",
"]",
"ret",
"=",
"[",
"self",
".",
"save_info",
"(",
"folder",
",",
"ameans"... | Destroy the environment and the subprocesses. | [
"Destroy",
"the",
"environment",
"and",
"the",
"subprocesses",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L704-L715 | train |
Kortemme-Lab/klab | klab/bio/basics.py | Sequence.add | def add(self, r):
'''Takes an id and a Residue r and adds them to the Sequence.'''
id = r.get_residue_id()
if self.order:
last_id = self.order[-1]
# KAB - allow for multiresidue noncanonicals
if id in self.order:
raise colortext.Exception('War... | python | def add(self, r):
'''Takes an id and a Residue r and adds them to the Sequence.'''
id = r.get_residue_id()
if self.order:
last_id = self.order[-1]
# KAB - allow for multiresidue noncanonicals
if id in self.order:
raise colortext.Exception('War... | [
"def",
"add",
"(",
"self",
",",
"r",
")",
":",
"id",
"=",
"r",
".",
"get_residue_id",
"(",
")",
"if",
"self",
".",
"order",
":",
"last_id",
"=",
"self",
".",
"order",
"[",
"-",
"1",
"]",
"if",
"id",
"in",
"self",
".",
"order",
":",
"raise",
"... | Takes an id and a Residue r and adds them to the Sequence. | [
"Takes",
"an",
"id",
"and",
"a",
"Residue",
"r",
"and",
"adds",
"them",
"to",
"the",
"Sequence",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L381-L396 | train |
Kortemme-Lab/klab | klab/bio/basics.py | Sequence.set_type | def set_type(self, sequence_type):
'''Set the type of a Sequence if it has not been set.'''
if not(self.sequence_type):
for id, r in self.sequence.iteritems():
assert(r.residue_type == None)
r.residue_type = sequence_type
self.sequence_type = seque... | python | def set_type(self, sequence_type):
'''Set the type of a Sequence if it has not been set.'''
if not(self.sequence_type):
for id, r in self.sequence.iteritems():
assert(r.residue_type == None)
r.residue_type = sequence_type
self.sequence_type = seque... | [
"def",
"set_type",
"(",
"self",
",",
"sequence_type",
")",
":",
"if",
"not",
"(",
"self",
".",
"sequence_type",
")",
":",
"for",
"id",
",",
"r",
"in",
"self",
".",
"sequence",
".",
"iteritems",
"(",
")",
":",
"assert",
"(",
"r",
".",
"residue_type",
... | Set the type of a Sequence if it has not been set. | [
"Set",
"the",
"type",
"of",
"a",
"Sequence",
"if",
"it",
"has",
"not",
"been",
"set",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L398-L404 | train |
Kortemme-Lab/klab | klab/bio/basics.py | Sequence.from_sequence | def from_sequence(chain, list_of_residues, sequence_type = None):
'''Takes in a chain identifier and protein sequence and returns a Sequence object of Residues, indexed from 1.'''
s = Sequence(sequence_type)
count = 1
for ResidueAA in list_of_residues:
s.add(Residue(chain, co... | python | def from_sequence(chain, list_of_residues, sequence_type = None):
'''Takes in a chain identifier and protein sequence and returns a Sequence object of Residues, indexed from 1.'''
s = Sequence(sequence_type)
count = 1
for ResidueAA in list_of_residues:
s.add(Residue(chain, co... | [
"def",
"from_sequence",
"(",
"chain",
",",
"list_of_residues",
",",
"sequence_type",
"=",
"None",
")",
":",
"s",
"=",
"Sequence",
"(",
"sequence_type",
")",
"count",
"=",
"1",
"for",
"ResidueAA",
"in",
"list_of_residues",
":",
"s",
".",
"add",
"(",
"Residu... | Takes in a chain identifier and protein sequence and returns a Sequence object of Residues, indexed from 1. | [
"Takes",
"in",
"a",
"chain",
"identifier",
"and",
"protein",
"sequence",
"and",
"returns",
"a",
"Sequence",
"object",
"of",
"Residues",
"indexed",
"from",
"1",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L413-L420 | train |
Kortemme-Lab/klab | klab/bio/basics.py | SequenceMap.substitution_scores_match | def substitution_scores_match(self, other):
'''Check to make sure that the substitution scores agree. If one map has a null score and the other has a non-null score, we trust the other's score and vice versa.'''
overlap = set(self.substitution_scores.keys()).intersection(set(other.substitution_scores.ke... | python | def substitution_scores_match(self, other):
'''Check to make sure that the substitution scores agree. If one map has a null score and the other has a non-null score, we trust the other's score and vice versa.'''
overlap = set(self.substitution_scores.keys()).intersection(set(other.substitution_scores.ke... | [
"def",
"substitution_scores_match",
"(",
"self",
",",
"other",
")",
":",
"overlap",
"=",
"set",
"(",
"self",
".",
"substitution_scores",
".",
"keys",
"(",
")",
")",
".",
"intersection",
"(",
"set",
"(",
"other",
".",
"substitution_scores",
".",
"keys",
"("... | Check to make sure that the substitution scores agree. If one map has a null score and the other has a non-null score, we trust the other's score and vice versa. | [
"Check",
"to",
"make",
"sure",
"that",
"the",
"substitution",
"scores",
"agree",
".",
"If",
"one",
"map",
"has",
"a",
"null",
"score",
"and",
"the",
"other",
"has",
"a",
"non",
"-",
"null",
"score",
"we",
"trust",
"the",
"other",
"s",
"score",
"and",
... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L465-L472 | train |
Kortemme-Lab/klab | klab/bio/basics.py | ElementCounter.merge | def merge(self, other):
'''Merge two element counters. For all elements, we take the max count from both counters.'''
our_element_frequencies = self.items
their_element_frequencies = other.items
for element_name, freq in sorted(our_element_frequencies.iteritems()):
our_elemen... | python | def merge(self, other):
'''Merge two element counters. For all elements, we take the max count from both counters.'''
our_element_frequencies = self.items
their_element_frequencies = other.items
for element_name, freq in sorted(our_element_frequencies.iteritems()):
our_elemen... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"our_element_frequencies",
"=",
"self",
".",
"items",
"their_element_frequencies",
"=",
"other",
".",
"items",
"for",
"element_name",
",",
"freq",
"in",
"sorted",
"(",
"our_element_frequencies",
".",
"iteritem... | Merge two element counters. For all elements, we take the max count from both counters. | [
"Merge",
"two",
"element",
"counters",
".",
"For",
"all",
"elements",
"we",
"take",
"the",
"max",
"count",
"from",
"both",
"counters",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L721-L729 | train |
gamechanger/avro_codec | avro_codec/__init__.py | AvroCodec.dump | def dump(self, obj, fp):
"""
Serializes obj as an avro-format byte stream to the provided
fp file-like object stream.
"""
if not validate(obj, self._raw_schema):
raise AvroTypeException(self._avro_schema, obj)
fastavro_write_data(fp, obj, self._raw_schema) | python | def dump(self, obj, fp):
"""
Serializes obj as an avro-format byte stream to the provided
fp file-like object stream.
"""
if not validate(obj, self._raw_schema):
raise AvroTypeException(self._avro_schema, obj)
fastavro_write_data(fp, obj, self._raw_schema) | [
"def",
"dump",
"(",
"self",
",",
"obj",
",",
"fp",
")",
":",
"if",
"not",
"validate",
"(",
"obj",
",",
"self",
".",
"_raw_schema",
")",
":",
"raise",
"AvroTypeException",
"(",
"self",
".",
"_avro_schema",
",",
"obj",
")",
"fastavro_write_data",
"(",
"f... | Serializes obj as an avro-format byte stream to the provided
fp file-like object stream. | [
"Serializes",
"obj",
"as",
"an",
"avro",
"-",
"format",
"byte",
"stream",
"to",
"the",
"provided",
"fp",
"file",
"-",
"like",
"object",
"stream",
"."
] | 57468bee8972a26b31b16a3437b3eeaa5ace2af6 | https://github.com/gamechanger/avro_codec/blob/57468bee8972a26b31b16a3437b3eeaa5ace2af6/avro_codec/__init__.py#L14-L21 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.