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
5,100
ynop/audiomate
audiomate/utils/textfile.py
read_key_value_lines
def read_key_value_lines(path, separator=' ', default_value=''): """ Reads lines of a text file with two columns as key/value dictionary. Parameters: path (str): Path to the file. separator (str): Separator that is used to split key and value. default_value (str): If no value is giv...
python
def read_key_value_lines(path, separator=' ', default_value=''): """ Reads lines of a text file with two columns as key/value dictionary. Parameters: path (str): Path to the file. separator (str): Separator that is used to split key and value. default_value (str): If no value is giv...
['def', 'read_key_value_lines', '(', 'path', ',', 'separator', '=', "' '", ',', 'default_value', '=', "''", ')', ':', 'gen', '=', 'read_separated_lines_generator', '(', 'path', ',', 'separator', ',', '2', ')', 'dic', '=', '{', '}', 'for', 'record', 'in', 'gen', ':', 'if', 'len', '(', 'record', ')', '>', '1', ':', 'dic'...
Reads lines of a text file with two columns as key/value dictionary. Parameters: path (str): Path to the file. separator (str): Separator that is used to split key and value. default_value (str): If no value is given this value is used. Returns: dict: A dictionary with first co...
['Reads', 'lines', 'of', 'a', 'text', 'file', 'with', 'two', 'columns', 'as', 'key', '/', 'value', 'dictionary', '.']
train
https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/textfile.py#L54-L76
5,101
ff0000/scarlet
scarlet/versioning/view_mixins.py
PreviewableObject.get_object
def get_object(self, queryset=None): """ Returns the object the view is displaying. Copied from SingleObjectMixin except that this allows us to lookup preview objects. """ schema = manager.get_schema() vid = None if self.request.GET.get('vid') and self.r...
python
def get_object(self, queryset=None): """ Returns the object the view is displaying. Copied from SingleObjectMixin except that this allows us to lookup preview objects. """ schema = manager.get_schema() vid = None if self.request.GET.get('vid') and self.r...
['def', 'get_object', '(', 'self', ',', 'queryset', '=', 'None', ')', ':', 'schema', '=', 'manager', '.', 'get_schema', '(', ')', 'vid', '=', 'None', 'if', 'self', '.', 'request', '.', 'GET', '.', 'get', '(', "'vid'", ')', 'and', 'self', '.', 'request', '.', 'user', '.', 'is_staff', 'and', 'self', '.', 'request', '.', ...
Returns the object the view is displaying. Copied from SingleObjectMixin except that this allows us to lookup preview objects.
['Returns', 'the', 'object', 'the', 'view', 'is', 'displaying', '.']
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/view_mixins.py#L13-L64
5,102
miccoli/pyownet
src/pyownet/protocol.py
_Proxy.present
def present(self, path, timeout=0): """returns True if there is an entity at path""" ret, data = self.sendmess(MSG_PRESENCE, str2bytez(path), timeout=timeout) assert ret <= 0 and not data, (ret, data) if ret < 0: return False else: ...
python
def present(self, path, timeout=0): """returns True if there is an entity at path""" ret, data = self.sendmess(MSG_PRESENCE, str2bytez(path), timeout=timeout) assert ret <= 0 and not data, (ret, data) if ret < 0: return False else: ...
['def', 'present', '(', 'self', ',', 'path', ',', 'timeout', '=', '0', ')', ':', 'ret', ',', 'data', '=', 'self', '.', 'sendmess', '(', 'MSG_PRESENCE', ',', 'str2bytez', '(', 'path', ')', ',', 'timeout', '=', 'timeout', ')', 'assert', 'ret', '<=', '0', 'and', 'not', 'data', ',', '(', 'ret', ',', 'data', ')', 'if', 'ret...
returns True if there is an entity at path
['returns', 'True', 'if', 'there', 'is', 'an', 'entity', 'at', 'path']
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L586-L595
5,103
Stewori/pytypes
pytypes/type_util.py
is_Type
def is_Type(tp): """Python version independent check if an object is a type. For Python 3.7 onwards(?) this is not equivalent to ``isinstance(tp, type)`` any more, as that call would return ``False`` for PEP 484 types. Tested with CPython 2.7, 3.5, 3.6, 3.7 and Jython 2.7.1. """ if isinstanc...
python
def is_Type(tp): """Python version independent check if an object is a type. For Python 3.7 onwards(?) this is not equivalent to ``isinstance(tp, type)`` any more, as that call would return ``False`` for PEP 484 types. Tested with CPython 2.7, 3.5, 3.6, 3.7 and Jython 2.7.1. """ if isinstanc...
['def', 'is_Type', '(', 'tp', ')', ':', 'if', 'isinstance', '(', 'tp', ',', 'type', ')', ':', 'return', 'True', 'try', ':', 'typing', '.', '_type_check', '(', 'tp', ',', "''", ')', 'return', 'True', 'except', 'TypeError', ':', 'return', 'False']
Python version independent check if an object is a type. For Python 3.7 onwards(?) this is not equivalent to ``isinstance(tp, type)`` any more, as that call would return ``False`` for PEP 484 types. Tested with CPython 2.7, 3.5, 3.6, 3.7 and Jython 2.7.1.
['Python', 'version', 'independent', 'check', 'if', 'an', 'object', 'is', 'a', 'type', '.', 'For', 'Python', '3', '.', '7', 'onwards', '(', '?', ')', 'this', 'is', 'not', 'equivalent', 'to', 'isinstance', '(', 'tp', 'type', ')', 'any', 'more', 'as', 'that', 'call', 'would', 'return', 'False', 'for', 'PEP', '484', 'type...
train
https://github.com/Stewori/pytypes/blob/b814d38709e84c0e0825caf8b721c20eb5a8ab3b/pytypes/type_util.py#L320-L333
5,104
angr/angr
angr/analyses/calling_convention.py
CallingConventionAnalysis._analyze_function
def _analyze_function(self): """ Go over the variable information in variable manager for this function, and return all uninitialized register/stack variables. :return: """ if not self._function.is_simprocedure \ and not self._function.is_plt \ ...
python
def _analyze_function(self): """ Go over the variable information in variable manager for this function, and return all uninitialized register/stack variables. :return: """ if not self._function.is_simprocedure \ and not self._function.is_plt \ ...
['def', '_analyze_function', '(', 'self', ')', ':', 'if', 'not', 'self', '.', '_function', '.', 'is_simprocedure', 'and', 'not', 'self', '.', '_function', '.', 'is_plt', 'and', 'not', 'self', '.', '_variable_manager', '.', 'has_function_manager', '(', 'self', '.', '_function', '.', 'addr', ')', ':', 'l', '.', 'warning'...
Go over the variable information in variable manager for this function, and return all uninitialized register/stack variables. :return:
['Go', 'over', 'the', 'variable', 'information', 'in', 'variable', 'manager', 'for', 'this', 'function', 'and', 'return', 'all', 'uninitialized', 'register', '/', 'stack', 'variables', '.']
train
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/calling_convention.py#L48-L77
5,105
IdentityPython/pysaml2
src/saml2/cache.py
Cache.entities
def entities(self, name_id): """ Returns all the entities of assertions for a subject, disregarding whether the assertion still is valid or not. :param name_id: The subject identifier, a NameID instance :return: A possibly empty list of entity identifiers """ cni = code(...
python
def entities(self, name_id): """ Returns all the entities of assertions for a subject, disregarding whether the assertion still is valid or not. :param name_id: The subject identifier, a NameID instance :return: A possibly empty list of entity identifiers """ cni = code(...
['def', 'entities', '(', 'self', ',', 'name_id', ')', ':', 'cni', '=', 'code', '(', 'name_id', ')', 'return', 'list', '(', 'self', '.', '_db', '[', 'cni', ']', '.', 'keys', '(', ')', ')']
Returns all the entities of assertions for a subject, disregarding whether the assertion still is valid or not. :param name_id: The subject identifier, a NameID instance :return: A possibly empty list of entity identifiers
['Returns', 'all', 'the', 'entities', 'of', 'assertions', 'for', 'a', 'subject', 'disregarding', 'whether', 'the', 'assertion', 'still', 'is', 'valid', 'or', 'not', '.']
train
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/cache.py#L143-L151
5,106
JukeboxPipeline/jukebox-core
src/jukeboxcore/gui/widgetdelegate.py
WD_TreeView.index_at_event
def index_at_event(self, event): """Get the index under the position of the given MouseEvent This implementation takes the indentation into account. :param event: the mouse event :type event: :class:`QtGui.QMouseEvent` :returns: the index :rtype: :class:`QtCore.QModelIn...
python
def index_at_event(self, event): """Get the index under the position of the given MouseEvent This implementation takes the indentation into account. :param event: the mouse event :type event: :class:`QtGui.QMouseEvent` :returns: the index :rtype: :class:`QtCore.QModelIn...
['def', 'index_at_event', '(', 'self', ',', 'event', ')', ':', '# find index at mouse position', 'globalpos', '=', 'event', '.', 'globalPos', '(', ')', 'viewport', '=', 'self', '.', 'viewport', '(', ')', 'pos', '=', 'viewport', '.', 'mapFromGlobal', '(', 'globalpos', ')', 'i', '=', 'self', '.', 'indexAt', '(', 'pos', '...
Get the index under the position of the given MouseEvent This implementation takes the indentation into account. :param event: the mouse event :type event: :class:`QtGui.QMouseEvent` :returns: the index :rtype: :class:`QtCore.QModelIndex` :raises: None
['Get', 'the', 'index', 'under', 'the', 'position', 'of', 'the', 'given', 'MouseEvent']
train
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgetdelegate.py#L549-L569
5,107
TeamHG-Memex/eli5
eli5/sklearn/explain_prediction.py
explain_prediction_sklearn
def explain_prediction_sklearn(estimator, doc, vec=None, top=None, top_targets=None, target_names=None, targets=None, feature_names=No...
python
def explain_prediction_sklearn(estimator, doc, vec=None, top=None, top_targets=None, target_names=None, targets=None, feature_names=No...
['def', 'explain_prediction_sklearn', '(', 'estimator', ',', 'doc', ',', 'vec', '=', 'None', ',', 'top', '=', 'None', ',', 'top_targets', '=', 'None', ',', 'target_names', '=', 'None', ',', 'targets', '=', 'None', ',', 'feature_names', '=', 'None', ',', 'feature_re', '=', 'None', ',', 'feature_filter', '=', 'None', ','...
Return an explanation of a scikit-learn estimator
['Return', 'an', 'explanation', 'of', 'a', 'scikit', '-', 'learn', 'estimator']
train
https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/explain_prediction.py#L77-L88
5,108
polysquare/cmake-ast
cmakeast/ast.py
_is_really_comment
def _is_really_comment(tokens, index): """Return true if the token at index is really a comment.""" if tokens[index].type == TokenType.Comment: return True # Really a comment in disguise! try: if tokens[index].content.lstrip()[0] == "#": return True except IndexError: ...
python
def _is_really_comment(tokens, index): """Return true if the token at index is really a comment.""" if tokens[index].type == TokenType.Comment: return True # Really a comment in disguise! try: if tokens[index].content.lstrip()[0] == "#": return True except IndexError: ...
['def', '_is_really_comment', '(', 'tokens', ',', 'index', ')', ':', 'if', 'tokens', '[', 'index', ']', '.', 'type', '==', 'TokenType', '.', 'Comment', ':', 'return', 'True', '# Really a comment in disguise!', 'try', ':', 'if', 'tokens', '[', 'index', ']', '.', 'content', '.', 'lstrip', '(', ')', '[', '0', ']', '==', '...
Return true if the token at index is really a comment.
['Return', 'true', 'if', 'the', 'token', 'at', 'index', 'is', 'really', 'a', 'comment', '.']
train
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L522-L532
5,109
PMBio/limix-backup
limix/deprecated/utils/preprocess.py
variance_K
def variance_K(K, verbose=False): """estimate the variance explained by K""" c = SP.sum((SP.eye(len(K)) - (1.0 / len(K)) * SP.ones(K.shape)) * SP.array(K)) scalar = (len(K) - 1) / c return 1.0/scalar
python
def variance_K(K, verbose=False): """estimate the variance explained by K""" c = SP.sum((SP.eye(len(K)) - (1.0 / len(K)) * SP.ones(K.shape)) * SP.array(K)) scalar = (len(K) - 1) / c return 1.0/scalar
['def', 'variance_K', '(', 'K', ',', 'verbose', '=', 'False', ')', ':', 'c', '=', 'SP', '.', 'sum', '(', '(', 'SP', '.', 'eye', '(', 'len', '(', 'K', ')', ')', '-', '(', '1.0', '/', 'len', '(', 'K', ')', ')', '*', 'SP', '.', 'ones', '(', 'K', '.', 'shape', ')', ')', '*', 'SP', '.', 'array', '(', 'K', ')', ')', 'scalar'...
estimate the variance explained by K
['estimate', 'the', 'variance', 'explained', 'by', 'K']
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/utils/preprocess.py#L22-L26
5,110
scottrice/pysteam
pysteam/legacy/game.py
Game.set_image
def set_image(self, user, image_path): """Sets a custom image for the game. `image_path` should refer to an image file on disk""" _, ext = os.path.splitext(image_path) shutil.copy(image_path, self._custom_image_path(user, ext))
python
def set_image(self, user, image_path): """Sets a custom image for the game. `image_path` should refer to an image file on disk""" _, ext = os.path.splitext(image_path) shutil.copy(image_path, self._custom_image_path(user, ext))
['def', 'set_image', '(', 'self', ',', 'user', ',', 'image_path', ')', ':', '_', ',', 'ext', '=', 'os', '.', 'path', '.', 'splitext', '(', 'image_path', ')', 'shutil', '.', 'copy', '(', 'image_path', ',', 'self', '.', '_custom_image_path', '(', 'user', ',', 'ext', ')', ')']
Sets a custom image for the game. `image_path` should refer to an image file on disk
['Sets', 'a', 'custom', 'image', 'for', 'the', 'game', '.', 'image_path', 'should', 'refer', 'to', 'an', 'image', 'file', 'on', 'disk']
train
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/legacy/game.py#L50-L54
5,111
etcher-be/elib_config
elib_config/_file/_config_example.py
_aggregate_config_values
def _aggregate_config_values(config_values: typing.List[ConfigValue]) -> dict: """ Returns a (sorted) :param config_values: :type config_values: :return: :rtype: """ _keys: defaultdict = _nested_default_dict() _sorted_values = sorted(config_values, key=lambda x: x.name) for valu...
python
def _aggregate_config_values(config_values: typing.List[ConfigValue]) -> dict: """ Returns a (sorted) :param config_values: :type config_values: :return: :rtype: """ _keys: defaultdict = _nested_default_dict() _sorted_values = sorted(config_values, key=lambda x: x.name) for valu...
['def', '_aggregate_config_values', '(', 'config_values', ':', 'typing', '.', 'List', '[', 'ConfigValue', ']', ')', '->', 'dict', ':', '_keys', ':', 'defaultdict', '=', '_nested_default_dict', '(', ')', '_sorted_values', '=', 'sorted', '(', 'config_values', ',', 'key', '=', 'lambda', 'x', ':', 'x', '.', 'name', ')', 'f...
Returns a (sorted) :param config_values: :type config_values: :return: :rtype:
['Returns', 'a', '(', 'sorted', ')']
train
https://github.com/etcher-be/elib_config/blob/5d8c839e84d70126620ab0186dc1f717e5868bd0/elib_config/_file/_config_example.py#L41-L58
5,112
eqcorrscan/EQcorrscan
eqcorrscan/core/match_filter.py
match_filter
def match_filter(template_names, template_list, st, threshold, threshold_type, trig_int, plotvar, plotdir='.', xcorr_func=None, concurrency=None, cores=None, debug=0, plot_format='png', output_cat=False, output_event=True, extract_detections=False, ...
python
def match_filter(template_names, template_list, st, threshold, threshold_type, trig_int, plotvar, plotdir='.', xcorr_func=None, concurrency=None, cores=None, debug=0, plot_format='png', output_cat=False, output_event=True, extract_detections=False, ...
['def', 'match_filter', '(', 'template_names', ',', 'template_list', ',', 'st', ',', 'threshold', ',', 'threshold_type', ',', 'trig_int', ',', 'plotvar', ',', 'plotdir', '=', "'.'", ',', 'xcorr_func', '=', 'None', ',', 'concurrency', '=', 'None', ',', 'cores', '=', 'None', ',', 'debug', '=', '0', ',', 'plot_format', '=...
Main matched-filter detection function. Over-arching code to run the correlations of given templates with a day of seismic data and output the detections based on a given threshold. For a functional example see the tutorials. :type template_names: list :param template_names: List of templa...
['Main', 'matched', '-', 'filter', 'detection', 'function', '.']
train
https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/core/match_filter.py#L4000-L4476
5,113
webrecorder/pywb
pywb/apps/frontendapp.py
FrontEndApp.is_valid_coll
def is_valid_coll(self, coll): """Determines if the collection name for a request is valid (exists) :param str coll: The name of the collection to check :return: True if the collection is valid, false otherwise :rtype: bool """ #if coll == self.all_coll: # ret...
python
def is_valid_coll(self, coll): """Determines if the collection name for a request is valid (exists) :param str coll: The name of the collection to check :return: True if the collection is valid, false otherwise :rtype: bool """ #if coll == self.all_coll: # ret...
['def', 'is_valid_coll', '(', 'self', ',', 'coll', ')', ':', '#if coll == self.all_coll:', '# return True', 'return', '(', 'coll', 'in', 'self', '.', 'warcserver', '.', 'list_fixed_routes', '(', ')', 'or', 'coll', 'in', 'self', '.', 'warcserver', '.', 'list_dynamic_routes', '(', ')', ')']
Determines if the collection name for a request is valid (exists) :param str coll: The name of the collection to check :return: True if the collection is valid, false otherwise :rtype: bool
['Determines', 'if', 'the', 'collection', 'name', 'for', 'a', 'request', 'is', 'valid', '(', 'exists', ')']
train
https://github.com/webrecorder/pywb/blob/77f8bb647639dd66f6b92b7a9174c28810e4b1d9/pywb/apps/frontendapp.py#L426-L437
5,114
pantsbuild/pants
src/python/pants/backend/python/subsystems/pex_build_util.py
PexBuilderWrapper.extract_single_dist_for_current_platform
def extract_single_dist_for_current_platform(self, reqs, dist_key): """Resolve a specific distribution from a set of requirements matching the current platform. :param list reqs: A list of :class:`PythonRequirement` to resolve. :param str dist_key: The value of `distribution.key` to match for a `distributi...
python
def extract_single_dist_for_current_platform(self, reqs, dist_key): """Resolve a specific distribution from a set of requirements matching the current platform. :param list reqs: A list of :class:`PythonRequirement` to resolve. :param str dist_key: The value of `distribution.key` to match for a `distributi...
['def', 'extract_single_dist_for_current_platform', '(', 'self', ',', 'reqs', ',', 'dist_key', ')', ':', 'distributions', '=', 'self', '.', '_resolve_distributions_by_platform', '(', 'reqs', ',', 'platforms', '=', '[', "'current'", ']', ')', 'try', ':', 'matched_dist', '=', 'assert_single_element', '(', 'list', '(', 'd...
Resolve a specific distribution from a set of requirements matching the current platform. :param list reqs: A list of :class:`PythonRequirement` to resolve. :param str dist_key: The value of `distribution.key` to match for a `distribution` from the resolved requirements. :return: T...
['Resolve', 'a', 'specific', 'distribution', 'from', 'a', 'set', 'of', 'requirements', 'matching', 'the', 'current', 'platform', '.']
train
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/python/subsystems/pex_build_util.py#L189-L211
5,115
graphistry/pygraphistry
graphistry/plotter.py
Plotter.bind
def bind(self, source=None, destination=None, node=None, edge_title=None, edge_label=None, edge_color=None, edge_weight=None, point_title=None, point_label=None, point_color=None, point_size=None): """Relate data attributes to graph structure and visual representation. To faci...
python
def bind(self, source=None, destination=None, node=None, edge_title=None, edge_label=None, edge_color=None, edge_weight=None, point_title=None, point_label=None, point_color=None, point_size=None): """Relate data attributes to graph structure and visual representation. To faci...
['def', 'bind', '(', 'self', ',', 'source', '=', 'None', ',', 'destination', '=', 'None', ',', 'node', '=', 'None', ',', 'edge_title', '=', 'None', ',', 'edge_label', '=', 'None', ',', 'edge_color', '=', 'None', ',', 'edge_weight', '=', 'None', ',', 'point_title', '=', 'None', ',', 'point_label', '=', 'None', ',', 'poi...
Relate data attributes to graph structure and visual representation. To facilitate reuse and replayable notebooks, the binding call is chainable. Invocation does not effect the old binding: it instead returns a new Plotter instance with the new bindings added to the existing ones. Both the old and new bindings...
['Relate', 'data', 'attributes', 'to', 'graph', 'structure', 'and', 'visual', 'representation', '.']
train
https://github.com/graphistry/pygraphistry/blob/3dfc50e60232c6f5fedd6e5fa9d3048b606944b8/graphistry/plotter.py#L68-L170
5,116
pkgw/pwkit
pwkit/lmmin.py
_qrd_solve_full
def _qrd_solve_full(a, b, ddiag, dtype=np.float): """Solve the equation A^T x = B, D x = 0. Parameters: a - an n-by-m array, m >= n b - an m-vector ddiag - an n-vector giving the diagonal of D. (The rest of D is 0.) Returns: x - n-vector solving the equation. s - the n-by-n supplementary matrix s. p...
python
def _qrd_solve_full(a, b, ddiag, dtype=np.float): """Solve the equation A^T x = B, D x = 0. Parameters: a - an n-by-m array, m >= n b - an m-vector ddiag - an n-vector giving the diagonal of D. (The rest of D is 0.) Returns: x - n-vector solving the equation. s - the n-by-n supplementary matrix s. p...
['def', '_qrd_solve_full', '(', 'a', ',', 'b', ',', 'ddiag', ',', 'dtype', '=', 'np', '.', 'float', ')', ':', 'a', '=', 'np', '.', 'asarray', '(', 'a', ',', 'dtype', ')', 'b', '=', 'np', '.', 'asarray', '(', 'b', ',', 'dtype', ')', 'ddiag', '=', 'np', '.', 'asarray', '(', 'ddiag', ',', 'dtype', ')', 'n', ',', 'm', '=',...
Solve the equation A^T x = B, D x = 0. Parameters: a - an n-by-m array, m >= n b - an m-vector ddiag - an n-vector giving the diagonal of D. (The rest of D is 0.) Returns: x - n-vector solving the equation. s - the n-by-n supplementary matrix s. pmut - n-element permutation vector defining the permutati...
['Solve', 'the', 'equation', 'A^T', 'x', '=', 'B', 'D', 'x', '=', '0', '.']
train
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lmmin.py#L774-L815
5,117
pypa/pipenv
pipenv/vendor/jinja2/filters.py
do_unique
def do_unique(environment, value, case_sensitive=False, attribute=None): """Returns a list of unique items from the the given iterable. .. sourcecode:: jinja {{ ['foo', 'bar', 'foobar', 'FooBar']|unique }} -> ['foo', 'bar', 'foobar'] The unique items are yielded in the same order as t...
python
def do_unique(environment, value, case_sensitive=False, attribute=None): """Returns a list of unique items from the the given iterable. .. sourcecode:: jinja {{ ['foo', 'bar', 'foobar', 'FooBar']|unique }} -> ['foo', 'bar', 'foobar'] The unique items are yielded in the same order as t...
['def', 'do_unique', '(', 'environment', ',', 'value', ',', 'case_sensitive', '=', 'False', ',', 'attribute', '=', 'None', ')', ':', 'getter', '=', 'make_attrgetter', '(', 'environment', ',', 'attribute', ',', 'postprocess', '=', 'ignore_case', 'if', 'not', 'case_sensitive', 'else', 'None', ')', 'seen', '=', 'set', '('...
Returns a list of unique items from the the given iterable. .. sourcecode:: jinja {{ ['foo', 'bar', 'foobar', 'FooBar']|unique }} -> ['foo', 'bar', 'foobar'] The unique items are yielded in the same order as their first occurrence in the iterable passed to the filter. :param case...
['Returns', 'a', 'list', 'of', 'unique', 'items', 'from', 'the', 'the', 'given', 'iterable', '.']
train
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L282-L307
5,118
CivicSpleen/ambry
ambry/bundle/bundle.py
Bundle._resolve_sources
def _resolve_sources(self, sources, tables, stage=None, predicate=None): """ Determine what sources to run from an input of sources and tables :param sources: A collection of source objects, source names, or source vids :param tables: A collection of table names :param stage: I...
python
def _resolve_sources(self, sources, tables, stage=None, predicate=None): """ Determine what sources to run from an input of sources and tables :param sources: A collection of source objects, source names, or source vids :param tables: A collection of table names :param stage: I...
['def', '_resolve_sources', '(', 'self', ',', 'sources', ',', 'tables', ',', 'stage', '=', 'None', ',', 'predicate', '=', 'None', ')', ':', 'assert', 'sources', 'is', 'None', 'or', 'tables', 'is', 'None', 'if', 'not', 'sources', ':', 'if', 'tables', ':', 'sources', '=', 'list', '(', 's', 'for', 's', 'in', 'self', '.', ...
Determine what sources to run from an input of sources and tables :param sources: A collection of source objects, source names, or source vids :param tables: A collection of table names :param stage: If not None, select only sources from this stage :param predicate: If not none, a call...
['Determine', 'what', 'sources', 'to', 'run', 'from', 'an', 'input', 'of', 'sources', 'and', 'tables']
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/bundle.py#L507-L544
5,119
fabioz/PyDev.Debugger
_pydev_imps/_pydev_SimpleXMLRPCServer.py
SimpleXMLRPCDispatcher.system_listMethods
def system_listMethods(self): """system.listMethods() => ['add', 'subtract', 'multiple'] Returns a list of the methods supported by the server.""" methods = self.funcs.keys() if self.instance is not None: # Instance can implement _listMethod to return a list of ...
python
def system_listMethods(self): """system.listMethods() => ['add', 'subtract', 'multiple'] Returns a list of the methods supported by the server.""" methods = self.funcs.keys() if self.instance is not None: # Instance can implement _listMethod to return a list of ...
['def', 'system_listMethods', '(', 'self', ')', ':', 'methods', '=', 'self', '.', 'funcs', '.', 'keys', '(', ')', 'if', 'self', '.', 'instance', 'is', 'not', 'None', ':', '# Instance can implement _listMethod to return a list of', '# methods', 'if', 'hasattr', '(', 'self', '.', 'instance', ',', "'_listMethods'", ')', '...
system.listMethods() => ['add', 'subtract', 'multiple'] Returns a list of the methods supported by the server.
['system', '.', 'listMethods', '()', '=', '>', '[', 'add', 'subtract', 'multiple', ']']
train
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_imps/_pydev_SimpleXMLRPCServer.py#L275-L296
5,120
mitsei/dlkit
dlkit/handcar/relationship/managers.py
RelationshipManager.get_family_admin_session
def get_family_admin_session(self): """Gets the ``OsidSession`` associated with the family administrative service. return: (osid.relationship.FamilyAdminSession) - a ``FamilyAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``sup...
python
def get_family_admin_session(self): """Gets the ``OsidSession`` associated with the family administrative service. return: (osid.relationship.FamilyAdminSession) - a ``FamilyAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``sup...
['def', 'get_family_admin_session', '(', 'self', ')', ':', 'if', 'not', 'self', '.', 'supports_family_admin', '(', ')', ':', 'raise', 'Unimplemented', '(', ')', 'try', ':', 'from', '.', 'import', 'sessions', 'except', 'ImportError', ':', 'raise', 'OperationFailed', '(', ')', 'try', ':', 'session', '=', 'sessions', '.',...
Gets the ``OsidSession`` associated with the family administrative service. return: (osid.relationship.FamilyAdminSession) - a ``FamilyAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_family_admin()`` is ``false`` *co...
['Gets', 'the', 'OsidSession', 'associated', 'with', 'the', 'family', 'administrative', 'service', '.']
train
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/managers.py#L743-L764
5,121
mikemaccana/python-docx
docx.py
table
def table(contents, heading=True, colw=None, cwunit='dxa', tblw=0, twunit='auto', borders={}, celstyle=None): """ Return a table element based on specified parameters @param list contents: A list of lists describing contents. Every item in the list can be a string or a v...
python
def table(contents, heading=True, colw=None, cwunit='dxa', tblw=0, twunit='auto', borders={}, celstyle=None): """ Return a table element based on specified parameters @param list contents: A list of lists describing contents. Every item in the list can be a string or a v...
['def', 'table', '(', 'contents', ',', 'heading', '=', 'True', ',', 'colw', '=', 'None', ',', 'cwunit', '=', "'dxa'", ',', 'tblw', '=', '0', ',', 'twunit', '=', "'auto'", ',', 'borders', '=', '{', '}', ',', 'celstyle', '=', 'None', ')', ':', 'table', '=', 'makeelement', '(', "'tbl'", ')', 'columns', '=', 'len', '(', 'c...
Return a table element based on specified parameters @param list contents: A list of lists describing contents. Every item in the list can be a string or a valid XML element itself. It can also be a list. In that case all the listed elem...
['Return', 'a', 'table', 'element', 'based', 'on', 'specified', 'parameters']
train
https://github.com/mikemaccana/python-docx/blob/4c9b46dbebe3d2a9b82dbcd35af36584a36fd9fe/docx.py#L297-L431
5,122
FujiMakoto/IPS-Vagrant
ips_vagrant/common/__init__.py
cookiejar
def cookiejar(name='session'): """ Ready the CookieJar, loading a saved session if available @rtype: cookielib.LWPCookieJar """ log = logging.getLogger('ipsv.common.cookiejar') spath = os.path.join(config().get('Paths', 'Data'), '{n}.txt'.format(n=name)) cj = cookielib.LWPCookieJar(spath) ...
python
def cookiejar(name='session'): """ Ready the CookieJar, loading a saved session if available @rtype: cookielib.LWPCookieJar """ log = logging.getLogger('ipsv.common.cookiejar') spath = os.path.join(config().get('Paths', 'Data'), '{n}.txt'.format(n=name)) cj = cookielib.LWPCookieJar(spath) ...
['def', 'cookiejar', '(', 'name', '=', "'session'", ')', ':', 'log', '=', 'logging', '.', 'getLogger', '(', "'ipsv.common.cookiejar'", ')', 'spath', '=', 'os', '.', 'path', '.', 'join', '(', 'config', '(', ')', '.', 'get', '(', "'Paths'", ',', "'Data'", ')', ',', "'{n}.txt'", '.', 'format', '(', 'n', '=', 'name', ')', ...
Ready the CookieJar, loading a saved session if available @rtype: cookielib.LWPCookieJar
['Ready', 'the', 'CookieJar', 'loading', 'a', 'saved', 'session', 'if', 'available']
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/__init__.py#L88-L104
5,123
saltstack/salt
salt/modules/cp.py
recv
def recv(files, dest): ''' Used with salt-cp, pass the files dict, and the destination. This function receives small fast copy files from the master via salt-cp. It does not work via the CLI. ''' ret = {} for path, data in six.iteritems(files): if os.path.basename(path) == os.path.b...
python
def recv(files, dest): ''' Used with salt-cp, pass the files dict, and the destination. This function receives small fast copy files from the master via salt-cp. It does not work via the CLI. ''' ret = {} for path, data in six.iteritems(files): if os.path.basename(path) == os.path.b...
['def', 'recv', '(', 'files', ',', 'dest', ')', ':', 'ret', '=', '{', '}', 'for', 'path', ',', 'data', 'in', 'six', '.', 'iteritems', '(', 'files', ')', ':', 'if', 'os', '.', 'path', '.', 'basename', '(', 'path', ')', '==', 'os', '.', 'path', '.', 'basename', '(', 'dest', ')', 'and', 'not', 'os', '.', 'path', '.', 'isd...
Used with salt-cp, pass the files dict, and the destination. This function receives small fast copy files from the master via salt-cp. It does not work via the CLI.
['Used', 'with', 'salt', '-', 'cp', 'pass', 'the', 'files', 'dict', 'and', 'the', 'destination', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cp.py#L63-L89
5,124
alvarogzp/telegram-bot-framework
bot/action/util/format.py
UserFormatter.default_format
def default_format(self): """ Returns full name (first and last) if name is available. If not, returns username if available. If not available too, returns the user id as a string. """ user = self.user if user.first_name is not None: return self.full_n...
python
def default_format(self): """ Returns full name (first and last) if name is available. If not, returns username if available. If not available too, returns the user id as a string. """ user = self.user if user.first_name is not None: return self.full_n...
['def', 'default_format', '(', 'self', ')', ':', 'user', '=', 'self', '.', 'user', 'if', 'user', '.', 'first_name', 'is', 'not', 'None', ':', 'return', 'self', '.', 'full_name', 'elif', 'user', '.', 'username', 'is', 'not', 'None', ':', 'return', 'user', '.', 'username', 'else', ':', 'return', 'str', '(', 'user', '.', ...
Returns full name (first and last) if name is available. If not, returns username if available. If not available too, returns the user id as a string.
['Returns', 'full', 'name', '(', 'first', 'and', 'last', ')', 'if', 'name', 'is', 'available', '.', 'If', 'not', 'returns', 'username', 'if', 'available', '.', 'If', 'not', 'available', 'too', 'returns', 'the', 'user', 'id', 'as', 'a', 'string', '.']
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L31-L43
5,125
tanghaibao/jcvi
jcvi/apps/uclust.py
cons
def cons(f, mindepth): """ Makes a list of lists of reads at each site """ C = ClustFile(f) for data in C: names, seqs, nreps = zip(*data) total_nreps = sum(nreps) # Depth filter if total_nreps < mindepth: continue S = [] for name, seq, nr...
python
def cons(f, mindepth): """ Makes a list of lists of reads at each site """ C = ClustFile(f) for data in C: names, seqs, nreps = zip(*data) total_nreps = sum(nreps) # Depth filter if total_nreps < mindepth: continue S = [] for name, seq, nr...
['def', 'cons', '(', 'f', ',', 'mindepth', ')', ':', 'C', '=', 'ClustFile', '(', 'f', ')', 'for', 'data', 'in', 'C', ':', 'names', ',', 'seqs', ',', 'nreps', '=', 'zip', '(', '*', 'data', ')', 'total_nreps', '=', 'sum', '(', 'nreps', ')', '# Depth filter', 'if', 'total_nreps', '<', 'mindepth', ':', 'continue', 'S', '='...
Makes a list of lists of reads at each site
['Makes', 'a', 'list', 'of', 'lists', 'of', 'reads', 'at', 'each', 'site']
train
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/uclust.py#L639-L658
5,126
cloud-custodian/cloud-custodian
c7n/utils.py
camelResource
def camelResource(obj): """Some sources from apis return lowerCased where as describe calls always return TitleCase, this function turns the former to the later """ if not isinstance(obj, dict): return obj for k in list(obj.keys()): v = obj.pop(k) obj["%s%s" % (k[0].upper(),...
python
def camelResource(obj): """Some sources from apis return lowerCased where as describe calls always return TitleCase, this function turns the former to the later """ if not isinstance(obj, dict): return obj for k in list(obj.keys()): v = obj.pop(k) obj["%s%s" % (k[0].upper(),...
['def', 'camelResource', '(', 'obj', ')', ':', 'if', 'not', 'isinstance', '(', 'obj', ',', 'dict', ')', ':', 'return', 'obj', 'for', 'k', 'in', 'list', '(', 'obj', '.', 'keys', '(', ')', ')', ':', 'v', '=', 'obj', '.', 'pop', '(', 'k', ')', 'obj', '[', '"%s%s"', '%', '(', 'k', '[', '0', ']', '.', 'upper', '(', ')', ','...
Some sources from apis return lowerCased where as describe calls always return TitleCase, this function turns the former to the later
['Some', 'sources', 'from', 'apis', 'return', 'lowerCased', 'where', 'as', 'describe', 'calls']
train
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L214-L228
5,127
JoseAntFer/pyny3d
pyny3d/geoms.py
Space.explode_map
def explode_map(self, map_): """ Much faster version of ``pyny.Space.explode()`` method for previously locked ``pyny.Space``. :param map_: the points, and the same order, that appear at ``pyny.Space.get_map()``. There is no need for the index if ...
python
def explode_map(self, map_): """ Much faster version of ``pyny.Space.explode()`` method for previously locked ``pyny.Space``. :param map_: the points, and the same order, that appear at ``pyny.Space.get_map()``. There is no need for the index if ...
['def', 'explode_map', '(', 'self', ',', 'map_', ')', ':', 'if', 'self', '.', 'explode_map_schedule', 'is', 'None', ':', 'index', '=', 'map_', '[', '0', ']', 'points', '=', 'map_', '[', '1', ']', '# points\r', 'k', '=', 'index', '[', ':', ',', '1', ']', '==', '-', '1', 'sop', '=', 'points', '[', 'k', ']', '# Set of poi...
Much faster version of ``pyny.Space.explode()`` method for previously locked ``pyny.Space``. :param map_: the points, and the same order, that appear at ``pyny.Space.get_map()``. There is no need for the index if locked. :type map_: ndarray (shape=(N, 3)...
['Much', 'faster', 'version', 'of', 'pyny', '.', 'Space', '.', 'explode', '()', 'method', 'for', 'previously', 'locked', 'pyny', '.', 'Space', '.', ':', 'param', 'map_', ':', 'the', 'points', 'and', 'the', 'same', 'order', 'that', 'appear', 'at', 'pyny', '.', 'Space', '.', 'get_map', '()', '.', 'There', 'is', 'no', 'ne...
train
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L2076-L2134
5,128
awslabs/serverless-application-model
samtranslator/model/eventsources/push.py
S3.to_cloudformation
def to_cloudformation(self, **kwargs): """Returns the Lambda Permission resource allowing S3 to invoke the function this event source triggers. :param dict kwargs: S3 bucket resource :returns: a list of vanilla CloudFormation Resources, to which this S3 event expands :rtype: list ...
python
def to_cloudformation(self, **kwargs): """Returns the Lambda Permission resource allowing S3 to invoke the function this event source triggers. :param dict kwargs: S3 bucket resource :returns: a list of vanilla CloudFormation Resources, to which this S3 event expands :rtype: list ...
['def', 'to_cloudformation', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'function', '=', 'kwargs', '.', 'get', '(', "'function'", ')', 'if', 'not', 'function', ':', 'raise', 'TypeError', '(', '"Missing required keyword argument: function"', ')', 'if', "'bucket'", 'not', 'in', 'kwargs', 'or', 'kwargs', '[', "'bucke...
Returns the Lambda Permission resource allowing S3 to invoke the function this event source triggers. :param dict kwargs: S3 bucket resource :returns: a list of vanilla CloudFormation Resources, to which this S3 event expands :rtype: list
['Returns', 'the', 'Lambda', 'Permission', 'resource', 'allowing', 'S3', 'to', 'invoke', 'the', 'function', 'this', 'event', 'source', 'triggers', '.']
train
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/eventsources/push.py#L197-L241
5,129
lowandrew/OLCTools
databasesetup/database_setup.py
DatabaseSetup.clark
def clark(self, databasepath): """ Download and set-up the CLARK database using the set_targets.sh script. Use defaults of bacteria for database type, and species for taxonomic level :param databasepath: path to use to save the database """ if self.clarkpath: ...
python
def clark(self, databasepath): """ Download and set-up the CLARK database using the set_targets.sh script. Use defaults of bacteria for database type, and species for taxonomic level :param databasepath: path to use to save the database """ if self.clarkpath: ...
['def', 'clark', '(', 'self', ',', 'databasepath', ')', ':', 'if', 'self', '.', 'clarkpath', ':', 'logging', '.', 'info', '(', "'Downloading CLARK database'", ')', '# Create the folder in which the database is to be stored', 'databasepath', '=', 'self', '.', 'create_database_folder', '(', 'databasepath', ',', "'clark'"...
Download and set-up the CLARK database using the set_targets.sh script. Use defaults of bacteria for database type, and species for taxonomic level :param databasepath: path to use to save the database
['Download', 'and', 'set', '-', 'up', 'the', 'CLARK', 'database', 'using', 'the', 'set_targets', '.', 'sh', 'script', '.', 'Use', 'defaults', 'of', 'bacteria', 'for', 'database', 'type', 'and', 'species', 'for', 'taxonomic', 'level', ':', 'param', 'databasepath', ':', 'path', 'to', 'use', 'to', 'save', 'the', 'database...
train
https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/database_setup.py#L197-L214
5,130
AltSchool/dynamic-rest
dynamic_rest/fields/fields.py
DynamicRelationField.get_serializer
def get_serializer(self, *args, **kwargs): """Get an instance of the child serializer.""" init_args = { k: v for k, v in six.iteritems(self.kwargs) if k in self.SERIALIZER_KWARGS } kwargs = self._inherit_parent_kwargs(kwargs) init_args.update(kwargs) ...
python
def get_serializer(self, *args, **kwargs): """Get an instance of the child serializer.""" init_args = { k: v for k, v in six.iteritems(self.kwargs) if k in self.SERIALIZER_KWARGS } kwargs = self._inherit_parent_kwargs(kwargs) init_args.update(kwargs) ...
['def', 'get_serializer', '(', 'self', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'init_args', '=', '{', 'k', ':', 'v', 'for', 'k', ',', 'v', 'in', 'six', '.', 'iteritems', '(', 'self', '.', 'kwargs', ')', 'if', 'k', 'in', 'self', '.', 'SERIALIZER_KWARGS', '}', 'kwargs', '=', 'self', '.', '_inherit_parent_kwa...
Get an instance of the child serializer.
['Get', 'an', 'instance', 'of', 'the', 'child', 'serializer', '.']
train
https://github.com/AltSchool/dynamic-rest/blob/5b0338c3dd8bc638d60c3bb92645857c5b89c920/dynamic_rest/fields/fields.py#L241-L254
5,131
aguinane/nem-reader
print_examples.py
print_meter_record
def print_meter_record(file_path, rows=5): """ Output readings for specified number of rows to console """ m = nr.read_nem_file(file_path) print('Header:', m.header) print('Transactions:', m.transactions) for nmi in m.readings: for channel in m.readings[nmi]: print(nmi, 'Channel'...
python
def print_meter_record(file_path, rows=5): """ Output readings for specified number of rows to console """ m = nr.read_nem_file(file_path) print('Header:', m.header) print('Transactions:', m.transactions) for nmi in m.readings: for channel in m.readings[nmi]: print(nmi, 'Channel'...
['def', 'print_meter_record', '(', 'file_path', ',', 'rows', '=', '5', ')', ':', 'm', '=', 'nr', '.', 'read_nem_file', '(', 'file_path', ')', 'print', '(', "'Header:'", ',', 'm', '.', 'header', ')', 'print', '(', "'Transactions:'", ',', 'm', '.', 'transactions', ')', 'for', 'nmi', 'in', 'm', '.', 'readings', ':', 'for'...
Output readings for specified number of rows to console
['Output', 'readings', 'for', 'specified', 'number', 'of', 'rows', 'to', 'console']
train
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/print_examples.py#L4-L13
5,132
taskcluster/taskcluster-client.py
taskcluster/queueevents.py
QueueEvents.taskRunning
def taskRunning(self, *args, **kwargs): """ Task Running Messages Whenever a task is claimed by a worker, a run is started on the worker, and a message is posted on this exchange. This exchange outputs: ``v1/task-running-message.json#``This exchange takes the following keys: ...
python
def taskRunning(self, *args, **kwargs): """ Task Running Messages Whenever a task is claimed by a worker, a run is started on the worker, and a message is posted on this exchange. This exchange outputs: ``v1/task-running-message.json#``This exchange takes the following keys: ...
['def', 'taskRunning', '(', 'self', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'ref', '=', '{', "'exchange'", ':', "'task-running'", ',', "'name'", ':', "'taskRunning'", ',', "'routingKey'", ':', '[', '{', "'constant'", ':', "'primary'", ',', "'multipleWords'", ':', 'False', ',', "'name'", ':', "'routingKeyKi...
Task Running Messages Whenever a task is claimed by a worker, a run is started on the worker, and a message is posted on this exchange. This exchange outputs: ``v1/task-running-message.json#``This exchange takes the following keys: * routingKeyKind: Identifier for the routing-key kin...
['Task', 'Running', 'Messages']
train
https://github.com/taskcluster/taskcluster-client.py/blob/bcc95217f8bf80bed2ae5885a19fa0035da7ebc9/taskcluster/queueevents.py#L242-L320
5,133
scanny/python-pptx
pptx/api.py
Presentation
def Presentation(pptx=None): """ Return a |Presentation| object loaded from *pptx*, where *pptx* can be either a path to a ``.pptx`` file (a string) or a file-like object. If *pptx* is missing or ``None``, the built-in default presentation "template" is loaded. """ if pptx is None: p...
python
def Presentation(pptx=None): """ Return a |Presentation| object loaded from *pptx*, where *pptx* can be either a path to a ``.pptx`` file (a string) or a file-like object. If *pptx* is missing or ``None``, the built-in default presentation "template" is loaded. """ if pptx is None: p...
['def', 'Presentation', '(', 'pptx', '=', 'None', ')', ':', 'if', 'pptx', 'is', 'None', ':', 'pptx', '=', '_default_pptx_path', '(', ')', 'presentation_part', '=', 'Package', '.', 'open', '(', 'pptx', ')', '.', 'main_document_part', 'if', 'not', '_is_pptx_package', '(', 'presentation_part', ')', ':', 'tmpl', '=', '"fil...
Return a |Presentation| object loaded from *pptx*, where *pptx* can be either a path to a ``.pptx`` file (a string) or a file-like object. If *pptx* is missing or ``None``, the built-in default presentation "template" is loaded.
['Return', 'a', '|Presentation|', 'object', 'loaded', 'from', '*', 'pptx', '*', 'where', '*', 'pptx', '*', 'can', 'be', 'either', 'a', 'path', 'to', 'a', '.', 'pptx', 'file', '(', 'a', 'string', ')', 'or', 'a', 'file', '-', 'like', 'object', '.', 'If', '*', 'pptx', '*', 'is', 'missing', 'or', 'None', 'the', 'built', '-...
train
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/api.py#L20-L36
5,134
wangsix/vmo
vmo/generate.py
generate
def generate(oracle, seq_len, p=0.5, k=1, LRS=0, weight=None): """ Generate a sequence based on traversing an oracle. :param oracle: a indexed vmo object :param seq_len: the length of the returned improvisation sequence :param p: a float between (0,1) representing the probability using the forward link...
python
def generate(oracle, seq_len, p=0.5, k=1, LRS=0, weight=None): """ Generate a sequence based on traversing an oracle. :param oracle: a indexed vmo object :param seq_len: the length of the returned improvisation sequence :param p: a float between (0,1) representing the probability using the forward link...
['def', 'generate', '(', 'oracle', ',', 'seq_len', ',', 'p', '=', '0.5', ',', 'k', '=', '1', ',', 'LRS', '=', '0', ',', 'weight', '=', 'None', ')', ':', 'trn', '=', 'oracle', '.', 'trn', '[', ':', ']', 'sfx', '=', 'oracle', '.', 'sfx', '[', ':', ']', 'lrs', '=', 'oracle', '.', 'lrs', '[', ':', ']', 'rsfx', '=', 'oracle...
Generate a sequence based on traversing an oracle. :param oracle: a indexed vmo object :param seq_len: the length of the returned improvisation sequence :param p: a float between (0,1) representing the probability using the forward links. :param k: the starting improvisation time step in oracle :pa...
['Generate', 'a', 'sequence', 'based', 'on', 'traversing', 'an', 'oracle', '.']
train
https://github.com/wangsix/vmo/blob/bb1cc4cf1f33f0bb49e38c91126c1be1a0cdd09d/vmo/generate.py#L106-L204
5,135
resonai/ybt
yabt/extend.py
Plugin.remove_builder
def remove_builder(cls, builder_name: str): """Remove a registered builder `builder_name`. No reason to use this except for tests. """ cls.builders.pop(builder_name, None) for hook_spec in cls.hooks.values(): hook_spec.pop(builder_name, None)
python
def remove_builder(cls, builder_name: str): """Remove a registered builder `builder_name`. No reason to use this except for tests. """ cls.builders.pop(builder_name, None) for hook_spec in cls.hooks.values(): hook_spec.pop(builder_name, None)
['def', 'remove_builder', '(', 'cls', ',', 'builder_name', ':', 'str', ')', ':', 'cls', '.', 'builders', '.', 'pop', '(', 'builder_name', ',', 'None', ')', 'for', 'hook_spec', 'in', 'cls', '.', 'hooks', '.', 'values', '(', ')', ':', 'hook_spec', '.', 'pop', '(', 'builder_name', ',', 'None', ')']
Remove a registered builder `builder_name`. No reason to use this except for tests.
['Remove', 'a', 'registered', 'builder', 'builder_name', '.']
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/extend.py#L198-L205
5,136
quadrismegistus/prosodic
prosodic/Text.py
Text.validlines
def validlines(self): """Return all lines within which Prosodic understood all words.""" return [ln for ln in self.lines() if (not ln.isBroken() and not ln.ignoreMe)]
python
def validlines(self): """Return all lines within which Prosodic understood all words.""" return [ln for ln in self.lines() if (not ln.isBroken() and not ln.ignoreMe)]
['def', 'validlines', '(', 'self', ')', ':', 'return', '[', 'ln', 'for', 'ln', 'in', 'self', '.', 'lines', '(', ')', 'if', '(', 'not', 'ln', '.', 'isBroken', '(', ')', 'and', 'not', 'ln', '.', 'ignoreMe', ')', ']']
Return all lines within which Prosodic understood all words.
['Return', 'all', 'lines', 'within', 'which', 'Prosodic', 'understood', 'all', 'words', '.']
train
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/Text.py#L843-L846
5,137
Autodesk/pyccc
pyccc/engines/subproc.py
Subprocess._check_file_is_under_workingdir
def _check_file_is_under_workingdir(filename, wdir): """ Raise error if input is being staged to a location not underneath the working dir """ p = filename if not os.path.isabs(p): p = os.path.join(wdir, p) targetpath = os.path.realpath(p) wdir = os.path.realp...
python
def _check_file_is_under_workingdir(filename, wdir): """ Raise error if input is being staged to a location not underneath the working dir """ p = filename if not os.path.isabs(p): p = os.path.join(wdir, p) targetpath = os.path.realpath(p) wdir = os.path.realp...
['def', '_check_file_is_under_workingdir', '(', 'filename', ',', 'wdir', ')', ':', 'p', '=', 'filename', 'if', 'not', 'os', '.', 'path', '.', 'isabs', '(', 'p', ')', ':', 'p', '=', 'os', '.', 'path', '.', 'join', '(', 'wdir', ',', 'p', ')', 'targetpath', '=', 'os', '.', 'path', '.', 'realpath', '(', 'p', ')', 'wdir', '...
Raise error if input is being staged to a location not underneath the working dir
['Raise', 'error', 'if', 'input', 'is', 'being', 'staged', 'to', 'a', 'location', 'not', 'underneath', 'the', 'working', 'dir']
train
https://github.com/Autodesk/pyccc/blob/011698e78d49a83ac332e0578a4a2a865b75ef8d/pyccc/engines/subproc.py#L89-L101
5,138
samjabrahams/anchorhub
anchorhub/messages.py
print_duplicate_anchor_information
def print_duplicate_anchor_information(duplicate_tags): """ Prints information about duplicate AnchorHub tags found during collection. :param duplicate_tags: Dictionary mapping string file path keys to a list of tuples. The tuples contain the following information, in order: 1. The string ...
python
def print_duplicate_anchor_information(duplicate_tags): """ Prints information about duplicate AnchorHub tags found during collection. :param duplicate_tags: Dictionary mapping string file path keys to a list of tuples. The tuples contain the following information, in order: 1. The string ...
['def', 'print_duplicate_anchor_information', '(', 'duplicate_tags', ')', ':', 'print', '(', '"Duplicate anchors specified within file(s)"', ')', 'print', '(', '"Please modify your code to remove duplicates.\\r\\n"', ')', 'for', 'file_path', 'in', 'duplicate_tags', ':', 'print', '(', '"File: "', '+', 'file_path', ')', ...
Prints information about duplicate AnchorHub tags found during collection. :param duplicate_tags: Dictionary mapping string file path keys to a list of tuples. The tuples contain the following information, in order: 1. The string AnchorHub tag that was repeated 2. The line in the file that...
['Prints', 'information', 'about', 'duplicate', 'AnchorHub', 'tags', 'found', 'during', 'collection', '.']
train
https://github.com/samjabrahams/anchorhub/blob/5ade359b08297d4003a5f477389c01de9e634b54/anchorhub/messages.py#L50-L68
5,139
scanny/python-pptx
pptx/oxml/chart/datalabel.py
CT_DLbl.remove_tx_rich
def remove_tx_rich(self): """ Remove any `c:tx[c:rich]` child, or do nothing if not present. """ matches = self.xpath('c:tx[c:rich]') if not matches: return tx = matches[0] self.remove(tx)
python
def remove_tx_rich(self): """ Remove any `c:tx[c:rich]` child, or do nothing if not present. """ matches = self.xpath('c:tx[c:rich]') if not matches: return tx = matches[0] self.remove(tx)
['def', 'remove_tx_rich', '(', 'self', ')', ':', 'matches', '=', 'self', '.', 'xpath', '(', "'c:tx[c:rich]'", ')', 'if', 'not', 'matches', ':', 'return', 'tx', '=', 'matches', '[', '0', ']', 'self', '.', 'remove', '(', 'tx', ')']
Remove any `c:tx[c:rich]` child, or do nothing if not present.
['Remove', 'any', 'c', ':', 'tx', '[', 'c', ':', 'rich', ']', 'child', 'or', 'do', 'nothing', 'if', 'not', 'present', '.']
train
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/oxml/chart/datalabel.py#L95-L103
5,140
nickmckay/LiPD-utilities
Python/lipd/bag.py
create_bag
def create_bag(dir_bag): """ Create a Bag out of given files. :param str dir_bag: Directory that contains csv, jsonld, and changelog files. :return obj: Bag """ logger_bagit.info("enter create_bag") # if not dir_bag: # dir_bag = os.getcwd() try: bag = bagit.make_bag(dir_b...
python
def create_bag(dir_bag): """ Create a Bag out of given files. :param str dir_bag: Directory that contains csv, jsonld, and changelog files. :return obj: Bag """ logger_bagit.info("enter create_bag") # if not dir_bag: # dir_bag = os.getcwd() try: bag = bagit.make_bag(dir_b...
['def', 'create_bag', '(', 'dir_bag', ')', ':', 'logger_bagit', '.', 'info', '(', '"enter create_bag"', ')', '# if not dir_bag:', '# dir_bag = os.getcwd()', 'try', ':', 'bag', '=', 'bagit', '.', 'make_bag', '(', 'dir_bag', ',', '{', "'Name'", ':', "'LiPD Project'", ',', "'Reference'", ':', "'www.lipds.net'", ',', "...
Create a Bag out of given files. :param str dir_bag: Directory that contains csv, jsonld, and changelog files. :return obj: Bag
['Create', 'a', 'Bag', 'out', 'of', 'given', 'files', '.', ':', 'param', 'str', 'dir_bag', ':', 'Directory', 'that', 'contains', 'csv', 'jsonld', 'and', 'changelog', 'files', '.', ':', 'return', 'obj', ':', 'Bag']
train
https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/bag.py#L8-L27
5,141
lorien/grab
grab/spider/task.py
Task.clone
def clone(self, **kwargs): """ Clone Task instance. Reset network_try_count, increase task_try_count. Reset priority attribute if it was not set explicitly. """ # First, create exact copy of the current Task object attr_copy = self.__dict__.copy() if att...
python
def clone(self, **kwargs): """ Clone Task instance. Reset network_try_count, increase task_try_count. Reset priority attribute if it was not set explicitly. """ # First, create exact copy of the current Task object attr_copy = self.__dict__.copy() if att...
['def', 'clone', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', '# First, create exact copy of the current Task object', 'attr_copy', '=', 'self', '.', '__dict__', '.', 'copy', '(', ')', 'if', 'attr_copy', '.', 'get', '(', "'grab_config'", ')', 'is', 'not', 'None', ':', 'del', 'attr_copy', '[', "'url'", ']', 'if', 'no...
Clone Task instance. Reset network_try_count, increase task_try_count. Reset priority attribute if it was not set explicitly.
['Clone', 'Task', 'instance', '.']
train
https://github.com/lorien/grab/blob/8b301db2a08c830245b61c589e58af6234f4db79/grab/spider/task.py#L170-L228
5,142
eandersson/amqpstorm
amqpstorm/channel.py
Channel.write_frames
def write_frames(self, frames_out): """Write multiple pamqp frames from the current channel. :param list frames_out: A list of pamqp frames. :return: """ self.check_for_errors() self._connection.write_frames(self.channel_id, frames_out)
python
def write_frames(self, frames_out): """Write multiple pamqp frames from the current channel. :param list frames_out: A list of pamqp frames. :return: """ self.check_for_errors() self._connection.write_frames(self.channel_id, frames_out)
['def', 'write_frames', '(', 'self', ',', 'frames_out', ')', ':', 'self', '.', 'check_for_errors', '(', ')', 'self', '.', '_connection', '.', 'write_frames', '(', 'self', '.', 'channel_id', ',', 'frames_out', ')']
Write multiple pamqp frames from the current channel. :param list frames_out: A list of pamqp frames. :return:
['Write', 'multiple', 'pamqp', 'frames', 'from', 'the', 'current', 'channel', '.']
train
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/channel.py#L346-L354
5,143
gnullByte/dotcolors
dotcolors/getdots.py
get_urls
def get_urls(htmlDoc, limit=200): '''takes in html document as string, returns links to dots''' soup = BeautifulSoup( htmlDoc ) anchors = soup.findAll( 'a' ) urls = {} counter = 0 for i,v in enumerate( anchors ): href = anchors[i].get( 'href' ) if ('dots' in href and counter <...
python
def get_urls(htmlDoc, limit=200): '''takes in html document as string, returns links to dots''' soup = BeautifulSoup( htmlDoc ) anchors = soup.findAll( 'a' ) urls = {} counter = 0 for i,v in enumerate( anchors ): href = anchors[i].get( 'href' ) if ('dots' in href and counter <...
['def', 'get_urls', '(', 'htmlDoc', ',', 'limit', '=', '200', ')', ':', 'soup', '=', 'BeautifulSoup', '(', 'htmlDoc', ')', 'anchors', '=', 'soup', '.', 'findAll', '(', "'a'", ')', 'urls', '=', '{', '}', 'counter', '=', '0', 'for', 'i', ',', 'v', 'in', 'enumerate', '(', 'anchors', ')', ':', 'href', '=', 'anchors', '[', ...
takes in html document as string, returns links to dots
['takes', 'in', 'html', 'document', 'as', 'string', 'returns', 'links', 'to', 'dots']
train
https://github.com/gnullByte/dotcolors/blob/4b09ff9862b88b3125fe9cd86aa054694ed3e46e/dotcolors/getdots.py#L42-L59
5,144
kylejusticemagnuson/pyti
pyti/exponential_moving_average.py
exponential_moving_average
def exponential_moving_average(data, period): """ Exponential Moving Average. Formula: p0 + (1 - w) * p1 + (1 - w)^2 * p2 + (1 + w)^3 * p3 +... / 1 + (1 - w) + (1 - w)^2 + (1 - w)^3 +... where: w = 2 / (N + 1) """ catch_errors.check_for_period_error(data, period) emas...
python
def exponential_moving_average(data, period): """ Exponential Moving Average. Formula: p0 + (1 - w) * p1 + (1 - w)^2 * p2 + (1 + w)^3 * p3 +... / 1 + (1 - w) + (1 - w)^2 + (1 - w)^3 +... where: w = 2 / (N + 1) """ catch_errors.check_for_period_error(data, period) emas...
['def', 'exponential_moving_average', '(', 'data', ',', 'period', ')', ':', 'catch_errors', '.', 'check_for_period_error', '(', 'data', ',', 'period', ')', 'emas', '=', '[', 'exponential_moving_average_helper', '(', 'data', '[', 'idx', '-', 'period', '+', '1', ':', 'idx', '+', '1', ']', ',', 'period', ')', 'for', 'idx'...
Exponential Moving Average. Formula: p0 + (1 - w) * p1 + (1 - w)^2 * p2 + (1 + w)^3 * p3 +... / 1 + (1 - w) + (1 - w)^2 + (1 - w)^3 +... where: w = 2 / (N + 1)
['Exponential', 'Moving', 'Average', '.']
train
https://github.com/kylejusticemagnuson/pyti/blob/2f78430dfd60a0d20f4e7fc0cb4588c03107c4b2/pyti/exponential_moving_average.py#L7-L21
5,145
exxeleron/qPython
qpython/qconnection.py
QConnection.sendSync
def sendSync(self, query, *parameters, **options): '''Performs a synchronous query against a q service and returns parsed data. In typical use case, `query` is the name of the function to call and `parameters` are its parameters. When `parameters` list is empty, the q...
python
def sendSync(self, query, *parameters, **options): '''Performs a synchronous query against a q service and returns parsed data. In typical use case, `query` is the name of the function to call and `parameters` are its parameters. When `parameters` list is empty, the q...
['def', 'sendSync', '(', 'self', ',', 'query', ',', '*', 'parameters', ',', '*', '*', 'options', ')', ':', 'self', '.', 'query', '(', 'MessageType', '.', 'SYNC', ',', 'query', ',', '*', 'parameters', ',', '*', '*', 'options', ')', 'response', '=', 'self', '.', 'receive', '(', 'data_only', '=', 'False', ',', '*', '*', '...
Performs a synchronous query against a q service and returns parsed data. In typical use case, `query` is the name of the function to call and `parameters` are its parameters. When `parameters` list is empty, the query can be an arbitrary q expression (e.g. ``0 +/ til 100``)....
['Performs', 'a', 'synchronous', 'query', 'against', 'a', 'q', 'service', 'and', 'returns', 'parsed', 'data', '.', 'In', 'typical', 'use', 'case', 'query', 'is', 'the', 'name', 'of', 'the', 'function', 'to', 'call', 'and', 'parameters', 'are', 'its', 'parameters', '.', 'When', 'parameters', 'list', 'is', 'empty', 'the'...
train
https://github.com/exxeleron/qPython/blob/7e64a28b1e8814a8d6b9217ce79bb8de546e62f3/qpython/qconnection.py#L248-L309
5,146
dw/mitogen
mitogen/parent.py
Stream.construct
def construct(self, max_message_size, remote_name=None, python_path=None, debug=False, connect_timeout=None, profiling=False, unidirectional=False, old_router=None, **kwargs): """Get the named context running on the local machine, creating it if it does not exist.""" ...
python
def construct(self, max_message_size, remote_name=None, python_path=None, debug=False, connect_timeout=None, profiling=False, unidirectional=False, old_router=None, **kwargs): """Get the named context running on the local machine, creating it if it does not exist.""" ...
['def', 'construct', '(', 'self', ',', 'max_message_size', ',', 'remote_name', '=', 'None', ',', 'python_path', '=', 'None', ',', 'debug', '=', 'False', ',', 'connect_timeout', '=', 'None', ',', 'profiling', '=', 'False', ',', 'unidirectional', '=', 'False', ',', 'old_router', '=', 'None', ',', '*', '*', 'kwargs', ')',...
Get the named context running on the local machine, creating it if it does not exist.
['Get', 'the', 'named', 'context', 'running', 'on', 'the', 'local', 'machine', 'creating', 'it', 'if', 'it', 'does', 'not', 'exist', '.']
train
https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/parent.py#L1210-L1230
5,147
ludwiktrammer/applamp
applamp/rgb.py
RgbLight.fade_out
def fade_out(self, duration=3): """Turns off the light by gradually fading it out. The optional `duration` parameter allows for control of the fade out duration (in seconds)""" super(RgbLight, self).fade_out(duration) self.off()
python
def fade_out(self, duration=3): """Turns off the light by gradually fading it out. The optional `duration` parameter allows for control of the fade out duration (in seconds)""" super(RgbLight, self).fade_out(duration) self.off()
['def', 'fade_out', '(', 'self', ',', 'duration', '=', '3', ')', ':', 'super', '(', 'RgbLight', ',', 'self', ')', '.', 'fade_out', '(', 'duration', ')', 'self', '.', 'off', '(', ')']
Turns off the light by gradually fading it out. The optional `duration` parameter allows for control of the fade out duration (in seconds)
['Turns', 'off', 'the', 'light', 'by', 'gradually', 'fading', 'it', 'out', '.', 'The', 'optional', 'duration', 'parameter', 'allows', 'for', 'control', 'of', 'the', 'fade', 'out', 'duration', '(', 'in', 'seconds', ')']
train
https://github.com/ludwiktrammer/applamp/blob/90d7d463826f0c8dcd33dfdbc5efc9fa44b0b484/applamp/rgb.py#L51-L56
5,148
pgjones/quart
quart/app.py
Quart.make_default_options_response
async def make_default_options_response(self) -> Response: """This is the default route function for OPTIONS requests.""" methods = _request_ctx_stack.top.url_adapter.allowed_methods() return self.response_class('', headers={'Allow': ', '.join(methods)})
python
async def make_default_options_response(self) -> Response: """This is the default route function for OPTIONS requests.""" methods = _request_ctx_stack.top.url_adapter.allowed_methods() return self.response_class('', headers={'Allow': ', '.join(methods)})
['async', 'def', 'make_default_options_response', '(', 'self', ')', '->', 'Response', ':', 'methods', '=', '_request_ctx_stack', '.', 'top', '.', 'url_adapter', '.', 'allowed_methods', '(', ')', 'return', 'self', '.', 'response_class', '(', "''", ',', 'headers', '=', '{', "'Allow'", ':', "', '", '.', 'join', '(', 'meth...
This is the default route function for OPTIONS requests.
['This', 'is', 'the', 'default', 'route', 'function', 'for', 'OPTIONS', 'requests', '.']
train
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1456-L1459
5,149
qubell/contrib-python-qubell-client
qubell/monitor/monitor.py
Monitor.launch
def launch(self, timeout=2): """ Hierapp instance, with environment dependencies: - can be launched within short timeout - auto-destroys shortly """ self.start_time = time.time() self.end_time = time.time() instance = self.app.launch(environment=self.env) ...
python
def launch(self, timeout=2): """ Hierapp instance, with environment dependencies: - can be launched within short timeout - auto-destroys shortly """ self.start_time = time.time() self.end_time = time.time() instance = self.app.launch(environment=self.env) ...
['def', 'launch', '(', 'self', ',', 'timeout', '=', '2', ')', ':', 'self', '.', 'start_time', '=', 'time', '.', 'time', '(', ')', 'self', '.', 'end_time', '=', 'time', '.', 'time', '(', ')', 'instance', '=', 'self', '.', 'app', '.', 'launch', '(', 'environment', '=', 'self', '.', 'env', ')', 'time', '.', 'sleep', '(', ...
Hierapp instance, with environment dependencies: - can be launched within short timeout - auto-destroys shortly
['Hierapp', 'instance', 'with', 'environment', 'dependencies', ':', '-', 'can', 'be', 'launched', 'within', 'short', 'timeout', '-', 'auto', '-', 'destroys', 'shortly']
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/monitor/monitor.py#L138-L156
5,150
gccxml/pygccxml
pygccxml/declarations/traits_impl_details.py
impl_details.find_value_type
def find_value_type(global_ns, value_type_str): """implementation details""" if not value_type_str.startswith('::'): value_type_str = '::' + value_type_str found = global_ns.decls( name=value_type_str, function=lambda decl: not isinstance(decl, calldef.calldef...
python
def find_value_type(global_ns, value_type_str): """implementation details""" if not value_type_str.startswith('::'): value_type_str = '::' + value_type_str found = global_ns.decls( name=value_type_str, function=lambda decl: not isinstance(decl, calldef.calldef...
['def', 'find_value_type', '(', 'global_ns', ',', 'value_type_str', ')', ':', 'if', 'not', 'value_type_str', '.', 'startswith', '(', "'::'", ')', ':', 'value_type_str', '=', "'::'", '+', 'value_type_str', 'found', '=', 'global_ns', '.', 'decls', '(', 'name', '=', 'value_type_str', ',', 'function', '=', 'lambda', 'decl'...
implementation details
['implementation', 'details']
train
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/traits_impl_details.py#L45-L88
5,151
iwanbk/nyamuk
nyamuk/nyamuk.py
Nyamuk.unsubscribe
def unsubscribe(self, topic): """Unsubscribe to some topic.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("UNSUBSCRIBE: %s", topic) return self.send_unsubscribe(False, [utf8encode(topic)])
python
def unsubscribe(self, topic): """Unsubscribe to some topic.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("UNSUBSCRIBE: %s", topic) return self.send_unsubscribe(False, [utf8encode(topic)])
['def', 'unsubscribe', '(', 'self', ',', 'topic', ')', ':', 'if', 'self', '.', 'sock', '==', 'NC', '.', 'INVALID_SOCKET', ':', 'return', 'NC', '.', 'ERR_NO_CONN', 'self', '.', 'logger', '.', 'info', '(', '"UNSUBSCRIBE: %s"', ',', 'topic', ')', 'return', 'self', '.', 'send_unsubscribe', '(', 'False', ',', '[', 'utf8enco...
Unsubscribe to some topic.
['Unsubscribe', 'to', 'some', 'topic', '.']
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L212-L218
5,152
ynop/audiomate
audiomate/containers/audio.py
AudioContainer.set
def set(self, key, samples, sampling_rate): """ Set the samples and sampling-rate for the given key. Existing data will be overwritten. The samples have to have ``np.float32`` datatype and values in the range of -1.0 and 1.0. Args: key (str): A key to store t...
python
def set(self, key, samples, sampling_rate): """ Set the samples and sampling-rate for the given key. Existing data will be overwritten. The samples have to have ``np.float32`` datatype and values in the range of -1.0 and 1.0. Args: key (str): A key to store t...
['def', 'set', '(', 'self', ',', 'key', ',', 'samples', ',', 'sampling_rate', ')', ':', 'if', 'not', 'np', '.', 'issubdtype', '(', 'samples', '.', 'dtype', ',', 'np', '.', 'floating', ')', ':', 'raise', 'ValueError', '(', "'Samples are required as np.float32!'", ')', 'if', 'len', '(', 'samples', '.', 'shape', ')', '>',...
Set the samples and sampling-rate for the given key. Existing data will be overwritten. The samples have to have ``np.float32`` datatype and values in the range of -1.0 and 1.0. Args: key (str): A key to store the data for. samples (numpy.ndarray): 1-D array of a...
['Set', 'the', 'samples', 'and', 'sampling', '-', 'rate', 'for', 'the', 'given', 'key', '.', 'Existing', 'data', 'will', 'be', 'overwritten', '.', 'The', 'samples', 'have', 'to', 'have', 'np', '.', 'float32', 'datatype', 'and', 'values', 'in', 'the', 'range', 'of', '-', '1', '.', '0', 'and', '1', '.', '0', '.']
train
https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/audio.py#L48-L77
5,153
python-wink/python-wink
src/pywink/devices/siren.py
WinkSiren.set_chime_volume
def set_chime_volume(self, volume): """ :param volume: one of [low, medium, high] """ values = { "desired_state": { "chime_volume": volume } } response = self.api_interface.set_device_state(self, values) self._upda...
python
def set_chime_volume(self, volume): """ :param volume: one of [low, medium, high] """ values = { "desired_state": { "chime_volume": volume } } response = self.api_interface.set_device_state(self, values) self._upda...
['def', 'set_chime_volume', '(', 'self', ',', 'volume', ')', ':', 'values', '=', '{', '"desired_state"', ':', '{', '"chime_volume"', ':', 'volume', '}', '}', 'response', '=', 'self', '.', 'api_interface', '.', 'set_device_state', '(', 'self', ',', 'values', ')', 'self', '.', '_update_state_from_response', '(', 'respons...
:param volume: one of [low, medium, high]
[':', 'param', 'volume', ':', 'one', 'of', '[', 'low', 'medium', 'high', ']']
train
https://github.com/python-wink/python-wink/blob/cf8bdce8c6518f30b91b23aa7aa32e89c2ce48da/src/pywink/devices/siren.py#L51-L61
5,154
mikedh/trimesh
trimesh/path/path.py
Path.merge_vertices
def merge_vertices(self, digits=None): """ Merges vertices which are identical and replace references. Parameters -------------- digits : None, or int How many digits to consider when merging vertices Alters ----------- self.entities : entity.p...
python
def merge_vertices(self, digits=None): """ Merges vertices which are identical and replace references. Parameters -------------- digits : None, or int How many digits to consider when merging vertices Alters ----------- self.entities : entity.p...
['def', 'merge_vertices', '(', 'self', ',', 'digits', '=', 'None', ')', ':', 'if', 'len', '(', 'self', '.', 'vertices', ')', '==', '0', ':', 'return', 'if', 'digits', 'is', 'None', ':', 'digits', '=', 'util', '.', 'decimal_to_digits', '(', 'tol', '.', 'merge', '*', 'self', '.', 'scale', ',', 'min_digits', '=', '1', ')'...
Merges vertices which are identical and replace references. Parameters -------------- digits : None, or int How many digits to consider when merging vertices Alters ----------- self.entities : entity.points re- referenced self.vertices : duplicates rem...
['Merges', 'vertices', 'which', 'are', 'identical', 'and', 'replace', 'references', '.']
train
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/path/path.py#L485-L538
5,155
cggh/scikit-allel
allel/stats/window.py
windowed_statistic
def windowed_statistic(pos, values, statistic, size=None, start=None, stop=None, step=None, windows=None, fill=np.nan): """Calculate a statistic from items in windows over a single chromosome/contig. Parameters ---------- pos : array_like, int, shape (n_items,) The i...
python
def windowed_statistic(pos, values, statistic, size=None, start=None, stop=None, step=None, windows=None, fill=np.nan): """Calculate a statistic from items in windows over a single chromosome/contig. Parameters ---------- pos : array_like, int, shape (n_items,) The i...
['def', 'windowed_statistic', '(', 'pos', ',', 'values', ',', 'statistic', ',', 'size', '=', 'None', ',', 'start', '=', 'None', ',', 'stop', '=', 'None', ',', 'step', '=', 'None', ',', 'windows', '=', 'None', ',', 'fill', '=', 'np', '.', 'nan', ')', ':', '# assume sorted positions', 'if', 'not', 'isinstance', '(', 'pos...
Calculate a statistic from items in windows over a single chromosome/contig. Parameters ---------- pos : array_like, int, shape (n_items,) The item positions in ascending order, using 1-based coordinates.. values : array_like, int, shape (n_items,) The values to summarise. May also...
['Calculate', 'a', 'statistic', 'from', 'items', 'in', 'windows', 'over', 'a', 'single', 'chromosome', '/', 'contig', '.']
train
https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/window.py#L234-L376
5,156
galactics/beyond
beyond/orbits/orbit.py
Orbit.iter
def iter(self, **kwargs): """see :py:meth:`Propagator.iter() <beyond.propagators.base.Propagator.iter>` """ if self.propagator.orbit is not self: self.propagator.orbit = self return self.propagator.iter(**kwargs)
python
def iter(self, **kwargs): """see :py:meth:`Propagator.iter() <beyond.propagators.base.Propagator.iter>` """ if self.propagator.orbit is not self: self.propagator.orbit = self return self.propagator.iter(**kwargs)
['def', 'iter', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'if', 'self', '.', 'propagator', '.', 'orbit', 'is', 'not', 'self', ':', 'self', '.', 'propagator', '.', 'orbit', '=', 'self', 'return', 'self', '.', 'propagator', '.', 'iter', '(', '*', '*', 'kwargs', ')']
see :py:meth:`Propagator.iter() <beyond.propagators.base.Propagator.iter>`
['see', ':', 'py', ':', 'meth', ':', 'Propagator', '.', 'iter', '()', '<beyond', '.', 'propagators', '.', 'base', '.', 'Propagator', '.', 'iter', '>']
train
https://github.com/galactics/beyond/blob/7a7590ff0fd4c0bac3e8e383ecca03caa98e5742/beyond/orbits/orbit.py#L322-L328
5,157
restran/mountains
mountains/http/__init__.py
query_str_2_dict
def query_str_2_dict(query_str): """ 将查询字符串,转换成字典 a=123&b=456 {'a': '123', 'b': '456'} :param query_str: :return: """ if query_str: query_list = query_str.split('&') query_dict = {} for t in query_list: x = t.split('=') query_dict[x[0]] = x...
python
def query_str_2_dict(query_str): """ 将查询字符串,转换成字典 a=123&b=456 {'a': '123', 'b': '456'} :param query_str: :return: """ if query_str: query_list = query_str.split('&') query_dict = {} for t in query_list: x = t.split('=') query_dict[x[0]] = x...
['def', 'query_str_2_dict', '(', 'query_str', ')', ':', 'if', 'query_str', ':', 'query_list', '=', 'query_str', '.', 'split', '(', "'&'", ')', 'query_dict', '=', '{', '}', 'for', 't', 'in', 'query_list', ':', 'x', '=', 't', '.', 'split', '(', "'='", ')', 'query_dict', '[', 'x', '[', '0', ']', ']', '=', 'x', '[', '1', '...
将查询字符串,转换成字典 a=123&b=456 {'a': '123', 'b': '456'} :param query_str: :return:
['将查询字符串,转换成字典', 'a', '=', '123&b', '=', '456', '{', 'a', ':', '123', 'b', ':', '456', '}', ':', 'param', 'query_str', ':', ':', 'return', ':']
train
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/http/__init__.py#L122-L138
5,158
StanfordVL/robosuite
robosuite/models/base.py
MujocoXML.resolve_asset_dependency
def resolve_asset_dependency(self): """ Converts every file dependency into absolute path so when we merge we don't break things. """ for node in self.asset.findall("./*[@file]"): file = node.get("file") abs_path = os.path.abspath(self.folder) abs_pat...
python
def resolve_asset_dependency(self): """ Converts every file dependency into absolute path so when we merge we don't break things. """ for node in self.asset.findall("./*[@file]"): file = node.get("file") abs_path = os.path.abspath(self.folder) abs_pat...
['def', 'resolve_asset_dependency', '(', 'self', ')', ':', 'for', 'node', 'in', 'self', '.', 'asset', '.', 'findall', '(', '"./*[@file]"', ')', ':', 'file', '=', 'node', '.', 'get', '(', '"file"', ')', 'abs_path', '=', 'os', '.', 'path', '.', 'abspath', '(', 'self', '.', 'folder', ')', 'abs_path', '=', 'os', '.', 'path...
Converts every file dependency into absolute path so when we merge we don't break things.
['Converts', 'every', 'file', 'dependency', 'into', 'absolute', 'path', 'so', 'when', 'we', 'merge', 'we', 'don', 't', 'break', 'things', '.']
train
https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/models/base.py#L37-L46
5,159
gmr/rejected
rejected/controller.py
Controller.setup
def setup(self): """Continue the run process blocking on MasterControlProgram.run""" # If the app was invoked to specified to prepend the path, do so now if self.args.prepend_path: self._prepend_python_path(self.args.prepend_path)
python
def setup(self): """Continue the run process blocking on MasterControlProgram.run""" # If the app was invoked to specified to prepend the path, do so now if self.args.prepend_path: self._prepend_python_path(self.args.prepend_path)
['def', 'setup', '(', 'self', ')', ':', '# If the app was invoked to specified to prepend the path, do so now', 'if', 'self', '.', 'args', '.', 'prepend_path', ':', 'self', '.', '_prepend_python_path', '(', 'self', '.', 'args', '.', 'prepend_path', ')']
Continue the run process blocking on MasterControlProgram.run
['Continue', 'the', 'run', 'process', 'blocking', 'on', 'MasterControlProgram', '.', 'run']
train
https://github.com/gmr/rejected/blob/610a3e1401122ecb98d891b6795cca0255e5b044/rejected/controller.py#L63-L67
5,160
raymondEhlers/pachyderm
pachyderm/projectors.py
HistProjector.output_key_name
def output_key_name(self, input_key: str, output_hist: Hist, projection_name: str, **kwargs) -> str: """ Returns the key under which the output object should be stored. Note: This function is just a basic placeholder which returns the projection name and likely should be overrid...
python
def output_key_name(self, input_key: str, output_hist: Hist, projection_name: str, **kwargs) -> str: """ Returns the key under which the output object should be stored. Note: This function is just a basic placeholder which returns the projection name and likely should be overrid...
['def', 'output_key_name', '(', 'self', ',', 'input_key', ':', 'str', ',', 'output_hist', ':', 'Hist', ',', 'projection_name', ':', 'str', ',', '*', '*', 'kwargs', ')', '->', 'str', ':', 'return', 'projection_name']
Returns the key under which the output object should be stored. Note: This function is just a basic placeholder which returns the projection name and likely should be overridden. Args: input_key: Key of the input hist in the input dict output_hist: The o...
['Returns', 'the', 'key', 'under', 'which', 'the', 'output', 'object', 'should', 'be', 'stored', '.']
train
https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/projectors.py#L707-L724
5,161
timster/peewee-validates
peewee_validates.py
Validator.validate
def validate(self, data=None, only=None, exclude=None): """ Validate the data for all fields and return whether the validation was successful. This method also retains the validated data in ``self.data`` so that it can be accessed later. This is usually the method you want to call after...
python
def validate(self, data=None, only=None, exclude=None): """ Validate the data for all fields and return whether the validation was successful. This method also retains the validated data in ``self.data`` so that it can be accessed later. This is usually the method you want to call after...
['def', 'validate', '(', 'self', ',', 'data', '=', 'None', ',', 'only', '=', 'None', ',', 'exclude', '=', 'None', ')', ':', 'only', '=', 'only', 'or', '[', ']', 'exclude', '=', 'exclude', 'or', '[', ']', 'data', '=', 'data', 'or', '{', '}', 'self', '.', 'errors', '=', '{', '}', 'self', '.', 'data', '=', '{', '}', '# Va...
Validate the data for all fields and return whether the validation was successful. This method also retains the validated data in ``self.data`` so that it can be accessed later. This is usually the method you want to call after creating the validator instance. :param data: Dictionary of data t...
['Validate', 'the', 'data', 'for', 'all', 'fields', 'and', 'return', 'whether', 'the', 'validation', 'was', 'successful', '.', 'This', 'method', 'also', 'retains', 'the', 'validated', 'data', 'in', 'self', '.', 'data', 'so', 'that', 'it', 'can', 'be', 'accessed', 'later', '.']
train
https://github.com/timster/peewee-validates/blob/417f0fafb87fe9209439d65bc279d86a3d9e8028/peewee_validates.py#L755-L795
5,162
assamite/creamas
creamas/mp.py
spawn_container
def spawn_container(addr, env_cls=Environment, mgr_cls=EnvManager, set_seed=True, *args, **kwargs): """Spawn a new environment in a given address as a coroutine. Arguments and keyword arguments are passed down to the created environment at initialization time. If `setproctitle <htt...
python
def spawn_container(addr, env_cls=Environment, mgr_cls=EnvManager, set_seed=True, *args, **kwargs): """Spawn a new environment in a given address as a coroutine. Arguments and keyword arguments are passed down to the created environment at initialization time. If `setproctitle <htt...
['def', 'spawn_container', '(', 'addr', ',', 'env_cls', '=', 'Environment', ',', 'mgr_cls', '=', 'EnvManager', ',', 'set_seed', '=', 'True', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', '# Try setting the process name to easily recognize the spawned', "# environments with 'ps -x' or 'top'", 'try', ':', 'import'...
Spawn a new environment in a given address as a coroutine. Arguments and keyword arguments are passed down to the created environment at initialization time. If `setproctitle <https://pypi.python.org/pypi/setproctitle>`_ is installed, this function renames the title of the process to start with 'c...
['Spawn', 'a', 'new', 'environment', 'in', 'a', 'given', 'address', 'as', 'a', 'coroutine', '.']
train
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L886-L915
5,163
PSPC-SPAC-buyandsell/von_anchor
von_anchor/wallet/wallet.py
Wallet.create_link_secret
async def create_link_secret(self, label: str) -> None: """ Create link secret (a.k.a. master secret) used in proofs by HolderProver, if the current link secret does not already correspond to the input link secret label. Raise WalletState if wallet is closed, or any other IndyError caus...
python
async def create_link_secret(self, label: str) -> None: """ Create link secret (a.k.a. master secret) used in proofs by HolderProver, if the current link secret does not already correspond to the input link secret label. Raise WalletState if wallet is closed, or any other IndyError caus...
['async', 'def', 'create_link_secret', '(', 'self', ',', 'label', ':', 'str', ')', '->', 'None', ':', 'LOGGER', '.', 'debug', '(', "'Wallet.create_link_secret >>> label: %s'", ',', 'label', ')', 'if', 'not', 'self', '.', 'handle', ':', 'LOGGER', '.', 'debug', '(', "'Wallet.create_link_secret <!< Wallet %s is closed'", ...
Create link secret (a.k.a. master secret) used in proofs by HolderProver, if the current link secret does not already correspond to the input link secret label. Raise WalletState if wallet is closed, or any other IndyError causing failure to set link secret in wallet. :param label: lab...
['Create', 'link', 'secret', '(', 'a', '.', 'k', '.', 'a', '.', 'master', 'secret', ')', 'used', 'in', 'proofs', 'by', 'HolderProver', 'if', 'the', 'current', 'link', 'secret', 'does', 'not', 'already', 'correspond', 'to', 'the', 'input', 'link', 'secret', 'label', '.']
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/wallet/wallet.py#L492-L524
5,164
gem/oq-engine
openquake/calculators/export/risk.py
export_agg_losses
def export_agg_losses(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ dskey = ekey[0] oq = dstore['oqparam'] dt = oq.loss_dt() name, value, tags = _get_data(dstore, dskey, oq.hazard_stats().items()) writer = writers.Csv...
python
def export_agg_losses(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ dskey = ekey[0] oq = dstore['oqparam'] dt = oq.loss_dt() name, value, tags = _get_data(dstore, dskey, oq.hazard_stats().items()) writer = writers.Csv...
['def', 'export_agg_losses', '(', 'ekey', ',', 'dstore', ')', ':', 'dskey', '=', 'ekey', '[', '0', ']', 'oq', '=', 'dstore', '[', "'oqparam'", ']', 'dt', '=', 'oq', '.', 'loss_dt', '(', ')', 'name', ',', 'value', ',', 'tags', '=', '_get_data', '(', 'dstore', ',', 'dskey', ',', 'oq', '.', 'hazard_stats', '(', ')', '.', ...
:param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object
[':', 'param', 'ekey', ':', 'export', 'key', 'i', '.', 'e', '.', 'a', 'pair', '(', 'datastore', 'key', 'fmt', ')', ':', 'param', 'dstore', ':', 'datastore', 'object']
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/risk.py#L153-L178
5,165
elifesciences/proofreader-python
proofreader/runner.py
_run_command
def _run_command(command, targets, options): # type: (str, List[str], List[str]) -> bool """Runs `command` + `targets` + `options` in a subprocess and returns a boolean determined by the process return code. >>> result = run_command('pylint', ['foo.py', 'some_module'], ['-E']) >>> result Tr...
python
def _run_command(command, targets, options): # type: (str, List[str], List[str]) -> bool """Runs `command` + `targets` + `options` in a subprocess and returns a boolean determined by the process return code. >>> result = run_command('pylint', ['foo.py', 'some_module'], ['-E']) >>> result Tr...
['def', '_run_command', '(', 'command', ',', 'targets', ',', 'options', ')', ':', '# type: (str, List[str], List[str]) -> bool', 'print', '(', "'{0}: targets={1} options={2}'", '.', 'format', '(', 'command', ',', 'targets', ',', 'options', ')', ')', 'cmd', '=', '[', 'command', ']', '+', 'targets', '+', 'options', 'proc...
Runs `command` + `targets` + `options` in a subprocess and returns a boolean determined by the process return code. >>> result = run_command('pylint', ['foo.py', 'some_module'], ['-E']) >>> result True :param command: str :param targets: List[str] :param options: List[str] :return:...
['Runs', 'command', '+', 'targets', '+', 'options', 'in', 'a', 'subprocess', 'and', 'returns', 'a', 'boolean', 'determined', 'by', 'the', 'process', 'return', 'code', '.']
train
https://github.com/elifesciences/proofreader-python/blob/387b3c65ee7777e26b3a7340179dc4ed68f24f58/proofreader/runner.py#L55-L75
5,166
hydraplatform/hydra-base
hydra_base/lib/template.py
validate_attr
def validate_attr(resource_attr_id, scenario_id, template_id=None): """ Check that a resource attribute satisfies the requirements of all the types of the resource. """ rs = db.DBSession.query(ResourceScenario).\ filter(ResourceScenario.resource_attr_id==resource_attr...
python
def validate_attr(resource_attr_id, scenario_id, template_id=None): """ Check that a resource attribute satisfies the requirements of all the types of the resource. """ rs = db.DBSession.query(ResourceScenario).\ filter(ResourceScenario.resource_attr_id==resource_attr...
['def', 'validate_attr', '(', 'resource_attr_id', ',', 'scenario_id', ',', 'template_id', '=', 'None', ')', ':', 'rs', '=', 'db', '.', 'DBSession', '.', 'query', '(', 'ResourceScenario', ')', '.', 'filter', '(', 'ResourceScenario', '.', 'resource_attr_id', '==', 'resource_attr_id', ',', 'ResourceScenario', '.', 'scenar...
Check that a resource attribute satisfies the requirements of all the types of the resource.
['Check', 'that', 'a', 'resource', 'attribute', 'satisfies', 'the', 'requirements', 'of', 'all', 'the', 'types', 'of', 'the', 'resource', '.']
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/template.py#L1724-L1753
5,167
pricingassistant/mrq
mrq/processes.py
ProcessPool.stop_watch
def stop_watch(self): """ Stops the periodic watch greenlet, thus the pool itself """ if self.greenlet_watch: self.greenlet_watch.kill(block=False) self.greenlet_watch = None
python
def stop_watch(self): """ Stops the periodic watch greenlet, thus the pool itself """ if self.greenlet_watch: self.greenlet_watch.kill(block=False) self.greenlet_watch = None
['def', 'stop_watch', '(', 'self', ')', ':', 'if', 'self', '.', 'greenlet_watch', ':', 'self', '.', 'greenlet_watch', '.', 'kill', '(', 'block', '=', 'False', ')', 'self', '.', 'greenlet_watch', '=', 'None']
Stops the periodic watch greenlet, thus the pool itself
['Stops', 'the', 'periodic', 'watch', 'greenlet', 'thus', 'the', 'pool', 'itself']
train
https://github.com/pricingassistant/mrq/blob/d0a5a34de9cba38afa94fb7c9e17f9b570b79a50/mrq/processes.py#L204-L209
5,168
bcbio/bcbio-nextgen
bcbio/utils.py
partition_all
def partition_all(n, iterable): """Partition a list into equally sized pieces, including last smaller parts http://stackoverflow.com/questions/5129102/python-equivalent-to-clojures-partition-all """ it = iter(iterable) while True: chunk = list(itertools.islice(it, n)) if not chunk: ...
python
def partition_all(n, iterable): """Partition a list into equally sized pieces, including last smaller parts http://stackoverflow.com/questions/5129102/python-equivalent-to-clojures-partition-all """ it = iter(iterable) while True: chunk = list(itertools.islice(it, n)) if not chunk: ...
['def', 'partition_all', '(', 'n', ',', 'iterable', ')', ':', 'it', '=', 'iter', '(', 'iterable', ')', 'while', 'True', ':', 'chunk', '=', 'list', '(', 'itertools', '.', 'islice', '(', 'it', ',', 'n', ')', ')', 'if', 'not', 'chunk', ':', 'break', 'yield', 'chunk']
Partition a list into equally sized pieces, including last smaller parts http://stackoverflow.com/questions/5129102/python-equivalent-to-clojures-partition-all
['Partition', 'a', 'list', 'into', 'equally', 'sized', 'pieces', 'including', 'last', 'smaller', 'parts', 'http', ':', '//', 'stackoverflow', '.', 'com', '/', 'questions', '/', '5129102', '/', 'python', '-', 'equivalent', '-', 'to', '-', 'clojures', '-', 'partition', '-', 'all']
train
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L433-L442
5,169
SheffieldML/GPyOpt
GPyOpt/models/gpmodel.py
GPModel.updateModel
def updateModel(self, X_all, Y_all, X_new, Y_new): """ Updates the model with new observations. """ if self.model is None: self._create_model(X_all, Y_all) else: self.model.set_XY(X_all, Y_all) # WARNING: Even if self.max_iters=0, the hyperparamet...
python
def updateModel(self, X_all, Y_all, X_new, Y_new): """ Updates the model with new observations. """ if self.model is None: self._create_model(X_all, Y_all) else: self.model.set_XY(X_all, Y_all) # WARNING: Even if self.max_iters=0, the hyperparamet...
['def', 'updateModel', '(', 'self', ',', 'X_all', ',', 'Y_all', ',', 'X_new', ',', 'Y_new', ')', ':', 'if', 'self', '.', 'model', 'is', 'None', ':', 'self', '.', '_create_model', '(', 'X_all', ',', 'Y_all', ')', 'else', ':', 'self', '.', 'model', '.', 'set_XY', '(', 'X_all', ',', 'Y_all', ')', '# WARNING: Even if self....
Updates the model with new observations.
['Updates', 'the', 'model', 'with', 'new', 'observations', '.']
train
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L76-L91
5,170
timothydmorton/isochrones
isochrones/starmodel_old.py
TripleStarModel.triangle
def triangle(self, params=None, **kwargs): """ Makes a nifty corner plot. """ if params is None: params = ['mass_A', 'mass_B', 'mass_C', 'age', 'feh', 'distance', 'AV'] super(TripleStarModel, self).triangle(params=params, **kwargs)
python
def triangle(self, params=None, **kwargs): """ Makes a nifty corner plot. """ if params is None: params = ['mass_A', 'mass_B', 'mass_C', 'age', 'feh', 'distance', 'AV'] super(TripleStarModel, self).triangle(params=params, **kwargs)
['def', 'triangle', '(', 'self', ',', 'params', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'if', 'params', 'is', 'None', ':', 'params', '=', '[', "'mass_A'", ',', "'mass_B'", ',', "'mass_C'", ',', "'age'", ',', "'feh'", ',', "'distance'", ',', "'AV'", ']', 'super', '(', 'TripleStarModel', ',', 'self', ')', '.', 't...
Makes a nifty corner plot.
['Makes', 'a', 'nifty', 'corner', 'plot', '.']
train
https://github.com/timothydmorton/isochrones/blob/d84495573044c66db2fd6b959fe69e370757ea14/isochrones/starmodel_old.py#L1818-L1827
5,171
mmp2/megaman
megaman/utils/spectral_clustering.py
spectral_clustering
def spectral_clustering(geom, K, eigen_solver = 'dense', random_state = None, solver_kwds = None, renormalize = True, stabalize = True, additional_vectors = 0): """ Spectral clustering for find K clusters by using the eigenvectors of a matrix which is derived from a set of similari...
python
def spectral_clustering(geom, K, eigen_solver = 'dense', random_state = None, solver_kwds = None, renormalize = True, stabalize = True, additional_vectors = 0): """ Spectral clustering for find K clusters by using the eigenvectors of a matrix which is derived from a set of similari...
['def', 'spectral_clustering', '(', 'geom', ',', 'K', ',', 'eigen_solver', '=', "'dense'", ',', 'random_state', '=', 'None', ',', 'solver_kwds', '=', 'None', ',', 'renormalize', '=', 'True', ',', 'stabalize', '=', 'True', ',', 'additional_vectors', '=', '0', ')', ':', '# Step 1: get similarity matrix', 'if', 'geom', '....
Spectral clustering for find K clusters by using the eigenvectors of a matrix which is derived from a set of similarities S. Parameters ----------- S: array-like,shape(n_sample,n_sample) similarity matrix K: integer number of K clusters eigen_solver : {'auto', 'dense', 'arpack...
['Spectral', 'clustering', 'for', 'find', 'K', 'clusters', 'by', 'using', 'the', 'eigenvectors', 'of', 'a', 'matrix', 'which', 'is', 'derived', 'from', 'a', 'set', 'of', 'similarities', 'S', '.']
train
https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/utils/spectral_clustering.py#L94-L193
5,172
ronaldguillen/wave
wave/utils/html.py
parse_html_list
def parse_html_list(dictionary, prefix=''): """ Used to suport list values in HTML forms. Supports lists of primitives and/or dictionaries. * List of primitives. { '[0]': 'abc', '[1]': 'def', '[2]': 'hij' } --> [ 'abc', 'def', 'hij' ...
python
def parse_html_list(dictionary, prefix=''): """ Used to suport list values in HTML forms. Supports lists of primitives and/or dictionaries. * List of primitives. { '[0]': 'abc', '[1]': 'def', '[2]': 'hij' } --> [ 'abc', 'def', 'hij' ...
['def', 'parse_html_list', '(', 'dictionary', ',', 'prefix', '=', "''", ')', ':', 'ret', '=', '{', '}', 'regex', '=', 're', '.', 'compile', '(', "r'^%s\\[([0-9]+)\\](.*)$'", '%', 're', '.', 'escape', '(', 'prefix', ')', ')', 'for', 'field', ',', 'value', 'in', 'dictionary', '.', 'items', '(', ')', ':', 'match', '=', 'r...
Used to suport list values in HTML forms. Supports lists of primitives and/or dictionaries. * List of primitives. { '[0]': 'abc', '[1]': 'def', '[2]': 'hij' } --> [ 'abc', 'def', 'hij' ] * List of dictionaries. { '[0]foo...
['Used', 'to', 'suport', 'list', 'values', 'in', 'HTML', 'forms', '.', 'Supports', 'lists', 'of', 'primitives', 'and', '/', 'or', 'dictionaries', '.']
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/utils/html.py#L15-L62
5,173
ornlneutronimaging/ImagingReso
ImagingReso/_utilities.py
set_distance_units
def set_distance_units(value=np.NaN, from_units='mm', to_units='cm'): """convert distance into new units Parameters: =========== value: float. value to convert from_units: string. Must be 'mm', 'cm' or 'm' to_units: string. must be 'mm','cm' or 'm' Returns: ======== convert...
python
def set_distance_units(value=np.NaN, from_units='mm', to_units='cm'): """convert distance into new units Parameters: =========== value: float. value to convert from_units: string. Must be 'mm', 'cm' or 'm' to_units: string. must be 'mm','cm' or 'm' Returns: ======== convert...
['def', 'set_distance_units', '(', 'value', '=', 'np', '.', 'NaN', ',', 'from_units', '=', "'mm'", ',', 'to_units', '=', "'cm'", ')', ':', 'if', 'from_units', '==', 'to_units', ':', 'return', 'value', 'if', 'from_units', '==', "'cm'", ':', 'if', 'to_units', '==', "'mm'", ':', 'coeff', '=', '10', 'elif', 'to_units', '==...
convert distance into new units Parameters: =========== value: float. value to convert from_units: string. Must be 'mm', 'cm' or 'm' to_units: string. must be 'mm','cm' or 'm' Returns: ======== converted value Raises: ======= ValueError if from_units is not a v...
['convert', 'distance', 'into', 'new', 'units', 'Parameters', ':', '===========', 'value', ':', 'float', '.', 'value', 'to', 'convert', 'from_units', ':', 'string', '.', 'Must', 'be', 'mm', 'cm', 'or', 'm', 'to_units', ':', 'string', '.', 'must', 'be', 'mm', 'cm', 'or', 'm', 'Returns', ':', '========', 'converted', 'va...
train
https://github.com/ornlneutronimaging/ImagingReso/blob/2da5cd1f565b3128f59d86bcedfd9adc2b02218b/ImagingReso/_utilities.py#L623-L668
5,174
bykof/billomapy
billomapy/billomapy.py
Billomapy.get_email_receivers_of_recurring_per_page
def get_email_receivers_of_recurring_per_page(self, recurring_id, per_page=1000, page=1): """ Get email receivers of recurring per page :param recurring_id: the recurring id :param per_page: How many objects per page. Default: 1000 :param page: Which page. Default: 1 :re...
python
def get_email_receivers_of_recurring_per_page(self, recurring_id, per_page=1000, page=1): """ Get email receivers of recurring per page :param recurring_id: the recurring id :param per_page: How many objects per page. Default: 1000 :param page: Which page. Default: 1 :re...
['def', 'get_email_receivers_of_recurring_per_page', '(', 'self', ',', 'recurring_id', ',', 'per_page', '=', '1000', ',', 'page', '=', '1', ')', ':', 'return', 'self', '.', '_get_resource_per_page', '(', 'resource', '=', 'RECURRING_EMAIL_RECEIVERS', ',', 'per_page', '=', 'per_page', ',', 'page', '=', 'page', ',', 'para...
Get email receivers of recurring per page :param recurring_id: the recurring id :param per_page: How many objects per page. Default: 1000 :param page: Which page. Default: 1 :return: list
['Get', 'email', 'receivers', 'of', 'recurring', 'per', 'page']
train
https://github.com/bykof/billomapy/blob/a28ba69fd37654fa145d0411d52c200e7f8984ab/billomapy/billomapy.py#L1606-L1620
5,175
rauenzi/discordbot.py
discordbot/cogs/reactions.py
Reactions.viewreaction
async def viewreaction(self, ctx, *, reactor : str): """Views a specific reaction""" data = self.config.get(ctx.message.server.id, {}) keyword = data.get(reactor, {}) if not keyword: await self.bot.responses.failure(message="Reaction '{}' was not found.".format(reactor)) ...
python
async def viewreaction(self, ctx, *, reactor : str): """Views a specific reaction""" data = self.config.get(ctx.message.server.id, {}) keyword = data.get(reactor, {}) if not keyword: await self.bot.responses.failure(message="Reaction '{}' was not found.".format(reactor)) ...
['async', 'def', 'viewreaction', '(', 'self', ',', 'ctx', ',', '*', ',', 'reactor', ':', 'str', ')', ':', 'data', '=', 'self', '.', 'config', '.', 'get', '(', 'ctx', '.', 'message', '.', 'server', '.', 'id', ',', '{', '}', ')', 'keyword', '=', 'data', '.', 'get', '(', 'reactor', ',', '{', '}', ')', 'if', 'not', 'keywor...
Views a specific reaction
['Views', 'a', 'specific', 'reaction']
train
https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/reactions.py#L112-L135
5,176
monarch-initiative/dipper
dipper/sources/FlyBase.py
FlyBase._process_disease_models
def _process_disease_models(self, limit): """ Here we make associations between a disease and the supplied "model". In this case it's an allele. FIXME consider changing this... are alleles really models? Perhaps map these alleles into actual animals/strains or genotypes? ...
python
def _process_disease_models(self, limit): """ Here we make associations between a disease and the supplied "model". In this case it's an allele. FIXME consider changing this... are alleles really models? Perhaps map these alleles into actual animals/strains or genotypes? ...
['def', '_process_disease_models', '(', 'self', ',', 'limit', ')', ':', 'if', 'self', '.', 'test_mode', ':', 'graph', '=', 'self', '.', 'testgraph', 'else', ':', 'graph', '=', 'self', '.', 'graph', 'raw', '=', "'/'", '.', 'join', '(', '(', 'self', '.', 'rawdir', ',', 'self', '.', 'files', '[', "'disease_models'", ']', ...
Here we make associations between a disease and the supplied "model". In this case it's an allele. FIXME consider changing this... are alleles really models? Perhaps map these alleles into actual animals/strains or genotypes? :param limit: :return:
['Here', 'we', 'make', 'associations', 'between', 'a', 'disease', 'and', 'the', 'supplied', 'model', '.', 'In', 'this', 'case', 'it', 's', 'an', 'allele', '.', 'FIXME', 'consider', 'changing', 'this', '...', 'are', 'alleles', 'really', 'models?', 'Perhaps', 'map', 'these', 'alleles', 'into', 'actual', 'animals', '/', '...
train
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L1923-L1987
5,177
spyder-ide/spyder
spyder/plugins/projects/widgets/projectdialog.py
is_writable
def is_writable(path): """Check if path has write access""" try: testfile = tempfile.TemporaryFile(dir=path) testfile.close() except OSError as e: if e.errno == errno.EACCES: # 13 return False return True
python
def is_writable(path): """Check if path has write access""" try: testfile = tempfile.TemporaryFile(dir=path) testfile.close() except OSError as e: if e.errno == errno.EACCES: # 13 return False return True
['def', 'is_writable', '(', 'path', ')', ':', 'try', ':', 'testfile', '=', 'tempfile', '.', 'TemporaryFile', '(', 'dir', '=', 'path', ')', 'testfile', '.', 'close', '(', ')', 'except', 'OSError', 'as', 'e', ':', 'if', 'e', '.', 'errno', '==', 'errno', '.', 'EACCES', ':', '# 13\r', 'return', 'False', 'return', 'True']
Check if path has write access
['Check', 'if', 'path', 'has', 'write', 'access']
train
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/widgets/projectdialog.py#L35-L43
5,178
blockstack/blockstack-core
blockstack/lib/nameset/namedb.py
BlockstackDB.is_name_owner
def is_name_owner( self, name, sender_script_pubkey ): """ Given the fully-qualified name and a sender's script pubkey, determine if the sender owns the name. The name must exist and not be revoked or expired at the current block. """ if not self.is_name_register...
python
def is_name_owner( self, name, sender_script_pubkey ): """ Given the fully-qualified name and a sender's script pubkey, determine if the sender owns the name. The name must exist and not be revoked or expired at the current block. """ if not self.is_name_register...
['def', 'is_name_owner', '(', 'self', ',', 'name', ',', 'sender_script_pubkey', ')', ':', 'if', 'not', 'self', '.', 'is_name_registered', '(', 'name', ')', ':', '# no one owns it ', 'return', 'False', 'owner', '=', 'self', '.', 'get_name_owner', '(', 'name', ')', 'if', 'owner', '!=', 'sender_script_pubkey', ':', 'retur...
Given the fully-qualified name and a sender's script pubkey, determine if the sender owns the name. The name must exist and not be revoked or expired at the current block.
['Given', 'the', 'fully', '-', 'qualified', 'name', 'and', 'a', 'sender', 's', 'script', 'pubkey', 'determine', 'if', 'the', 'sender', 'owns', 'the', 'name', '.']
train
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L1443-L1459
5,179
rlabbe/filterpy
filterpy/hinfinity/hinfinity_filter.py
HInfinityFilter.predict
def predict(self, u=0): """ Predict next position. Parameters ---------- u : ndarray Optional control vector. If non-zero, it is multiplied by `B` to create the control input into the system. """ # x = Fx + Bu self.x = dot(self.F,...
python
def predict(self, u=0): """ Predict next position. Parameters ---------- u : ndarray Optional control vector. If non-zero, it is multiplied by `B` to create the control input into the system. """ # x = Fx + Bu self.x = dot(self.F,...
['def', 'predict', '(', 'self', ',', 'u', '=', '0', ')', ':', '# x = Fx + Bu', 'self', '.', 'x', '=', 'dot', '(', 'self', '.', 'F', ',', 'self', '.', 'x', ')', '+', 'dot', '(', 'self', '.', 'B', ',', 'u', ')']
Predict next position. Parameters ---------- u : ndarray Optional control vector. If non-zero, it is multiplied by `B` to create the control input into the system.
['Predict', 'next', 'position', '.']
train
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/hinfinity/hinfinity_filter.py#L145-L157
5,180
pepkit/peppy
peppy/utils.py
check_bam
def check_bam(bam, o): """ Check reads in BAM file for read type and lengths. :param str bam: BAM file path. :param int o: Number of reads to look at for estimation. """ try: p = sp.Popen(['samtools', 'view', bam], stdout=sp.PIPE) # Count paired alignments paired = 0 ...
python
def check_bam(bam, o): """ Check reads in BAM file for read type and lengths. :param str bam: BAM file path. :param int o: Number of reads to look at for estimation. """ try: p = sp.Popen(['samtools', 'view', bam], stdout=sp.PIPE) # Count paired alignments paired = 0 ...
['def', 'check_bam', '(', 'bam', ',', 'o', ')', ':', 'try', ':', 'p', '=', 'sp', '.', 'Popen', '(', '[', "'samtools'", ',', "'view'", ',', 'bam', ']', ',', 'stdout', '=', 'sp', '.', 'PIPE', ')', '# Count paired alignments', 'paired', '=', '0', 'read_lengths', '=', 'defaultdict', '(', 'int', ')', 'while', 'o', '>', '0',...
Check reads in BAM file for read type and lengths. :param str bam: BAM file path. :param int o: Number of reads to look at for estimation.
['Check', 'reads', 'in', 'BAM', 'file', 'for', 'read', 'type', 'and', 'lengths', '.']
train
https://github.com/pepkit/peppy/blob/f0f725e1557936b81c86573a77400e6f8da78f05/peppy/utils.py#L62-L91
5,181
log2timeline/dfwinreg
dfwinreg/virtual.py
VirtualWinRegistryKey.offset
def offset(self): """int: offset of the key within the Windows Registry file or None.""" if not self._registry_key and self._registry: self._GetKeyFromRegistry() if not self._registry_key: return None return self._registry_key.offset
python
def offset(self): """int: offset of the key within the Windows Registry file or None.""" if not self._registry_key and self._registry: self._GetKeyFromRegistry() if not self._registry_key: return None return self._registry_key.offset
['def', 'offset', '(', 'self', ')', ':', 'if', 'not', 'self', '.', '_registry_key', 'and', 'self', '.', '_registry', ':', 'self', '.', '_GetKeyFromRegistry', '(', ')', 'if', 'not', 'self', '.', '_registry_key', ':', 'return', 'None', 'return', 'self', '.', '_registry_key', '.', 'offset']
int: offset of the key within the Windows Registry file or None.
['int', ':', 'offset', 'of', 'the', 'key', 'within', 'the', 'Windows', 'Registry', 'file', 'or', 'None', '.']
train
https://github.com/log2timeline/dfwinreg/blob/9d488bb1db562197dbfb48de9613d6b29dea056e/dfwinreg/virtual.py#L84-L92
5,182
pudo/dataset
dataset/table.py
Table.drop
def drop(self): """Drop the table from the database. Deletes both the schema and all the contents within it. """ with self.db.lock: if self.exists: self._threading_warn() self.table.drop(self.db.executable, checkfirst=True) sel...
python
def drop(self): """Drop the table from the database. Deletes both the schema and all the contents within it. """ with self.db.lock: if self.exists: self._threading_warn() self.table.drop(self.db.executable, checkfirst=True) sel...
['def', 'drop', '(', 'self', ')', ':', 'with', 'self', '.', 'db', '.', 'lock', ':', 'if', 'self', '.', 'exists', ':', 'self', '.', '_threading_warn', '(', ')', 'self', '.', 'table', '.', 'drop', '(', 'self', '.', 'db', '.', 'executable', ',', 'checkfirst', '=', 'True', ')', 'self', '.', '_table', '=', 'None']
Drop the table from the database. Deletes both the schema and all the contents within it.
['Drop', 'the', 'table', 'from', 'the', 'database', '.']
train
https://github.com/pudo/dataset/blob/a008d120c7f3c48ccba98a282c0c67d6e719c0e5/dataset/table.py#L390-L399
5,183
ev3dev/ev3dev-lang-python
ev3dev2/motor.py
MoveTank.on
def on(self, left_speed, right_speed): """ Start rotating the motors according to ``left_speed`` and ``right_speed`` forever. Speeds can be percentages or any SpeedValue implementation. """ (left_speed_native_units, right_speed_native_units) = self._unpack_speeds_to_native_units(...
python
def on(self, left_speed, right_speed): """ Start rotating the motors according to ``left_speed`` and ``right_speed`` forever. Speeds can be percentages or any SpeedValue implementation. """ (left_speed_native_units, right_speed_native_units) = self._unpack_speeds_to_native_units(...
['def', 'on', '(', 'self', ',', 'left_speed', ',', 'right_speed', ')', ':', '(', 'left_speed_native_units', ',', 'right_speed_native_units', ')', '=', 'self', '.', '_unpack_speeds_to_native_units', '(', 'left_speed', ',', 'right_speed', ')', '# Set all parameters', 'self', '.', 'left_motor', '.', 'speed_sp', '=', 'int'...
Start rotating the motors according to ``left_speed`` and ``right_speed`` forever. Speeds can be percentages or any SpeedValue implementation.
['Start', 'rotating', 'the', 'motors', 'according', 'to', 'left_speed', 'and', 'right_speed', 'forever', '.', 'Speeds', 'can', 'be', 'percentages', 'or', 'any', 'SpeedValue', 'implementation', '.']
train
https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/motor.py#L1904-L1922
5,184
dhermes/bezier
src/bezier/surface.py
_make_intersection
def _make_intersection(edge_info, all_edge_nodes): """Convert a description of edges into a curved polygon. .. note:: This is a helper used only by :meth:`.Surface.intersect`. Args: edge_info (Tuple[Tuple[int, float, float], ...]): Information describing each edge in the curved...
python
def _make_intersection(edge_info, all_edge_nodes): """Convert a description of edges into a curved polygon. .. note:: This is a helper used only by :meth:`.Surface.intersect`. Args: edge_info (Tuple[Tuple[int, float, float], ...]): Information describing each edge in the curved...
['def', '_make_intersection', '(', 'edge_info', ',', 'all_edge_nodes', ')', ':', 'edges', '=', '[', ']', 'for', 'index', ',', 'start', ',', 'end', 'in', 'edge_info', ':', 'nodes', '=', 'all_edge_nodes', '[', 'index', ']', 'new_nodes', '=', '_curve_helpers', '.', 'specialize_curve', '(', 'nodes', ',', 'start', ',', 'end...
Convert a description of edges into a curved polygon. .. note:: This is a helper used only by :meth:`.Surface.intersect`. Args: edge_info (Tuple[Tuple[int, float, float], ...]): Information describing each edge in the curved polygon by indicating which surface / edge on...
['Convert', 'a', 'description', 'of', 'edges', 'into', 'a', 'curved', 'polygon', '.']
train
https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/surface.py#L1100-L1128
5,185
tcalmant/ipopo
pelix/framework.py
BundleContext.install_package
def install_package(self, path, recursive=False): # type: (str, bool) -> tuple """ Installs all the modules found in the given package (directory). It is a utility method working like :meth:`~pelix.framework.BundleContext.install_visiting`, with a visitor accepting every ...
python
def install_package(self, path, recursive=False): # type: (str, bool) -> tuple """ Installs all the modules found in the given package (directory). It is a utility method working like :meth:`~pelix.framework.BundleContext.install_visiting`, with a visitor accepting every ...
['def', 'install_package', '(', 'self', ',', 'path', ',', 'recursive', '=', 'False', ')', ':', '# type: (str, bool) -> tuple', 'return', 'self', '.', '__framework', '.', 'install_package', '(', 'path', ',', 'recursive', ')']
Installs all the modules found in the given package (directory). It is a utility method working like :meth:`~pelix.framework.BundleContext.install_visiting`, with a visitor accepting every module found. :param path: Path of the package (folder) :param recursive: If True, install...
['Installs', 'all', 'the', 'modules', 'found', 'in', 'the', 'given', 'package', '(', 'directory', ')', '.', 'It', 'is', 'a', 'utility', 'method', 'working', 'like', ':', 'meth', ':', '~pelix', '.', 'framework', '.', 'BundleContext', '.', 'install_visiting', 'with', 'a', 'visitor', 'accepting', 'every', 'module', 'found...
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/framework.py#L1686-L1701
5,186
SYNHAK/spiff
spiff/payment/models.py
LineDiscountItem.value
def value(self): """Returns the positive value to subtract from the total.""" originalPrice = self.lineItem.totalPrice if self.flatRate == 0: return originalPrice * self.percent return self.flatRate
python
def value(self): """Returns the positive value to subtract from the total.""" originalPrice = self.lineItem.totalPrice if self.flatRate == 0: return originalPrice * self.percent return self.flatRate
['def', 'value', '(', 'self', ')', ':', 'originalPrice', '=', 'self', '.', 'lineItem', '.', 'totalPrice', 'if', 'self', '.', 'flatRate', '==', '0', ':', 'return', 'originalPrice', '*', 'self', '.', 'percent', 'return', 'self', '.', 'flatRate']
Returns the positive value to subtract from the total.
['Returns', 'the', 'positive', 'value', 'to', 'subtract', 'from', 'the', 'total', '.']
train
https://github.com/SYNHAK/spiff/blob/5e5c731f67954ddc11d2fb75371cfcfd0fef49b7/spiff/payment/models.py#L142-L147
5,187
noisyboiler/wampy
wampy/mixins.py
ParseUrlMixin.parse_url
def parse_url(self): """ Parses a URL of the form: - ws://host[:port][path] - wss://host[:port][path] - ws+unix:///path/to/my.socket """ self.scheme = None self.resource = None self.host = None self.port = None if self.url is None: ...
python
def parse_url(self): """ Parses a URL of the form: - ws://host[:port][path] - wss://host[:port][path] - ws+unix:///path/to/my.socket """ self.scheme = None self.resource = None self.host = None self.port = None if self.url is None: ...
['def', 'parse_url', '(', 'self', ')', ':', 'self', '.', 'scheme', '=', 'None', 'self', '.', 'resource', '=', 'None', 'self', '.', 'host', '=', 'None', 'self', '.', 'port', '=', 'None', 'if', 'self', '.', 'url', 'is', 'None', ':', 'return', 'scheme', ',', 'url', '=', 'self', '.', 'url', '.', 'split', '(', '":"', ',', '...
Parses a URL of the form: - ws://host[:port][path] - wss://host[:port][path] - ws+unix:///path/to/my.socket
['Parses', 'a', 'URL', 'of', 'the', 'form', ':']
train
https://github.com/noisyboiler/wampy/blob/7c7ef246fec1b2bf3ec3a0e24c85c42fdd99d4bf/wampy/mixins.py#L12-L64
5,188
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
_get_length_sequences_where
def _get_length_sequences_where(x): """ This method calculates the length of all sub-sequences where the array x is either True or 1. Examples -------- >>> x = [0,1,0,0,1,1,1,0,0,1,0,1,1] >>> _get_length_sequences_where(x) >>> [1, 3, 1, 2] >>> x = [0,True,0,0,True,True,True,0,0,True,0,...
python
def _get_length_sequences_where(x): """ This method calculates the length of all sub-sequences where the array x is either True or 1. Examples -------- >>> x = [0,1,0,0,1,1,1,0,0,1,0,1,1] >>> _get_length_sequences_where(x) >>> [1, 3, 1, 2] >>> x = [0,True,0,0,True,True,True,0,0,True,0,...
['def', '_get_length_sequences_where', '(', 'x', ')', ':', 'if', 'len', '(', 'x', ')', '==', '0', ':', 'return', '[', '0', ']', 'else', ':', 'res', '=', '[', 'len', '(', 'list', '(', 'group', ')', ')', 'for', 'value', ',', 'group', 'in', 'itertools', '.', 'groupby', '(', 'x', ')', 'if', 'value', '==', '1', ']', 'return...
This method calculates the length of all sub-sequences where the array x is either True or 1. Examples -------- >>> x = [0,1,0,0,1,1,1,0,0,1,0,1,1] >>> _get_length_sequences_where(x) >>> [1, 3, 1, 2] >>> x = [0,True,0,0,True,True,True,0,0,True,0,True,True] >>> _get_length_sequences_where(x...
['This', 'method', 'calculates', 'the', 'length', 'of', 'all', 'sub', '-', 'sequences', 'where', 'the', 'array', 'x', 'is', 'either', 'True', 'or', '1', '.']
train
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L81-L107
5,189
openstack/networking-cisco
networking_cisco/plugins/cisco/db/l3/ha_db.py
HA_db_mixin._teardown_redundancy_router_gw_connectivity
def _teardown_redundancy_router_gw_connectivity(self, context, router, router_db, plugging_driver): """To be called in update_router() if the router gateway is to change BEFORE router has been updated...
python
def _teardown_redundancy_router_gw_connectivity(self, context, router, router_db, plugging_driver): """To be called in update_router() if the router gateway is to change BEFORE router has been updated...
['def', '_teardown_redundancy_router_gw_connectivity', '(', 'self', ',', 'context', ',', 'router', ',', 'router_db', ',', 'plugging_driver', ')', ':', 'if', 'not', 'router', '[', 'ha', '.', 'ENABLED', ']', ':', "# No HA currently enabled so we're done", 'return', 'e_context', '=', 'context', '.', 'elevated', '(', ')', ...
To be called in update_router() if the router gateway is to change BEFORE router has been updated in DB .
['To', 'be', 'called', 'in', 'update_router', '()', 'if', 'the', 'router', 'gateway', 'is', 'to', 'change', 'BEFORE', 'router', 'has', 'been', 'updated', 'in', 'DB', '.']
train
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/db/l3/ha_db.py#L309-L334
5,190
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
cred_def_id
def cred_def_id(issuer_did: str, schema_seq_no: int, protocol: Protocol = None) -> str: """ Return credential definition identifier for input issuer DID and schema sequence number. Implementation passes to NodePool Protocol. :param issuer_did: DID of credential definition issuer :param schema_seq_...
python
def cred_def_id(issuer_did: str, schema_seq_no: int, protocol: Protocol = None) -> str: """ Return credential definition identifier for input issuer DID and schema sequence number. Implementation passes to NodePool Protocol. :param issuer_did: DID of credential definition issuer :param schema_seq_...
['def', 'cred_def_id', '(', 'issuer_did', ':', 'str', ',', 'schema_seq_no', ':', 'int', ',', 'protocol', ':', 'Protocol', '=', 'None', ')', '->', 'str', ':', 'return', '(', 'protocol', 'or', 'Protocol', '.', 'DEFAULT', ')', '.', 'cred_def_id', '(', 'issuer_did', ',', 'schema_seq_no', ')']
Return credential definition identifier for input issuer DID and schema sequence number. Implementation passes to NodePool Protocol. :param issuer_did: DID of credential definition issuer :param schema_seq_no: schema sequence number :param protocol: indy protocol version :return: credential defini...
['Return', 'credential', 'definition', 'identifier', 'for', 'input', 'issuer', 'DID', 'and', 'schema', 'sequence', 'number', '.']
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L120-L132
5,191
saltstack/salt
salt/states/junos.py
install_os
def install_os(name, **kwargs): ''' Installs the given image on the device. After the installation is complete the device is rebooted, if reboot=True is given as a keyworded argument. .. code-block:: yaml salt://images/junos_image.tgz: junos: - install_os ...
python
def install_os(name, **kwargs): ''' Installs the given image on the device. After the installation is complete the device is rebooted, if reboot=True is given as a keyworded argument. .. code-block:: yaml salt://images/junos_image.tgz: junos: - install_os ...
['def', 'install_os', '(', 'name', ',', '*', '*', 'kwargs', ')', ':', 'ret', '=', '{', "'name'", ':', 'name', ',', "'changes'", ':', '{', '}', ',', "'result'", ':', 'True', ',', "'comment'", ':', "''", '}', 'ret', '[', "'changes'", ']', '=', '__salt__', '[', "'junos.install_os'", ']', '(', 'name', ',', '*', '*', 'kwarg...
Installs the given image on the device. After the installation is complete the device is rebooted, if reboot=True is given as a keyworded argument. .. code-block:: yaml salt://images/junos_image.tgz: junos: - install_os - timeout: 100 -...
['Installs', 'the', 'given', 'image', 'on', 'the', 'device', '.', 'After', 'the', 'installation', 'is', 'complete', 'the', 'device', 'is', 'rebooted', 'if', 'reboot', '=', 'True', 'is', 'given', 'as', 'a', 'keyworded', 'argument', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/junos.py#L363-L395
5,192
mwouts/jupytext
jupytext/cell_reader.py
DoublePercentScriptCellReader.metadata_and_language_from_option_line
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(line[line.find('%...
python
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(line[line.find('%...
['def', 'metadata_and_language_from_option_line', '(', 'self', ',', 'line', ')', ':', 'if', 'self', '.', 'start_code_re', '.', 'match', '(', 'line', ')', ':', 'self', '.', 'language', ',', 'self', '.', 'metadata', '=', 'self', '.', 'options_to_metadata', '(', 'line', '[', 'line', '.', 'find', '(', "'%%'", ')', '+', '2'...
Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.
['Parse', 'code', 'options', 'on', 'the', 'given', 'line', '.', 'When', 'a', 'start', 'of', 'a', 'code', 'cell', 'is', 'found', 'self', '.', 'metadata', 'is', 'set', 'to', 'a', 'dictionary', '.']
train
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L572-L578
5,193
cltk/cltk
cltk/phonology/syllabify.py
get_onsets
def get_onsets(text, vowels="aeiou", threshold=0.0002): """ Source: Resonances in Middle High German: New Methodologies in Prosody, 2017, C. L. Hench :param text: str list: text to be analysed :param vowels: str: valid vowels constituting the syllable :param threshold: minimum frequency count...
python
def get_onsets(text, vowels="aeiou", threshold=0.0002): """ Source: Resonances in Middle High German: New Methodologies in Prosody, 2017, C. L. Hench :param text: str list: text to be analysed :param vowels: str: valid vowels constituting the syllable :param threshold: minimum frequency count...
['def', 'get_onsets', '(', 'text', ',', 'vowels', '=', '"aeiou"', ',', 'threshold', '=', '0.0002', ')', ':', 'onset_dict', '=', 'defaultdict', '(', 'lambda', ':', '0', ')', 'n', '=', 'len', '(', 'text', ')', 'for', 'word', 'in', 'text', ':', 'onset', '=', "''", 'candidates', '=', '[', ']', 'for', 'l', 'in', 'word', ':'...
Source: Resonances in Middle High German: New Methodologies in Prosody, 2017, C. L. Hench :param text: str list: text to be analysed :param vowels: str: valid vowels constituting the syllable :param threshold: minimum frequency count for valid onset, C. Hench noted that the algorithm produces the...
['Source', ':', 'Resonances', 'in', 'Middle', 'High', 'German', ':', 'New', 'Methodologies', 'in', 'Prosody', '2017', 'C', '.', 'L', '.', 'Hench']
train
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/phonology/syllabify.py#L23-L72
5,194
CamDavidsonPilon/lifelines
lifelines/utils/concordance.py
concordance_index
def concordance_index(event_times, predicted_scores, event_observed=None): """ Calculates the concordance index (C-index) between two series of event times. The first is the real survival times from the experimental data, and the other is the predicted survival times from a model of some kind. ...
python
def concordance_index(event_times, predicted_scores, event_observed=None): """ Calculates the concordance index (C-index) between two series of event times. The first is the real survival times from the experimental data, and the other is the predicted survival times from a model of some kind. ...
['def', 'concordance_index', '(', 'event_times', ',', 'predicted_scores', ',', 'event_observed', '=', 'None', ')', ':', 'event_times', '=', 'np', '.', 'asarray', '(', 'event_times', ',', 'dtype', '=', 'float', ')', 'predicted_scores', '=', 'np', '.', 'asarray', '(', 'predicted_scores', ',', 'dtype', '=', 'float', ')', ...
Calculates the concordance index (C-index) between two series of event times. The first is the real survival times from the experimental data, and the other is the predicted survival times from a model of some kind. The c-index is the average of how often a model says X is greater than Y when, in the o...
['Calculates', 'the', 'concordance', 'index', '(', 'C', '-', 'index', ')', 'between', 'two', 'series', 'of', 'event', 'times', '.', 'The', 'first', 'is', 'the', 'real', 'survival', 'times', 'from', 'the', 'experimental', 'data', 'and', 'the', 'other', 'is', 'the', 'predicted', 'survival', 'times', 'from', 'a', 'model',...
train
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/concordance.py#L7-L79
5,195
bcbio/bcbio-nextgen
bcbio/pipeline/sample.py
_merge_out_from_infiles
def _merge_out_from_infiles(in_files): """Generate output merged file name from set of input files. Handles non-shared filesystems where we don't know output path when setting up split parts. """ fname = os.path.commonprefix([os.path.basename(f) for f in in_files]) while fname.endswith(("-", "_...
python
def _merge_out_from_infiles(in_files): """Generate output merged file name from set of input files. Handles non-shared filesystems where we don't know output path when setting up split parts. """ fname = os.path.commonprefix([os.path.basename(f) for f in in_files]) while fname.endswith(("-", "_...
['def', '_merge_out_from_infiles', '(', 'in_files', ')', ':', 'fname', '=', 'os', '.', 'path', '.', 'commonprefix', '(', '[', 'os', '.', 'path', '.', 'basename', '(', 'f', ')', 'for', 'f', 'in', 'in_files', ']', ')', 'while', 'fname', '.', 'endswith', '(', '(', '"-"', ',', '"_"', ',', '"."', ')', ')', ':', 'fname', '='...
Generate output merged file name from set of input files. Handles non-shared filesystems where we don't know output path when setting up split parts.
['Generate', 'output', 'merged', 'file', 'name', 'from', 'set', 'of', 'input', 'files', '.']
train
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L272-L285
5,196
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.complete
def complete(self, default_output=None): """Marks this asynchronous Pipeline as complete. Args: default_output: What value the 'default' output slot should be assigned. Raises: UnexpectedPipelineError if the slot no longer exists or this method was called for a pipeline that is not async...
python
def complete(self, default_output=None): """Marks this asynchronous Pipeline as complete. Args: default_output: What value the 'default' output slot should be assigned. Raises: UnexpectedPipelineError if the slot no longer exists or this method was called for a pipeline that is not async...
['def', 'complete', '(', 'self', ',', 'default_output', '=', 'None', ')', ':', '# TODO: Enforce that all outputs expected by this async pipeline were', '# filled before this complete() function was called. May required all', '# async functions to declare their outputs upfront.', 'if', 'not', 'self', '.', 'async', ':', ...
Marks this asynchronous Pipeline as complete. Args: default_output: What value the 'default' output slot should be assigned. Raises: UnexpectedPipelineError if the slot no longer exists or this method was called for a pipeline that is not async.
['Marks', 'this', 'asynchronous', 'Pipeline', 'as', 'complete', '.']
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L817-L834
5,197
fastai/fastai
fastai/vision/data.py
ImageDataBunch.from_csv
def from_csv(cls, path:PathOrStr, folder:PathOrStr=None, label_delim:str=None, csv_labels:PathOrStr='labels.csv', valid_pct:float=0.2, fn_col:int=0, label_col:int=1, suffix:str='', delimiter:str=None, header:Optional[Union[int,str]]='infer', **kwargs:Any)->'ImageDataBunch': "Cr...
python
def from_csv(cls, path:PathOrStr, folder:PathOrStr=None, label_delim:str=None, csv_labels:PathOrStr='labels.csv', valid_pct:float=0.2, fn_col:int=0, label_col:int=1, suffix:str='', delimiter:str=None, header:Optional[Union[int,str]]='infer', **kwargs:Any)->'ImageDataBunch': "Cr...
['def', 'from_csv', '(', 'cls', ',', 'path', ':', 'PathOrStr', ',', 'folder', ':', 'PathOrStr', '=', 'None', ',', 'label_delim', ':', 'str', '=', 'None', ',', 'csv_labels', ':', 'PathOrStr', '=', "'labels.csv'", ',', 'valid_pct', ':', 'float', '=', '0.2', ',', 'fn_col', ':', 'int', '=', '0', ',', 'label_col', ':', 'int...
Create from a csv file in `path/csv_labels`.
['Create', 'from', 'a', 'csv', 'file', 'in', 'path', '/', 'csv_labels', '.']
train
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/vision/data.py#L123-L130
5,198
cnelson/python-fleet
fleet/v1/client.py
Client._get_proxy_info
def _get_proxy_info(self, _=None): """Generate a ProxyInfo class from a connected SSH transport Args: _ (None): Ignored. This is just here as the ProxyInfo spec requires it. Returns: SSHTunnelProxyInfo: A ProxyInfo with an active socket tunneled through SSH "...
python
def _get_proxy_info(self, _=None): """Generate a ProxyInfo class from a connected SSH transport Args: _ (None): Ignored. This is just here as the ProxyInfo spec requires it. Returns: SSHTunnelProxyInfo: A ProxyInfo with an active socket tunneled through SSH "...
['def', '_get_proxy_info', '(', 'self', ',', '_', '=', 'None', ')', ':', '# parse the fleet endpoint url, to establish a tunnel to that host', '(', 'target_host', ',', 'target_port', ',', 'target_path', ')', '=', 'self', '.', '_endpoint_to_target', '(', 'self', '.', '_endpoint', ')', '# implement the proxy_info interfa...
Generate a ProxyInfo class from a connected SSH transport Args: _ (None): Ignored. This is just here as the ProxyInfo spec requires it. Returns: SSHTunnelProxyInfo: A ProxyInfo with an active socket tunneled through SSH
['Generate', 'a', 'ProxyInfo', 'class', 'from', 'a', 'connected', 'SSH', 'transport']
train
https://github.com/cnelson/python-fleet/blob/a11dcd8bb3986d1d8f0af90d2da7399c9cc54b4d/fleet/v1/client.py#L357-L385
5,199
elehcimd/pynb
pynb/notebook.py
CachedExecutePreprocessor.run_cell
def run_cell(self, cell, cell_index=0): """ Run cell with caching :param cell: cell to run :param cell_index: cell index (optional) :return: """ hash = self.cell_hash(cell, cell_index) fname_session = '/tmp/pynb-cache-{}-session.dill'.format(hash) ...
python
def run_cell(self, cell, cell_index=0): """ Run cell with caching :param cell: cell to run :param cell_index: cell index (optional) :return: """ hash = self.cell_hash(cell, cell_index) fname_session = '/tmp/pynb-cache-{}-session.dill'.format(hash) ...
['def', 'run_cell', '(', 'self', ',', 'cell', ',', 'cell_index', '=', '0', ')', ':', 'hash', '=', 'self', '.', 'cell_hash', '(', 'cell', ',', 'cell_index', ')', 'fname_session', '=', "'/tmp/pynb-cache-{}-session.dill'", '.', 'format', '(', 'hash', ')', 'fname_value', '=', "'/tmp/pynb-cache-{}-value.dill'", '.', 'format...
Run cell with caching :param cell: cell to run :param cell_index: cell index (optional) :return:
['Run', 'cell', 'with', 'caching', ':', 'param', 'cell', ':', 'cell', 'to', 'run', ':', 'param', 'cell_index', ':', 'cell', 'index', '(', 'optional', ')', ':', 'return', ':']
train
https://github.com/elehcimd/pynb/blob/a32af1f0e574f880eccda4a46aede6d65151f8c9/pynb/notebook.py#L54-L119