id
int32
0
252k
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
244,500
scottgigante/tasklogger
tasklogger/api.py
log_warning
def log_warning(msg, logger="TaskLogger"): """Log a WARNING message Convenience function to log a message to the default Logger Parameters ---------- msg : str Message to be logged logger : str, optional (default: "TaskLogger") Unique name of the logger to retrieve Returns...
python
def log_warning(msg, logger="TaskLogger"): """Log a WARNING message Convenience function to log a message to the default Logger Parameters ---------- msg : str Message to be logged logger : str, optional (default: "TaskLogger") Unique name of the logger to retrieve Returns...
[ "def", "log_warning", "(", "msg", ",", "logger", "=", "\"TaskLogger\"", ")", ":", "tasklogger", "=", "get_tasklogger", "(", "logger", ")", "tasklogger", ".", "warning", "(", "msg", ")", "return", "tasklogger" ]
Log a WARNING message Convenience function to log a message to the default Logger Parameters ---------- msg : str Message to be logged logger : str, optional (default: "TaskLogger") Unique name of the logger to retrieve Returns ------- logger : TaskLogger
[ "Log", "a", "WARNING", "message" ]
06a263715d2db0653615c17b2df14b8272967b8d
https://github.com/scottgigante/tasklogger/blob/06a263715d2db0653615c17b2df14b8272967b8d/tasklogger/api.py#L110-L128
244,501
scottgigante/tasklogger
tasklogger/api.py
log_error
def log_error(msg, logger="TaskLogger"): """Log an ERROR message Convenience function to log a message to the default Logger Parameters ---------- msg : str Message to be logged logger : str, optional (default: "TaskLogger") Unique name of the logger to retrieve Returns ...
python
def log_error(msg, logger="TaskLogger"): """Log an ERROR message Convenience function to log a message to the default Logger Parameters ---------- msg : str Message to be logged logger : str, optional (default: "TaskLogger") Unique name of the logger to retrieve Returns ...
[ "def", "log_error", "(", "msg", ",", "logger", "=", "\"TaskLogger\"", ")", ":", "tasklogger", "=", "get_tasklogger", "(", "logger", ")", "tasklogger", ".", "error", "(", "msg", ")", "return", "tasklogger" ]
Log an ERROR message Convenience function to log a message to the default Logger Parameters ---------- msg : str Message to be logged logger : str, optional (default: "TaskLogger") Unique name of the logger to retrieve Returns ------- logger : TaskLogger
[ "Log", "an", "ERROR", "message" ]
06a263715d2db0653615c17b2df14b8272967b8d
https://github.com/scottgigante/tasklogger/blob/06a263715d2db0653615c17b2df14b8272967b8d/tasklogger/api.py#L131-L149
244,502
scottgigante/tasklogger
tasklogger/api.py
log_critical
def log_critical(msg, logger="TaskLogger"): """Log a CRITICAL message Convenience function to log a message to the default Logger Parameters ---------- msg : str Message to be logged name : `str`, optional (default: "TaskLogger") Name used to retrieve the unique TaskLogger ...
python
def log_critical(msg, logger="TaskLogger"): """Log a CRITICAL message Convenience function to log a message to the default Logger Parameters ---------- msg : str Message to be logged name : `str`, optional (default: "TaskLogger") Name used to retrieve the unique TaskLogger ...
[ "def", "log_critical", "(", "msg", ",", "logger", "=", "\"TaskLogger\"", ")", ":", "tasklogger", "=", "get_tasklogger", "(", "logger", ")", "tasklogger", ".", "critical", "(", "msg", ")", "return", "tasklogger" ]
Log a CRITICAL message Convenience function to log a message to the default Logger Parameters ---------- msg : str Message to be logged name : `str`, optional (default: "TaskLogger") Name used to retrieve the unique TaskLogger Returns ------- logger : TaskLogger
[ "Log", "a", "CRITICAL", "message" ]
06a263715d2db0653615c17b2df14b8272967b8d
https://github.com/scottgigante/tasklogger/blob/06a263715d2db0653615c17b2df14b8272967b8d/tasklogger/api.py#L152-L170
244,503
scottgigante/tasklogger
tasklogger/api.py
set_indent
def set_indent(indent=2, logger="TaskLogger"): """Set the indent function Convenience function to set the indent size Parameters ---------- indent : int, optional (default: 2) number of spaces by which to indent based on the number of tasks currently running` Returns -----...
python
def set_indent(indent=2, logger="TaskLogger"): """Set the indent function Convenience function to set the indent size Parameters ---------- indent : int, optional (default: 2) number of spaces by which to indent based on the number of tasks currently running` Returns -----...
[ "def", "set_indent", "(", "indent", "=", "2", ",", "logger", "=", "\"TaskLogger\"", ")", ":", "tasklogger", "=", "get_tasklogger", "(", "logger", ")", "tasklogger", ".", "set_indent", "(", "indent", ")", "return", "tasklogger" ]
Set the indent function Convenience function to set the indent size Parameters ---------- indent : int, optional (default: 2) number of spaces by which to indent based on the number of tasks currently running` Returns ------- logger : TaskLogger
[ "Set", "the", "indent", "function" ]
06a263715d2db0653615c17b2df14b8272967b8d
https://github.com/scottgigante/tasklogger/blob/06a263715d2db0653615c17b2df14b8272967b8d/tasklogger/api.py#L214-L231
244,504
etcher-be/emiz
emiz/parse_parking_spots.py
main
def main(miz_path): """ Artifact from earlier development """ from emiz.miz import Miz with Miz(miz_path) as m: mis = m.mission result = defaultdict(dict) for unit in mis.units: airport, spot = unit.group_name.split('#') spot = int(spot) # print(airport, int(...
python
def main(miz_path): """ Artifact from earlier development """ from emiz.miz import Miz with Miz(miz_path) as m: mis = m.mission result = defaultdict(dict) for unit in mis.units: airport, spot = unit.group_name.split('#') spot = int(spot) # print(airport, int(...
[ "def", "main", "(", "miz_path", ")", ":", "from", "emiz", ".", "miz", "import", "Miz", "with", "Miz", "(", "miz_path", ")", "as", "m", ":", "mis", "=", "m", ".", "mission", "result", "=", "defaultdict", "(", "dict", ")", "for", "unit", "in", "mis",...
Artifact from earlier development
[ "Artifact", "from", "earlier", "development" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/parse_parking_spots.py#L15-L32
244,505
PSU-OIT-ARC/django-local-settings
local_settings/settings.py
DottedAccessMixin._traverse
def _traverse(self, name, create_missing=False, action=None, value=NO_DEFAULT): """Traverse to the item specified by ``name``. To create missing items on the way to the ``name``d item, pass ``create_missing=True``. This will insert an item for each missing segment in ``name``. The type ...
python
def _traverse(self, name, create_missing=False, action=None, value=NO_DEFAULT): """Traverse to the item specified by ``name``. To create missing items on the way to the ``name``d item, pass ``create_missing=True``. This will insert an item for each missing segment in ``name``. The type ...
[ "def", "_traverse", "(", "self", ",", "name", ",", "create_missing", "=", "False", ",", "action", "=", "None", ",", "value", "=", "NO_DEFAULT", ")", ":", "obj", "=", "self", "segments", "=", "self", ".", "_parse_path", "(", "name", ")", "for", "segment...
Traverse to the item specified by ``name``. To create missing items on the way to the ``name``d item, pass ``create_missing=True``. This will insert an item for each missing segment in ``name``. The type and value of item that will be inserted for a missing segment depends on the *next*...
[ "Traverse", "to", "the", "item", "specified", "by", "name", "." ]
758810fbd9411c2046a187afcac6532155cac694
https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/settings.py#L73-L109
244,506
PSU-OIT-ARC/django-local-settings
local_settings/settings.py
DottedAccessMixin._parse_path
def _parse_path(self, path): """Parse ``path`` into segments. Paths must start with a WORD (i.e., a top level Django setting name). Path segments are separated by dots. Compound path segments (i.e., a name with a dot in it) can be grouped inside parentheses. Examples:: ...
python
def _parse_path(self, path): """Parse ``path`` into segments. Paths must start with a WORD (i.e., a top level Django setting name). Path segments are separated by dots. Compound path segments (i.e., a name with a dot in it) can be grouped inside parentheses. Examples:: ...
[ "def", "_parse_path", "(", "self", ",", "path", ")", ":", "if", "not", "path", ":", "raise", "ValueError", "(", "'path cannot be empty'", ")", "segments", "=", "[", "]", "path_iter", "=", "zip", "(", "iter", "(", "path", ")", ",", "chain", "(", "path",...
Parse ``path`` into segments. Paths must start with a WORD (i.e., a top level Django setting name). Path segments are separated by dots. Compound path segments (i.e., a name with a dot in it) can be grouped inside parentheses. Examples:: >>> settings = Settings() ...
[ "Parse", "path", "into", "segments", "." ]
758810fbd9411c2046a187afcac6532155cac694
https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/settings.py#L137-L249
244,507
PSU-OIT-ARC/django-local-settings
local_settings/settings.py
DottedAccessMixin._convert_name
def _convert_name(self, name): """Convert ``name`` to int if it looks like an int. Otherwise, return it as is. """ if re.search('^\d+$', name): if len(name) > 1 and name[0] == '0': # Don't treat strings beginning with "0" as ints return name ...
python
def _convert_name(self, name): """Convert ``name`` to int if it looks like an int. Otherwise, return it as is. """ if re.search('^\d+$', name): if len(name) > 1 and name[0] == '0': # Don't treat strings beginning with "0" as ints return name ...
[ "def", "_convert_name", "(", "self", ",", "name", ")", ":", "if", "re", ".", "search", "(", "'^\\d+$'", ",", "name", ")", ":", "if", "len", "(", "name", ")", ">", "1", "and", "name", "[", "0", "]", "==", "'0'", ":", "# Don't treat strings beginning w...
Convert ``name`` to int if it looks like an int. Otherwise, return it as is.
[ "Convert", "name", "to", "int", "if", "it", "looks", "like", "an", "int", "." ]
758810fbd9411c2046a187afcac6532155cac694
https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/settings.py#L251-L262
244,508
jucacrispim/asyncamqp
asyncamqp/channel.py
Channel.basic_consume
async def basic_consume(self, queue_name='', consumer_tag='', no_local=False, no_ack=False, exclusive=False, no_wait=False, arguments=None, wait_message=True, timeout=0): """Starts the consumption of message into a queue. ...
python
async def basic_consume(self, queue_name='', consumer_tag='', no_local=False, no_ack=False, exclusive=False, no_wait=False, arguments=None, wait_message=True, timeout=0): """Starts the consumption of message into a queue. ...
[ "async", "def", "basic_consume", "(", "self", ",", "queue_name", "=", "''", ",", "consumer_tag", "=", "''", ",", "no_local", "=", "False", ",", "no_ack", "=", "False", ",", "exclusive", "=", "False", ",", "no_wait", "=", "False", ",", "arguments", "=", ...
Starts the consumption of message into a queue. the callback will be called each time we're receiving a message. Args: queue_name: str, the queue to receive message from consumer_tag: str, optional consumer tag no_local: bool, if set the s...
[ "Starts", "the", "consumption", "of", "message", "into", "a", "queue", ".", "the", "callback", "will", "be", "called", "each", "time", "we", "re", "receiving", "a", "message", "." ]
fa50541ab528f4e0753cb9562c29b0d89d738889
https://github.com/jucacrispim/asyncamqp/blob/fa50541ab528f4e0753cb9562c29b0d89d738889/asyncamqp/channel.py#L48-L106
244,509
SergeySatskiy/cdm-gc-plugin
setup.py
getPluginVersion
def getPluginVersion(): """The version must be updated in the .cdmp file""" desc_file = os.path.join('cdmplugins', 'gc', plugin_desc_file) if not os.path.exists(desc_file): print('Cannot find the plugin description file. Expected here: ' + desc_file, file=sys.stderr) sys.exit(1...
python
def getPluginVersion(): """The version must be updated in the .cdmp file""" desc_file = os.path.join('cdmplugins', 'gc', plugin_desc_file) if not os.path.exists(desc_file): print('Cannot find the plugin description file. Expected here: ' + desc_file, file=sys.stderr) sys.exit(1...
[ "def", "getPluginVersion", "(", ")", ":", "desc_file", "=", "os", ".", "path", ".", "join", "(", "'cdmplugins'", ",", "'gc'", ",", "plugin_desc_file", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "desc_file", ")", ":", "print", "(", "'Canno...
The version must be updated in the .cdmp file
[ "The", "version", "must", "be", "updated", "in", "the", ".", "cdmp", "file" ]
f6dd59d5dc80d3f8f5ca5bcf49bad86c88be38df
https://github.com/SergeySatskiy/cdm-gc-plugin/blob/f6dd59d5dc80d3f8f5ca5bcf49bad86c88be38df/setup.py#L30-L45
244,510
fusionapp/fusion-util
fusion_util/cert.py
chainCerts
def chainCerts(data): """ Matches and returns any certificates found except the first match. Regex code copied from L{twisted.internet.endpoints._parseSSL}. Related ticket: https://twistedmatrix.com/trac/ticket/7732 @type path: L{bytes} @param data: PEM-encoded data containing the certificates...
python
def chainCerts(data): """ Matches and returns any certificates found except the first match. Regex code copied from L{twisted.internet.endpoints._parseSSL}. Related ticket: https://twistedmatrix.com/trac/ticket/7732 @type path: L{bytes} @param data: PEM-encoded data containing the certificates...
[ "def", "chainCerts", "(", "data", ")", ":", "matches", "=", "re", ".", "findall", "(", "r'(-----BEGIN CERTIFICATE-----\\n.+?\\n-----END CERTIFICATE-----)'", ",", "data", ",", "flags", "=", "re", ".", "DOTALL", ")", "chainCertificates", "=", "[", "Certificate", "."...
Matches and returns any certificates found except the first match. Regex code copied from L{twisted.internet.endpoints._parseSSL}. Related ticket: https://twistedmatrix.com/trac/ticket/7732 @type path: L{bytes} @param data: PEM-encoded data containing the certificates. @rtype: L{list} containing ...
[ "Matches", "and", "returns", "any", "certificates", "found", "except", "the", "first", "match", "." ]
089c525799926c8b8bf1117ab22ed055dc99c7e6
https://github.com/fusionapp/fusion-util/blob/089c525799926c8b8bf1117ab22ed055dc99c7e6/fusion_util/cert.py#L13-L32
244,511
stephanepechard/projy
projy/templates/DjangoProjectTemplate.py
DjangoProjectTemplate.directories
def directories(self): """ Return the names of directories to be created. """ directories_description = [ self.project_name, self.project_name + '/conf', self.project_name + '/static', ] return directories_description
python
def directories(self): """ Return the names of directories to be created. """ directories_description = [ self.project_name, self.project_name + '/conf', self.project_name + '/static', ] return directories_description
[ "def", "directories", "(", "self", ")", ":", "directories_description", "=", "[", "self", ".", "project_name", ",", "self", ".", "project_name", "+", "'/conf'", ",", "self", ".", "project_name", "+", "'/static'", ",", "]", "return", "directories_description" ]
Return the names of directories to be created.
[ "Return", "the", "names", "of", "directories", "to", "be", "created", "." ]
3146b0e3c207b977e1b51fcb33138746dae83c23
https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/templates/DjangoProjectTemplate.py#L23-L30
244,512
alexpearce/jobmonitor
jobmonitor/FlaskWithJobResolvers.py
FlaskWithJobResolvers.remove_job_resolver
def remove_job_resolver(self, job_resolver): """Remove job_resolver from the list of job resolvers. Keyword arguments: job_resolver -- Function reference of the job resolver to be removed. """ for i, r in enumerate(self.job_resolvers()): if job_resolver == r: ...
python
def remove_job_resolver(self, job_resolver): """Remove job_resolver from the list of job resolvers. Keyword arguments: job_resolver -- Function reference of the job resolver to be removed. """ for i, r in enumerate(self.job_resolvers()): if job_resolver == r: ...
[ "def", "remove_job_resolver", "(", "self", ",", "job_resolver", ")", ":", "for", "i", ",", "r", "in", "enumerate", "(", "self", ".", "job_resolvers", "(", ")", ")", ":", "if", "job_resolver", "==", "r", ":", "del", "self", ".", "_job_resolvers", "[", "...
Remove job_resolver from the list of job resolvers. Keyword arguments: job_resolver -- Function reference of the job resolver to be removed.
[ "Remove", "job_resolver", "from", "the", "list", "of", "job", "resolvers", "." ]
c08955ed3c357b2b3518aa0853b43bc237bc0814
https://github.com/alexpearce/jobmonitor/blob/c08955ed3c357b2b3518aa0853b43bc237bc0814/jobmonitor/FlaskWithJobResolvers.py#L60-L68
244,513
alexpearce/jobmonitor
jobmonitor/FlaskWithJobResolvers.py
FlaskWithJobResolvers.resolve_job
def resolve_job(self, name): """Attempt to resolve the task name in to a job name. If no job resolver can resolve the task, i.e. they all return None, return None. Keyword arguments: name -- Name of the task to be resolved. """ for r in self.job_resolvers(): ...
python
def resolve_job(self, name): """Attempt to resolve the task name in to a job name. If no job resolver can resolve the task, i.e. they all return None, return None. Keyword arguments: name -- Name of the task to be resolved. """ for r in self.job_resolvers(): ...
[ "def", "resolve_job", "(", "self", ",", "name", ")", ":", "for", "r", "in", "self", ".", "job_resolvers", "(", ")", ":", "resolved_name", "=", "r", "(", "name", ")", "if", "resolved_name", "is", "not", "None", ":", "return", "resolved_name", "return", ...
Attempt to resolve the task name in to a job name. If no job resolver can resolve the task, i.e. they all return None, return None. Keyword arguments: name -- Name of the task to be resolved.
[ "Attempt", "to", "resolve", "the", "task", "name", "in", "to", "a", "job", "name", "." ]
c08955ed3c357b2b3518aa0853b43bc237bc0814
https://github.com/alexpearce/jobmonitor/blob/c08955ed3c357b2b3518aa0853b43bc237bc0814/jobmonitor/FlaskWithJobResolvers.py#L70-L83
244,514
tripzero/python-photons
photons/lightprotocol.py
LightProtocol.setColor
def setColor(self, id, color): """ Command 0x01 sets the color of a specific light Data: [Command][Number_Lights_to_set][id_1][r][g][b][id_n][r][g][b]... """ header = bytearray() header.append(LightProtocolCommand.SetColor) if not isinstance(id, list): id = [id] if not isinstance(color, list)...
python
def setColor(self, id, color): """ Command 0x01 sets the color of a specific light Data: [Command][Number_Lights_to_set][id_1][r][g][b][id_n][r][g][b]... """ header = bytearray() header.append(LightProtocolCommand.SetColor) if not isinstance(id, list): id = [id] if not isinstance(color, list)...
[ "def", "setColor", "(", "self", ",", "id", ",", "color", ")", ":", "header", "=", "bytearray", "(", ")", "header", ".", "append", "(", "LightProtocolCommand", ".", "SetColor", ")", "if", "not", "isinstance", "(", "id", ",", "list", ")", ":", "id", "=...
Command 0x01 sets the color of a specific light Data: [Command][Number_Lights_to_set][id_1][r][g][b][id_n][r][g][b]...
[ "Command", "0x01", "sets", "the", "color", "of", "a", "specific", "light" ]
e185bbb55881189c7deeb599384944e61cf6048d
https://github.com/tripzero/python-photons/blob/e185bbb55881189c7deeb599384944e61cf6048d/photons/lightprotocol.py#L160-L190
244,515
tripzero/python-photons
photons/lightprotocol.py
LightProtocol.setSeries
def setSeries(self, startId, length, color): """ Command 0x07 sets all lights in the series starting from "startId" to "endId" to "color" Data: [0x07][startId][length][r][g][b] """ buff = bytearray() buff.append(LightProtocolCommand.SetSeries) buff.extend(struct.pack('<H', startId)) buff.extend(st...
python
def setSeries(self, startId, length, color): """ Command 0x07 sets all lights in the series starting from "startId" to "endId" to "color" Data: [0x07][startId][length][r][g][b] """ buff = bytearray() buff.append(LightProtocolCommand.SetSeries) buff.extend(struct.pack('<H', startId)) buff.extend(st...
[ "def", "setSeries", "(", "self", ",", "startId", ",", "length", ",", "color", ")", ":", "buff", "=", "bytearray", "(", ")", "buff", ".", "append", "(", "LightProtocolCommand", ".", "SetSeries", ")", "buff", ".", "extend", "(", "struct", ".", "pack", "(...
Command 0x07 sets all lights in the series starting from "startId" to "endId" to "color" Data: [0x07][startId][length][r][g][b]
[ "Command", "0x07", "sets", "all", "lights", "in", "the", "series", "starting", "from", "startId", "to", "endId", "to", "color" ]
e185bbb55881189c7deeb599384944e61cf6048d
https://github.com/tripzero/python-photons/blob/e185bbb55881189c7deeb599384944e61cf6048d/photons/lightprotocol.py#L192-L207
244,516
dossier/dossier.models
dossier/models/web/routes.py
v0_highlighter_post
def v0_highlighter_post(request, response, tfidf, cid): '''Obtain highlights for a document POSTed as the body, which is the pre-design-thinking structure of the highlights API. See v1 below. NB: This end point will soon be deleted. The route for this endpoint is: ``POST /dossier/v0/highlighter/<...
python
def v0_highlighter_post(request, response, tfidf, cid): '''Obtain highlights for a document POSTed as the body, which is the pre-design-thinking structure of the highlights API. See v1 below. NB: This end point will soon be deleted. The route for this endpoint is: ``POST /dossier/v0/highlighter/<...
[ "def", "v0_highlighter_post", "(", "request", ",", "response", ",", "tfidf", ",", "cid", ")", ":", "logger", ".", "info", "(", "'got %r'", ",", "cid", ")", "tfidf", "=", "tfidf", "or", "None", "content_type", "=", "request", ".", "headers", ".", "get", ...
Obtain highlights for a document POSTed as the body, which is the pre-design-thinking structure of the highlights API. See v1 below. NB: This end point will soon be deleted. The route for this endpoint is: ``POST /dossier/v0/highlighter/<cid>``. ``content_id`` is the id to associate with the giv...
[ "Obtain", "highlights", "for", "a", "document", "POSTed", "as", "the", "body", "which", "is", "the", "pre", "-", "design", "-", "thinking", "structure", "of", "the", "highlights", "API", ".", "See", "v1", "below", "." ]
c9e282f690eab72963926329efe1600709e48b13
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L289-L331
244,517
dossier/dossier.models
dossier/models/web/routes.py
v1_highlights_get
def v1_highlights_get(response, kvlclient, file_id_str, max_elapsed = 300): '''Obtain highlights for a document POSTed previously to this end point. See documentation for v1_highlights_post for further details. If the `state` is still `pending` for more than `max_elapsed` after the start of the `WorkU...
python
def v1_highlights_get(response, kvlclient, file_id_str, max_elapsed = 300): '''Obtain highlights for a document POSTed previously to this end point. See documentation for v1_highlights_post for further details. If the `state` is still `pending` for more than `max_elapsed` after the start of the `WorkU...
[ "def", "v1_highlights_get", "(", "response", ",", "kvlclient", ",", "file_id_str", ",", "max_elapsed", "=", "300", ")", ":", "file_id", "=", "make_file_id", "(", "file_id_str", ")", "kvlclient", ".", "setup_namespace", "(", "highlights_kvlayer_tables", ")", "paylo...
Obtain highlights for a document POSTed previously to this end point. See documentation for v1_highlights_post for further details. If the `state` is still `pending` for more than `max_elapsed` after the start of the `WorkUnit`, then this reports an error, although the `WorkUnit` may continue in the b...
[ "Obtain", "highlights", "for", "a", "document", "POSTed", "previously", "to", "this", "end", "point", ".", "See", "documentation", "for", "v1_highlights_post", "for", "further", "details", ".", "If", "the", "state", "is", "still", "pending", "for", "more", "th...
c9e282f690eab72963926329efe1600709e48b13
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L345-L393
244,518
dossier/dossier.models
dossier/models/web/routes.py
create_highlights
def create_highlights(data, tfidf): '''compute highlights for `data`, store it in the store using `kvlclient`, and return a `highlights` response payload. ''' try: fc = etl.create_fc_from_html( data['content-location'], data['body'], tfidf=tfidf, encoding=None) except Exception,...
python
def create_highlights(data, tfidf): '''compute highlights for `data`, store it in the store using `kvlclient`, and return a `highlights` response payload. ''' try: fc = etl.create_fc_from_html( data['content-location'], data['body'], tfidf=tfidf, encoding=None) except Exception,...
[ "def", "create_highlights", "(", "data", ",", "tfidf", ")", ":", "try", ":", "fc", "=", "etl", ".", "create_fc_from_html", "(", "data", "[", "'content-location'", "]", ",", "data", "[", "'body'", "]", ",", "tfidf", "=", "tfidf", ",", "encoding", "=", "...
compute highlights for `data`, store it in the store using `kvlclient`, and return a `highlights` response payload.
[ "compute", "highlights", "for", "data", "store", "it", "in", "the", "store", "using", "kvlclient", "and", "return", "a", "highlights", "response", "payload", "." ]
c9e282f690eab72963926329efe1600709e48b13
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L744-L798
244,519
dossier/dossier.models
dossier/models/web/routes.py
make_xpath_ranges
def make_xpath_ranges(html, phrase): '''Given a HTML string and a `phrase`, build a regex to find offsets for the phrase, and then build a list of `XPathRange` objects for it. If this fails, return empty list. ''' if not html: return [] if not isinstance(phrase, unicode): try: ...
python
def make_xpath_ranges(html, phrase): '''Given a HTML string and a `phrase`, build a regex to find offsets for the phrase, and then build a list of `XPathRange` objects for it. If this fails, return empty list. ''' if not html: return [] if not isinstance(phrase, unicode): try: ...
[ "def", "make_xpath_ranges", "(", "html", ",", "phrase", ")", ":", "if", "not", "html", ":", "return", "[", "]", "if", "not", "isinstance", "(", "phrase", ",", "unicode", ")", ":", "try", ":", "phrase", "=", "phrase", ".", "decode", "(", "'utf8'", ")"...
Given a HTML string and a `phrase`, build a regex to find offsets for the phrase, and then build a list of `XPathRange` objects for it. If this fails, return empty list.
[ "Given", "a", "HTML", "string", "and", "a", "phrase", "build", "a", "regex", "to", "find", "offsets", "for", "the", "phrase", "and", "then", "build", "a", "list", "of", "XPathRange", "objects", "for", "it", ".", "If", "this", "fails", "return", "empty", ...
c9e282f690eab72963926329efe1600709e48b13
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L835-L871
244,520
lwcook/horsetail-matching
horsetailmatching/surrogates.py
eval_poly
def eval_poly(uvec, nvec, Jvec): '''Evaluate multi-dimensional polynomials through tensor multiplication. :param list uvec: vector value of the uncertain parameters at which to evaluate the polynomial :param list nvec: order in each dimension at which to evaluate the polynomial :param list Jv...
python
def eval_poly(uvec, nvec, Jvec): '''Evaluate multi-dimensional polynomials through tensor multiplication. :param list uvec: vector value of the uncertain parameters at which to evaluate the polynomial :param list nvec: order in each dimension at which to evaluate the polynomial :param list Jv...
[ "def", "eval_poly", "(", "uvec", ",", "nvec", ",", "Jvec", ")", ":", "us", "=", "_makeIter", "(", "uvec", ")", "ns", "=", "_makeIter", "(", "nvec", ")", "Js", "=", "_makeIter", "(", "Jvec", ")", "return", "np", ".", "prod", "(", "[", "_eval_poly_1D...
Evaluate multi-dimensional polynomials through tensor multiplication. :param list uvec: vector value of the uncertain parameters at which to evaluate the polynomial :param list nvec: order in each dimension at which to evaluate the polynomial :param list Jvec: Jacobi matrix of each dimension's 1D...
[ "Evaluate", "multi", "-", "dimensional", "polynomials", "through", "tensor", "multiplication", "." ]
f3d5f8d01249debbca978f412ce4eae017458119
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/surrogates.py#L186-L204
244,521
lwcook/horsetail-matching
horsetailmatching/surrogates.py
PolySurrogate.train
def train(self, ftrain): '''Trains the polynomial expansion. :param numpy.ndarray/function ftrain: output values corresponding to the quadrature points given by the getQuadraturePoints method to which the expansion should be trained. Or a function that should be evaluated ...
python
def train(self, ftrain): '''Trains the polynomial expansion. :param numpy.ndarray/function ftrain: output values corresponding to the quadrature points given by the getQuadraturePoints method to which the expansion should be trained. Or a function that should be evaluated ...
[ "def", "train", "(", "self", ",", "ftrain", ")", ":", "self", ".", "coeffs", "=", "0", "*", "self", ".", "coeffs", "upoints", ",", "wpoints", "=", "self", ".", "getQuadraturePointsAndWeights", "(", ")", "try", ":", "fpoints", "=", "[", "ftrain", "(", ...
Trains the polynomial expansion. :param numpy.ndarray/function ftrain: output values corresponding to the quadrature points given by the getQuadraturePoints method to which the expansion should be trained. Or a function that should be evaluated at the quadrature points to gi...
[ "Trains", "the", "polynomial", "expansion", "." ]
f3d5f8d01249debbca978f412ce4eae017458119
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/surrogates.py#L100-L138
244,522
lwcook/horsetail-matching
horsetailmatching/surrogates.py
PolySurrogate.getQuadraturePointsAndWeights
def getQuadraturePointsAndWeights(self): '''Gets the quadrature points and weights for gaussian quadrature integration of inner products from the definition of the polynomials in each dimension. :return: (u_points, w_points) - np.ndarray of shape (num_polynomials, num_dimen...
python
def getQuadraturePointsAndWeights(self): '''Gets the quadrature points and weights for gaussian quadrature integration of inner products from the definition of the polynomials in each dimension. :return: (u_points, w_points) - np.ndarray of shape (num_polynomials, num_dimen...
[ "def", "getQuadraturePointsAndWeights", "(", "self", ")", ":", "qw_list", ",", "qp_list", "=", "[", "]", ",", "[", "]", "for", "ii", "in", "np", ".", "arange", "(", "len", "(", "self", ".", "J_list", ")", ")", ":", "d", ",", "Q", "=", "np", ".", ...
Gets the quadrature points and weights for gaussian quadrature integration of inner products from the definition of the polynomials in each dimension. :return: (u_points, w_points) - np.ndarray of shape (num_polynomials, num_dimensions) and a np.ndarray of size (num_pol...
[ "Gets", "the", "quadrature", "points", "and", "weights", "for", "gaussian", "quadrature", "integration", "of", "inner", "products", "from", "the", "definition", "of", "the", "polynomials", "in", "each", "dimension", "." ]
f3d5f8d01249debbca978f412ce4eae017458119
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/surrogates.py#L140-L169
244,523
kolypto/py-exdoc
exdoc/sa/__init__.py
_model_columns
def _model_columns(ins): """ Get columns info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[SaColumnDoc] """ columns = [] for c in ins.column_attrs: # Skip protected if c.key.startswith('_'): continue # Collect columns.append(SaColumnDoc( ...
python
def _model_columns(ins): """ Get columns info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[SaColumnDoc] """ columns = [] for c in ins.column_attrs: # Skip protected if c.key.startswith('_'): continue # Collect columns.append(SaColumnDoc( ...
[ "def", "_model_columns", "(", "ins", ")", ":", "columns", "=", "[", "]", "for", "c", "in", "ins", ".", "column_attrs", ":", "# Skip protected", "if", "c", ".", "key", ".", "startswith", "(", "'_'", ")", ":", "continue", "# Collect", "columns", ".", "ap...
Get columns info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[SaColumnDoc]
[ "Get", "columns", "info" ]
516526c01c203271410e7d7340024ef9f0bfa46a
https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L55-L74
244,524
kolypto/py-exdoc
exdoc/sa/__init__.py
_model_foreign
def _model_foreign(ins): """ Get foreign keys info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[SaForeignkeyDoc] """ fks = [] for t in ins.tables: fks.extend([ SaForeignkeyDoc( key=fk.column.key, target=fk.target_fullname, ...
python
def _model_foreign(ins): """ Get foreign keys info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[SaForeignkeyDoc] """ fks = [] for t in ins.tables: fks.extend([ SaForeignkeyDoc( key=fk.column.key, target=fk.target_fullname, ...
[ "def", "_model_foreign", "(", "ins", ")", ":", "fks", "=", "[", "]", "for", "t", "in", "ins", ".", "tables", ":", "fks", ".", "extend", "(", "[", "SaForeignkeyDoc", "(", "key", "=", "fk", ".", "column", ".", "key", ",", "target", "=", "fk", ".", ...
Get foreign keys info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[SaForeignkeyDoc]
[ "Get", "foreign", "keys", "info" ]
516526c01c203271410e7d7340024ef9f0bfa46a
https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L86-L102
244,525
kolypto/py-exdoc
exdoc/sa/__init__.py
_model_unique
def _model_unique(ins): """ Get unique constraints info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[tuple[str]] """ unique = [] for t in ins.tables: for c in t.constraints: if isinstance(c, UniqueConstraint): unique.append(tuple(col.key for col in c....
python
def _model_unique(ins): """ Get unique constraints info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[tuple[str]] """ unique = [] for t in ins.tables: for c in t.constraints: if isinstance(c, UniqueConstraint): unique.append(tuple(col.key for col in c....
[ "def", "_model_unique", "(", "ins", ")", ":", "unique", "=", "[", "]", "for", "t", "in", "ins", ".", "tables", ":", "for", "c", "in", "t", ".", "constraints", ":", "if", "isinstance", "(", "c", ",", "UniqueConstraint", ")", ":", "unique", ".", "app...
Get unique constraints info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[tuple[str]]
[ "Get", "unique", "constraints", "info" ]
516526c01c203271410e7d7340024ef9f0bfa46a
https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L105-L116
244,526
kolypto/py-exdoc
exdoc/sa/__init__.py
_model_relations
def _model_relations(ins): """ Get relationships info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[SaRelationshipDoc] """ relations = [] for r in ins.relationships: # Hard times with the foreign model :) if isinstance(r.argument, Mapper): model_name = r.argum...
python
def _model_relations(ins): """ Get relationships info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[SaRelationshipDoc] """ relations = [] for r in ins.relationships: # Hard times with the foreign model :) if isinstance(r.argument, Mapper): model_name = r.argum...
[ "def", "_model_relations", "(", "ins", ")", ":", "relations", "=", "[", "]", "for", "r", "in", "ins", ".", "relationships", ":", "# Hard times with the foreign model :)", "if", "isinstance", "(", "r", ".", "argument", ",", "Mapper", ")", ":", "model_name", "...
Get relationships info :type ins: sqlalchemy.orm.mapper.Mapper :rtype: list[SaRelationshipDoc]
[ "Get", "relationships", "info" ]
516526c01c203271410e7d7340024ef9f0bfa46a
https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L119-L143
244,527
kolypto/py-exdoc
exdoc/sa/__init__.py
doc
def doc(model): """ Get documentation object for an SqlAlchemy model :param model: Model :type model: sqlalchemy.ext.declarative.DeclarativeBase :rtype: SaModelDoc """ ins = inspect(model) return SaModelDoc( name=model.__name__, table=[t.name for t in ins.tables], d...
python
def doc(model): """ Get documentation object for an SqlAlchemy model :param model: Model :type model: sqlalchemy.ext.declarative.DeclarativeBase :rtype: SaModelDoc """ ins = inspect(model) return SaModelDoc( name=model.__name__, table=[t.name for t in ins.tables], d...
[ "def", "doc", "(", "model", ")", ":", "ins", "=", "inspect", "(", "model", ")", "return", "SaModelDoc", "(", "name", "=", "model", ".", "__name__", ",", "table", "=", "[", "t", ".", "name", "for", "t", "in", "ins", ".", "tables", "]", ",", "doc",...
Get documentation object for an SqlAlchemy model :param model: Model :type model: sqlalchemy.ext.declarative.DeclarativeBase :rtype: SaModelDoc
[ "Get", "documentation", "object", "for", "an", "SqlAlchemy", "model" ]
516526c01c203271410e7d7340024ef9f0bfa46a
https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L146-L164
244,528
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/utility.py
GetModuleBaseNameFromWSDL
def GetModuleBaseNameFromWSDL(wsdl): """By default try to construct a reasonable base name for all generated modules. Otherwise return None. """ base_name = wsdl.name or wsdl.services[0].name base_name = SplitQName(base_name)[1] if base_name is None: return None return NCName_to_Mo...
python
def GetModuleBaseNameFromWSDL(wsdl): """By default try to construct a reasonable base name for all generated modules. Otherwise return None. """ base_name = wsdl.name or wsdl.services[0].name base_name = SplitQName(base_name)[1] if base_name is None: return None return NCName_to_Mo...
[ "def", "GetModuleBaseNameFromWSDL", "(", "wsdl", ")", ":", "base_name", "=", "wsdl", ".", "name", "or", "wsdl", ".", "services", "[", "0", "]", ".", "name", "base_name", "=", "SplitQName", "(", "base_name", ")", "[", "1", "]", "if", "base_name", "is", ...
By default try to construct a reasonable base name for all generated modules. Otherwise return None.
[ "By", "default", "try", "to", "construct", "a", "reasonable", "base", "name", "for", "all", "generated", "modules", ".", "Otherwise", "return", "None", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/utility.py#L26-L34
244,529
jeroyang/txttk
txttk/retools.py
condense
def condense(ss_unescaped): """ Given multiple strings, returns a compressed regular expression just for these strings >>> condense(['she', 'he', 'her', 'hemoglobin']) 'he(moglobin|r)?|she' """ def estimated_len(longg, short): return (3 + len(short) +...
python
def condense(ss_unescaped): """ Given multiple strings, returns a compressed regular expression just for these strings >>> condense(['she', 'he', 'her', 'hemoglobin']) 'he(moglobin|r)?|she' """ def estimated_len(longg, short): return (3 + len(short) +...
[ "def", "condense", "(", "ss_unescaped", ")", ":", "def", "estimated_len", "(", "longg", ",", "short", ")", ":", "return", "(", "3", "+", "len", "(", "short", ")", "+", "sum", "(", "map", "(", "len", ",", "longg", ")", ")", "-", "len", "(", "longg...
Given multiple strings, returns a compressed regular expression just for these strings >>> condense(['she', 'he', 'her', 'hemoglobin']) 'he(moglobin|r)?|she'
[ "Given", "multiple", "strings", "returns", "a", "compressed", "regular", "expression", "just", "for", "these", "strings" ]
8e6daf9cbb7dfbc4900870fb365add17929bd4ab
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L10-L73
244,530
jeroyang/txttk
txttk/retools.py
is_solid
def is_solid(regex): """ Check the given regular expression is solid. >>> is_solid(r'a') True >>> is_solid(r'[ab]') True >>> is_solid(r'(a|b|c)') True >>> is_solid(r'(a|b|c)?') True >>> is_solid(r'(a|b)(c)') False >>> is_solid(r'(a|b)(c)?') False """ sha...
python
def is_solid(regex): """ Check the given regular expression is solid. >>> is_solid(r'a') True >>> is_solid(r'[ab]') True >>> is_solid(r'(a|b|c)') True >>> is_solid(r'(a|b|c)?') True >>> is_solid(r'(a|b)(c)') False >>> is_solid(r'(a|b)(c)?') False """ sha...
[ "def", "is_solid", "(", "regex", ")", ":", "shape", "=", "re", ".", "sub", "(", "r'(\\\\.|[^\\[\\]\\(\\)\\|\\?\\+\\*])'", ",", "'#'", ",", "regex", ")", "skeleton", "=", "shape", ".", "replace", "(", "'#'", ",", "''", ")", "if", "len", "(", "shape", ")...
Check the given regular expression is solid. >>> is_solid(r'a') True >>> is_solid(r'[ab]') True >>> is_solid(r'(a|b|c)') True >>> is_solid(r'(a|b|c)?') True >>> is_solid(r'(a|b)(c)') False >>> is_solid(r'(a|b)(c)?') False
[ "Check", "the", "given", "regular", "expression", "is", "solid", "." ]
8e6daf9cbb7dfbc4900870fb365add17929bd4ab
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L75-L104
244,531
jeroyang/txttk
txttk/retools.py
danger_unpack
def danger_unpack(regex): """ Remove the outermost parens >>> unpack(r'(abc)') 'abc' >>> unpack(r'(?:abc)') 'abc' >>> unpack(r'(?P<xyz>abc)') 'abc' >>> unpack(r'[abc]') '[abc]' """ if is_packed(regex): return re.sub(r'^\((\?(:|P<.*?>))?(?P<content>.*?)\)$', r'\g...
python
def danger_unpack(regex): """ Remove the outermost parens >>> unpack(r'(abc)') 'abc' >>> unpack(r'(?:abc)') 'abc' >>> unpack(r'(?P<xyz>abc)') 'abc' >>> unpack(r'[abc]') '[abc]' """ if is_packed(regex): return re.sub(r'^\((\?(:|P<.*?>))?(?P<content>.*?)\)$', r'\g...
[ "def", "danger_unpack", "(", "regex", ")", ":", "if", "is_packed", "(", "regex", ")", ":", "return", "re", ".", "sub", "(", "r'^\\((\\?(:|P<.*?>))?(?P<content>.*?)\\)$'", ",", "r'\\g<content>'", ",", "regex", ")", "else", ":", "return", "regex" ]
Remove the outermost parens >>> unpack(r'(abc)') 'abc' >>> unpack(r'(?:abc)') 'abc' >>> unpack(r'(?P<xyz>abc)') 'abc' >>> unpack(r'[abc]') '[abc]'
[ "Remove", "the", "outermost", "parens" ]
8e6daf9cbb7dfbc4900870fb365add17929bd4ab
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L122-L139
244,532
jeroyang/txttk
txttk/retools.py
concat
def concat(regex_list): """ Concat multiple regular expression into one, if the given regular expression is not packed, a pair of paren will be add. >>> reg_1 = r'a|b' >>> reg_2 = r'(c|d|e)' >>> concat([reg_1, reg2]) (a|b)(c|d|e) """ output_list = [] for regex in regex_list: ...
python
def concat(regex_list): """ Concat multiple regular expression into one, if the given regular expression is not packed, a pair of paren will be add. >>> reg_1 = r'a|b' >>> reg_2 = r'(c|d|e)' >>> concat([reg_1, reg2]) (a|b)(c|d|e) """ output_list = [] for regex in regex_list: ...
[ "def", "concat", "(", "regex_list", ")", ":", "output_list", "=", "[", "]", "for", "regex", "in", "regex_list", ":", "output_list", ".", "append", "(", "consolidate", "(", "regex", ")", ")", "return", "r''", ".", "join", "(", "output_list", ")" ]
Concat multiple regular expression into one, if the given regular expression is not packed, a pair of paren will be add. >>> reg_1 = r'a|b' >>> reg_2 = r'(c|d|e)' >>> concat([reg_1, reg2]) (a|b)(c|d|e)
[ "Concat", "multiple", "regular", "expression", "into", "one", "if", "the", "given", "regular", "expression", "is", "not", "packed", "a", "pair", "of", "paren", "will", "be", "add", "." ]
8e6daf9cbb7dfbc4900870fb365add17929bd4ab
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L188-L202
244,533
jic-dtool/dtool-config
dtool_config/utils.py
set_cache
def set_cache(config_fpath, cache_dir): """Write the cache directory to the dtool config file. :param config_fpath: path to the dtool config file :param cache_dir: the path to the dtool cache direcotory """ cache_dir = os.path.abspath(cache_dir) return write_config_value_to_file( CACHE_...
python
def set_cache(config_fpath, cache_dir): """Write the cache directory to the dtool config file. :param config_fpath: path to the dtool config file :param cache_dir: the path to the dtool cache direcotory """ cache_dir = os.path.abspath(cache_dir) return write_config_value_to_file( CACHE_...
[ "def", "set_cache", "(", "config_fpath", ",", "cache_dir", ")", ":", "cache_dir", "=", "os", ".", "path", ".", "abspath", "(", "cache_dir", ")", "return", "write_config_value_to_file", "(", "CACHE_DIRECTORY_KEY", ",", "cache_dir", ",", "config_fpath", ")" ]
Write the cache directory to the dtool config file. :param config_fpath: path to the dtool config file :param cache_dir: the path to the dtool cache direcotory
[ "Write", "the", "cache", "directory", "to", "the", "dtool", "config", "file", "." ]
21afa99a6794909e1d0180a45895492b4b726a51
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/utils.py#L167-L178
244,534
jic-dtool/dtool-config
dtool_config/utils.py
set_azure_secret_access_key
def set_azure_secret_access_key(config_fpath, container, az_secret_access_key): """Write the ECS access key id to the dtool config file. :param config_fpath: path to the dtool config file :param container: azure storage container name :param az_secret_access_key: azure secret access key for the contain...
python
def set_azure_secret_access_key(config_fpath, container, az_secret_access_key): """Write the ECS access key id to the dtool config file. :param config_fpath: path to the dtool config file :param container: azure storage container name :param az_secret_access_key: azure secret access key for the contain...
[ "def", "set_azure_secret_access_key", "(", "config_fpath", ",", "container", ",", "az_secret_access_key", ")", ":", "key", "=", "AZURE_KEY_PREFIX", "+", "container", "return", "write_config_value_to_file", "(", "key", ",", "az_secret_access_key", ",", "config_fpath", ")...
Write the ECS access key id to the dtool config file. :param config_fpath: path to the dtool config file :param container: azure storage container name :param az_secret_access_key: azure secret access key for the container
[ "Write", "the", "ECS", "access", "key", "id", "to", "the", "dtool", "config", "file", "." ]
21afa99a6794909e1d0180a45895492b4b726a51
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/utils.py#L192-L200
244,535
jic-dtool/dtool-config
dtool_config/utils.py
list_azure_containers
def list_azure_containers(config_fpath): """List the azure storage containers in the config file. :param config_fpath: path to the dtool config file :returns: the list of azure storage container names """ config_content = _get_config_dict_from_file(config_fpath) az_container_names = [] for ...
python
def list_azure_containers(config_fpath): """List the azure storage containers in the config file. :param config_fpath: path to the dtool config file :returns: the list of azure storage container names """ config_content = _get_config_dict_from_file(config_fpath) az_container_names = [] for ...
[ "def", "list_azure_containers", "(", "config_fpath", ")", ":", "config_content", "=", "_get_config_dict_from_file", "(", "config_fpath", ")", "az_container_names", "=", "[", "]", "for", "key", "in", "config_content", ".", "keys", "(", ")", ":", "if", "key", ".",...
List the azure storage containers in the config file. :param config_fpath: path to the dtool config file :returns: the list of azure storage container names
[ "List", "the", "azure", "storage", "containers", "in", "the", "config", "file", "." ]
21afa99a6794909e1d0180a45895492b4b726a51
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/utils.py#L203-L215
244,536
voidpp/python-tools
voidpp_tools/config_loader.py
ConfigLoader.load
def load(self, filename, create = None, default_conf = {}): """Load the config file Args: filename (str): the filename of the config, without any path create (str): if the config file not found, and this parameter is not None, a config file will be crea...
python
def load(self, filename, create = None, default_conf = {}): """Load the config file Args: filename (str): the filename of the config, without any path create (str): if the config file not found, and this parameter is not None, a config file will be crea...
[ "def", "load", "(", "self", ",", "filename", ",", "create", "=", "None", ",", "default_conf", "=", "{", "}", ")", ":", "filenames", ",", "tries", "=", "self", ".", "__search_config_files", "(", "filename", ")", "if", "len", "(", "filenames", ")", ":", ...
Load the config file Args: filename (str): the filename of the config, without any path create (str): if the config file not found, and this parameter is not None, a config file will be create with content of default_conf default_conf (dict): conten...
[ "Load", "the", "config", "file" ]
0fc7460c827b02d8914411cedddadc23ccb3cc73
https://github.com/voidpp/python-tools/blob/0fc7460c827b02d8914411cedddadc23ccb3cc73/voidpp_tools/config_loader.py#L79-L106
244,537
voidpp/python-tools
voidpp_tools/config_loader.py
ConfigLoader.save
def save(self, data): """Save the config data Args: data: any serializable config data Raises: ConfigLoaderException: if the ConfigLoader.load not called, so there is no config file name, or the data is not serializable or the loader i...
python
def save(self, data): """Save the config data Args: data: any serializable config data Raises: ConfigLoaderException: if the ConfigLoader.load not called, so there is no config file name, or the data is not serializable or the loader i...
[ "def", "save", "(", "self", ",", "data", ")", ":", "if", "self", ".", "__nested", ":", "raise", "ConfigLoaderException", "(", "\"Cannot save the config if the 'nested' paramter is True!\"", ")", "if", "self", ".", "__loaded_config_file", "is", "None", ":", "raise", ...
Save the config data Args: data: any serializable config data Raises: ConfigLoaderException: if the ConfigLoader.load not called, so there is no config file name, or the data is not serializable or the loader is nested
[ "Save", "the", "config", "data" ]
0fc7460c827b02d8914411cedddadc23ccb3cc73
https://github.com/voidpp/python-tools/blob/0fc7460c827b02d8914411cedddadc23ccb3cc73/voidpp_tools/config_loader.py#L108-L128
244,538
etcher-be/emiz
emiz/weather/avwx/avwx.py
AVWX.metar_to_speech
def metar_to_speech(metar: str) -> str: """ Creates a speakable text from a METAR Args: metar: METAR string to use Returns: speakable METAR for TTS """ LOGGER.info('getting speech text from METAR: %s', metar) metar_data, metar_units = emiz.avwx.meta...
python
def metar_to_speech(metar: str) -> str: """ Creates a speakable text from a METAR Args: metar: METAR string to use Returns: speakable METAR for TTS """ LOGGER.info('getting speech text from METAR: %s', metar) metar_data, metar_units = emiz.avwx.meta...
[ "def", "metar_to_speech", "(", "metar", ":", "str", ")", "->", "str", ":", "LOGGER", ".", "info", "(", "'getting speech text from METAR: %s'", ",", "metar", ")", "metar_data", ",", "metar_units", "=", "emiz", ".", "avwx", ".", "metar", ".", "parse_in", "(", ...
Creates a speakable text from a METAR Args: metar: METAR string to use Returns: speakable METAR for TTS
[ "Creates", "a", "speakable", "text", "from", "a", "METAR" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/avwx/avwx.py#L22-L37
244,539
kallimachos/chios
chios/remoteinclude/__init__.py
RemoteInclude.run
def run(self): """Return rel path to a downloaded file as `include` node argument.""" document = self.state.document env = document.settings.env buildpath = env.app.outdir link = self.arguments[0] try: r = requests.get(link) r.raise_for_status() ...
python
def run(self): """Return rel path to a downloaded file as `include` node argument.""" document = self.state.document env = document.settings.env buildpath = env.app.outdir link = self.arguments[0] try: r = requests.get(link) r.raise_for_status() ...
[ "def", "run", "(", "self", ")", ":", "document", "=", "self", ".", "state", ".", "document", "env", "=", "document", ".", "settings", ".", "env", "buildpath", "=", "env", ".", "app", ".", "outdir", "link", "=", "self", ".", "arguments", "[", "0", "...
Return rel path to a downloaded file as `include` node argument.
[ "Return", "rel", "path", "to", "a", "downloaded", "file", "as", "include", "node", "argument", "." ]
e14044e4019d57089c625d4ad2f73ccb66b8b7b8
https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/remoteinclude/__init__.py#L35-L57
244,540
sassoo/goldman
goldman/deserializers/jsonapi.py
Deserializer.normalize
def normalize(self, body): """ Invoke the JSON API normalizer Perform the following: * add the type as a rtype property * flatten the payload * add the id as a rid property ONLY if present We don't need to vet the inputs much because the Parser has ...
python
def normalize(self, body): """ Invoke the JSON API normalizer Perform the following: * add the type as a rtype property * flatten the payload * add the id as a rid property ONLY if present We don't need to vet the inputs much because the Parser has ...
[ "def", "normalize", "(", "self", ",", "body", ")", ":", "resource", "=", "body", "[", "'data'", "]", "data", "=", "{", "'rtype'", ":", "resource", "[", "'type'", "]", "}", "if", "'attributes'", "in", "resource", ":", "attributes", "=", "resource", "[",...
Invoke the JSON API normalizer Perform the following: * add the type as a rtype property * flatten the payload * add the id as a rid property ONLY if present We don't need to vet the inputs much because the Parser has already done all the work. :pa...
[ "Invoke", "the", "JSON", "API", "normalizer" ]
b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L85-L121
244,541
sassoo/goldman
goldman/deserializers/jsonapi.py
Deserializer._parse_attributes
def _parse_attributes(self, attributes): """ Ensure compliance with the spec's attributes section Specifically, the attributes object of the single resource object. This contains the key / values to be mapped to the model. :param attributes: dict JSON API attributes...
python
def _parse_attributes(self, attributes): """ Ensure compliance with the spec's attributes section Specifically, the attributes object of the single resource object. This contains the key / values to be mapped to the model. :param attributes: dict JSON API attributes...
[ "def", "_parse_attributes", "(", "self", ",", "attributes", ")", ":", "link", "=", "'jsonapi.org/format/#document-resource-object-attributes'", "if", "not", "isinstance", "(", "attributes", ",", "dict", ")", ":", "self", ".", "fail", "(", "'The JSON API resource objec...
Ensure compliance with the spec's attributes section Specifically, the attributes object of the single resource object. This contains the key / values to be mapped to the model. :param attributes: dict JSON API attributes object
[ "Ensure", "compliance", "with", "the", "spec", "s", "attributes", "section" ]
b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L123-L142
244,542
sassoo/goldman
goldman/deserializers/jsonapi.py
Deserializer._parse_relationships
def _parse_relationships(self, relationships): """ Ensure compliance with the spec's relationships section Specifically, the relationships object of the single resource object. For modifications we only support relationships via the `data` key referred to as Resource Linkage. :...
python
def _parse_relationships(self, relationships): """ Ensure compliance with the spec's relationships section Specifically, the relationships object of the single resource object. For modifications we only support relationships via the `data` key referred to as Resource Linkage. :...
[ "def", "_parse_relationships", "(", "self", ",", "relationships", ")", ":", "link", "=", "'jsonapi.org/format/#document-resource-object-relationships'", "if", "not", "isinstance", "(", "relationships", ",", "dict", ")", ":", "self", ".", "fail", "(", "'The JSON API re...
Ensure compliance with the spec's relationships section Specifically, the relationships object of the single resource object. For modifications we only support relationships via the `data` key referred to as Resource Linkage. :param relationships: dict JSON API relationship...
[ "Ensure", "compliance", "with", "the", "spec", "s", "relationships", "section" ]
b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L144-L189
244,543
sassoo/goldman
goldman/deserializers/jsonapi.py
Deserializer._parse_resource
def _parse_resource(self, resource): """ Ensure compliance with the spec's resource objects section :param resource: dict JSON API resource object """ link = 'jsonapi.org/format/#document-resource-objects' rid = isinstance(resource.get('id'), unicode) rtype ...
python
def _parse_resource(self, resource): """ Ensure compliance with the spec's resource objects section :param resource: dict JSON API resource object """ link = 'jsonapi.org/format/#document-resource-objects' rid = isinstance(resource.get('id'), unicode) rtype ...
[ "def", "_parse_resource", "(", "self", ",", "resource", ")", ":", "link", "=", "'jsonapi.org/format/#document-resource-objects'", "rid", "=", "isinstance", "(", "resource", ".", "get", "(", "'id'", ")", ",", "unicode", ")", "rtype", "=", "isinstance", "(", "re...
Ensure compliance with the spec's resource objects section :param resource: dict JSON API resource object
[ "Ensure", "compliance", "with", "the", "spec", "s", "resource", "objects", "section" ]
b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L191-L219
244,544
sassoo/goldman
goldman/deserializers/jsonapi.py
Deserializer._parse_top_level
def _parse_top_level(self, body): """ Ensure compliance with the spec's top-level section """ link = 'jsonapi.org/format/#document-top-level' try: if not isinstance(body['data'], dict): raise TypeError except (KeyError, TypeError): self.fail('JSO...
python
def _parse_top_level(self, body): """ Ensure compliance with the spec's top-level section """ link = 'jsonapi.org/format/#document-top-level' try: if not isinstance(body['data'], dict): raise TypeError except (KeyError, TypeError): self.fail('JSO...
[ "def", "_parse_top_level", "(", "self", ",", "body", ")", ":", "link", "=", "'jsonapi.org/format/#document-top-level'", "try", ":", "if", "not", "isinstance", "(", "body", "[", "'data'", "]", ",", "dict", ")", ":", "raise", "TypeError", "except", "(", "KeyEr...
Ensure compliance with the spec's top-level section
[ "Ensure", "compliance", "with", "the", "spec", "s", "top", "-", "level", "section" ]
b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L221-L238
244,545
sassoo/goldman
goldman/deserializers/jsonapi.py
Deserializer.parse
def parse(self, body): """ Invoke the JSON API spec compliant parser Order is important. Start from the request body root key & work your way down so exception handling is easier to follow. :return: the parsed & vetted request body """ self._parse_t...
python
def parse(self, body): """ Invoke the JSON API spec compliant parser Order is important. Start from the request body root key & work your way down so exception handling is easier to follow. :return: the parsed & vetted request body """ self._parse_t...
[ "def", "parse", "(", "self", ",", "body", ")", ":", "self", ".", "_parse_top_level", "(", "body", ")", "self", ".", "_parse_resource", "(", "body", "[", "'data'", "]", ")", "resource", "=", "body", "[", "'data'", "]", "if", "'attributes'", "in", "resou...
Invoke the JSON API spec compliant parser Order is important. Start from the request body root key & work your way down so exception handling is easier to follow. :return: the parsed & vetted request body
[ "Invoke", "the", "JSON", "API", "spec", "compliant", "parser" ]
b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L240-L259
244,546
baliame/http-hmac-python
httphmac/compat.py
get_signer_by_version
def get_signer_by_version(digest, ver): """Returns a new signer object for a digest and version combination. Keyword arguments: digest -- a callable that may be passed to the initializer of any Signer object in this library. The callable must return a hasher object when called with no arguments. ...
python
def get_signer_by_version(digest, ver): """Returns a new signer object for a digest and version combination. Keyword arguments: digest -- a callable that may be passed to the initializer of any Signer object in this library. The callable must return a hasher object when called with no arguments. ...
[ "def", "get_signer_by_version", "(", "digest", ",", "ver", ")", ":", "if", "int", "(", "ver", ")", "==", "1", ":", "return", "V1Signer", "(", "digest", ")", "elif", "int", "(", "ver", ")", "==", "2", ":", "return", "V2Signer", "(", "digest", ")", "...
Returns a new signer object for a digest and version combination. Keyword arguments: digest -- a callable that may be passed to the initializer of any Signer object in this library. The callable must return a hasher object when called with no arguments. ver -- the version of the signature. This may...
[ "Returns", "a", "new", "signer", "object", "for", "a", "digest", "and", "version", "combination", "." ]
9884c0cbfdb712f9f37080a8efbfdce82850785f
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/compat.py#L6-L19
244,547
baliame/http-hmac-python
httphmac/compat.py
SignatureIdentifier.identify
def identify(self, header): """Identifies a signature and returns the appropriate Signer object. This is done by reading an authorization header and matching it to signature characteristics. None is returned if the authorization header does not match the format of any signature identified by thi...
python
def identify(self, header): """Identifies a signature and returns the appropriate Signer object. This is done by reading an authorization header and matching it to signature characteristics. None is returned if the authorization header does not match the format of any signature identified by thi...
[ "def", "identify", "(", "self", ",", "header", ")", ":", "for", "ver", ",", "signer", "in", "self", ".", "signers", ".", "items", "(", ")", ":", "if", "signer", ".", "matches", "(", "header", ")", ":", "return", "signer", "return", "None" ]
Identifies a signature and returns the appropriate Signer object. This is done by reading an authorization header and matching it to signature characteristics. None is returned if the authorization header does not match the format of any signature identified by this identifier. Keyword argument...
[ "Identifies", "a", "signature", "and", "returns", "the", "appropriate", "Signer", "object", ".", "This", "is", "done", "by", "reading", "an", "authorization", "header", "and", "matching", "it", "to", "signature", "characteristics", ".", "None", "is", "returned",...
9884c0cbfdb712f9f37080a8efbfdce82850785f
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/compat.py#L41-L52
244,548
keik/audiotrans
audiotrans/load_transforms.py
load_transforms
def load_transforms(transforms): """ Load transform modules and return instance of transform class. Parameters ---------- transforms : [str] or [[str]] array of transform module name, or nested array of transform module name with argv to load Returns ------- array o...
python
def load_transforms(transforms): """ Load transform modules and return instance of transform class. Parameters ---------- transforms : [str] or [[str]] array of transform module name, or nested array of transform module name with argv to load Returns ------- array o...
[ "def", "load_transforms", "(", "transforms", ")", ":", "from", ".", "import", "Transform", "import", "inspect", "# normalize arguments to form as [(name, [option, ...]), ...]", "transforms_with_argv", "=", "map", "(", "lambda", "t", ":", "(", "t", "[", "0", "]", ","...
Load transform modules and return instance of transform class. Parameters ---------- transforms : [str] or [[str]] array of transform module name, or nested array of transform module name with argv to load Returns ------- array of transform instance
[ "Load", "transform", "modules", "and", "return", "instance", "of", "transform", "class", "." ]
0849e32b9eacc3256a9da48d1cab8935448fa1e7
https://github.com/keik/audiotrans/blob/0849e32b9eacc3256a9da48d1cab8935448fa1e7/audiotrans/load_transforms.py#L4-L42
244,549
fakedrake/overlay_parse
overlay_parse/dates.py
date_tuple
def date_tuple(ovls): """ We should have a list of overlays from which to extract day month year. """ day = month = year = 0 for o in ovls: if 'day' in o.props: day = o.value if 'month' in o.props: month = o.value if 'year' in o.props: ...
python
def date_tuple(ovls): """ We should have a list of overlays from which to extract day month year. """ day = month = year = 0 for o in ovls: if 'day' in o.props: day = o.value if 'month' in o.props: month = o.value if 'year' in o.props: ...
[ "def", "date_tuple", "(", "ovls", ")", ":", "day", "=", "month", "=", "year", "=", "0", "for", "o", "in", "ovls", ":", "if", "'day'", "in", "o", ".", "props", ":", "day", "=", "o", ".", "value", "if", "'month'", "in", "o", ".", "props", ":", ...
We should have a list of overlays from which to extract day month year.
[ "We", "should", "have", "a", "list", "of", "overlays", "from", "which", "to", "extract", "day", "month", "year", "." ]
9ac362d6aef1ea41aff7375af088c6ebef93d0cd
https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/dates.py#L57-L78
244,550
fakedrake/overlay_parse
overlay_parse/dates.py
longest_overlap
def longest_overlap(ovls): """ From a list of overlays if any overlap keep the longest. """ # Ovls know how to compare to each other. ovls = sorted(ovls) # I know this could be better but ovls wont be more than 50 or so. for i, s in enumerate(ovls): passing = True for l in...
python
def longest_overlap(ovls): """ From a list of overlays if any overlap keep the longest. """ # Ovls know how to compare to each other. ovls = sorted(ovls) # I know this could be better but ovls wont be more than 50 or so. for i, s in enumerate(ovls): passing = True for l in...
[ "def", "longest_overlap", "(", "ovls", ")", ":", "# Ovls know how to compare to each other.", "ovls", "=", "sorted", "(", "ovls", ")", "# I know this could be better but ovls wont be more than 50 or so.", "for", "i", ",", "s", "in", "enumerate", "(", "ovls", ")", ":", ...
From a list of overlays if any overlap keep the longest.
[ "From", "a", "list", "of", "overlays", "if", "any", "overlap", "keep", "the", "longest", "." ]
9ac362d6aef1ea41aff7375af088c6ebef93d0cd
https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/dates.py#L81-L100
244,551
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/XMLSchema.py
GetSchema
def GetSchema(component): """convience function for finding the parent XMLSchema instance. """ parent = component while not isinstance(parent, XMLSchema): parent = parent._parent() return parent
python
def GetSchema(component): """convience function for finding the parent XMLSchema instance. """ parent = component while not isinstance(parent, XMLSchema): parent = parent._parent() return parent
[ "def", "GetSchema", "(", "component", ")", ":", "parent", "=", "component", "while", "not", "isinstance", "(", "parent", ",", "XMLSchema", ")", ":", "parent", "=", "parent", ".", "_parent", "(", ")", "return", "parent" ]
convience function for finding the parent XMLSchema instance.
[ "convience", "function", "for", "finding", "the", "parent", "XMLSchema", "instance", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L42-L48
244,552
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/XMLSchema.py
XMLSchemaComponent.getXMLNS
def getXMLNS(self, prefix=None): """deference prefix or by default xmlns, returns namespace. """ if prefix == XMLSchemaComponent.xml: return XMLNS.XML parent = self ns = self.attributes[XMLSchemaComponent.xmlns].get(prefix or\ XMLSchemaComponent.xmlns...
python
def getXMLNS(self, prefix=None): """deference prefix or by default xmlns, returns namespace. """ if prefix == XMLSchemaComponent.xml: return XMLNS.XML parent = self ns = self.attributes[XMLSchemaComponent.xmlns].get(prefix or\ XMLSchemaComponent.xmlns...
[ "def", "getXMLNS", "(", "self", ",", "prefix", "=", "None", ")", ":", "if", "prefix", "==", "XMLSchemaComponent", ".", "xml", ":", "return", "XMLNS", ".", "XML", "parent", "=", "self", "ns", "=", "self", ".", "attributes", "[", "XMLSchemaComponent", ".",...
deference prefix or by default xmlns, returns namespace.
[ "deference", "prefix", "or", "by", "default", "xmlns", "returns", "namespace", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L648-L664
244,553
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/XMLSchema.py
XMLSchemaComponent.getAttribute
def getAttribute(self, attribute): """return requested attribute value or None """ if type(attribute) in (list, tuple): if len(attribute) != 2: raise LookupError, 'To access attributes must use name or (namespace,name)' ns_dict = self.attributes.get(attri...
python
def getAttribute(self, attribute): """return requested attribute value or None """ if type(attribute) in (list, tuple): if len(attribute) != 2: raise LookupError, 'To access attributes must use name or (namespace,name)' ns_dict = self.attributes.get(attri...
[ "def", "getAttribute", "(", "self", ",", "attribute", ")", ":", "if", "type", "(", "attribute", ")", "in", "(", "list", ",", "tuple", ")", ":", "if", "len", "(", "attribute", ")", "!=", "2", ":", "raise", "LookupError", ",", "'To access attributes must u...
return requested attribute value or None
[ "return", "requested", "attribute", "value", "or", "None" ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L666-L679
244,554
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/XMLSchema.py
XMLSchemaComponent.__setAttributeDefaults
def __setAttributeDefaults(self): """Looks for default values for unset attributes. If class variable representing attribute is None, then it must be defined as an instance variable. """ for k,v in self.__class__.attributes.items(): if v is not None and self.at...
python
def __setAttributeDefaults(self): """Looks for default values for unset attributes. If class variable representing attribute is None, then it must be defined as an instance variable. """ for k,v in self.__class__.attributes.items(): if v is not None and self.at...
[ "def", "__setAttributeDefaults", "(", "self", ")", ":", "for", "k", ",", "v", "in", "self", ".", "__class__", ".", "attributes", ".", "items", "(", ")", ":", "if", "v", "is", "not", "None", "and", "self", ".", "attributes", ".", "has_key", "(", "k", ...
Looks for default values for unset attributes. If class variable representing attribute is None, then it must be defined as an instance variable.
[ "Looks", "for", "default", "values", "for", "unset", "attributes", ".", "If", "class", "variable", "representing", "attribute", "is", "None", "then", "it", "must", "be", "defined", "as", "an", "instance", "variable", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L760-L770
244,555
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/XMLSchema.py
LocalElementDeclaration.isQualified
def isQualified(self): """ Local elements can be qualified or unqualifed according to the attribute form, or the elementFormDefault. By default local elements are unqualified. """ form = self.getAttribute('form') if form == 'qualified': return True if...
python
def isQualified(self): """ Local elements can be qualified or unqualifed according to the attribute form, or the elementFormDefault. By default local elements are unqualified. """ form = self.getAttribute('form') if form == 'qualified': return True if...
[ "def", "isQualified", "(", "self", ")", ":", "form", "=", "self", ".", "getAttribute", "(", "'form'", ")", "if", "form", "==", "'qualified'", ":", "return", "True", "if", "form", "==", "'unqualified'", ":", "return", "False", "raise", "SchemaError", ",", ...
Local elements can be qualified or unqualifed according to the attribute form, or the elementFormDefault. By default local elements are unqualified.
[ "Local", "elements", "can", "be", "qualified", "or", "unqualifed", "according", "to", "the", "attribute", "form", "or", "the", "elementFormDefault", ".", "By", "default", "local", "elements", "are", "unqualified", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L2019-L2030
244,556
dreipol/meta-tagger
meta_tagger/templatetags/meta_tagger_tags.py
render_title_tag
def render_title_tag(context, is_og=False): """ Returns the title as string or a complete open graph meta tag. """ request = context['request'] content = '' # Try to get the title from the context object (e.g. DetailViews). if context.get('object'): try: content = contex...
python
def render_title_tag(context, is_og=False): """ Returns the title as string or a complete open graph meta tag. """ request = context['request'] content = '' # Try to get the title from the context object (e.g. DetailViews). if context.get('object'): try: content = contex...
[ "def", "render_title_tag", "(", "context", ",", "is_og", "=", "False", ")", ":", "request", "=", "context", "[", "'request'", "]", "content", "=", "''", "# Try to get the title from the context object (e.g. DetailViews).", "if", "context", ".", "get", "(", "'object'...
Returns the title as string or a complete open graph meta tag.
[ "Returns", "the", "title", "as", "string", "or", "a", "complete", "open", "graph", "meta", "tag", "." ]
e00a8c774d7b45882f068ba6d2706bb559de2b80
https://github.com/dreipol/meta-tagger/blob/e00a8c774d7b45882f068ba6d2706bb559de2b80/meta_tagger/templatetags/meta_tagger_tags.py#L29-L57
244,557
dreipol/meta-tagger
meta_tagger/templatetags/meta_tagger_tags.py
render_description_meta_tag
def render_description_meta_tag(context, is_og=False): """ Returns the description as meta or open graph tag. """ request = context['request'] content = '' # Try to get the description from the context object (e.g. DetailViews). if context.get('object'): try: content = c...
python
def render_description_meta_tag(context, is_og=False): """ Returns the description as meta or open graph tag. """ request = context['request'] content = '' # Try to get the description from the context object (e.g. DetailViews). if context.get('object'): try: content = c...
[ "def", "render_description_meta_tag", "(", "context", ",", "is_og", "=", "False", ")", ":", "request", "=", "context", "[", "'request'", "]", "content", "=", "''", "# Try to get the description from the context object (e.g. DetailViews).", "if", "context", ".", "get", ...
Returns the description as meta or open graph tag.
[ "Returns", "the", "description", "as", "meta", "or", "open", "graph", "tag", "." ]
e00a8c774d7b45882f068ba6d2706bb559de2b80
https://github.com/dreipol/meta-tagger/blob/e00a8c774d7b45882f068ba6d2706bb559de2b80/meta_tagger/templatetags/meta_tagger_tags.py#L61-L91
244,558
dreipol/meta-tagger
meta_tagger/templatetags/meta_tagger_tags.py
render_robots_meta_tag
def render_robots_meta_tag(context): """ Returns the robots meta tag. """ request = context['request'] robots_indexing = None robots_following = None # Prevent indexing any unwanted domains (e.g. staging). if context.request.get_host() in settings.META_TAGGER_ROBOTS_DOMAIN_WHITELIST: ...
python
def render_robots_meta_tag(context): """ Returns the robots meta tag. """ request = context['request'] robots_indexing = None robots_following = None # Prevent indexing any unwanted domains (e.g. staging). if context.request.get_host() in settings.META_TAGGER_ROBOTS_DOMAIN_WHITELIST: ...
[ "def", "render_robots_meta_tag", "(", "context", ")", ":", "request", "=", "context", "[", "'request'", "]", "robots_indexing", "=", "None", "robots_following", "=", "None", "# Prevent indexing any unwanted domains (e.g. staging).", "if", "context", ".", "request", ".",...
Returns the robots meta tag.
[ "Returns", "the", "robots", "meta", "tag", "." ]
e00a8c774d7b45882f068ba6d2706bb559de2b80
https://github.com/dreipol/meta-tagger/blob/e00a8c774d7b45882f068ba6d2706bb559de2b80/meta_tagger/templatetags/meta_tagger_tags.py#L95-L133
244,559
collectiveacuity/labPack
labpack/storage/aws/s3.py
_s3Client.list_buckets
def list_buckets(self): ''' a method to retrieve a list of buckets on s3 :return: list of buckets ''' title = '%s.list_buckets' % self.__class__.__name__ bucket_list = [] # send request to s3 try: response = self.connection...
python
def list_buckets(self): ''' a method to retrieve a list of buckets on s3 :return: list of buckets ''' title = '%s.list_buckets' % self.__class__.__name__ bucket_list = [] # send request to s3 try: response = self.connection...
[ "def", "list_buckets", "(", "self", ")", ":", "title", "=", "'%s.list_buckets'", "%", "self", ".", "__class__", ".", "__name__", "bucket_list", "=", "[", "]", "# send request to s3", "try", ":", "response", "=", "self", ".", "connection", ".", "list_buckets", ...
a method to retrieve a list of buckets on s3 :return: list of buckets
[ "a", "method", "to", "retrieve", "a", "list", "of", "buckets", "on", "s3" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L87-L111
244,560
collectiveacuity/labPack
labpack/storage/aws/s3.py
_s3Client.delete_bucket
def delete_bucket(self, bucket_name): ''' a method to delete a bucket in s3 and all its contents :param bucket_name: string with name of bucket :return: string with status of method ''' title = '%s.delete_bucket' % self.__class__.__name__ # validate in...
python
def delete_bucket(self, bucket_name): ''' a method to delete a bucket in s3 and all its contents :param bucket_name: string with name of bucket :return: string with status of method ''' title = '%s.delete_bucket' % self.__class__.__name__ # validate in...
[ "def", "delete_bucket", "(", "self", ",", "bucket_name", ")", ":", "title", "=", "'%s.delete_bucket'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'bucket_name'", ":", "bucket_name", "}", "for", "key", ",", "...
a method to delete a bucket in s3 and all its contents :param bucket_name: string with name of bucket :return: string with status of method
[ "a", "method", "to", "delete", "a", "bucket", "in", "s3", "and", "all", "its", "contents" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L790-L867
244,561
collectiveacuity/labPack
labpack/storage/aws/s3.py
_s3Client.read_headers
def read_headers(self, bucket_name, record_key, record_version='', version_check=False): ''' a method for retrieving the headers of a record from s3 :param bucket_name: string with name of bucket :param record_key: string with key value of record :param record_version: [opt...
python
def read_headers(self, bucket_name, record_key, record_version='', version_check=False): ''' a method for retrieving the headers of a record from s3 :param bucket_name: string with name of bucket :param record_key: string with key value of record :param record_version: [opt...
[ "def", "read_headers", "(", "self", ",", "bucket_name", ",", "record_key", ",", "record_version", "=", "''", ",", "version_check", "=", "False", ")", ":", "title", "=", "'%s.read_headers'", "%", "self", ".", "__class__", ".", "__name__", "from", "datetime", ...
a method for retrieving the headers of a record from s3 :param bucket_name: string with name of bucket :param record_key: string with key value of record :param record_version: [optional] string with aws id of version of record :param version_check: [optional] boolean to enable current ...
[ "a", "method", "for", "retrieving", "the", "headers", "of", "a", "record", "from", "s3" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L1167-L1252
244,562
collectiveacuity/labPack
labpack/storage/aws/s3.py
_s3Client.delete_record
def delete_record(self, bucket_name, record_key, record_version=''): ''' a method for deleting an object record in s3 :param bucket_name: string with name of bucket :param record_key: string with key value of record :param record_version: [optional] string with aws id of ve...
python
def delete_record(self, bucket_name, record_key, record_version=''): ''' a method for deleting an object record in s3 :param bucket_name: string with name of bucket :param record_key: string with key value of record :param record_version: [optional] string with aws id of ve...
[ "def", "delete_record", "(", "self", ",", "bucket_name", ",", "record_key", ",", "record_version", "=", "''", ")", ":", "title", "=", "'%s.delete_record'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'bucket_na...
a method for deleting an object record in s3 :param bucket_name: string with name of bucket :param record_key: string with key value of record :param record_version: [optional] string with aws id of version of record :return: dictionary with status of delete request
[ "a", "method", "for", "deleting", "an", "object", "record", "in", "s3" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L1345-L1396
244,563
collectiveacuity/labPack
labpack/storage/aws/s3.py
_s3Client.import_records
def import_records(self, bucket_name, import_path='', overwrite=True): ''' a method to importing records from local files to a bucket :param bucket_name: string with name of bucket :param export_path: [optional] string with path to root directory of files :param overwrite: ...
python
def import_records(self, bucket_name, import_path='', overwrite=True): ''' a method to importing records from local files to a bucket :param bucket_name: string with name of bucket :param export_path: [optional] string with path to root directory of files :param overwrite: ...
[ "def", "import_records", "(", "self", ",", "bucket_name", ",", "import_path", "=", "''", ",", "overwrite", "=", "True", ")", ":", "title", "=", "'%s.import_records'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{"...
a method to importing records from local files to a bucket :param bucket_name: string with name of bucket :param export_path: [optional] string with path to root directory of files :param overwrite: [optional] boolean to overwrite existing files matching records :return: True
[ "a", "method", "to", "importing", "records", "from", "local", "files", "to", "a", "bucket" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L1490-L1548
244,564
collectiveacuity/labPack
labpack/storage/aws/s3.py
s3Client.save
def save(self, record_key, record_data, overwrite=True, secret_key=''): ''' a method to create a file in the collection folder on S3 :param record_key: string with name to assign to record (see NOTES below) :param record_data: byte data for record body :param overw...
python
def save(self, record_key, record_data, overwrite=True, secret_key=''): ''' a method to create a file in the collection folder on S3 :param record_key: string with name to assign to record (see NOTES below) :param record_data: byte data for record body :param overw...
[ "def", "save", "(", "self", ",", "record_key", ",", "record_data", ",", "overwrite", "=", "True", ",", "secret_key", "=", "''", ")", ":", "title", "=", "'%s.save'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "...
a method to create a file in the collection folder on S3 :param record_key: string with name to assign to record (see NOTES below) :param record_data: byte data for record body :param overwrite: [optional] boolean to overwrite records with same name :param secret_key: [optional] string ...
[ "a", "method", "to", "create", "a", "file", "in", "the", "collection", "folder", "on", "S3" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L1722-L1796
244,565
collectiveacuity/labPack
labpack/storage/aws/s3.py
s3Client.load
def load(self, record_key, secret_key=''): ''' a method to retrieve byte data of an S3 record :param record_key: string with name of record :param secret_key: [optional] string used to decrypt data :return: byte data for record body ''' titl...
python
def load(self, record_key, secret_key=''): ''' a method to retrieve byte data of an S3 record :param record_key: string with name of record :param secret_key: [optional] string used to decrypt data :return: byte data for record body ''' titl...
[ "def", "load", "(", "self", ",", "record_key", ",", "secret_key", "=", "''", ")", ":", "title", "=", "'%s.load'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'record_key'", ":", "record_key", ",", "'secret_...
a method to retrieve byte data of an S3 record :param record_key: string with name of record :param secret_key: [optional] string used to decrypt data :return: byte data for record body
[ "a", "method", "to", "retrieve", "byte", "data", "of", "an", "S3", "record" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L1798-L1838
244,566
collectiveacuity/labPack
labpack/storage/aws/s3.py
s3Client.list
def list(self, prefix='', delimiter='', filter_function=None, max_results=1, previous_key=''): ''' a method to list keys in the collection :param prefix: string with prefix value to filter results :param delimiter: string with value results must not contain (after prefix) ...
python
def list(self, prefix='', delimiter='', filter_function=None, max_results=1, previous_key=''): ''' a method to list keys in the collection :param prefix: string with prefix value to filter results :param delimiter: string with value results must not contain (after prefix) ...
[ "def", "list", "(", "self", ",", "prefix", "=", "''", ",", "delimiter", "=", "''", ",", "filter_function", "=", "None", ",", "max_results", "=", "1", ",", "previous_key", "=", "''", ")", ":", "title", "=", "'%s.list'", "%", "self", ".", "__class__", ...
a method to list keys in the collection :param prefix: string with prefix value to filter results :param delimiter: string with value results must not contain (after prefix) :param filter_function: (positional arguments) function used to filter results :param max_results: integer with m...
[ "a", "method", "to", "list", "keys", "in", "the", "collection" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L1873-L1991
244,567
collectiveacuity/labPack
labpack/storage/aws/s3.py
s3Client.delete
def delete(self, record_key): ''' a method to delete a record from S3 :param record_key: string with key of record :return: string reporting outcome ''' title = '%s.delete' % self.__class__.__name__ # validate inputs input_fields = { 'r...
python
def delete(self, record_key): ''' a method to delete a record from S3 :param record_key: string with key of record :return: string reporting outcome ''' title = '%s.delete' % self.__class__.__name__ # validate inputs input_fields = { 'r...
[ "def", "delete", "(", "self", ",", "record_key", ")", ":", "title", "=", "'%s.delete'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'record_key'", ":", "record_key", "}", "for", "key", ",", "value", "in", ...
a method to delete a record from S3 :param record_key: string with key of record :return: string reporting outcome
[ "a", "method", "to", "delete", "a", "record", "from", "S3" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L1993-L2021
244,568
collectiveacuity/labPack
labpack/storage/aws/s3.py
s3Client.remove
def remove(self): ''' a method to remove collection and all records in the collection :return: string with confirmation of deletion ''' title = '%s.remove' % self.__class__.__name__ # request bucket delete self.s3.delete_bucket(self.bucket_na...
python
def remove(self): ''' a method to remove collection and all records in the collection :return: string with confirmation of deletion ''' title = '%s.remove' % self.__class__.__name__ # request bucket delete self.s3.delete_bucket(self.bucket_na...
[ "def", "remove", "(", "self", ")", ":", "title", "=", "'%s.remove'", "%", "self", ".", "__class__", ".", "__name__", "# request bucket delete ", "self", ".", "s3", ".", "delete_bucket", "(", "self", ".", "bucket_name", ")", "# return confirmation", "exit_msg", ...
a method to remove collection and all records in the collection :return: string with confirmation of deletion
[ "a", "method", "to", "remove", "collection", "and", "all", "records", "in", "the", "collection" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/aws/s3.py#L2023-L2038
244,569
nefarioustim/parker
parker/crawlpage.py
CrawlPage.get_uris
def get_uris(self, base_uri, filter_list=None): """Return a set of internal URIs.""" return { re.sub(r'^/', base_uri, link.attrib['href']) for link in self.parsedpage.get_nodes_by_selector('a') if 'href' in link.attrib and ( link.attrib['href'].startsw...
python
def get_uris(self, base_uri, filter_list=None): """Return a set of internal URIs.""" return { re.sub(r'^/', base_uri, link.attrib['href']) for link in self.parsedpage.get_nodes_by_selector('a') if 'href' in link.attrib and ( link.attrib['href'].startsw...
[ "def", "get_uris", "(", "self", ",", "base_uri", ",", "filter_list", "=", "None", ")", ":", "return", "{", "re", ".", "sub", "(", "r'^/'", ",", "base_uri", ",", "link", ".", "attrib", "[", "'href'", "]", ")", "for", "link", "in", "self", ".", "pars...
Return a set of internal URIs.
[ "Return", "a", "set", "of", "internal", "URIs", "." ]
ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/crawlpage.py#L53-L63
244,570
lwcook/horsetail-matching
horsetailmatching/demoproblems.py
TP0
def TP0(dv, u): '''Demo problem 0 for horsetail matching, takes two input vectors of any size and returns a single output''' return np.linalg.norm(np.array(dv)) + np.linalg.norm(np.array(u))
python
def TP0(dv, u): '''Demo problem 0 for horsetail matching, takes two input vectors of any size and returns a single output''' return np.linalg.norm(np.array(dv)) + np.linalg.norm(np.array(u))
[ "def", "TP0", "(", "dv", ",", "u", ")", ":", "return", "np", ".", "linalg", ".", "norm", "(", "np", ".", "array", "(", "dv", ")", ")", "+", "np", ".", "linalg", ".", "norm", "(", "np", ".", "array", "(", "u", ")", ")" ]
Demo problem 0 for horsetail matching, takes two input vectors of any size and returns a single output
[ "Demo", "problem", "0", "for", "horsetail", "matching", "takes", "two", "input", "vectors", "of", "any", "size", "and", "returns", "a", "single", "output" ]
f3d5f8d01249debbca978f412ce4eae017458119
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/demoproblems.py#L3-L6
244,571
lwcook/horsetail-matching
horsetailmatching/demoproblems.py
TP1
def TP1(x, u, jac=False): '''Demo problem 1 for horsetail matching, takes two input vectors of size 2 and returns just the qoi if jac is False or the qoi and its gradient if jac is True''' factor = 0.1*(u[0]**2 + 2*u[0]*u[1] + u[1]**2) q = 0 + factor*(x[0]**2 + 2*x[1]*x[0] + x[1]**2) if not jac:...
python
def TP1(x, u, jac=False): '''Demo problem 1 for horsetail matching, takes two input vectors of size 2 and returns just the qoi if jac is False or the qoi and its gradient if jac is True''' factor = 0.1*(u[0]**2 + 2*u[0]*u[1] + u[1]**2) q = 0 + factor*(x[0]**2 + 2*x[1]*x[0] + x[1]**2) if not jac:...
[ "def", "TP1", "(", "x", ",", "u", ",", "jac", "=", "False", ")", ":", "factor", "=", "0.1", "*", "(", "u", "[", "0", "]", "**", "2", "+", "2", "*", "u", "[", "0", "]", "*", "u", "[", "1", "]", "+", "u", "[", "1", "]", "**", "2", ")"...
Demo problem 1 for horsetail matching, takes two input vectors of size 2 and returns just the qoi if jac is False or the qoi and its gradient if jac is True
[ "Demo", "problem", "1", "for", "horsetail", "matching", "takes", "two", "input", "vectors", "of", "size", "2", "and", "returns", "just", "the", "qoi", "if", "jac", "is", "False", "or", "the", "qoi", "and", "its", "gradient", "if", "jac", "is", "True" ]
f3d5f8d01249debbca978f412ce4eae017458119
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/demoproblems.py#L8-L18
244,572
lwcook/horsetail-matching
horsetailmatching/demoproblems.py
TP2
def TP2(dv, u, jac=False): '''Demo problem 2 for horsetail matching, takes two input vectors of size 2 and returns just the qoi if jac is False or the qoi and its gradient if jac is True''' y = dv[0]/2. z = dv[1]/2. + 12 q = 0.25*((y**2 + z**2)/10 + 5*u[0]*u[1] - z*u[1]**2) + 0.2*z*u[1]**3 + 7 ...
python
def TP2(dv, u, jac=False): '''Demo problem 2 for horsetail matching, takes two input vectors of size 2 and returns just the qoi if jac is False or the qoi and its gradient if jac is True''' y = dv[0]/2. z = dv[1]/2. + 12 q = 0.25*((y**2 + z**2)/10 + 5*u[0]*u[1] - z*u[1]**2) + 0.2*z*u[1]**3 + 7 ...
[ "def", "TP2", "(", "dv", ",", "u", ",", "jac", "=", "False", ")", ":", "y", "=", "dv", "[", "0", "]", "/", "2.", "z", "=", "dv", "[", "1", "]", "/", "2.", "+", "12", "q", "=", "0.25", "*", "(", "(", "y", "**", "2", "+", "z", "**", "...
Demo problem 2 for horsetail matching, takes two input vectors of size 2 and returns just the qoi if jac is False or the qoi and its gradient if jac is True
[ "Demo", "problem", "2", "for", "horsetail", "matching", "takes", "two", "input", "vectors", "of", "size", "2", "and", "returns", "just", "the", "qoi", "if", "jac", "is", "False", "or", "the", "qoi", "and", "its", "gradient", "if", "jac", "is", "True" ]
f3d5f8d01249debbca978f412ce4eae017458119
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/demoproblems.py#L20-L34
244,573
lwcook/horsetail-matching
horsetailmatching/demoproblems.py
TP3
def TP3(x, u, jac=False): '''Demo problem 1 for horsetail matching, takes two input values of size 1''' q = 2 + 0.5*x + 1.5*(1-x)*u if not jac: return q else: grad = 0.5 -1.5*u return q, grad
python
def TP3(x, u, jac=False): '''Demo problem 1 for horsetail matching, takes two input values of size 1''' q = 2 + 0.5*x + 1.5*(1-x)*u if not jac: return q else: grad = 0.5 -1.5*u return q, grad
[ "def", "TP3", "(", "x", ",", "u", ",", "jac", "=", "False", ")", ":", "q", "=", "2", "+", "0.5", "*", "x", "+", "1.5", "*", "(", "1", "-", "x", ")", "*", "u", "if", "not", "jac", ":", "return", "q", "else", ":", "grad", "=", "0.5", "-",...
Demo problem 1 for horsetail matching, takes two input values of size 1
[ "Demo", "problem", "1", "for", "horsetail", "matching", "takes", "two", "input", "values", "of", "size", "1" ]
f3d5f8d01249debbca978f412ce4eae017458119
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/demoproblems.py#L53-L62
244,574
sassoo/goldman
goldman/stores/base.py
Cache.get
def get(self, key, bucket): """ Get a cached item by key If the cached item isn't found the return None. """ try: return self._cache[bucket][key] except (KeyError, TypeError): return None
python
def get(self, key, bucket): """ Get a cached item by key If the cached item isn't found the return None. """ try: return self._cache[bucket][key] except (KeyError, TypeError): return None
[ "def", "get", "(", "self", ",", "key", ",", "bucket", ")", ":", "try", ":", "return", "self", ".", "_cache", "[", "bucket", "]", "[", "key", "]", "except", "(", "KeyError", ",", "TypeError", ")", ":", "return", "None" ]
Get a cached item by key If the cached item isn't found the return None.
[ "Get", "a", "cached", "item", "by", "key" ]
b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/stores/base.py#L24-L33
244,575
sassoo/goldman
goldman/stores/base.py
Cache.set
def set(self, key, val, bucket): """ Set a cached item by key WARN: Regardless if the item is already in the cache, it will be udpated with the new value. """ if bucket not in self._cache: self._cache[bucket] = {} self._cache[bucket][key] = val
python
def set(self, key, val, bucket): """ Set a cached item by key WARN: Regardless if the item is already in the cache, it will be udpated with the new value. """ if bucket not in self._cache: self._cache[bucket] = {} self._cache[bucket][key] = val
[ "def", "set", "(", "self", ",", "key", ",", "val", ",", "bucket", ")", ":", "if", "bucket", "not", "in", "self", ".", "_cache", ":", "self", ".", "_cache", "[", "bucket", "]", "=", "{", "}", "self", ".", "_cache", "[", "bucket", "]", "[", "key"...
Set a cached item by key WARN: Regardless if the item is already in the cache, it will be udpated with the new value.
[ "Set", "a", "cached", "item", "by", "key" ]
b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/stores/base.py#L35-L45
244,576
stephanepechard/projy
projy/templates/ProjyTemplate.py
ProjyTemplate.create
def create(self, project_name, template_name, substitutions): """ Launch the project creation. """ self.project_name = project_name self.template_name = template_name # create substitutions dictionary from user arguments # TODO: check what is given for subs in substituti...
python
def create(self, project_name, template_name, substitutions): """ Launch the project creation. """ self.project_name = project_name self.template_name = template_name # create substitutions dictionary from user arguments # TODO: check what is given for subs in substituti...
[ "def", "create", "(", "self", ",", "project_name", ",", "template_name", ",", "substitutions", ")", ":", "self", ".", "project_name", "=", "project_name", "self", ".", "template_name", "=", "template_name", "# create substitutions dictionary from user arguments", "# TOD...
Launch the project creation.
[ "Launch", "the", "project", "creation", "." ]
3146b0e3c207b977e1b51fcb33138746dae83c23
https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/templates/ProjyTemplate.py#L27-L45
244,577
stephanepechard/projy
projy/templates/ProjyTemplate.py
ProjyTemplate.make_directories
def make_directories(self): """ Create the directories of the template. """ # get the directories from the template directories = [] try: directories = self.directories() except AttributeError: self.term.print_info(u"No directory in the template.") ...
python
def make_directories(self): """ Create the directories of the template. """ # get the directories from the template directories = [] try: directories = self.directories() except AttributeError: self.term.print_info(u"No directory in the template.") ...
[ "def", "make_directories", "(", "self", ")", ":", "# get the directories from the template", "directories", "=", "[", "]", "try", ":", "directories", "=", "self", ".", "directories", "(", ")", "except", "AttributeError", ":", "self", ".", "term", ".", "print_inf...
Create the directories of the template.
[ "Create", "the", "directories", "of", "the", "template", "." ]
3146b0e3c207b977e1b51fcb33138746dae83c23
https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/templates/ProjyTemplate.py#L48-L73
244,578
stephanepechard/projy
projy/templates/ProjyTemplate.py
ProjyTemplate.make_files
def make_files(self): """ Create the files of the template. """ # get the files from the template files = [] try: files = self.files() except AttributeError: self.term.print_info(u"No file in the template. Weird, but why not?") # get the substit...
python
def make_files(self): """ Create the files of the template. """ # get the files from the template files = [] try: files = self.files() except AttributeError: self.term.print_info(u"No file in the template. Weird, but why not?") # get the substit...
[ "def", "make_files", "(", "self", ")", ":", "# get the files from the template", "files", "=", "[", "]", "try", ":", "files", "=", "self", ".", "files", "(", ")", "except", "AttributeError", ":", "self", ".", "term", ".", "print_info", "(", "u\"No file in th...
Create the files of the template.
[ "Create", "the", "files", "of", "the", "template", "." ]
3146b0e3c207b977e1b51fcb33138746dae83c23
https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/templates/ProjyTemplate.py#L76-L135
244,579
stephanepechard/projy
projy/templates/ProjyTemplate.py
ProjyTemplate.make_posthook
def make_posthook(self): """ Run the post hook into the project directory. """ print(id(self.posthook), self.posthook) print(id(super(self.__class__, self).posthook), super(self.__class__, self).posthook) import ipdb;ipdb.set_trace() if self.posthook: os.chdir(self.pr...
python
def make_posthook(self): """ Run the post hook into the project directory. """ print(id(self.posthook), self.posthook) print(id(super(self.__class__, self).posthook), super(self.__class__, self).posthook) import ipdb;ipdb.set_trace() if self.posthook: os.chdir(self.pr...
[ "def", "make_posthook", "(", "self", ")", ":", "print", "(", "id", "(", "self", ".", "posthook", ")", ",", "self", ".", "posthook", ")", "print", "(", "id", "(", "super", "(", "self", ".", "__class__", ",", "self", ")", ".", "posthook", ")", ",", ...
Run the post hook into the project directory.
[ "Run", "the", "post", "hook", "into", "the", "project", "directory", "." ]
3146b0e3c207b977e1b51fcb33138746dae83c23
https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/templates/ProjyTemplate.py#L138-L145
244,580
stephanepechard/projy
projy/templates/ProjyTemplate.py
ProjyTemplate.replace_in_file
def replace_in_file(self, file_path, old_exp, new_exp): """ In the given file, replace all 'old_exp' by 'new_exp'. """ self.term.print_info(u"Making replacement into {}" .format(self.term.text_in_color(file_path, ...
python
def replace_in_file(self, file_path, old_exp, new_exp): """ In the given file, replace all 'old_exp' by 'new_exp'. """ self.term.print_info(u"Making replacement into {}" .format(self.term.text_in_color(file_path, ...
[ "def", "replace_in_file", "(", "self", ",", "file_path", ",", "old_exp", ",", "new_exp", ")", ":", "self", ".", "term", ".", "print_info", "(", "u\"Making replacement into {}\"", ".", "format", "(", "self", ".", "term", ".", "text_in_color", "(", "file_path", ...
In the given file, replace all 'old_exp' by 'new_exp'.
[ "In", "the", "given", "file", "replace", "all", "old_exp", "by", "new_exp", "." ]
3146b0e3c207b977e1b51fcb33138746dae83c23
https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/templates/ProjyTemplate.py#L148-L166
244,581
dossier/dossier.models
dossier/models/openquery/fetcher.py
ChunkRoller.add
def add(self, si): '''puts `si` into the currently open chunk, which it creates if necessary. If this item causes the chunk to cross chunk_max, then the chunk closed after adding. ''' if self.o_chunk is None: if os.path.exists(self.t_path): os.remove...
python
def add(self, si): '''puts `si` into the currently open chunk, which it creates if necessary. If this item causes the chunk to cross chunk_max, then the chunk closed after adding. ''' if self.o_chunk is None: if os.path.exists(self.t_path): os.remove...
[ "def", "add", "(", "self", ",", "si", ")", ":", "if", "self", ".", "o_chunk", "is", "None", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "t_path", ")", ":", "os", ".", "remove", "(", "self", ".", "t_path", ")", "self", ".", ...
puts `si` into the currently open chunk, which it creates if necessary. If this item causes the chunk to cross chunk_max, then the chunk closed after adding.
[ "puts", "si", "into", "the", "currently", "open", "chunk", "which", "it", "creates", "if", "necessary", ".", "If", "this", "item", "causes", "the", "chunk", "to", "cross", "chunk_max", "then", "the", "chunk", "closed", "after", "adding", "." ]
c9e282f690eab72963926329efe1600709e48b13
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/openquery/fetcher.py#L108-L121
244,582
ikalnytskyi/dooku
dooku/algorithm.py
find_if
def find_if(pred, iterable, default=None): """ Returns a reference to the first element in the ``iterable`` range for which ``pred`` returns ``True``. If no such element is found, the function returns ``default``. >>> find_if(lambda x: x == 3, [1, 2, 3, 4]) 3 :param pred: a predica...
python
def find_if(pred, iterable, default=None): """ Returns a reference to the first element in the ``iterable`` range for which ``pred`` returns ``True``. If no such element is found, the function returns ``default``. >>> find_if(lambda x: x == 3, [1, 2, 3, 4]) 3 :param pred: a predica...
[ "def", "find_if", "(", "pred", ",", "iterable", ",", "default", "=", "None", ")", ":", "return", "next", "(", "(", "i", "for", "i", "in", "iterable", "if", "pred", "(", "i", ")", ")", ",", "default", ")" ]
Returns a reference to the first element in the ``iterable`` range for which ``pred`` returns ``True``. If no such element is found, the function returns ``default``. >>> find_if(lambda x: x == 3, [1, 2, 3, 4]) 3 :param pred: a predicate function to check a value from the iterable range ...
[ "Returns", "a", "reference", "to", "the", "first", "element", "in", "the", "iterable", "range", "for", "which", "pred", "returns", "True", ".", "If", "no", "such", "element", "is", "found", "the", "function", "returns", "default", "." ]
77e6c82c9c41211c86ee36ae5e591d477945fedf
https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/algorithm.py#L43-L57
244,583
twidi/py-dataql
dataql/parsers/generic.py
DataQLParser.visit_root
def visit_root(self, _, children): """The main node holding all the query. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``WS`` (whitespace): ``None``. - 1: for ``NAMED_RESOURCE``: an instance of a subclass of ``.resourc...
python
def visit_root(self, _, children): """The main node holding all the query. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``WS`` (whitespace): ``None``. - 1: for ``NAMED_RESOURCE``: an instance of a subclass of ``.resourc...
[ "def", "visit_root", "(", "self", ",", "_", ",", "children", ")", ":", "resource", "=", "children", "[", "1", "]", "resource", ".", "is_root", "=", "True", "return", "resource" ]
The main node holding all the query. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``WS`` (whitespace): ``None``. - 1: for ``NAMED_RESOURCE``: an instance of a subclass of ``.resources.Resource``. - 2: for ``WS`` (wh...
[ "The", "main", "node", "holding", "all", "the", "query", "." ]
5841a3fd559829193ed709c255166085bdde1c52
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/parsers/generic.py#L78-L127
244,584
twidi/py-dataql
dataql/parsers/generic.py
DataQLParser.visit_named_resource
def visit_named_resource(self, _, children): """A resource in the query with its optional name. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``OPTIONAL_RESOURCE_NAME``: str, the name of the resource, or ``None`` if not ...
python
def visit_named_resource(self, _, children): """A resource in the query with its optional name. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``OPTIONAL_RESOURCE_NAME``: str, the name of the resource, or ``None`` if not ...
[ "def", "visit_named_resource", "(", "self", ",", "_", ",", "children", ")", ":", "name", ",", "resource", "=", "children", "if", "name", ":", "resource", ".", "name", "=", "name", "return", "resource" ]
A resource in the query with its optional name. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``OPTIONAL_RESOURCE_NAME``: str, the name of the resource, or ``None`` if not set in the query. - 1: for ``RESOURCE``...
[ "A", "resource", "in", "the", "query", "with", "its", "optional", "name", "." ]
5841a3fd559829193ed709c255166085bdde1c52
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/parsers/generic.py#L167-L199
244,585
twidi/py-dataql
dataql/parsers/generic.py
DataQLParser.visit_field
def visit_field(self, _, children): """A simple field. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``FILTERS``: list of instances of ``.resources.Field``. Returns ------- .resources.Field An in...
python
def visit_field(self, _, children): """A simple field. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``FILTERS``: list of instances of ``.resources.Field``. Returns ------- .resources.Field An in...
[ "def", "visit_field", "(", "self", ",", "_", ",", "children", ")", ":", "filters", "=", "children", "[", "0", "]", "return", "self", ".", "Field", "(", "getattr", "(", "filters", "[", "0", "]", ",", "'name'", ",", "None", ")", ",", "filters", "=", ...
A simple field. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``FILTERS``: list of instances of ``.resources.Field``. Returns ------- .resources.Field An instance of ``.resources.Field`` with the correct...
[ "A", "simple", "field", "." ]
5841a3fd559829193ed709c255166085bdde1c52
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/parsers/generic.py#L373-L399
244,586
twidi/py-dataql
dataql/parsers/generic.py
DataQLParser.visit_named_object
def visit_named_object(self, _, children): """Manage an object, represented by a ``.resources.Object`` instance. This object is populated with data from the result of the ``FILTERS``. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - ...
python
def visit_named_object(self, _, children): """Manage an object, represented by a ``.resources.Object`` instance. This object is populated with data from the result of the ``FILTERS``. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - ...
[ "def", "visit_named_object", "(", "self", ",", "_", ",", "children", ")", ":", "filters", ",", "resource", "=", "children", "resource", ".", "name", "=", "filters", "[", "0", "]", ".", "name", "resource", ".", "filters", "=", "filters", "return", "resour...
Manage an object, represented by a ``.resources.Object`` instance. This object is populated with data from the result of the ``FILTERS``. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``FILTERS``: list of instances of ``.resources....
[ "Manage", "an", "object", "represented", "by", "a", ".", "resources", ".", "Object", "instance", "." ]
5841a3fd559829193ed709c255166085bdde1c52
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/parsers/generic.py#L402-L428
244,587
twidi/py-dataql
dataql/parsers/generic.py
DataQLParser.visit_named_list
def visit_named_list(self, _, children): """Manage a list, represented by a ``.resources.List`` instance. This list is populated with data from the result of the ``FILTERS``. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``...
python
def visit_named_list(self, _, children): """Manage a list, represented by a ``.resources.List`` instance. This list is populated with data from the result of the ``FILTERS``. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``...
[ "def", "visit_named_list", "(", "self", ",", "_", ",", "children", ")", ":", "filters", ",", "resource", "=", "children", "resource", ".", "name", "=", "filters", "[", "0", "]", ".", "name", "resource", ".", "filters", "=", "filters", "return", "resource...
Manage a list, represented by a ``.resources.List`` instance. This list is populated with data from the result of the ``FILTERS``. Arguments --------- _ (node) : parsimonious.nodes.Node. children : list - 0: for ``FILTERS``: list of instances of ``.resources.Field``...
[ "Manage", "a", "list", "represented", "by", "a", ".", "resources", ".", "List", "instance", "." ]
5841a3fd559829193ed709c255166085bdde1c52
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/parsers/generic.py#L456-L482
244,588
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/solar_system.py
load_constants
def load_constants(): """Load physical constants to simulate the earth-sun system""" # The universal gravitational constant # https://en.wikipedia.org/wiki/Gravitational_constant G: float = 6.67408E-11 # The names of the celestial bodies body_name = \ ['sun', 'moon', ...
python
def load_constants(): """Load physical constants to simulate the earth-sun system""" # The universal gravitational constant # https://en.wikipedia.org/wiki/Gravitational_constant G: float = 6.67408E-11 # The names of the celestial bodies body_name = \ ['sun', 'moon', ...
[ "def", "load_constants", "(", ")", ":", "# The universal gravitational constant", "# https://en.wikipedia.org/wiki/Gravitational_constant", "G", ":", "float", "=", "6.67408E-11", "# The names of the celestial bodies", "body_name", "=", "[", "'sun'", ",", "'moon'", ",", "'merc...
Load physical constants to simulate the earth-sun system
[ "Load", "physical", "constants", "to", "simulate", "the", "earth", "-", "sun", "system" ]
842e9c2d3ca1490cef18c086dfde81856d8d3a82
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/solar_system.py#L71-L122
244,589
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/solar_system.py
julian_day
def julian_day(t: date) -> int: """Convert a Python datetime to a Julian day""" # Compute the number of days from January 1, 2000 to date t dt = t - julian_base_date # Add the julian base number to the number of days from the julian base date to date t return julian_base_number + dt.days
python
def julian_day(t: date) -> int: """Convert a Python datetime to a Julian day""" # Compute the number of days from January 1, 2000 to date t dt = t - julian_base_date # Add the julian base number to the number of days from the julian base date to date t return julian_base_number + dt.days
[ "def", "julian_day", "(", "t", ":", "date", ")", "->", "int", ":", "# Compute the number of days from January 1, 2000 to date t", "dt", "=", "t", "-", "julian_base_date", "# Add the julian base number to the number of days from the julian base date to date t", "return", "julian_b...
Convert a Python datetime to a Julian day
[ "Convert", "a", "Python", "datetime", "to", "a", "Julian", "day" ]
842e9c2d3ca1490cef18c086dfde81856d8d3a82
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/solar_system.py#L126-L131
244,590
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/solar_system.py
calc_mse
def calc_mse(q1, q2): """Compare the results of two simulations""" # Difference in positions between two simulations dq = q2 - q1 # Mean squared error in AUs return np.sqrt(np.mean(dq*dq))/au2m
python
def calc_mse(q1, q2): """Compare the results of two simulations""" # Difference in positions between two simulations dq = q2 - q1 # Mean squared error in AUs return np.sqrt(np.mean(dq*dq))/au2m
[ "def", "calc_mse", "(", "q1", ",", "q2", ")", ":", "# Difference in positions between two simulations", "dq", "=", "q2", "-", "q1", "# Mean squared error in AUs", "return", "np", ".", "sqrt", "(", "np", ".", "mean", "(", "dq", "*", "dq", ")", ")", "/", "au...
Compare the results of two simulations
[ "Compare", "the", "results", "of", "two", "simulations" ]
842e9c2d3ca1490cef18c086dfde81856d8d3a82
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/solar_system.py#L134-L139
244,591
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/solar_system.py
flux_v2
def flux_v2(v_vars: List[fl.Var], i: int): """Make Fluxion with the speed squared of body i""" # Index with the base of (v_x, v_y, v_z) for body i k = 3*i # The speed squared of body i return fl.square(v_vars[k+0]) + fl.square(v_vars[k+1]) + fl.square(v_vars[k+2])
python
def flux_v2(v_vars: List[fl.Var], i: int): """Make Fluxion with the speed squared of body i""" # Index with the base of (v_x, v_y, v_z) for body i k = 3*i # The speed squared of body i return fl.square(v_vars[k+0]) + fl.square(v_vars[k+1]) + fl.square(v_vars[k+2])
[ "def", "flux_v2", "(", "v_vars", ":", "List", "[", "fl", ".", "Var", "]", ",", "i", ":", "int", ")", ":", "# Index with the base of (v_x, v_y, v_z) for body i", "k", "=", "3", "*", "i", "# The speed squared of body i", "return", "fl", ".", "square", "(", "v_...
Make Fluxion with the speed squared of body i
[ "Make", "Fluxion", "with", "the", "speed", "squared", "of", "body", "i" ]
842e9c2d3ca1490cef18c086dfde81856d8d3a82
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/solar_system.py#L213-L218
244,592
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/solar_system.py
U_ij
def U_ij(q_vars: List[fl.Var], mass: np.ndarray, i: int, j: int): """Make Fluxion with the gratiational potential energy beween body i and j""" # Check that the lengths are consistent assert len(q_vars) == 3 * len(mass) # Masses of the bodies i and j mi = mass[i] mj = mass[j] # Gra...
python
def U_ij(q_vars: List[fl.Var], mass: np.ndarray, i: int, j: int): """Make Fluxion with the gratiational potential energy beween body i and j""" # Check that the lengths are consistent assert len(q_vars) == 3 * len(mass) # Masses of the bodies i and j mi = mass[i] mj = mass[j] # Gra...
[ "def", "U_ij", "(", "q_vars", ":", "List", "[", "fl", ".", "Var", "]", ",", "mass", ":", "np", ".", "ndarray", ",", "i", ":", "int", ",", "j", ":", "int", ")", ":", "# Check that the lengths are consistent", "assert", "len", "(", "q_vars", ")", "==",...
Make Fluxion with the gratiational potential energy beween body i and j
[ "Make", "Fluxion", "with", "the", "gratiational", "potential", "energy", "beween", "body", "i", "and", "j" ]
842e9c2d3ca1490cef18c086dfde81856d8d3a82
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/solar_system.py#L225-L236
244,593
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/solar_system.py
T_i
def T_i(v_vars: List[fl.Var], mass: np.ndarray, i: int): """Make Fluxion with the kinetic energy of body i""" # Check that the lengths are consistent assert len(v_vars) == 3 * len(mass) # Mass of the body i m = mass[i] # kineteic energy = 1/2 * mass * speed^2 T = (0.5 * m) * flux_v2(v_...
python
def T_i(v_vars: List[fl.Var], mass: np.ndarray, i: int): """Make Fluxion with the kinetic energy of body i""" # Check that the lengths are consistent assert len(v_vars) == 3 * len(mass) # Mass of the body i m = mass[i] # kineteic energy = 1/2 * mass * speed^2 T = (0.5 * m) * flux_v2(v_...
[ "def", "T_i", "(", "v_vars", ":", "List", "[", "fl", ".", "Var", "]", ",", "mass", ":", "np", ".", "ndarray", ",", "i", ":", "int", ")", ":", "# Check that the lengths are consistent", "assert", "len", "(", "v_vars", ")", "==", "3", "*", "len", "(", ...
Make Fluxion with the kinetic energy of body i
[ "Make", "Fluxion", "with", "the", "kinetic", "energy", "of", "body", "i" ]
842e9c2d3ca1490cef18c086dfde81856d8d3a82
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/solar_system.py#L239-L249
244,594
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/solar_system.py
plot_energy
def plot_energy(time, H, T, U): """Plot kinetic and potential energy of system over time""" # Normalize energy to initial KE T0 = T[0] H = H / T0 T = T / T0 U = U / T0 # Plot fig, ax = plt.subplots(figsize=[16,8]) ax.set_title('System Energy vs. Time') ax.set_xlabel('Time in...
python
def plot_energy(time, H, T, U): """Plot kinetic and potential energy of system over time""" # Normalize energy to initial KE T0 = T[0] H = H / T0 T = T / T0 U = U / T0 # Plot fig, ax = plt.subplots(figsize=[16,8]) ax.set_title('System Energy vs. Time') ax.set_xlabel('Time in...
[ "def", "plot_energy", "(", "time", ",", "H", ",", "T", ",", "U", ")", ":", "# Normalize energy to initial KE", "T0", "=", "T", "[", "0", "]", "H", "=", "H", "/", "T0", "T", "=", "T", "/", "T0", "U", "=", "U", "/", "T0", "# Plot", "fig", ",", ...
Plot kinetic and potential energy of system over time
[ "Plot", "kinetic", "and", "potential", "energy", "of", "system", "over", "time" ]
842e9c2d3ca1490cef18c086dfde81856d8d3a82
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/solar_system.py#L253-L271
244,595
carlosp420/dataset-creator
dataset_creator/dataset.py
Dataset.sort_seq_records
def sort_seq_records(self, seq_records): """Checks that SeqExpandedRecords are sorted by gene_code and then by voucher code. The dashes in taxon names need to be converted to underscores so the dataset will be accepted by Biopython to do format conversions. """ for seq_record i...
python
def sort_seq_records(self, seq_records): """Checks that SeqExpandedRecords are sorted by gene_code and then by voucher code. The dashes in taxon names need to be converted to underscores so the dataset will be accepted by Biopython to do format conversions. """ for seq_record i...
[ "def", "sort_seq_records", "(", "self", ",", "seq_records", ")", ":", "for", "seq_record", "in", "seq_records", ":", "seq_record", ".", "voucher_code", "=", "seq_record", ".", "voucher_code", ".", "replace", "(", "\"-\"", ",", "\"_\"", ")", "unsorted_gene_codes"...
Checks that SeqExpandedRecords are sorted by gene_code and then by voucher code. The dashes in taxon names need to be converted to underscores so the dataset will be accepted by Biopython to do format conversions.
[ "Checks", "that", "SeqExpandedRecords", "are", "sorted", "by", "gene_code", "and", "then", "by", "voucher", "code", "." ]
ea27340b145cb566a36c1836ff42263f1b2003a0
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/dataset.py#L81-L109
244,596
carlosp420/dataset-creator
dataset_creator/dataset.py
Dataset._validate_outgroup
def _validate_outgroup(self, outgroup): """All voucher codes in our datasets have dashes converted to underscores.""" if outgroup: outgroup = outgroup.replace("-", "_") good_outgroup = False for seq_record in self.seq_records: if seq_record.voucher_cod...
python
def _validate_outgroup(self, outgroup): """All voucher codes in our datasets have dashes converted to underscores.""" if outgroup: outgroup = outgroup.replace("-", "_") good_outgroup = False for seq_record in self.seq_records: if seq_record.voucher_cod...
[ "def", "_validate_outgroup", "(", "self", ",", "outgroup", ")", ":", "if", "outgroup", ":", "outgroup", "=", "outgroup", ".", "replace", "(", "\"-\"", ",", "\"_\"", ")", "good_outgroup", "=", "False", "for", "seq_record", "in", "self", ".", "seq_records", ...
All voucher codes in our datasets have dashes converted to underscores.
[ "All", "voucher", "codes", "in", "our", "datasets", "have", "dashes", "converted", "to", "underscores", "." ]
ea27340b145cb566a36c1836ff42263f1b2003a0
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/dataset.py#L131-L146
244,597
carlosp420/dataset-creator
dataset_creator/dataset.py
Dataset._prepare_data
def _prepare_data(self): """ Creates named tuple with info needed to create a dataset. :return: named tuple """ self._extract_genes() self._extract_total_number_of_chars() self._extract_number_of_taxa() self._extract_reading_frames() Data = named...
python
def _prepare_data(self): """ Creates named tuple with info needed to create a dataset. :return: named tuple """ self._extract_genes() self._extract_total_number_of_chars() self._extract_number_of_taxa() self._extract_reading_frames() Data = named...
[ "def", "_prepare_data", "(", "self", ")", ":", "self", ".", "_extract_genes", "(", ")", "self", ".", "_extract_total_number_of_chars", "(", ")", "self", ".", "_extract_number_of_taxa", "(", ")", "self", ".", "_extract_reading_frames", "(", ")", "Data", "=", "n...
Creates named tuple with info needed to create a dataset. :return: named tuple
[ "Creates", "named", "tuple", "with", "info", "needed", "to", "create", "a", "dataset", "." ]
ea27340b145cb566a36c1836ff42263f1b2003a0
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/dataset.py#L148-L164
244,598
carlosp420/dataset-creator
dataset_creator/dataset.py
Dataset._extract_total_number_of_chars
def _extract_total_number_of_chars(self): """ sets `self.number_chars` to the number of characters as string. """ self._get_gene_codes_and_seq_lengths() sum = 0 for seq_length in self._gene_codes_and_lengths.values(): sum += sorted(seq_length, reverse=True)[0...
python
def _extract_total_number_of_chars(self): """ sets `self.number_chars` to the number of characters as string. """ self._get_gene_codes_and_seq_lengths() sum = 0 for seq_length in self._gene_codes_and_lengths.values(): sum += sorted(seq_length, reverse=True)[0...
[ "def", "_extract_total_number_of_chars", "(", "self", ")", ":", "self", ".", "_get_gene_codes_and_seq_lengths", "(", ")", "sum", "=", "0", "for", "seq_length", "in", "self", ".", "_gene_codes_and_lengths", ".", "values", "(", ")", ":", "sum", "+=", "sorted", "...
sets `self.number_chars` to the number of characters as string.
[ "sets", "self", ".", "number_chars", "to", "the", "number", "of", "characters", "as", "string", "." ]
ea27340b145cb566a36c1836ff42263f1b2003a0
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/dataset.py#L174-L183
244,599
carlosp420/dataset-creator
dataset_creator/dataset.py
Dataset._extract_number_of_taxa
def _extract_number_of_taxa(self): """ sets `self.number_taxa` to the number of taxa as string """ n_taxa = dict() for i in self.seq_records: if i.gene_code not in n_taxa: n_taxa[i.gene_code] = 0 n_taxa[i.gene_code] += 1 number_taxa...
python
def _extract_number_of_taxa(self): """ sets `self.number_taxa` to the number of taxa as string """ n_taxa = dict() for i in self.seq_records: if i.gene_code not in n_taxa: n_taxa[i.gene_code] = 0 n_taxa[i.gene_code] += 1 number_taxa...
[ "def", "_extract_number_of_taxa", "(", "self", ")", ":", "n_taxa", "=", "dict", "(", ")", "for", "i", "in", "self", ".", "seq_records", ":", "if", "i", ".", "gene_code", "not", "in", "n_taxa", ":", "n_taxa", "[", "i", ".", "gene_code", "]", "=", "0",...
sets `self.number_taxa` to the number of taxa as string
[ "sets", "self", ".", "number_taxa", "to", "the", "number", "of", "taxa", "as", "string" ]
ea27340b145cb566a36c1836ff42263f1b2003a0
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/dataset.py#L201-L211