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
4,000
lincolnloop/salmon
salmon/core/graph.py
WhisperDatabase._create
def _create(self): """Create the Whisper file on disk""" if not os.path.exists(settings.SALMON_WHISPER_DB_PATH): os.makedirs(settings.SALMON_WHISPER_DB_PATH) archives = [whisper.parseRetentionDef(retentionDef) for retentionDef in settings.ARCHIVES.split(",")] ...
python
def _create(self): """Create the Whisper file on disk""" if not os.path.exists(settings.SALMON_WHISPER_DB_PATH): os.makedirs(settings.SALMON_WHISPER_DB_PATH) archives = [whisper.parseRetentionDef(retentionDef) for retentionDef in settings.ARCHIVES.split(",")] ...
['def', '_create', '(', 'self', ')', ':', 'if', 'not', 'os', '.', 'path', '.', 'exists', '(', 'settings', '.', 'SALMON_WHISPER_DB_PATH', ')', ':', 'os', '.', 'makedirs', '(', 'settings', '.', 'SALMON_WHISPER_DB_PATH', ')', 'archives', '=', '[', 'whisper', '.', 'parseRetentionDef', '(', 'retentionDef', ')', 'for', 'rete...
Create the Whisper file on disk
['Create', 'the', 'Whisper', 'file', 'on', 'disk']
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/core/graph.py#L18-L26
4,001
boriel/zxbasic
zxbparser.py
p_arr_access_expr
def p_arr_access_expr(p): """ func_call : ARRAY_ID arg_list """ # This is an array access p[0] = make_call(p[1], p.lineno(1), p[2]) if p[0] is None: return entry = SYMBOL_TABLE.access_call(p[1], p.lineno(1)) entry.accessed = True
python
def p_arr_access_expr(p): """ func_call : ARRAY_ID arg_list """ # This is an array access p[0] = make_call(p[1], p.lineno(1), p[2]) if p[0] is None: return entry = SYMBOL_TABLE.access_call(p[1], p.lineno(1)) entry.accessed = True
['def', 'p_arr_access_expr', '(', 'p', ')', ':', '# This is an array access', 'p', '[', '0', ']', '=', 'make_call', '(', 'p', '[', '1', ']', ',', 'p', '.', 'lineno', '(', '1', ')', ',', 'p', '[', '2', ']', ')', 'if', 'p', '[', '0', ']', 'is', 'None', ':', 'return', 'entry', '=', 'SYMBOL_TABLE', '.', 'access_call', '(',...
func_call : ARRAY_ID arg_list
['func_call', ':', 'ARRAY_ID', 'arg_list']
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L2581-L2589
4,002
SeleniumHQ/selenium
py/selenium/webdriver/firefox/firefox_binary.py
FirefoxBinary.launch_browser
def launch_browser(self, profile, timeout=30): """Launches the browser for the given profile name. It is assumed the profile already exists. """ self.profile = profile self._start_from_profile_path(self.profile.path) self._wait_until_connectable(timeout=timeout)
python
def launch_browser(self, profile, timeout=30): """Launches the browser for the given profile name. It is assumed the profile already exists. """ self.profile = profile self._start_from_profile_path(self.profile.path) self._wait_until_connectable(timeout=timeout)
['def', 'launch_browser', '(', 'self', ',', 'profile', ',', 'timeout', '=', '30', ')', ':', 'self', '.', 'profile', '=', 'profile', 'self', '.', '_start_from_profile_path', '(', 'self', '.', 'profile', '.', 'path', ')', 'self', '.', '_wait_until_connectable', '(', 'timeout', '=', 'timeout', ')']
Launches the browser for the given profile name. It is assumed the profile already exists.
['Launches', 'the', 'browser', 'for', 'the', 'given', 'profile', 'name', '.', 'It', 'is', 'assumed', 'the', 'profile', 'already', 'exists', '.']
train
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/firefox_binary.py#L66-L73
4,003
pantsbuild/pex
pex/common.py
Chroot.clone
def clone(self, into=None): """Clone this chroot. :keyword into: (optional) An optional destination directory to clone the Chroot into. If not specified, a temporary directory will be created. .. versionchanged:: 0.8 The temporary directory created when ``into`` is not specified is now garbag...
python
def clone(self, into=None): """Clone this chroot. :keyword into: (optional) An optional destination directory to clone the Chroot into. If not specified, a temporary directory will be created. .. versionchanged:: 0.8 The temporary directory created when ``into`` is not specified is now garbag...
['def', 'clone', '(', 'self', ',', 'into', '=', 'None', ')', ':', 'into', '=', 'into', 'or', 'safe_mkdtemp', '(', ')', 'new_chroot', '=', 'Chroot', '(', 'into', ')', 'for', 'label', ',', 'fileset', 'in', 'self', '.', 'filesets', '.', 'items', '(', ')', ':', 'for', 'fn', 'in', 'fileset', ':', 'new_chroot', '.', 'link', ...
Clone this chroot. :keyword into: (optional) An optional destination directory to clone the Chroot into. If not specified, a temporary directory will be created. .. versionchanged:: 0.8 The temporary directory created when ``into`` is not specified is now garbage collected on interpreter ex...
['Clone', 'this', 'chroot', '.']
train
https://github.com/pantsbuild/pex/blob/87b2129d860250d3b9edce75b9cb62f9789ee521/pex/common.py#L239-L254
4,004
etcher-be/epab
epab/utils/_repo.py
Repo.list_staged_files
def list_staged_files(self) -> typing.List[str]: """ :return: staged files :rtype: list of str """ staged_files: typing.List[str] = [x.a_path for x in self.repo.index.diff('HEAD')] LOGGER.debug('staged files: %s', staged_files) return staged_files
python
def list_staged_files(self) -> typing.List[str]: """ :return: staged files :rtype: list of str """ staged_files: typing.List[str] = [x.a_path for x in self.repo.index.diff('HEAD')] LOGGER.debug('staged files: %s', staged_files) return staged_files
['def', 'list_staged_files', '(', 'self', ')', '->', 'typing', '.', 'List', '[', 'str', ']', ':', 'staged_files', ':', 'typing', '.', 'List', '[', 'str', ']', '=', '[', 'x', '.', 'a_path', 'for', 'x', 'in', 'self', '.', 'repo', '.', 'index', '.', 'diff', '(', "'HEAD'", ')', ']', 'LOGGER', '.', 'debug', '(', "'staged fi...
:return: staged files :rtype: list of str
[':', 'return', ':', 'staged', 'files', ':', 'rtype', ':', 'list', 'of', 'str']
train
https://github.com/etcher-be/epab/blob/024cde74d058281aa66e6e4b7b71dccbe803b1c1/epab/utils/_repo.py#L212-L219
4,005
bskinn/opan
opan/vpt2/repo.py
OpanAnharmRepo.load
def load(self, fname): """ .. todo:: REPO.load docstring """ # Imports import h5py as h5 from ..error import RepoError # If repo not None, complain if not self._repo == None: raise RepoError(RepoError.STATUS, "Repository already o...
python
def load(self, fname): """ .. todo:: REPO.load docstring """ # Imports import h5py as h5 from ..error import RepoError # If repo not None, complain if not self._repo == None: raise RepoError(RepoError.STATUS, "Repository already o...
['def', 'load', '(', 'self', ',', 'fname', ')', ':', '# Imports', 'import', 'h5py', 'as', 'h5', 'from', '.', '.', 'error', 'import', 'RepoError', '# If repo not None, complain', 'if', 'not', 'self', '.', '_repo', '==', 'None', ':', 'raise', 'RepoError', '(', 'RepoError', '.', 'STATUS', ',', '"Repository already open"',...
.. todo:: REPO.load docstring
['..', 'todo', '::', 'REPO', '.', 'load', 'docstring']
train
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/vpt2/repo.py#L142-L162
4,006
Azure/msrest-for-python
msrest/serialization.py
Deserializer._unpack_content
def _unpack_content(raw_data, content_type=None): """Extract the correct structure for deserialization. If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. if we can't, raise. Your Pipeline should have a RawDeserializer. If not a pipeline response and raw_d...
python
def _unpack_content(raw_data, content_type=None): """Extract the correct structure for deserialization. If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. if we can't, raise. Your Pipeline should have a RawDeserializer. If not a pipeline response and raw_d...
['def', '_unpack_content', '(', 'raw_data', ',', 'content_type', '=', 'None', ')', ':', '# This avoids a circular dependency. We might want to consider RawDesializer is more generic', '# than the pipeline concept, and put it in a toolbox, used both here and in pipeline. TBD.', 'from', '.', 'pipeline', '.', 'universal',...
Extract the correct structure for deserialization. If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. if we can't, raise. Your Pipeline should have a RawDeserializer. If not a pipeline response and raw_data is bytes or string, use content-type to decode it...
['Extract', 'the', 'correct', 'structure', 'for', 'deserialization', '.']
train
https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1339-L1382
4,007
duniter/duniter-python-api
duniterpy/key/ascii_armor.py
AsciiArmor.create
def create(message: str, pubkey: Optional[str] = None, signing_keys: Optional[List[SigningKey]] = None, message_comment: Optional[str] = None, signatures_comment: Optional[str] = None) -> str: """ Encrypt a message in ascii armor format, optionally signing it :param message: Utf-...
python
def create(message: str, pubkey: Optional[str] = None, signing_keys: Optional[List[SigningKey]] = None, message_comment: Optional[str] = None, signatures_comment: Optional[str] = None) -> str: """ Encrypt a message in ascii armor format, optionally signing it :param message: Utf-...
['def', 'create', '(', 'message', ':', 'str', ',', 'pubkey', ':', 'Optional', '[', 'str', ']', '=', 'None', ',', 'signing_keys', ':', 'Optional', '[', 'List', '[', 'SigningKey', ']', ']', '=', 'None', ',', 'message_comment', ':', 'Optional', '[', 'str', ']', '=', 'None', ',', 'signatures_comment', ':', 'Optional', '[',...
Encrypt a message in ascii armor format, optionally signing it :param message: Utf-8 message :param pubkey: Public key of recipient for encryption :param signing_keys: Optional list of SigningKey instances :param message_comment: Optional message comment field :param signatures_...
['Encrypt', 'a', 'message', 'in', 'ascii', 'armor', 'format', 'optionally', 'signing', 'it']
train
https://github.com/duniter/duniter-python-api/blob/3a1e5d61a2f72f5afaf29d010c6cf4dff3648165/duniterpy/key/ascii_armor.py#L67-L130
4,008
edibledinos/pwnypack
pwnypack/codec.py
find_xor_mask
def find_xor_mask(data, alphabet=None, max_depth=3, min_depth=0, iv=None): """ Produce a series of bytestrings that when XORed together end up being equal to ``data`` and only contain characters from the giving ``alphabet``. The initial state (or previous state) can be given as ``iv``. Argument...
python
def find_xor_mask(data, alphabet=None, max_depth=3, min_depth=0, iv=None): """ Produce a series of bytestrings that when XORed together end up being equal to ``data`` and only contain characters from the giving ``alphabet``. The initial state (or previous state) can be given as ``iv``. Argument...
['def', 'find_xor_mask', '(', 'data', ',', 'alphabet', '=', 'None', ',', 'max_depth', '=', '3', ',', 'min_depth', '=', '0', ',', 'iv', '=', 'None', ')', ':', 'if', 'alphabet', 'is', 'None', ':', 'alphabet', '=', 'set', '(', 'i', 'for', 'i', 'in', 'range', '(', '256', ')', 'if', 'i', 'not', 'in', '(', '0', ',', '10', ',...
Produce a series of bytestrings that when XORed together end up being equal to ``data`` and only contain characters from the giving ``alphabet``. The initial state (or previous state) can be given as ``iv``. Arguments: data (bytes): The data to recreate as a series of XOR operations. al...
['Produce', 'a', 'series', 'of', 'bytestrings', 'that', 'when', 'XORed', 'together', 'end', 'up', 'being', 'equal', 'to', 'data', 'and', 'only', 'contain', 'characters', 'from', 'the', 'giving', 'alphabet', '.', 'The', 'initial', 'state', '(', 'or', 'previous', 'state', ')', 'can', 'be', 'given', 'as', 'iv', '.']
train
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L79-L172
4,009
aws/chalice
chalice/utils.py
remove_stage_from_deployed_values
def remove_stage_from_deployed_values(key, filename): # type: (str, str) -> None """Delete a top level key from the deployed JSON file.""" final_values = {} # type: Dict[str, Any] try: with open(filename, 'r') as f: final_values = json.load(f) except IOError: # If there ...
python
def remove_stage_from_deployed_values(key, filename): # type: (str, str) -> None """Delete a top level key from the deployed JSON file.""" final_values = {} # type: Dict[str, Any] try: with open(filename, 'r') as f: final_values = json.load(f) except IOError: # If there ...
['def', 'remove_stage_from_deployed_values', '(', 'key', ',', 'filename', ')', ':', '# type: (str, str) -> None', 'final_values', '=', '{', '}', '# type: Dict[str, Any]', 'try', ':', 'with', 'open', '(', 'filename', ',', "'r'", ')', 'as', 'f', ':', 'final_values', '=', 'json', '.', 'load', '(', 'f', ')', 'except', 'IOE...
Delete a top level key from the deployed JSON file.
['Delete', 'a', 'top', 'level', 'key', 'from', 'the', 'deployed', 'JSON', 'file', '.']
train
https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L49-L67
4,010
lawsie/guizero
guizero/Box.py
Box.set_border
def set_border(self, thickness, color="black"): """ Sets the border thickness and color. :param int thickness: The thickenss of the border. :param str color: The color of the border. """ self._set_tk_config("highlightthickness", thickness) ...
python
def set_border(self, thickness, color="black"): """ Sets the border thickness and color. :param int thickness: The thickenss of the border. :param str color: The color of the border. """ self._set_tk_config("highlightthickness", thickness) ...
['def', 'set_border', '(', 'self', ',', 'thickness', ',', 'color', '=', '"black"', ')', ':', 'self', '.', '_set_tk_config', '(', '"highlightthickness"', ',', 'thickness', ')', 'self', '.', '_set_tk_config', '(', '"highlightbackground"', ',', 'utils', '.', 'convert_color', '(', 'color', ')', ')']
Sets the border thickness and color. :param int thickness: The thickenss of the border. :param str color: The color of the border.
['Sets', 'the', 'border', 'thickness', 'and', 'color', '.']
train
https://github.com/lawsie/guizero/blob/84c7f0b314fa86f9fc88eb11c9a0f6c4b57155e2/guizero/Box.py#L87-L98
4,011
hyperledger/indy-plenum
plenum/server/client_authn.py
ClientAuthNr.authenticate
def authenticate(self, msg: Dict, identifier: Optional[str] = None, signature: Optional[str] = None, threshold: Optional[int] = None, key: Optional[str] = None) -> str: """ Authenticate the client's ...
python
def authenticate(self, msg: Dict, identifier: Optional[str] = None, signature: Optional[str] = None, threshold: Optional[int] = None, key: Optional[str] = None) -> str: """ Authenticate the client's ...
['def', 'authenticate', '(', 'self', ',', 'msg', ':', 'Dict', ',', 'identifier', ':', 'Optional', '[', 'str', ']', '=', 'None', ',', 'signature', ':', 'Optional', '[', 'str', ']', '=', 'None', ',', 'threshold', ':', 'Optional', '[', 'int', ']', '=', 'None', ',', 'key', ':', 'Optional', '[', 'str', ']', '=', 'None', ')'...
Authenticate the client's message with the signature provided. :param identifier: some unique identifier; if None, then try to use msg['identifier'] as identifier :param signature: a utf-8 and base58 encoded signature :param msg: the message to authenticate :param threshold: The...
['Authenticate', 'the', 'client', 's', 'message', 'with', 'the', 'signature', 'provided', '.']
train
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/client_authn.py#L31-L49
4,012
UCL-INGI/INGInious
inginious/frontend/task_problems.py
DisplayableMultipleChoiceProblem.show_input
def show_input(self, template_helper, language, seed): """ Show multiple choice problems """ choices = [] limit = self._limit if limit == 0: limit = len(self._choices) # no limit rand = Random("{}#{}#{}".format(self.get_task().get_id(), self.get_id(), seed)) ...
python
def show_input(self, template_helper, language, seed): """ Show multiple choice problems """ choices = [] limit = self._limit if limit == 0: limit = len(self._choices) # no limit rand = Random("{}#{}#{}".format(self.get_task().get_id(), self.get_id(), seed)) ...
['def', 'show_input', '(', 'self', ',', 'template_helper', ',', 'language', ',', 'seed', ')', ':', 'choices', '=', '[', ']', 'limit', '=', 'self', '.', '_limit', 'if', 'limit', '==', '0', ':', 'limit', '=', 'len', '(', 'self', '.', '_choices', ')', '# no limit', 'rand', '=', 'Random', '(', '"{}#{}#{}"', '.', 'format', ...
Show multiple choice problems
['Show', 'multiple', 'choice', 'problems']
train
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/task_problems.py#L153-L199
4,013
thejunglejane/datums
datums/models/base.py
GhostBase.update
def update(cls, **kwargs): ''' If a record matching the instance id already exists in the database, update it. If a record matching the instance id does not already exist, create a new record. ''' q = cls._get_instance(**{'id': kwargs['id']}) if q: fo...
python
def update(cls, **kwargs): ''' If a record matching the instance id already exists in the database, update it. If a record matching the instance id does not already exist, create a new record. ''' q = cls._get_instance(**{'id': kwargs['id']}) if q: fo...
['def', 'update', '(', 'cls', ',', '*', '*', 'kwargs', ')', ':', 'q', '=', 'cls', '.', '_get_instance', '(', '*', '*', '{', "'id'", ':', 'kwargs', '[', "'id'", ']', '}', ')', 'if', 'q', ':', 'for', 'k', ',', 'v', 'in', 'kwargs', '.', 'items', '(', ')', ':', 'setattr', '(', 'q', ',', 'k', ',', 'v', ')', '_action_and_com...
If a record matching the instance id already exists in the database, update it. If a record matching the instance id does not already exist, create a new record.
['If', 'a', 'record', 'matching', 'the', 'instance', 'id', 'already', 'exists', 'in', 'the', 'database', 'update', 'it', '.', 'If', 'a', 'record', 'matching', 'the', 'instance', 'id', 'does', 'not', 'already', 'exist', 'create', 'a', 'new', 'record', '.']
train
https://github.com/thejunglejane/datums/blob/2250b365e37ba952c2426edc615c1487afabae6e/datums/models/base.py#L70-L82
4,014
anti1869/sunhead
src/sunhead/utils.py
parallel_results
async def parallel_results(future_map: Sequence[Tuple]) -> Dict: """ Run parallel execution of futures and return mapping of their results to the provided keys. Just a neat shortcut around ``asyncio.gather()`` :param future_map: Keys to futures mapping, e.g.: ( ('nav', get_nav()), ('content, get_conten...
python
async def parallel_results(future_map: Sequence[Tuple]) -> Dict: """ Run parallel execution of futures and return mapping of their results to the provided keys. Just a neat shortcut around ``asyncio.gather()`` :param future_map: Keys to futures mapping, e.g.: ( ('nav', get_nav()), ('content, get_conten...
['async', 'def', 'parallel_results', '(', 'future_map', ':', 'Sequence', '[', 'Tuple', ']', ')', '->', 'Dict', ':', 'ctx_methods', '=', 'OrderedDict', '(', 'future_map', ')', 'fs', '=', 'list', '(', 'ctx_methods', '.', 'values', '(', ')', ')', 'results', '=', 'await', 'asyncio', '.', 'gather', '(', '*', 'fs', ')', 'res...
Run parallel execution of futures and return mapping of their results to the provided keys. Just a neat shortcut around ``asyncio.gather()`` :param future_map: Keys to futures mapping, e.g.: ( ('nav', get_nav()), ('content, get_content()) ) :return: Dict with futures results mapped to keys {'nav': {1:2}, '...
['Run', 'parallel', 'execution', 'of', 'futures', 'and', 'return', 'mapping', 'of', 'their', 'results', 'to', 'the', 'provided', 'keys', '.', 'Just', 'a', 'neat', 'shortcut', 'around', 'asyncio', '.', 'gather', '()']
train
https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/utils.py#L99-L113
4,015
rapidpro/expressions
python/temba_expressions/functions/__init__.py
FunctionManager.invoke_function
def invoke_function(self, ctx, name, arguments): """ Invokes the given function :param ctx: the evaluation context :param name: the function name (case insensitive) :param arguments: the arguments to be passed to the function :return: the function return value """...
python
def invoke_function(self, ctx, name, arguments): """ Invokes the given function :param ctx: the evaluation context :param name: the function name (case insensitive) :param arguments: the arguments to be passed to the function :return: the function return value """...
['def', 'invoke_function', '(', 'self', ',', 'ctx', ',', 'name', ',', 'arguments', ')', ':', 'from', 'temba_expressions', 'import', 'EvaluationError', ',', 'conversions', '# find function with given name', 'func', '=', 'self', '.', 'get_function', '(', 'name', ')', 'if', 'func', 'is', 'None', ':', 'raise', 'EvaluationE...
Invokes the given function :param ctx: the evaluation context :param name: the function name (case insensitive) :param arguments: the arguments to be passed to the function :return: the function return value
['Invokes', 'the', 'given', 'function', ':', 'param', 'ctx', ':', 'the', 'evaluation', 'context', ':', 'param', 'name', ':', 'the', 'function', 'name', '(', 'case', 'insensitive', ')', ':', 'param', 'arguments', ':', 'the', 'arguments', 'to', 'be', 'passed', 'to', 'the', 'function', ':', 'return', ':', 'the', 'function...
train
https://github.com/rapidpro/expressions/blob/b03d91ec58fc328960bce90ecb5fa49dcf467627/python/temba_expressions/functions/__init__.py#L29-L81
4,016
tjvr/kurt
kurt/scratch14/objtable.py
decode_network
def decode_network(objects): """Return root object from ref-containing obj table entries""" def resolve_ref(obj, objects=objects): if isinstance(obj, Ref): # first entry is 1 return objects[obj.index - 1] else: return obj # Reading the ObjTable backwards ...
python
def decode_network(objects): """Return root object from ref-containing obj table entries""" def resolve_ref(obj, objects=objects): if isinstance(obj, Ref): # first entry is 1 return objects[obj.index - 1] else: return obj # Reading the ObjTable backwards ...
['def', 'decode_network', '(', 'objects', ')', ':', 'def', 'resolve_ref', '(', 'obj', ',', 'objects', '=', 'objects', ')', ':', 'if', 'isinstance', '(', 'obj', ',', 'Ref', ')', ':', '# first entry is 1', 'return', 'objects', '[', 'obj', '.', 'index', '-', '1', ']', 'else', ':', 'return', 'obj', '# Reading the ObjTable ...
Return root object from ref-containing obj table entries
['Return', 'root', 'object', 'from', 'ref', '-', 'containing', 'obj', 'table', 'entries']
train
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L251-L298
4,017
nvbn/thefuck
thefuck/specific/git.py
git_support
def git_support(fn, command): """Resolves git aliases and supports testing for both git and hub.""" # supports GitHub's `hub` command # which is recommended to be used with `alias git=hub` # but at this point, shell aliases have already been resolved if not is_app(command, 'git', 'hub'): ret...
python
def git_support(fn, command): """Resolves git aliases and supports testing for both git and hub.""" # supports GitHub's `hub` command # which is recommended to be used with `alias git=hub` # but at this point, shell aliases have already been resolved if not is_app(command, 'git', 'hub'): ret...
['def', 'git_support', '(', 'fn', ',', 'command', ')', ':', "# supports GitHub's `hub` command", '# which is recommended to be used with `alias git=hub`', '# but at this point, shell aliases have already been resolved', 'if', 'not', 'is_app', '(', 'command', ',', "'git'", ',', "'hub'", ')', ':', 'return', 'False', '# p...
Resolves git aliases and supports testing for both git and hub.
['Resolves', 'git', 'aliases', 'and', 'supports', 'testing', 'for', 'both', 'git', 'and', 'hub', '.']
train
https://github.com/nvbn/thefuck/blob/40ab4eb62db57627bff10cf029d29c94704086a2/thefuck/specific/git.py#L8-L32
4,018
DLR-RM/RAFCON
source/rafcon/gui/mygaphas/items/ports.py
PortView.get_port_area
def get_port_area(self, view): """Calculates the drawing area affected by the (hovered) port """ state_v = self.parent center = self.handle.pos margin = self.port_side_size / 4. if self.side in [SnappedSide.LEFT, SnappedSide.RIGHT]: height, width = self.port_s...
python
def get_port_area(self, view): """Calculates the drawing area affected by the (hovered) port """ state_v = self.parent center = self.handle.pos margin = self.port_side_size / 4. if self.side in [SnappedSide.LEFT, SnappedSide.RIGHT]: height, width = self.port_s...
['def', 'get_port_area', '(', 'self', ',', 'view', ')', ':', 'state_v', '=', 'self', '.', 'parent', 'center', '=', 'self', '.', 'handle', '.', 'pos', 'margin', '=', 'self', '.', 'port_side_size', '/', '4.', 'if', 'self', '.', 'side', 'in', '[', 'SnappedSide', '.', 'LEFT', ',', 'SnappedSide', '.', 'RIGHT', ']', ':', 'he...
Calculates the drawing area affected by the (hovered) port
['Calculates', 'the', 'drawing', 'area', 'affected', 'by', 'the', '(', 'hovered', ')', 'port']
train
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/items/ports.py#L225-L240
4,019
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher.search_and_extract_nucleotides_matching_nucleotide_database
def search_and_extract_nucleotides_matching_nucleotide_database(self, unpack, euk_check, search_method, ...
python
def search_and_extract_nucleotides_matching_nucleotide_database(self, unpack, euk_check, search_method, ...
['def', 'search_and_extract_nucleotides_matching_nucleotide_database', '(', 'self', ',', 'unpack', ',', 'euk_check', ',', 'search_method', ',', 'maximum_range', ',', 'threads', ',', 'evalue', ',', 'hmmsearch_output_table', ',', 'hit_reads_fasta', ')', ':', 'if', 'search_method', '==', '"hmmsearch"', ':', '# First searc...
As per nt_db_search() except slightly lower level. Search an input read set (unpack) and then extract the sequences that hit. Parameters ---------- hmmsearch_output_table: str path to hmmsearch output table hit_reads_fasta: str path to hit nucleotide sequ...
['As', 'per', 'nt_db_search', '()', 'except', 'slightly', 'lower', 'level', '.', 'Search', 'an', 'input', 'read', 'set', '(', 'unpack', ')', 'and', 'then', 'extract', 'the', 'sequences', 'that', 'hit', '.']
train
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L1015-L1108
4,020
jazzband/django-push-notifications
push_notifications/apns.py
apns_send_bulk_message
def apns_send_bulk_message( registration_ids, alert, application_id=None, certfile=None, **kwargs ): """ Sends an APNS notification to one or more registration_ids. The registration_ids argument needs to be a list. Note that if set alert should always be a string. If it is not set, it won"t be included in the no...
python
def apns_send_bulk_message( registration_ids, alert, application_id=None, certfile=None, **kwargs ): """ Sends an APNS notification to one or more registration_ids. The registration_ids argument needs to be a list. Note that if set alert should always be a string. If it is not set, it won"t be included in the no...
['def', 'apns_send_bulk_message', '(', 'registration_ids', ',', 'alert', ',', 'application_id', '=', 'None', ',', 'certfile', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'results', '=', '_apns_send', '(', 'registration_ids', ',', 'alert', ',', 'batch', '=', 'True', ',', 'application_id', '=', 'application_id', ',',...
Sends an APNS notification to one or more registration_ids. The registration_ids argument needs to be a list. Note that if set alert should always be a string. If it is not set, it won"t be included in the notification. You will need to pass None to this for silent notifications.
['Sends', 'an', 'APNS', 'notification', 'to', 'one', 'or', 'more', 'registration_ids', '.', 'The', 'registration_ids', 'argument', 'needs', 'to', 'be', 'a', 'list', '.']
train
https://github.com/jazzband/django-push-notifications/blob/c4a0d710711fa27bfb6533c0bf3468cb67a62679/push_notifications/apns.py#L123-L141
4,021
MeaningCloud/meaningcloud-python
meaningcloud/Response.py
Response.getRemainingCredits
def getRemainingCredits(self): """ Returns the remaining credits for the license key used after the request was made :return: String with remaining credits """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('remainin...
python
def getRemainingCredits(self): """ Returns the remaining credits for the license key used after the request was made :return: String with remaining credits """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('remainin...
['def', 'getRemainingCredits', '(', 'self', ')', ':', 'if', "'status'", 'in', 'self', '.', '_response', '.', 'keys', '(', ')', ':', 'if', '(', 'self', '.', '_response', '[', "'status'", ']', 'is', 'not', 'None', ')', 'and', '(', "'remaining_credits'", 'in', 'self', '.', '_response', '[', "'status'", ']', '.', 'keys', '...
Returns the remaining credits for the license key used after the request was made :return: String with remaining credits
['Returns', 'the', 'remaining', 'credits', 'for', 'the', 'license', 'key', 'used', 'after', 'the', 'request', 'was', 'made']
train
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/Response.py#L87-L104
4,022
joausaga/ideascaly
ideascaly/api.py
API.vote_up_idea
def vote_up_idea(self, *args, **kwargs): """ :allowed_param: 'ideaId', 'myVote' (optional) """ kwargs.update({'headers': {'content-type':'application/json'}}) return bind_api( api=self, path='/ideas/{ideaId}/vote/up', method='POST', payload...
python
def vote_up_idea(self, *args, **kwargs): """ :allowed_param: 'ideaId', 'myVote' (optional) """ kwargs.update({'headers': {'content-type':'application/json'}}) return bind_api( api=self, path='/ideas/{ideaId}/vote/up', method='POST', payload...
['def', 'vote_up_idea', '(', 'self', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'kwargs', '.', 'update', '(', '{', "'headers'", ':', '{', "'content-type'", ':', "'application/json'", '}', '}', ')', 'return', 'bind_api', '(', 'api', '=', 'self', ',', 'path', '=', "'/ideas/{ideaId}/vote/up'", ',', 'method', '='...
:allowed_param: 'ideaId', 'myVote' (optional)
[':', 'allowed_param', ':', 'ideaId', 'myVote', '(', 'optional', ')']
train
https://github.com/joausaga/ideascaly/blob/8aabb7bb1ed058406a8d352a7844e183ab64e008/ideascaly/api.py#L291-L302
4,023
davidmcclure/textplot
textplot/text.py
Text.term_count_buckets
def term_count_buckets(self): """ Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text. """ buckets = {} for term, count in self.term_counts().items(): if count in buckets: buckets[count...
python
def term_count_buckets(self): """ Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text. """ buckets = {} for term, count in self.term_counts().items(): if count in buckets: buckets[count...
['def', 'term_count_buckets', '(', 'self', ')', ':', 'buckets', '=', '{', '}', 'for', 'term', ',', 'count', 'in', 'self', '.', 'term_counts', '(', ')', '.', 'items', '(', ')', ':', 'if', 'count', 'in', 'buckets', ':', 'buckets', '[', 'count', ']', '.', 'append', '(', 'term', ')', 'else', ':', 'buckets', '[', 'count', '...
Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text.
['Returns', ':', 'dict', ':', 'A', 'dictionary', 'that', 'maps', 'occurrence', 'counts', 'to', 'the', 'terms', 'that', 'appear', 'that', 'many', 'times', 'in', 'the', 'text', '.']
train
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L112-L125
4,024
explosion/spaCy
bin/ud/run_eval.py
_contains_blinded_text
def _contains_blinded_text(stats_xml): """ Heuristic to determine whether the treebank has blinded texts or not """ tree = ET.parse(stats_xml) root = tree.getroot() total_tokens = int(root.find('size/total/tokens').text) unique_lemmas = int(root.find('lemmas').get('unique')) # assume the corpus...
python
def _contains_blinded_text(stats_xml): """ Heuristic to determine whether the treebank has blinded texts or not """ tree = ET.parse(stats_xml) root = tree.getroot() total_tokens = int(root.find('size/total/tokens').text) unique_lemmas = int(root.find('lemmas').get('unique')) # assume the corpus...
['def', '_contains_blinded_text', '(', 'stats_xml', ')', ':', 'tree', '=', 'ET', '.', 'parse', '(', 'stats_xml', ')', 'root', '=', 'tree', '.', 'getroot', '(', ')', 'total_tokens', '=', 'int', '(', 'root', '.', 'find', '(', "'size/total/tokens'", ')', '.', 'text', ')', 'unique_lemmas', '=', 'int', '(', 'root', '.', 'fi...
Heuristic to determine whether the treebank has blinded texts or not
['Heuristic', 'to', 'determine', 'whether', 'the', 'treebank', 'has', 'blinded', 'texts', 'or', 'not']
train
https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/bin/ud/run_eval.py#L71-L79
4,025
wakatime/wakatime
wakatime/packages/urllib3/connectionpool.py
HTTPConnectionPool.close
def close(self): """ Close all pooled connections and disable the pool. """ # Disable access to the pool old_pool, self.pool = self.pool, None try: while True: conn = old_pool.get(block=False) if conn: conn....
python
def close(self): """ Close all pooled connections and disable the pool. """ # Disable access to the pool old_pool, self.pool = self.pool, None try: while True: conn = old_pool.get(block=False) if conn: conn....
['def', 'close', '(', 'self', ')', ':', '# Disable access to the pool', 'old_pool', ',', 'self', '.', 'pool', '=', 'self', '.', 'pool', ',', 'None', 'try', ':', 'while', 'True', ':', 'conn', '=', 'old_pool', '.', 'get', '(', 'block', '=', 'False', ')', 'if', 'conn', ':', 'conn', '.', 'close', '(', ')', 'except', 'queue...
Close all pooled connections and disable the pool.
['Close', 'all', 'pooled', 'connections', 'and', 'disable', 'the', 'pool', '.']
train
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/urllib3/connectionpool.py#L410-L424
4,026
wavefrontHQ/python-client
wavefront_api_client/models/alert.py
Alert.alert_type
def alert_type(self, alert_type): """Sets the alert_type of this Alert. Alert type. # noqa: E501 :param alert_type: The alert_type of this Alert. # noqa: E501 :type: str """ allowed_values = ["CLASSIC", "THRESHOLD"] # noqa: E501 if alert_type not in allowed_v...
python
def alert_type(self, alert_type): """Sets the alert_type of this Alert. Alert type. # noqa: E501 :param alert_type: The alert_type of this Alert. # noqa: E501 :type: str """ allowed_values = ["CLASSIC", "THRESHOLD"] # noqa: E501 if alert_type not in allowed_v...
['def', 'alert_type', '(', 'self', ',', 'alert_type', ')', ':', 'allowed_values', '=', '[', '"CLASSIC"', ',', '"THRESHOLD"', ']', '# noqa: E501', 'if', 'alert_type', 'not', 'in', 'allowed_values', ':', 'raise', 'ValueError', '(', '"Invalid value for `alert_type` ({0}), must be one of {1}"', '# noqa: E501', '.', 'format...
Sets the alert_type of this Alert. Alert type. # noqa: E501 :param alert_type: The alert_type of this Alert. # noqa: E501 :type: str
['Sets', 'the', 'alert_type', 'of', 'this', 'Alert', '.']
train
https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/models/alert.py#L395-L410
4,027
saltstack/salt
salt/modules/opkg.py
_create_repo
def _create_repo(line, filename): ''' Create repo ''' repo = {} if line.startswith('#'): repo['enabled'] = False line = line[1:] else: repo['enabled'] = True cols = salt.utils.args.shlex_split(line.strip()) repo['compressed'] = not cols[0] in 'src' repo['name'...
python
def _create_repo(line, filename): ''' Create repo ''' repo = {} if line.startswith('#'): repo['enabled'] = False line = line[1:] else: repo['enabled'] = True cols = salt.utils.args.shlex_split(line.strip()) repo['compressed'] = not cols[0] in 'src' repo['name'...
['def', '_create_repo', '(', 'line', ',', 'filename', ')', ':', 'repo', '=', '{', '}', 'if', 'line', '.', 'startswith', '(', "'#'", ')', ':', 'repo', '[', "'enabled'", ']', '=', 'False', 'line', '=', 'line', '[', '1', ':', ']', 'else', ':', 'repo', '[', "'enabled'", ']', '=', 'True', 'cols', '=', 'salt', '.', 'utils', ...
Create repo
['Create', 'repo']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/opkg.py#L1274-L1291
4,028
sethmlarson/virtualbox-python
virtualbox/library.py
IMedium.resize
def resize(self, logical_size): """Starts resizing this medium. This means that the nominal size of the medium is set to the new value. Both increasing and decreasing the size is possible, and there are no safety checks, since VirtualBox does not make any assumptions about the medium con...
python
def resize(self, logical_size): """Starts resizing this medium. This means that the nominal size of the medium is set to the new value. Both increasing and decreasing the size is possible, and there are no safety checks, since VirtualBox does not make any assumptions about the medium con...
['def', 'resize', '(', 'self', ',', 'logical_size', ')', ':', 'if', 'not', 'isinstance', '(', 'logical_size', ',', 'baseinteger', ')', ':', 'raise', 'TypeError', '(', '"logical_size can only be an instance of type baseinteger"', ')', 'progress', '=', 'self', '.', '_call', '(', '"resize"', ',', 'in_p', '=', '[', 'logica...
Starts resizing this medium. This means that the nominal size of the medium is set to the new value. Both increasing and decreasing the size is possible, and there are no safety checks, since VirtualBox does not make any assumptions about the medium contents. Resizing usually ne...
['Starts', 'resizing', 'this', 'medium', '.', 'This', 'means', 'that', 'the', 'nominal', 'size', 'of', 'the', 'medium', 'is', 'set', 'to', 'the', 'new', 'value', '.', 'Both', 'increasing', 'and', 'decreasing', 'the', 'size', 'is', 'possible', 'and', 'there', 'are', 'no', 'safety', 'checks', 'since', 'VirtualBox', 'does...
train
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L23749-L23782
4,029
estnltk/estnltk
estnltk/text.py
Text.verb_chain_texts
def verb_chain_texts(self): """The list of texts of ``verb_chains`` layer elements.""" if not self.is_tagged(VERB_CHAINS): self.tag_verb_chains() return self.texts(VERB_CHAINS)
python
def verb_chain_texts(self): """The list of texts of ``verb_chains`` layer elements.""" if not self.is_tagged(VERB_CHAINS): self.tag_verb_chains() return self.texts(VERB_CHAINS)
['def', 'verb_chain_texts', '(', 'self', ')', ':', 'if', 'not', 'self', '.', 'is_tagged', '(', 'VERB_CHAINS', ')', ':', 'self', '.', 'tag_verb_chains', '(', ')', 'return', 'self', '.', 'texts', '(', 'VERB_CHAINS', ')']
The list of texts of ``verb_chains`` layer elements.
['The', 'list', 'of', 'texts', 'of', 'verb_chains', 'layer', 'elements', '.']
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/text.py#L1047-L1051
4,030
tensorflow/tensor2tensor
tensor2tensor/trax/history.py
History.metrics_for_mode
def metrics_for_mode(self, mode): """Metrics available for a given mode.""" if mode not in self._values: logging.info("Mode %s not found", mode) return [] return sorted(list(self._values[mode].keys()))
python
def metrics_for_mode(self, mode): """Metrics available for a given mode.""" if mode not in self._values: logging.info("Mode %s not found", mode) return [] return sorted(list(self._values[mode].keys()))
['def', 'metrics_for_mode', '(', 'self', ',', 'mode', ')', ':', 'if', 'mode', 'not', 'in', 'self', '.', '_values', ':', 'logging', '.', 'info', '(', '"Mode %s not found"', ',', 'mode', ')', 'return', '[', ']', 'return', 'sorted', '(', 'list', '(', 'self', '.', '_values', '[', 'mode', ']', '.', 'keys', '(', ')', ')', ')...
Metrics available for a given mode.
['Metrics', 'available', 'for', 'a', 'given', 'mode', '.']
train
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/history.py#L70-L75
4,031
gem/oq-engine
openquake/hazardlib/valid.py
probabilities
def probabilities(value, rows=0, cols=0): """ :param value: input string, comma separated or space separated :param rows: the number of rows if the floats are in a matrix (0 otherwise) :param cols: the number of columns if the floats are in a matrix (or 0 :returns: a list of probabilities >>> p...
python
def probabilities(value, rows=0, cols=0): """ :param value: input string, comma separated or space separated :param rows: the number of rows if the floats are in a matrix (0 otherwise) :param cols: the number of columns if the floats are in a matrix (or 0 :returns: a list of probabilities >>> p...
['def', 'probabilities', '(', 'value', ',', 'rows', '=', '0', ',', 'cols', '=', '0', ')', ':', 'probs', '=', 'list', '(', 'map', '(', 'probability', ',', 'value', '.', 'replace', '(', "','", ',', "' '", ')', '.', 'split', '(', ')', ')', ')', 'if', 'rows', 'and', 'cols', ':', 'probs', '=', 'numpy', '.', 'array', '(', 'p...
:param value: input string, comma separated or space separated :param rows: the number of rows if the floats are in a matrix (0 otherwise) :param cols: the number of columns if the floats are in a matrix (or 0 :returns: a list of probabilities >>> probabilities('') [] >>> probabilities('1') ...
[':', 'param', 'value', ':', 'input', 'string', 'comma', 'separated', 'or', 'space', 'separated', ':', 'param', 'rows', ':', 'the', 'number', 'of', 'rows', 'if', 'the', 'floats', 'are', 'in', 'a', 'matrix', '(', '0', 'otherwise', ')', ':', 'param', 'cols', ':', 'the', 'number', 'of', 'columns', 'if', 'the', 'floats', '...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L587-L606
4,032
wonambi-python/wonambi
wonambi/trans/analyze.py
event_params
def event_params(segments, params, band=None, n_fft=None, slopes=None, prep=None, parent=None): """Compute event parameters. Parameters ---------- segments : instance of wonambi.trans.select.Segments list of segments, with time series and metadata params : dict of bool...
python
def event_params(segments, params, band=None, n_fft=None, slopes=None, prep=None, parent=None): """Compute event parameters. Parameters ---------- segments : instance of wonambi.trans.select.Segments list of segments, with time series and metadata params : dict of bool...
['def', 'event_params', '(', 'segments', ',', 'params', ',', 'band', '=', 'None', ',', 'n_fft', '=', 'None', ',', 'slopes', '=', 'None', ',', 'prep', '=', 'None', ',', 'parent', '=', 'None', ')', ':', 'if', 'parent', 'is', 'not', 'None', ':', 'progress', '=', 'QProgressDialog', '(', "'Computing parameters'", ',', "'Abo...
Compute event parameters. Parameters ---------- segments : instance of wonambi.trans.select.Segments list of segments, with time series and metadata params : dict of bool, or str 'dur', 'minamp', 'maxamp', 'ptp', 'rms', 'power', 'peakf', 'energy', 'peakef'. If 'all', a dict...
['Compute', 'event', 'parameters', '.', 'Parameters', '----------', 'segments', ':', 'instance', 'of', 'wonambi', '.', 'trans', '.', 'select', '.', 'Segments', 'list', 'of', 'segments', 'with', 'time', 'series', 'and', 'metadata', 'params', ':', 'dict', 'of', 'bool', 'or', 'str', 'dur', 'minamp', 'maxamp', 'ptp', 'rms'...
train
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/trans/analyze.py#L25-L167
4,033
kaste/mockito-python
mockito/spying.py
spy
def spy(object): """Spy an object. Spying means that all functions will behave as before, so they will be side effects, but the interactions can be verified afterwards. Returns Dummy-like, almost empty object as proxy to `object`. The *returned* object must be injected and used by the code under ...
python
def spy(object): """Spy an object. Spying means that all functions will behave as before, so they will be side effects, but the interactions can be verified afterwards. Returns Dummy-like, almost empty object as proxy to `object`. The *returned* object must be injected and used by the code under ...
['def', 'spy', '(', 'object', ')', ':', 'if', 'inspect', '.', 'isclass', '(', 'object', ')', 'or', 'inspect', '.', 'ismodule', '(', 'object', ')', ':', 'class_', '=', 'None', 'else', ':', 'class_', '=', 'object', '.', '__class__', 'class', 'Spy', '(', '_Dummy', ')', ':', 'if', 'class_', ':', '__class__', '=', 'class_',...
Spy an object. Spying means that all functions will behave as before, so they will be side effects, but the interactions can be verified afterwards. Returns Dummy-like, almost empty object as proxy to `object`. The *returned* object must be injected and used by the code under test; after that all...
['Spy', 'an', 'object', '.']
train
https://github.com/kaste/mockito-python/blob/d6b22b003f56ee5b156dbd9d8ba209faf35b6713/mockito/spying.py#L33-L78
4,034
valohai/ulid2
ulid2.py
generate_ulid_as_uuid
def generate_ulid_as_uuid(timestamp=None, monotonic=False): """ Generate an ULID, but expressed as an UUID. :param timestamp: An optional timestamp override. If `None`, the current time is used. :type timestamp: int|float|datetime.datetime|None :param monotonic: Attempt to ens...
python
def generate_ulid_as_uuid(timestamp=None, monotonic=False): """ Generate an ULID, but expressed as an UUID. :param timestamp: An optional timestamp override. If `None`, the current time is used. :type timestamp: int|float|datetime.datetime|None :param monotonic: Attempt to ens...
['def', 'generate_ulid_as_uuid', '(', 'timestamp', '=', 'None', ',', 'monotonic', '=', 'False', ')', ':', 'return', 'uuid', '.', 'UUID', '(', 'bytes', '=', 'generate_binary_ulid', '(', 'timestamp', ',', 'monotonic', '=', 'monotonic', ')', ')']
Generate an ULID, but expressed as an UUID. :param timestamp: An optional timestamp override. If `None`, the current time is used. :type timestamp: int|float|datetime.datetime|None :param monotonic: Attempt to ensure ULIDs are monotonically increasing. Monotonic ...
['Generate', 'an', 'ULID', 'but', 'expressed', 'as', 'an', 'UUID', '.']
train
https://github.com/valohai/ulid2/blob/cebc523ac70c5d5ca055c0c3de6318de617b07d7/ulid2.py#L208-L221
4,035
zhanglab/psamm
psamm/fluxanalysis.py
flux_variability
def flux_variability(model, reactions, fixed, tfba, solver): """Find the variability of each reaction while fixing certain fluxes. Yields the reaction id, and a tuple of minimum and maximum value for each of the given reactions. The fixed reactions are given in a dictionary as a reaction id to value ma...
python
def flux_variability(model, reactions, fixed, tfba, solver): """Find the variability of each reaction while fixing certain fluxes. Yields the reaction id, and a tuple of minimum and maximum value for each of the given reactions. The fixed reactions are given in a dictionary as a reaction id to value ma...
['def', 'flux_variability', '(', 'model', ',', 'reactions', ',', 'fixed', ',', 'tfba', ',', 'solver', ')', ':', 'fba', '=', '_get_fba_problem', '(', 'model', ',', 'tfba', ',', 'solver', ')', 'for', 'reaction_id', ',', 'value', 'in', 'iteritems', '(', 'fixed', ')', ':', 'flux', '=', 'fba', '.', 'get_flux_var', '(', 'rea...
Find the variability of each reaction while fixing certain fluxes. Yields the reaction id, and a tuple of minimum and maximum value for each of the given reactions. The fixed reactions are given in a dictionary as a reaction id to value mapping. This is an implementation of flux variability analysis (...
['Find', 'the', 'variability', 'of', 'each', 'reaction', 'while', 'fixing', 'certain', 'fluxes', '.']
train
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L323-L357
4,036
luckydonald/pytgbot
code_generation/code_generator_template.py
Function.class_name
def class_name(self) -> str: """ Makes the fist letter big, keep the rest of the camelCaseApiName. """ if not self.api_name: # empty string return self.api_name # end if return self.api_name[0].upper() + self.api_name[1:]
python
def class_name(self) -> str: """ Makes the fist letter big, keep the rest of the camelCaseApiName. """ if not self.api_name: # empty string return self.api_name # end if return self.api_name[0].upper() + self.api_name[1:]
['def', 'class_name', '(', 'self', ')', '->', 'str', ':', 'if', 'not', 'self', '.', 'api_name', ':', '# empty string', 'return', 'self', '.', 'api_name', '# end if', 'return', 'self', '.', 'api_name', '[', '0', ']', '.', 'upper', '(', ')', '+', 'self', '.', 'api_name', '[', '1', ':', ']']
Makes the fist letter big, keep the rest of the camelCaseApiName.
['Makes', 'the', 'fist', 'letter', 'big', 'keep', 'the', 'rest', 'of', 'the', 'camelCaseApiName', '.']
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_template.py#L224-L231
4,037
lwcook/horsetail-matching
horsetailmatching/hm.py
_matrix_grad
def _matrix_grad(q, h, h_dx, t, t_prime): ''' Returns the gradient with respect to a single variable''' N = len(q) W = np.zeros([N, N]) Wprime = np.zeros([N, N]) for i in range(N): W[i, i] = 0.5*(h[min(i+1, N-1)] - h[max(i-1, 0)]) Wprime[i, i] = \ 0.5*(h_dx[min(i+1, N-1)...
python
def _matrix_grad(q, h, h_dx, t, t_prime): ''' Returns the gradient with respect to a single variable''' N = len(q) W = np.zeros([N, N]) Wprime = np.zeros([N, N]) for i in range(N): W[i, i] = 0.5*(h[min(i+1, N-1)] - h[max(i-1, 0)]) Wprime[i, i] = \ 0.5*(h_dx[min(i+1, N-1)...
['def', '_matrix_grad', '(', 'q', ',', 'h', ',', 'h_dx', ',', 't', ',', 't_prime', ')', ':', 'N', '=', 'len', '(', 'q', ')', 'W', '=', 'np', '.', 'zeros', '(', '[', 'N', ',', 'N', ']', ')', 'Wprime', '=', 'np', '.', 'zeros', '(', '[', 'N', ',', 'N', ']', ')', 'for', 'i', 'in', 'range', '(', 'N', ')', ':', 'W', '[', 'i'...
Returns the gradient with respect to a single variable
['Returns', 'the', 'gradient', 'with', 'respect', 'to', 'a', 'single', 'variable']
train
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L938-L954
4,038
splunk/splunk-sdk-python
examples/analytics/bottle.py
Bottle.close
def close(self): ''' Close the application and all installed plugins. ''' for plugin in self.plugins: if hasattr(plugin, 'close'): plugin.close() self.stopped = True
python
def close(self): ''' Close the application and all installed plugins. ''' for plugin in self.plugins: if hasattr(plugin, 'close'): plugin.close() self.stopped = True
['def', 'close', '(', 'self', ')', ':', 'for', 'plugin', 'in', 'self', '.', 'plugins', ':', 'if', 'hasattr', '(', 'plugin', ',', "'close'", ')', ':', 'plugin', '.', 'close', '(', ')', 'self', '.', 'stopped', '=', 'True']
Close the application and all installed plugins.
['Close', 'the', 'application', 'and', 'all', 'installed', 'plugins', '.']
train
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L493-L497
4,039
ludeeus/pycfdns
pycfdns/__init__.py
CloudflareUpdater.get_recordInfo
def get_recordInfo(self, headers, zoneID, zone, records): """Get the information of the records.""" if 'None' in records: #If ['None'] in record argument, query all. recordQueryEnpoint = '/' + zoneID + '/dns_records&per_page=100' recordUrl = self.BASE_URL + recordQueryEnpoint ...
python
def get_recordInfo(self, headers, zoneID, zone, records): """Get the information of the records.""" if 'None' in records: #If ['None'] in record argument, query all. recordQueryEnpoint = '/' + zoneID + '/dns_records&per_page=100' recordUrl = self.BASE_URL + recordQueryEnpoint ...
['def', 'get_recordInfo', '(', 'self', ',', 'headers', ',', 'zoneID', ',', 'zone', ',', 'records', ')', ':', 'if', "'None'", 'in', 'records', ':', "#If ['None'] in record argument, query all.", 'recordQueryEnpoint', '=', "'/'", '+', 'zoneID', '+', "'/dns_records&per_page=100'", 'recordUrl', '=', 'self', '.', 'BASE_URL'...
Get the information of the records.
['Get', 'the', 'information', 'of', 'the', 'records', '.']
train
https://github.com/ludeeus/pycfdns/blob/0fd027be49d67250f85f2398d006a9409a7dae28/pycfdns/__init__.py#L33-L67
4,040
saltstack/salt
salt/utils/openstack/nova.py
SaltNova.boot
def boot(self, name, flavor_id=0, image_id=0, timeout=300, **kwargs): ''' Boot a cloud server. ''' nt_ks = self.compute_conn kwargs['name'] = name kwargs['flavor'] = flavor_id kwargs['image'] = image_id or None ephemeral = kwargs.pop('ephemeral', []) ...
python
def boot(self, name, flavor_id=0, image_id=0, timeout=300, **kwargs): ''' Boot a cloud server. ''' nt_ks = self.compute_conn kwargs['name'] = name kwargs['flavor'] = flavor_id kwargs['image'] = image_id or None ephemeral = kwargs.pop('ephemeral', []) ...
['def', 'boot', '(', 'self', ',', 'name', ',', 'flavor_id', '=', '0', ',', 'image_id', '=', '0', ',', 'timeout', '=', '300', ',', '*', '*', 'kwargs', ')', ':', 'nt_ks', '=', 'self', '.', 'compute_conn', 'kwargs', '[', "'name'", ']', '=', 'name', 'kwargs', '[', "'flavor'", ']', '=', 'flavor_id', 'kwargs', '[', "'image'"...
Boot a cloud server.
['Boot', 'a', 'cloud', 'server', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L496-L535
4,041
colab/colab-superarchives-plugin
src/colab_superarchives/views.py
EmailView.post
def post(self, request, key): """Create new email address that will wait for validation""" email = request.POST.get('email') user_id = request.POST.get('user') if not email: return http.HttpResponseBadRequest() try: EmailAddressValidation.objects.create(...
python
def post(self, request, key): """Create new email address that will wait for validation""" email = request.POST.get('email') user_id = request.POST.get('user') if not email: return http.HttpResponseBadRequest() try: EmailAddressValidation.objects.create(...
['def', 'post', '(', 'self', ',', 'request', ',', 'key', ')', ':', 'email', '=', 'request', '.', 'POST', '.', 'get', '(', "'email'", ')', 'user_id', '=', 'request', '.', 'POST', '.', 'get', '(', "'user'", ')', 'if', 'not', 'email', ':', 'return', 'http', '.', 'HttpResponseBadRequest', '(', ')', 'try', ':', 'EmailAddres...
Create new email address that will wait for validation
['Create', 'new', 'email', 'address', 'that', 'will', 'wait', 'for', 'validation']
train
https://github.com/colab/colab-superarchives-plugin/blob/fe588a1d4fac874ccad2063ee19a857028a22721/src/colab_superarchives/views.py#L202-L219
4,042
twisted/mantissa
xmantissa/ampserver.py
AMPConfiguration.getFactory
def getFactory(self): """ Return a server factory which creates AMP protocol instances. """ factory = ServerFactory() def protocol(): proto = CredReceiver() proto.portal = Portal( self.loginSystem, [self.loginSystem, ...
python
def getFactory(self): """ Return a server factory which creates AMP protocol instances. """ factory = ServerFactory() def protocol(): proto = CredReceiver() proto.portal = Portal( self.loginSystem, [self.loginSystem, ...
['def', 'getFactory', '(', 'self', ')', ':', 'factory', '=', 'ServerFactory', '(', ')', 'def', 'protocol', '(', ')', ':', 'proto', '=', 'CredReceiver', '(', ')', 'proto', '.', 'portal', '=', 'Portal', '(', 'self', '.', 'loginSystem', ',', '[', 'self', '.', 'loginSystem', ',', 'OneTimePadChecker', '(', 'self', '.', '_on...
Return a server factory which creates AMP protocol instances.
['Return', 'a', 'server', 'factory', 'which', 'creates', 'AMP', 'protocol', 'instances', '.']
train
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/ampserver.py#L78-L91
4,043
franciscogarate/pyliferisk
pyliferisk/__init__.py
Cx
def Cx(mt, x): """ Return the Cx """ return ((1 / (1 + mt.i)) ** (x + 1)) * mt.dx[x] * ((1 + mt.i) ** 0.5)
python
def Cx(mt, x): """ Return the Cx """ return ((1 / (1 + mt.i)) ** (x + 1)) * mt.dx[x] * ((1 + mt.i) ** 0.5)
['def', 'Cx', '(', 'mt', ',', 'x', ')', ':', 'return', '(', '(', '1', '/', '(', '1', '+', 'mt', '.', 'i', ')', ')', '**', '(', 'x', '+', '1', ')', ')', '*', 'mt', '.', 'dx', '[', 'x', ']', '*', '(', '(', '1', '+', 'mt', '.', 'i', ')', '**', '0.5', ')']
Return the Cx
['Return', 'the', 'Cx']
train
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L268-L270
4,044
anchore/anchore
anchore/cli/toolbox.py
image_import
def image_import(infile, force): """Import image anchore data from a JSON file.""" ecode = 0 try: with open(infile, 'r') as FH: savelist = json.loads(FH.read()) except Exception as err: anchore_print_err("could not load input file: " + str(err)) ecode = 1 if...
python
def image_import(infile, force): """Import image anchore data from a JSON file.""" ecode = 0 try: with open(infile, 'r') as FH: savelist = json.loads(FH.read()) except Exception as err: anchore_print_err("could not load input file: " + str(err)) ecode = 1 if...
['def', 'image_import', '(', 'infile', ',', 'force', ')', ':', 'ecode', '=', '0', 'try', ':', 'with', 'open', '(', 'infile', ',', "'r'", ')', 'as', 'FH', ':', 'savelist', '=', 'json', '.', 'loads', '(', 'FH', '.', 'read', '(', ')', ')', 'except', 'Exception', 'as', 'err', ':', 'anchore_print_err', '(', '"could not load...
Import image anchore data from a JSON file.
['Import', 'image', 'anchore', 'data', 'from', 'a', 'JSON', 'file', '.']
train
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/toolbox.py#L421-L452
4,045
mistio/mist.client
src/mistclient/model.py
Machine.get_stats
def get_stats(self, start=int(time()), stop=int(time())+10, step=10): """ Get stats of a monitored machine :param start: Time formatted as integer, from when to fetch stats (default now) :param stop: Time formatted as integer, until when to fetch stats (default +10 seconds) :par...
python
def get_stats(self, start=int(time()), stop=int(time())+10, step=10): """ Get stats of a monitored machine :param start: Time formatted as integer, from when to fetch stats (default now) :param stop: Time formatted as integer, until when to fetch stats (default +10 seconds) :par...
['def', 'get_stats', '(', 'self', ',', 'start', '=', 'int', '(', 'time', '(', ')', ')', ',', 'stop', '=', 'int', '(', 'time', '(', ')', ')', '+', '10', ',', 'step', '=', '10', ')', ':', 'payload', '=', '{', "'v'", ':', '2', ',', "'start'", ':', 'start', ',', "'stop'", ':', 'stop', ',', "'step'", ':', 'step', '}', 'data...
Get stats of a monitored machine :param start: Time formatted as integer, from when to fetch stats (default now) :param stop: Time formatted as integer, until when to fetch stats (default +10 seconds) :param step: Step to fetch stats (default 10 seconds) :returns: A dict of stats
['Get', 'stats', 'of', 'a', 'monitored', 'machine']
train
https://github.com/mistio/mist.client/blob/bc190af2cba358fa556a69b205c12a77a34eb2a8/src/mistclient/model.py#L557-L576
4,046
unionbilling/union-python
union/models.py
BaseModel.save
def save(self): ''' Save an instance of a Union object ''' client = self._new_api_client() params = {'id': self.id} if hasattr(self, 'id') else {} action = 'patch' if hasattr(self, 'id') else 'post' saved_model = client.make_request(self, action, url_params=param...
python
def save(self): ''' Save an instance of a Union object ''' client = self._new_api_client() params = {'id': self.id} if hasattr(self, 'id') else {} action = 'patch' if hasattr(self, 'id') else 'post' saved_model = client.make_request(self, action, url_params=param...
['def', 'save', '(', 'self', ')', ':', 'client', '=', 'self', '.', '_new_api_client', '(', ')', 'params', '=', '{', "'id'", ':', 'self', '.', 'id', '}', 'if', 'hasattr', '(', 'self', ',', "'id'", ')', 'else', '{', '}', 'action', '=', "'patch'", 'if', 'hasattr', '(', 'self', ',', "'id'", ')', 'else', "'post'", 'saved_mo...
Save an instance of a Union object
['Save', 'an', 'instance', 'of', 'a', 'Union', 'object']
train
https://github.com/unionbilling/union-python/blob/551e4fc1a0b395b632781d80527a3660a7c67c0c/union/models.py#L61-L69
4,047
CityOfZion/neo-python-core
neocore/IO/BinaryWriter.py
BinaryWriter.WriteUInt256
def WriteUInt256(self, value): """ Write a UInt256 type to the stream. Args: value (UInt256): Raises: Exception: when `value` is not of neocore.UInt256 type. """ if type(value) is UInt256: value.Serialize(self) else: ...
python
def WriteUInt256(self, value): """ Write a UInt256 type to the stream. Args: value (UInt256): Raises: Exception: when `value` is not of neocore.UInt256 type. """ if type(value) is UInt256: value.Serialize(self) else: ...
['def', 'WriteUInt256', '(', 'self', ',', 'value', ')', ':', 'if', 'type', '(', 'value', ')', 'is', 'UInt256', ':', 'value', '.', 'Serialize', '(', 'self', ')', 'else', ':', 'raise', 'Exception', '(', '"Cannot write value that is not UInt256"', ')']
Write a UInt256 type to the stream. Args: value (UInt256): Raises: Exception: when `value` is not of neocore.UInt256 type.
['Write', 'a', 'UInt256', 'type', 'to', 'the', 'stream', '.']
train
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryWriter.py#L289-L302
4,048
aiogram/aiogram
aiogram/dispatcher/dispatcher.py
Dispatcher.stop_polling
def stop_polling(self): """ Break long-polling process. :return: """ if hasattr(self, '_polling') and self._polling: log.info('Stop polling...') self._polling = False
python
def stop_polling(self): """ Break long-polling process. :return: """ if hasattr(self, '_polling') and self._polling: log.info('Stop polling...') self._polling = False
['def', 'stop_polling', '(', 'self', ')', ':', 'if', 'hasattr', '(', 'self', ',', "'_polling'", ')', 'and', 'self', '.', '_polling', ':', 'log', '.', 'info', '(', "'Stop polling...'", ')', 'self', '.', '_polling', '=', 'False']
Break long-polling process. :return:
['Break', 'long', '-', 'polling', 'process', '.']
train
https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L293-L301
4,049
timstaley/voevent-parse
src/voeventparse/convenience.py
pull_astro_coords
def pull_astro_coords(voevent, index=0): """ Deprecated alias of :func:`.get_event_position` """ import warnings warnings.warn( """ The function `pull_astro_coords` has been renamed to `get_event_position`. This alias is preserved for backwards compatibility, and may ...
python
def pull_astro_coords(voevent, index=0): """ Deprecated alias of :func:`.get_event_position` """ import warnings warnings.warn( """ The function `pull_astro_coords` has been renamed to `get_event_position`. This alias is preserved for backwards compatibility, and may ...
['def', 'pull_astro_coords', '(', 'voevent', ',', 'index', '=', '0', ')', ':', 'import', 'warnings', 'warnings', '.', 'warn', '(', '"""\n The function `pull_astro_coords` has been renamed to\n `get_event_position`. This alias is preserved for backwards\n compatibility, and may be removed in a futur...
Deprecated alias of :func:`.get_event_position`
['Deprecated', 'alias', 'of', ':', 'func', ':', '.', 'get_event_position']
train
https://github.com/timstaley/voevent-parse/blob/58fc1eb3af5eca23d9e819c727204950615402a7/src/voeventparse/convenience.py#L186-L198
4,050
Yelp/kafka-utils
kafka_utils/util/zookeeper.py
ZK.execute_plan
def execute_plan(self, plan, allow_rf_change=False): """Submit reassignment plan for execution.""" reassignment_path = '{admin}/{reassignment_node}'\ .format(admin=ADMIN_PATH, reassignment_node=REASSIGNMENT_NODE) plan_json = dump_json(plan) base_plan = self.get_cluster_plan()...
python
def execute_plan(self, plan, allow_rf_change=False): """Submit reassignment plan for execution.""" reassignment_path = '{admin}/{reassignment_node}'\ .format(admin=ADMIN_PATH, reassignment_node=REASSIGNMENT_NODE) plan_json = dump_json(plan) base_plan = self.get_cluster_plan()...
['def', 'execute_plan', '(', 'self', ',', 'plan', ',', 'allow_rf_change', '=', 'False', ')', ':', 'reassignment_path', '=', "'{admin}/{reassignment_node}'", '.', 'format', '(', 'admin', '=', 'ADMIN_PATH', ',', 'reassignment_node', '=', 'REASSIGNMENT_NODE', ')', 'plan_json', '=', 'dump_json', '(', 'plan', ')', 'base_pla...
Submit reassignment plan for execution.
['Submit', 'reassignment', 'plan', 'for', 'execution', '.']
train
https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/util/zookeeper.py#L483-L527
4,051
openego/eDisGo
edisgo/grid/components.py
Load.timeseries
def timeseries(self): """ Load time series It returns the actual time series used in power flow analysis. If :attr:`_timeseries` is not :obj:`None`, it is returned. Otherwise, :meth:`timeseries()` looks for time series of the according sector in :class:`~.grid.network.Ti...
python
def timeseries(self): """ Load time series It returns the actual time series used in power flow analysis. If :attr:`_timeseries` is not :obj:`None`, it is returned. Otherwise, :meth:`timeseries()` looks for time series of the according sector in :class:`~.grid.network.Ti...
['def', 'timeseries', '(', 'self', ')', ':', 'if', 'self', '.', '_timeseries', 'is', 'None', ':', 'if', 'isinstance', '(', 'self', '.', 'grid', ',', 'MVGrid', ')', ':', 'voltage_level', '=', "'mv'", 'elif', 'isinstance', '(', 'self', '.', 'grid', ',', 'LVGrid', ')', ':', 'voltage_level', '=', "'lv'", 'ts_total', '=', '...
Load time series It returns the actual time series used in power flow analysis. If :attr:`_timeseries` is not :obj:`None`, it is returned. Otherwise, :meth:`timeseries()` looks for time series of the according sector in :class:`~.grid.network.TimeSeries` object. Returns ...
['Load', 'time', 'series']
train
https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/components.py#L178-L234
4,052
bapakode/OmMongo
ommongo/fields/mapping.py
DictField.validate_wrap
def validate_wrap(self, value): ''' Checks that value is a ``dict``, that every key is a valid MongoDB key, and that every value validates based on DictField.value_type ''' if not isinstance(value, dict): self._fail_validation_type(value, dict) for k, v in value.i...
python
def validate_wrap(self, value): ''' Checks that value is a ``dict``, that every key is a valid MongoDB key, and that every value validates based on DictField.value_type ''' if not isinstance(value, dict): self._fail_validation_type(value, dict) for k, v in value.i...
['def', 'validate_wrap', '(', 'self', ',', 'value', ')', ':', 'if', 'not', 'isinstance', '(', 'value', ',', 'dict', ')', ':', 'self', '.', '_fail_validation_type', '(', 'value', ',', 'dict', ')', 'for', 'k', ',', 'v', 'in', 'value', '.', 'items', '(', ')', ':', 'self', '.', '_validate_key_wrap', '(', 'k', ')', 'try', '...
Checks that value is a ``dict``, that every key is a valid MongoDB key, and that every value validates based on DictField.value_type
['Checks', 'that', 'value', 'is', 'a', 'dict', 'that', 'every', 'key', 'is', 'a', 'valid', 'MongoDB', 'key', 'and', 'that', 'every', 'value', 'validates', 'based', 'on', 'DictField', '.', 'value_type']
train
https://github.com/bapakode/OmMongo/blob/52b5a5420516dc709f2d2eb065818c7973991ce3/ommongo/fields/mapping.py#L91-L102
4,053
salimm/pylods
pylods/backend/pylodsc/mapper.py
CObjectMapper.copy
def copy(self): ''' makes a clone copy of the mapper. It won't clone the serializers or deserializers and it won't copy the events ''' try: tmp = self.__class__() except Exception: tmp = self.__class__(self._pdict) tmp._serializers = ...
python
def copy(self): ''' makes a clone copy of the mapper. It won't clone the serializers or deserializers and it won't copy the events ''' try: tmp = self.__class__() except Exception: tmp = self.__class__(self._pdict) tmp._serializers = ...
['def', 'copy', '(', 'self', ')', ':', 'try', ':', 'tmp', '=', 'self', '.', '__class__', '(', ')', 'except', 'Exception', ':', 'tmp', '=', 'self', '.', '__class__', '(', 'self', '.', '_pdict', ')', 'tmp', '.', '_serializers', '=', 'self', '.', '_serializers', 'tmp', '.', '__deserializers', '=', 'self', '.', '__deserial...
makes a clone copy of the mapper. It won't clone the serializers or deserializers and it won't copy the events
['makes', 'a', 'clone', 'copy', 'of', 'the', 'mapper', '.', 'It', 'won', 't', 'clone', 'the', 'serializers', 'or', 'deserializers', 'and', 'it', 'won', 't', 'copy', 'the', 'events']
train
https://github.com/salimm/pylods/blob/d089e2a9afb1fa8cb6c754933fc574b512757c40/pylods/backend/pylodsc/mapper.py#L95-L107
4,054
saltstack/salt
salt/modules/win_path.py
get_path
def get_path(): ''' Returns a list of items in the SYSTEM path CLI Example: .. code-block:: bash salt '*' win_path.get_path ''' ret = salt.utils.stringutils.to_unicode( __utils__['reg.read_value']( 'HKEY_LOCAL_MACHINE', 'SYSTEM\\CurrentControlSet\\Contr...
python
def get_path(): ''' Returns a list of items in the SYSTEM path CLI Example: .. code-block:: bash salt '*' win_path.get_path ''' ret = salt.utils.stringutils.to_unicode( __utils__['reg.read_value']( 'HKEY_LOCAL_MACHINE', 'SYSTEM\\CurrentControlSet\\Contr...
['def', 'get_path', '(', ')', ':', 'ret', '=', 'salt', '.', 'utils', '.', 'stringutils', '.', 'to_unicode', '(', '__utils__', '[', "'reg.read_value'", ']', '(', "'HKEY_LOCAL_MACHINE'", ',', "'SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment'", ',', "'PATH'", ')', '[', "'vdata'", ']', ')', '.', '...
Returns a list of items in the SYSTEM path CLI Example: .. code-block:: bash salt '*' win_path.get_path
['Returns', 'a', 'list', 'of', 'items', 'in', 'the', 'SYSTEM', 'path']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_path.py#L76-L94
4,055
DLR-RM/RAFCON
source/rafcon/core/library_manager.py
LibraryManager.get_library_state_copy_instance
def get_library_state_copy_instance(self, lib_os_path): """ A method to get a state copy of the library specified via the lib_os_path. :param lib_os_path: the location of the library to get a copy for :return: """ # originally libraries were called like this; DO NOT DELETE; int...
python
def get_library_state_copy_instance(self, lib_os_path): """ A method to get a state copy of the library specified via the lib_os_path. :param lib_os_path: the location of the library to get a copy for :return: """ # originally libraries were called like this; DO NOT DELETE; int...
['def', 'get_library_state_copy_instance', '(', 'self', ',', 'lib_os_path', ')', ':', '# originally libraries were called like this; DO NOT DELETE; interesting for performance tests', '# state_machine = storage.load_state_machine_from_path(lib_os_path)', '# return state_machine.version, state_machine.root_state', '# TO...
A method to get a state copy of the library specified via the lib_os_path. :param lib_os_path: the location of the library to get a copy for :return:
['A', 'method', 'to', 'get', 'a', 'state', 'copy', 'of', 'the', 'library', 'specified', 'via', 'the', 'lib_os_path', '.']
train
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/library_manager.py#L377-L403
4,056
uw-it-aca/uw-restclients
restclients/r25/__init__.py
get_resource
def get_resource(url): """ Issue a GET request to R25 with the given url and return a response as an etree element. """ response = R25_DAO().getURL(url, {"Accept": "text/xml"}) if response.status != 200: raise DataFailureException(url, response.status, response.data) tree = etree.fr...
python
def get_resource(url): """ Issue a GET request to R25 with the given url and return a response as an etree element. """ response = R25_DAO().getURL(url, {"Accept": "text/xml"}) if response.status != 200: raise DataFailureException(url, response.status, response.data) tree = etree.fr...
['def', 'get_resource', '(', 'url', ')', ':', 'response', '=', 'R25_DAO', '(', ')', '.', 'getURL', '(', 'url', ',', '{', '"Accept"', ':', '"text/xml"', '}', ')', 'if', 'response', '.', 'status', '!=', '200', ':', 'raise', 'DataFailureException', '(', 'url', ',', 'response', '.', 'status', ',', 'response', '.', 'data', ...
Issue a GET request to R25 with the given url and return a response as an etree element.
['Issue', 'a', 'GET', 'request', 'to', 'R25', 'with', 'the', 'given', 'url', 'and', 'return', 'a', 'response', 'as', 'an', 'etree', 'element', '.']
train
https://github.com/uw-it-aca/uw-restclients/blob/e12dcd32bf5296b6ebdf71798031594afb7852cb/restclients/r25/__init__.py#L10-L26
4,057
concordusapps/alchemist
alchemist/db/operations/sql.py
flush
def flush(**kwargs): """Flush the specified names from the specified databases. This can be highly destructive as it destroys all data. """ expression = lambda target, table: target.execute(table.delete()) test = lambda target, table: not table.exists(target) op(expression, reversed(metadata.s...
python
def flush(**kwargs): """Flush the specified names from the specified databases. This can be highly destructive as it destroys all data. """ expression = lambda target, table: target.execute(table.delete()) test = lambda target, table: not table.exists(target) op(expression, reversed(metadata.s...
['def', 'flush', '(', '*', '*', 'kwargs', ')', ':', 'expression', '=', 'lambda', 'target', ',', 'table', ':', 'target', '.', 'execute', '(', 'table', '.', 'delete', '(', ')', ')', 'test', '=', 'lambda', 'target', ',', 'table', ':', 'not', 'table', '.', 'exists', '(', 'target', ')', 'op', '(', 'expression', ',', 'revers...
Flush the specified names from the specified databases. This can be highly destructive as it destroys all data.
['Flush', 'the', 'specified', 'names', 'from', 'the', 'specified', 'databases', '.']
train
https://github.com/concordusapps/alchemist/blob/822571366271b5dca0ac8bf41df988c6a3b61432/alchemist/db/operations/sql.py#L96-L105
4,058
timothydmorton/VESPA
vespa/populations.py
EclipsePopulation.prior
def prior(self): """ Model prior for particular model. Product of eclipse probability (``self.prob``), the fraction of scenario that is allowed by the various constraints (``self.selectfrac``), and all additional factors in ``self.priorfactors``. """ pri...
python
def prior(self): """ Model prior for particular model. Product of eclipse probability (``self.prob``), the fraction of scenario that is allowed by the various constraints (``self.selectfrac``), and all additional factors in ``self.priorfactors``. """ pri...
['def', 'prior', '(', 'self', ')', ':', 'prior', '=', 'self', '.', 'prob', '*', 'self', '.', 'selectfrac', 'for', 'f', 'in', 'self', '.', 'priorfactors', ':', 'prior', '*=', 'self', '.', 'priorfactors', '[', 'f', ']', 'return', 'prior']
Model prior for particular model. Product of eclipse probability (``self.prob``), the fraction of scenario that is allowed by the various constraints (``self.selectfrac``), and all additional factors in ``self.priorfactors``.
['Model', 'prior', 'for', 'particular', 'model', '.']
train
https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L409-L422
4,059
dpgaspar/Flask-AppBuilder
flask_appbuilder/models/sqla/interface.py
SQLAInterface._query_select_options
def _query_select_options(self, query, select_columns=None): """ Add select load options to query. The goal is to only SQL select what is requested :param query: SQLAlchemy Query obj :param select_columns: (list) of columns :return: SQLAlchemy Query obj "...
python
def _query_select_options(self, query, select_columns=None): """ Add select load options to query. The goal is to only SQL select what is requested :param query: SQLAlchemy Query obj :param select_columns: (list) of columns :return: SQLAlchemy Query obj "...
['def', '_query_select_options', '(', 'self', ',', 'query', ',', 'select_columns', '=', 'None', ')', ':', 'if', 'select_columns', ':', '_load_options', '=', 'list', '(', ')', 'for', 'column', 'in', 'select_columns', ':', 'if', '"."', 'in', 'column', ':', 'model_relation', '=', 'self', '.', 'get_related_model', '(', 'co...
Add select load options to query. The goal is to only SQL select what is requested :param query: SQLAlchemy Query obj :param select_columns: (list) of columns :return: SQLAlchemy Query obj
['Add', 'select', 'load', 'options', 'to', 'query', '.', 'The', 'goal', 'is', 'to', 'only', 'SQL', 'select', 'what', 'is', 'requested']
train
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/sqla/interface.py#L97-L124
4,060
twilio/twilio-python
twilio/base/deserialize.py
rfc2822_datetime
def rfc2822_datetime(s): """ Parses an RFC 2822 date string and returns a UTC datetime object, or the string if parsing failed. :param s: RFC 2822-formatted string date :return: datetime or str """ date_tuple = parsedate(s) if date_tuple is None: return None return datetime.d...
python
def rfc2822_datetime(s): """ Parses an RFC 2822 date string and returns a UTC datetime object, or the string if parsing failed. :param s: RFC 2822-formatted string date :return: datetime or str """ date_tuple = parsedate(s) if date_tuple is None: return None return datetime.d...
['def', 'rfc2822_datetime', '(', 's', ')', ':', 'date_tuple', '=', 'parsedate', '(', 's', ')', 'if', 'date_tuple', 'is', 'None', ':', 'return', 'None', 'return', 'datetime', '.', 'datetime', '(', '*', 'date_tuple', '[', ':', '6', ']', ')', '.', 'replace', '(', 'tzinfo', '=', 'pytz', '.', 'utc', ')']
Parses an RFC 2822 date string and returns a UTC datetime object, or the string if parsing failed. :param s: RFC 2822-formatted string date :return: datetime or str
['Parses', 'an', 'RFC', '2822', 'date', 'string', 'and', 'returns', 'a', 'UTC', 'datetime', 'object', 'or', 'the', 'string', 'if', 'parsing', 'failed', '.', ':', 'param', 's', ':', 'RFC', '2822', '-', 'formatted', 'string', 'date', ':', 'return', ':', 'datetime', 'or', 'str']
train
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/base/deserialize.py#L36-L46
4,061
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.write_roi
def write_roi(self, outfile=None, save_model_map=False, **kwargs): """Write current state of the analysis to a file. This method writes an XML model definition, a ROI dictionary, and a FITS source catalog file. A previously saved analysis state can be reloaded from th...
python
def write_roi(self, outfile=None, save_model_map=False, **kwargs): """Write current state of the analysis to a file. This method writes an XML model definition, a ROI dictionary, and a FITS source catalog file. A previously saved analysis state can be reloaded from th...
['def', 'write_roi', '(', 'self', ',', 'outfile', '=', 'None', ',', 'save_model_map', '=', 'False', ',', '*', '*', 'kwargs', ')', ':', '# extract the results in a convenient format', 'make_plots', '=', 'kwargs', '.', 'get', '(', "'make_plots'", ',', 'False', ')', 'save_weight_map', '=', 'kwargs', '.', 'get', '(', "'sav...
Write current state of the analysis to a file. This method writes an XML model definition, a ROI dictionary, and a FITS source catalog file. A previously saved analysis state can be reloaded from the ROI dictionary file with the `~fermipy.gtanalysis.GTAnalysis.load_roi` method. ...
['Write', 'current', 'state', 'of', 'the', 'analysis', 'to', 'a', 'file', '.', 'This', 'method', 'writes', 'an', 'XML', 'model', 'definition', 'a', 'ROI', 'dictionary', 'and', 'a', 'FITS', 'source', 'catalog', 'file', '.', 'A', 'previously', 'saved', 'analysis', 'state', 'can', 'be', 'reloaded', 'from', 'the', 'ROI', '...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L3612-L3690
4,062
dvdotsenko/jsonrpc.py
jsonrpcparts/serializers.py
JSONRPC20Serializer._parse_single_response
def _parse_single_response(cls, response_data): """de-serialize a JSON-RPC Response/error :Returns: | [result, id] for Responses :Raises: | RPCFault+derivates for error-packages/faults, RPCParseError, RPCInvalidRPC """ if not isinstance(response_data, dict): raise ...
python
def _parse_single_response(cls, response_data): """de-serialize a JSON-RPC Response/error :Returns: | [result, id] for Responses :Raises: | RPCFault+derivates for error-packages/faults, RPCParseError, RPCInvalidRPC """ if not isinstance(response_data, dict): raise ...
['def', '_parse_single_response', '(', 'cls', ',', 'response_data', ')', ':', 'if', 'not', 'isinstance', '(', 'response_data', ',', 'dict', ')', ':', 'raise', 'errors', '.', 'RPCInvalidRequest', '(', '"No valid RPC-package."', ')', 'if', '"id"', 'not', 'in', 'response_data', ':', 'raise', 'errors', '.', 'RPCInvalidRequ...
de-serialize a JSON-RPC Response/error :Returns: | [result, id] for Responses :Raises: | RPCFault+derivates for error-packages/faults, RPCParseError, RPCInvalidRPC
['de', '-', 'serialize', 'a', 'JSON', '-', 'RPC', 'Response', '/', 'error']
train
https://github.com/dvdotsenko/jsonrpc.py/blob/19673edd77a9518ac5655bd407f6b93ffbb2cafc/jsonrpcparts/serializers.py#L470-L515
4,063
nccgroup/Scout2
AWSScout2/services/iam.py
IAMConfig.parse_roles
def parse_roles(self, fetched_role, params): """ Parse a single IAM role and fetch additional data """ role = {} role['instances_count'] = 'N/A' # When resuming upon throttling error, skip if already fetched if fetched_role['RoleName'] in self.roles: r...
python
def parse_roles(self, fetched_role, params): """ Parse a single IAM role and fetch additional data """ role = {} role['instances_count'] = 'N/A' # When resuming upon throttling error, skip if already fetched if fetched_role['RoleName'] in self.roles: r...
['def', 'parse_roles', '(', 'self', ',', 'fetched_role', ',', 'params', ')', ':', 'role', '=', '{', '}', 'role', '[', "'instances_count'", ']', '=', "'N/A'", '# When resuming upon throttling error, skip if already fetched', 'if', 'fetched_role', '[', "'RoleName'", ']', 'in', 'self', '.', 'roles', ':', 'return', 'api_cl...
Parse a single IAM role and fetch additional data
['Parse', 'a', 'single', 'IAM', 'role', 'and', 'fetch', 'additional', 'data']
train
https://github.com/nccgroup/Scout2/blob/5d86d46d7ed91a92000496189e9cfa6b98243937/AWSScout2/services/iam.py#L205-L237
4,064
benoitkugler/abstractDataLibrary
pyDLib/GUI/app.py
abstractToolBar.set_interface
def set_interface(self, interface): """Add update toolbar callback to the interface""" self.interface = interface self.interface.callbacks.update_toolbar = self._update self._update()
python
def set_interface(self, interface): """Add update toolbar callback to the interface""" self.interface = interface self.interface.callbacks.update_toolbar = self._update self._update()
['def', 'set_interface', '(', 'self', ',', 'interface', ')', ':', 'self', '.', 'interface', '=', 'interface', 'self', '.', 'interface', '.', 'callbacks', '.', 'update_toolbar', '=', 'self', '.', '_update', 'self', '.', '_update', '(', ')']
Add update toolbar callback to the interface
['Add', 'update', 'toolbar', 'callback', 'to', 'the', 'interface']
train
https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/app.py#L101-L105
4,065
apple/turicreate
src/unity/python/turicreate/data_structures/sframe.py
SFrame.topk
def topk(self, column_name, k=10, reverse=False): """ Get top k rows according to the given column. Result is according to and sorted by `column_name` in the given order (default is descending). When `k` is small, `topk` is more efficient than `sort`. Parameters --------...
python
def topk(self, column_name, k=10, reverse=False): """ Get top k rows according to the given column. Result is according to and sorted by `column_name` in the given order (default is descending). When `k` is small, `topk` is more efficient than `sort`. Parameters --------...
['def', 'topk', '(', 'self', ',', 'column_name', ',', 'k', '=', '10', ',', 'reverse', '=', 'False', ')', ':', 'if', 'type', '(', 'column_name', ')', 'is', 'not', 'str', ':', 'raise', 'TypeError', '(', '"column_name must be a string"', ')', 'sf', '=', 'self', '[', 'self', '[', 'column_name', ']', '.', 'is_topk', '(', 'k...
Get top k rows according to the given column. Result is according to and sorted by `column_name` in the given order (default is descending). When `k` is small, `topk` is more efficient than `sort`. Parameters ---------- column_name : string The column to sort on ...
['Get', 'top', 'k', 'rows', 'according', 'to', 'the', 'given', 'column', '.', 'Result', 'is', 'according', 'to', 'and', 'sorted', 'by', 'column_name', 'in', 'the', 'given', 'order', '(', 'default', 'is', 'descending', ')', '.', 'When', 'k', 'is', 'small', 'topk', 'is', 'more', 'efficient', 'than', 'sort', '.']
train
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/data_structures/sframe.py#L2710-L2766
4,066
Autodesk/pyccc
pyccc/python.py
PackagedFunction.prepare_namespace
def prepare_namespace(self, func): """ Prepares the function to be run after deserializing it. Re-associates any previously bound variables and modules from the closure Returns: callable: ready-to-call function """ if self.is_imethod: to_run = get...
python
def prepare_namespace(self, func): """ Prepares the function to be run after deserializing it. Re-associates any previously bound variables and modules from the closure Returns: callable: ready-to-call function """ if self.is_imethod: to_run = get...
['def', 'prepare_namespace', '(', 'self', ',', 'func', ')', ':', 'if', 'self', '.', 'is_imethod', ':', 'to_run', '=', 'getattr', '(', 'self', '.', 'obj', ',', 'self', '.', 'imethod_name', ')', 'else', ':', 'to_run', '=', 'func', 'for', 'varname', ',', 'modulename', 'in', 'self', '.', 'global_modules', '.', 'items', '('...
Prepares the function to be run after deserializing it. Re-associates any previously bound variables and modules from the closure Returns: callable: ready-to-call function
['Prepares', 'the', 'function', 'to', 'be', 'run', 'after', 'deserializing', 'it', '.', 'Re', '-', 'associates', 'any', 'previously', 'bound', 'variables', 'and', 'modules', 'from', 'the', 'closure']
train
https://github.com/Autodesk/pyccc/blob/011698e78d49a83ac332e0578a4a2a865b75ef8d/pyccc/python.py#L292-L311
4,067
jazzband/django-axes
axes/attempts.py
get_user_attempts
def get_user_attempts(request: AxesHttpRequest, credentials: dict = None) -> QuerySet: """ Get valid user attempts that match the given request and credentials. """ attempts = filter_user_attempts(request, credentials) if settings.AXES_COOLOFF_TIME is None: log.debug('AXES: Getting all acc...
python
def get_user_attempts(request: AxesHttpRequest, credentials: dict = None) -> QuerySet: """ Get valid user attempts that match the given request and credentials. """ attempts = filter_user_attempts(request, credentials) if settings.AXES_COOLOFF_TIME is None: log.debug('AXES: Getting all acc...
['def', 'get_user_attempts', '(', 'request', ':', 'AxesHttpRequest', ',', 'credentials', ':', 'dict', '=', 'None', ')', '->', 'QuerySet', ':', 'attempts', '=', 'filter_user_attempts', '(', 'request', ',', 'credentials', ')', 'if', 'settings', '.', 'AXES_COOLOFF_TIME', 'is', 'None', ':', 'log', '.', 'debug', '(', "'AXES...
Get valid user attempts that match the given request and credentials.
['Get', 'valid', 'user', 'attempts', 'that', 'match', 'the', 'given', 'request', 'and', 'credentials', '.']
train
https://github.com/jazzband/django-axes/blob/3e215a174030e43e7ab8c2a79c395eb0eeddc667/axes/attempts.py#L45-L58
4,068
RPi-Distro/python-sense-hat
sense_hat/sense_hat.py
SenseHat.get_pressure
def get_pressure(self): """ Returns the pressure in Millibars """ self._init_pressure() # Ensure pressure sensor is initialised pressure = 0 data = self._pressure.pressureRead() if (data[0]): # Pressure valid pressure = data[1] return pressu...
python
def get_pressure(self): """ Returns the pressure in Millibars """ self._init_pressure() # Ensure pressure sensor is initialised pressure = 0 data = self._pressure.pressureRead() if (data[0]): # Pressure valid pressure = data[1] return pressu...
['def', 'get_pressure', '(', 'self', ')', ':', 'self', '.', '_init_pressure', '(', ')', '# Ensure pressure sensor is initialised', 'pressure', '=', '0', 'data', '=', 'self', '.', '_pressure', '.', 'pressureRead', '(', ')', 'if', '(', 'data', '[', '0', ']', ')', ':', '# Pressure valid', 'pressure', '=', 'data', '[', '1'...
Returns the pressure in Millibars
['Returns', 'the', 'pressure', 'in', 'Millibars']
train
https://github.com/RPi-Distro/python-sense-hat/blob/9a37f0923ce8dbde69514c3b8d58d30de01c9ee7/sense_hat/sense_hat.py#L616-L626
4,069
enkore/i3pystatus
i3pystatus/calendar/google.py
Google.refresh_events
def refresh_events(self): """ Retrieve the next N events from Google. """ now = datetime.datetime.now(tz=pytz.UTC) try: now, later = self.get_timerange_formatted(now) events_result = self.service.events().list( calendarId='primary', ...
python
def refresh_events(self): """ Retrieve the next N events from Google. """ now = datetime.datetime.now(tz=pytz.UTC) try: now, later = self.get_timerange_formatted(now) events_result = self.service.events().list( calendarId='primary', ...
['def', 'refresh_events', '(', 'self', ')', ':', 'now', '=', 'datetime', '.', 'datetime', '.', 'now', '(', 'tz', '=', 'pytz', '.', 'UTC', ')', 'try', ':', 'now', ',', 'later', '=', 'self', '.', 'get_timerange_formatted', '(', 'now', ')', 'events_result', '=', 'self', '.', 'service', '.', 'events', '(', ')', '.', 'list'...
Retrieve the next N events from Google.
['Retrieve', 'the', 'next', 'N', 'events', 'from', 'Google', '.']
train
https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/calendar/google.py#L105-L128
4,070
wummel/linkchecker
linkcheck/url.py
urlunsplit
def urlunsplit (urlparts): """Same as urlparse.urlunsplit but with extra UNC path handling for Windows OS.""" res = urlparse.urlunsplit(urlparts) if os.name == 'nt' and urlparts[0] == 'file' and '|' not in urlparts[2]: # UNC paths must have 4 slashes: 'file:////server/path' # Depending o...
python
def urlunsplit (urlparts): """Same as urlparse.urlunsplit but with extra UNC path handling for Windows OS.""" res = urlparse.urlunsplit(urlparts) if os.name == 'nt' and urlparts[0] == 'file' and '|' not in urlparts[2]: # UNC paths must have 4 slashes: 'file:////server/path' # Depending o...
['def', 'urlunsplit', '(', 'urlparts', ')', ':', 'res', '=', 'urlparse', '.', 'urlunsplit', '(', 'urlparts', ')', 'if', 'os', '.', 'name', '==', "'nt'", 'and', 'urlparts', '[', '0', ']', '==', "'file'", 'and', "'|'", 'not', 'in', 'urlparts', '[', '2', ']', ':', "# UNC paths must have 4 slashes: 'file:////server/path'",...
Same as urlparse.urlunsplit but with extra UNC path handling for Windows OS.
['Same', 'as', 'urlparse', '.', 'urlunsplit', 'but', 'with', 'extra', 'UNC', 'path', 'handling', 'for', 'Windows', 'OS', '.']
train
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/url.py#L275-L285
4,071
nitely/django-hooks
hooks/templatehook.py
Hook.register
def register(self, name, func): """ Register a new callback.\ When the name/id is not found\ a new hook is created under its name,\ meaning the hook is usually created by\ the first registered callback :param str name: Hook name :param callable func: A fu...
python
def register(self, name, func): """ Register a new callback.\ When the name/id is not found\ a new hook is created under its name,\ meaning the hook is usually created by\ the first registered callback :param str name: Hook name :param callable func: A fu...
['def', 'register', '(', 'self', ',', 'name', ',', 'func', ')', ':', 'try', ':', 'templatehook', '=', 'self', '.', '_registry', '[', 'name', ']', 'except', 'KeyError', ':', 'templatehook', '=', 'self', '.', '_register', '(', 'name', ')', 'templatehook', '.', 'register', '(', 'func', ')']
Register a new callback.\ When the name/id is not found\ a new hook is created under its name,\ meaning the hook is usually created by\ the first registered callback :param str name: Hook name :param callable func: A func reference (callback)
['Register', 'a', 'new', 'callback', '.', '\\', 'When', 'the', 'name', '/', 'id', 'is', 'not', 'found', '\\', 'a', 'new', 'hook', 'is', 'created', 'under', 'its', 'name', '\\', 'meaning', 'the', 'hook', 'is', 'usually', 'created', 'by', '\\', 'the', 'first', 'registered', 'callback']
train
https://github.com/nitely/django-hooks/blob/26ea2150c9be110e90b9ee60fbfd1065ac30ab1d/hooks/templatehook.py#L99-L115
4,072
SpriteLink/NIPAP
pynipap/pynipap.py
Pool.get
def get(cls, id): """ Get the pool with id 'id'. """ # cached? if CACHE: if id in _cache['Pool']: log.debug('cache hit for pool %d' % id) return _cache['Pool'][id] log.debug('cache miss for pool %d' % id) try: ...
python
def get(cls, id): """ Get the pool with id 'id'. """ # cached? if CACHE: if id in _cache['Pool']: log.debug('cache hit for pool %d' % id) return _cache['Pool'][id] log.debug('cache miss for pool %d' % id) try: ...
['def', 'get', '(', 'cls', ',', 'id', ')', ':', '# cached?', 'if', 'CACHE', ':', 'if', 'id', 'in', '_cache', '[', "'Pool'", ']', ':', 'log', '.', 'debug', '(', "'cache hit for pool %d'", '%', 'id', ')', 'return', '_cache', '[', "'Pool'", ']', '[', 'id', ']', 'log', '.', 'debug', '(', "'cache miss for pool %d'", '%', 'i...
Get the pool with id 'id'.
['Get', 'the', 'pool', 'with', 'id', 'id', '.']
train
https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/pynipap/pynipap.py#L780-L797
4,073
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer._flush_tile_queue_blits
def _flush_tile_queue_blits(self, surface): """ Blit the queued tiles and block until the tile queue is empty for pygame 1.9.4 + """ tw, th = self.data.tile_size ltw = self._tile_view.left * tw tth = self._tile_view.top * th self.data.prepare_tiles(self._tile_vi...
python
def _flush_tile_queue_blits(self, surface): """ Blit the queued tiles and block until the tile queue is empty for pygame 1.9.4 + """ tw, th = self.data.tile_size ltw = self._tile_view.left * tw tth = self._tile_view.top * th self.data.prepare_tiles(self._tile_vi...
['def', '_flush_tile_queue_blits', '(', 'self', ',', 'surface', ')', ':', 'tw', ',', 'th', '=', 'self', '.', 'data', '.', 'tile_size', 'ltw', '=', 'self', '.', '_tile_view', '.', 'left', '*', 'tw', 'tth', '=', 'self', '.', '_tile_view', '.', 'top', '*', 'th', 'self', '.', 'data', '.', 'prepare_tiles', '(', 'self', '.',...
Blit the queued tiles and block until the tile queue is empty for pygame 1.9.4 +
['Blit', 'the', 'queued', 'tiles', 'and', 'block', 'until', 'the', 'tile', 'queue', 'is', 'empty']
train
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L508-L520
4,074
ultrabug/py3status
py3status/formatter.py
Formatter.update_placeholders
def update_placeholders(self, format_string, placeholders): """ Update a format string renaming placeholders. """ # Tokenize the format string and process them output = [] for token in self.tokens(format_string): if token.group("key") in placeholders: ...
python
def update_placeholders(self, format_string, placeholders): """ Update a format string renaming placeholders. """ # Tokenize the format string and process them output = [] for token in self.tokens(format_string): if token.group("key") in placeholders: ...
['def', 'update_placeholders', '(', 'self', ',', 'format_string', ',', 'placeholders', ')', ':', '# Tokenize the format string and process them', 'output', '=', '[', ']', 'for', 'token', 'in', 'self', '.', 'tokens', '(', 'format_string', ')', ':', 'if', 'token', '.', 'group', '(', '"key"', ')', 'in', 'placeholders', ':...
Update a format string renaming placeholders.
['Update', 'a', 'format', 'string', 'renaming', 'placeholders', '.']
train
https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/formatter.py#L105-L153
4,075
andersinno/django-sanitized-dump
sanitized_dump/config.py
Configuration.diff_with_models
def diff_with_models(self): """ Return a dict stating the differences between current state of models and the configuration itself. TODO: Detect fields that are in conf, but not in models """ missing_from_conf = defaultdict(set) for model in get_models(): ...
python
def diff_with_models(self): """ Return a dict stating the differences between current state of models and the configuration itself. TODO: Detect fields that are in conf, but not in models """ missing_from_conf = defaultdict(set) for model in get_models(): ...
['def', 'diff_with_models', '(', 'self', ')', ':', 'missing_from_conf', '=', 'defaultdict', '(', 'set', ')', 'for', 'model', 'in', 'get_models', '(', ')', ':', 'db_tables_and_columns', '=', 'get_db_tables_and_columns_of_model', '(', 'model', ')', 'for', '(', 'table_name', ',', 'columns', ')', 'in', 'db_tables_and_colum...
Return a dict stating the differences between current state of models and the configuration itself. TODO: Detect fields that are in conf, but not in models
['Return', 'a', 'dict', 'stating', 'the', 'differences', 'between', 'current', 'state', 'of', 'models', 'and', 'the', 'configuration', 'itself', '.', 'TODO', ':', 'Detect', 'fields', 'that', 'are', 'in', 'conf', 'but', 'not', 'in', 'models']
train
https://github.com/andersinno/django-sanitized-dump/blob/185a693d153dd9fb56cdc58382e4744635afc2e7/sanitized_dump/config.py#L60-L75
4,076
dmort27/panphon
panphon/_panphon.py
FeatureTable.segs
def segs(self, word): """Returns a list of segments from a word Args: word (unicode): input word as Unicode IPA string Returns: list: list of strings corresponding to segments found in `word` """ return [m.group('all') for m in self.seg_regex.finditer(wo...
python
def segs(self, word): """Returns a list of segments from a word Args: word (unicode): input word as Unicode IPA string Returns: list: list of strings corresponding to segments found in `word` """ return [m.group('all') for m in self.seg_regex.finditer(wo...
['def', 'segs', '(', 'self', ',', 'word', ')', ':', 'return', '[', 'm', '.', 'group', '(', "'all'", ')', 'for', 'm', 'in', 'self', '.', 'seg_regex', '.', 'finditer', '(', 'word', ')', ']']
Returns a list of segments from a word Args: word (unicode): input word as Unicode IPA string Returns: list: list of strings corresponding to segments found in `word`
['Returns', 'a', 'list', 'of', 'segments', 'from', 'a', 'word']
train
https://github.com/dmort27/panphon/blob/17eaa482e3edb211f3a8138137d76e4b9246d201/panphon/_panphon.py#L243-L252
4,077
twilio/twilio-python
twilio/rest/taskrouter/v1/workspace/task_channel.py
TaskChannelList.get
def get(self, sid): """ Constructs a TaskChannelContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext """ return TaskChannelContext(se...
python
def get(self, sid): """ Constructs a TaskChannelContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext """ return TaskChannelContext(se...
['def', 'get', '(', 'self', ',', 'sid', ')', ':', 'return', 'TaskChannelContext', '(', 'self', '.', '_version', ',', 'workspace_sid', '=', 'self', '.', '_solution', '[', "'workspace_sid'", ']', ',', 'sid', '=', 'sid', ',', ')']
Constructs a TaskChannelContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext
['Constructs', 'a', 'TaskChannelContext']
train
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/taskrouter/v1/workspace/task_channel.py#L137-L146
4,078
openstack/networking-arista
networking_arista/common/db_lib.py
filter_unmanaged_physnets
def filter_unmanaged_physnets(query): """Filter ports managed by other ML2 plugins """ config = cfg.CONF.ml2_arista managed_physnets = config['managed_physnets'] # Filter out ports bound to segments on physnets that we're not # managing segment_model = segment_models.NetworkSegment if manag...
python
def filter_unmanaged_physnets(query): """Filter ports managed by other ML2 plugins """ config = cfg.CONF.ml2_arista managed_physnets = config['managed_physnets'] # Filter out ports bound to segments on physnets that we're not # managing segment_model = segment_models.NetworkSegment if manag...
['def', 'filter_unmanaged_physnets', '(', 'query', ')', ':', 'config', '=', 'cfg', '.', 'CONF', '.', 'ml2_arista', 'managed_physnets', '=', 'config', '[', "'managed_physnets'", ']', "# Filter out ports bound to segments on physnets that we're not", '# managing', 'segment_model', '=', 'segment_models', '.', 'NetworkSegm...
Filter ports managed by other ML2 plugins
['Filter', 'ports', 'managed', 'by', 'other', 'ML2', 'plugins']
train
https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/common/db_lib.py#L152-L165
4,079
pandas-dev/pandas
pandas/io/sql.py
SQLTable._query_iterator
def _query_iterator(self, result, chunksize, columns, coerce_float=True, parse_dates=None): """Return generator through chunked result set.""" while True: data = result.fetchmany(chunksize) if not data: break else: ...
python
def _query_iterator(self, result, chunksize, columns, coerce_float=True, parse_dates=None): """Return generator through chunked result set.""" while True: data = result.fetchmany(chunksize) if not data: break else: ...
['def', '_query_iterator', '(', 'self', ',', 'result', ',', 'chunksize', ',', 'columns', ',', 'coerce_float', '=', 'True', ',', 'parse_dates', '=', 'None', ')', ':', 'while', 'True', ':', 'data', '=', 'result', '.', 'fetchmany', '(', 'chunksize', ')', 'if', 'not', 'data', ':', 'break', 'else', ':', 'self', '.', 'frame'...
Return generator through chunked result set.
['Return', 'generator', 'through', 'chunked', 'result', 'set', '.']
train
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L679-L696
4,080
ucfopen/canvasapi
canvasapi/canvas.py
Canvas.get_outcome
def get_outcome(self, outcome): """ Returns the details of the outcome with the given id. :calls: `GET /api/v1/outcomes/:id \ <https://canvas.instructure.com/doc/api/outcomes.html#method.outcomes_api.show>`_ :param outcome: The outcome object or ID to return. :type outc...
python
def get_outcome(self, outcome): """ Returns the details of the outcome with the given id. :calls: `GET /api/v1/outcomes/:id \ <https://canvas.instructure.com/doc/api/outcomes.html#method.outcomes_api.show>`_ :param outcome: The outcome object or ID to return. :type outc...
['def', 'get_outcome', '(', 'self', ',', 'outcome', ')', ':', 'from', 'canvasapi', '.', 'outcome', 'import', 'Outcome', 'outcome_id', '=', 'obj_or_id', '(', 'outcome', ',', '"outcome"', ',', '(', 'Outcome', ',', ')', ')', 'response', '=', 'self', '.', '__requester', '.', 'request', '(', "'GET'", ',', "'outcomes/{}'", '...
Returns the details of the outcome with the given id. :calls: `GET /api/v1/outcomes/:id \ <https://canvas.instructure.com/doc/api/outcomes.html#method.outcomes_api.show>`_ :param outcome: The outcome object or ID to return. :type outcome: :class:`canvasapi.outcome.Outcome` or int ...
['Returns', 'the', 'details', 'of', 'the', 'outcome', 'with', 'the', 'given', 'id', '.']
train
https://github.com/ucfopen/canvasapi/blob/319064b5fc97ba54250af683eb98723ef3f76cf8/canvasapi/canvas.py#L1058-L1078
4,081
gmr/tinman
tinman/handlers/mixins.py
ModelAPIMixin.get
def get(self, *args, **kwargs): """Handle reading of the model :param args: :param kwargs: """ # Create the model and fetch its data self.model = self.get_model(kwargs.get('id')) result = yield self.model.fetch() # If model is not found, return 404 ...
python
def get(self, *args, **kwargs): """Handle reading of the model :param args: :param kwargs: """ # Create the model and fetch its data self.model = self.get_model(kwargs.get('id')) result = yield self.model.fetch() # If model is not found, return 404 ...
['def', 'get', '(', 'self', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', '# Create the model and fetch its data', 'self', '.', 'model', '=', 'self', '.', 'get_model', '(', 'kwargs', '.', 'get', '(', "'id'", ')', ')', 'result', '=', 'yield', 'self', '.', 'model', '.', 'fetch', '(', ')', '# If model is not found,...
Handle reading of the model :param args: :param kwargs:
['Handle', 'reading', 'of', 'the', 'model']
train
https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L258-L283
4,082
softlayer/softlayer-python
SoftLayer/CLI/file/snapshot/disable.py
cli
def cli(env, volume_id, schedule_type): """Disables snapshots on the specified schedule for a given volume""" if (schedule_type not in ['INTERVAL', 'HOURLY', 'DAILY', 'WEEKLY']): raise exceptions.CLIAbort( '--schedule_type must be INTERVAL, HOURLY, DAILY, or WEEKLY') file_manager = Sof...
python
def cli(env, volume_id, schedule_type): """Disables snapshots on the specified schedule for a given volume""" if (schedule_type not in ['INTERVAL', 'HOURLY', 'DAILY', 'WEEKLY']): raise exceptions.CLIAbort( '--schedule_type must be INTERVAL, HOURLY, DAILY, or WEEKLY') file_manager = Sof...
['def', 'cli', '(', 'env', ',', 'volume_id', ',', 'schedule_type', ')', ':', 'if', '(', 'schedule_type', 'not', 'in', '[', "'INTERVAL'", ',', "'HOURLY'", ',', "'DAILY'", ',', "'WEEKLY'", ']', ')', ':', 'raise', 'exceptions', '.', 'CLIAbort', '(', "'--schedule_type must be INTERVAL, HOURLY, DAILY, or WEEKLY'", ')', 'fil...
Disables snapshots on the specified schedule for a given volume
['Disables', 'snapshots', 'on', 'the', 'specified', 'schedule', 'for', 'a', 'given', 'volume']
train
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/file/snapshot/disable.py#L16-L28
4,083
deepmind/pysc2
pysc2/lib/point.py
Point.floor
def floor(self): """Round `x` and `y` down to integers.""" return Point(int(math.floor(self.x)), int(math.floor(self.y)))
python
def floor(self): """Round `x` and `y` down to integers.""" return Point(int(math.floor(self.x)), int(math.floor(self.y)))
['def', 'floor', '(', 'self', ')', ':', 'return', 'Point', '(', 'int', '(', 'math', '.', 'floor', '(', 'self', '.', 'x', ')', ')', ',', 'int', '(', 'math', '.', 'floor', '(', 'self', '.', 'y', ')', ')', ')']
Round `x` and `y` down to integers.
['Round', 'x', 'and', 'y', 'down', 'to', 'integers', '.']
train
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L60-L62
4,084
pesaply/sarafu
pesaply.py
pesaplyMM._parse_transactions
def _parse_transactions(self, response): """ This method parses the CSV output in `get_transactions` to generate a usable list of transactions that use native python data types """ transactions = list() if response: f = StringIO(response) ...
python
def _parse_transactions(self, response): """ This method parses the CSV output in `get_transactions` to generate a usable list of transactions that use native python data types """ transactions = list() if response: f = StringIO(response) ...
['def', '_parse_transactions', '(', 'self', ',', 'response', ')', ':', 'transactions', '=', 'list', '(', ')', 'if', 'response', ':', 'f', '=', 'StringIO', '(', 'response', ')', 'reader', '=', 'csv', '.', 'DictReader', '(', 'f', ')', 'for', 'line', 'in', 'reader', ':', 'txn', '=', '{', '}', 'txn', '[', "'date'", ']', '=...
This method parses the CSV output in `get_transactions` to generate a usable list of transactions that use native python data types
['This', 'method', 'parses', 'the', 'CSV', 'output', 'in', 'get_transactions', 'to', 'generate', 'a', 'usable', 'list', 'of', 'transactions', 'that', 'use', 'native', 'python', 'data', 'types']
train
https://github.com/pesaply/sarafu/blob/8c1296d48427a6cf17ffc5600d100b49acc9c5b7/pesaply.py#L253-L278
4,085
WojciechMula/pyahocorasick
py/pyahocorasick.py
Trie.add_word
def add_word(self, word, value): """ Adds word and associated value. If word already exists, its value is replaced. """ if not word: return node = self.root for c in word: try: node = node.children[c] except KeyError: n = TrieNode(c) node.children[c] = n node = n node.output ...
python
def add_word(self, word, value): """ Adds word and associated value. If word already exists, its value is replaced. """ if not word: return node = self.root for c in word: try: node = node.children[c] except KeyError: n = TrieNode(c) node.children[c] = n node = n node.output ...
['def', 'add_word', '(', 'self', ',', 'word', ',', 'value', ')', ':', 'if', 'not', 'word', ':', 'return', 'node', '=', 'self', '.', 'root', 'for', 'c', 'in', 'word', ':', 'try', ':', 'node', '=', 'node', '.', 'children', '[', 'c', ']', 'except', 'KeyError', ':', 'n', '=', 'TrieNode', '(', 'c', ')', 'node', '.', 'childr...
Adds word and associated value. If word already exists, its value is replaced.
['Adds', 'word', 'and', 'associated', 'value', '.']
train
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L151-L169
4,086
reingart/pyafipws
wsremcarne.py
WSRemCarne.ConsultarTiposContingencia
def ConsultarTiposContingencia(self, sep="||"): "Obtener el código y descripción para cada tipo de contingencia que puede reportar" ret = self.client.consultarTiposContingencia( authRequest={ 'token': self.Token, 'sign': self.Sign, ...
python
def ConsultarTiposContingencia(self, sep="||"): "Obtener el código y descripción para cada tipo de contingencia que puede reportar" ret = self.client.consultarTiposContingencia( authRequest={ 'token': self.Token, 'sign': self.Sign, ...
['def', 'ConsultarTiposContingencia', '(', 'self', ',', 'sep', '=', '"||"', ')', ':', 'ret', '=', 'self', '.', 'client', '.', 'consultarTiposContingencia', '(', 'authRequest', '=', '{', "'token'", ':', 'self', '.', 'Token', ',', "'sign'", ':', 'self', '.', 'Sign', ',', "'cuitRepresentada'", ':', 'self', '.', 'Cuit', ',...
Obtener el código y descripción para cada tipo de contingencia que puede reportar
['Obtener', 'el', 'código', 'y', 'descripción', 'para', 'cada', 'tipo', 'de', 'contingencia', 'que', 'puede', 'reportar']
train
https://github.com/reingart/pyafipws/blob/ee87cfe4ac12285ab431df5fec257f103042d1ab/wsremcarne.py#L346-L356
4,087
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAFetch/QATdx.py
QA_fetch_get_option_50etf_contract_time_to_market
def QA_fetch_get_option_50etf_contract_time_to_market(): ''' #🛠todo 获取期权合约的上市日期 ? 暂时没有。 :return: list Series ''' result = QA_fetch_get_option_list('tdx') # pprint.pprint(result) # category market code name desc code ''' fix here : See the caveats in the documenta...
python
def QA_fetch_get_option_50etf_contract_time_to_market(): ''' #🛠todo 获取期权合约的上市日期 ? 暂时没有。 :return: list Series ''' result = QA_fetch_get_option_list('tdx') # pprint.pprint(result) # category market code name desc code ''' fix here : See the caveats in the documenta...
['def', 'QA_fetch_get_option_50etf_contract_time_to_market', '(', ')', ':', 'result', '=', 'QA_fetch_get_option_list', '(', "'tdx'", ')', '# pprint.pprint(result)', '# category market code name desc code', "'''\n fix here : \n See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/in...
#🛠todo 获取期权合约的上市日期 ? 暂时没有。 :return: list Series
['#🛠todo', '获取期权合约的上市日期', '?', '暂时没有。', ':', 'return', ':', 'list', 'Series']
train
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAFetch/QATdx.py#L1649-L1730
4,088
eaton-lab/toytree
toytree/TreeParser.py
Newick2TreeNode.newick_from_string
def newick_from_string(self): "Reads a newick string in the New Hampshire format." # split on parentheses to traverse hierarchical tree structure for chunk in self.data.split("(")[1:]: # add child to make this node a parent. self.current_parent = ( self.r...
python
def newick_from_string(self): "Reads a newick string in the New Hampshire format." # split on parentheses to traverse hierarchical tree structure for chunk in self.data.split("(")[1:]: # add child to make this node a parent. self.current_parent = ( self.r...
['def', 'newick_from_string', '(', 'self', ')', ':', '# split on parentheses to traverse hierarchical tree structure', 'for', 'chunk', 'in', 'self', '.', 'data', '.', 'split', '(', '"("', ')', '[', '1', ':', ']', ':', '# add child to make this node a parent.', 'self', '.', 'current_parent', '=', '(', 'self', '.', 'root...
Reads a newick string in the New Hampshire format.
['Reads', 'a', 'newick', 'string', 'in', 'the', 'New', 'Hampshire', 'format', '.']
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L319-L352
4,089
yamcs/yamcs-python
yamcs-client/yamcs/client.py
YamcsClient.get_user_info
def get_user_info(self): """ Get information on the authenticated user. :rtype: .UserInfo """ response = self.get_proto(path='/user') message = yamcsManagement_pb2.UserInfo() message.ParseFromString(response.content) return UserInfo(message)
python
def get_user_info(self): """ Get information on the authenticated user. :rtype: .UserInfo """ response = self.get_proto(path='/user') message = yamcsManagement_pb2.UserInfo() message.ParseFromString(response.content) return UserInfo(message)
['def', 'get_user_info', '(', 'self', ')', ':', 'response', '=', 'self', '.', 'get_proto', '(', 'path', '=', "'/user'", ')', 'message', '=', 'yamcsManagement_pb2', '.', 'UserInfo', '(', ')', 'message', '.', 'ParseFromString', '(', 'response', '.', 'content', ')', 'return', 'UserInfo', '(', 'message', ')']
Get information on the authenticated user. :rtype: .UserInfo
['Get', 'information', 'on', 'the', 'authenticated', 'user', '.']
train
https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/client.py#L193-L202
4,090
nicolargo/glances
glances/plugins/glances_cpu.py
Plugin.msg_curse
def msg_curse(self, args=None, max_width=None): """Return the list to display in the UI.""" # Init the return message ret = [] # Only process if stats exist and plugin not disable if not self.stats or self.args.percpu or self.is_disable(): return ret # Build...
python
def msg_curse(self, args=None, max_width=None): """Return the list to display in the UI.""" # Init the return message ret = [] # Only process if stats exist and plugin not disable if not self.stats or self.args.percpu or self.is_disable(): return ret # Build...
['def', 'msg_curse', '(', 'self', ',', 'args', '=', 'None', ',', 'max_width', '=', 'None', ')', ':', '# Init the return message', 'ret', '=', '[', ']', '# Only process if stats exist and plugin not disable', 'if', 'not', 'self', '.', 'stats', 'or', 'self', '.', 'args', '.', 'percpu', 'or', 'self', '.', 'is_disable', '(...
Return the list to display in the UI.
['Return', 'the', 'list', 'to', 'display', 'in', 'the', 'UI', '.']
train
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L213-L342
4,091
sorgerlab/indra
indra/tools/reading/readers.py
get_reader_classes
def get_reader_classes(parent=Reader): """Get all childless the descendants of a parent class, recursively.""" children = parent.__subclasses__() descendants = children[:] for child in children: grandchildren = get_reader_classes(child) if grandchildren: descendants.remove(ch...
python
def get_reader_classes(parent=Reader): """Get all childless the descendants of a parent class, recursively.""" children = parent.__subclasses__() descendants = children[:] for child in children: grandchildren = get_reader_classes(child) if grandchildren: descendants.remove(ch...
['def', 'get_reader_classes', '(', 'parent', '=', 'Reader', ')', ':', 'children', '=', 'parent', '.', '__subclasses__', '(', ')', 'descendants', '=', 'children', '[', ':', ']', 'for', 'child', 'in', 'children', ':', 'grandchildren', '=', 'get_reader_classes', '(', 'child', ')', 'if', 'grandchildren', ':', 'descendants'...
Get all childless the descendants of a parent class, recursively.
['Get', 'all', 'childless', 'the', 'descendants', 'of', 'a', 'parent', 'class', 'recursively', '.']
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L761-L770
4,092
kbr/fritzconnection
fritzconnection/fritzstatus.py
FritzStatus.str_max_bit_rate
def str_max_bit_rate(self): """ Returns a human readable maximun upstream- and downstream-rate of the given connection. The rate is given in bits/sec. """ upstream, downstream = self.max_bit_rate return ( fritztools.format_rate(upstream, unit='bits'), ...
python
def str_max_bit_rate(self): """ Returns a human readable maximun upstream- and downstream-rate of the given connection. The rate is given in bits/sec. """ upstream, downstream = self.max_bit_rate return ( fritztools.format_rate(upstream, unit='bits'), ...
['def', 'str_max_bit_rate', '(', 'self', ')', ':', 'upstream', ',', 'downstream', '=', 'self', '.', 'max_bit_rate', 'return', '(', 'fritztools', '.', 'format_rate', '(', 'upstream', ',', 'unit', '=', "'bits'", ')', ',', 'fritztools', '.', 'format_rate', '(', 'downstream', ',', 'unit', '=', "'bits'", ')', ')']
Returns a human readable maximun upstream- and downstream-rate of the given connection. The rate is given in bits/sec.
['Returns', 'a', 'human', 'readable', 'maximun', 'upstream', '-', 'and', 'downstream', '-', 'rate', 'of', 'the', 'given', 'connection', '.', 'The', 'rate', 'is', 'given', 'in', 'bits', '/', 'sec', '.']
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzstatus.py#L147-L156
4,093
econ-ark/HARK
HARK/ConsumptionSaving/ConsIndShockModel.py
solveConsIndShock
def solveConsIndShock(solution_next,IncomeDstn,LivPrb,DiscFac,CRRA,Rfree,PermGroFac, BoroCnstArt,aXtraGrid,vFuncBool,CubicBool): ''' Solves a single period consumption-saving problem with CRRA utility and risky income (subject to permanent and transitory shocks). Can generat...
python
def solveConsIndShock(solution_next,IncomeDstn,LivPrb,DiscFac,CRRA,Rfree,PermGroFac, BoroCnstArt,aXtraGrid,vFuncBool,CubicBool): ''' Solves a single period consumption-saving problem with CRRA utility and risky income (subject to permanent and transitory shocks). Can generat...
['def', 'solveConsIndShock', '(', 'solution_next', ',', 'IncomeDstn', ',', 'LivPrb', ',', 'DiscFac', ',', 'CRRA', ',', 'Rfree', ',', 'PermGroFac', ',', 'BoroCnstArt', ',', 'aXtraGrid', ',', 'vFuncBool', ',', 'CubicBool', ')', ':', "# Use the basic solver if user doesn't want cubic splines or the value function", 'if', ...
Solves a single period consumption-saving problem with CRRA utility and risky income (subject to permanent and transitory shocks). Can generate a value function if requested; consumption function can be linear or cubic splines. Parameters ---------- solution_next : ConsumerSolution The sol...
['Solves', 'a', 'single', 'period', 'consumption', '-', 'saving', 'problem', 'with', 'CRRA', 'utility', 'and', 'risky', 'income', '(', 'subject', 'to', 'permanent', 'and', 'transitory', 'shocks', ')', '.', 'Can', 'generate', 'a', 'value', 'function', 'if', 'requested', ';', 'consumption', 'function', 'can', 'be', 'line...
train
https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsIndShockModel.py#L1183-L1244
4,094
awslabs/sockeye
sockeye/training.py
EarlyStoppingTrainer._save_training_state
def _save_training_state(self, train_iter: data_io.BaseParallelSampleIter): """ Saves current training state. """ # Create temporary directory for storing the state of the optimization process training_state_dirname = os.path.join(self.model.output_dir, C.TRAINING_STATE_TEMP_DIRN...
python
def _save_training_state(self, train_iter: data_io.BaseParallelSampleIter): """ Saves current training state. """ # Create temporary directory for storing the state of the optimization process training_state_dirname = os.path.join(self.model.output_dir, C.TRAINING_STATE_TEMP_DIRN...
['def', '_save_training_state', '(', 'self', ',', 'train_iter', ':', 'data_io', '.', 'BaseParallelSampleIter', ')', ':', '# Create temporary directory for storing the state of the optimization process', 'training_state_dirname', '=', 'os', '.', 'path', '.', 'join', '(', 'self', '.', 'model', '.', 'output_dir', ',', 'C'...
Saves current training state.
['Saves', 'current', 'training', 'state', '.']
train
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/training.py#L1093-L1139
4,095
Telefonica/toolium
toolium/driver_wrapper.py
DriverWrapper.should_reuse_driver
def should_reuse_driver(self, scope, test_passed, context=None): """Check if the driver should be reused :param scope: execution scope (function, module, class or session) :param test_passed: True if the test has passed :param context: behave context :returns: True if the driver...
python
def should_reuse_driver(self, scope, test_passed, context=None): """Check if the driver should be reused :param scope: execution scope (function, module, class or session) :param test_passed: True if the test has passed :param context: behave context :returns: True if the driver...
['def', 'should_reuse_driver', '(', 'self', ',', 'scope', ',', 'test_passed', ',', 'context', '=', 'None', ')', ':', 'reuse_driver', '=', 'self', '.', 'config', '.', 'getboolean_optional', '(', "'Driver'", ',', "'reuse_driver'", ')', 'reuse_driver_session', '=', 'self', '.', 'config', '.', 'getboolean_optional', '(', "...
Check if the driver should be reused :param scope: execution scope (function, module, class or session) :param test_passed: True if the test has passed :param context: behave context :returns: True if the driver should be reused
['Check', 'if', 'the', 'driver', 'should', 'be', 'reused']
train
https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/driver_wrapper.py#L325-L341
4,096
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
GlyphsBuilder._fake_designspace
def _fake_designspace(self, ufos): """Build a fake designspace with the given UFOs as sources, so that all builder functions can rely on the presence of a designspace. """ designspace = designspaceLib.DesignSpaceDocument() ufo_to_location = defaultdict(dict) # Make weig...
python
def _fake_designspace(self, ufos): """Build a fake designspace with the given UFOs as sources, so that all builder functions can rely on the presence of a designspace. """ designspace = designspaceLib.DesignSpaceDocument() ufo_to_location = defaultdict(dict) # Make weig...
['def', '_fake_designspace', '(', 'self', ',', 'ufos', ')', ':', 'designspace', '=', 'designspaceLib', '.', 'DesignSpaceDocument', '(', ')', 'ufo_to_location', '=', 'defaultdict', '(', 'dict', ')', '# Make weight and width axis if relevant', 'for', 'info_key', ',', 'axis_def', 'in', 'zip', '(', '(', '"openTypeOS2Weight...
Build a fake designspace with the given UFOs as sources, so that all builder functions can rely on the presence of a designspace.
['Build', 'a', 'fake', 'designspace', 'with', 'the', 'given', 'UFOs', 'as', 'sources', 'so', 'that', 'all', 'builder', 'functions', 'can', 'rely', 'on', 'the', 'presence', 'of', 'a', 'designspace', '.']
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L640-L702
4,097
ask/carrot
carrot/backends/pystomp.py
Message.ack
def ack(self): """Acknowledge this message as being processed., This will remove the message from the queue. :raises MessageStateError: If the message has already been acknowledged/requeued/rejected. """ if self.acknowledged: raise self.MessageStateError...
python
def ack(self): """Acknowledge this message as being processed., This will remove the message from the queue. :raises MessageStateError: If the message has already been acknowledged/requeued/rejected. """ if self.acknowledged: raise self.MessageStateError...
['def', 'ack', '(', 'self', ')', ':', 'if', 'self', '.', 'acknowledged', ':', 'raise', 'self', '.', 'MessageStateError', '(', '"Message already acknowledged with state: %s"', '%', 'self', '.', '_state', ')', 'self', '.', 'backend', '.', 'ack', '(', 'self', '.', '_frame', ')', 'self', '.', '_state', '=', '"ACK"']
Acknowledge this message as being processed., This will remove the message from the queue. :raises MessageStateError: If the message has already been acknowledged/requeued/rejected.
['Acknowledge', 'this', 'message', 'as', 'being', 'processed', '.', 'This', 'will', 'remove', 'the', 'message', 'from', 'the', 'queue', '.']
train
https://github.com/ask/carrot/blob/5889a25cd2e274642071c9bba39772f4b3e3d9da/carrot/backends/pystomp.py#L54-L66
4,098
david-cortes/costsensitive
costsensitive/__init__.py
WeightedOneVsRest.predict
def predict(self, X): """ Predict the less costly class for a given observation Parameters ---------- X : array (n_samples, n_features) Data for which to predict minimum cost label. Returns ------- y_hat : array (n_samples,) ...
python
def predict(self, X): """ Predict the less costly class for a given observation Parameters ---------- X : array (n_samples, n_features) Data for which to predict minimum cost label. Returns ------- y_hat : array (n_samples,) ...
['def', 'predict', '(', 'self', ',', 'X', ')', ':', 'X', '=', '_check_2d_inp', '(', 'X', ')', 'return', 'np', '.', 'argmax', '(', 'self', '.', 'decision_function', '(', 'X', ')', ',', 'axis', '=', '1', ')']
Predict the less costly class for a given observation Parameters ---------- X : array (n_samples, n_features) Data for which to predict minimum cost label. Returns ------- y_hat : array (n_samples,) Label with expected minimum cos...
['Predict', 'the', 'less', 'costly', 'class', 'for', 'a', 'given', 'observation', 'Parameters', '----------', 'X', ':', 'array', '(', 'n_samples', 'n_features', ')', 'Data', 'for', 'which', 'to', 'predict', 'minimum', 'cost', 'label', '.', 'Returns', '-------', 'y_hat', ':', 'array', '(', 'n_samples', ')', 'Label', 'wi...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L802-L817
4,099
hyde/fswrap
fswrap.py
FS.file_or_folder
def file_or_folder(path): """ Returns a File or Folder object that would represent the given path. """ target = unicode(path) return Folder(target) if os.path.isdir(target) else File(target)
python
def file_or_folder(path): """ Returns a File or Folder object that would represent the given path. """ target = unicode(path) return Folder(target) if os.path.isdir(target) else File(target)
['def', 'file_or_folder', '(', 'path', ')', ':', 'target', '=', 'unicode', '(', 'path', ')', 'return', 'Folder', '(', 'target', ')', 'if', 'os', '.', 'path', '.', 'isdir', '(', 'target', ')', 'else', 'File', '(', 'target', ')']
Returns a File or Folder object that would represent the given path.
['Returns', 'a', 'File', 'or', 'Folder', 'object', 'that', 'would', 'represent', 'the', 'given', 'path', '.']
train
https://github.com/hyde/fswrap/blob/41e4ad6f7e9ba73eabe61bd97847cd284e3edbd2/fswrap.py#L157-L162