Unnamed: 0 int64 0 10k | repository_name stringlengths 7 54 | func_path_in_repository stringlengths 5 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 100 30.3k | language stringclasses 1
value | func_code_string stringlengths 100 30.3k | func_code_tokens stringlengths 138 33.2k | func_documentation_string stringlengths 1 15k | func_documentation_tokens stringlengths 5 5.14k | split_name stringclasses 1
value | func_code_url stringlengths 91 315 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3,400 | dbcli/athenacli | athenacli/packages/filepaths.py | suggest_path | def suggest_path(root_dir):
"""List all files and subdirectories in a directory.
If the directory is not specified, suggest root directory,
user directory, current and parent directory.
:param root_dir: string: directory to list
:return: list
"""
if not root_dir:
return [os.path.absp... | python | def suggest_path(root_dir):
"""List all files and subdirectories in a directory.
If the directory is not specified, suggest root directory,
user directory, current and parent directory.
:param root_dir: string: directory to list
:return: list
"""
if not root_dir:
return [os.path.absp... | ['def', 'suggest_path', '(', 'root_dir', ')', ':', 'if', 'not', 'root_dir', ':', 'return', '[', 'os', '.', 'path', '.', 'abspath', '(', 'os', '.', 'sep', ')', ',', "'~'", ',', 'os', '.', 'curdir', ',', 'os', '.', 'pardir', ']', 'if', "'~'", 'in', 'root_dir', ':', 'root_dir', '=', 'os', '.', 'path', '.', 'expanduser', '... | List all files and subdirectories in a directory.
If the directory is not specified, suggest root directory,
user directory, current and parent directory.
:param root_dir: string: directory to list
:return: list | ['List', 'all', 'files', 'and', 'subdirectories', 'in', 'a', 'directory', '.', 'If', 'the', 'directory', 'is', 'not', 'specified', 'suggest', 'root', 'directory', 'user', 'directory', 'current', 'and', 'parent', 'directory', '.', ':', 'param', 'root_dir', ':', 'string', ':', 'directory', 'to', 'list', ':', 'return', ':... | train | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/filepaths.py#L44-L60 |
3,401 | MillionIntegrals/vel | vel/phase/cycle.py | CycleCallback.set_lr | def set_lr(self, lr):
""" Set a learning rate for the optimizer """
if isinstance(lr, list):
for group_lr, param_group in zip(lr, self.optimizer.param_groups):
param_group['lr'] = group_lr
else:
for param_group in self.optimizer.param_groups:
... | python | def set_lr(self, lr):
""" Set a learning rate for the optimizer """
if isinstance(lr, list):
for group_lr, param_group in zip(lr, self.optimizer.param_groups):
param_group['lr'] = group_lr
else:
for param_group in self.optimizer.param_groups:
... | ['def', 'set_lr', '(', 'self', ',', 'lr', ')', ':', 'if', 'isinstance', '(', 'lr', ',', 'list', ')', ':', 'for', 'group_lr', ',', 'param_group', 'in', 'zip', '(', 'lr', ',', 'self', '.', 'optimizer', '.', 'param_groups', ')', ':', 'param_group', '[', "'lr'", ']', '=', 'group_lr', 'else', ':', 'for', 'param_group', 'in'... | Set a learning rate for the optimizer | ['Set', 'a', 'learning', 'rate', 'for', 'the', 'optimizer'] | train | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/phase/cycle.py#L75-L82 |
3,402 | Microsoft/knack | knack/introspection.py | extract_full_summary_from_signature | def extract_full_summary_from_signature(operation):
""" Extract the summary from the docstring of the command. """
lines = inspect.getdoc(operation)
regex = r'\s*(:param)\s+(.+?)\s*:(.*)'
summary = ''
if lines:
match = re.search(regex, lines)
summary = lines[:match.regs[0][0]] if mat... | python | def extract_full_summary_from_signature(operation):
""" Extract the summary from the docstring of the command. """
lines = inspect.getdoc(operation)
regex = r'\s*(:param)\s+(.+?)\s*:(.*)'
summary = ''
if lines:
match = re.search(regex, lines)
summary = lines[:match.regs[0][0]] if mat... | ['def', 'extract_full_summary_from_signature', '(', 'operation', ')', ':', 'lines', '=', 'inspect', '.', 'getdoc', '(', 'operation', ')', 'regex', '=', "r'\\s*(:param)\\s+(.+?)\\s*:(.*)'", 'summary', '=', "''", 'if', 'lines', ':', 'match', '=', 're', '.', 'search', '(', 'regex', ',', 'lines', ')', 'summary', '=', 'line... | Extract the summary from the docstring of the command. | ['Extract', 'the', 'summary', 'from', 'the', 'docstring', 'of', 'the', 'command', '.'] | train | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/introspection.py#L15-L25 |
3,403 | saltstack/salt | salt/modules/boto_iam.py | list_policies | def list_policies(region=None, key=None, keyid=None, profile=None):
'''
List policies.
CLI Example:
.. code-block:: bash
salt myminion boto_iam.list_policies
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
try:
policies = []
for ret in _... | python | def list_policies(region=None, key=None, keyid=None, profile=None):
'''
List policies.
CLI Example:
.. code-block:: bash
salt myminion boto_iam.list_policies
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
try:
policies = []
for ret in _... | ['def', 'list_policies', '(', 'region', '=', 'None', ',', 'key', '=', 'None', ',', 'keyid', '=', 'None', ',', 'profile', '=', 'None', ')', ':', 'conn', '=', '_get_conn', '(', 'region', '=', 'region', ',', 'key', '=', 'key', ',', 'keyid', '=', 'keyid', ',', 'profile', '=', 'profile', ')', 'try', ':', 'policies', '=', '[... | List policies.
CLI Example:
.. code-block:: bash
salt myminion boto_iam.list_policies | ['List', 'policies', '.'] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_iam.py#L1806-L1827 |
3,404 | saltstack/salt | salt/cli/support/__init__.py | _render_profile | def _render_profile(path, caller, runner):
'''
Render profile as Jinja2.
:param path:
:return:
'''
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(path)), trim_blocks=False)
return env.get_template(os.path.basename(path)).render(salt=caller, runners=runner).strip() | python | def _render_profile(path, caller, runner):
'''
Render profile as Jinja2.
:param path:
:return:
'''
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(path)), trim_blocks=False)
return env.get_template(os.path.basename(path)).render(salt=caller, runners=runner).strip() | ['def', '_render_profile', '(', 'path', ',', 'caller', ',', 'runner', ')', ':', 'env', '=', 'jinja2', '.', 'Environment', '(', 'loader', '=', 'jinja2', '.', 'FileSystemLoader', '(', 'os', '.', 'path', '.', 'dirname', '(', 'path', ')', ')', ',', 'trim_blocks', '=', 'False', ')', 'return', 'env', '.', 'get_template', '('... | Render profile as Jinja2.
:param path:
:return: | ['Render', 'profile', 'as', 'Jinja2', '.', ':', 'param', 'path', ':', ':', 'return', ':'] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/__init__.py#L15-L22 |
3,405 | marcotcr/lime | lime/lime_tabular.py | TableDomainMapper.map_exp_ids | def map_exp_ids(self, exp):
"""Maps ids to feature names.
Args:
exp: list of tuples [(id, weight), (id,weight)]
Returns:
list of tuples (feature_name, weight)
"""
names = self.exp_feature_names
if self.discretized_feature_names is not None:
... | python | def map_exp_ids(self, exp):
"""Maps ids to feature names.
Args:
exp: list of tuples [(id, weight), (id,weight)]
Returns:
list of tuples (feature_name, weight)
"""
names = self.exp_feature_names
if self.discretized_feature_names is not None:
... | ['def', 'map_exp_ids', '(', 'self', ',', 'exp', ')', ':', 'names', '=', 'self', '.', 'exp_feature_names', 'if', 'self', '.', 'discretized_feature_names', 'is', 'not', 'None', ':', 'names', '=', 'self', '.', 'discretized_feature_names', 'return', '[', '(', 'names', '[', 'x', '[', '0', ']', ']', ',', 'x', '[', '1', ']', ... | Maps ids to feature names.
Args:
exp: list of tuples [(id, weight), (id,weight)]
Returns:
list of tuples (feature_name, weight) | ['Maps', 'ids', 'to', 'feature', 'names', '.'] | train | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L45-L57 |
3,406 | resync/resync | resync/resource_set.py | ResourceSet.add | def add(self, resource, replace=False):
"""Add just a single resource."""
uri = resource.uri
if (uri in self and not replace):
raise ResourceSetDupeError(
"Attempt to add resource already in this set")
self[uri] = resource | python | def add(self, resource, replace=False):
"""Add just a single resource."""
uri = resource.uri
if (uri in self and not replace):
raise ResourceSetDupeError(
"Attempt to add resource already in this set")
self[uri] = resource | ['def', 'add', '(', 'self', ',', 'resource', ',', 'replace', '=', 'False', ')', ':', 'uri', '=', 'resource', '.', 'uri', 'if', '(', 'uri', 'in', 'self', 'and', 'not', 'replace', ')', ':', 'raise', 'ResourceSetDupeError', '(', '"Attempt to add resource already in this set"', ')', 'self', '[', 'uri', ']', '=', 'resource'... | Add just a single resource. | ['Add', 'just', 'a', 'single', 'resource', '.'] | train | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_set.py#L30-L36 |
3,407 | diffeo/rejester | rejester/_registry.py | Registry.popitem_move | def popitem_move(self, from_dict, to_dict,
priority_min='-inf', priority_max='+inf'):
'''Select an item and move it to another dictionary.
The item comes from `from_dict`, and has the lowest score
at least `priority_min` and at most `priority_max`. If some
item is ... | python | def popitem_move(self, from_dict, to_dict,
priority_min='-inf', priority_max='+inf'):
'''Select an item and move it to another dictionary.
The item comes from `from_dict`, and has the lowest score
at least `priority_min` and at most `priority_max`. If some
item is ... | ['def', 'popitem_move', '(', 'self', ',', 'from_dict', ',', 'to_dict', ',', 'priority_min', '=', "'-inf'", ',', 'priority_max', '=', "'+inf'", ')', ':', 'if', 'self', '.', '_session_lock_identifier', 'is', 'None', ':', 'raise', 'ProgrammerError', '(', "'must acquire lock first'", ')', 'conn', '=', 'redis', '.', 'Redis'... | Select an item and move it to another dictionary.
The item comes from `from_dict`, and has the lowest score
at least `priority_min` and at most `priority_max`. If some
item is found, remove it from `from_dict`, add it to `to_dict`,
and return it.
This runs as a single atomic o... | ['Select', 'an', 'item', 'and', 'move', 'it', 'to', 'another', 'dictionary', '.'] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_registry.py#L581-L650 |
3,408 | mitsei/dlkit | dlkit/handcar/learning/sessions.py | ObjectiveBankAdminSession._record_extension | def _record_extension(self, bank_id, key, value):
"""
To structure a record extension property bean
"""
record_bean = {
'value': value,
'displayName': self._text_bean(key),
'description': self._text_bean(key),
'displayLabel': self._text_bea... | python | def _record_extension(self, bank_id, key, value):
"""
To structure a record extension property bean
"""
record_bean = {
'value': value,
'displayName': self._text_bean(key),
'description': self._text_bean(key),
'displayLabel': self._text_bea... | ['def', '_record_extension', '(', 'self', ',', 'bank_id', ',', 'key', ',', 'value', ')', ':', 'record_bean', '=', '{', "'value'", ':', 'value', ',', "'displayName'", ':', 'self', '.', '_text_bean', '(', 'key', ')', ',', "'description'", ':', 'self', '.', '_text_bean', '(', 'key', ')', ',', "'displayLabel'", ':', 'self'... | To structure a record extension property bean | ['To', 'structure', 'a', 'record', 'extension', 'property', 'bean'] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/sessions.py#L3667-L3678 |
3,409 | dls-controls/pymalcolm | malcolm/core/serializable.py | camel_to_title | def camel_to_title(name):
"""Takes a camelCaseFieldName and returns an Title Case Field Name
Args:
name (str): E.g. camelCaseFieldName
Returns:
str: Title Case converted name. E.g. Camel Case Field Name
"""
split = re.findall(r"[A-Z]?[a-z0-9]+|[A-Z]+(?=[A-Z]|$)", name)
ret = " ... | python | def camel_to_title(name):
"""Takes a camelCaseFieldName and returns an Title Case Field Name
Args:
name (str): E.g. camelCaseFieldName
Returns:
str: Title Case converted name. E.g. Camel Case Field Name
"""
split = re.findall(r"[A-Z]?[a-z0-9]+|[A-Z]+(?=[A-Z]|$)", name)
ret = " ... | ['def', 'camel_to_title', '(', 'name', ')', ':', 'split', '=', 're', '.', 'findall', '(', 'r"[A-Z]?[a-z0-9]+|[A-Z]+(?=[A-Z]|$)"', ',', 'name', ')', 'ret', '=', '" "', '.', 'join', '(', 'split', ')', 'ret', '=', 'ret', '[', '0', ']', '.', 'upper', '(', ')', '+', 'ret', '[', '1', ':', ']', 'return', 'ret'] | Takes a camelCaseFieldName and returns an Title Case Field Name
Args:
name (str): E.g. camelCaseFieldName
Returns:
str: Title Case converted name. E.g. Camel Case Field Name | ['Takes', 'a', 'camelCaseFieldName', 'and', 'returns', 'an', 'Title', 'Case', 'Field', 'Name'] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/serializable.py#L55-L67 |
3,410 | QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/command_orchestrator.py | CommandOrchestrator._parse_remote_model | def _parse_remote_model(self, context):
"""
parse the remote resource model and adds its full name
:type context: models.QualiDriverModels.ResourceRemoteCommandContext
"""
if not context.remote_endpoints:
raise Exception('no remote resources found in context: {0}', j... | python | def _parse_remote_model(self, context):
"""
parse the remote resource model and adds its full name
:type context: models.QualiDriverModels.ResourceRemoteCommandContext
"""
if not context.remote_endpoints:
raise Exception('no remote resources found in context: {0}', j... | ['def', '_parse_remote_model', '(', 'self', ',', 'context', ')', ':', 'if', 'not', 'context', '.', 'remote_endpoints', ':', 'raise', 'Exception', '(', "'no remote resources found in context: {0}'", ',', 'jsonpickle', '.', 'encode', '(', 'context', ',', 'unpicklable', '=', 'False', ')', ')', 'resource', '=', 'context', ... | parse the remote resource model and adds its full name
:type context: models.QualiDriverModels.ResourceRemoteCommandContext | ['parse', 'the', 'remote', 'resource', 'model', 'and', 'adds', 'its', 'full', 'name', ':', 'type', 'context', ':', 'models', '.', 'QualiDriverModels', '.', 'ResourceRemoteCommandContext'] | train | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/command_orchestrator.py#L432-L450 |
3,411 | cbrand/vpnchooser | src/vpnchooser/resources/user.py | UserResource.delete | def delete(self, user_name: str):
"""
Deletes the resource with the given name.
"""
user = self._get_or_abort(user_name)
session.delete(user)
session.commit()
return '', 204 | python | def delete(self, user_name: str):
"""
Deletes the resource with the given name.
"""
user = self._get_or_abort(user_name)
session.delete(user)
session.commit()
return '', 204 | ['def', 'delete', '(', 'self', ',', 'user_name', ':', 'str', ')', ':', 'user', '=', 'self', '.', '_get_or_abort', '(', 'user_name', ')', 'session', '.', 'delete', '(', 'user', ')', 'session', '.', 'commit', '(', ')', 'return', "''", ',', '204'] | Deletes the resource with the given name. | ['Deletes', 'the', 'resource', 'with', 'the', 'given', 'name', '.'] | train | https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/resources/user.py#L111-L118 |
3,412 | nuagenetworks/bambou | bambou/nurest_fetcher.py | NURESTFetcher._send_content | def _send_content(self, content, connection):
""" Send a content array from the connection """
if connection:
if connection.async:
callback = connection.callbacks['remote']
if callback:
callback(self, self.parent_object, content)
... | python | def _send_content(self, content, connection):
""" Send a content array from the connection """
if connection:
if connection.async:
callback = connection.callbacks['remote']
if callback:
callback(self, self.parent_object, content)
... | ['def', '_send_content', '(', 'self', ',', 'content', ',', 'connection', ')', ':', 'if', 'connection', ':', 'if', 'connection', '.', 'async', ':', 'callback', '=', 'connection', '.', 'callbacks', '[', "'remote'", ']', 'if', 'callback', ':', 'callback', '(', 'self', ',', 'self', '.', 'parent_object', ',', 'content', ')'... | Send a content array from the connection | ['Send', 'a', 'content', 'array', 'from', 'the', 'connection'] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_fetcher.py#L481-L495 |
3,413 | akfullfo/taskforce | taskforce/task.py | legion.task_del | def task_del(self, t):
"""
Remove a task in this legion.
If the task has active processes, an attempt is made to
stop them before the task is deleted.
"""
name = t._name
if name in self._tasknames:
del self._tasknames[name]
self._tasks.discard(t)
... | python | def task_del(self, t):
"""
Remove a task in this legion.
If the task has active processes, an attempt is made to
stop them before the task is deleted.
"""
name = t._name
if name in self._tasknames:
del self._tasknames[name]
self._tasks.discard(t)
... | ['def', 'task_del', '(', 'self', ',', 't', ')', ':', 'name', '=', 't', '.', '_name', 'if', 'name', 'in', 'self', '.', '_tasknames', ':', 'del', 'self', '.', '_tasknames', '[', 'name', ']', 'self', '.', '_tasks', '.', 'discard', '(', 't', ')', 'self', '.', '_tasks_scoped', '.', 'discard', '(', 't', ')', 'try', ':', 't',... | Remove a task in this legion.
If the task has active processes, an attempt is made to
stop them before the task is deleted. | ['Remove', 'a', 'task', 'in', 'this', 'legion', '.', 'If', 'the', 'task', 'has', 'active', 'processes', 'an', 'attempt', 'is', 'made', 'to', 'stop', 'them', 'before', 'the', 'task', 'is', 'deleted', '.'] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1233-L1250 |
3,414 | avelkoski/FRB | fred/clients/releases.py | ReleasesClient.all_releases | def all_releases(self,response_type=None,params=None):
"""
Function to request all releases of economic data.
`<https://research.stlouisfed.org/docs/api/fred/releases.html>`_
:arg str response_type: File extension of response. Options are 'xml', 'json',
'dict... | python | def all_releases(self,response_type=None,params=None):
"""
Function to request all releases of economic data.
`<https://research.stlouisfed.org/docs/api/fred/releases.html>`_
:arg str response_type: File extension of response. Options are 'xml', 'json',
'dict... | ['def', 'all_releases', '(', 'self', ',', 'response_type', '=', 'None', ',', 'params', '=', 'None', ')', ':', 'path', '=', "'/releases?'", 'response_type', '=', 'response_type', 'if', 'response_type', 'else', 'self', '.', 'response_type', 'if', 'response_type', '!=', "'xml'", ':', 'params', '[', "'file_type'", ']', '='... | Function to request all releases of economic data.
`<https://research.stlouisfed.org/docs/api/fred/releases.html>`_
:arg str response_type: File extension of response. Options are 'xml', 'json',
'dict','df','numpy','csv','tab,'pipe'. Required.
:arg str realtime_start... | ['Function', 'to', 'request', 'all', 'releases', 'of', 'economic', 'data', '.', '<https', ':', '//', 'research', '.', 'stlouisfed', '.', 'org', '/', 'docs', '/', 'api', '/', 'fred', '/', 'releases', '.', 'html', '>', '_'] | train | https://github.com/avelkoski/FRB/blob/692bcf576e17bd1a81db2b7644f4f61aeb39e5c7/fred/clients/releases.py#L12-L32 |
3,415 | StanfordVL/robosuite | robosuite/environments/baxter.py | BaxterEnv._get_observation | def _get_observation(self):
"""
Returns an OrderedDict containing observations [(name_string, np.array), ...].
Important keys:
robot-state: contains robot-centric information.
"""
di = super()._get_observation()
# proprioceptive features
di["j... | python | def _get_observation(self):
"""
Returns an OrderedDict containing observations [(name_string, np.array), ...].
Important keys:
robot-state: contains robot-centric information.
"""
di = super()._get_observation()
# proprioceptive features
di["j... | ['def', '_get_observation', '(', 'self', ')', ':', 'di', '=', 'super', '(', ')', '.', '_get_observation', '(', ')', '# proprioceptive features', 'di', '[', '"joint_pos"', ']', '=', 'np', '.', 'array', '(', '[', 'self', '.', 'sim', '.', 'data', '.', 'qpos', '[', 'x', ']', 'for', 'x', 'in', 'self', '.', '_ref_joint_pos_i... | Returns an OrderedDict containing observations [(name_string, np.array), ...].
Important keys:
robot-state: contains robot-centric information. | ['Returns', 'an', 'OrderedDict', 'containing', 'observations', '[', '(', 'name_string', 'np', '.', 'array', ')', '...', ']', '.', 'Important', 'keys', ':', 'robot', '-', 'state', ':', 'contains', 'robot', '-', 'centric', 'information', '.'] | train | https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/environments/baxter.py#L248-L312 |
3,416 | fitnr/twitter_bot_utils | twitter_bot_utils/args.py | add_logger | def add_logger(name, level=None, format=None):
'''
Set up a stdout logger.
Args:
name (str): name of the logger
level: defaults to logging.INFO
format (str): format string for logging output.
defaults to ``%(filename)-11s %(lineno)-3d: %(message)s``.
Retur... | python | def add_logger(name, level=None, format=None):
'''
Set up a stdout logger.
Args:
name (str): name of the logger
level: defaults to logging.INFO
format (str): format string for logging output.
defaults to ``%(filename)-11s %(lineno)-3d: %(message)s``.
Retur... | ['def', 'add_logger', '(', 'name', ',', 'level', '=', 'None', ',', 'format', '=', 'None', ')', ':', 'format', '=', 'format', 'or', "'%(filename)-11s %(lineno)-3d: %(message)s'", 'log', '=', 'logging', '.', 'getLogger', '(', 'name', ')', '# Set logging level.', 'log', '.', 'setLevel', '(', 'level', 'or', 'logging', '.',... | Set up a stdout logger.
Args:
name (str): name of the logger
level: defaults to logging.INFO
format (str): format string for logging output.
defaults to ``%(filename)-11s %(lineno)-3d: %(message)s``.
Returns:
The logger object. | ['Set', 'up', 'a', 'stdout', 'logger', '.'] | train | https://github.com/fitnr/twitter_bot_utils/blob/21f35afa5048cd3efa54db8cb87d405f69a78a62/twitter_bot_utils/args.py#L69-L92 |
3,417 | saltstack/salt | salt/utils/user.py | get_uid | def get_uid(user=None):
'''
Get the uid for a given user name. If no user given, the current euid will
be returned. If the user does not exist, None will be returned. On systems
which do not support pwd or os.geteuid, None will be returned.
'''
if not HAS_PWD:
return None
elif user i... | python | def get_uid(user=None):
'''
Get the uid for a given user name. If no user given, the current euid will
be returned. If the user does not exist, None will be returned. On systems
which do not support pwd or os.geteuid, None will be returned.
'''
if not HAS_PWD:
return None
elif user i... | ['def', 'get_uid', '(', 'user', '=', 'None', ')', ':', 'if', 'not', 'HAS_PWD', ':', 'return', 'None', 'elif', 'user', 'is', 'None', ':', 'try', ':', 'return', 'os', '.', 'geteuid', '(', ')', 'except', 'AttributeError', ':', 'return', 'None', 'else', ':', 'try', ':', 'return', 'pwd', '.', 'getpwnam', '(', 'user', ')', '... | Get the uid for a given user name. If no user given, the current euid will
be returned. If the user does not exist, None will be returned. On systems
which do not support pwd or os.geteuid, None will be returned. | ['Get', 'the', 'uid', 'for', 'a', 'given', 'user', 'name', '.', 'If', 'no', 'user', 'given', 'the', 'current', 'euid', 'will', 'be', 'returned', '.', 'If', 'the', 'user', 'does', 'not', 'exist', 'None', 'will', 'be', 'returned', '.', 'On', 'systems', 'which', 'do', 'not', 'support', 'pwd', 'or', 'os', '.', 'geteuid', '... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L69-L86 |
3,418 | saltstack/salt | salt/renderers/gpg.py | _get_key_dir | def _get_key_dir():
'''
return the location of the GPG key directory
'''
gpg_keydir = None
if 'config.get' in __salt__:
gpg_keydir = __salt__['config.get']('gpg_keydir')
if not gpg_keydir:
gpg_keydir = __opts__.get(
'gpg_keydir',
os.path.join(
... | python | def _get_key_dir():
'''
return the location of the GPG key directory
'''
gpg_keydir = None
if 'config.get' in __salt__:
gpg_keydir = __salt__['config.get']('gpg_keydir')
if not gpg_keydir:
gpg_keydir = __opts__.get(
'gpg_keydir',
os.path.join(
... | ['def', '_get_key_dir', '(', ')', ':', 'gpg_keydir', '=', 'None', 'if', "'config.get'", 'in', '__salt__', ':', 'gpg_keydir', '=', '__salt__', '[', "'config.get'", ']', '(', "'gpg_keydir'", ')', 'if', 'not', 'gpg_keydir', ':', 'gpg_keydir', '=', '__opts__', '.', 'get', '(', "'gpg_keydir'", ',', 'os', '.', 'path', '.', '... | return the location of the GPG key directory | ['return', 'the', 'location', 'of', 'the', 'GPG', 'key', 'directory'] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/gpg.py#L307-L326 |
3,419 | shazow/unstdlib.py | unstdlib/standard/string_.py | number_to_string | def number_to_string(n, alphabet):
"""
Given an non-negative integer ``n``, convert it to a string composed of
the given ``alphabet`` mapping, where the position of each element in
``alphabet`` is its radix value.
Examples::
>>> number_to_string(12345678, '01')
'1011110001100001010... | python | def number_to_string(n, alphabet):
"""
Given an non-negative integer ``n``, convert it to a string composed of
the given ``alphabet`` mapping, where the position of each element in
``alphabet`` is its radix value.
Examples::
>>> number_to_string(12345678, '01')
'1011110001100001010... | ['def', 'number_to_string', '(', 'n', ',', 'alphabet', ')', ':', 'result', '=', "''", 'base', '=', 'len', '(', 'alphabet', ')', 'current', '=', 'int', '(', 'n', ')', 'if', 'current', '<', '0', ':', 'raise', 'ValueError', '(', '"invalid n (must be non-negative): %s"', ',', 'n', ')', 'while', 'current', ':', 'result', '=... | Given an non-negative integer ``n``, convert it to a string composed of
the given ``alphabet`` mapping, where the position of each element in
``alphabet`` is its radix value.
Examples::
>>> number_to_string(12345678, '01')
'101111000110000101001110'
>>> number_to_string(12345678, ... | ['Given', 'an', 'non', '-', 'negative', 'integer', 'n', 'convert', 'it', 'to', 'a', 'string', 'composed', 'of', 'the', 'given', 'alphabet', 'mapping', 'where', 'the', 'position', 'of', 'each', 'element', 'in', 'alphabet', 'is', 'its', 'radix', 'value', '.'] | train | https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/string_.py#L53-L83 |
3,420 | Workiva/furious | furious/async.py | Async.context_id | def context_id(self):
"""Return this Async's Context Id if it exists."""
if not self._context_id:
self._context_id = self._get_context_id()
self.update_options(context_id=self._context_id)
return self._context_id | python | def context_id(self):
"""Return this Async's Context Id if it exists."""
if not self._context_id:
self._context_id = self._get_context_id()
self.update_options(context_id=self._context_id)
return self._context_id | ['def', 'context_id', '(', 'self', ')', ':', 'if', 'not', 'self', '.', '_context_id', ':', 'self', '.', '_context_id', '=', 'self', '.', '_get_context_id', '(', ')', 'self', '.', 'update_options', '(', 'context_id', '=', 'self', '.', '_context_id', ')', 'return', 'self', '.', '_context_id'] | Return this Async's Context Id if it exists. | ['Return', 'this', 'Async', 's', 'Context', 'Id', 'if', 'it', 'exists', '.'] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/async.py#L515-L521 |
3,421 | dpgaspar/Flask-AppBuilder | flask_appbuilder/cli.py | list_users | def list_users():
"""
List all users on the database
"""
echo_header("List of users")
for user in current_app.appbuilder.sm.get_all_users():
click.echo(
"username:{0} | email:{1} | role:{2}".format(
user.username, user.email, user.roles
)
) | python | def list_users():
"""
List all users on the database
"""
echo_header("List of users")
for user in current_app.appbuilder.sm.get_all_users():
click.echo(
"username:{0} | email:{1} | role:{2}".format(
user.username, user.email, user.roles
)
) | ['def', 'list_users', '(', ')', ':', 'echo_header', '(', '"List of users"', ')', 'for', 'user', 'in', 'current_app', '.', 'appbuilder', '.', 'sm', '.', 'get_all_users', '(', ')', ':', 'click', '.', 'echo', '(', '"username:{0} | email:{1} | role:{2}"', '.', 'format', '(', 'user', '.', 'username', ',', 'user', '.', 'emai... | List all users on the database | ['List', 'all', 'users', 'on', 'the', 'database'] | train | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/cli.py#L163-L173 |
3,422 | JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py | MAVLink.fence_fetch_point_send | def fence_fetch_point_send(self, target_system, target_component, idx, force_mavlink1=False):
'''
Request a current fence point from MAV
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
idx... | python | def fence_fetch_point_send(self, target_system, target_component, idx, force_mavlink1=False):
'''
Request a current fence point from MAV
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
idx... | ['def', 'fence_fetch_point_send', '(', 'self', ',', 'target_system', ',', 'target_component', ',', 'idx', ',', 'force_mavlink1', '=', 'False', ')', ':', 'return', 'self', '.', 'send', '(', 'self', '.', 'fence_fetch_point_encode', '(', 'target_system', ',', 'target_component', ',', 'idx', ')', ',', 'force_mavlink1', '='... | Request a current fence point from MAV
target_system : System ID (uint8_t)
target_component : Component ID (uint8_t)
idx : point index (first point is 1, 0 is for return point) (uint8_t) | ['Request', 'a', 'current', 'fence', 'point', 'from', 'MAV'] | train | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10005-L10014 |
3,423 | StackStorm/pybind | pybind/nos/v6_0_2f/interface/port_channel/switchport/private_vlan/__init__.py | private_vlan._set_association | def _set_association(self, v, load=False):
"""
Setter method for association, mapped from YANG variable /interface/port_channel/switchport/private_vlan/association (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_association is considered as a private
meth... | python | def _set_association(self, v, load=False):
"""
Setter method for association, mapped from YANG variable /interface/port_channel/switchport/private_vlan/association (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_association is considered as a private
meth... | ['def', '_set_association', '(', 'self', ',', 'v', ',', 'load', '=', 'False', ')', ':', 'if', 'hasattr', '(', 'v', ',', '"_utype"', ')', ':', 'v', '=', 'v', '.', '_utype', '(', 'v', ')', 'try', ':', 't', '=', 'YANGDynClass', '(', 'v', ',', 'base', '=', 'association', '.', 'association', ',', 'is_container', '=', "'cont... | Setter method for association, mapped from YANG variable /interface/port_channel/switchport/private_vlan/association (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_association is considered as a private
method. Backends looking to populate this variable should
... | ['Setter', 'method', 'for', 'association', 'mapped', 'from', 'YANG', 'variable', '/', 'interface', '/', 'port_channel', '/', 'switchport', '/', 'private_vlan', '/', 'association', '(', 'container', ')', 'If', 'this', 'variable', 'is', 'read', '-', 'only', '(', 'config', ':', 'false', ')', 'in', 'the', 'source', 'YANG',... | train | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/interface/port_channel/switchport/private_vlan/__init__.py#L176-L199 |
3,424 | libtcod/python-tcod | tcod/path.py | _get_pathcost_func | def _get_pathcost_func(
name: str
) -> Callable[[int, int, int, int, Any], float]:
"""Return a properly cast PathCostArray callback."""
return ffi.cast( # type: ignore
"TCOD_path_func_t", ffi.addressof(lib, name)
) | python | def _get_pathcost_func(
name: str
) -> Callable[[int, int, int, int, Any], float]:
"""Return a properly cast PathCostArray callback."""
return ffi.cast( # type: ignore
"TCOD_path_func_t", ffi.addressof(lib, name)
) | ['def', '_get_pathcost_func', '(', 'name', ':', 'str', ')', '->', 'Callable', '[', '[', 'int', ',', 'int', ',', 'int', ',', 'int', ',', 'Any', ']', ',', 'float', ']', ':', 'return', 'ffi', '.', 'cast', '(', '# type: ignore', '"TCOD_path_func_t"', ',', 'ffi', '.', 'addressof', '(', 'lib', ',', 'name', ')', ')'] | Return a properly cast PathCostArray callback. | ['Return', 'a', 'properly', 'cast', 'PathCostArray', 'callback', '.'] | train | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/path.py#L82-L88 |
3,425 | dmcc/PyStanfordDependencies | StanfordDependencies/CoNLL.py | Token.from_conll | def from_conll(this_class, text):
"""Construct a Token from a line in CoNLL-X format."""
fields = text.split('\t')
fields[0] = int(fields[0]) # index
fields[6] = int(fields[6]) # head index
if fields[5] != '_': # feats
fields[5] = tuple(fields[5].split('|'))
f... | python | def from_conll(this_class, text):
"""Construct a Token from a line in CoNLL-X format."""
fields = text.split('\t')
fields[0] = int(fields[0]) # index
fields[6] = int(fields[6]) # head index
if fields[5] != '_': # feats
fields[5] = tuple(fields[5].split('|'))
f... | ['def', 'from_conll', '(', 'this_class', ',', 'text', ')', ':', 'fields', '=', 'text', '.', 'split', '(', "'\\t'", ')', 'fields', '[', '0', ']', '=', 'int', '(', 'fields', '[', '0', ']', ')', '# index', 'fields', '[', '6', ']', '=', 'int', '(', 'fields', '[', '6', ']', ')', '# head index', 'if', 'fields', '[', '5', ']'... | Construct a Token from a line in CoNLL-X format. | ['Construct', 'a', 'Token', 'from', 'a', 'line', 'in', 'CoNLL', '-', 'X', 'format', '.'] | train | https://github.com/dmcc/PyStanfordDependencies/blob/43d8f38a19e40087f273330087918c87df6d4d8f/StanfordDependencies/CoNLL.py#L85-L94 |
3,426 | bjodah/chempy | chempy/equilibria.py | EqSystem.dissolved | def dissolved(self, concs):
""" Return dissolved concentrations """
new_concs = concs.copy()
for r in self.rxns:
if r.has_precipitates(self.substances):
net_stoich = np.asarray(r.net_stoich(self.substances))
s_net, s_stoich, s_idx = r.precipitate_stoic... | python | def dissolved(self, concs):
""" Return dissolved concentrations """
new_concs = concs.copy()
for r in self.rxns:
if r.has_precipitates(self.substances):
net_stoich = np.asarray(r.net_stoich(self.substances))
s_net, s_stoich, s_idx = r.precipitate_stoic... | ['def', 'dissolved', '(', 'self', ',', 'concs', ')', ':', 'new_concs', '=', 'concs', '.', 'copy', '(', ')', 'for', 'r', 'in', 'self', '.', 'rxns', ':', 'if', 'r', '.', 'has_precipitates', '(', 'self', '.', 'substances', ')', ':', 'net_stoich', '=', 'np', '.', 'asarray', '(', 'r', '.', 'net_stoich', '(', 'self', '.', 's... | Return dissolved concentrations | ['Return', 'dissolved', 'concentrations'] | train | https://github.com/bjodah/chempy/blob/bd62c3e1f7cb797782471203acd3bcf23b21c47e/chempy/equilibria.py#L93-L101 |
3,427 | oasis-open/cti-stix-validator | stix2validator/output.py | print_results | def print_results(results):
"""Print `results` (the results of validation) to stdout.
Args:
results: A list of FileValidationResults or ObjectValidationResults
instances.
"""
if not isinstance(results, list):
results = [results]
for r in results:
try:
... | python | def print_results(results):
"""Print `results` (the results of validation) to stdout.
Args:
results: A list of FileValidationResults or ObjectValidationResults
instances.
"""
if not isinstance(results, list):
results = [results]
for r in results:
try:
... | ['def', 'print_results', '(', 'results', ')', ':', 'if', 'not', 'isinstance', '(', 'results', ',', 'list', ')', ':', 'results', '=', '[', 'results', ']', 'for', 'r', 'in', 'results', ':', 'try', ':', 'r', '.', 'log', '(', ')', 'except', 'AttributeError', ':', 'raise', 'ValueError', '(', "'Argument to print_results() mu... | Print `results` (the results of validation) to stdout.
Args:
results: A list of FileValidationResults or ObjectValidationResults
instances. | ['Print', 'results', '(', 'the', 'results', 'of', 'validation', ')', 'to', 'stdout', '.'] | train | https://github.com/oasis-open/cti-stix-validator/blob/a607014e3fa500a7678f8b61b278456ca581f9d0/stix2validator/output.py#L191-L207 |
3,428 | gwpy/gwpy | gwpy/plot/colorbar.py | find_mappable | def find_mappable(*axes):
"""Find the most recently added mappable layer in the given axes
Parameters
----------
*axes : `~matplotlib.axes.Axes`
one or more axes to search for a mappable
"""
for ax in axes:
for aset in ('collections', 'images'):
try:
... | python | def find_mappable(*axes):
"""Find the most recently added mappable layer in the given axes
Parameters
----------
*axes : `~matplotlib.axes.Axes`
one or more axes to search for a mappable
"""
for ax in axes:
for aset in ('collections', 'images'):
try:
... | ['def', 'find_mappable', '(', '*', 'axes', ')', ':', 'for', 'ax', 'in', 'axes', ':', 'for', 'aset', 'in', '(', "'collections'", ',', "'images'", ')', ':', 'try', ':', 'return', 'getattr', '(', 'ax', ',', 'aset', ')', '[', '-', '1', ']', 'except', '(', 'AttributeError', ',', 'IndexError', ')', ':', 'continue', 'raise', ... | Find the most recently added mappable layer in the given axes
Parameters
----------
*axes : `~matplotlib.axes.Axes`
one or more axes to search for a mappable | ['Find', 'the', 'most', 'recently', 'added', 'mappable', 'layer', 'in', 'the', 'given', 'axes'] | train | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/plot/colorbar.py#L99-L114 |
3,429 | networks-lab/metaknowledge | metaknowledge/graphHelpers.py | getWeight | def getWeight(grph, nd1, nd2, weightString = "weight", returnType = int):
"""
A way of getting the weight of an edge with or without weight as a parameter
returns a the value of the weight parameter converted to returnType if it is given or 1 (also converted) if not
"""
if not weightString:
... | python | def getWeight(grph, nd1, nd2, weightString = "weight", returnType = int):
"""
A way of getting the weight of an edge with or without weight as a parameter
returns a the value of the weight parameter converted to returnType if it is given or 1 (also converted) if not
"""
if not weightString:
... | ['def', 'getWeight', '(', 'grph', ',', 'nd1', ',', 'nd2', ',', 'weightString', '=', '"weight"', ',', 'returnType', '=', 'int', ')', ':', 'if', 'not', 'weightString', ':', 'return', 'returnType', '(', '1', ')', 'else', ':', 'return', 'returnType', '(', 'grph', '.', 'edges', '[', 'nd1', ',', 'nd2', ']', '[', 'weightStrin... | A way of getting the weight of an edge with or without weight as a parameter
returns a the value of the weight parameter converted to returnType if it is given or 1 (also converted) if not | ['A', 'way', 'of', 'getting', 'the', 'weight', 'of', 'an', 'edge', 'with', 'or', 'without', 'weight', 'as', 'a', 'parameter', 'returns', 'a', 'the', 'value', 'of', 'the', 'weight', 'parameter', 'converted', 'to', 'returnType', 'if', 'it', 'is', 'given', 'or', '1', '(', 'also', 'converted', ')', 'if', 'not'] | train | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/graphHelpers.py#L447-L455 |
3,430 | restran/mountains | mountains/file/__init__.py | read_dict | def read_dict(file_name, clear_none=False, encoding='utf-8'):
"""
读取字典文件
:param encoding:
:param clear_none:
:param file_name:
:return:
"""
with open(file_name, 'rb') as f:
data = f.read()
if encoding is not None:
data = data.decode(encoding)
line_list = data.sp... | python | def read_dict(file_name, clear_none=False, encoding='utf-8'):
"""
读取字典文件
:param encoding:
:param clear_none:
:param file_name:
:return:
"""
with open(file_name, 'rb') as f:
data = f.read()
if encoding is not None:
data = data.decode(encoding)
line_list = data.sp... | ['def', 'read_dict', '(', 'file_name', ',', 'clear_none', '=', 'False', ',', 'encoding', '=', "'utf-8'", ')', ':', 'with', 'open', '(', 'file_name', ',', "'rb'", ')', 'as', 'f', ':', 'data', '=', 'f', '.', 'read', '(', ')', 'if', 'encoding', 'is', 'not', 'None', ':', 'data', '=', 'data', '.', 'decode', '(', 'encoding',... | 读取字典文件
:param encoding:
:param clear_none:
:param file_name:
:return: | ['读取字典文件', ':', 'param', 'encoding', ':', ':', 'param', 'clear_none', ':', ':', 'param', 'file_name', ':', ':', 'return', ':'] | train | https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/file/__init__.py#L9-L36 |
3,431 | google/grr | grr/client/grr_response_client/comms.py | Timer.Wait | def Wait(self):
"""Wait until the next action is needed."""
time.sleep(self.sleep_time - int(self.sleep_time))
# Split a long sleep interval into 1 second intervals so we can heartbeat.
for _ in range(int(self.sleep_time)):
time.sleep(1)
# Back off slowly at first and fast if no answer.
... | python | def Wait(self):
"""Wait until the next action is needed."""
time.sleep(self.sleep_time - int(self.sleep_time))
# Split a long sleep interval into 1 second intervals so we can heartbeat.
for _ in range(int(self.sleep_time)):
time.sleep(1)
# Back off slowly at first and fast if no answer.
... | ['def', 'Wait', '(', 'self', ')', ':', 'time', '.', 'sleep', '(', 'self', '.', 'sleep_time', '-', 'int', '(', 'self', '.', 'sleep_time', ')', ')', '# Split a long sleep interval into 1 second intervals so we can heartbeat.', 'for', '_', 'in', 'range', '(', 'int', '(', 'self', '.', 'sleep_time', ')', ')', ':', 'time', '... | Wait until the next action is needed. | ['Wait', 'until', 'the', 'next', 'action', 'is', 'needed', '.'] | train | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L468-L478 |
3,432 | polysquare/cmake-ast | cmakeast/ast.py | _MultilineStringRecorder.maybe_start_recording | def maybe_start_recording(tokens, index):
"""Return a new _MultilineStringRecorder when its time to record."""
if _is_begin_quoted_type(tokens[index].type):
string_type = _get_string_type_from_token(tokens[index].type)
return _MultilineStringRecorder(index, string_type)
... | python | def maybe_start_recording(tokens, index):
"""Return a new _MultilineStringRecorder when its time to record."""
if _is_begin_quoted_type(tokens[index].type):
string_type = _get_string_type_from_token(tokens[index].type)
return _MultilineStringRecorder(index, string_type)
... | ['def', 'maybe_start_recording', '(', 'tokens', ',', 'index', ')', ':', 'if', '_is_begin_quoted_type', '(', 'tokens', '[', 'index', ']', '.', 'type', ')', ':', 'string_type', '=', '_get_string_type_from_token', '(', 'tokens', '[', 'index', ']', '.', 'type', ')', 'return', '_MultilineStringRecorder', '(', 'index', ',', ... | Return a new _MultilineStringRecorder when its time to record. | ['Return', 'a', 'new', '_MultilineStringRecorder', 'when', 'its', 'time', 'to', 'record', '.'] | train | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L696-L702 |
3,433 | collectiveacuity/labPack | labpack/events/meetup.py | meetupClient.get_member_calendar | def get_member_calendar(self, max_results=0):
''' a method to retrieve the upcoming events for all groups member belongs to
:param max_results: [optional] integer with number of events to include
:return: dictionary with list of event details inside [json] key
event_details = s... | python | def get_member_calendar(self, max_results=0):
''' a method to retrieve the upcoming events for all groups member belongs to
:param max_results: [optional] integer with number of events to include
:return: dictionary with list of event details inside [json] key
event_details = s... | ['def', 'get_member_calendar', '(', 'self', ',', 'max_results', '=', '0', ')', ':', '# https://www.meetup.com/meetup_api/docs/self/calendar/#list\r', 'title', '=', "'%s.get_member_calendar'", '%', 'self', '.', '__class__', '.', '__name__', '# validate inputs\r', 'input_fields', '=', '{', "'max_results'", ':', 'max_resu... | a method to retrieve the upcoming events for all groups member belongs to
:param max_results: [optional] integer with number of events to include
:return: dictionary with list of event details inside [json] key
event_details = self._reconstruct_event({}) | ['a', 'method', 'to', 'retrieve', 'the', 'upcoming', 'events', 'for', 'all', 'groups', 'member', 'belongs', 'to', ':', 'param', 'max_results', ':', '[', 'optional', ']', 'integer', 'with', 'number', 'of', 'events', 'to', 'include', ':', 'return', ':', 'dictionary', 'with', 'list', 'of', 'event', 'details', 'inside', '[... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/events/meetup.py#L1384-L1428 |
3,434 | gabstopper/smc-python | smc/elements/network.py | Network.create | def create(cls, name, ipv4_network=None, ipv6_network=None,
comment=None):
"""
Create the network element
:param str name: Name of element
:param str ipv4_network: network cidr (optional if ipv6)
:param str ipv6_network: network cidr (optional if ipv4)
:pa... | python | def create(cls, name, ipv4_network=None, ipv6_network=None,
comment=None):
"""
Create the network element
:param str name: Name of element
:param str ipv4_network: network cidr (optional if ipv6)
:param str ipv6_network: network cidr (optional if ipv4)
:pa... | ['def', 'create', '(', 'cls', ',', 'name', ',', 'ipv4_network', '=', 'None', ',', 'ipv6_network', '=', 'None', ',', 'comment', '=', 'None', ')', ':', 'ipv4_network', '=', 'ipv4_network', 'if', 'ipv4_network', 'else', 'None', 'ipv6_network', '=', 'ipv6_network', 'if', 'ipv6_network', 'else', 'None', 'json', '=', '{', "'... | Create the network element
:param str name: Name of element
:param str ipv4_network: network cidr (optional if ipv6)
:param str ipv6_network: network cidr (optional if ipv4)
:param str comment: comment (optional)
:raises CreateElementFailed: element creation failed with reason
... | ['Create', 'the', 'network', 'element'] | train | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/network.py#L186-L208 |
3,435 | classam/silly | silly/main.py | plural | def plural(random=random, *args, **kwargs):
"""
Return a plural noun.
>>> mock_random.seed(0)
>>> plural(random=mock_random)
'onions'
>>> plural(random=mock_random, capitalize=True)
'Chimps'
>>> plural(random=mock_random, slugify=True)
'blisters'
"""
return inflectify.plural... | python | def plural(random=random, *args, **kwargs):
"""
Return a plural noun.
>>> mock_random.seed(0)
>>> plural(random=mock_random)
'onions'
>>> plural(random=mock_random, capitalize=True)
'Chimps'
>>> plural(random=mock_random, slugify=True)
'blisters'
"""
return inflectify.plural... | ['def', 'plural', '(', 'random', '=', 'random', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'return', 'inflectify', '.', 'plural', '(', 'random', '.', 'choice', '(', 'nouns', ')', ')'] | Return a plural noun.
>>> mock_random.seed(0)
>>> plural(random=mock_random)
'onions'
>>> plural(random=mock_random, capitalize=True)
'Chimps'
>>> plural(random=mock_random, slugify=True)
'blisters' | ['Return', 'a', 'plural', 'noun', '.'] | train | https://github.com/classam/silly/blob/f3202e997d5ebc9e4f98370b08665fd1178a9556/silly/main.py#L830-L842 |
3,436 | chezou/tabula-py | tabula/file_util.py | localize_file | def localize_file(path_or_buffer):
'''Ensure localize target file.
If the target file is remote, this function fetches into local storage.
Args:
path (str):
File path or file like object or URL of target file.
Returns:
filename (str): file name in local storage
tem... | python | def localize_file(path_or_buffer):
'''Ensure localize target file.
If the target file is remote, this function fetches into local storage.
Args:
path (str):
File path or file like object or URL of target file.
Returns:
filename (str): file name in local storage
tem... | ['def', 'localize_file', '(', 'path_or_buffer', ')', ':', 'path_or_buffer', '=', '_stringify_path', '(', 'path_or_buffer', ')', 'if', '_is_url', '(', 'path_or_buffer', ')', ':', 'req', '=', 'urlopen', '(', 'path_or_buffer', ')', 'filename', '=', 'os', '.', 'path', '.', 'basename', '(', 'req', '.', 'geturl', '(', ')', '... | Ensure localize target file.
If the target file is remote, this function fetches into local storage.
Args:
path (str):
File path or file like object or URL of target file.
Returns:
filename (str): file name in local storage
temporary_file_flag (bool): temporary file fl... | ['Ensure', 'localize', 'target', 'file', '.'] | train | https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/file_util.py#L24-L63 |
3,437 | sk-/git-lint | gitlint/__init__.py | get_vcs_root | def get_vcs_root():
"""Returns the vcs module and the root of the repo.
Returns:
A tuple containing the vcs module to use (git, hg) and the root of the
repository. If no repository exisits then (None, None) is returned.
"""
for vcs in (git, hg):
repo_root = vcs.repository_root()
... | python | def get_vcs_root():
"""Returns the vcs module and the root of the repo.
Returns:
A tuple containing the vcs module to use (git, hg) and the root of the
repository. If no repository exisits then (None, None) is returned.
"""
for vcs in (git, hg):
repo_root = vcs.repository_root()
... | ['def', 'get_vcs_root', '(', ')', ':', 'for', 'vcs', 'in', '(', 'git', ',', 'hg', ')', ':', 'repo_root', '=', 'vcs', '.', 'repository_root', '(', ')', 'if', 'repo_root', ':', 'return', 'vcs', ',', 'repo_root', 'return', '(', 'None', ',', 'None', ')'] | Returns the vcs module and the root of the repo.
Returns:
A tuple containing the vcs module to use (git, hg) and the root of the
repository. If no repository exisits then (None, None) is returned. | ['Returns', 'the', 'vcs', 'module', 'and', 'the', 'root', 'of', 'the', 'repo', '.'] | train | https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/__init__.py#L153-L165 |
3,438 | sepandhaghighi/pycm | pycm/pycm_overall_func.py | cross_entropy_calc | def cross_entropy_calc(TOP, P, POP):
"""
Calculate cross entropy.
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:param POP: population
:type POP : dict
:return: cross entropy as float
"""
try:
result = 0
for i ... | python | def cross_entropy_calc(TOP, P, POP):
"""
Calculate cross entropy.
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:param POP: population
:type POP : dict
:return: cross entropy as float
"""
try:
result = 0
for i ... | ['def', 'cross_entropy_calc', '(', 'TOP', ',', 'P', ',', 'POP', ')', ':', 'try', ':', 'result', '=', '0', 'for', 'i', 'in', 'TOP', '.', 'keys', '(', ')', ':', 'reference_likelihood', '=', 'P', '[', 'i', ']', '/', 'POP', '[', 'i', ']', 'response_likelihood', '=', 'TOP', '[', 'i', ']', '/', 'POP', '[', 'i', ']', 'if', 'r... | Calculate cross entropy.
:param TOP: test outcome positive
:type TOP : dict
:param P: condition positive
:type P : dict
:param POP: population
:type POP : dict
:return: cross entropy as float | ['Calculate', 'cross', 'entropy', '.'] | train | https://github.com/sepandhaghighi/pycm/blob/cb03258afd6a821d10acba73c965aaac174bedcd/pycm/pycm_overall_func.py#L327-L349 |
3,439 | androguard/androguard | androguard/core/bytecodes/apk.py | APK.get_requested_aosp_permissions | def get_requested_aosp_permissions(self):
"""
Returns requested permissions declared within AOSP project.
This includes several other permissions as well, which are in the platform apps.
:rtype: list of str
"""
aosp_permissions = []
all_permissions = self.get_pe... | python | def get_requested_aosp_permissions(self):
"""
Returns requested permissions declared within AOSP project.
This includes several other permissions as well, which are in the platform apps.
:rtype: list of str
"""
aosp_permissions = []
all_permissions = self.get_pe... | ['def', 'get_requested_aosp_permissions', '(', 'self', ')', ':', 'aosp_permissions', '=', '[', ']', 'all_permissions', '=', 'self', '.', 'get_permissions', '(', ')', 'for', 'perm', 'in', 'all_permissions', ':', 'if', 'perm', 'in', 'list', '(', 'self', '.', 'permission_module', '.', 'keys', '(', ')', ')', ':', 'aosp_per... | Returns requested permissions declared within AOSP project.
This includes several other permissions as well, which are in the platform apps.
:rtype: list of str | ['Returns', 'requested', 'permissions', 'declared', 'within', 'AOSP', 'project', '.'] | train | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/apk.py#L1258-L1271 |
3,440 | PyCQA/astroid | astroid/rebuilder.py | TreeRebuilder.visit_break | def visit_break(self, node, parent):
"""visit a Break node by returning a fresh instance of it"""
return nodes.Break(
getattr(node, "lineno", None), getattr(node, "col_offset", None), parent
) | python | def visit_break(self, node, parent):
"""visit a Break node by returning a fresh instance of it"""
return nodes.Break(
getattr(node, "lineno", None), getattr(node, "col_offset", None), parent
) | ['def', 'visit_break', '(', 'self', ',', 'node', ',', 'parent', ')', ':', 'return', 'nodes', '.', 'Break', '(', 'getattr', '(', 'node', ',', '"lineno"', ',', 'None', ')', ',', 'getattr', '(', 'node', ',', '"col_offset"', ',', 'None', ')', ',', 'parent', ')'] | visit a Break node by returning a fresh instance of it | ['visit', 'a', 'Break', 'node', 'by', 'returning', 'a', 'fresh', 'instance', 'of', 'it'] | train | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/rebuilder.py#L347-L351 |
3,441 | 3ll3d00d/vibe | backend/src/recorder/common/mpu6050.py | mpu6050.initialiseDevice | def initialiseDevice(self):
"""
performs initialisation of the device
:param batchSize: the no of samples that each provideData call should yield
:return:
"""
logger.debug("Initialising device")
self.getInterruptStatus()
self.setAccelerometerSensitivity(se... | python | def initialiseDevice(self):
"""
performs initialisation of the device
:param batchSize: the no of samples that each provideData call should yield
:return:
"""
logger.debug("Initialising device")
self.getInterruptStatus()
self.setAccelerometerSensitivity(se... | ['def', 'initialiseDevice', '(', 'self', ')', ':', 'logger', '.', 'debug', '(', '"Initialising device"', ')', 'self', '.', 'getInterruptStatus', '(', ')', 'self', '.', 'setAccelerometerSensitivity', '(', 'self', '.', '_accelerationFactor', '*', '32768.0', ')', 'self', '.', 'setGyroSensitivity', '(', 'self', '.', '_gyro... | performs initialisation of the device
:param batchSize: the no of samples that each provideData call should yield
:return: | ['performs', 'initialisation', 'of', 'the', 'device', ':', 'param', 'batchSize', ':', 'the', 'no', 'of', 'samples', 'that', 'each', 'provideData', 'call', 'should', 'yield', ':', 'return', ':'] | train | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L287-L308 |
3,442 | kwikteam/phy | phy/plot/base.py | BaseCanvas.on_draw | def on_draw(self, e):
"""Draw all visuals."""
gloo.clear()
for visual in self.visuals:
logger.log(5, "Draw visual `%s`.", visual)
visual.on_draw() | python | def on_draw(self, e):
"""Draw all visuals."""
gloo.clear()
for visual in self.visuals:
logger.log(5, "Draw visual `%s`.", visual)
visual.on_draw() | ['def', 'on_draw', '(', 'self', ',', 'e', ')', ':', 'gloo', '.', 'clear', '(', ')', 'for', 'visual', 'in', 'self', '.', 'visuals', ':', 'logger', '.', 'log', '(', '5', ',', '"Draw visual `%s`."', ',', 'visual', ')', 'visual', '.', 'on_draw', '(', ')'] | Draw all visuals. | ['Draw', 'all', 'visuals', '.'] | train | https://github.com/kwikteam/phy/blob/7e9313dc364304b7d2bd03b92938347343703003/phy/plot/base.py#L295-L300 |
3,443 | gwastro/pycbc | pycbc/filter/resample.py | notch_fir | def notch_fir(timeseries, f1, f2, order, beta=5.0):
""" notch filter the time series using an FIR filtered generated from
the ideal response passed through a time-domain kaiser window (beta = 5.0)
The suppression of the notch filter is related to the bandwidth and
the number of samples in the filter le... | python | def notch_fir(timeseries, f1, f2, order, beta=5.0):
""" notch filter the time series using an FIR filtered generated from
the ideal response passed through a time-domain kaiser window (beta = 5.0)
The suppression of the notch filter is related to the bandwidth and
the number of samples in the filter le... | ['def', 'notch_fir', '(', 'timeseries', ',', 'f1', ',', 'f2', ',', 'order', ',', 'beta', '=', '5.0', ')', ':', 'k1', '=', 'f1', '/', 'float', '(', '(', 'int', '(', '1.0', '/', 'timeseries', '.', 'delta_t', ')', '/', '2', ')', ')', 'k2', '=', 'f2', '/', 'float', '(', '(', 'int', '(', '1.0', '/', 'timeseries', '.', 'delt... | notch filter the time series using an FIR filtered generated from
the ideal response passed through a time-domain kaiser window (beta = 5.0)
The suppression of the notch filter is related to the bandwidth and
the number of samples in the filter length. For a few Hz bandwidth,
a length corresponding to ... | ['notch', 'filter', 'the', 'time', 'series', 'using', 'an', 'FIR', 'filtered', 'generated', 'from', 'the', 'ideal', 'response', 'passed', 'through', 'a', 'time', '-', 'domain', 'kaiser', 'window', '(', 'beta', '=', '5', '.', '0', ')'] | train | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/filter/resample.py#L181-L210 |
3,444 | projectshift/shift-boiler | boiler/cli/boiler.py | version | def version():
"""
Version
Imports and displays current boiler version.
:return:
"""
echo(green('\nshift-boiler:'))
echo(green('-' * 40))
echo(yellow('Version: ') + '{}'.format(boiler_version))
echo(yellow('GitHub: ') + 'https://github.com/projectshift/shift-boiler')
echo(yellow(... | python | def version():
"""
Version
Imports and displays current boiler version.
:return:
"""
echo(green('\nshift-boiler:'))
echo(green('-' * 40))
echo(yellow('Version: ') + '{}'.format(boiler_version))
echo(yellow('GitHub: ') + 'https://github.com/projectshift/shift-boiler')
echo(yellow(... | ['def', 'version', '(', ')', ':', 'echo', '(', 'green', '(', "'\\nshift-boiler:'", ')', ')', 'echo', '(', 'green', '(', "'-'", '*', '40', ')', ')', 'echo', '(', 'yellow', '(', "'Version: '", ')', '+', "'{}'", '.', 'format', '(', 'boiler_version', ')', ')', 'echo', '(', 'yellow', '(', "'GitHub: '", ')', '+', "'https://g... | Version
Imports and displays current boiler version.
:return: | ['Version', 'Imports', 'and', 'displays', 'current', 'boiler', 'version', '.', ':', 'return', ':'] | train | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/boiler.py#L21-L32 |
3,445 | RJT1990/pyflux | pyflux/garch/segarchm.py | SEGARCHM.add_leverage | def add_leverage(self):
""" Adds leverage term to the model
Returns
----------
None (changes instance attributes)
"""
if self.leverage is True:
pass
else:
self.leverage = True
self.z_no += 1
self.laten... | python | def add_leverage(self):
""" Adds leverage term to the model
Returns
----------
None (changes instance attributes)
"""
if self.leverage is True:
pass
else:
self.leverage = True
self.z_no += 1
self.laten... | ['def', 'add_leverage', '(', 'self', ')', ':', 'if', 'self', '.', 'leverage', 'is', 'True', ':', 'pass', 'else', ':', 'self', '.', 'leverage', '=', 'True', 'self', '.', 'z_no', '+=', '1', 'self', '.', 'latent_variables', '.', 'z_list', '.', 'pop', '(', ')', 'self', '.', 'latent_variables', '.', 'z_list', '.', 'pop', '(... | Adds leverage term to the model
Returns
----------
None (changes instance attributes) | ['Adds', 'leverage', 'term', 'to', 'the', 'model'] | train | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/garch/segarchm.py#L508-L530 |
3,446 | mlavin/argyle | argyle/system.py | service_command | def service_command(name, command):
"""Run an init.d/upstart command."""
service_command_template = getattr(env, 'ARGYLE_SERVICE_COMMAND_TEMPLATE',
u'/etc/init.d/%(name)s %(command)s')
sudo(service_command_template % {'name': name,
... | python | def service_command(name, command):
"""Run an init.d/upstart command."""
service_command_template = getattr(env, 'ARGYLE_SERVICE_COMMAND_TEMPLATE',
u'/etc/init.d/%(name)s %(command)s')
sudo(service_command_template % {'name': name,
... | ['def', 'service_command', '(', 'name', ',', 'command', ')', ':', 'service_command_template', '=', 'getattr', '(', 'env', ',', "'ARGYLE_SERVICE_COMMAND_TEMPLATE'", ',', "u'/etc/init.d/%(name)s %(command)s'", ')', 'sudo', '(', 'service_command_template', '%', '{', "'name'", ':', 'name', ',', "'command'", ':', 'command',... | Run an init.d/upstart command. | ['Run', 'an', 'init', '.', 'd', '/', 'upstart', 'command', '.'] | train | https://github.com/mlavin/argyle/blob/92cc6e1dd9b8e7cb41c5098a79d05e14b8243d72/argyle/system.py#L129-L135 |
3,447 | xapple/fasta | fasta/aligned.py | AlignedFASTA.build_tree_fast | def build_tree_fast(self, new_path=None, seq_type='nucl' or 'prot'):
"""Make a tree with FastTree. Names will be truncated however."""
# Check output #
if new_path is None: new_path = self.prefix_path + '.tree'
# Command #
command_args = []
if seq_type == 'nucl': command_... | python | def build_tree_fast(self, new_path=None, seq_type='nucl' or 'prot'):
"""Make a tree with FastTree. Names will be truncated however."""
# Check output #
if new_path is None: new_path = self.prefix_path + '.tree'
# Command #
command_args = []
if seq_type == 'nucl': command_... | ['def', 'build_tree_fast', '(', 'self', ',', 'new_path', '=', 'None', ',', 'seq_type', '=', "'nucl'", 'or', "'prot'", ')', ':', '# Check output #', 'if', 'new_path', 'is', 'None', ':', 'new_path', '=', 'self', '.', 'prefix_path', '+', "'.tree'", '# Command #', 'command_args', '=', '[', ']', 'if', 'seq_type', '==', "'nu... | Make a tree with FastTree. Names will be truncated however. | ['Make', 'a', 'tree', 'with', 'FastTree', '.', 'Names', 'will', 'be', 'truncated', 'however', '.'] | train | https://github.com/xapple/fasta/blob/a827c3138812d555203be45187ffae1277dd0d76/fasta/aligned.py#L111-L124 |
3,448 | Addvilz/hemp | hemp/gitutils.py | clone | def clone(url, directory, single_branch=None):
print_info('Cloning {0} to {1} {2}'.format(
url,
directory,
'[full clone]' if single_branch is None else '[{0}]'.format(single_branch)
))
# type: (str, str, str) -> Repo
"""
Clone a repository, optionally using shallow clone
... | python | def clone(url, directory, single_branch=None):
print_info('Cloning {0} to {1} {2}'.format(
url,
directory,
'[full clone]' if single_branch is None else '[{0}]'.format(single_branch)
))
# type: (str, str, str) -> Repo
"""
Clone a repository, optionally using shallow clone
... | ['def', 'clone', '(', 'url', ',', 'directory', ',', 'single_branch', '=', 'None', ')', ':', 'print_info', '(', "'Cloning {0} to {1} {2}'", '.', 'format', '(', 'url', ',', 'directory', ',', "'[full clone]'", 'if', 'single_branch', 'is', 'None', 'else', "'[{0}]'", '.', 'format', '(', 'single_branch', ')', ')', ')', '# ty... | Clone a repository, optionally using shallow clone
:rtype: Repo
:param url: URL of the repository
:param directory: Directory to clone to
:param single_branch: branch to clone if shallow clone is preferred
:return: GitPython repository object of the newly cloned repository | ['Clone', 'a', 'repository', 'optionally', 'using', 'shallow', 'clone', ':', 'rtype', ':', 'Repo', ':', 'param', 'url', ':', 'URL', 'of', 'the', 'repository', ':', 'param', 'directory', ':', 'Directory', 'to', 'clone', 'to', ':', 'param', 'single_branch', ':', 'branch', 'to', 'clone', 'if', 'shallow', 'clone', 'is', 'p... | train | https://github.com/Addvilz/hemp/blob/80d189f15ba20068a61efc2591070c80549c9d06/hemp/gitutils.py#L36-L63 |
3,449 | tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/extensions_v1beta1_api.py | ExtensionsV1beta1Api.list_replica_set_for_all_namespaces | def list_replica_set_for_all_namespaces(self, **kwargs): # noqa: E501
"""list_replica_set_for_all_namespaces # noqa: E501
list or watch objects of kind ReplicaSet # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass a... | python | def list_replica_set_for_all_namespaces(self, **kwargs): # noqa: E501
"""list_replica_set_for_all_namespaces # noqa: E501
list or watch objects of kind ReplicaSet # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass a... | ['def', 'list_replica_set_for_all_namespaces', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', '# noqa: E501', 'kwargs', '[', "'_return_http_data_only'", ']', '=', 'True', 'if', 'kwargs', '.', 'get', '(', "'async_req'", ')', ':', 'return', 'self', '.', 'list_replica_set_for_all_namespaces_with_http_info', '(', '*', '*'... | list_replica_set_for_all_namespaces # noqa: E501
list or watch objects of kind ReplicaSet # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.list_replica_set_for_all_namespaces(async_r... | ['list_replica_set_for_all_namespaces', '#', 'noqa', ':', 'E501'] | train | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/extensions_v1beta1_api.py#L3759-L3787 |
3,450 | ensime/ensime-vim | ensime_shared/editor.py | Editor.selection_pos | def selection_pos(self):
"""Return start and end positions of the visual selection respectively."""
buff = self._vim.current.buffer
beg = buff.mark('<')
end = buff.mark('>')
return beg, end | python | def selection_pos(self):
"""Return start and end positions of the visual selection respectively."""
buff = self._vim.current.buffer
beg = buff.mark('<')
end = buff.mark('>')
return beg, end | ['def', 'selection_pos', '(', 'self', ')', ':', 'buff', '=', 'self', '.', '_vim', '.', 'current', '.', 'buffer', 'beg', '=', 'buff', '.', 'mark', '(', "'<'", ')', 'end', '=', 'buff', '.', 'mark', '(', "'>'", ')', 'return', 'beg', ',', 'end'] | Return start and end positions of the visual selection respectively. | ['Return', 'start', 'and', 'end', 'positions', 'of', 'the', 'visual', 'selection', 'respectively', '.'] | train | https://github.com/ensime/ensime-vim/blob/caa734e84f002b25446c615706283a74edd4ecfe/ensime_shared/editor.py#L246-L251 |
3,451 | trevisanj/a99 | a99/textinterface.py | format_h4 | def format_h4(s, format="text", indents=0):
"""
Encloses string in format text
Args, Returns: see format_h1()
"""
_CHAR = "^"
if format.startswith("text"):
return format_underline(s, _CHAR, indents)
elif format.startswith("markdown"):
return ["#### {}".format(s)]... | python | def format_h4(s, format="text", indents=0):
"""
Encloses string in format text
Args, Returns: see format_h1()
"""
_CHAR = "^"
if format.startswith("text"):
return format_underline(s, _CHAR, indents)
elif format.startswith("markdown"):
return ["#### {}".format(s)]... | ['def', 'format_h4', '(', 's', ',', 'format', '=', '"text"', ',', 'indents', '=', '0', ')', ':', '_CHAR', '=', '"^"', 'if', 'format', '.', 'startswith', '(', '"text"', ')', ':', 'return', 'format_underline', '(', 's', ',', '_CHAR', ',', 'indents', ')', 'elif', 'format', '.', 'startswith', '(', '"markdown"', ')', ':', '... | Encloses string in format text
Args, Returns: see format_h1() | ['Encloses', 'string', 'in', 'format', 'text', 'Args', 'Returns', ':', 'see', 'format_h1', '()'] | train | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/textinterface.py#L104-L117 |
3,452 | spacetelescope/stsci.tools | lib/stsci/tools/readgeis.py | stsci | def stsci(hdulist):
"""For STScI GEIS files, need to do extra steps."""
instrument = hdulist[0].header.get('INSTRUME', '')
# Update extension header keywords
if instrument in ("WFPC2", "FOC"):
rootname = hdulist[0].header.get('ROOTNAME', '')
filetype = hdulist[0].header.get('FILETYPE',... | python | def stsci(hdulist):
"""For STScI GEIS files, need to do extra steps."""
instrument = hdulist[0].header.get('INSTRUME', '')
# Update extension header keywords
if instrument in ("WFPC2", "FOC"):
rootname = hdulist[0].header.get('ROOTNAME', '')
filetype = hdulist[0].header.get('FILETYPE',... | ['def', 'stsci', '(', 'hdulist', ')', ':', 'instrument', '=', 'hdulist', '[', '0', ']', '.', 'header', '.', 'get', '(', "'INSTRUME'", ',', "''", ')', '# Update extension header keywords', 'if', 'instrument', 'in', '(', '"WFPC2"', ',', '"FOC"', ')', ':', 'rootname', '=', 'hdulist', '[', '0', ']', '.', 'header', '.', 'ge... | For STScI GEIS files, need to do extra steps. | ['For', 'STScI', 'GEIS', 'files', 'need', 'to', 'do', 'extra', 'steps', '.'] | train | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/readgeis.py#L79-L97 |
3,453 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.set_or_clear_breakpoint | def set_or_clear_breakpoint(self):
"""Set/Clear breakpoint"""
editorstack = self.get_current_editorstack()
if editorstack is not None:
self.switch_to_plugin()
editorstack.set_or_clear_breakpoint() | python | def set_or_clear_breakpoint(self):
"""Set/Clear breakpoint"""
editorstack = self.get_current_editorstack()
if editorstack is not None:
self.switch_to_plugin()
editorstack.set_or_clear_breakpoint() | ['def', 'set_or_clear_breakpoint', '(', 'self', ')', ':', 'editorstack', '=', 'self', '.', 'get_current_editorstack', '(', ')', 'if', 'editorstack', 'is', 'not', 'None', ':', 'self', '.', 'switch_to_plugin', '(', ')', 'editorstack', '.', 'set_or_clear_breakpoint', '(', ')'] | Set/Clear breakpoint | ['Set', '/', 'Clear', 'breakpoint'] | train | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2189-L2194 |
3,454 | LCAV/pylocus | pylocus/lateration.py | get_lateration_parameters | def get_lateration_parameters(all_points, indices, index, edm, W=None):
""" Get parameters relevant for lateration from full all_points, edm and W.
"""
if W is None:
W = np.ones(edm.shape)
# delete points that are not considered anchors
anchors = np.delete(all_points, indices, axis=0)
r... | python | def get_lateration_parameters(all_points, indices, index, edm, W=None):
""" Get parameters relevant for lateration from full all_points, edm and W.
"""
if W is None:
W = np.ones(edm.shape)
# delete points that are not considered anchors
anchors = np.delete(all_points, indices, axis=0)
r... | ['def', 'get_lateration_parameters', '(', 'all_points', ',', 'indices', ',', 'index', ',', 'edm', ',', 'W', '=', 'None', ')', ':', 'if', 'W', 'is', 'None', ':', 'W', '=', 'np', '.', 'ones', '(', 'edm', '.', 'shape', ')', '# delete points that are not considered anchors', 'anchors', '=', 'np', '.', 'delete', '(', 'all_p... | Get parameters relevant for lateration from full all_points, edm and W. | ['Get', 'parameters', 'relevant', 'for', 'lateration', 'from', 'full', 'all_points', 'edm', 'and', 'W', '.'] | train | https://github.com/LCAV/pylocus/blob/c56a38c251d8a435caf4641a8ae6027ecba2c8c6/pylocus/lateration.py#L11-L42 |
3,455 | angr/angr | angr/analyses/variable_recovery/variable_recovery.py | VariableRecoveryState._addr_to_stack_offset | def _addr_to_stack_offset(self, addr):
"""
Convert an address to a stack offset.
:param claripy.ast.Base addr: The address to convert from.
:return: A stack offset if the addr comes from the stack pointer, or None if the address
... | python | def _addr_to_stack_offset(self, addr):
"""
Convert an address to a stack offset.
:param claripy.ast.Base addr: The address to convert from.
:return: A stack offset if the addr comes from the stack pointer, or None if the address
... | ['def', '_addr_to_stack_offset', '(', 'self', ',', 'addr', ')', ':', 'def', '_parse', '(', 'addr', ')', ':', 'if', 'addr', '.', 'op', '==', "'__add__'", ':', '# __add__ might have multiple arguments', 'parsed', '=', '[', '_parse', '(', 'arg', ')', 'for', 'arg', 'in', 'addr', '.', 'args', ']', 'annotated', '=', '[', 'Tr... | Convert an address to a stack offset.
:param claripy.ast.Base addr: The address to convert from.
:return: A stack offset if the addr comes from the stack pointer, or None if the address
does not come from the stack pointer. | ['Convert', 'an', 'address', 'to', 'a', 'stack', 'offset', '.'] | train | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/variable_recovery/variable_recovery.py#L325-L372 |
3,456 | UCSBarchlab/PyRTL | pyrtl/rtllib/multipliers.py | generalized_fma | def generalized_fma(mult_pairs, add_wires, signed=False, reducer=adders.wallace_reducer,
adder_func=adders.kogge_stone):
"""Generated an opimitized fused multiply adder.
A generalized FMA unit that multiplies each pair of numbers in mult_pairs,
then adds the resulting numbers and and th... | python | def generalized_fma(mult_pairs, add_wires, signed=False, reducer=adders.wallace_reducer,
adder_func=adders.kogge_stone):
"""Generated an opimitized fused multiply adder.
A generalized FMA unit that multiplies each pair of numbers in mult_pairs,
then adds the resulting numbers and and th... | ['def', 'generalized_fma', '(', 'mult_pairs', ',', 'add_wires', ',', 'signed', '=', 'False', ',', 'reducer', '=', 'adders', '.', 'wallace_reducer', ',', 'adder_func', '=', 'adders', '.', 'kogge_stone', ')', ':', '# first need to figure out the max length', 'if', 'mult_pairs', ':', '# Need to deal with the case when it ... | Generated an opimitized fused multiply adder.
A generalized FMA unit that multiplies each pair of numbers in mult_pairs,
then adds the resulting numbers and and the values of the add wires all
together to form an answer. This is faster than separate adders and
multipliers because you avoid unnecessary ... | ['Generated', 'an', 'opimitized', 'fused', 'multiply', 'adder', '.'] | train | https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/multipliers.py#L208-L258 |
3,457 | fake-name/ChromeController | ChromeController/Generator/Generated.py | ChromeRemoteDebugInterface.Storage_trackCacheStorageForOrigin | def Storage_trackCacheStorageForOrigin(self, origin):
"""
Function path: Storage.trackCacheStorageForOrigin
Domain: Storage
Method name: trackCacheStorageForOrigin
Parameters:
Required arguments:
'origin' (type: string) -> Security origin.
No return value.
Description: Registers origin... | python | def Storage_trackCacheStorageForOrigin(self, origin):
"""
Function path: Storage.trackCacheStorageForOrigin
Domain: Storage
Method name: trackCacheStorageForOrigin
Parameters:
Required arguments:
'origin' (type: string) -> Security origin.
No return value.
Description: Registers origin... | ['def', 'Storage_trackCacheStorageForOrigin', '(', 'self', ',', 'origin', ')', ':', 'assert', 'isinstance', '(', 'origin', ',', '(', 'str', ',', ')', ')', ',', '"Argument \'origin\' must be of type \'[\'str\']\'. Received type: \'%s\'"', '%', 'type', '(', 'origin', ')', 'subdom_funcs', '=', 'self', '.', 'synchronous_co... | Function path: Storage.trackCacheStorageForOrigin
Domain: Storage
Method name: trackCacheStorageForOrigin
Parameters:
Required arguments:
'origin' (type: string) -> Security origin.
No return value.
Description: Registers origin to be notified when an update occurs to its cache storage lis... | ['Function', 'path', ':', 'Storage', '.', 'trackCacheStorageForOrigin', 'Domain', ':', 'Storage', 'Method', 'name', ':', 'trackCacheStorageForOrigin', 'Parameters', ':', 'Required', 'arguments', ':', 'origin', '(', 'type', ':', 'string', ')', '-', '>', 'Security', 'origin', '.', 'No', 'return', 'value', '.', 'Descripti... | train | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L6262-L6280 |
3,458 | quantopian/metautils | metautils/compat.py | compose | def compose(*fs):
"""
Compose functions together in order:
compose(f, g, h) = lambda n: f(g(h(n)))
"""
# Pull the iterator out into a tuple so we can call `composed`
# more than once.
rs = tuple(reversed(fs))
def composed(n):
return reduce(lambda a, b: b(a), rs, n)
# Attem... | python | def compose(*fs):
"""
Compose functions together in order:
compose(f, g, h) = lambda n: f(g(h(n)))
"""
# Pull the iterator out into a tuple so we can call `composed`
# more than once.
rs = tuple(reversed(fs))
def composed(n):
return reduce(lambda a, b: b(a), rs, n)
# Attem... | ['def', 'compose', '(', '*', 'fs', ')', ':', '# Pull the iterator out into a tuple so we can call `composed`', '# more than once.', 'rs', '=', 'tuple', '(', 'reversed', '(', 'fs', ')', ')', 'def', 'composed', '(', 'n', ')', ':', 'return', 'reduce', '(', 'lambda', 'a', ',', 'b', ':', 'b', '(', 'a', ')', ',', 'rs', ',', ... | Compose functions together in order:
compose(f, g, h) = lambda n: f(g(h(n))) | ['Compose', 'functions', 'together', 'in', 'order', ':'] | train | https://github.com/quantopian/metautils/blob/10e11c5bd8bd7ded52b97261f61c3186607bd617/metautils/compat.py#L72-L96 |
3,459 | janpipek/physt | physt/plotting/vega.py | _create_axes | def _create_axes(hist: HistogramBase, vega: dict, kwargs: dict):
"""Create axes in the figure."""
xlabel = kwargs.pop("xlabel", hist.axis_names[0])
ylabel = kwargs.pop("ylabel", hist.axis_names[1] if len(hist.axis_names) >= 2 else None)
vega["axes"] = [
{"orient": "bottom", "scale": "xscale", "t... | python | def _create_axes(hist: HistogramBase, vega: dict, kwargs: dict):
"""Create axes in the figure."""
xlabel = kwargs.pop("xlabel", hist.axis_names[0])
ylabel = kwargs.pop("ylabel", hist.axis_names[1] if len(hist.axis_names) >= 2 else None)
vega["axes"] = [
{"orient": "bottom", "scale": "xscale", "t... | ['def', '_create_axes', '(', 'hist', ':', 'HistogramBase', ',', 'vega', ':', 'dict', ',', 'kwargs', ':', 'dict', ')', ':', 'xlabel', '=', 'kwargs', '.', 'pop', '(', '"xlabel"', ',', 'hist', '.', 'axis_names', '[', '0', ']', ')', 'ylabel', '=', 'kwargs', '.', 'pop', '(', '"ylabel"', ',', 'hist', '.', 'axis_names', '[', ... | Create axes in the figure. | ['Create', 'axes', 'in', 'the', 'figure', '.'] | train | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/vega.py#L673-L680 |
3,460 | caffeinehit/django-oauth2-provider | provider/oauth2/models.py | AccessToken.get_expire_delta | def get_expire_delta(self, reference=None):
"""
Return the number of seconds until this token expires.
"""
if reference is None:
reference = now()
expiration = self.expires
if timezone:
if timezone.is_aware(reference) and timezone.is_naive(expirat... | python | def get_expire_delta(self, reference=None):
"""
Return the number of seconds until this token expires.
"""
if reference is None:
reference = now()
expiration = self.expires
if timezone:
if timezone.is_aware(reference) and timezone.is_naive(expirat... | ['def', 'get_expire_delta', '(', 'self', ',', 'reference', '=', 'None', ')', ':', 'if', 'reference', 'is', 'None', ':', 'reference', '=', 'now', '(', ')', 'expiration', '=', 'self', '.', 'expires', 'if', 'timezone', ':', 'if', 'timezone', '.', 'is_aware', '(', 'reference', ')', 'and', 'timezone', '.', 'is_naive', '(', ... | Return the number of seconds until this token expires. | ['Return', 'the', 'number', 'of', 'seconds', 'until', 'this', 'token', 'expires', '.'] | train | https://github.com/caffeinehit/django-oauth2-provider/blob/6b5bc0d3ad706d2aaa47fa476f38406cddd01236/provider/oauth2/models.py#L149-L166 |
3,461 | NASA-AMMOS/AIT-Core | ait/core/api.py | GeventDeque.extend | def extend(self, iterable):
"""Extend the right side of this GeventDeque by appending
elements from the iterable argument.
"""
self._deque.extend(iterable)
if len(self._deque) > 0:
self.notEmpty.set() | python | def extend(self, iterable):
"""Extend the right side of this GeventDeque by appending
elements from the iterable argument.
"""
self._deque.extend(iterable)
if len(self._deque) > 0:
self.notEmpty.set() | ['def', 'extend', '(', 'self', ',', 'iterable', ')', ':', 'self', '.', '_deque', '.', 'extend', '(', 'iterable', ')', 'if', 'len', '(', 'self', '.', '_deque', ')', '>', '0', ':', 'self', '.', 'notEmpty', '.', 'set', '(', ')'] | Extend the right side of this GeventDeque by appending
elements from the iterable argument. | ['Extend', 'the', 'right', 'side', 'of', 'this', 'GeventDeque', 'by', 'appending', 'elements', 'from', 'the', 'iterable', 'argument', '.'] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L299-L305 |
3,462 | ratcave/ratcave | ratcave/mesh.py | Mesh._fill_vao | def _fill_vao(self):
"""Put array location in VAO for shader in same order as arrays given to Mesh."""
with self.vao:
self.vbos = []
for loc, verts in enumerate(self.arrays):
vbo = VBO(verts)
self.vbos.append(vbo)
self.vao.assign_ve... | python | def _fill_vao(self):
"""Put array location in VAO for shader in same order as arrays given to Mesh."""
with self.vao:
self.vbos = []
for loc, verts in enumerate(self.arrays):
vbo = VBO(verts)
self.vbos.append(vbo)
self.vao.assign_ve... | ['def', '_fill_vao', '(', 'self', ')', ':', 'with', 'self', '.', 'vao', ':', 'self', '.', 'vbos', '=', '[', ']', 'for', 'loc', ',', 'verts', 'in', 'enumerate', '(', 'self', '.', 'arrays', ')', ':', 'vbo', '=', 'VBO', '(', 'verts', ')', 'self', '.', 'vbos', '.', 'append', '(', 'vbo', ')', 'self', '.', 'vao', '.', 'assig... | Put array location in VAO for shader in same order as arrays given to Mesh. | ['Put', 'array', 'location', 'in', 'VAO', 'for', 'shader', 'in', 'same', 'order', 'as', 'arrays', 'given', 'to', 'Mesh', '.'] | train | https://github.com/ratcave/ratcave/blob/e3862cdaba100ac2c6c78c08c4b09638e0c88fd4/ratcave/mesh.py#L192-L199 |
3,463 | zeroSteiner/smoke-zephyr | smoke_zephyr/configuration.py | Configuration.get_missing | def get_missing(self, verify_file):
"""
Use a verification configuration which has a list of required options
and their respective types. This information is used to identify missing
and incompatible options in the loaded configuration.
:param str verify_file: The file to load for verification data.
:retur... | python | def get_missing(self, verify_file):
"""
Use a verification configuration which has a list of required options
and their respective types. This information is used to identify missing
and incompatible options in the loaded configuration.
:param str verify_file: The file to load for verification data.
:retur... | ['def', 'get_missing', '(', 'self', ',', 'verify_file', ')', ':', 'vconf', '=', 'Configuration', '(', 'verify_file', ')', 'missing', '=', '{', '}', 'for', 'setting', ',', 'setting_type', 'in', 'vconf', '.', 'get', '(', "'settings'", ')', '.', 'items', '(', ')', ':', 'if', 'not', 'self', '.', 'has_option', '(', 'setting... | Use a verification configuration which has a list of required options
and their respective types. This information is used to identify missing
and incompatible options in the loaded configuration.
:param str verify_file: The file to load for verification data.
:return: A dictionary of missing and incompatible ... | ['Use', 'a', 'verification', 'configuration', 'which', 'has', 'a', 'list', 'of', 'required', 'options', 'and', 'their', 'respective', 'types', '.', 'This', 'information', 'is', 'used', 'to', 'identify', 'missing', 'and', 'incompatible', 'options', 'in', 'the', 'loaded', 'configuration', '.'] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/configuration.py#L197-L216 |
3,464 | juju/charm-helpers | charmhelpers/core/hookenv.py | expected_peer_units | def expected_peer_units():
"""Get a generator for units we expect to join peer relation based on
goal-state.
The local unit is excluded from the result to make it easy to gauge
completion of all peers joining the relation with existing hook tools.
Example usage:
log('peer {} of {} joined peer ... | python | def expected_peer_units():
"""Get a generator for units we expect to join peer relation based on
goal-state.
The local unit is excluded from the result to make it easy to gauge
completion of all peers joining the relation with existing hook tools.
Example usage:
log('peer {} of {} joined peer ... | ['def', 'expected_peer_units', '(', ')', ':', 'if', 'not', 'has_juju_version', '(', '"2.4.0"', ')', ':', '# goal-state first appeared in 2.4.0.', 'raise', 'NotImplementedError', '(', '"goal-state"', ')', '_goal_state', '=', 'goal_state', '(', ')', 'return', '(', 'key', 'for', 'key', 'in', '_goal_state', '[', "'units'",... | Get a generator for units we expect to join peer relation based on
goal-state.
The local unit is excluded from the result to make it easy to gauge
completion of all peers joining the relation with existing hook tools.
Example usage:
log('peer {} of {} joined peer relation'
.format(len(rela... | ['Get', 'a', 'generator', 'for', 'units', 'we', 'expect', 'to', 'join', 'peer', 'relation', 'based', 'on', 'goal', '-', 'state', '.'] | train | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/hookenv.py#L518-L542 |
3,465 | Azure/blobxfer | blobxfer/operations/azure/__init__.py | StorageAccount._credential_allows_container_list | def _credential_allows_container_list(self):
# type: (StorageAccount) -> bool
"""Check if container list is allowed
:param StorageAccount self: this
:rtype: bool
:return: if container list is allowed
"""
if self.is_sas:
sasparts = self.key.split('&')
... | python | def _credential_allows_container_list(self):
# type: (StorageAccount) -> bool
"""Check if container list is allowed
:param StorageAccount self: this
:rtype: bool
:return: if container list is allowed
"""
if self.is_sas:
sasparts = self.key.split('&')
... | ['def', '_credential_allows_container_list', '(', 'self', ')', ':', '# type: (StorageAccount) -> bool', 'if', 'self', '.', 'is_sas', ':', 'sasparts', '=', 'self', '.', 'key', '.', 'split', '(', "'&'", ')', 'caccess', '=', 'self', '.', 'can_create_containers', '# search for container signed resource for service level sa... | Check if container list is allowed
:param StorageAccount self: this
:rtype: bool
:return: if container list is allowed | ['Check', 'if', 'container', 'list', 'is', 'allowed', ':', 'param', 'StorageAccount', 'self', ':', 'this', ':', 'rtype', ':', 'bool', ':', 'return', ':', 'if', 'container', 'list', 'is', 'allowed'] | train | https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/azure/__init__.py#L252-L282 |
3,466 | linuxsoftware/ls.joyous | ls/joyous/models/events.py | PostponementPage.postponed_from_when | def postponed_from_when(self):
"""
A string describing when the event was postponed from (in the local time zone).
"""
what = self.what
if what:
return _("{what} from {when}").format(what=what,
when=self.cancellationpa... | python | def postponed_from_when(self):
"""
A string describing when the event was postponed from (in the local time zone).
"""
what = self.what
if what:
return _("{what} from {when}").format(what=what,
when=self.cancellationpa... | ['def', 'postponed_from_when', '(', 'self', ')', ':', 'what', '=', 'self', '.', 'what', 'if', 'what', ':', 'return', '_', '(', '"{what} from {when}"', ')', '.', 'format', '(', 'what', '=', 'what', ',', 'when', '=', 'self', '.', 'cancellationpage', '.', 'when', ')'] | A string describing when the event was postponed from (in the local time zone). | ['A', 'string', 'describing', 'when', 'the', 'event', 'was', 'postponed', 'from', '(', 'in', 'the', 'local', 'time', 'zone', ')', '.'] | train | https://github.com/linuxsoftware/ls.joyous/blob/316283140ca5171a68ad3170a5964fdc89be0b56/ls/joyous/models/events.py#L1740-L1747 |
3,467 | quintusdias/glymur | glymur/codestream.py | Codestream._parse_ppt_segment | def _parse_ppt_segment(self, fptr):
"""Parse the PPT segment.
The packet headers are not parsed, i.e. they remain "uninterpreted"
raw data beffers.
Parameters
----------
fptr : file object
The file to parse.
Returns
-------
PPTSegmen... | python | def _parse_ppt_segment(self, fptr):
"""Parse the PPT segment.
The packet headers are not parsed, i.e. they remain "uninterpreted"
raw data beffers.
Parameters
----------
fptr : file object
The file to parse.
Returns
-------
PPTSegmen... | ['def', '_parse_ppt_segment', '(', 'self', ',', 'fptr', ')', ':', 'offset', '=', 'fptr', '.', 'tell', '(', ')', '-', '2', 'read_buffer', '=', 'fptr', '.', 'read', '(', '3', ')', 'length', ',', 'zppt', '=', 'struct', '.', 'unpack', '(', "'>HB'", ',', 'read_buffer', ')', 'length', '=', 'length', 'zppt', '=', 'zppt', 'num... | Parse the PPT segment.
The packet headers are not parsed, i.e. they remain "uninterpreted"
raw data beffers.
Parameters
----------
fptr : file object
The file to parse.
Returns
-------
PPTSegment
The current PPT segment. | ['Parse', 'the', 'PPT', 'segment', '.'] | train | https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/codestream.py#L541-L567 |
3,468 | mkoura/dump2polarion | dump2polarion/dumper_cli.py | process_args | def process_args(args):
"""Processes passed arguments."""
passed_args = args
if isinstance(args, argparse.Namespace):
passed_args = vars(passed_args)
elif hasattr(args, "to_dict"):
passed_args = passed_args.to_dict()
return Box(passed_args, frozen_box=True, default_box=True) | python | def process_args(args):
"""Processes passed arguments."""
passed_args = args
if isinstance(args, argparse.Namespace):
passed_args = vars(passed_args)
elif hasattr(args, "to_dict"):
passed_args = passed_args.to_dict()
return Box(passed_args, frozen_box=True, default_box=True) | ['def', 'process_args', '(', 'args', ')', ':', 'passed_args', '=', 'args', 'if', 'isinstance', '(', 'args', ',', 'argparse', '.', 'Namespace', ')', ':', 'passed_args', '=', 'vars', '(', 'passed_args', ')', 'elif', 'hasattr', '(', 'args', ',', '"to_dict"', ')', ':', 'passed_args', '=', 'passed_args', '.', 'to_dict', '('... | Processes passed arguments. | ['Processes', 'passed', 'arguments', '.'] | train | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/dumper_cli.py#L79-L87 |
3,469 | phoebe-project/phoebe2 | phoebe/backend/universe.py | System.populate_observables | def populate_observables(self, time, kinds, datasets, ignore_effects=False):
"""
TODO: add documentation
ignore_effects: whether to ignore reflection and features (useful for computing luminosities)
"""
if self.irrad_method is not 'none' and not ignore_effects:
# T... | python | def populate_observables(self, time, kinds, datasets, ignore_effects=False):
"""
TODO: add documentation
ignore_effects: whether to ignore reflection and features (useful for computing luminosities)
"""
if self.irrad_method is not 'none' and not ignore_effects:
# T... | ['def', 'populate_observables', '(', 'self', ',', 'time', ',', 'kinds', ',', 'datasets', ',', 'ignore_effects', '=', 'False', ')', ':', 'if', 'self', '.', 'irrad_method', 'is', 'not', "'none'", 'and', 'not', 'ignore_effects', ':', '# TODO: only for kinds that require intensities (i.e. not orbit or', '# dynamical RVs, e... | TODO: add documentation
ignore_effects: whether to ignore reflection and features (useful for computing luminosities) | ['TODO', ':', 'add', 'documentation'] | train | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/backend/universe.py#L301-L316 |
3,470 | ev3dev/ev3dev-lang-python | ev3dev2/sound.py | Sound.play_song | def play_song(self, song, tempo=120, delay=0.05):
""" Plays a song provided as a list of tuples containing the note name and its
value using music conventional notation instead of numerical values for frequency
and duration.
It supports symbolic notes (e.g. ``A4``, ``D#3``, ``Gb5``) and... | python | def play_song(self, song, tempo=120, delay=0.05):
""" Plays a song provided as a list of tuples containing the note name and its
value using music conventional notation instead of numerical values for frequency
and duration.
It supports symbolic notes (e.g. ``A4``, ``D#3``, ``Gb5``) and... | ['def', 'play_song', '(', 'self', ',', 'song', ',', 'tempo', '=', '120', ',', 'delay', '=', '0.05', ')', ':', 'if', 'tempo', '<=', '0', ':', 'raise', 'ValueError', '(', "'invalid tempo (%s)'", '%', 'tempo', ')', 'if', 'delay', '<', '0', ':', 'raise', 'ValueError', '(', "'invalid delay (%s)'", '%', 'delay', ')', 'delay_... | Plays a song provided as a list of tuples containing the note name and its
value using music conventional notation instead of numerical values for frequency
and duration.
It supports symbolic notes (e.g. ``A4``, ``D#3``, ``Gb5``) and durations (e.g. ``q``, ``h``).
For an exhaustive lis... | ['Plays', 'a', 'song', 'provided', 'as', 'a', 'list', 'of', 'tuples', 'containing', 'the', 'note', 'name', 'and', 'its', 'value', 'using', 'music', 'conventional', 'notation', 'instead', 'of', 'numerical', 'values', 'for', 'frequency', 'and', 'duration', '.'] | train | https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/sound.py#L380-L485 |
3,471 | apache/incubator-mxnet | example/sparse/wide_deep/data.py | preprocess_uci_adult | def preprocess_uci_adult(data_name):
"""Some tricks of feature engineering are adapted
from tensorflow's wide and deep tutorial.
"""
csv_columns = [
"age", "workclass", "fnlwgt", "education", "education_num",
"marital_status", "occupation", "relationship", "race", "gender",
"capi... | python | def preprocess_uci_adult(data_name):
"""Some tricks of feature engineering are adapted
from tensorflow's wide and deep tutorial.
"""
csv_columns = [
"age", "workclass", "fnlwgt", "education", "education_num",
"marital_status", "occupation", "relationship", "race", "gender",
"capi... | ['def', 'preprocess_uci_adult', '(', 'data_name', ')', ':', 'csv_columns', '=', '[', '"age"', ',', '"workclass"', ',', '"fnlwgt"', ',', '"education"', ',', '"education_num"', ',', '"marital_status"', ',', '"occupation"', ',', '"relationship"', ',', '"race"', ',', '"gender"', ',', '"capital_gain"', ',', '"capital_loss"'... | Some tricks of feature engineering are adapted
from tensorflow's wide and deep tutorial. | ['Some', 'tricks', 'of', 'feature', 'engineering', 'are', 'adapted', 'from', 'tensorflow', 's', 'wide', 'and', 'deep', 'tutorial', '.'] | train | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/sparse/wide_deep/data.py#L40-L139 |
3,472 | minhhoit/yacms | yacms/core/managers.py | PublishedManager.published | def published(self, for_user=None):
"""
For non-staff users, return items with a published status and
whose publish and expiry dates fall before and after the
current date when specified.
"""
from yacms.core.models import CONTENT_STATUS_PUBLISHED
if for_user is no... | python | def published(self, for_user=None):
"""
For non-staff users, return items with a published status and
whose publish and expiry dates fall before and after the
current date when specified.
"""
from yacms.core.models import CONTENT_STATUS_PUBLISHED
if for_user is no... | ['def', 'published', '(', 'self', ',', 'for_user', '=', 'None', ')', ':', 'from', 'yacms', '.', 'core', '.', 'models', 'import', 'CONTENT_STATUS_PUBLISHED', 'if', 'for_user', 'is', 'not', 'None', 'and', 'for_user', '.', 'is_staff', ':', 'return', 'self', '.', 'all', '(', ')', 'return', 'self', '.', 'filter', '(', 'Q', ... | For non-staff users, return items with a published status and
whose publish and expiry dates fall before and after the
current date when specified. | ['For', 'non', '-', 'staff', 'users', 'return', 'items', 'with', 'a', 'published', 'status', 'and', 'whose', 'publish', 'and', 'expiry', 'dates', 'fall', 'before', 'and', 'after', 'the', 'current', 'date', 'when', 'specified', '.'] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L58-L70 |
3,473 | phaethon/kamene | kamene/contrib/gsm_um.py | activateAaPdpContextAccept | def activateAaPdpContextAccept(ProtocolConfigurationOptions_presence=0,
GprsTimer_presence=0):
"""ACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.11"""
a = TpPd(pd=0x8)
b = MessageType(mesType=0x51) # 01010001
c = LlcServiceAccessPointIdentifier()
d = QualityOfService()
... | python | def activateAaPdpContextAccept(ProtocolConfigurationOptions_presence=0,
GprsTimer_presence=0):
"""ACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.11"""
a = TpPd(pd=0x8)
b = MessageType(mesType=0x51) # 01010001
c = LlcServiceAccessPointIdentifier()
d = QualityOfService()
... | ['def', 'activateAaPdpContextAccept', '(', 'ProtocolConfigurationOptions_presence', '=', '0', ',', 'GprsTimer_presence', '=', '0', ')', ':', 'a', '=', 'TpPd', '(', 'pd', '=', '0x8', ')', 'b', '=', 'MessageType', '(', 'mesType', '=', '0x51', ')', '# 01010001', 'c', '=', 'LlcServiceAccessPointIdentifier', '(', ')', 'd', ... | ACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.11 | ['ACTIVATE', 'AA', 'PDP', 'CONTEXT', 'ACCEPT', 'Section', '9', '.', '5', '.', '11'] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2757-L2774 |
3,474 | klavinslab/coral | coral/database/_yeast.py | get_yeast_sequence | def get_yeast_sequence(chromosome, start, end, reverse_complement=False):
'''Acquire a sequence from SGD http://www.yeastgenome.org
:param chromosome: Yeast chromosome.
:type chromosome: int
:param start: A biostart.
:type start: int
:param end: A bioend.
:type end: int
:param reverse_co... | python | def get_yeast_sequence(chromosome, start, end, reverse_complement=False):
'''Acquire a sequence from SGD http://www.yeastgenome.org
:param chromosome: Yeast chromosome.
:type chromosome: int
:param start: A biostart.
:type start: int
:param end: A bioend.
:type end: int
:param reverse_co... | ['def', 'get_yeast_sequence', '(', 'chromosome', ',', 'start', ',', 'end', ',', 'reverse_complement', '=', 'False', ')', ':', 'import', 'requests', 'if', 'start', '!=', 'end', ':', 'if', 'reverse_complement', ':', 'rev_option', '=', "'-REV'", 'else', ':', 'rev_option', '=', "''", 'param_url', '=', "'&chr='", '+', 'str'... | Acquire a sequence from SGD http://www.yeastgenome.org
:param chromosome: Yeast chromosome.
:type chromosome: int
:param start: A biostart.
:type start: int
:param end: A bioend.
:type end: int
:param reverse_complement: Get the reverse complement.
:type revervse_complement: bool
:re... | ['Acquire', 'a', 'sequence', 'from', 'SGD', 'http', ':', '//', 'www', '.', 'yeastgenome', '.', 'org', ':', 'param', 'chromosome', ':', 'Yeast', 'chromosome', '.', ':', 'type', 'chromosome', ':', 'int', ':', 'param', 'start', ':', 'A', 'biostart', '.', ':', 'type', 'start', ':', 'int', ':', 'param', 'end', ':', 'A', 'bi... | train | https://github.com/klavinslab/coral/blob/17f59591211562a59a051f474cd6cecba4829df9/coral/database/_yeast.py#L86-L126 |
3,475 | openstack/networking-cisco | networking_cisco/plugins/cisco/cfg_agent/device_drivers/iosxe/iosxe_routing_driver.py | IosXeRoutingDriver._get_vrfs | def _get_vrfs(self):
"""Get the current VRFs configured in the device.
:return: A list of vrf names as string
"""
vrfs = []
ios_cfg = self._get_running_config()
parse = HTParser(ios_cfg)
vrfs_raw = parse.find_lines("^vrf definition")
for line in vrfs_raw:... | python | def _get_vrfs(self):
"""Get the current VRFs configured in the device.
:return: A list of vrf names as string
"""
vrfs = []
ios_cfg = self._get_running_config()
parse = HTParser(ios_cfg)
vrfs_raw = parse.find_lines("^vrf definition")
for line in vrfs_raw:... | ['def', '_get_vrfs', '(', 'self', ')', ':', 'vrfs', '=', '[', ']', 'ios_cfg', '=', 'self', '.', '_get_running_config', '(', ')', 'parse', '=', 'HTParser', '(', 'ios_cfg', ')', 'vrfs_raw', '=', 'parse', '.', 'find_lines', '(', '"^vrf definition"', ')', 'for', 'line', 'in', 'vrfs_raw', ':', "# raw format ['ip vrf <vrf-n... | Get the current VRFs configured in the device.
:return: A list of vrf names as string | ['Get', 'the', 'current', 'VRFs', 'configured', 'in', 'the', 'device', '.'] | train | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/cfg_agent/device_drivers/iosxe/iosxe_routing_driver.py#L339-L353 |
3,476 | ehansis/ozelot | ozelot/etl/tasks.py | ORMTask.close_session | def close_session(self, commit=True):
"""Commit and close the DB session associated with this task (no error is raised if None is open)
Args:
commit (bool): commit session before closing (default=True)
"""
if self._session is not None:
if commit:
... | python | def close_session(self, commit=True):
"""Commit and close the DB session associated with this task (no error is raised if None is open)
Args:
commit (bool): commit session before closing (default=True)
"""
if self._session is not None:
if commit:
... | ['def', 'close_session', '(', 'self', ',', 'commit', '=', 'True', ')', ':', 'if', 'self', '.', '_session', 'is', 'not', 'None', ':', 'if', 'commit', ':', 'self', '.', '_session', '.', 'commit', '(', ')', 'self', '.', '_session', '.', 'close', '(', ')', 'self', '.', '_session', '=', 'None'] | Commit and close the DB session associated with this task (no error is raised if None is open)
Args:
commit (bool): commit session before closing (default=True) | ['Commit', 'and', 'close', 'the', 'DB', 'session', 'associated', 'with', 'this', 'task', '(', 'no', 'error', 'is', 'raised', 'if', 'None', 'is', 'open', ')'] | train | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L142-L152 |
3,477 | polysquare/polysquare-setuptools-lint | polysquare_setuptools_lint/__init__.py | _run_prospector | def _run_prospector(filename,
stamp_file_name,
disabled_linters,
show_lint_files):
"""Run prospector."""
linter_tools = [
"pep257",
"pep8",
"pyflakes"
]
if can_run_pylint():
linter_tools.append("pylint")
# ... | python | def _run_prospector(filename,
stamp_file_name,
disabled_linters,
show_lint_files):
"""Run prospector."""
linter_tools = [
"pep257",
"pep8",
"pyflakes"
]
if can_run_pylint():
linter_tools.append("pylint")
# ... | ['def', '_run_prospector', '(', 'filename', ',', 'stamp_file_name', ',', 'disabled_linters', ',', 'show_lint_files', ')', ':', 'linter_tools', '=', '[', '"pep257"', ',', '"pep8"', ',', '"pyflakes"', ']', 'if', 'can_run_pylint', '(', ')', ':', 'linter_tools', '.', 'append', '(', '"pylint"', ')', "# Run prospector on tes... | Run prospector. | ['Run', 'prospector', '.'] | train | https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L244-L286 |
3,478 | Clinical-Genomics/trailblazer | trailblazer/cli/core.py | start | def start(context, mip_config, email, priority, dryrun, command, start_with, family):
"""Start a new analysis."""
mip_cli = MipCli(context.obj['script'])
mip_config = mip_config or context.obj['mip_config']
email = email or environ_email()
kwargs = dict(config=mip_config, family=family, priority=pri... | python | def start(context, mip_config, email, priority, dryrun, command, start_with, family):
"""Start a new analysis."""
mip_cli = MipCli(context.obj['script'])
mip_config = mip_config or context.obj['mip_config']
email = email or environ_email()
kwargs = dict(config=mip_config, family=family, priority=pri... | ['def', 'start', '(', 'context', ',', 'mip_config', ',', 'email', ',', 'priority', ',', 'dryrun', ',', 'command', ',', 'start_with', ',', 'family', ')', ':', 'mip_cli', '=', 'MipCli', '(', 'context', '.', 'obj', '[', "'script'", ']', ')', 'mip_config', '=', 'mip_config', 'or', 'context', '.', 'obj', '[', "'mip_config'"... | Start a new analysis. | ['Start', 'a', 'new', 'analysis', '.'] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/cli/core.py#L80-L95 |
3,479 | AguaClara/aguaclara | aguaclara/design/lfom.py | LFOM.n_orifices_per_row_max | def n_orifices_per_row_max(self):
"""A bound on the number of orifices allowed in each row.
The distance between consecutive orifices must be enough to retain
structural integrity of the pipe.
"""
c = math.pi * pipe.ID_SDR(self.nom_diam_pipe, self.sdr)
b = self.orifice_di... | python | def n_orifices_per_row_max(self):
"""A bound on the number of orifices allowed in each row.
The distance between consecutive orifices must be enough to retain
structural integrity of the pipe.
"""
c = math.pi * pipe.ID_SDR(self.nom_diam_pipe, self.sdr)
b = self.orifice_di... | ['def', 'n_orifices_per_row_max', '(', 'self', ')', ':', 'c', '=', 'math', '.', 'pi', '*', 'pipe', '.', 'ID_SDR', '(', 'self', '.', 'nom_diam_pipe', ',', 'self', '.', 'sdr', ')', 'b', '=', 'self', '.', 'orifice_diameter', '+', 'self', '.', 's_orifice', 'return', 'math', '.', 'floor', '(', 'c', '/', 'b', ')'] | A bound on the number of orifices allowed in each row.
The distance between consecutive orifices must be enough to retain
structural integrity of the pipe. | ['A', 'bound', 'on', 'the', 'number', 'of', 'orifices', 'allowed', 'in', 'each', 'row', '.', 'The', 'distance', 'between', 'consecutive', 'orifices', 'must', 'be', 'enough', 'to', 'retain', 'structural', 'integrity', 'of', 'the', 'pipe', '.'] | train | https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/design/lfom.py#L108-L116 |
3,480 | wtsi-hgi/consul-lock | consullock/cli.py | parse_cli_configuration | def parse_cli_configuration(arguments: List[str]) -> CliConfiguration:
"""
Parses the configuration passed in via command line arguments.
:param arguments: CLI arguments
:return: the configuration
"""
try:
parsed_arguments = {x.replace("_", "-"): y for x, y in vars(_argument_parser.parse... | python | def parse_cli_configuration(arguments: List[str]) -> CliConfiguration:
"""
Parses the configuration passed in via command line arguments.
:param arguments: CLI arguments
:return: the configuration
"""
try:
parsed_arguments = {x.replace("_", "-"): y for x, y in vars(_argument_parser.parse... | ['def', 'parse_cli_configuration', '(', 'arguments', ':', 'List', '[', 'str', ']', ')', '->', 'CliConfiguration', ':', 'try', ':', 'parsed_arguments', '=', '{', 'x', '.', 'replace', '(', '"_"', ',', '"-"', ')', ':', 'y', 'for', 'x', ',', 'y', 'in', 'vars', '(', '_argument_parser', '.', 'parse_args', '(', 'arguments', '... | Parses the configuration passed in via command line arguments.
:param arguments: CLI arguments
:return: the configuration | ['Parses', 'the', 'configuration', 'passed', 'in', 'via', 'command', 'line', 'arguments', '.', ':', 'param', 'arguments', ':', 'CLI', 'arguments', ':', 'return', ':', 'the', 'configuration'] | train | https://github.com/wtsi-hgi/consul-lock/blob/deb07ab41dabbb49f4d0bbc062bc3b4b6e5d71b2/consullock/cli.py#L185-L234 |
3,481 | ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.sc_pan | def sc_pan(self, viewer, event, msg=True):
"""Interactively pan the image by scrolling motion.
"""
if not self.canpan:
return True
# User has "Pan Reverse" preference set?
rev = self.settings.get('pan_reverse', False)
direction = event.direction
if r... | python | def sc_pan(self, viewer, event, msg=True):
"""Interactively pan the image by scrolling motion.
"""
if not self.canpan:
return True
# User has "Pan Reverse" preference set?
rev = self.settings.get('pan_reverse', False)
direction = event.direction
if r... | ['def', 'sc_pan', '(', 'self', ',', 'viewer', ',', 'event', ',', 'msg', '=', 'True', ')', ':', 'if', 'not', 'self', '.', 'canpan', ':', 'return', 'True', '# User has "Pan Reverse" preference set?', 'rev', '=', 'self', '.', 'settings', '.', 'get', '(', "'pan_reverse'", ',', 'False', ')', 'direction', '=', 'event', '.', ... | Interactively pan the image by scrolling motion. | ['Interactively', 'pan', 'the', 'image', 'by', 'scrolling', 'motion', '.'] | train | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1994-L2014 |
3,482 | ipfs/py-ipfs-api | ipfsapi/http.py | HTTPClient.session | def session(self):
"""A context manager for this client's session.
This function closes the current session when this client goes out of
scope.
"""
self._session = requests.session()
yield
self._session.close()
self._session = None | python | def session(self):
"""A context manager for this client's session.
This function closes the current session when this client goes out of
scope.
"""
self._session = requests.session()
yield
self._session.close()
self._session = None | ['def', 'session', '(', 'self', ')', ':', 'self', '.', '_session', '=', 'requests', '.', 'session', '(', ')', 'yield', 'self', '.', '_session', '.', 'close', '(', ')', 'self', '.', '_session', '=', 'None'] | A context manager for this client's session.
This function closes the current session when this client goes out of
scope. | ['A', 'context', 'manager', 'for', 'this', 'client', 's', 'session', '.'] | train | https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/http.py#L311-L320 |
3,483 | quantumlib/Cirq | cirq/google/sim/xmon_simulator.py | XmonSimulator._run | def _run(
self,
circuit: circuits.Circuit,
param_resolver: study.ParamResolver,
repetitions: int,
) -> Dict[str, List[np.ndarray]]:
"""See definition in `cirq.SimulatesSamples`."""
circuit = protocols.resolve_parameters(circuit, param_resolver)
_verify_xmon_c... | python | def _run(
self,
circuit: circuits.Circuit,
param_resolver: study.ParamResolver,
repetitions: int,
) -> Dict[str, List[np.ndarray]]:
"""See definition in `cirq.SimulatesSamples`."""
circuit = protocols.resolve_parameters(circuit, param_resolver)
_verify_xmon_c... | ['def', '_run', '(', 'self', ',', 'circuit', ':', 'circuits', '.', 'Circuit', ',', 'param_resolver', ':', 'study', '.', 'ParamResolver', ',', 'repetitions', ':', 'int', ',', ')', '->', 'Dict', '[', 'str', ',', 'List', '[', 'np', '.', 'ndarray', ']', ']', ':', 'circuit', '=', 'protocols', '.', 'resolve_parameters', '(',... | See definition in `cirq.SimulatesSamples`. | ['See', 'definition', 'in', 'cirq', '.', 'SimulatesSamples', '.'] | train | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/xmon_simulator.py#L144-L159 |
3,484 | yyuu/botornado | boto/ec2/connection.py | EC2Connection.modify_image_attribute | def modify_image_attribute(self, image_id, attribute='launchPermission',
operation='add', user_ids=None, groups=None,
product_codes=None):
"""
Changes an attribute of an image.
:type image_id: string
:param image_id: The imag... | python | def modify_image_attribute(self, image_id, attribute='launchPermission',
operation='add', user_ids=None, groups=None,
product_codes=None):
"""
Changes an attribute of an image.
:type image_id: string
:param image_id: The imag... | ['def', 'modify_image_attribute', '(', 'self', ',', 'image_id', ',', 'attribute', '=', "'launchPermission'", ',', 'operation', '=', "'add'", ',', 'user_ids', '=', 'None', ',', 'groups', '=', 'None', ',', 'product_codes', '=', 'None', ')', ':', 'params', '=', '{', "'ImageId'", ':', 'image_id', ',', "'Attribute'", ':', '... | Changes an attribute of an image.
:type image_id: string
:param image_id: The image id you wish to change
:type attribute: string
:param attribute: The attribute you wish to change
:type operation: string
:param operation: Either add or remove (this is required for cha... | ['Changes', 'an', 'attribute', 'of', 'an', 'image', '.'] | train | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/connection.py#L375-L411 |
3,485 | inasafe/inasafe | safe/gui/tools/wizard/step_kw57_extra_keywords.py | extra_keywords_to_widgets | def extra_keywords_to_widgets(extra_keyword_definition):
"""Create widgets for extra keyword.
:param extra_keyword_definition: An extra keyword definition.
:type extra_keyword_definition: dict
:return: QCheckBox and The input widget
:rtype: (QCheckBox, QWidget)
"""
# Check box
check_bo... | python | def extra_keywords_to_widgets(extra_keyword_definition):
"""Create widgets for extra keyword.
:param extra_keyword_definition: An extra keyword definition.
:type extra_keyword_definition: dict
:return: QCheckBox and The input widget
:rtype: (QCheckBox, QWidget)
"""
# Check box
check_bo... | ['def', 'extra_keywords_to_widgets', '(', 'extra_keyword_definition', ')', ':', '# Check box', 'check_box', '=', 'QCheckBox', '(', 'extra_keyword_definition', '[', "'name'", ']', ')', 'check_box', '.', 'setToolTip', '(', 'extra_keyword_definition', '[', "'description'", ']', ')', 'check_box', '.', 'setChecked', '(', 'T... | Create widgets for extra keyword.
:param extra_keyword_definition: An extra keyword definition.
:type extra_keyword_definition: dict
:return: QCheckBox and The input widget
:rtype: (QCheckBox, QWidget) | ['Create', 'widgets', 'for', 'extra', 'keyword', '.'] | train | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw57_extra_keywords.py#L173-L225 |
3,486 | gwpy/gwpy | gwpy/io/cache.py | is_cache | def is_cache(cache):
"""Returns `True` if ``cache`` is a readable cache file or object
Parameters
----------
cache : `str`, `file`, `list`
Object to detect as cache
Returns
-------
iscache : `bool`
`True` if the input object is a cache, or a file in LAL cache format,
... | python | def is_cache(cache):
"""Returns `True` if ``cache`` is a readable cache file or object
Parameters
----------
cache : `str`, `file`, `list`
Object to detect as cache
Returns
-------
iscache : `bool`
`True` if the input object is a cache, or a file in LAL cache format,
... | ['def', 'is_cache', '(', 'cache', ')', ':', 'if', 'isinstance', '(', 'cache', ',', 'string_types', '+', 'FILE_LIKE', ')', ':', 'try', ':', 'return', 'bool', '(', 'len', '(', 'read_cache', '(', 'cache', ')', ')', ')', 'except', '(', 'TypeError', ',', 'ValueError', ',', 'UnicodeDecodeError', ',', 'ImportError', ')', ':',... | Returns `True` if ``cache`` is a readable cache file or object
Parameters
----------
cache : `str`, `file`, `list`
Object to detect as cache
Returns
-------
iscache : `bool`
`True` if the input object is a cache, or a file in LAL cache format,
otherwise `False` | ['Returns', 'True', 'if', 'cache', 'is', 'a', 'readable', 'cache', 'file', 'or', 'object'] | train | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/io/cache.py#L265-L291 |
3,487 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/random/RandomString.py | RandomString.distort | def distort(value):
"""
Distorts a string by randomly replacing characters in it.
:param value: a string to distort.
:return: a distored string.
"""
value = value.lower()
if (RandomBoolean.chance(1, 5)):
value = value[0:1].upper() + value[1:]
... | python | def distort(value):
"""
Distorts a string by randomly replacing characters in it.
:param value: a string to distort.
:return: a distored string.
"""
value = value.lower()
if (RandomBoolean.chance(1, 5)):
value = value[0:1].upper() + value[1:]
... | ['def', 'distort', '(', 'value', ')', ':', 'value', '=', 'value', '.', 'lower', '(', ')', 'if', '(', 'RandomBoolean', '.', 'chance', '(', '1', ',', '5', ')', ')', ':', 'value', '=', 'value', '[', '0', ':', '1', ']', '.', 'upper', '(', ')', '+', 'value', '[', '1', ':', ']', 'if', '(', 'RandomBoolean', '.', 'chance', '('... | Distorts a string by randomly replacing characters in it.
:param value: a string to distort.
:return: a distored string. | ['Distorts', 'a', 'string', 'by', 'randomly', 'replacing', 'characters', 'in', 'it', '.'] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/random/RandomString.py#L47-L63 |
3,488 | mosdef-hub/mbuild | mbuild/lib/recipes/silica_interface.py | SilicaInterface._strip_stray_atoms | def _strip_stray_atoms(self):
"""Remove stray atoms and surface pieces. """
components = self.bond_graph.connected_components()
major_component = max(components, key=len)
for atom in list(self.particles()):
if atom not in major_component:
self.remove(atom) | python | def _strip_stray_atoms(self):
"""Remove stray atoms and surface pieces. """
components = self.bond_graph.connected_components()
major_component = max(components, key=len)
for atom in list(self.particles()):
if atom not in major_component:
self.remove(atom) | ['def', '_strip_stray_atoms', '(', 'self', ')', ':', 'components', '=', 'self', '.', 'bond_graph', '.', 'connected_components', '(', ')', 'major_component', '=', 'max', '(', 'components', ',', 'key', '=', 'len', ')', 'for', 'atom', 'in', 'list', '(', 'self', '.', 'particles', '(', ')', ')', ':', 'if', 'atom', 'not', 'i... | Remove stray atoms and surface pieces. | ['Remove', 'stray', 'atoms', 'and', 'surface', 'pieces', '.'] | train | https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/lib/recipes/silica_interface.py#L76-L82 |
3,489 | quantopian/zipline | zipline/assets/asset_writer.py | AssetDBWriter.init_db | def init_db(self, txn=None):
"""Connect to database and create tables.
Parameters
----------
txn : sa.engine.Connection, optional
The transaction to execute in. If this is not provided, a new
transaction will be started with the engine provided.
Returns
... | python | def init_db(self, txn=None):
"""Connect to database and create tables.
Parameters
----------
txn : sa.engine.Connection, optional
The transaction to execute in. If this is not provided, a new
transaction will be started with the engine provided.
Returns
... | ['def', 'init_db', '(', 'self', ',', 'txn', '=', 'None', ')', ':', 'with', 'ExitStack', '(', ')', 'as', 'stack', ':', 'if', 'txn', 'is', 'None', ':', 'txn', '=', 'stack', '.', 'enter_context', '(', 'self', '.', 'engine', '.', 'begin', '(', ')', ')', 'tables_already_exist', '=', 'self', '.', '_all_tables_present', '(', ... | Connect to database and create tables.
Parameters
----------
txn : sa.engine.Connection, optional
The transaction to execute in. If this is not provided, a new
transaction will be started with the engine provided.
Returns
-------
metadata : sa.Me... | ['Connect', 'to', 'database', 'and', 'create', 'tables', '.'] | train | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_writer.py#L876-L902 |
3,490 | iotile/coretools | iotilegateway/iotilegateway/supervisor/server.py | IOTileSupervisor.respond_rpc | async def respond_rpc(self, msg, _context):
"""Respond to an RPC previously sent to a service."""
rpc_id = msg.get('response_uuid')
result = msg.get('result')
payload = msg.get('response')
self.service_manager.send_rpc_response(rpc_id, result, payload) | python | async def respond_rpc(self, msg, _context):
"""Respond to an RPC previously sent to a service."""
rpc_id = msg.get('response_uuid')
result = msg.get('result')
payload = msg.get('response')
self.service_manager.send_rpc_response(rpc_id, result, payload) | ['async', 'def', 'respond_rpc', '(', 'self', ',', 'msg', ',', '_context', ')', ':', 'rpc_id', '=', 'msg', '.', 'get', '(', "'response_uuid'", ')', 'result', '=', 'msg', '.', 'get', '(', "'result'", ')', 'payload', '=', 'msg', '.', 'get', '(', "'response'", ')', 'self', '.', 'service_manager', '.', 'send_rpc_response', ... | Respond to an RPC previously sent to a service. | ['Respond', 'to', 'an', 'RPC', 'previously', 'sent', 'to', 'a', 'service', '.'] | train | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/server.py#L162-L169 |
3,491 | ramrod-project/database-brain | schema/brain/binary/data.py | put_buffer | def put_buffer(filename, content, conn=None):
"""
helper function for put
:param filename: <str>
:param content: <bytes>
:param conn: <rethinkdb.DefaultConnection>
:return: <dict>
"""
obj_dict = {PRIMARY_FIELD: filename,
CONTENT_FIELD: content,
TIMESTAMP_F... | python | def put_buffer(filename, content, conn=None):
"""
helper function for put
:param filename: <str>
:param content: <bytes>
:param conn: <rethinkdb.DefaultConnection>
:return: <dict>
"""
obj_dict = {PRIMARY_FIELD: filename,
CONTENT_FIELD: content,
TIMESTAMP_F... | ['def', 'put_buffer', '(', 'filename', ',', 'content', ',', 'conn', '=', 'None', ')', ':', 'obj_dict', '=', '{', 'PRIMARY_FIELD', ':', 'filename', ',', 'CONTENT_FIELD', ':', 'content', ',', 'TIMESTAMP_FIELD', ':', 'time', '(', ')', '}', 'return', 'put', '(', 'obj_dict', ',', 'conn', '=', 'conn', ')'] | helper function for put
:param filename: <str>
:param content: <bytes>
:param conn: <rethinkdb.DefaultConnection>
:return: <dict> | ['helper', 'function', 'for', 'put', ':', 'param', 'filename', ':', '<str', '>', ':', 'param', 'content', ':', '<bytes', '>', ':', 'param', 'conn', ':', '<rethinkdb', '.', 'DefaultConnection', '>', ':', 'return', ':', '<dict', '>'] | train | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/binary/data.py#L44-L55 |
3,492 | AndresMWeber/Nomenclate | nomenclate/core/formatter.py | FormatString.get_valid_format_order | def get_valid_format_order(cls, format_target, format_order=None):
""" Checks to see if the target format string follows the proper style
"""
format_order = format_order or cls.parse_format_order(format_target)
cls.validate_no_token_duplicates(format_order)
format_target = cls.re... | python | def get_valid_format_order(cls, format_target, format_order=None):
""" Checks to see if the target format string follows the proper style
"""
format_order = format_order or cls.parse_format_order(format_target)
cls.validate_no_token_duplicates(format_order)
format_target = cls.re... | ['def', 'get_valid_format_order', '(', 'cls', ',', 'format_target', ',', 'format_order', '=', 'None', ')', ':', 'format_order', '=', 'format_order', 'or', 'cls', '.', 'parse_format_order', '(', 'format_target', ')', 'cls', '.', 'validate_no_token_duplicates', '(', 'format_order', ')', 'format_target', '=', 'cls', '.', ... | Checks to see if the target format string follows the proper style | ['Checks', 'to', 'see', 'if', 'the', 'target', 'format', 'string', 'follows', 'the', 'proper', 'style'] | train | https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/formatter.py#L52-L61 |
3,493 | raphaelvallat/pingouin | pingouin/correlation.py | distance_corr | def distance_corr(x, y, tail='upper', n_boot=1000, seed=None):
"""Distance correlation between two arrays.
Statistical significance (p-value) is evaluated with a permutation test.
Parameters
----------
x, y : np.ndarray
1D or 2D input arrays, shape (n_samples, n_features).
x and y ... | python | def distance_corr(x, y, tail='upper', n_boot=1000, seed=None):
"""Distance correlation between two arrays.
Statistical significance (p-value) is evaluated with a permutation test.
Parameters
----------
x, y : np.ndarray
1D or 2D input arrays, shape (n_samples, n_features).
x and y ... | ['def', 'distance_corr', '(', 'x', ',', 'y', ',', 'tail', '=', "'upper'", ',', 'n_boot', '=', '1000', ',', 'seed', '=', 'None', ')', ':', 'assert', 'tail', 'in', '[', "'upper'", ',', "'lower'", ',', "'two-sided'", ']', ',', "'Wrong tail argument.'", 'x', '=', 'np', '.', 'asarray', '(', 'x', ')', 'y', '=', 'np', '.', 'a... | Distance correlation between two arrays.
Statistical significance (p-value) is evaluated with a permutation test.
Parameters
----------
x, y : np.ndarray
1D or 2D input arrays, shape (n_samples, n_features).
x and y must have the same number of samples and must not
contain miss... | ['Distance', 'correlation', 'between', 'two', 'arrays', '.'] | train | https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/correlation.py#L774-L909 |
3,494 | LettError/ufoProcessor | Lib/ufoProcessor/emptyPen.py | checkGlyphIsEmpty | def checkGlyphIsEmpty(glyph, allowWhiteSpace=True):
"""
This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen.
Additionally, the unicode of the glyph is checked against a list of known unicode whitespace
characters. This makes it possible to filter out gl... | python | def checkGlyphIsEmpty(glyph, allowWhiteSpace=True):
"""
This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen.
Additionally, the unicode of the glyph is checked against a list of known unicode whitespace
characters. This makes it possible to filter out gl... | ['def', 'checkGlyphIsEmpty', '(', 'glyph', ',', 'allowWhiteSpace', '=', 'True', ')', ':', 'whiteSpace', '=', '[', '0x9', ',', '# horizontal tab', '0xa', ',', '# line feed', '0xb', ',', '# vertical tab', '0xc', ',', '# form feed', '0xd', ',', '# carriage return', '0x20', ',', '# space', '0x85', ',', '# next line', '0xa0... | This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen.
Additionally, the unicode of the glyph is checked against a list of known unicode whitespace
characters. This makes it possible to filter out glyphs that have a valid reason to be empty
and those that can... | ['This', 'will', 'establish', 'if', 'the', 'glyph', 'is', 'completely', 'empty', 'by', 'drawing', 'the', 'glyph', 'with', 'an', 'EmptyPen', '.', 'Additionally', 'the', 'unicode', 'of', 'the', 'glyph', 'is', 'checked', 'against', 'a', 'list', 'of', 'known', 'unicode', 'whitespace', 'characters', '.', 'This', 'makes', 'i... | train | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/emptyPen.py#L34-L75 |
3,495 | costastf/toonlib | toonlib/toonlib.py | Toon.get_smokedetector_by_name | def get_smokedetector_by_name(self, name):
"""Retrieves a smokedetector object by its name
:param name: The name of the smokedetector to return
:return: A smokedetector object
"""
return next((smokedetector for smokedetector in self.smokedetectors
if smokede... | python | def get_smokedetector_by_name(self, name):
"""Retrieves a smokedetector object by its name
:param name: The name of the smokedetector to return
:return: A smokedetector object
"""
return next((smokedetector for smokedetector in self.smokedetectors
if smokede... | ['def', 'get_smokedetector_by_name', '(', 'self', ',', 'name', ')', ':', 'return', 'next', '(', '(', 'smokedetector', 'for', 'smokedetector', 'in', 'self', '.', 'smokedetectors', 'if', 'smokedetector', '.', 'name', '.', 'lower', '(', ')', '==', 'name', '.', 'lower', '(', ')', ')', ',', 'None', ')'] | Retrieves a smokedetector object by its name
:param name: The name of the smokedetector to return
:return: A smokedetector object | ['Retrieves', 'a', 'smokedetector', 'object', 'by', 'its', 'name'] | train | https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L236-L243 |
3,496 | twaldear/flask-secure-headers | flask_secure_headers/headers.py | Simple_Header.create_header | def create_header(self):
""" return header dict """
try:
self.check_valid()
_header_list = []
for k,v in self.inputs.items():
if v is None:
return {self.__class__.__name__.replace('_','-'):None}
elif k == 'value':
_header_list.insert(0,str(v))
elif isinstance(v,bool):
if v is Tr... | python | def create_header(self):
""" return header dict """
try:
self.check_valid()
_header_list = []
for k,v in self.inputs.items():
if v is None:
return {self.__class__.__name__.replace('_','-'):None}
elif k == 'value':
_header_list.insert(0,str(v))
elif isinstance(v,bool):
if v is Tr... | ['def', 'create_header', '(', 'self', ')', ':', 'try', ':', 'self', '.', 'check_valid', '(', ')', '_header_list', '=', '[', ']', 'for', 'k', ',', 'v', 'in', 'self', '.', 'inputs', '.', 'items', '(', ')', ':', 'if', 'v', 'is', 'None', ':', 'return', '{', 'self', '.', '__class__', '.', '__name__', '.', 'replace', '(', "'... | return header dict | ['return', 'header', 'dict'] | train | https://github.com/twaldear/flask-secure-headers/blob/3eca972b369608a7669b67cbe66679570a6505ce/flask_secure_headers/headers.py#L40-L57 |
3,497 | nerdvegas/rez | src/rez/packages_.py | iter_package_families | def iter_package_families(paths=None):
"""Iterate over package families, in no particular order.
Note that multiple package families with the same name can be returned.
Unlike packages, families later in the searchpath are not hidden by earlier
families.
Args:
paths (list of str, optional)... | python | def iter_package_families(paths=None):
"""Iterate over package families, in no particular order.
Note that multiple package families with the same name can be returned.
Unlike packages, families later in the searchpath are not hidden by earlier
families.
Args:
paths (list of str, optional)... | ['def', 'iter_package_families', '(', 'paths', '=', 'None', ')', ':', 'for', 'path', 'in', '(', 'paths', 'or', 'config', '.', 'packages_path', ')', ':', 'repo', '=', 'package_repository_manager', '.', 'get_repository', '(', 'path', ')', 'for', 'resource', 'in', 'repo', '.', 'iter_package_families', '(', ')', ':', 'yiel... | Iterate over package families, in no particular order.
Note that multiple package families with the same name can be returned.
Unlike packages, families later in the searchpath are not hidden by earlier
families.
Args:
paths (list of str, optional): paths to search for package families,
... | ['Iterate', 'over', 'package', 'families', 'in', 'no', 'particular', 'order', '.'] | train | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L465-L482 |
3,498 | trevisanj/a99 | a99/textinterface.py | format_box | def format_box(title, ch="*"):
"""
Encloses title in a box. Result is a list
>>> for line in format_box("Today's TODO list"):
... print(line)
*************************
*** Today's TODO list ***
*************************
"""
lt = len(title)
return [(ch * (lt + 8)),... | python | def format_box(title, ch="*"):
"""
Encloses title in a box. Result is a list
>>> for line in format_box("Today's TODO list"):
... print(line)
*************************
*** Today's TODO list ***
*************************
"""
lt = len(title)
return [(ch * (lt + 8)),... | ['def', 'format_box', '(', 'title', ',', 'ch', '=', '"*"', ')', ':', 'lt', '=', 'len', '(', 'title', ')', 'return', '[', '(', 'ch', '*', '(', 'lt', '+', '8', ')', ')', ',', '(', 'ch', '*', '3', '+', '" "', '+', 'title', '+', '" "', '+', 'ch', '*', '3', ')', ',', '(', 'ch', '*', '(', 'lt', '+', '8', ')', ')', ']'] | Encloses title in a box. Result is a list
>>> for line in format_box("Today's TODO list"):
... print(line)
*************************
*** Today's TODO list ***
************************* | ['Encloses', 'title', 'in', 'a', 'box', '.', 'Result', 'is', 'a', 'list', '>>>', 'for', 'line', 'in', 'format_box', '(', 'Today', 's', 'TODO', 'list', ')', ':', '...', 'print', '(', 'line', ')', '*************************', '***', 'Today', 's', 'TODO', 'list', '***', '*************************'] | train | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/textinterface.py#L267-L281 |
3,499 | Hironsan/anago | anago/tagger.py | Tagger.predict | def predict(self, text):
"""Predict using the model.
Args:
text: string, the input text.
Returns:
tags: list, shape = (num_words,)
Returns predicted values.
"""
pred = self.predict_proba(text)
tags = self._get_tags(pred)
retu... | python | def predict(self, text):
"""Predict using the model.
Args:
text: string, the input text.
Returns:
tags: list, shape = (num_words,)
Returns predicted values.
"""
pred = self.predict_proba(text)
tags = self._get_tags(pred)
retu... | ['def', 'predict', '(', 'self', ',', 'text', ')', ':', 'pred', '=', 'self', '.', 'predict_proba', '(', 'text', ')', 'tags', '=', 'self', '.', '_get_tags', '(', 'pred', ')', 'return', 'tags'] | Predict using the model.
Args:
text: string, the input text.
Returns:
tags: list, shape = (num_words,)
Returns predicted values. | ['Predict', 'using', 'the', 'model', '.'] | train | https://github.com/Hironsan/anago/blob/66a97f91c41f9613b736892e9762dccb9c28f623/anago/tagger.py#L126-L139 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.