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
7,300
nmohoric/nypl-digital-collections
nyplcollections/nyplcollections.py
NYPLsearch.uuid
def uuid(self, type, val): """Return the item-uuid for a identifier""" picker = lambda x: x.get('uuid', x) return self._get((type, val), picker)
python
def uuid(self, type, val): """Return the item-uuid for a identifier""" picker = lambda x: x.get('uuid', x) return self._get((type, val), picker)
['def', 'uuid', '(', 'self', ',', 'type', ',', 'val', ')', ':', 'picker', '=', 'lambda', 'x', ':', 'x', '.', 'get', '(', "'uuid'", ',', 'x', ')', 'return', 'self', '.', '_get', '(', '(', 'type', ',', 'val', ')', ',', 'picker', ')']
Return the item-uuid for a identifier
['Return', 'the', 'item', '-', 'uuid', 'for', 'a', 'identifier']
train
https://github.com/nmohoric/nypl-digital-collections/blob/f66cd0a11e7ea2b6c3c327d2693211e2c4609231/nyplcollections/nyplcollections.py#L20-L23
7,301
iotile/coretools
iotilebuild/iotile/build/config/site_scons/trub_script.py
_build_reflash_script_action
def _build_reflash_script_action(target, source, env): """Create a TRUB script containing tile and controller reflashes and/or sensorgraph If the app_info is provided, then the final source file will be a sensorgraph. All subsequent files in source must be in intel hex format. This is guaranteed by the...
python
def _build_reflash_script_action(target, source, env): """Create a TRUB script containing tile and controller reflashes and/or sensorgraph If the app_info is provided, then the final source file will be a sensorgraph. All subsequent files in source must be in intel hex format. This is guaranteed by the...
['def', '_build_reflash_script_action', '(', 'target', ',', 'source', ',', 'env', ')', ':', 'out_path', '=', 'str', '(', 'target', '[', '0', ']', ')', 'source', '=', '[', 'str', '(', 'x', ')', 'for', 'x', 'in', 'source', ']', 'records', '=', '[', ']', 'if', 'env', '[', "'USE_SAFEUPDATE'", ']', ':', 'sgf_off', '=', 'Sen...
Create a TRUB script containing tile and controller reflashes and/or sensorgraph If the app_info is provided, then the final source file will be a sensorgraph. All subsequent files in source must be in intel hex format. This is guaranteed by the ensure_image_is_hex call in build_update_script.
['Create', 'a', 'TRUB', 'script', 'containing', 'tile', 'and', 'controller', 'reflashes', 'and', '/', 'or', 'sensorgraph']
train
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/trub_script.py#L64-L124
7,302
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py
HtmlStats.create_pie_chart
def create_pie_chart(self, snapshot, filename=''): """ Create a pie chart that depicts the distribution of the allocated memory for a given `snapshot`. The chart is saved to `filename`. """ try: from pylab import figure, title, pie, axes, savefig from pyla...
python
def create_pie_chart(self, snapshot, filename=''): """ Create a pie chart that depicts the distribution of the allocated memory for a given `snapshot`. The chart is saved to `filename`. """ try: from pylab import figure, title, pie, axes, savefig from pyla...
['def', 'create_pie_chart', '(', 'self', ',', 'snapshot', ',', 'filename', '=', "''", ')', ':', 'try', ':', 'from', 'pylab', 'import', 'figure', ',', 'title', ',', 'pie', ',', 'axes', ',', 'savefig', 'from', 'pylab', 'import', 'sum', 'as', 'pylab_sum', 'except', 'ImportError', ':', 'return', 'self', '.', 'nopylab_msg',...
Create a pie chart that depicts the distribution of the allocated memory for a given `snapshot`. The chart is saved to `filename`.
['Create', 'a', 'pie', 'chart', 'that', 'depicts', 'the', 'distribution', 'of', 'the', 'allocated', 'memory', 'for', 'a', 'given', 'snapshot', '.', 'The', 'chart', 'is', 'saved', 'to', 'filename', '.']
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py#L680-L711
7,303
resonai/ybt
yabt/builders/cpp.py
compile_cc
def compile_cc(build_context, compiler_config, buildenv, sources, workspace_dir, buildenv_workspace, cmd_env): """Compile list of C++ source files in a buildenv image and return list of generated object file. """ objects = [] for src in sources: obj_rel_path = '{}.o'.format...
python
def compile_cc(build_context, compiler_config, buildenv, sources, workspace_dir, buildenv_workspace, cmd_env): """Compile list of C++ source files in a buildenv image and return list of generated object file. """ objects = [] for src in sources: obj_rel_path = '{}.o'.format...
['def', 'compile_cc', '(', 'build_context', ',', 'compiler_config', ',', 'buildenv', ',', 'sources', ',', 'workspace_dir', ',', 'buildenv_workspace', ',', 'cmd_env', ')', ':', 'objects', '=', '[', ']', 'for', 'src', 'in', 'sources', ':', 'obj_rel_path', '=', "'{}.o'", '.', 'format', '(', 'splitext', '(', 'src', ')', '[...
Compile list of C++ source files in a buildenv image and return list of generated object file.
['Compile', 'list', 'of', 'C', '++', 'source', 'files', 'in', 'a', 'buildenv', 'image', 'and', 'return', 'list', 'of', 'generated', 'object', 'file', '.']
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L244-L265
7,304
DiamondLightSource/python-workflows
workflows/services/common_service.py
CommonService.__start_command_queue_listener
def __start_command_queue_listener(self): """Start the function __command_queue_listener in a separate thread. This function continuously listens to the pipe connected to the frontend. """ thread_function = self.__command_queue_listener class QueueListenerThread(threading.Thread...
python
def __start_command_queue_listener(self): """Start the function __command_queue_listener in a separate thread. This function continuously listens to the pipe connected to the frontend. """ thread_function = self.__command_queue_listener class QueueListenerThread(threading.Thread...
['def', '__start_command_queue_listener', '(', 'self', ')', ':', 'thread_function', '=', 'self', '.', '__command_queue_listener', 'class', 'QueueListenerThread', '(', 'threading', '.', 'Thread', ')', ':', 'def', 'run', '(', 'qltself', ')', ':', 'thread_function', '(', ')', 'assert', 'not', 'hasattr', '(', 'self', ',', ...
Start the function __command_queue_listener in a separate thread. This function continuously listens to the pipe connected to the frontend.
['Start', 'the', 'function', '__command_queue_listener', 'in', 'a', 'separate', 'thread', '.', 'This', 'function', 'continuously', 'listens', 'to', 'the', 'pipe', 'connected', 'to', 'the', 'frontend', '.']
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/services/common_service.py#L263-L278
7,305
tdegeus/GooseMPL
GooseMPL/__init__.py
subplots
def subplots(scale_x=None, scale_y=None, scale=None, **kwargs): r''' Run ``matplotlib.pyplot.subplots`` with ``figsize`` set to the correct multiple of the default. :additional options: **scale, scale_x, scale_y** (``<float>``) Scale the figure-size (along one of the dimensions). ''' if 'figsize' in kwar...
python
def subplots(scale_x=None, scale_y=None, scale=None, **kwargs): r''' Run ``matplotlib.pyplot.subplots`` with ``figsize`` set to the correct multiple of the default. :additional options: **scale, scale_x, scale_y** (``<float>``) Scale the figure-size (along one of the dimensions). ''' if 'figsize' in kwar...
['def', 'subplots', '(', 'scale_x', '=', 'None', ',', 'scale_y', '=', 'None', ',', 'scale', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'if', "'figsize'", 'in', 'kwargs', ':', 'return', 'plt', '.', 'subplots', '(', '*', '*', 'kwargs', ')', 'width', ',', 'height', '=', 'mpl', '.', 'rcParams', '[', "'figure.figsize'"...
r''' Run ``matplotlib.pyplot.subplots`` with ``figsize`` set to the correct multiple of the default. :additional options: **scale, scale_x, scale_y** (``<float>``) Scale the figure-size (along one of the dimensions).
['r', 'Run', 'matplotlib', '.', 'pyplot', '.', 'subplots', 'with', 'figsize', 'set', 'to', 'the', 'correct', 'multiple', 'of', 'the', 'default', '.']
train
https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L367-L397
7,306
rueckstiess/mtools
mtools/util/logfile.py
LogFile.fast_forward
def fast_forward(self, start_dt): """ Fast-forward file to given start_dt datetime obj using binary search. Only fast for files. Streams need to be forwarded manually, and it will miss the first line that would otherwise match (as it consumes the log line). """ i...
python
def fast_forward(self, start_dt): """ Fast-forward file to given start_dt datetime obj using binary search. Only fast for files. Streams need to be forwarded manually, and it will miss the first line that would otherwise match (as it consumes the log line). """ i...
['def', 'fast_forward', '(', 'self', ',', 'start_dt', ')', ':', 'if', 'self', '.', 'from_stdin', ':', '# skip lines until start_dt is reached', 'return', 'else', ':', '# fast bisection path', 'max_mark', '=', 'self', '.', 'filesize', 'step_size', '=', 'max_mark', '# check if start_dt is already smaller than first datet...
Fast-forward file to given start_dt datetime obj using binary search. Only fast for files. Streams need to be forwarded manually, and it will miss the first line that would otherwise match (as it consumes the log line).
['Fast', '-', 'forward', 'file', 'to', 'given', 'start_dt', 'datetime', 'obj', 'using', 'binary', 'search', '.']
train
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L517-L566
7,307
Kautenja/nes-py
nes_py/app/play_random.py
play_random
def play_random(env, steps): """ Play the environment making uniformly random decisions. Args: env (gym.Env): the initialized gym environment to play steps (int): the number of random steps to take Returns: None """ try: done = True progress = tqdm(rang...
python
def play_random(env, steps): """ Play the environment making uniformly random decisions. Args: env (gym.Env): the initialized gym environment to play steps (int): the number of random steps to take Returns: None """ try: done = True progress = tqdm(rang...
['def', 'play_random', '(', 'env', ',', 'steps', ')', ':', 'try', ':', 'done', '=', 'True', 'progress', '=', 'tqdm', '(', 'range', '(', 'steps', ')', ')', 'for', '_', 'in', 'progress', ':', 'if', 'done', ':', '_', '=', 'env', '.', 'reset', '(', ')', 'action', '=', 'env', '.', 'action_space', '.', 'sample', '(', ')', '_...
Play the environment making uniformly random decisions. Args: env (gym.Env): the initialized gym environment to play steps (int): the number of random steps to take Returns: None
['Play', 'the', 'environment', 'making', 'uniformly', 'random', 'decisions', '.']
train
https://github.com/Kautenja/nes-py/blob/a113885198d418f38fcf24b8f79ac508975788c2/nes_py/app/play_random.py#L5-L30
7,308
tumblr/pytumblr
pytumblr/request.py
TumblrRequest.post_multipart
def post_multipart(self, url, params, files): """ Generates and issues a multipart request for data files :param url: a string, the url you are requesting :param params: a dict, a key-value of all the parameters :param files: a dict, matching the form '{name: file descriptor}' ...
python
def post_multipart(self, url, params, files): """ Generates and issues a multipart request for data files :param url: a string, the url you are requesting :param params: a dict, a key-value of all the parameters :param files: a dict, matching the form '{name: file descriptor}' ...
['def', 'post_multipart', '(', 'self', ',', 'url', ',', 'params', ',', 'files', ')', ':', 'resp', '=', 'requests', '.', 'post', '(', 'url', ',', 'data', '=', 'params', ',', 'params', '=', 'params', ',', 'files', '=', 'files', ',', 'headers', '=', 'self', '.', 'headers', ',', 'allow_redirects', '=', 'False', ',', 'auth'...
Generates and issues a multipart request for data files :param url: a string, the url you are requesting :param params: a dict, a key-value of all the parameters :param files: a dict, matching the form '{name: file descriptor}' :returns: a dict parsed from the JSON response
['Generates', 'and', 'issues', 'a', 'multipart', 'request', 'for', 'data', 'files']
train
https://github.com/tumblr/pytumblr/blob/4a5cd7c4b8ae78d12811d9fd52620afa1692a415/pytumblr/request.py#L100-L119
7,309
gabstopper/smc-python
smc/core/general.py
SNMP.update_configuration
def update_configuration(self, **kwargs): """ Update the SNMP configuration using any kwargs supported in the `enable` constructor. Return whether a change was made. You must call update on the engine to commit any changes. :param dict kwargs: keyword arguments supported...
python
def update_configuration(self, **kwargs): """ Update the SNMP configuration using any kwargs supported in the `enable` constructor. Return whether a change was made. You must call update on the engine to commit any changes. :param dict kwargs: keyword arguments supported...
['def', 'update_configuration', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'updated', '=', 'False', 'if', "'snmp_agent'", 'in', 'kwargs', ':', 'kwargs', '.', 'update', '(', 'snmp_agent_ref', '=', 'kwargs', '.', 'pop', '(', "'snmp_agent'", ')', ')', 'snmp_interface', '=', 'kwargs', '.', 'pop', '(', "'snmp_interface...
Update the SNMP configuration using any kwargs supported in the `enable` constructor. Return whether a change was made. You must call update on the engine to commit any changes. :param dict kwargs: keyword arguments supported by enable constructor :rtype: bool
['Update', 'the', 'SNMP', 'configuration', 'using', 'any', 'kwargs', 'supported', 'in', 'the', 'enable', 'constructor', '.', 'Return', 'whether', 'a', 'change', 'was', 'made', '.', 'You', 'must', 'call', 'update', 'on', 'the', 'engine', 'to', 'commit', 'any', 'changes', '.', ':', 'param', 'dict', 'kwargs', ':', 'keywor...
train
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/general.py#L85-L114
7,310
aws/aws-encryption-sdk-python
src/aws_encryption_sdk/key_providers/kms.py
_region_from_key_id
def _region_from_key_id(key_id, default_region=None): """Determine the target region from a key ID, falling back to a default region if provided. :param str key_id: AWS KMS key ID :param str default_region: Region to use if no region found in key_id :returns: region name :rtype: str :raises Unk...
python
def _region_from_key_id(key_id, default_region=None): """Determine the target region from a key ID, falling back to a default region if provided. :param str key_id: AWS KMS key ID :param str default_region: Region to use if no region found in key_id :returns: region name :rtype: str :raises Unk...
['def', '_region_from_key_id', '(', 'key_id', ',', 'default_region', '=', 'None', ')', ':', 'try', ':', 'region_name', '=', 'key_id', '.', 'split', '(', '":"', ',', '4', ')', '[', '3', ']', 'except', 'IndexError', ':', 'if', 'default_region', 'is', 'None', ':', 'raise', 'UnknownRegionError', '(', '"No default region fo...
Determine the target region from a key ID, falling back to a default region if provided. :param str key_id: AWS KMS key ID :param str default_region: Region to use if no region found in key_id :returns: region name :rtype: str :raises UnknownRegionError: if no region found in key_id and no default_...
['Determine', 'the', 'target', 'region', 'from', 'a', 'key', 'ID', 'falling', 'back', 'to', 'a', 'default', 'region', 'if', 'provided', '.']
train
https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L35-L52
7,311
PaulHancock/Aegean
AegeanTools/cluster.py
regroup_vectorized
def regroup_vectorized(srccat, eps, far=None, dist=norm_dist): """ Regroup the islands of a catalog according to their normalised distance. Assumes srccat is recarray-like for efficiency. Return a list of island groups. Parameters ---------- srccat : np.rec.arry or pd.DataFrame Sho...
python
def regroup_vectorized(srccat, eps, far=None, dist=norm_dist): """ Regroup the islands of a catalog according to their normalised distance. Assumes srccat is recarray-like for efficiency. Return a list of island groups. Parameters ---------- srccat : np.rec.arry or pd.DataFrame Sho...
['def', 'regroup_vectorized', '(', 'srccat', ',', 'eps', ',', 'far', '=', 'None', ',', 'dist', '=', 'norm_dist', ')', ':', 'if', 'far', 'is', 'None', ':', 'far', '=', '0.5', '# 10*max(a.a/3600 for a in srccat)', '# most negative declination first', "# XXX: kind='mergesort' ensures stable sorting for determinism.", '# ...
Regroup the islands of a catalog according to their normalised distance. Assumes srccat is recarray-like for efficiency. Return a list of island groups. Parameters ---------- srccat : np.rec.arry or pd.DataFrame Should have the following fields[units]: ra[deg],dec[deg], a[arcsec],b...
['Regroup', 'the', 'islands', 'of', 'a', 'catalog', 'according', 'to', 'their', 'normalised', 'distance', '.']
train
https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/cluster.py#L138-L206
7,312
uw-it-aca/uw-restclients-nws
uw_nws/__init__.py
NWS.get_message_type_by_id
def get_message_type_by_id(self, message_type_id): """ Get a message type by message type ID :param message_type_id: is the message type that the client wants to retrieve """ self._validate_uuid(message_type_id) url = "/notification/v1/mes...
python
def get_message_type_by_id(self, message_type_id): """ Get a message type by message type ID :param message_type_id: is the message type that the client wants to retrieve """ self._validate_uuid(message_type_id) url = "/notification/v1/mes...
['def', 'get_message_type_by_id', '(', 'self', ',', 'message_type_id', ')', ':', 'self', '.', '_validate_uuid', '(', 'message_type_id', ')', 'url', '=', '"/notification/v1/message-type/{}"', '.', 'format', '(', 'message_type_id', ')', 'response', '=', 'NWS_DAO', '(', ')', '.', 'getURL', '(', 'url', ',', 'self', '.', '_...
Get a message type by message type ID :param message_type_id: is the message type that the client wants to retrieve
['Get', 'a', 'message', 'type', 'by', 'message', 'type', 'ID', ':', 'param', 'message_type_id', ':', 'is', 'the', 'message', 'type', 'that', 'the', 'client', 'wants', 'to', 'retrieve']
train
https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L445-L459
7,313
tensorflow/tensor2tensor
tensor2tensor/models/research/moe_experiments.py
xmoe_2d
def xmoe_2d(): """Two-dimensional hierarchical mixture of 16 experts.""" hparams = xmoe_top_2() hparams.decoder_layers = ["att", "hmoe"] * 4 hparams.mesh_shape = "b0:2;b1:4" hparams.outer_batch_size = 4 hparams.layout = "outer_batch:b0;inner_batch:b1,expert_x:b1,expert_y:b0" hparams.moe_num_experts = [4, ...
python
def xmoe_2d(): """Two-dimensional hierarchical mixture of 16 experts.""" hparams = xmoe_top_2() hparams.decoder_layers = ["att", "hmoe"] * 4 hparams.mesh_shape = "b0:2;b1:4" hparams.outer_batch_size = 4 hparams.layout = "outer_batch:b0;inner_batch:b1,expert_x:b1,expert_y:b0" hparams.moe_num_experts = [4, ...
['def', 'xmoe_2d', '(', ')', ':', 'hparams', '=', 'xmoe_top_2', '(', ')', 'hparams', '.', 'decoder_layers', '=', '[', '"att"', ',', '"hmoe"', ']', '*', '4', 'hparams', '.', 'mesh_shape', '=', '"b0:2;b1:4"', 'hparams', '.', 'outer_batch_size', '=', '4', 'hparams', '.', 'layout', '=', '"outer_batch:b0;inner_batch:b1,expe...
Two-dimensional hierarchical mixture of 16 experts.
['Two', '-', 'dimensional', 'hierarchical', 'mixture', 'of', '16', 'experts', '.']
train
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/moe_experiments.py#L185-L193
7,314
boriel/zxbasic
arch/zx48k/optimizer.py
BasicBlock.requires
def requires(self, i=0, end_=None): """ Returns a list of registers and variables this block requires. By default checks from the beginning (i = 0). :param i: initial position of the block to examine :param end_: final position to examine :returns: registers safe to write ...
python
def requires(self, i=0, end_=None): """ Returns a list of registers and variables this block requires. By default checks from the beginning (i = 0). :param i: initial position of the block to examine :param end_: final position to examine :returns: registers safe to write ...
['def', 'requires', '(', 'self', ',', 'i', '=', '0', ',', 'end_', '=', 'None', ')', ':', 'if', 'i', '<', '0', ':', 'i', '=', '0', 'end_', '=', 'len', '(', 'self', ')', 'if', 'end_', 'is', 'None', 'or', 'end_', '>', 'len', '(', 'self', ')', 'else', 'end_', 'regs', '=', '{', "'a'", ',', "'b'", ',', "'c'", ',', "'d'", ','...
Returns a list of registers and variables this block requires. By default checks from the beginning (i = 0). :param i: initial position of the block to examine :param end_: final position to examine :returns: registers safe to write
['Returns', 'a', 'list', 'of', 'registers', 'and', 'variables', 'this', 'block', 'requires', '.', 'By', 'default', 'checks', 'from', 'the', 'beginning', '(', 'i', '=', '0', ')', '.', ':', 'param', 'i', ':', 'initial', 'position', 'of', 'the', 'block', 'to', 'examine', ':', 'param', 'end_', ':', 'final', 'position', 'to...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L1580-L1608
7,315
google/grr
grr/core/grr_response_core/lib/rdfvalues/structs.py
ProtoRDFValue._GetPrimitiveEncoder
def _GetPrimitiveEncoder(self): """Finds the primitive encoder according to the type's data_store_type.""" # Decide what should the primitive type be for packing the target rdfvalue # into the protobuf and create a delegate descriptor to control that. primitive_cls = self._PROTO_DATA_STORE_LOOKUP[self.t...
python
def _GetPrimitiveEncoder(self): """Finds the primitive encoder according to the type's data_store_type.""" # Decide what should the primitive type be for packing the target rdfvalue # into the protobuf and create a delegate descriptor to control that. primitive_cls = self._PROTO_DATA_STORE_LOOKUP[self.t...
['def', '_GetPrimitiveEncoder', '(', 'self', ')', ':', '# Decide what should the primitive type be for packing the target rdfvalue', '# into the protobuf and create a delegate descriptor to control that.', 'primitive_cls', '=', 'self', '.', '_PROTO_DATA_STORE_LOOKUP', '[', 'self', '.', 'type', '.', 'data_store_type', '...
Finds the primitive encoder according to the type's data_store_type.
['Finds', 'the', 'primitive', 'encoder', 'according', 'to', 'the', 'type', 's', 'data_store_type', '.']
train
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1527-L1539
7,316
jonathanslenders/textfsm
jtextfsm.py
TextFSMValue.Parse
def Parse(self, value): """Parse a 'Value' declaration. Args: value: String line from a template file, must begin with 'Value '. Raises: TextFSMTemplateError: Value declaration contains an error. """ value_line = value.split(' ') if len(value_line) < 3: raise TextFSMTemplat...
python
def Parse(self, value): """Parse a 'Value' declaration. Args: value: String line from a template file, must begin with 'Value '. Raises: TextFSMTemplateError: Value declaration contains an error. """ value_line = value.split(' ') if len(value_line) < 3: raise TextFSMTemplat...
['def', 'Parse', '(', 'self', ',', 'value', ')', ':', 'value_line', '=', 'value', '.', 'split', '(', "' '", ')', 'if', 'len', '(', 'value_line', ')', '<', '3', ':', 'raise', 'TextFSMTemplateError', '(', "'Expect at least 3 tokens on line.'", ')', 'if', 'not', 'value_line', '[', '2', ']', '.', 'startswith', '(', "'('", ...
Parse a 'Value' declaration. Args: value: String line from a template file, must begin with 'Value '. Raises: TextFSMTemplateError: Value declaration contains an error.
['Parse', 'a', 'Value', 'declaration', '.']
train
https://github.com/jonathanslenders/textfsm/blob/cca5084512d14bc367205aceb34c938ac1c65daf/jtextfsm.py#L251-L291
7,317
pkgw/pwkit
pwkit/sherpa.py
make_multi_qq_plots
def make_multi_qq_plots(arrays, key_text): """Make a quantile-quantile plot comparing multiple sets of events and models. *arrays* X. *key_text* Text describing the quantile-quantile comparison quantity; will be shown on the plot legend. Returns: An :class:`omega.RectPlot` insta...
python
def make_multi_qq_plots(arrays, key_text): """Make a quantile-quantile plot comparing multiple sets of events and models. *arrays* X. *key_text* Text describing the quantile-quantile comparison quantity; will be shown on the plot legend. Returns: An :class:`omega.RectPlot` insta...
['def', 'make_multi_qq_plots', '(', 'arrays', ',', 'key_text', ')', ':', 'import', 'omega', 'as', 'om', 'p', '=', 'om', '.', 'RectPlot', '(', ')', 'p', '.', 'addXY', '(', '[', '0', ',', '1.', ']', ',', '[', '0', ',', '1.', ']', ',', "'1:1'", ')', 'for', 'index', ',', 'array', 'in', 'enumerate', '(', 'arrays', ')', ':',...
Make a quantile-quantile plot comparing multiple sets of events and models. *arrays* X. *key_text* Text describing the quantile-quantile comparison quantity; will be shown on the plot legend. Returns: An :class:`omega.RectPlot` instance. *TODO*: nothing about this is Sherpa-spe...
['Make', 'a', 'quantile', '-', 'quantile', 'plot', 'comparing', 'multiple', 'sets', 'of', 'events', 'and', 'models', '.']
train
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/sherpa.py#L478-L531
7,318
erdewit/ib_insync
ib_insync/ib.py
IB.reqTickByTickData
def reqTickByTickData( self, contract: Contract, tickType: str, numberOfTicks: int = 0, ignoreSize: bool = False) -> Ticker: """ Subscribe to tick-by-tick data and return the Ticker that holds the ticks in ticker.tickByTicks. https://interactivebrokers.github.io/...
python
def reqTickByTickData( self, contract: Contract, tickType: str, numberOfTicks: int = 0, ignoreSize: bool = False) -> Ticker: """ Subscribe to tick-by-tick data and return the Ticker that holds the ticks in ticker.tickByTicks. https://interactivebrokers.github.io/...
['def', 'reqTickByTickData', '(', 'self', ',', 'contract', ':', 'Contract', ',', 'tickType', ':', 'str', ',', 'numberOfTicks', ':', 'int', '=', '0', ',', 'ignoreSize', ':', 'bool', '=', 'False', ')', '->', 'Ticker', ':', 'reqId', '=', 'self', '.', 'client', '.', 'getReqId', '(', ')', 'ticker', '=', 'self', '.', 'wrappe...
Subscribe to tick-by-tick data and return the Ticker that holds the ticks in ticker.tickByTicks. https://interactivebrokers.github.io/tws-api/tick_data.html Args: contract: Contract of interest. tickType: One of 'Last', 'AllLast', 'BidAsk' or 'MidPoint'. nu...
['Subscribe', 'to', 'tick', '-', 'by', '-', 'tick', 'data', 'and', 'return', 'the', 'Ticker', 'that', 'holds', 'the', 'ticks', 'in', 'ticker', '.', 'tickByTicks', '.']
train
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1172-L1191
7,319
nyaruka/smartmin
smartmin/management/commands/collect_sql.py
Command.normalize_operations
def normalize_operations(self, operations): """ Removes redundant SQL operations - e.g. a CREATE X followed by a DROP X """ normalized = OrderedDict() for operation in operations: op_key = (operation.sql_type, operation.obj_name) # do we already have an ...
python
def normalize_operations(self, operations): """ Removes redundant SQL operations - e.g. a CREATE X followed by a DROP X """ normalized = OrderedDict() for operation in operations: op_key = (operation.sql_type, operation.obj_name) # do we already have an ...
['def', 'normalize_operations', '(', 'self', ',', 'operations', ')', ':', 'normalized', '=', 'OrderedDict', '(', ')', 'for', 'operation', 'in', 'operations', ':', 'op_key', '=', '(', 'operation', '.', 'sql_type', ',', 'operation', '.', 'obj_name', ')', '# do we already have an operation for this object?', 'if', 'op_key...
Removes redundant SQL operations - e.g. a CREATE X followed by a DROP X
['Removes', 'redundant', 'SQL', 'operations', '-', 'e', '.', 'g', '.', 'a', 'CREATE', 'X', 'followed', 'by', 'a', 'DROP', 'X']
train
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/commands/collect_sql.py#L156-L178
7,320
thebigmunch/google-music
src/google_music/clients/mobileclient.py
MobileClient.playlist_song_delete
def playlist_song_delete(self, playlist_song): """Delete song from playlist. Parameters: playlist_song (str): A playlist song dict. Returns: dict: Playlist dict including songs. """ self.playlist_songs_delete([playlist_song]) return self.playlist(playlist_song['playlistId'], include_songs=True)
python
def playlist_song_delete(self, playlist_song): """Delete song from playlist. Parameters: playlist_song (str): A playlist song dict. Returns: dict: Playlist dict including songs. """ self.playlist_songs_delete([playlist_song]) return self.playlist(playlist_song['playlistId'], include_songs=True)
['def', 'playlist_song_delete', '(', 'self', ',', 'playlist_song', ')', ':', 'self', '.', 'playlist_songs_delete', '(', '[', 'playlist_song', ']', ')', 'return', 'self', '.', 'playlist', '(', 'playlist_song', '[', "'playlistId'", ']', ',', 'include_songs', '=', 'True', ')']
Delete song from playlist. Parameters: playlist_song (str): A playlist song dict. Returns: dict: Playlist dict including songs.
['Delete', 'song', 'from', 'playlist', '.']
train
https://github.com/thebigmunch/google-music/blob/d8a94dab462a1f063fbc1152187a73dc2f0e2a85/src/google_music/clients/mobileclient.py#L552-L564
7,321
jpscaletti/pyceo
pyceo/manager.py
Manager.command
def command(self, group=None, help="", name=None): """Decorator for adding a command to this manager.""" def decorator(func): return self.add_command(func, group=group, help=help, name=name) return decorator
python
def command(self, group=None, help="", name=None): """Decorator for adding a command to this manager.""" def decorator(func): return self.add_command(func, group=group, help=help, name=name) return decorator
['def', 'command', '(', 'self', ',', 'group', '=', 'None', ',', 'help', '=', '""', ',', 'name', '=', 'None', ')', ':', 'def', 'decorator', '(', 'func', ')', ':', 'return', 'self', '.', 'add_command', '(', 'func', ',', 'group', '=', 'group', ',', 'help', '=', 'help', ',', 'name', '=', 'name', ')', 'return', 'decorator']
Decorator for adding a command to this manager.
['Decorator', 'for', 'adding', 'a', 'command', 'to', 'this', 'manager', '.']
train
https://github.com/jpscaletti/pyceo/blob/7f37eaf8e557d25f8e54634176139e0aad84b8df/pyceo/manager.py#L57-L61
7,322
timothyb0912/pylogit
pylogit/bootstrap_sampler.py
create_deepcopied_groupby_dict
def create_deepcopied_groupby_dict(orig_df, obs_id_col): """ Will create a dictionary where each key corresponds to a unique value in `orig_df[obs_id_col]` and each value corresponds to all of the rows of `orig_df` where `orig_df[obs_id_col] == key`. Parameters ---------- orig_df : pandas D...
python
def create_deepcopied_groupby_dict(orig_df, obs_id_col): """ Will create a dictionary where each key corresponds to a unique value in `orig_df[obs_id_col]` and each value corresponds to all of the rows of `orig_df` where `orig_df[obs_id_col] == key`. Parameters ---------- orig_df : pandas D...
['def', 'create_deepcopied_groupby_dict', '(', 'orig_df', ',', 'obs_id_col', ')', ':', '# Get the observation id values', 'obs_id_vals', '=', 'orig_df', '[', 'obs_id_col', ']', '.', 'values', '# Get the unique observation ids', 'unique_obs_ids', '=', 'np', '.', 'unique', '(', 'obs_id_vals', ')', '# Initialize the dicti...
Will create a dictionary where each key corresponds to a unique value in `orig_df[obs_id_col]` and each value corresponds to all of the rows of `orig_df` where `orig_df[obs_id_col] == key`. Parameters ---------- orig_df : pandas DataFrame. Should be long-format dataframe containing the data...
['Will', 'create', 'a', 'dictionary', 'where', 'each', 'key', 'corresponds', 'to', 'a', 'unique', 'value', 'in', 'orig_df', '[', 'obs_id_col', ']', 'and', 'each', 'value', 'corresponds', 'to', 'all', 'of', 'the', 'rows', 'of', 'orig_df', 'where', 'orig_df', '[', 'obs_id_col', ']', '==', 'key', '.']
train
https://github.com/timothyb0912/pylogit/blob/f83b0fd6debaa7358d87c3828428f6d4ead71357/pylogit/bootstrap_sampler.py#L207-L242
7,323
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxanalysis.py
DXAnalysis.add_tags
def add_tags(self, tags, **kwargs): """ :param tags: Tags to add to the analysis :type tags: list of strings Adds each of the specified tags to the analysis. Takes no action for tags that are already listed for the analysis. """ dxpy.api.analysis_add_tags(self....
python
def add_tags(self, tags, **kwargs): """ :param tags: Tags to add to the analysis :type tags: list of strings Adds each of the specified tags to the analysis. Takes no action for tags that are already listed for the analysis. """ dxpy.api.analysis_add_tags(self....
['def', 'add_tags', '(', 'self', ',', 'tags', ',', '*', '*', 'kwargs', ')', ':', 'dxpy', '.', 'api', '.', 'analysis_add_tags', '(', 'self', '.', '_dxid', ',', '{', '"tags"', ':', 'tags', '}', ',', '*', '*', 'kwargs', ')']
:param tags: Tags to add to the analysis :type tags: list of strings Adds each of the specified tags to the analysis. Takes no action for tags that are already listed for the analysis.
[':', 'param', 'tags', ':', 'Tags', 'to', 'add', 'to', 'the', 'analysis', ':', 'type', 'tags', ':', 'list', 'of', 'strings']
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxanalysis.py#L70-L80
7,324
facebook/pyre-check
sapp/sapp/analysis_output.py
AnalysisOutput.file_handles
def file_handles(self) -> Iterable[IO[str]]: """Generates all file handles represented by the analysis. Callee owns file handle and closes it when the next is yielded or the generator ends. """ if self.file_handle: yield self.file_handle self.file_handle.c...
python
def file_handles(self) -> Iterable[IO[str]]: """Generates all file handles represented by the analysis. Callee owns file handle and closes it when the next is yielded or the generator ends. """ if self.file_handle: yield self.file_handle self.file_handle.c...
['def', 'file_handles', '(', 'self', ')', '->', 'Iterable', '[', 'IO', '[', 'str', ']', ']', ':', 'if', 'self', '.', 'file_handle', ':', 'yield', 'self', '.', 'file_handle', 'self', '.', 'file_handle', '.', 'close', '(', ')', 'self', '.', 'file_handle', '=', 'None', 'else', ':', 'for', 'name', 'in', 'self', '.', 'file_...
Generates all file handles represented by the analysis. Callee owns file handle and closes it when the next is yielded or the generator ends.
['Generates', 'all', 'file', 'handles', 'represented', 'by', 'the', 'analysis', '.', 'Callee', 'owns', 'file', 'handle', 'and', 'closes', 'it', 'when', 'the', 'next', 'is', 'yielded', 'or', 'the', 'generator', 'ends', '.']
train
https://github.com/facebook/pyre-check/blob/4a9604d943d28ef20238505a51acfb1f666328d7/sapp/sapp/analysis_output.py#L107-L119
7,325
airspeed-velocity/asv
asv/benchmark.py
Benchmark.insert_param
def insert_param(self, param): """ Insert a parameter at the front of the parameter list. """ self._current_params = tuple([param] + list(self._current_params))
python
def insert_param(self, param): """ Insert a parameter at the front of the parameter list. """ self._current_params = tuple([param] + list(self._current_params))
['def', 'insert_param', '(', 'self', ',', 'param', ')', ':', 'self', '.', '_current_params', '=', 'tuple', '(', '[', 'param', ']', '+', 'list', '(', 'self', '.', '_current_params', ')', ')']
Insert a parameter at the front of the parameter list.
['Insert', 'a', 'parameter', 'at', 'the', 'front', 'of', 'the', 'parameter', 'list', '.']
train
https://github.com/airspeed-velocity/asv/blob/d23bb8b74e8adacbfa3cf5724bda55fb39d56ba6/asv/benchmark.py#L462-L466
7,326
mailgun/talon
talon/utils.py
to_utf8
def to_utf8(str_or_unicode): """ Safely returns a UTF-8 version of a given string >>> utils.to_utf8(u'hi') 'hi' """ if not isinstance(str_or_unicode, six.text_type): return str_or_unicode.encode("utf-8", "ignore") return str(str_or_unicode)
python
def to_utf8(str_or_unicode): """ Safely returns a UTF-8 version of a given string >>> utils.to_utf8(u'hi') 'hi' """ if not isinstance(str_or_unicode, six.text_type): return str_or_unicode.encode("utf-8", "ignore") return str(str_or_unicode)
['def', 'to_utf8', '(', 'str_or_unicode', ')', ':', 'if', 'not', 'isinstance', '(', 'str_or_unicode', ',', 'six', '.', 'text_type', ')', ':', 'return', 'str_or_unicode', '.', 'encode', '(', '"utf-8"', ',', '"ignore"', ')', 'return', 'str', '(', 'str_or_unicode', ')']
Safely returns a UTF-8 version of a given string >>> utils.to_utf8(u'hi') 'hi'
['Safely', 'returns', 'a', 'UTF', '-', '8', 'version', 'of', 'a', 'given', 'string', '>>>', 'utils', '.', 'to_utf8', '(', 'u', 'hi', ')', 'hi']
train
https://github.com/mailgun/talon/blob/cdd84563dd329c4f887591807870d10015e0c7a7/talon/utils.py#L89-L97
7,327
Yelp/detect-secrets
detect_secrets/core/secrets_collection.py
SecretsCollection._extract_secrets_from_patch
def _extract_secrets_from_patch(self, f, plugin, filename): """Extract secrets from a given patch file object. Note that we only want to capture incoming secrets (so added lines). :type f: unidiff.patch.PatchedFile :type plugin: detect_secrets.plugins.base.BasePlugin :type file...
python
def _extract_secrets_from_patch(self, f, plugin, filename): """Extract secrets from a given patch file object. Note that we only want to capture incoming secrets (so added lines). :type f: unidiff.patch.PatchedFile :type plugin: detect_secrets.plugins.base.BasePlugin :type file...
['def', '_extract_secrets_from_patch', '(', 'self', ',', 'f', ',', 'plugin', ',', 'filename', ')', ':', 'output', '=', '{', '}', 'for', 'chunk', 'in', 'f', ':', '# target_lines refers to incoming (new) changes', 'for', 'line', 'in', 'chunk', '.', 'target_lines', '(', ')', ':', 'if', 'line', '.', 'is_added', ':', 'outpu...
Extract secrets from a given patch file object. Note that we only want to capture incoming secrets (so added lines). :type f: unidiff.patch.PatchedFile :type plugin: detect_secrets.plugins.base.BasePlugin :type filename: str
['Extract', 'secrets', 'from', 'a', 'given', 'patch', 'file', 'object', '.']
train
https://github.com/Yelp/detect-secrets/blob/473923ea71f1ac2b5ea1eacc49b98f97967e3d05/detect_secrets/core/secrets_collection.py#L312-L334
7,328
gear11/pypelogs
pypein/flickr.py
Flickr.search_groups
def search_groups(self, args): """ Executes a search flickr:(credsfile),search,(arg1)=(val1),(arg2)=(val2)... """ kwargs = {'text': args[0]} return self._paged_api_call(self.flickr.groups_search, kwargs, 'group')
python
def search_groups(self, args): """ Executes a search flickr:(credsfile),search,(arg1)=(val1),(arg2)=(val2)... """ kwargs = {'text': args[0]} return self._paged_api_call(self.flickr.groups_search, kwargs, 'group')
['def', 'search_groups', '(', 'self', ',', 'args', ')', ':', 'kwargs', '=', '{', "'text'", ':', 'args', '[', '0', ']', '}', 'return', 'self', '.', '_paged_api_call', '(', 'self', '.', 'flickr', '.', 'groups_search', ',', 'kwargs', ',', "'group'", ')']
Executes a search flickr:(credsfile),search,(arg1)=(val1),(arg2)=(val2)...
['Executes', 'a', 'search']
train
https://github.com/gear11/pypelogs/blob/da5dc0fee5373a4be294798b5e32cd0a803d8bbe/pypein/flickr.py#L90-L97
7,329
michael-lazar/rtv
rtv/packages/praw/__init__.py
PrivateMessagesMixin.get_messages
def get_messages(self, *args, **kwargs): """Return a get_content generator for inbox (messages only). The additional parameters are passed directly into :meth:`.get_content`. Note: the `url` parameter cannot be altered. """ return self.get_content(self.config['messages'], *args...
python
def get_messages(self, *args, **kwargs): """Return a get_content generator for inbox (messages only). The additional parameters are passed directly into :meth:`.get_content`. Note: the `url` parameter cannot be altered. """ return self.get_content(self.config['messages'], *args...
['def', 'get_messages', '(', 'self', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'return', 'self', '.', 'get_content', '(', 'self', '.', 'config', '[', "'messages'", ']', ',', '*', 'args', ',', '*', '*', 'kwargs', ')']
Return a get_content generator for inbox (messages only). The additional parameters are passed directly into :meth:`.get_content`. Note: the `url` parameter cannot be altered.
['Return', 'a', 'get_content', 'generator', 'for', 'inbox', '(', 'messages', 'only', ')', '.']
train
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L2511-L2518
7,330
oleg-golovanov/unilog
unilog/unilog.py
as_unicode
def as_unicode(obj, encoding=convert.LOCALE, pretty=False): """ Representing any object to <unicode> string (python2.7) or <str> string (python3.0). :param obj: any object :type encoding: str :param encoding: codec for encoding unicode strings (locale.getpreferredencoding() by ...
python
def as_unicode(obj, encoding=convert.LOCALE, pretty=False): """ Representing any object to <unicode> string (python2.7) or <str> string (python3.0). :param obj: any object :type encoding: str :param encoding: codec for encoding unicode strings (locale.getpreferredencoding() by ...
['def', 'as_unicode', '(', 'obj', ',', 'encoding', '=', 'convert', '.', 'LOCALE', ',', 'pretty', '=', 'False', ')', ':', 'return', 'convert', '.', 'convert', '(', 'obj', ',', 'encoding', ',', '0', 'if', 'pretty', 'else', 'None', ')']
Representing any object to <unicode> string (python2.7) or <str> string (python3.0). :param obj: any object :type encoding: str :param encoding: codec for encoding unicode strings (locale.getpreferredencoding() by default) :type pretty: bool :param pretty: pretty print :rt...
['Representing', 'any', 'object', 'to', '<unicode', '>', 'string', '(', 'python2', '.', '7', ')', 'or', '<str', '>', 'string', '(', 'python3', '.', '0', ')', '.']
train
https://github.com/oleg-golovanov/unilog/blob/4d59cd910032383a71796c4df7446fd5875938c3/unilog/unilog.py#L7-L22
7,331
walter426/Python_GoogleMapsApi
GoogleMapsApi/geocode.py
Geocoding.reverse
def reverse(self, point, language=None, sensor=False): '''Reverse geocode a point. Pls refer to the Google Maps Web API for the details of the parameters ''' params = { 'latlng': point, 'sensor': str(sensor).lower() } if language: ...
python
def reverse(self, point, language=None, sensor=False): '''Reverse geocode a point. Pls refer to the Google Maps Web API for the details of the parameters ''' params = { 'latlng': point, 'sensor': str(sensor).lower() } if language: ...
['def', 'reverse', '(', 'self', ',', 'point', ',', 'language', '=', 'None', ',', 'sensor', '=', 'False', ')', ':', 'params', '=', '{', "'latlng'", ':', 'point', ',', "'sensor'", ':', 'str', '(', 'sensor', ')', '.', 'lower', '(', ')', '}', 'if', 'language', ':', 'params', '[', "'language'", ']', '=', 'language', 'if', '...
Reverse geocode a point. Pls refer to the Google Maps Web API for the details of the parameters
['Reverse', 'geocode', 'a', 'point', '.', 'Pls', 'refer', 'to', 'the', 'Google', 'Maps', 'Web', 'API', 'for', 'the', 'details', 'of', 'the', 'parameters']
train
https://github.com/walter426/Python_GoogleMapsApi/blob/4832b293a0027446941a5f00ecc66256f92ddbce/GoogleMapsApi/geocode.py#L66-L83
7,332
evandempsey/fp-growth
pyfpgrowth/pyfpgrowth.py
FPNode.add_child
def add_child(self, value): """ Add a node as a child node. """ child = FPNode(value, 1, self) self.children.append(child) return child
python
def add_child(self, value): """ Add a node as a child node. """ child = FPNode(value, 1, self) self.children.append(child) return child
['def', 'add_child', '(', 'self', ',', 'value', ')', ':', 'child', '=', 'FPNode', '(', 'value', ',', '1', ',', 'self', ')', 'self', '.', 'children', '.', 'append', '(', 'child', ')', 'return', 'child']
Add a node as a child node.
['Add', 'a', 'node', 'as', 'a', 'child', 'node', '.']
train
https://github.com/evandempsey/fp-growth/blob/6bf4503024e86c5bbea8a05560594f2f7f061c15/pyfpgrowth/pyfpgrowth.py#L39-L45
7,333
fhcrc/seqmagick
seqmagick/transform.py
drop_columns
def drop_columns(records, slices): """ Drop all columns present in ``slices`` from records """ for record in records: # Generate a set of indices to remove drop = set(i for slice in slices for i in range(*slice.indices(len(record)))) keep = [i not in drop for i...
python
def drop_columns(records, slices): """ Drop all columns present in ``slices`` from records """ for record in records: # Generate a set of indices to remove drop = set(i for slice in slices for i in range(*slice.indices(len(record)))) keep = [i not in drop for i...
['def', 'drop_columns', '(', 'records', ',', 'slices', ')', ':', 'for', 'record', 'in', 'records', ':', '# Generate a set of indices to remove', 'drop', '=', 'set', '(', 'i', 'for', 'slice', 'in', 'slices', 'for', 'i', 'in', 'range', '(', '*', 'slice', '.', 'indices', '(', 'len', '(', 'record', ')', ')', ')', ')', 'kee...
Drop all columns present in ``slices`` from records
['Drop', 'all', 'columns', 'present', 'in', 'slices', 'from', 'records']
train
https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L184-L194
7,334
pycontribs/pyrax
pyrax/object_storage.py
StorageClient.get_container_metadata
def get_container_metadata(self, container, prefix=None): """ Returns a dictionary containing the metadata for the container. """ return self._manager.get_metadata(container, prefix=prefix)
python
def get_container_metadata(self, container, prefix=None): """ Returns a dictionary containing the metadata for the container. """ return self._manager.get_metadata(container, prefix=prefix)
['def', 'get_container_metadata', '(', 'self', ',', 'container', ',', 'prefix', '=', 'None', ')', ':', 'return', 'self', '.', '_manager', '.', 'get_metadata', '(', 'container', ',', 'prefix', '=', 'prefix', ')']
Returns a dictionary containing the metadata for the container.
['Returns', 'a', 'dictionary', 'containing', 'the', 'metadata', 'for', 'the', 'container', '.']
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/object_storage.py#L2530-L2534
7,335
jmurty/xml4h
xml4h/nodes.py
Node.xml
def xml(self, indent=4, **kwargs): """ :return: this node as XML text. Delegates to :meth:`write` """ writer = StringIO() self.write(writer, indent=indent, **kwargs) return writer.getvalue()
python
def xml(self, indent=4, **kwargs): """ :return: this node as XML text. Delegates to :meth:`write` """ writer = StringIO() self.write(writer, indent=indent, **kwargs) return writer.getvalue()
['def', 'xml', '(', 'self', ',', 'indent', '=', '4', ',', '*', '*', 'kwargs', ')', ':', 'writer', '=', 'StringIO', '(', ')', 'self', '.', 'write', '(', 'writer', ',', 'indent', '=', 'indent', ',', '*', '*', 'kwargs', ')', 'return', 'writer', '.', 'getvalue', '(', ')']
:return: this node as XML text. Delegates to :meth:`write`
[':', 'return', ':', 'this', 'node', 'as', 'XML', 'text', '.']
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L503-L511
7,336
django-extensions/django-extensions
django_extensions/management/commands/graph_models.py
Command.render_output_pygraphviz
def render_output_pygraphviz(self, dotdata, **kwargs): """Render model data as image using pygraphviz""" if not HAS_PYGRAPHVIZ: raise CommandError("You need to install pygraphviz python module") version = pygraphviz.__version__.rstrip("-svn") try: if tuple(int(v)...
python
def render_output_pygraphviz(self, dotdata, **kwargs): """Render model data as image using pygraphviz""" if not HAS_PYGRAPHVIZ: raise CommandError("You need to install pygraphviz python module") version = pygraphviz.__version__.rstrip("-svn") try: if tuple(int(v)...
['def', 'render_output_pygraphviz', '(', 'self', ',', 'dotdata', ',', '*', '*', 'kwargs', ')', ':', 'if', 'not', 'HAS_PYGRAPHVIZ', ':', 'raise', 'CommandError', '(', '"You need to install pygraphviz python module"', ')', 'version', '=', 'pygraphviz', '.', '__version__', '.', 'rstrip', '(', '"-svn"', ')', 'try', ':', 'i...
Render model data as image using pygraphviz
['Render', 'model', 'data', 'as', 'image', 'using', 'pygraphviz']
train
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/graph_models.py#L254-L272
7,337
fastai/fastai
old/fastai/dataset.py
ImageClassifierData.from_csv
def from_csv(cls, path, folder, csv_fname, bs=64, tfms=(None,None), val_idxs=None, suffix='', test_name=None, continuous=False, skip_header=True, num_workers=8, cat_separator=' '): """ Read in images and their labels given as a CSV file. This method should be used when training image lab...
python
def from_csv(cls, path, folder, csv_fname, bs=64, tfms=(None,None), val_idxs=None, suffix='', test_name=None, continuous=False, skip_header=True, num_workers=8, cat_separator=' '): """ Read in images and their labels given as a CSV file. This method should be used when training image lab...
['def', 'from_csv', '(', 'cls', ',', 'path', ',', 'folder', ',', 'csv_fname', ',', 'bs', '=', '64', ',', 'tfms', '=', '(', 'None', ',', 'None', ')', ',', 'val_idxs', '=', 'None', ',', 'suffix', '=', "''", ',', 'test_name', '=', 'None', ',', 'continuous', '=', 'False', ',', 'skip_header', '=', 'True', ',', 'num_workers'...
Read in images and their labels given as a CSV file. This method should be used when training image labels are given in an CSV file as opposed to sub-directories with label names. Arguments: path: a root path of the data (used for storing trained models, precomputed values, etc) ...
['Read', 'in', 'images', 'and', 'their', 'labels', 'given', 'as', 'a', 'CSV', 'file', '.']
train
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/old/fastai/dataset.py#L522-L553
7,338
keras-rl/keras-rl
rl/policy.py
SoftmaxPolicy.select_action
def select_action(self, nb_actions, probs): """Return the selected action # Arguments probs (np.ndarray) : Probabilty for each action # Returns action """ action = np.random.choice(range(nb_actions), p=probs) return action
python
def select_action(self, nb_actions, probs): """Return the selected action # Arguments probs (np.ndarray) : Probabilty for each action # Returns action """ action = np.random.choice(range(nb_actions), p=probs) return action
['def', 'select_action', '(', 'self', ',', 'nb_actions', ',', 'probs', ')', ':', 'action', '=', 'np', '.', 'random', '.', 'choice', '(', 'range', '(', 'nb_actions', ')', ',', 'p', '=', 'probs', ')', 'return', 'action']
Return the selected action # Arguments probs (np.ndarray) : Probabilty for each action # Returns action
['Return', 'the', 'selected', 'action']
train
https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L128-L139
7,339
codeinthehole/purl
purl/url.py
URL.path_segments
def path_segments(self, value=None): """ Return the path segments :param list value: the new path segments to use """ if value is not None: encoded_values = map(unicode_quote_path_segment, value) new_path = '/' + '/'.join(encoded_values) retur...
python
def path_segments(self, value=None): """ Return the path segments :param list value: the new path segments to use """ if value is not None: encoded_values = map(unicode_quote_path_segment, value) new_path = '/' + '/'.join(encoded_values) retur...
['def', 'path_segments', '(', 'self', ',', 'value', '=', 'None', ')', ':', 'if', 'value', 'is', 'not', 'None', ':', 'encoded_values', '=', 'map', '(', 'unicode_quote_path_segment', ',', 'value', ')', 'new_path', '=', "'/'", '+', "'/'", '.', 'join', '(', 'encoded_values', ')', 'return', 'URL', '.', '_mutate', '(', 'self...
Return the path segments :param list value: the new path segments to use
['Return', 'the', 'path', 'segments']
train
https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L385-L400
7,340
scidam/cachepy
utils.py
Helpers.encode_safely
def encode_safely(self, data): """Encode the data. """ encoder = self.base_encoder result = settings.null try: result = encoder(pickle.dumps(data)) except: warnings.warn("Data could not be serialized.", RuntimeWarning) return resu...
python
def encode_safely(self, data): """Encode the data. """ encoder = self.base_encoder result = settings.null try: result = encoder(pickle.dumps(data)) except: warnings.warn("Data could not be serialized.", RuntimeWarning) return resu...
['def', 'encode_safely', '(', 'self', ',', 'data', ')', ':', 'encoder', '=', 'self', '.', 'base_encoder', 'result', '=', 'settings', '.', 'null', 'try', ':', 'result', '=', 'encoder', '(', 'pickle', '.', 'dumps', '(', 'data', ')', ')', 'except', ':', 'warnings', '.', 'warn', '(', '"Data could not be serialized."', ',',...
Encode the data.
['Encode', 'the', 'data', '.']
train
https://github.com/scidam/cachepy/blob/680eeb7ff04ec9bb634b71cceb0841abaf2d530e/utils.py#L49-L60
7,341
jonathf/chaospy
chaospy/bertran/operators.py
olindex
def olindex(order, dim): """ Create an lexiographical sorted basis for a given order. Examples -------- >>> chaospy.bertran.olindex(3, 2) array([[0, 3], [1, 2], [2, 1], [3, 0]]) """ idxm = [0]*dim out = [] def _olindex(idx): """Recursive...
python
def olindex(order, dim): """ Create an lexiographical sorted basis for a given order. Examples -------- >>> chaospy.bertran.olindex(3, 2) array([[0, 3], [1, 2], [2, 1], [3, 0]]) """ idxm = [0]*dim out = [] def _olindex(idx): """Recursive...
['def', 'olindex', '(', 'order', ',', 'dim', ')', ':', 'idxm', '=', '[', '0', ']', '*', 'dim', 'out', '=', '[', ']', 'def', '_olindex', '(', 'idx', ')', ':', '"""Recursive backend for olindex."""', 'if', 'numpy', '.', 'sum', '(', 'idxm', ')', '==', 'order', ':', 'out', '.', 'append', '(', 'idxm', '[', ':', ']', ')', 'r...
Create an lexiographical sorted basis for a given order. Examples -------- >>> chaospy.bertran.olindex(3, 2) array([[0, 3], [1, 2], [2, 1], [3, 0]])
['Create', 'an', 'lexiographical', 'sorted', 'basis', 'for', 'a', 'given', 'order', '.']
train
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/bertran/operators.py#L291-L330
7,342
Karaage-Cluster/karaage
karaage/common/decorators.py
login_required
def login_required(function=None): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary. """ def check_perms(user): # if user not logged in, show login form if not user.is_authenticated: return False # if this...
python
def login_required(function=None): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary. """ def check_perms(user): # if user not logged in, show login form if not user.is_authenticated: return False # if this...
['def', 'login_required', '(', 'function', '=', 'None', ')', ':', 'def', 'check_perms', '(', 'user', ')', ':', '# if user not logged in, show login form', 'if', 'not', 'user', '.', 'is_authenticated', ':', 'return', 'False', '# if this is the admin site only admin access', 'if', 'settings', '.', 'ADMIN_REQUIRED', 'and'...
Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary.
['Decorator', 'for', 'views', 'that', 'checks', 'that', 'the', 'user', 'is', 'logged', 'in', 'redirecting', 'to', 'the', 'log', '-', 'in', 'page', 'if', 'necessary', '.']
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/decorators.py#L53-L70
7,343
spacetelescope/acstools
acstools/utils_calib.py
get_corner
def get_corner(hdr, rsize=1): """Obtain bin and corner information for a subarray. ``LTV1``, ``LTV2``, ``LTM1_1``, and ``LTM2_2`` keywords are extracted from the given extension header and converted to bin and corner values (0-indexed). ``LTV1`` for the CCD uses the beginning of the illuminated ...
python
def get_corner(hdr, rsize=1): """Obtain bin and corner information for a subarray. ``LTV1``, ``LTV2``, ``LTM1_1``, and ``LTM2_2`` keywords are extracted from the given extension header and converted to bin and corner values (0-indexed). ``LTV1`` for the CCD uses the beginning of the illuminated ...
['def', 'get_corner', '(', 'hdr', ',', 'rsize', '=', '1', ')', ':', 'ltm', ',', 'ltv', '=', 'get_lt', '(', 'hdr', ')', 'return', 'from_lt', '(', 'rsize', ',', 'ltm', ',', 'ltv', ')']
Obtain bin and corner information for a subarray. ``LTV1``, ``LTV2``, ``LTM1_1``, and ``LTM2_2`` keywords are extracted from the given extension header and converted to bin and corner values (0-indexed). ``LTV1`` for the CCD uses the beginning of the illuminated portion as the origin, not the begi...
['Obtain', 'bin', 'and', 'corner', 'information', 'for', 'a', 'subarray', '.']
train
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/utils_calib.py#L354-L388
7,344
portfors-lab/sparkle
sparkle/gui/stim/tuning_curve.py
TuningCurveEditor.setStimDuration
def setStimDuration(self): """Sets the duration of the StimulusModel from values pulled from this widget""" duration = self.ui.durSpnbx.value() self.tone.setDuration(duration)
python
def setStimDuration(self): """Sets the duration of the StimulusModel from values pulled from this widget""" duration = self.ui.durSpnbx.value() self.tone.setDuration(duration)
['def', 'setStimDuration', '(', 'self', ')', ':', 'duration', '=', 'self', '.', 'ui', '.', 'durSpnbx', '.', 'value', '(', ')', 'self', '.', 'tone', '.', 'setDuration', '(', 'duration', ')']
Sets the duration of the StimulusModel from values pulled from this widget
['Sets', 'the', 'duration', 'of', 'the', 'StimulusModel', 'from', 'values', 'pulled', 'from', 'this', 'widget']
train
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/tuning_curve.py#L83-L87
7,345
luckydonald/pytgbot
examples/cli.py
CLI.print_peer
def print_peer(self, peer, show_id=True, id_prefix="", reply=True): """ :param id_prefix: Prefix of the #id thing. Set a string, or true to have it generated. :type id_prefix: str|bool """ if isinstance(id_prefix, bool): if id_prefix: # True if isins...
python
def print_peer(self, peer, show_id=True, id_prefix="", reply=True): """ :param id_prefix: Prefix of the #id thing. Set a string, or true to have it generated. :type id_prefix: str|bool """ if isinstance(id_prefix, bool): if id_prefix: # True if isins...
['def', 'print_peer', '(', 'self', ',', 'peer', ',', 'show_id', '=', 'True', ',', 'id_prefix', '=', '""', ',', 'reply', '=', 'True', ')', ':', 'if', 'isinstance', '(', 'id_prefix', ',', 'bool', ')', ':', 'if', 'id_prefix', ':', '# True', 'if', 'isinstance', '(', 'peer', ',', 'User', ')', ':', 'id_prefix', '=', '"user"'...
:param id_prefix: Prefix of the #id thing. Set a string, or true to have it generated. :type id_prefix: str|bool
[':', 'param', 'id_prefix', ':', 'Prefix', 'of', 'the', '#id', 'thing', '.', 'Set', 'a', 'string', 'or', 'true', 'to', 'have', 'it', 'generated', '.', ':', 'type', 'id_prefix', ':', 'str|bool']
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/examples/cli.py#L580-L601
7,346
saltstack/salt
salt/modules/zonecfg.py
update_resource
def update_resource(zone, resource_type, resource_selector, **kwargs): ''' Add a resource zone : string name of zone resource_type : string type of resource resource_selector : string unique resource identifier kwargs : string|int|... resource properties .. ...
python
def update_resource(zone, resource_type, resource_selector, **kwargs): ''' Add a resource zone : string name of zone resource_type : string type of resource resource_selector : string unique resource identifier kwargs : string|int|... resource properties .. ...
['def', 'update_resource', '(', 'zone', ',', 'resource_type', ',', 'resource_selector', ',', '*', '*', 'kwargs', ')', ':', 'return', '_resource', '(', "'update'", ',', 'zone', ',', 'resource_type', ',', 'resource_selector', ',', '*', '*', 'kwargs', ')']
Add a resource zone : string name of zone resource_type : string type of resource resource_selector : string unique resource identifier kwargs : string|int|... resource properties .. note:: Set resource_selector to None for resource that do not require one. ...
['Add', 'a', 'resource']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L593-L615
7,347
merll/docker-map
dockermap/map/action/script.py
ScriptActionGenerator.get_state_actions
def get_state_actions(self, state, **kwargs): """ For dependent items, inherits the behavior from :class:`dockermap.map.action.resume.ResumeActionGenerator`. For other the main container, checks if containers exist, and depending on the ``remove_existing_before`` option either fails or r...
python
def get_state_actions(self, state, **kwargs): """ For dependent items, inherits the behavior from :class:`dockermap.map.action.resume.ResumeActionGenerator`. For other the main container, checks if containers exist, and depending on the ``remove_existing_before`` option either fails or r...
['def', 'get_state_actions', '(', 'self', ',', 'state', ',', '*', '*', 'kwargs', ')', ':', 'if', 'state', '.', 'config_flags', '&', 'ConfigFlags', '.', 'DEPENDENT', 'or', 'state', '.', 'config_id', '.', 'config_type', '!=', 'ItemType', '.', 'CONTAINER', ':', 'return', 'super', '(', 'ScriptActionGenerator', ',', 'self',...
For dependent items, inherits the behavior from :class:`dockermap.map.action.resume.ResumeActionGenerator`. For other the main container, checks if containers exist, and depending on the ``remove_existing_before`` option either fails or removes them. Otherwise runs the script. :param state: Con...
['For', 'dependent', 'items', 'inherits', 'the', 'behavior', 'from', ':', 'class', ':', 'dockermap', '.', 'map', '.', 'action', '.', 'resume', '.', 'ResumeActionGenerator', '.', 'For', 'other', 'the', 'main', 'container', 'checks', 'if', 'containers', 'exist', 'and', 'depending', 'on', 'the', 'remove_existing_before', ...
train
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/action/script.py#L21-L58
7,348
cloudsmith-io/cloudsmith-cli
cloudsmith_cli/cli/commands/copy.py
copy
def copy( ctx, opts, owner_repo_package, destination, skip_errors, wait_interval, no_wait_for_sync, sync_attempts, ): """ Copy a package to another repository. This requires appropriate permissions for both the source repository/package and the destination repository. ...
python
def copy( ctx, opts, owner_repo_package, destination, skip_errors, wait_interval, no_wait_for_sync, sync_attempts, ): """ Copy a package to another repository. This requires appropriate permissions for both the source repository/package and the destination repository. ...
['def', 'copy', '(', 'ctx', ',', 'opts', ',', 'owner_repo_package', ',', 'destination', ',', 'skip_errors', ',', 'wait_interval', ',', 'no_wait_for_sync', ',', 'sync_attempts', ',', ')', ':', 'owner', ',', 'source', ',', 'slug', '=', 'owner_repo_package', 'click', '.', 'echo', '(', '"Copying %(slug)s package from %(sou...
Copy a package to another repository. This requires appropriate permissions for both the source repository/package and the destination repository. - OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), the REPO name where the package is stored, and the PACKAGE name (slug) of the pac...
['Copy', 'a', 'package', 'to', 'another', 'repository', '.']
train
https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/copy.py#L28-L94
7,349
lemieuxl/pyGenClean
pyGenClean/RelatedSamples/find_related_samples.py
checkArgs
def checkArgs(args): """Checks the arguments and options. :param args: an object containing the options of the program. :type args: argparse.Namespace :returns: ``True`` if everything was OK. If there is a problem with an option, an exception is raised using the :py:class:`ProgramError` clas...
python
def checkArgs(args): """Checks the arguments and options. :param args: an object containing the options of the program. :type args: argparse.Namespace :returns: ``True`` if everything was OK. If there is a problem with an option, an exception is raised using the :py:class:`ProgramError` clas...
['def', 'checkArgs', '(', 'args', ')', ':', '# Check if we have the tped and the tfam files', 'for', 'fileName', 'in', '[', 'args', '.', 'bfile', '+', 'i', 'for', 'i', 'in', '[', '".bed"', ',', '".bim"', ',', '".fam"', ']', ']', ':', 'if', 'not', 'os', '.', 'path', '.', 'isfile', '(', 'fileName', ')', ':', 'msg', '=', ...
Checks the arguments and options. :param args: an object containing the options of the program. :type args: argparse.Namespace :returns: ``True`` if everything was OK. If there is a problem with an option, an exception is raised using the :py:class:`ProgramError` class, a message is printed to t...
['Checks', 'the', 'arguments', 'and', 'options', '.']
train
https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/RelatedSamples/find_related_samples.py#L783-L835
7,350
EpistasisLab/tpot
tpot/builtins/one_hot_encoder.py
OneHotEncoder._transform
def _transform(self, X): """Asssume X contains only categorical features. Parameters ---------- X : array-like or sparse matrix, shape=(n_samples, n_features) Dense array or sparse matrix. """ X = self._matrix_adjust(X) X = check_array(X, accept_spar...
python
def _transform(self, X): """Asssume X contains only categorical features. Parameters ---------- X : array-like or sparse matrix, shape=(n_samples, n_features) Dense array or sparse matrix. """ X = self._matrix_adjust(X) X = check_array(X, accept_spar...
['def', '_transform', '(', 'self', ',', 'X', ')', ':', 'X', '=', 'self', '.', '_matrix_adjust', '(', 'X', ')', 'X', '=', 'check_array', '(', 'X', ',', 'accept_sparse', '=', "'csc'", ',', 'force_all_finite', '=', 'False', ',', 'dtype', '=', 'int', ')', 'if', 'X', '.', 'min', '(', ')', '<', '0', ':', 'raise', 'ValueError...
Asssume X contains only categorical features. Parameters ---------- X : array-like or sparse matrix, shape=(n_samples, n_features) Dense array or sparse matrix.
['Asssume', 'X', 'contains', 'only', 'categorical', 'features', '.']
train
https://github.com/EpistasisLab/tpot/blob/b626271e6b5896a73fb9d7d29bebc7aa9100772e/tpot/builtins/one_hot_encoder.py#L399-L479
7,351
kytos/python-openflow
pyof/foundation/network_types.py
Ethernet.unpack
def unpack(self, buff, offset=0): """Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Ethernet headers may have VLAN tags. If no VLAN tag is found, a 'wildcard VLAN tag' is inserted to ...
python
def unpack(self, buff, offset=0): """Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Ethernet headers may have VLAN tags. If no VLAN tag is found, a 'wildcard VLAN tag' is inserted to ...
['def', 'unpack', '(', 'self', ',', 'buff', ',', 'offset', '=', '0', ')', ':', 'begin', '=', 'offset', 'vlan_length', '=', 'self', '.', '_get_vlan_length', '(', 'buff', ')', 'for', 'attribute_name', ',', 'class_attribute', 'in', 'self', '.', 'get_class_attributes', '(', ')', ':', 'attribute', '=', 'deepcopy', '(', 'cla...
Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Ethernet headers may have VLAN tags. If no VLAN tag is found, a 'wildcard VLAN tag' is inserted to assure correct unpacking. Args: ...
['Unpack', 'a', 'binary', 'message', 'into', 'this', 'object', 's', 'attributes', '.']
train
https://github.com/kytos/python-openflow/blob/4f2d0d08ab28e102ed88fe57a4ee17729f1e1bb7/pyof/foundation/network_types.py#L306-L334
7,352
DBuildService/dockerfile-parse
dockerfile_parse/parser.py
DockerfileParser._instruction_getter
def _instruction_getter(self, name, env_replace): """ Get LABEL or ENV instructions with environment replacement :param name: e.g. 'LABEL' or 'ENV' :param env_replace: bool, whether to perform ENV substitution :return: Labels instance or Envs instance """ if name...
python
def _instruction_getter(self, name, env_replace): """ Get LABEL or ENV instructions with environment replacement :param name: e.g. 'LABEL' or 'ENV' :param env_replace: bool, whether to perform ENV substitution :return: Labels instance or Envs instance """ if name...
['def', '_instruction_getter', '(', 'self', ',', 'name', ',', 'env_replace', ')', ':', 'if', 'name', '!=', "'LABEL'", 'and', 'name', '!=', "'ENV'", ':', 'raise', 'ValueError', '(', '"Unsupported instruction \'%s\'"', ',', 'name', ')', 'instructions', '=', '{', '}', 'envs', '=', '{', '}', 'for', 'instruction_desc', 'in'...
Get LABEL or ENV instructions with environment replacement :param name: e.g. 'LABEL' or 'ENV' :param env_replace: bool, whether to perform ENV substitution :return: Labels instance or Envs instance
['Get', 'LABEL', 'or', 'ENV', 'instructions', 'with', 'environment', 'replacement']
train
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/parser.py#L391-L422
7,353
tensorflow/tensorboard
tensorboard/plugins/histogram/summary.py
op
def op(name, data, bucket_count=None, display_name=None, description=None, collections=None): """Create a legacy histogram summary op. Arguments: name: A unique name for the generated summary node. data: A `Tensor` of any shape. Must be castable to `float64`. bucket_c...
python
def op(name, data, bucket_count=None, display_name=None, description=None, collections=None): """Create a legacy histogram summary op. Arguments: name: A unique name for the generated summary node. data: A `Tensor` of any shape. Must be castable to `float64`. bucket_c...
['def', 'op', '(', 'name', ',', 'data', ',', 'bucket_count', '=', 'None', ',', 'display_name', '=', 'None', ',', 'description', '=', 'None', ',', 'collections', '=', 'None', ')', ':', '# TODO(nickfelt): remove on-demand imports once dep situation is fixed.', 'import', 'tensorflow', '.', 'compat', '.', 'v1', 'as', 'tf',...
Create a legacy histogram summary op. Arguments: name: A unique name for the generated summary node. data: A `Tensor` of any shape. Must be castable to `float64`. bucket_count: Optional positive `int`. The output will have this many buckets, except in two edge cases. If there is no data, then ...
['Create', 'a', 'legacy', 'histogram', 'summary', 'op', '.']
train
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/histogram/summary.py#L105-L144
7,354
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py
to_deeper_graph
def to_deeper_graph(graph): ''' deeper graph ''' weighted_layer_ids = graph.deep_layer_ids() if len(weighted_layer_ids) >= Constant.MAX_LAYERS: return None deeper_layer_ids = sample(weighted_layer_ids, 1) for layer_id in deeper_layer_ids: layer = graph.layer_list[layer_id] ...
python
def to_deeper_graph(graph): ''' deeper graph ''' weighted_layer_ids = graph.deep_layer_ids() if len(weighted_layer_ids) >= Constant.MAX_LAYERS: return None deeper_layer_ids = sample(weighted_layer_ids, 1) for layer_id in deeper_layer_ids: layer = graph.layer_list[layer_id] ...
['def', 'to_deeper_graph', '(', 'graph', ')', ':', 'weighted_layer_ids', '=', 'graph', '.', 'deep_layer_ids', '(', ')', 'if', 'len', '(', 'weighted_layer_ids', ')', '>=', 'Constant', '.', 'MAX_LAYERS', ':', 'return', 'None', 'deeper_layer_ids', '=', 'sample', '(', 'weighted_layer_ids', ',', '1', ')', 'for', 'layer_id',...
deeper graph
['deeper', 'graph']
train
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/graph_transformer.py#L127-L141
7,355
IdentityPython/pysaml2
src/saml2/attribute_converter.py
AttributeConverter.to_
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in attrvals.items(): name = self._to.get(key.lower()) ...
python
def to_(self, attrvals): """ Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances """ attributes = [] for key, value in attrvals.items(): name = self._to.get(key.lower()) ...
['def', 'to_', '(', 'self', ',', 'attrvals', ')', ':', 'attributes', '=', '[', ']', 'for', 'key', ',', 'value', 'in', 'attrvals', '.', 'items', '(', ')', ':', 'name', '=', 'self', '.', '_to', '.', 'get', '(', 'key', '.', 'lower', '(', ')', ')', 'if', 'name', ':', 'if', 'name', '==', '"urn:oid:1.3.6.1.4.1.5923.1.1.1.10"...
Create a list of Attribute instances. :param attrvals: A dictionary of attributes and values :return: A list of Attribute instances
['Create', 'a', 'list', 'of', 'Attribute', 'instances', '.']
train
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/attribute_converter.py#L423-L453
7,356
minhhoit/yacms
yacms/blog/management/base.py
BaseImporterCommand.add_page
def add_page(self, title=None, content=None, old_url=None, tags=None, old_id=None, old_parent_id=None): """ Adds a page to the list of pages to be imported - used by the Wordpress importer. """ if not title: text = decode_entities(strip_tags(content))...
python
def add_page(self, title=None, content=None, old_url=None, tags=None, old_id=None, old_parent_id=None): """ Adds a page to the list of pages to be imported - used by the Wordpress importer. """ if not title: text = decode_entities(strip_tags(content))...
['def', 'add_page', '(', 'self', ',', 'title', '=', 'None', ',', 'content', '=', 'None', ',', 'old_url', '=', 'None', ',', 'tags', '=', 'None', ',', 'old_id', '=', 'None', ',', 'old_parent_id', '=', 'None', ')', ':', 'if', 'not', 'title', ':', 'text', '=', 'decode_entities', '(', 'strip_tags', '(', 'content', ')', ')',...
Adds a page to the list of pages to be imported - used by the Wordpress importer.
['Adds', 'a', 'page', 'to', 'the', 'list', 'of', 'pages', 'to', 'be', 'imported', '-', 'used', 'by', 'the', 'Wordpress', 'importer', '.']
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/base.py#L86-L104
7,357
skorokithakis/shortuuid
shortuuid/main.py
ShortUUID.set_alphabet
def set_alphabet(self, alphabet): """Set the alphabet to be used for new UUIDs.""" # Turn the alphabet into a set and sort it to prevent duplicates # and ensure reproducibility. new_alphabet = list(sorted(set(alphabet))) if len(new_alphabet) > 1: self._alphabet = new...
python
def set_alphabet(self, alphabet): """Set the alphabet to be used for new UUIDs.""" # Turn the alphabet into a set and sort it to prevent duplicates # and ensure reproducibility. new_alphabet = list(sorted(set(alphabet))) if len(new_alphabet) > 1: self._alphabet = new...
['def', 'set_alphabet', '(', 'self', ',', 'alphabet', ')', ':', '# Turn the alphabet into a set and sort it to prevent duplicates', '# and ensure reproducibility.', 'new_alphabet', '=', 'list', '(', 'sorted', '(', 'set', '(', 'alphabet', ')', ')', ')', 'if', 'len', '(', 'new_alphabet', ')', '>', '1', ':', 'self', '.', ...
Set the alphabet to be used for new UUIDs.
['Set', 'the', 'alphabet', 'to', 'be', 'used', 'for', 'new', 'UUIDs', '.']
train
https://github.com/skorokithakis/shortuuid/blob/4da632a986c3a43f75c7df64f27a90bbf7ff8039/shortuuid/main.py#L111-L121
7,358
martinpitt/python-dbusmock
dbusmock/templates/ofono.py
add_simmanager_api
def add_simmanager_api(self, mock): '''Add org.ofono.SimManager API to a mock''' iface = 'org.ofono.SimManager' mock.AddProperties(iface, { 'BarredDialing': _parameters.get('BarredDialing', False), 'CardIdentifier': _parameters.get('CardIdentifier', new_iccid(self)), 'FixedDialing':...
python
def add_simmanager_api(self, mock): '''Add org.ofono.SimManager API to a mock''' iface = 'org.ofono.SimManager' mock.AddProperties(iface, { 'BarredDialing': _parameters.get('BarredDialing', False), 'CardIdentifier': _parameters.get('CardIdentifier', new_iccid(self)), 'FixedDialing':...
['def', 'add_simmanager_api', '(', 'self', ',', 'mock', ')', ':', 'iface', '=', "'org.ofono.SimManager'", 'mock', '.', 'AddProperties', '(', 'iface', ',', '{', "'BarredDialing'", ':', '_parameters', '.', 'get', '(', "'BarredDialing'", ',', 'False', ')', ',', "'CardIdentifier'", ':', '_parameters', '.', 'get', '(', "'Ca...
Add org.ofono.SimManager API to a mock
['Add', 'org', '.', 'ofono', '.', 'SimManager', 'API', 'to', 'a', 'mock']
train
https://github.com/martinpitt/python-dbusmock/blob/26f65f78bc0ed347233f699a8d6ee0e6880e7eb0/dbusmock/templates/ofono.py#L329-L388
7,359
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/interactive.py
ConsoleDebugger.do_search
def do_search(self, arg): """ [~process] s [address-address] <search string> [~process] search [address-address] <search string> """ token_list = self.split_tokens(arg, 1, 3) pid, tid = self.get_process_and_thread_ids_from_prefix() process = self.get_process(...
python
def do_search(self, arg): """ [~process] s [address-address] <search string> [~process] search [address-address] <search string> """ token_list = self.split_tokens(arg, 1, 3) pid, tid = self.get_process_and_thread_ids_from_prefix() process = self.get_process(...
['def', 'do_search', '(', 'self', ',', 'arg', ')', ':', 'token_list', '=', 'self', '.', 'split_tokens', '(', 'arg', ',', '1', ',', '3', ')', 'pid', ',', 'tid', '=', 'self', '.', 'get_process_and_thread_ids_from_prefix', '(', ')', 'process', '=', 'self', '.', 'get_process', '(', 'pid', ')', 'if', 'len', '(', 'token_list...
[~process] s [address-address] <search string> [~process] search [address-address] <search string>
['[', '~process', ']', 's', '[', 'address', '-', 'address', ']', '<search', 'string', '>', '[', '~process', ']', 'search', '[', 'address', '-', 'address', ']', '<search', 'string', '>']
train
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/interactive.py#L1854-L1878
7,360
getpelican/pelican-plugins
filetime_from_git/content_adapter.py
GitContentAdapter.get_newest_commit_date
def get_newest_commit_date(self): ''' Get datetime of newest commit involving this file :returns: Datetime of newest commit ''' newest_commit = self.get_newest_commit() return self.git.get_commit_date(newest_commit, self.tz_name)
python
def get_newest_commit_date(self): ''' Get datetime of newest commit involving this file :returns: Datetime of newest commit ''' newest_commit = self.get_newest_commit() return self.git.get_commit_date(newest_commit, self.tz_name)
['def', 'get_newest_commit_date', '(', 'self', ')', ':', 'newest_commit', '=', 'self', '.', 'get_newest_commit', '(', ')', 'return', 'self', '.', 'git', '.', 'get_commit_date', '(', 'newest_commit', ',', 'self', '.', 'tz_name', ')']
Get datetime of newest commit involving this file :returns: Datetime of newest commit
['Get', 'datetime', 'of', 'newest', 'commit', 'involving', 'this', 'file']
train
https://github.com/getpelican/pelican-plugins/blob/cfc7a3f224f1743063b034561f89a6a712d13587/filetime_from_git/content_adapter.py#L92-L99
7,361
openstack/hacking
hacking/checks/python23.py
hacking_python3x_print_function
def hacking_python3x_print_function(logical_line, noqa): r"""Check that all print occurrences look like print functions. Check that all occurrences of print look like functions, not print operator. As of Python 3.x, the print operator has been removed. Okay: print(msg) Okay: print (msg) O...
python
def hacking_python3x_print_function(logical_line, noqa): r"""Check that all print occurrences look like print functions. Check that all occurrences of print look like functions, not print operator. As of Python 3.x, the print operator has been removed. Okay: print(msg) Okay: print (msg) O...
['def', 'hacking_python3x_print_function', '(', 'logical_line', ',', 'noqa', ')', ':', 'if', 'noqa', ':', 'return', 'for', 'match', 'in', 'RE_PRINT', '.', 'finditer', '(', 'logical_line', ')', ':', 'yield', 'match', '.', 'start', '(', '0', ')', ',', '(', '"H233: Python 3.x incompatible use of print operator"', ')']
r"""Check that all print occurrences look like print functions. Check that all occurrences of print look like functions, not print operator. As of Python 3.x, the print operator has been removed. Okay: print(msg) Okay: print (msg) Okay: print msg # noqa Okay: print() H233: print msg ...
['r', 'Check', 'that', 'all', 'print', 'occurrences', 'look', 'like', 'print', 'functions', '.']
train
https://github.com/openstack/hacking/blob/10e58f907181cac91d3b2af422c2458b04a1ec79/hacking/checks/python23.py#L81-L102
7,362
lemieuxl/pyGenClean
pyGenClean/SampleMissingness/sample_missingness.py
runPlink
def runPlink(options): """Run Plink with the ``mind`` option. :param options: the options. :type options: argparse.Namespace """ # The plink command plinkCommand = [ "plink", "--noweb", "--bfile" if options.is_bfile else "--tfile", options.ifile, "--min...
python
def runPlink(options): """Run Plink with the ``mind`` option. :param options: the options. :type options: argparse.Namespace """ # The plink command plinkCommand = [ "plink", "--noweb", "--bfile" if options.is_bfile else "--tfile", options.ifile, "--min...
['def', 'runPlink', '(', 'options', ')', ':', '# The plink command', 'plinkCommand', '=', '[', '"plink"', ',', '"--noweb"', ',', '"--bfile"', 'if', 'options', '.', 'is_bfile', 'else', '"--tfile"', ',', 'options', '.', 'ifile', ',', '"--mind"', ',', 'str', '(', 'options', '.', 'mind', ')', ',', '"--make-bed"', ',', '"--...
Run Plink with the ``mind`` option. :param options: the options. :type options: argparse.Namespace
['Run', 'Plink', 'with', 'the', 'mind', 'option', '.']
train
https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SampleMissingness/sample_missingness.py#L56-L83
7,363
mitsei/dlkit
dlkit/json_/repository/sessions.py
RepositoryHierarchySession.get_child_repository_ids
def get_child_repository_ids(self, repository_id): """Gets the ``Ids`` of the children of the given repository. arg: repository_id (osid.id.Id): the ``Id`` to query return: (osid.id.IdList) - the children of the repository raise: NotFound - ``repository_id`` not found raise:...
python
def get_child_repository_ids(self, repository_id): """Gets the ``Ids`` of the children of the given repository. arg: repository_id (osid.id.Id): the ``Id`` to query return: (osid.id.IdList) - the children of the repository raise: NotFound - ``repository_id`` not found raise:...
['def', 'get_child_repository_ids', '(', 'self', ',', 'repository_id', ')', ':', '# Implemented from template for', '# osid.resource.BinHierarchySession.get_child_bin_ids', 'if', 'self', '.', '_catalog_session', 'is', 'not', 'None', ':', 'return', 'self', '.', '_catalog_session', '.', 'get_child_catalog_ids', '(', 'cat...
Gets the ``Ids`` of the children of the given repository. arg: repository_id (osid.id.Id): the ``Id`` to query return: (osid.id.IdList) - the children of the repository raise: NotFound - ``repository_id`` not found raise: NullArgument - ``repository_id`` is ``null`` raise: ...
['Gets', 'the', 'Ids', 'of', 'the', 'children', 'of', 'the', 'given', 'repository', '.']
train
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L5623-L5639
7,364
michael-lazar/rtv
rtv/packages/praw/__init__.py
Config.ua_string
def ua_string(praw_info): """Return the user-agent string. The user-agent string contains PRAW version and platform version info. """ if os.environ.get('SERVER_SOFTWARE') is not None: # Google App Engine information # https://developers.google.com/appengine/docs...
python
def ua_string(praw_info): """Return the user-agent string. The user-agent string contains PRAW version and platform version info. """ if os.environ.get('SERVER_SOFTWARE') is not None: # Google App Engine information # https://developers.google.com/appengine/docs...
['def', 'ua_string', '(', 'praw_info', ')', ':', 'if', 'os', '.', 'environ', '.', 'get', '(', "'SERVER_SOFTWARE'", ')', 'is', 'not', 'None', ':', '# Google App Engine information', '# https://developers.google.com/appengine/docs/python/', 'info', '=', 'os', '.', 'environ', '.', 'get', '(', "'SERVER_SOFTWARE'", ')', 'el...
Return the user-agent string. The user-agent string contains PRAW version and platform version info.
['Return', 'the', 'user', '-', 'agent', 'string', '.']
train
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L197-L212
7,365
klen/peewee_migrate
peewee_migrate/migrator.py
SchemaMigrator.from_database
def from_database(cls, database): """Initialize migrator by db.""" if isinstance(database, PostgresqlDatabase): return PostgresqlMigrator(database) if isinstance(database, SqliteDatabase): return SqliteMigrator(database) if isinstance(database, MySQLDatabase): ...
python
def from_database(cls, database): """Initialize migrator by db.""" if isinstance(database, PostgresqlDatabase): return PostgresqlMigrator(database) if isinstance(database, SqliteDatabase): return SqliteMigrator(database) if isinstance(database, MySQLDatabase): ...
['def', 'from_database', '(', 'cls', ',', 'database', ')', ':', 'if', 'isinstance', '(', 'database', ',', 'PostgresqlDatabase', ')', ':', 'return', 'PostgresqlMigrator', '(', 'database', ')', 'if', 'isinstance', '(', 'database', ',', 'SqliteDatabase', ')', ':', 'return', 'SqliteMigrator', '(', 'database', ')', 'if', 'i...
Initialize migrator by db.
['Initialize', 'migrator', 'by', 'db', '.']
train
https://github.com/klen/peewee_migrate/blob/b77895ab1c9be3121bc127e0c2dfb047eed8b24c/peewee_migrate/migrator.py#L20-L28
7,366
fhcrc/taxtastic
taxtastic/utils.py
getlines
def getlines(fname): """ Returns iterator of whitespace-stripped lines in file, omitting blank lines, lines beginning with '#', and line contents following the first '#' character. """ with open(fname, 'rU') as f: for line in f: if line.strip() and not line.startswith('#'): ...
python
def getlines(fname): """ Returns iterator of whitespace-stripped lines in file, omitting blank lines, lines beginning with '#', and line contents following the first '#' character. """ with open(fname, 'rU') as f: for line in f: if line.strip() and not line.startswith('#'): ...
['def', 'getlines', '(', 'fname', ')', ':', 'with', 'open', '(', 'fname', ',', "'rU'", ')', 'as', 'f', ':', 'for', 'line', 'in', 'f', ':', 'if', 'line', '.', 'strip', '(', ')', 'and', 'not', 'line', '.', 'startswith', '(', "'#'", ')', ':', 'yield', 'line', '.', 'split', '(', "'#'", ',', '1', ')', '[', '0', ']', '.', 's...
Returns iterator of whitespace-stripped lines in file, omitting blank lines, lines beginning with '#', and line contents following the first '#' character.
['Returns', 'iterator', 'of', 'whitespace', '-', 'stripped', 'lines', 'in', 'file', 'omitting', 'blank', 'lines', 'lines', 'beginning', 'with', '#', 'and', 'line', 'contents', 'following', 'the', 'first', '#', 'character', '.']
train
https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/utils.py#L51-L61
7,367
NoneGG/aredis
aredis/commands/hyperlog.py
ClusterHyperLogCommandMixin.pfmerge
async def pfmerge(self, dest, *sources): """ Merge N different HyperLogLogs into a single one. Cluster impl: Very special implementation is required to make pfmerge() work But it works :] It works by first fetching all HLL objects that should be merged and ...
python
async def pfmerge(self, dest, *sources): """ Merge N different HyperLogLogs into a single one. Cluster impl: Very special implementation is required to make pfmerge() work But it works :] It works by first fetching all HLL objects that should be merged and ...
['async', 'def', 'pfmerge', '(', 'self', ',', 'dest', ',', '*', 'sources', ')', ':', 'all_k', '=', '[', ']', '# Fetch all HLL objects via GET and store them client side as strings', 'all_hll_objects', '=', 'list', '(', ')', 'for', 'hll_key', 'in', 'sources', ':', 'all_hll_objects', '.', 'append', '(', 'await', 'self', ...
Merge N different HyperLogLogs into a single one. Cluster impl: Very special implementation is required to make pfmerge() work But it works :] It works by first fetching all HLL objects that should be merged and move them to one hashslot so that pfmerge operation...
['Merge', 'N', 'different', 'HyperLogLogs', 'into', 'a', 'single', 'one', '.']
train
https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/commands/hyperlog.py#L35-L87
7,368
saltstack/salt
salt/modules/inspectlib/fsdb.py
CsvDB.list_tables
def list_tables(self): ''' Load existing tables and their descriptions. :return: ''' if not self._tables: for table_name in os.listdir(self.db_path): self._tables[table_name] = self._load_table(table_name) return self._tables.keys()
python
def list_tables(self): ''' Load existing tables and their descriptions. :return: ''' if not self._tables: for table_name in os.listdir(self.db_path): self._tables[table_name] = self._load_table(table_name) return self._tables.keys()
['def', 'list_tables', '(', 'self', ')', ':', 'if', 'not', 'self', '.', '_tables', ':', 'for', 'table_name', 'in', 'os', '.', 'listdir', '(', 'self', '.', 'db_path', ')', ':', 'self', '.', '_tables', '[', 'table_name', ']', '=', 'self', '.', '_load_table', '(', 'table_name', ')', 'return', 'self', '.', '_tables', '.', ...
Load existing tables and their descriptions. :return:
['Load', 'existing', 'tables', 'and', 'their', 'descriptions', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L126-L136
7,369
KelSolaar/Foundations
foundations/nodes.py
AbstractNode.get_attributes
def get_attributes(self): """ Returns the Node attributes. Usage:: >>> node_a = AbstractNode("MyNodeA", attributeA=Attribute(value="A"), attributeB=Attribute(value="B")) >>> node_a.get_attributes() [<Attribute object at 0x7fa471d3b5e0>, <Attribute object at ...
python
def get_attributes(self): """ Returns the Node attributes. Usage:: >>> node_a = AbstractNode("MyNodeA", attributeA=Attribute(value="A"), attributeB=Attribute(value="B")) >>> node_a.get_attributes() [<Attribute object at 0x7fa471d3b5e0>, <Attribute object at ...
['def', 'get_attributes', '(', 'self', ')', ':', 'return', '[', 'attribute', 'for', 'attribute', 'in', 'self', '.', 'itervalues', '(', ')', 'if', 'issubclass', '(', 'attribute', '.', '__class__', ',', 'Attribute', ')', ']']
Returns the Node attributes. Usage:: >>> node_a = AbstractNode("MyNodeA", attributeA=Attribute(value="A"), attributeB=Attribute(value="B")) >>> node_a.get_attributes() [<Attribute object at 0x7fa471d3b5e0>, <Attribute object at 0x101e6c4a0>] :return: Attributes. ...
['Returns', 'the', 'Node', 'attributes', '.']
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/nodes.py#L452-L466
7,370
geophysics-ubonn/reda
lib/reda/utils/pseudo_positions.py
get_xy_simple_dipole_dipole
def get_xy_simple_dipole_dipole(dataframe, spacing=1, indices=None): """For each configuration indicated by the numerical index array, compute (x,z) pseudo locations based on the paper from XX. All positions are computed for indices=None. """ if indices is None: indices = slice(None) ab...
python
def get_xy_simple_dipole_dipole(dataframe, spacing=1, indices=None): """For each configuration indicated by the numerical index array, compute (x,z) pseudo locations based on the paper from XX. All positions are computed for indices=None. """ if indices is None: indices = slice(None) ab...
['def', 'get_xy_simple_dipole_dipole', '(', 'dataframe', ',', 'spacing', '=', '1', ',', 'indices', '=', 'None', ')', ':', 'if', 'indices', 'is', 'None', ':', 'indices', '=', 'slice', '(', 'None', ')', 'abmn', '=', 'dataframe', '.', 'ix', '[', 'indices', ',', '[', "'a'", ',', "'b'", ',', "'m'", ',', "'n'", ']', ']', '.'...
For each configuration indicated by the numerical index array, compute (x,z) pseudo locations based on the paper from XX. All positions are computed for indices=None.
['For', 'each', 'configuration', 'indicated', 'by', 'the', 'numerical', 'index', 'array', 'compute', '(', 'x', 'z', ')', 'pseudo', 'locations', 'based', 'on', 'the', 'paper', 'from', 'XX', '.']
train
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/pseudo_positions.py#L7-L26
7,371
ioos/compliance-checker
compliance_checker/suite.py
CheckSuite.load_all_available_checkers
def load_all_available_checkers(cls): """ Helper method to retrieve all sub checker classes derived from various base classes. """ for x in working_set.iter_entry_points('compliance_checker.suites'): try: xl = x.resolve() cls.checkers['...
python
def load_all_available_checkers(cls): """ Helper method to retrieve all sub checker classes derived from various base classes. """ for x in working_set.iter_entry_points('compliance_checker.suites'): try: xl = x.resolve() cls.checkers['...
['def', 'load_all_available_checkers', '(', 'cls', ')', ':', 'for', 'x', 'in', 'working_set', '.', 'iter_entry_points', '(', "'compliance_checker.suites'", ')', ':', 'try', ':', 'xl', '=', 'x', '.', 'resolve', '(', ')', 'cls', '.', 'checkers', '[', "':'", '.', 'join', '(', '(', 'xl', '.', '_cc_spec', ',', 'xl', '.', '_...
Helper method to retrieve all sub checker classes derived from various base classes.
['Helper', 'method', 'to', 'retrieve', 'all', 'sub', 'checker', 'classes', 'derived', 'from', 'various', 'base', 'classes', '.']
train
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/suite.py#L81-L116
7,372
ibis-project/ibis
ibis/expr/api.py
geo_point_n
def geo_point_n(arg, n): """Return the Nth point in a single linestring in the geometry. Negative values are counted backwards from the end of the LineString, so that -1 is the last point. Returns NULL if there is no linestring in the geometry Parameters ---------- arg : geometry n : in...
python
def geo_point_n(arg, n): """Return the Nth point in a single linestring in the geometry. Negative values are counted backwards from the end of the LineString, so that -1 is the last point. Returns NULL if there is no linestring in the geometry Parameters ---------- arg : geometry n : in...
['def', 'geo_point_n', '(', 'arg', ',', 'n', ')', ':', 'op', '=', 'ops', '.', 'GeoPointN', '(', 'arg', ',', 'n', ')', 'return', 'op', '.', 'to_expr', '(', ')']
Return the Nth point in a single linestring in the geometry. Negative values are counted backwards from the end of the LineString, so that -1 is the last point. Returns NULL if there is no linestring in the geometry Parameters ---------- arg : geometry n : integer Returns ------- ...
['Return', 'the', 'Nth', 'point', 'in', 'a', 'single', 'linestring', 'in', 'the', 'geometry', '.', 'Negative', 'values', 'are', 'counted', 'backwards', 'from', 'the', 'end', 'of', 'the', 'LineString', 'so', 'that', '-', '1', 'is', 'the', 'last', 'point', '.', 'Returns', 'NULL', 'if', 'there', 'is', 'no', 'linestring', ...
train
https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/expr/api.py#L1802-L1818
7,373
thespacedoctor/qubits
qubits/datagenerator.py
extract_spectra_from_file
def extract_spectra_from_file( log, pathToSpectrum, convertLumToFlux=False): """ *Given a spectrum file this function shall convert the two columns (wavelength and luminosity) to a wavelegnth (wavelengthArray) and flux (fluxArray) array* **Key Arguments:** - ``log`` -- logge...
python
def extract_spectra_from_file( log, pathToSpectrum, convertLumToFlux=False): """ *Given a spectrum file this function shall convert the two columns (wavelength and luminosity) to a wavelegnth (wavelengthArray) and flux (fluxArray) array* **Key Arguments:** - ``log`` -- logge...
['def', 'extract_spectra_from_file', '(', 'log', ',', 'pathToSpectrum', ',', 'convertLumToFlux', '=', 'False', ')', ':', '################ > IMPORTS ################', '## STANDARD LIB ##', 'import', 'os', '## THIRD PARTY ##', 'import', 'numpy', 'as', 'np', '## LOCAL APPLICATION ##', 'import', 'dryxPython', '.', 'astro...
*Given a spectrum file this function shall convert the two columns (wavelength and luminosity) to a wavelegnth (wavelengthArray) and flux (fluxArray) array* **Key Arguments:** - ``log`` -- logger - ``pathToSpectrum`` -- absolute path the the spectrum file **Return:** - None
['*', 'Given', 'a', 'spectrum', 'file', 'this', 'function', 'shall', 'convert', 'the', 'two', 'columns', '(', 'wavelength', 'and', 'luminosity', ')', 'to', 'a', 'wavelegnth', '(', 'wavelengthArray', ')', 'and', 'flux', '(', 'fluxArray', ')', 'array', '*']
train
https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L195-L239
7,374
streeter/pelican-gist
pelican_gist/plugin.py
replace_gist_tags
def replace_gist_tags(generator): """Replace gist tags in the article content.""" from jinja2 import Template template = Template(gist_template) should_cache = generator.context.get('GIST_CACHE_ENABLED') cache_location = generator.context.get('GIST_CACHE_LOCATION') pygments_style = generator.co...
python
def replace_gist_tags(generator): """Replace gist tags in the article content.""" from jinja2 import Template template = Template(gist_template) should_cache = generator.context.get('GIST_CACHE_ENABLED') cache_location = generator.context.get('GIST_CACHE_LOCATION') pygments_style = generator.co...
['def', 'replace_gist_tags', '(', 'generator', ')', ':', 'from', 'jinja2', 'import', 'Template', 'template', '=', 'Template', '(', 'gist_template', ')', 'should_cache', '=', 'generator', '.', 'context', '.', 'get', '(', "'GIST_CACHE_ENABLED'", ')', 'cache_location', '=', 'generator', '.', 'context', '.', 'get', '(', "'...
Replace gist tags in the article content.
['Replace', 'gist', 'tags', 'in', 'the', 'article', 'content', '.']
train
https://github.com/streeter/pelican-gist/blob/395e619534b404fb2b94456dc400dc2a8a2f934a/pelican_gist/plugin.py#L103-L153
7,375
diffeo/py-nilsimsa
nilsimsa/deprecated/_deprecated_nilsimsa.py
compare_hexdigests
def compare_hexdigests( digest1, digest2 ): """Compute difference in bits between digest1 and digest2 returns -127 to 128; 128 is the same, -127 is different""" # convert to 32-tuple of unsighed two-byte INTs digest1 = tuple([int(digest1[i:i+2],16) for i in range(0,63,2)]) digest2 = tuple([int(di...
python
def compare_hexdigests( digest1, digest2 ): """Compute difference in bits between digest1 and digest2 returns -127 to 128; 128 is the same, -127 is different""" # convert to 32-tuple of unsighed two-byte INTs digest1 = tuple([int(digest1[i:i+2],16) for i in range(0,63,2)]) digest2 = tuple([int(di...
['def', 'compare_hexdigests', '(', 'digest1', ',', 'digest2', ')', ':', '# convert to 32-tuple of unsighed two-byte INTs', 'digest1', '=', 'tuple', '(', '[', 'int', '(', 'digest1', '[', 'i', ':', 'i', '+', '2', ']', ',', '16', ')', 'for', 'i', 'in', 'range', '(', '0', ',', '63', ',', '2', ')', ']', ')', 'digest2', '=',...
Compute difference in bits between digest1 and digest2 returns -127 to 128; 128 is the same, -127 is different
['Compute', 'difference', 'in', 'bits', 'between', 'digest1', 'and', 'digest2', 'returns', '-', '127', 'to', '128', ';', '128', 'is', 'the', 'same', '-', '127', 'is', 'different']
train
https://github.com/diffeo/py-nilsimsa/blob/c652f4bbfd836f7aebf292dcea676cc925ec315a/nilsimsa/deprecated/_deprecated_nilsimsa.py#L196-L205
7,376
mozilla/elasticutils
elasticutils/contrib/django/tasks.py
index_objects
def index_objects(mapping_type, ids, chunk_size=100, es=None, index=None): """Index documents of a specified mapping type. This allows for asynchronous indexing. If a mapping_type extends Indexable, you can add a ``post_save`` hook for the model that it's based on like this:: @receiver(dbsign...
python
def index_objects(mapping_type, ids, chunk_size=100, es=None, index=None): """Index documents of a specified mapping type. This allows for asynchronous indexing. If a mapping_type extends Indexable, you can add a ``post_save`` hook for the model that it's based on like this:: @receiver(dbsign...
['def', 'index_objects', '(', 'mapping_type', ',', 'ids', ',', 'chunk_size', '=', '100', ',', 'es', '=', 'None', ',', 'index', '=', 'None', ')', ':', 'if', 'settings', '.', 'ES_DISABLED', ':', 'return', 'log', '.', 'debug', '(', "'Indexing objects {0}-{1}. [{2}]'", '.', 'format', '(', 'ids', '[', '0', ']', ',', 'ids', ...
Index documents of a specified mapping type. This allows for asynchronous indexing. If a mapping_type extends Indexable, you can add a ``post_save`` hook for the model that it's based on like this:: @receiver(dbsignals.post_save, sender=MyModel) def update_in_index(sender, instance, **kw)...
['Index', 'documents', 'of', 'a', 'specified', 'mapping', 'type', '.']
train
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/contrib/django/tasks.py#L13-L65
7,377
toomore/grs
grs/best_buy_or_sell.py
BestFourPoint.bias_ratio
def bias_ratio(self, positive_or_negative=False): """ 判斷乖離 :param bool positive_or_negative: 正乖離 為 True,負乖離 為 False """ return self.data.check_moving_average_bias_ratio( self.data.moving_average_bias_ratio(3, 6)[0], posit...
python
def bias_ratio(self, positive_or_negative=False): """ 判斷乖離 :param bool positive_or_negative: 正乖離 為 True,負乖離 為 False """ return self.data.check_moving_average_bias_ratio( self.data.moving_average_bias_ratio(3, 6)[0], posit...
['def', 'bias_ratio', '(', 'self', ',', 'positive_or_negative', '=', 'False', ')', ':', 'return', 'self', '.', 'data', '.', 'check_moving_average_bias_ratio', '(', 'self', '.', 'data', '.', 'moving_average_bias_ratio', '(', '3', ',', '6', ')', '[', '0', ']', ',', 'positive_or_negative', '=', 'positive_or_negative', ')'...
判斷乖離 :param bool positive_or_negative: 正乖離 為 True,負乖離 為 False
['判斷乖離']
train
https://github.com/toomore/grs/blob/a1285cb57878284a886952968be9e31fbfa595dd/grs/best_buy_or_sell.py#L32-L39
7,378
YosaiProject/yosai
yosai/core/authc/authc.py
DefaultAuthenticator.validate_locked
def validate_locked(self, authc_token, failed_attempts): """ :param failed_attempts: the failed attempts for this type of credential """ if self.locking_limit and len(failed_attempts) > self.locking_limit: msg = ('Authentication attempts breached threshold. Account' ...
python
def validate_locked(self, authc_token, failed_attempts): """ :param failed_attempts: the failed attempts for this type of credential """ if self.locking_limit and len(failed_attempts) > self.locking_limit: msg = ('Authentication attempts breached threshold. Account' ...
['def', 'validate_locked', '(', 'self', ',', 'authc_token', ',', 'failed_attempts', ')', ':', 'if', 'self', '.', 'locking_limit', 'and', 'len', '(', 'failed_attempts', ')', '>', 'self', '.', 'locking_limit', ':', 'msg', '=', '(', "'Authentication attempts breached threshold. Account'", "' is now locked for: '", '+', '...
:param failed_attempts: the failed attempts for this type of credential
[':', 'param', 'failed_attempts', ':', 'the', 'failed', 'attempts', 'for', 'this', 'type', 'of', 'credential']
train
https://github.com/YosaiProject/yosai/blob/7f96aa6b837ceae9bf3d7387cd7e35f5ab032575/yosai/core/authc/authc.py#L314-L323
7,379
vanheeringen-lab/gimmemotifs
gimmemotifs/tools.py
MotifSampler.parse_out
def parse_out(self, fo): """ Convert MotifSampler output to motifs Parameters ---------- fo : file-like File object containing MotifSampler output. Returns ------- motifs : list List of Motif instances. """ ...
python
def parse_out(self, fo): """ Convert MotifSampler output to motifs Parameters ---------- fo : file-like File object containing MotifSampler output. Returns ------- motifs : list List of Motif instances. """ ...
['def', 'parse_out', '(', 'self', ',', 'fo', ')', ':', 'motifs', '=', '[', ']', 'nucs', '=', '{', '"A"', ':', '0', ',', '"C"', ':', '1', ',', '"G"', ':', '2', ',', '"T"', ':', '3', '}', 'pseudo', '=', '0.0', '# Should be 1/sqrt(# of seqs)', 'aligns', '=', '{', '}', 'for', 'line', 'in', 'fo', '.', 'readlines', '(', ')',...
Convert MotifSampler output to motifs Parameters ---------- fo : file-like File object containing MotifSampler output. Returns ------- motifs : list List of Motif instances.
['Convert', 'MotifSampler', 'output', 'to', 'motifs', 'Parameters', '----------', 'fo', ':', 'file', '-', 'like', 'File', 'object', 'containing', 'MotifSampler', 'output', '.']
train
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/tools.py#L1301-L1348
7,380
sorgerlab/indra
indra/tools/assemble_corpus.py
run_preassembly_duplicate
def run_preassembly_duplicate(preassembler, beliefengine, **kwargs): """Run deduplication stage of preassembly on a list of statements. Parameters ---------- preassembler : indra.preassembler.Preassembler A Preassembler instance beliefengine : indra.belief.BeliefEngine A BeliefEngin...
python
def run_preassembly_duplicate(preassembler, beliefengine, **kwargs): """Run deduplication stage of preassembly on a list of statements. Parameters ---------- preassembler : indra.preassembler.Preassembler A Preassembler instance beliefengine : indra.belief.BeliefEngine A BeliefEngin...
['def', 'run_preassembly_duplicate', '(', 'preassembler', ',', 'beliefengine', ',', '*', '*', 'kwargs', ')', ':', 'logger', '.', 'info', '(', "'Combining duplicates on %d statements...'", '%', 'len', '(', 'preassembler', '.', 'stmts', ')', ')', 'dump_pkl', '=', 'kwargs', '.', 'get', '(', "'save'", ')', 'stmts_out', '='...
Run deduplication stage of preassembly on a list of statements. Parameters ---------- preassembler : indra.preassembler.Preassembler A Preassembler instance beliefengine : indra.belief.BeliefEngine A BeliefEngine instance. save : Optional[str] The name of a pickle file to sa...
['Run', 'deduplication', 'stage', 'of', 'preassembly', 'on', 'a', 'list', 'of', 'statements', '.']
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/assemble_corpus.py#L401-L426
7,381
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/win32/version.py
_get_arch
def _get_arch(): """ Determines the current processor architecture. @rtype: str @return: On error, returns: - L{ARCH_UNKNOWN} (C{"unknown"}) meaning the architecture could not be detected or is not known to WinAppDbg. On success, returns one of the following values: ...
python
def _get_arch(): """ Determines the current processor architecture. @rtype: str @return: On error, returns: - L{ARCH_UNKNOWN} (C{"unknown"}) meaning the architecture could not be detected or is not known to WinAppDbg. On success, returns one of the following values: ...
['def', '_get_arch', '(', ')', ':', 'try', ':', 'si', '=', 'GetNativeSystemInfo', '(', ')', 'except', 'Exception', ':', 'si', '=', 'GetSystemInfo', '(', ')', 'try', ':', 'return', '_arch_map', '[', 'si', '.', 'id', '.', 'w', '.', 'wProcessorArchitecture', ']', 'except', 'KeyError', ':', 'return', 'ARCH_UNKNOWN']
Determines the current processor architecture. @rtype: str @return: On error, returns: - L{ARCH_UNKNOWN} (C{"unknown"}) meaning the architecture could not be detected or is not known to WinAppDbg. On success, returns one of the following values: - L{ARCH_I386} (C{"i386"}) f...
['Determines', 'the', 'current', 'processor', 'architecture', '.']
train
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/win32/version.py#L675-L716
7,382
yyuu/botornado
boto/mturk/connection.py
MTurkConnection.get_qualification_score
def get_qualification_score(self, qualification_type_id, worker_id): """TODO: Document.""" params = {'QualificationTypeId' : qualification_type_id, 'SubjectId' : worker_id} return self._process_request('GetQualificationScore', params, [('Qualification', Qual...
python
def get_qualification_score(self, qualification_type_id, worker_id): """TODO: Document.""" params = {'QualificationTypeId' : qualification_type_id, 'SubjectId' : worker_id} return self._process_request('GetQualificationScore', params, [('Qualification', Qual...
['def', 'get_qualification_score', '(', 'self', ',', 'qualification_type_id', ',', 'worker_id', ')', ':', 'params', '=', '{', "'QualificationTypeId'", ':', 'qualification_type_id', ',', "'SubjectId'", ':', 'worker_id', '}', 'return', 'self', '.', '_process_request', '(', "'GetQualificationScore'", ',', 'params', ',', '...
TODO: Document.
['TODO', ':', 'Document', '.']
train
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/mturk/connection.py#L712-L717
7,383
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
Environment.fix_lockfile
def fix_lockfile(self): """Run each line of outfile through fix_pin""" with open(self.outfile, 'rt') as fp: lines = [ self.fix_pin(line) for line in self.concatenated(fp) ] with open(self.outfile, 'wt') as fp: fp.writelines([ ...
python
def fix_lockfile(self): """Run each line of outfile through fix_pin""" with open(self.outfile, 'rt') as fp: lines = [ self.fix_pin(line) for line in self.concatenated(fp) ] with open(self.outfile, 'wt') as fp: fp.writelines([ ...
['def', 'fix_lockfile', '(', 'self', ')', ':', 'with', 'open', '(', 'self', '.', 'outfile', ',', "'rt'", ')', 'as', 'fp', ':', 'lines', '=', '[', 'self', '.', 'fix_pin', '(', 'line', ')', 'for', 'line', 'in', 'self', '.', 'concatenated', '(', 'fp', ')', ']', 'with', 'open', '(', 'self', '.', 'outfile', ',', "'wt'", ')'...
Run each line of outfile through fix_pin
['Run', 'each', 'line', 'of', 'outfile', 'through', 'fix_pin']
train
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L103-L115
7,384
spacetelescope/drizzlepac
drizzlepac/createMedian.py
_writeImage
def _writeImage(dataArray=None, inputHeader=None): """ Writes out the result of the combination step. The header of the first 'outsingle' file in the association parlist is used as the header of the new image. Parameters ---------- dataArray : arr Array o...
python
def _writeImage(dataArray=None, inputHeader=None): """ Writes out the result of the combination step. The header of the first 'outsingle' file in the association parlist is used as the header of the new image. Parameters ---------- dataArray : arr Array o...
['def', '_writeImage', '(', 'dataArray', '=', 'None', ',', 'inputHeader', '=', 'None', ')', ':', 'prihdu', '=', 'fits', '.', 'PrimaryHDU', '(', 'data', '=', 'dataArray', ',', 'header', '=', 'inputHeader', ')', 'pf', '=', 'fits', '.', 'HDUList', '(', ')', 'pf', '.', 'append', '(', 'prihdu', ')', 'return', 'pf']
Writes out the result of the combination step. The header of the first 'outsingle' file in the association parlist is used as the header of the new image. Parameters ---------- dataArray : arr Array of data to be written to a fits.PrimaryHDU object i...
['Writes', 'out', 'the', 'result', 'of', 'the', 'combination', 'step', '.', 'The', 'header', 'of', 'the', 'first', 'outsingle', 'file', 'in', 'the', 'association', 'parlist', 'is', 'used', 'as', 'the', 'header', 'of', 'the', 'new', 'image', '.']
train
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/createMedian.py#L454-L472
7,385
BYU-PCCL/holodeck
holodeck/util.py
convert_unicode
def convert_unicode(value): """Resolves python 2 issue with json loading in unicode instead of string Args: value (str): Unicode value to be converted Returns: (str): converted string """ if isinstance(value, dict): return {convert_unicode(key): convert_unicode(value) ...
python
def convert_unicode(value): """Resolves python 2 issue with json loading in unicode instead of string Args: value (str): Unicode value to be converted Returns: (str): converted string """ if isinstance(value, dict): return {convert_unicode(key): convert_unicode(value) ...
['def', 'convert_unicode', '(', 'value', ')', ':', 'if', 'isinstance', '(', 'value', ',', 'dict', ')', ':', 'return', '{', 'convert_unicode', '(', 'key', ')', ':', 'convert_unicode', '(', 'value', ')', 'for', 'key', ',', 'value', 'in', 'value', '.', 'iteritems', '(', ')', '}', 'elif', 'isinstance', '(', 'value', ',', '...
Resolves python 2 issue with json loading in unicode instead of string Args: value (str): Unicode value to be converted Returns: (str): converted string
['Resolves', 'python', '2', 'issue', 'with', 'json', 'loading', 'in', 'unicode', 'instead', 'of', 'string']
train
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/util.py#L27-L45
7,386
saltstack/salt
salt/modules/bluez_bluetooth.py
block
def block(bdaddr): ''' Block a specific bluetooth device by BD Address CLI Example: .. code-block:: bash salt '*' bluetooth.block DE:AD:BE:EF:CA:FE ''' if not salt.utils.validate.net.mac(bdaddr): raise CommandExecutionError( 'Invalid BD address passed to bluetooth....
python
def block(bdaddr): ''' Block a specific bluetooth device by BD Address CLI Example: .. code-block:: bash salt '*' bluetooth.block DE:AD:BE:EF:CA:FE ''' if not salt.utils.validate.net.mac(bdaddr): raise CommandExecutionError( 'Invalid BD address passed to bluetooth....
['def', 'block', '(', 'bdaddr', ')', ':', 'if', 'not', 'salt', '.', 'utils', '.', 'validate', '.', 'net', '.', 'mac', '(', 'bdaddr', ')', ':', 'raise', 'CommandExecutionError', '(', "'Invalid BD address passed to bluetooth.block'", ')', 'cmd', '=', "'hciconfig {0} block'", '.', 'format', '(', 'bdaddr', ')', '__salt__',...
Block a specific bluetooth device by BD Address CLI Example: .. code-block:: bash salt '*' bluetooth.block DE:AD:BE:EF:CA:FE
['Block', 'a', 'specific', 'bluetooth', 'device', 'by', 'BD', 'Address']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L192-L208
7,387
hammerlab/cohorts
cohorts/plot.py
hide_ticks
def hide_ticks(plot, min_tick_value=None, max_tick_value=None): """Hide tick values that are outside of [min_tick_value, max_tick_value]""" for tick, tick_value in zip(plot.get_yticklabels(), plot.get_yticks()): tick_label = as_numeric(tick_value) if tick_label: if (min_tick_value is...
python
def hide_ticks(plot, min_tick_value=None, max_tick_value=None): """Hide tick values that are outside of [min_tick_value, max_tick_value]""" for tick, tick_value in zip(plot.get_yticklabels(), plot.get_yticks()): tick_label = as_numeric(tick_value) if tick_label: if (min_tick_value is...
['def', 'hide_ticks', '(', 'plot', ',', 'min_tick_value', '=', 'None', ',', 'max_tick_value', '=', 'None', ')', ':', 'for', 'tick', ',', 'tick_value', 'in', 'zip', '(', 'plot', '.', 'get_yticklabels', '(', ')', ',', 'plot', '.', 'get_yticks', '(', ')', ')', ':', 'tick_label', '=', 'as_numeric', '(', 'tick_value', ')', ...
Hide tick values that are outside of [min_tick_value, max_tick_value]
['Hide', 'tick', 'values', 'that', 'are', 'outside', 'of', '[', 'min_tick_value', 'max_tick_value', ']']
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L37-L44
7,388
chaoss/grimoirelab-elk
grimoire_elk/enriched/ceres_base.py
ESConnector._build_search_query
def _build_search_query(self, from_date): """Build an ElasticSearch search query to retrieve items for read methods. :param from_date: date to start retrieving items from. :return: JSON query in dict format """ sort = [{self._sort_on_field: {"order": "asc"}}] filters =...
python
def _build_search_query(self, from_date): """Build an ElasticSearch search query to retrieve items for read methods. :param from_date: date to start retrieving items from. :return: JSON query in dict format """ sort = [{self._sort_on_field: {"order": "asc"}}] filters =...
['def', '_build_search_query', '(', 'self', ',', 'from_date', ')', ':', 'sort', '=', '[', '{', 'self', '.', '_sort_on_field', ':', '{', '"order"', ':', '"asc"', '}', '}', ']', 'filters', '=', '[', ']', 'if', 'self', '.', '_repo', ':', 'filters', '.', 'append', '(', '{', '"term"', ':', '{', '"origin"', ':', 'self', '.',...
Build an ElasticSearch search query to retrieve items for read methods. :param from_date: date to start retrieving items from. :return: JSON query in dict format
['Build', 'an', 'ElasticSearch', 'search', 'query', 'to', 'retrieve', 'items', 'for', 'read', 'methods', '.']
train
https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/ceres_base.py#L304-L330
7,389
learningequality/ricecooker
ricecooker/utils/pdf.py
PDFParser.get_toc
def get_toc(self, subchapters=False): """ Returns table-of-contents information extracted from the PDF doc. When `subchapters=False`, the output is a list of this form .. code-block:: python [ {'title': 'First chapter', 'page_start': 0, 'page_end': 10}, ...
python
def get_toc(self, subchapters=False): """ Returns table-of-contents information extracted from the PDF doc. When `subchapters=False`, the output is a list of this form .. code-block:: python [ {'title': 'First chapter', 'page_start': 0, 'page_end': 10}, ...
['def', 'get_toc', '(', 'self', ',', 'subchapters', '=', 'False', ')', ':', 'self', '.', 'check_path', '(', ')', 'chapters', '=', '[', ']', 'index', '=', '0', 'for', 'dest', 'in', 'self', '.', 'pdf', '.', 'getOutlines', '(', ')', ':', '# Process chapters', 'if', 'isinstance', '(', 'dest', ',', 'CustomDestination', ')',...
Returns table-of-contents information extracted from the PDF doc. When `subchapters=False`, the output is a list of this form .. code-block:: python [ {'title': 'First chapter', 'page_start': 0, 'page_end': 10}, {'title': 'Second chapter', 'page_start': 10...
['Returns', 'table', '-', 'of', '-', 'contents', 'information', 'extracted', 'from', 'the', 'PDF', 'doc', '.', 'When', 'subchapters', '=', 'False', 'the', 'output', 'is', 'a', 'list', 'of', 'this', 'form']
train
https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/ricecooker/utils/pdf.py#L75-L136
7,390
gem/oq-engine
openquake/risklib/scientific.py
VulnerabilityFunction._cov_for
def _cov_for(self, imls): """ Clip `imls` to the range associated with the support of the vulnerability function and returns the corresponding covariance values by linear interpolation. For instance if the range is [0.005, 0.0269] and the imls are [0.0049, 0.006, 0.027], ...
python
def _cov_for(self, imls): """ Clip `imls` to the range associated with the support of the vulnerability function and returns the corresponding covariance values by linear interpolation. For instance if the range is [0.005, 0.0269] and the imls are [0.0049, 0.006, 0.027], ...
['def', '_cov_for', '(', 'self', ',', 'imls', ')', ':', 'return', 'self', '.', '_covs_i1d', '(', 'numpy', '.', 'piecewise', '(', 'imls', ',', '[', 'imls', '>', 'self', '.', 'imls', '[', '-', '1', ']', ',', 'imls', '<', 'self', '.', 'imls', '[', '0', ']', ']', ',', '[', 'self', '.', 'imls', '[', '-', '1', ']', ',', 'sel...
Clip `imls` to the range associated with the support of the vulnerability function and returns the corresponding covariance values by linear interpolation. For instance if the range is [0.005, 0.0269] and the imls are [0.0049, 0.006, 0.027], the clipped imls are [0.005, 0.006, 0...
['Clip', 'imls', 'to', 'the', 'range', 'associated', 'with', 'the', 'support', 'of', 'the', 'vulnerability', 'function', 'and', 'returns', 'the', 'corresponding', 'covariance', 'values', 'by', 'linear', 'interpolation', '.', 'For', 'instance', 'if', 'the', 'range', 'is', '[', '0', '.', '005', '0', '.', '0269', ']', 'an...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L242-L255
7,391
5monkeys/djedi-cms
djedi/admin/api.py
NodeApi.delete
def delete(self, request, uri): """ Delete versioned uri and return empty text response on success. """ uri = self.decode_uri(uri) uris = cio.delete(uri) if uri not in uris: raise Http404 return self.render_to_response()
python
def delete(self, request, uri): """ Delete versioned uri and return empty text response on success. """ uri = self.decode_uri(uri) uris = cio.delete(uri) if uri not in uris: raise Http404 return self.render_to_response()
['def', 'delete', '(', 'self', ',', 'request', ',', 'uri', ')', ':', 'uri', '=', 'self', '.', 'decode_uri', '(', 'uri', ')', 'uris', '=', 'cio', '.', 'delete', '(', 'uri', ')', 'if', 'uri', 'not', 'in', 'uris', ':', 'raise', 'Http404', 'return', 'self', '.', 'render_to_response', '(', ')']
Delete versioned uri and return empty text response on success.
['Delete', 'versioned', 'uri', 'and', 'return', 'empty', 'text', 'response', 'on', 'success', '.']
train
https://github.com/5monkeys/djedi-cms/blob/3c077edfda310717b9cdb4f2ee14e78723c94894/djedi/admin/api.py#L110-L120
7,392
googleapis/google-cloud-python
bigquery/google/cloud/bigquery/_helpers.py
_rows_from_json
def _rows_from_json(values, schema): """Convert JSON row data to rows with appropriate types.""" from google.cloud.bigquery import Row field_to_index = _field_to_index_mapping(schema) return [Row(_row_tuple_from_json(r, schema), field_to_index) for r in values]
python
def _rows_from_json(values, schema): """Convert JSON row data to rows with appropriate types.""" from google.cloud.bigquery import Row field_to_index = _field_to_index_mapping(schema) return [Row(_row_tuple_from_json(r, schema), field_to_index) for r in values]
['def', '_rows_from_json', '(', 'values', ',', 'schema', ')', ':', 'from', 'google', '.', 'cloud', '.', 'bigquery', 'import', 'Row', 'field_to_index', '=', '_field_to_index_mapping', '(', 'schema', ')', 'return', '[', 'Row', '(', '_row_tuple_from_json', '(', 'r', ',', 'schema', ')', ',', 'field_to_index', ')', 'for', '...
Convert JSON row data to rows with appropriate types.
['Convert', 'JSON', 'row', 'data', 'to', 'rows', 'with', 'appropriate', 'types', '.']
train
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/_helpers.py#L226-L231
7,393
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py
AggregatorAccountAdminApi.get_account_certificate
def get_account_certificate(self, account_id, cert_id, **kwargs): # noqa: E501 """Get trusted certificate by ID. # noqa: E501 An endpoint for retrieving a trusted certificate by ID. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/trusted-certificates/{cert-id} -...
python
def get_account_certificate(self, account_id, cert_id, **kwargs): # noqa: E501 """Get trusted certificate by ID. # noqa: E501 An endpoint for retrieving a trusted certificate by ID. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/trusted-certificates/{cert-id} -...
['def', 'get_account_certificate', '(', 'self', ',', 'account_id', ',', 'cert_id', ',', '*', '*', 'kwargs', ')', ':', '# noqa: E501', 'kwargs', '[', "'_return_http_data_only'", ']', '=', 'True', 'if', 'kwargs', '.', 'get', '(', "'asynchronous'", ')', ':', 'return', 'self', '.', 'get_account_certificate_with_http_info',...
Get trusted certificate by ID. # noqa: E501 An endpoint for retrieving a trusted certificate by ID. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/trusted-certificates/{cert-id} -H 'Authorization: Bearer API_KEY'` # noqa: E501 This method makes a synchronous HT...
['Get', 'trusted', 'certificate', 'by', 'ID', '.', '#', 'noqa', ':', 'E501']
train
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py#L1744-L1765
7,394
couchbase/couchbase-python-client
couchbase/bucket.py
Bucket.queue_push
def queue_push(self, key, value, create=False, **kwargs): """ Add an item to the end of a queue. :param key: The document ID of the queue :param value: The item to add to the queue :param create: Whether the queue should be created if it does not exist :param kwargs: Arg...
python
def queue_push(self, key, value, create=False, **kwargs): """ Add an item to the end of a queue. :param key: The document ID of the queue :param value: The item to add to the queue :param create: Whether the queue should be created if it does not exist :param kwargs: Arg...
['def', 'queue_push', '(', 'self', ',', 'key', ',', 'value', ',', 'create', '=', 'False', ',', '*', '*', 'kwargs', ')', ':', 'return', 'self', '.', 'list_prepend', '(', 'key', ',', 'value', ',', '*', '*', 'kwargs', ')']
Add an item to the end of a queue. :param key: The document ID of the queue :param value: The item to add to the queue :param create: Whether the queue should be created if it does not exist :param kwargs: Arguments to pass to :meth:`mutate_in` :return: :class:`OperationResult` ...
['Add', 'an', 'item', 'to', 'the', 'end', 'of', 'a', 'queue', '.']
train
https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/bucket.py#L2383-L2403
7,395
sony/nnabla
python/src/nnabla/utils/converter/onnx/importer.py
generate_transpose
def generate_transpose(node_name, in_name, out_name, axes, base_name, func_counter): """Generate a Transpose operator to transpose the specified buffer. """ trans = nnabla_pb2.Function() trans.type = "Transpose" set_function_name(trans, node_name, base_name, func_counter) trans.input.extend([in_...
python
def generate_transpose(node_name, in_name, out_name, axes, base_name, func_counter): """Generate a Transpose operator to transpose the specified buffer. """ trans = nnabla_pb2.Function() trans.type = "Transpose" set_function_name(trans, node_name, base_name, func_counter) trans.input.extend([in_...
['def', 'generate_transpose', '(', 'node_name', ',', 'in_name', ',', 'out_name', ',', 'axes', ',', 'base_name', ',', 'func_counter', ')', ':', 'trans', '=', 'nnabla_pb2', '.', 'Function', '(', ')', 'trans', '.', 'type', '=', '"Transpose"', 'set_function_name', '(', 'trans', ',', 'node_name', ',', 'base_name', ',', 'fun...
Generate a Transpose operator to transpose the specified buffer.
['Generate', 'a', 'Transpose', 'operator', 'to', 'transpose', 'the', 'specified', 'buffer', '.']
train
https://github.com/sony/nnabla/blob/aaf3d33b7cbb38f2a03aa754178ba8f7c8481320/python/src/nnabla/utils/converter/onnx/importer.py#L162-L172
7,396
obriencj/python-javatools
javatools/distdiff.py
DistReport.collect_impl
def collect_impl(self): """ overrides DistJarChange and DistClassChange from the underlying DistChange with DistJarReport and DistClassReport instances """ for c in DistChange.collect_impl(self): if isinstance(c, DistJarChange): if c.is_change(): ...
python
def collect_impl(self): """ overrides DistJarChange and DistClassChange from the underlying DistChange with DistJarReport and DistClassReport instances """ for c in DistChange.collect_impl(self): if isinstance(c, DistJarChange): if c.is_change(): ...
['def', 'collect_impl', '(', 'self', ')', ':', 'for', 'c', 'in', 'DistChange', '.', 'collect_impl', '(', 'self', ')', ':', 'if', 'isinstance', '(', 'c', ',', 'DistJarChange', ')', ':', 'if', 'c', '.', 'is_change', '(', ')', ':', 'ln', '=', 'DistJarReport', '.', 'report_name', 'nr', '=', 'self', '.', 'reporter', '.', 's...
overrides DistJarChange and DistClassChange from the underlying DistChange with DistJarReport and DistClassReport instances
['overrides', 'DistJarChange', 'and', 'DistClassChange', 'from', 'the', 'underlying', 'DistChange', 'with', 'DistJarReport', 'and', 'DistClassReport', 'instances']
train
https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distdiff.py#L383-L400
7,397
bcbio/bcbio-nextgen
bcbio/variation/varscan.py
_get_jvm_opts
def _get_jvm_opts(config, tmp_dir): """Retrieve common options for running VarScan. Handles jvm_opts, setting user and country to English to avoid issues with different locales producing non-compliant VCF. """ resources = config_utils.get_resources("varscan", config) jvm_opts = resources.get("jv...
python
def _get_jvm_opts(config, tmp_dir): """Retrieve common options for running VarScan. Handles jvm_opts, setting user and country to English to avoid issues with different locales producing non-compliant VCF. """ resources = config_utils.get_resources("varscan", config) jvm_opts = resources.get("jv...
['def', '_get_jvm_opts', '(', 'config', ',', 'tmp_dir', ')', ':', 'resources', '=', 'config_utils', '.', 'get_resources', '(', '"varscan"', ',', 'config', ')', 'jvm_opts', '=', 'resources', '.', 'get', '(', '"jvm_opts"', ',', '[', '"-Xmx750m"', ',', '"-Xmx2g"', ']', ')', 'jvm_opts', '=', 'config_utils', '.', 'adjust_op...
Retrieve common options for running VarScan. Handles jvm_opts, setting user and country to English to avoid issues with different locales producing non-compliant VCF.
['Retrieve', 'common', 'options', 'for', 'running', 'VarScan', '.', 'Handles', 'jvm_opts', 'setting', 'user', 'and', 'country', 'to', 'English', 'to', 'avoid', 'issues', 'with', 'different', 'locales', 'producing', 'non', '-', 'compliant', 'VCF', '.']
train
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/varscan.py#L36-L48
7,398
jdoda/sdl2hl
sdl2hl/renderer.py
Renderer.draw_points
def draw_points(self, *points): """Draw multiple points on the current rendering target. Args: *points (Point): The points to draw. Raises: SDLError: If an error is encountered. """ point_array = ffi.new('SDL_Point[]', len(points)) for i, p in en...
python
def draw_points(self, *points): """Draw multiple points on the current rendering target. Args: *points (Point): The points to draw. Raises: SDLError: If an error is encountered. """ point_array = ffi.new('SDL_Point[]', len(points)) for i, p in en...
['def', 'draw_points', '(', 'self', ',', '*', 'points', ')', ':', 'point_array', '=', 'ffi', '.', 'new', '(', "'SDL_Point[]'", ',', 'len', '(', 'points', ')', ')', 'for', 'i', ',', 'p', 'in', 'enumerate', '(', 'points', ')', ':', 'point_array', '[', 'i', ']', '=', 'p', '.', '_ptr', '[', '0', ']', 'check_int_err', '(', ...
Draw multiple points on the current rendering target. Args: *points (Point): The points to draw. Raises: SDLError: If an error is encountered.
['Draw', 'multiple', 'points', 'on', 'the', 'current', 'rendering', 'target', '.']
train
https://github.com/jdoda/sdl2hl/blob/3b477e1e01cea5d8e15e9e5ef3a302ea460f5946/sdl2hl/renderer.py#L204-L216
7,399
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/key_ranges.py
KeyRangesFactory.from_json
def from_json(cls, json): """Deserialize from json. Args: json: a dict of json compatible fields. Returns: a KeyRanges object. Raises: ValueError: if the json is invalid. """ if json["name"] in _KEYRANGES_CLASSES: return _KEYRANGES_CLASSES[json["name"]].from_json(json)...
python
def from_json(cls, json): """Deserialize from json. Args: json: a dict of json compatible fields. Returns: a KeyRanges object. Raises: ValueError: if the json is invalid. """ if json["name"] in _KEYRANGES_CLASSES: return _KEYRANGES_CLASSES[json["name"]].from_json(json)...
['def', 'from_json', '(', 'cls', ',', 'json', ')', ':', 'if', 'json', '[', '"name"', ']', 'in', '_KEYRANGES_CLASSES', ':', 'return', '_KEYRANGES_CLASSES', '[', 'json', '[', '"name"', ']', ']', '.', 'from_json', '(', 'json', ')', 'raise', 'ValueError', '(', '"Invalid json %s"', ',', 'json', ')']
Deserialize from json. Args: json: a dict of json compatible fields. Returns: a KeyRanges object. Raises: ValueError: if the json is invalid.
['Deserialize', 'from', 'json', '.']
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/key_ranges.py#L58-L72