repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
jedie/DragonPy
PyDC/PyDC/utils.py
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L634-L651
def print_bitlist(bitstream, no_repr=False): """ >>> bitstream = bytes2bitstream("Hallo World!") >>> print_bitlist(bitstream) ... # doctest: +NORMALIZE_WHITESPACE 8 - 00010010 10000110 00110110 00110110 11110110 00000100 11101010 11110110 0x48 'H' 0x61 'a' 0x6c 'l' 0x6c 'l' 0x6f 'o' 0x...
[ "def", "print_bitlist", "(", "bitstream", ",", "no_repr", "=", "False", ")", ":", "block_bit_list", "=", "iter_steps", "(", "bitstream", ",", "steps", "=", "8", ")", "print_block_bit_list", "(", "block_bit_list", ",", "no_repr", "=", "no_repr", ")" ]
>>> bitstream = bytes2bitstream("Hallo World!") >>> print_bitlist(bitstream) ... # doctest: +NORMALIZE_WHITESPACE 8 - 00010010 10000110 00110110 00110110 11110110 00000100 11101010 11110110 0x48 'H' 0x61 'a' 0x6c 'l' 0x6c 'l' 0x6f 'o' 0x20 ' ' 0x57 'W' 0x6f 'o' 12 - 01001110 00110110 001...
[ ">>>", "bitstream", "=", "bytes2bitstream", "(", "Hallo", "World!", ")", ">>>", "print_bitlist", "(", "bitstream", ")", "...", "#", "doctest", ":", "+", "NORMALIZE_WHITESPACE", "8", "-", "00010010", "10000110", "00110110", "00110110", "11110110", "00000100", "11...
python
train
cloudera/cm_api
python/src/cm_api/endpoints/cms.py
https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L320-L343
def update_peer(self, current_name, new_name, new_url, username, password, peer_type="REPLICATION"): """ Update a replication peer. @param current_name: The name of the peer to updated. @param new_name: The new name for the peer. @param new_url: The new url for the peer. @param user...
[ "def", "update_peer", "(", "self", ",", "current_name", ",", "new_name", ",", "new_url", ",", "username", ",", "password", ",", "peer_type", "=", "\"REPLICATION\"", ")", ":", "if", "self", ".", "_get_resource_root", "(", ")", ".", "version", "<", "11", ":"...
Update a replication peer. @param current_name: The name of the peer to updated. @param new_name: The new name for the peer. @param new_url: The new url for the peer. @param username: The admin username to use to setup the remote side of the peer connection. @param password: The password of the adm...
[ "Update", "a", "replication", "peer", "." ]
python
train
saltstack/salt
salt/states/rdp.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rdp.py#L15-L38
def enabled(name): ''' Enable the RDP service and make sure access to the RDP port is allowed in the firewall configuration ''' ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} stat = __salt__['rdp.status']() if not stat: if __opts...
[ "def", "enabled", "(", "name", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'changes'", ":", "{", "}", ",", "'comment'", ":", "''", "}", "stat", "=", "__salt__", "[", "'rdp.status'", "]", "(", ")", "if", "...
Enable the RDP service and make sure access to the RDP port is allowed in the firewall configuration
[ "Enable", "the", "RDP", "service", "and", "make", "sure", "access", "to", "the", "RDP", "port", "is", "allowed", "in", "the", "firewall", "configuration" ]
python
train
jforman/pybindxml
pybindxml/reader.py
https://github.com/jforman/pybindxml/blob/795fd5b1fab85e2debad8655888e2d52ef8dce5f/pybindxml/reader.py#L33-L49
def gather_xml(self): """Attempt to read the XML, whether from a file on-disk or via host:port. TODO: handle when you cant gather stats, due to bad hostname """ if self.xml_filepath: with open(self.xml_filepath, "r") as xml_fh: self.raw_xml = xml_fh.read() ...
[ "def", "gather_xml", "(", "self", ")", ":", "if", "self", ".", "xml_filepath", ":", "with", "open", "(", "self", ".", "xml_filepath", ",", "\"r\"", ")", "as", "xml_fh", ":", "self", ".", "raw_xml", "=", "xml_fh", ".", "read", "(", ")", "self", ".", ...
Attempt to read the XML, whether from a file on-disk or via host:port. TODO: handle when you cant gather stats, due to bad hostname
[ "Attempt", "to", "read", "the", "XML", "whether", "from", "a", "file", "on", "-", "disk", "or", "via", "host", ":", "port", "." ]
python
train
grycap/RADL
radl/radl_parse.py
https://github.com/grycap/RADL/blob/03ccabb0313a48a5aa0e20c1f7983fddcb95e9cb/radl/radl_parse.py#L274-L281
def p_system_sentence(self, t): """system_sentence : SYSTEM VAR | SYSTEM VAR LPAREN features RPAREN""" if len(t) == 3: t[0] = system(t[2], reference=True, line=t.lineno(1)) else: t[0] = system(t[2], t[4], line=t.lineno(1))
[ "def", "p_system_sentence", "(", "self", ",", "t", ")", ":", "if", "len", "(", "t", ")", "==", "3", ":", "t", "[", "0", "]", "=", "system", "(", "t", "[", "2", "]", ",", "reference", "=", "True", ",", "line", "=", "t", ".", "lineno", "(", "...
system_sentence : SYSTEM VAR | SYSTEM VAR LPAREN features RPAREN
[ "system_sentence", ":", "SYSTEM", "VAR", "|", "SYSTEM", "VAR", "LPAREN", "features", "RPAREN" ]
python
train
erdewit/ib_insync
ib_insync/wrapper.py
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/wrapper.py#L88-L102
def _endReq(self, key, result=None, success=True): """ Finish the future of corresponding key with the given result. If no result is given then it will be popped of the general results. """ future = self._futures.pop(key, None) self._reqId2Contract.pop(key, None) ...
[ "def", "_endReq", "(", "self", ",", "key", ",", "result", "=", "None", ",", "success", "=", "True", ")", ":", "future", "=", "self", ".", "_futures", ".", "pop", "(", "key", ",", "None", ")", "self", ".", "_reqId2Contract", ".", "pop", "(", "key", ...
Finish the future of corresponding key with the given result. If no result is given then it will be popped of the general results.
[ "Finish", "the", "future", "of", "corresponding", "key", "with", "the", "given", "result", ".", "If", "no", "result", "is", "given", "then", "it", "will", "be", "popped", "of", "the", "general", "results", "." ]
python
train
amzn/ion-python
amazon/ion/reader_binary.py
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_binary.py#L132-L152
def _parse_var_int_components(buf, signed): """Parses a ``VarInt`` or ``VarUInt`` field from a file-like object.""" value = 0 sign = 1 while True: ch = buf.read(1) if ch == '': raise IonException('Variable integer under-run') octet = ord(ch) if signed: ...
[ "def", "_parse_var_int_components", "(", "buf", ",", "signed", ")", ":", "value", "=", "0", "sign", "=", "1", "while", "True", ":", "ch", "=", "buf", ".", "read", "(", "1", ")", "if", "ch", "==", "''", ":", "raise", "IonException", "(", "'Variable in...
Parses a ``VarInt`` or ``VarUInt`` field from a file-like object.
[ "Parses", "a", "VarInt", "or", "VarUInt", "field", "from", "a", "file", "-", "like", "object", "." ]
python
train
CityOfZion/neo-python
neo/Core/TX/Transaction.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/TX/Transaction.py#L278-L289
def Hash(self): """ Get the hash of the transaction. Returns: UInt256: """ if not self.__hash: ba = bytearray(binascii.unhexlify(self.GetHashData())) hash = Crypto.Hash256(ba) self.__hash = UInt256(data=hash) return self.__...
[ "def", "Hash", "(", "self", ")", ":", "if", "not", "self", ".", "__hash", ":", "ba", "=", "bytearray", "(", "binascii", ".", "unhexlify", "(", "self", ".", "GetHashData", "(", ")", ")", ")", "hash", "=", "Crypto", ".", "Hash256", "(", "ba", ")", ...
Get the hash of the transaction. Returns: UInt256:
[ "Get", "the", "hash", "of", "the", "transaction", "." ]
python
train
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L241-L244
def p_portlist_io(self, p): 'portlist : LPAREN ioports RPAREN SEMICOLON' p[0] = Portlist(ports=p[2], lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_portlist_io", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "Portlist", "(", "ports", "=", "p", "[", "2", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", "p", ".", "set_lineno", "(", "0", ",", "p", "."...
portlist : LPAREN ioports RPAREN SEMICOLON
[ "portlist", ":", "LPAREN", "ioports", "RPAREN", "SEMICOLON" ]
python
train
quantmind/pulsar
pulsar/utils/importer.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/importer.py#L32-L47
def import_modules(modules, safe=True): '''Safely import a list of *modules* ''' all = [] for mname in modules: if mname.endswith('.*'): to_load = expand_star(mname) else: to_load = [mname] for module in to_load: try: all.append...
[ "def", "import_modules", "(", "modules", ",", "safe", "=", "True", ")", ":", "all", "=", "[", "]", "for", "mname", "in", "modules", ":", "if", "mname", ".", "endswith", "(", "'.*'", ")", ":", "to_load", "=", "expand_star", "(", "mname", ")", "else", ...
Safely import a list of *modules*
[ "Safely", "import", "a", "list", "of", "*", "modules", "*" ]
python
train
sosreport/sos
sos/plugins/__init__.py
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L69-L81
def _node_type(st): """ return a string indicating the type of special node represented by the stat buffer st (block, character, fifo, socket). """ _types = [ (stat.S_ISBLK, "block device"), (stat.S_ISCHR, "character device"), (stat.S_ISFIFO, "named pipe"), (stat.S_ISSOCK...
[ "def", "_node_type", "(", "st", ")", ":", "_types", "=", "[", "(", "stat", ".", "S_ISBLK", ",", "\"block device\"", ")", ",", "(", "stat", ".", "S_ISCHR", ",", "\"character device\"", ")", ",", "(", "stat", ".", "S_ISFIFO", ",", "\"named pipe\"", ")", ...
return a string indicating the type of special node represented by the stat buffer st (block, character, fifo, socket).
[ "return", "a", "string", "indicating", "the", "type", "of", "special", "node", "represented", "by", "the", "stat", "buffer", "st", "(", "block", "character", "fifo", "socket", ")", "." ]
python
train
jmcgeheeiv/pyfakefs
pyfakefs/fake_filesystem.py
https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_filesystem.py#L2389-L2428
def add_real_file(self, source_path, read_only=True, target_path=None): """Create `file_path`, including all the parent directories along the way, for an existing real file. The contents of the real file are read only on demand. Args: source_path: Path to an existing file in...
[ "def", "add_real_file", "(", "self", ",", "source_path", ",", "read_only", "=", "True", ",", "target_path", "=", "None", ")", ":", "target_path", "=", "target_path", "or", "source_path", "source_path", "=", "make_string_path", "(", "source_path", ")", "target_pa...
Create `file_path`, including all the parent directories along the way, for an existing real file. The contents of the real file are read only on demand. Args: source_path: Path to an existing file in the real file system read_only: If `True` (the default), writing to th...
[ "Create", "file_path", "including", "all", "the", "parent", "directories", "along", "the", "way", "for", "an", "existing", "real", "file", ".", "The", "contents", "of", "the", "real", "file", "are", "read", "only", "on", "demand", "." ]
python
train
rochacbruno/dynaconf
dynaconf/base.py
https://github.com/rochacbruno/dynaconf/blob/5a7cc8f8252251cbdf4f4112965801f9dfe2831d/dynaconf/base.py#L333-L349
def get_environ(self, key, default=None, cast=None): """Get value from environment variable using os.environ.get :param key: The name of the setting value, will always be upper case :param default: In case of not found it will be returned :param cast: Should cast in to @int, @float, @bo...
[ "def", "get_environ", "(", "self", ",", "key", ",", "default", "=", "None", ",", "cast", "=", "None", ")", ":", "key", "=", "key", ".", "upper", "(", ")", "data", "=", "self", ".", "environ", ".", "get", "(", "key", ",", "default", ")", "if", "...
Get value from environment variable using os.environ.get :param key: The name of the setting value, will always be upper case :param default: In case of not found it will be returned :param cast: Should cast in to @int, @float, @bool or @json ? or cast must be true to use cast inferenc...
[ "Get", "value", "from", "environment", "variable", "using", "os", ".", "environ", ".", "get" ]
python
train
F-Secure/see
see/context/resources/network.py
https://github.com/F-Secure/see/blob/3e053e52a45229f96a12db9e98caf7fb3880e811/see/context/resources/network.py#L187-L195
def generate_address(hypervisor, configuration): """Generate a valid IP address according to the configuration.""" ipv4 = configuration['ipv4'] prefix = configuration['prefix'] subnet_prefix = configuration['subnet_prefix'] subnet_address = ipaddress.IPv4Network(u'/'.join((str(ipv4), str(prefix)))) ...
[ "def", "generate_address", "(", "hypervisor", ",", "configuration", ")", ":", "ipv4", "=", "configuration", "[", "'ipv4'", "]", "prefix", "=", "configuration", "[", "'prefix'", "]", "subnet_prefix", "=", "configuration", "[", "'subnet_prefix'", "]", "subnet_addres...
Generate a valid IP address according to the configuration.
[ "Generate", "a", "valid", "IP", "address", "according", "to", "the", "configuration", "." ]
python
train
quantopian/empyrical
empyrical/stats.py
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L885-L931
def excess_sharpe(returns, factor_returns, out=None): """ Determines the Excess Sharpe of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. factor_retu...
[ "def", "excess_sharpe", "(", "returns", ",", "factor_returns", ",", "out", "=", "None", ")", ":", "allocated_output", "=", "out", "is", "None", "if", "allocated_output", ":", "out", "=", "np", ".", "empty", "(", "returns", ".", "shape", "[", "1", ":", ...
Determines the Excess Sharpe of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. factor_returns: float / series Benchmark return to compare returns ag...
[ "Determines", "the", "Excess", "Sharpe", "of", "a", "strategy", "." ]
python
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/VCFTools.py
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/VCFTools.py#L91-L142
def parse(self, filename, gziped = False, stream = False) : """opens a file""" self.stream = stream if gziped : self.f = gzip.open(filename) else : self.f = open(filename) self.filename = filename self.gziped = gziped lineId = 0 inLegend = True while inLegend : ll = self.f.readline()...
[ "def", "parse", "(", "self", ",", "filename", ",", "gziped", "=", "False", ",", "stream", "=", "False", ")", ":", "self", ".", "stream", "=", "stream", "if", "gziped", ":", "self", ".", "f", "=", "gzip", ".", "open", "(", "filename", ")", "else", ...
opens a file
[ "opens", "a", "file" ]
python
train
trustar/trustar-python
trustar/models/tag.py
https://github.com/trustar/trustar-python/blob/707d51adc58d68aed7de12a4ca37949cb75cf122/trustar/models/tag.py#L48-L65
def to_dict(self, remove_nones=False): """ Creates a dictionary representation of the tag. :param remove_nones: Whether ``None`` values should be filtered out of the dictionary. Defaults to ``False``. :return: A dictionary representation of the tag. """ if remove_nones...
[ "def", "to_dict", "(", "self", ",", "remove_nones", "=", "False", ")", ":", "if", "remove_nones", ":", "d", "=", "super", "(", ")", ".", "to_dict", "(", "remove_nones", "=", "True", ")", "else", ":", "d", "=", "{", "'name'", ":", "self", ".", "name...
Creates a dictionary representation of the tag. :param remove_nones: Whether ``None`` values should be filtered out of the dictionary. Defaults to ``False``. :return: A dictionary representation of the tag.
[ "Creates", "a", "dictionary", "representation", "of", "the", "tag", "." ]
python
train
eraclitux/ipcampy
ipcampy/foscam.py
https://github.com/eraclitux/ipcampy/blob/bffd1c4df9006705cffa5b83a090b0db90cbcbcf/ipcampy/foscam.py#L28-L52
def snap(self, path=None): """Get a snapshot and save it to disk.""" if path is None: path = "/tmp" else: path = path.rstrip("/") day_dir = datetime.datetime.now().strftime("%d%m%Y") hour_dir = datetime.datetime.now().strftime("%H%M") ensure_snapsh...
[ "def", "snap", "(", "self", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "\"/tmp\"", "else", ":", "path", "=", "path", ".", "rstrip", "(", "\"/\"", ")", "day_dir", "=", "datetime", ".", "datetime", ".", "now", ...
Get a snapshot and save it to disk.
[ "Get", "a", "snapshot", "and", "save", "it", "to", "disk", "." ]
python
train
jimporter/bfg9000
bfg9000/versioning.py
https://github.com/jimporter/bfg9000/blob/33615fc67573f0d416297ee9a98dd1ec8b1aa960/bfg9000/versioning.py#L37-L88
def simplify_specifiers(spec): """Try to simplify a SpecifierSet by combining redundant specifiers.""" def key(s): return (s.version, 1 if s.operator in ['>=', '<'] else 2) def in_bounds(v, lo, hi): if lo and v not in lo: return False if hi and v not in hi: ...
[ "def", "simplify_specifiers", "(", "spec", ")", ":", "def", "key", "(", "s", ")", ":", "return", "(", "s", ".", "version", ",", "1", "if", "s", ".", "operator", "in", "[", "'>='", ",", "'<'", "]", "else", "2", ")", "def", "in_bounds", "(", "v", ...
Try to simplify a SpecifierSet by combining redundant specifiers.
[ "Try", "to", "simplify", "a", "SpecifierSet", "by", "combining", "redundant", "specifiers", "." ]
python
train
pymc-devs/pymc
pymc/Model.py
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/Model.py#L777-L797
def restore_sampler_state(self): """ Restore the state of the sampler and to the state stored in the database. """ state = self.db.getstate() or {} # Restore sampler's state sampler_state = state.get('sampler', {}) self.__dict__.update(sampler_state) ...
[ "def", "restore_sampler_state", "(", "self", ")", ":", "state", "=", "self", ".", "db", ".", "getstate", "(", ")", "or", "{", "}", "# Restore sampler's state", "sampler_state", "=", "state", ".", "get", "(", "'sampler'", ",", "{", "}", ")", "self", ".", ...
Restore the state of the sampler and to the state stored in the database.
[ "Restore", "the", "state", "of", "the", "sampler", "and", "to", "the", "state", "stored", "in", "the", "database", "." ]
python
train
chaimleib/intervaltree
intervaltree/intervaltree.py
https://github.com/chaimleib/intervaltree/blob/ffb2b1667f8b832e89324a75a175be8440504c9d/intervaltree/intervaltree.py#L600-L620
def overlaps_range(self, begin, end): """ Returns whether some interval in the tree overlaps the given range. Returns False if given a null interval over which to test. Completes in O(r*log n) time, where r is the range length and n is the table size. :rtype: boo...
[ "def", "overlaps_range", "(", "self", ",", "begin", ",", "end", ")", ":", "if", "self", ".", "is_empty", "(", ")", ":", "return", "False", "elif", "begin", ">=", "end", ":", "return", "False", "elif", "self", ".", "overlaps_point", "(", "begin", ")", ...
Returns whether some interval in the tree overlaps the given range. Returns False if given a null interval over which to test. Completes in O(r*log n) time, where r is the range length and n is the table size. :rtype: bool
[ "Returns", "whether", "some", "interval", "in", "the", "tree", "overlaps", "the", "given", "range", ".", "Returns", "False", "if", "given", "a", "null", "interval", "over", "which", "to", "test", "." ]
python
train
lucuma/Clay
clay/markdown_ext/md_captions.py
https://github.com/lucuma/Clay/blob/620d37086b712bdc4d13930ced43a5b7c9a5f46d/clay/markdown_ext/md_captions.py#L98-L103
def extendMarkdown(self, md, md_globals): """ Add an instance of FigcaptionProcessor to BlockParser. """ # def_list = 'def_list' in md.registeredExtensions md.parser.blockprocessors.add( 'figcaption', FigcaptionProcessor(md.parser), '<ulist')
[ "def", "extendMarkdown", "(", "self", ",", "md", ",", "md_globals", ")", ":", "# def_list = 'def_list' in md.registeredExtensions", "md", ".", "parser", ".", "blockprocessors", ".", "add", "(", "'figcaption'", ",", "FigcaptionProcessor", "(", "md", ".", "parser", ...
Add an instance of FigcaptionProcessor to BlockParser.
[ "Add", "an", "instance", "of", "FigcaptionProcessor", "to", "BlockParser", "." ]
python
train
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/gui/qt_b26_gui.py
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_gui.py#L1148-L1180
def edit_tree_item(self): """ if sender is self.tree_gui_settings this will open a filedialog and ask for a filepath this filepath will be updated in the field of self.tree_gui_settings that has been double clicked """ def open_path_dialog(path): """ open...
[ "def", "edit_tree_item", "(", "self", ")", ":", "def", "open_path_dialog", "(", "path", ")", ":", "\"\"\"\n opens a file dialog to get the path to a file and\n \"\"\"", "dialog", "=", "QtWidgets", ".", "QFileDialog", "(", ")", "dialog", ".", "setFile...
if sender is self.tree_gui_settings this will open a filedialog and ask for a filepath this filepath will be updated in the field of self.tree_gui_settings that has been double clicked
[ "if", "sender", "is", "self", ".", "tree_gui_settings", "this", "will", "open", "a", "filedialog", "and", "ask", "for", "a", "filepath", "this", "filepath", "will", "be", "updated", "in", "the", "field", "of", "self", ".", "tree_gui_settings", "that", "has",...
python
train
ojengwa/accounting
accounting/accounting.py
https://github.com/ojengwa/accounting/blob/6343cf373a5c57941e407a92c101ac4bc45382e3/accounting/accounting.py#L179-L223
def format(self, number, **kwargs): """Format a given number. Format a number, with comma-separated thousands and custom precision/decimal places Localise by overriding the precision and thousand / decimal separators 2nd parameter `precision` can be an object matching `settings...
[ "def", "format", "(", "self", ",", "number", ",", "*", "*", "kwargs", ")", ":", "# Resursively format lists", "if", "check_type", "(", "number", ",", "'list'", ")", ":", "return", "map", "(", "lambda", "val", ":", "self", ".", "format", "(", "val", ","...
Format a given number. Format a number, with comma-separated thousands and custom precision/decimal places Localise by overriding the precision and thousand / decimal separators 2nd parameter `precision` can be an object matching `settings.number` Args: number (TYP...
[ "Format", "a", "given", "number", "." ]
python
test
mdavidsaver/p4p
src/p4p/nt/scalar.py
https://github.com/mdavidsaver/p4p/blob/c5e45eac01edfdad9cc2857bc283c7f2695802b8/src/p4p/nt/scalar.py#L183-L203
def wrap(self, value, timestamp=None): """Pack python value into Value Accepts dict to explicitly initialize fields be name. Any other type is assigned to the 'value' field. """ if isinstance(value, Value): return value elif isinstance(value, ntwrappercommon)...
[ "def", "wrap", "(", "self", ",", "value", ",", "timestamp", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "Value", ")", ":", "return", "value", "elif", "isinstance", "(", "value", ",", "ntwrappercommon", ")", ":", "return", "value", "."...
Pack python value into Value Accepts dict to explicitly initialize fields be name. Any other type is assigned to the 'value' field.
[ "Pack", "python", "value", "into", "Value" ]
python
train
pyroscope/pyrocore
src/pyrocore/torrent/engine.py
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/engine.py#L142-L190
def _fmt_files(filelist): """ Produce a file listing. """ depth = max(i.path.count('/') for i in filelist) pad = ['\uFFFE'] * depth base_indent = ' ' * 38 indent = 0 result = [] prev_path = pad sorted_files = sorted((i.path.split('/')[:-1]+pad, i.path.rsplit('/', 1)[-1], i) for i in...
[ "def", "_fmt_files", "(", "filelist", ")", ":", "depth", "=", "max", "(", "i", ".", "path", ".", "count", "(", "'/'", ")", "for", "i", "in", "filelist", ")", "pad", "=", "[", "'\\uFFFE'", "]", "*", "depth", "base_indent", "=", "' '", "*", "38", "...
Produce a file listing.
[ "Produce", "a", "file", "listing", "." ]
python
train
svinota/mdns
mdns/zeroconf.py
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L624-L629
def set_property(self, key, value): """ Update only one property in the dict """ self.properties[key] = value self.sync_properties()
[ "def", "set_property", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "properties", "[", "key", "]", "=", "value", "self", ".", "sync_properties", "(", ")" ]
Update only one property in the dict
[ "Update", "only", "one", "property", "in", "the", "dict" ]
python
train
hugapi/hug
hug/decorators.py
https://github.com/hugapi/hug/blob/080901c81576657f82e2432fd4a82f1d0d2f370c/hug/decorators.py#L41-L57
def default_output_format(content_type='application/json', apply_globally=False, api=None, cli=False, http=True): """A decorator that allows you to override the default output format for an API""" def decorator(formatter): formatter = hug.output_format.content_type(content_type)(formatter) if ap...
[ "def", "default_output_format", "(", "content_type", "=", "'application/json'", ",", "apply_globally", "=", "False", ",", "api", "=", "None", ",", "cli", "=", "False", ",", "http", "=", "True", ")", ":", "def", "decorator", "(", "formatter", ")", ":", "for...
A decorator that allows you to override the default output format for an API
[ "A", "decorator", "that", "allows", "you", "to", "override", "the", "default", "output", "format", "for", "an", "API" ]
python
train
arviz-devs/arviz
arviz/stats/stats.py
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L48-L251
def compare( dataset_dict, ic="waic", method="BB-pseudo-BMA", b_samples=1000, alpha=1, seed=None, scale="deviance", ): r"""Compare models based on WAIC or LOO cross validation. WAIC is Widely applicable information criterion, and LOO is leave-one-out (LOO) cross-validation. Read...
[ "def", "compare", "(", "dataset_dict", ",", "ic", "=", "\"waic\"", ",", "method", "=", "\"BB-pseudo-BMA\"", ",", "b_samples", "=", "1000", ",", "alpha", "=", "1", ",", "seed", "=", "None", ",", "scale", "=", "\"deviance\"", ",", ")", ":", "names", "=",...
r"""Compare models based on WAIC or LOO cross validation. WAIC is Widely applicable information criterion, and LOO is leave-one-out (LOO) cross-validation. Read more theory here - in a paper by some of the leading authorities on model selection - dx.doi.org/10.1111/1467-9868.00353 Parameters -----...
[ "r", "Compare", "models", "based", "on", "WAIC", "or", "LOO", "cross", "validation", "." ]
python
train
infobloxopen/infoblox-client
infoblox_client/object_manager.py
https://github.com/infobloxopen/infoblox-client/blob/edeec62db1935784c728731b2ae7cf0fcc9bf84d/infoblox_client/object_manager.py#L453-L470
def delete_objects_associated_with_a_record(self, name, view, delete_list): """Deletes records associated with record:a or record:aaaa.""" search_objects = {} if 'record:cname' in delete_list: search_objects['record:cname'] = 'canonical' if 'record:txt' in delete_list: ...
[ "def", "delete_objects_associated_with_a_record", "(", "self", ",", "name", ",", "view", ",", "delete_list", ")", ":", "search_objects", "=", "{", "}", "if", "'record:cname'", "in", "delete_list", ":", "search_objects", "[", "'record:cname'", "]", "=", "'canonical...
Deletes records associated with record:a or record:aaaa.
[ "Deletes", "records", "associated", "with", "record", ":", "a", "or", "record", ":", "aaaa", "." ]
python
train
fastai/fastai
fastai/vision/image.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/vision/image.py#L126-L135
def refresh(self)->None: "Apply any logit, flow, or affine transfers that have been sent to the `Image`." if self._logit_px is not None: self._px = self._logit_px.sigmoid_() self._logit_px = None if self._affine_mat is not None or self._flow is not None: self....
[ "def", "refresh", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_logit_px", "is", "not", "None", ":", "self", ".", "_px", "=", "self", ".", "_logit_px", ".", "sigmoid_", "(", ")", "self", ".", "_logit_px", "=", "None", "if", "self", ".",...
Apply any logit, flow, or affine transfers that have been sent to the `Image`.
[ "Apply", "any", "logit", "flow", "or", "affine", "transfers", "that", "have", "been", "sent", "to", "the", "Image", "." ]
python
train
hazelcast/hazelcast-python-client
hazelcast/protocol/codec/ringbuffer_read_many_codec.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/protocol/codec/ringbuffer_read_many_codec.py#L12-L22
def calculate_size(name, start_sequence, min_count, max_count, filter): """ Calculates the request payload size""" data_size = 0 data_size += calculate_size_str(name) data_size += LONG_SIZE_IN_BYTES data_size += INT_SIZE_IN_BYTES data_size += INT_SIZE_IN_BYTES data_size += BOOLEAN_SIZE_IN_BY...
[ "def", "calculate_size", "(", "name", ",", "start_sequence", ",", "min_count", ",", "max_count", ",", "filter", ")", ":", "data_size", "=", "0", "data_size", "+=", "calculate_size_str", "(", "name", ")", "data_size", "+=", "LONG_SIZE_IN_BYTES", "data_size", "+="...
Calculates the request payload size
[ "Calculates", "the", "request", "payload", "size" ]
python
train
niemasd/TreeSwift
treeswift/Tree.py
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L550-L589
def label_to_node(self, selection='leaves'): '''Return a dictionary mapping labels (strings) to ``Node`` objects * If ``selection`` is ``"all"``, the dictionary will contain all nodes * If ``selection`` is ``"leaves"``, the dictionary will only contain leaves * If ``selection`` is ``"...
[ "def", "label_to_node", "(", "self", ",", "selection", "=", "'leaves'", ")", ":", "if", "not", "isinstance", "(", "selection", ",", "set", ")", "and", "not", "isinstance", "(", "selection", ",", "list", ")", "and", "(", "not", "isinstance", "(", "selecti...
Return a dictionary mapping labels (strings) to ``Node`` objects * If ``selection`` is ``"all"``, the dictionary will contain all nodes * If ``selection`` is ``"leaves"``, the dictionary will only contain leaves * If ``selection`` is ``"internal"``, the dictionary will only contain internal n...
[ "Return", "a", "dictionary", "mapping", "labels", "(", "strings", ")", "to", "Node", "objects" ]
python
train
pycontribs/pyrax
pyrax/clouddatabases.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L117-L131
def create_backup(self, instance, name, description=None): """ Creates a backup of the specified instance, giving it the specified name along with an optional description. """ body = {"backup": { "instance": utils.get_id(instance), "name": name, ...
[ "def", "create_backup", "(", "self", ",", "instance", ",", "name", ",", "description", "=", "None", ")", ":", "body", "=", "{", "\"backup\"", ":", "{", "\"instance\"", ":", "utils", ".", "get_id", "(", "instance", ")", ",", "\"name\"", ":", "name", ","...
Creates a backup of the specified instance, giving it the specified name along with an optional description.
[ "Creates", "a", "backup", "of", "the", "specified", "instance", "giving", "it", "the", "specified", "name", "along", "with", "an", "optional", "description", "." ]
python
train
maxalbert/tohu
tohu/v2/generators.py
https://github.com/maxalbert/tohu/blob/43380162fadec99cdd5c5c3152dd6b7d3a9d39a8/tohu/v2/generators.py#L48-L55
def tuple_len(self): """ Length of tuples produced by this generator. """ try: return self._tuple_len except AttributeError: raise NotImplementedError("Class {} does not implement attribute 'tuple_len'.".format(self.__class__.__name__))
[ "def", "tuple_len", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_tuple_len", "except", "AttributeError", ":", "raise", "NotImplementedError", "(", "\"Class {} does not implement attribute 'tuple_len'.\"", ".", "format", "(", "self", ".", "__class__", ...
Length of tuples produced by this generator.
[ "Length", "of", "tuples", "produced", "by", "this", "generator", "." ]
python
train
peterbrittain/asciimatics
asciimatics/effects.py
https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/effects.py#L425-L437
def _respawn(self): """ Pick a random location for the star making sure it does not overwrite an existing piece of text. """ self._cycle = randint(0, len(self._star_chars)) (height, width) = self._screen.dimensions while True: self._x = randint(0, widt...
[ "def", "_respawn", "(", "self", ")", ":", "self", ".", "_cycle", "=", "randint", "(", "0", ",", "len", "(", "self", ".", "_star_chars", ")", ")", "(", "height", ",", "width", ")", "=", "self", ".", "_screen", ".", "dimensions", "while", "True", ":"...
Pick a random location for the star making sure it does not overwrite an existing piece of text.
[ "Pick", "a", "random", "location", "for", "the", "star", "making", "sure", "it", "does", "not", "overwrite", "an", "existing", "piece", "of", "text", "." ]
python
train
Kortemme-Lab/klab
klab/bio/ligand.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/ligand.py#L90-L130
def retrieve_data_from_rcsb(cls, ligand_code, pdb_id = None, silent = True, cached_dir = None): '''Retrieve a file from the RCSB.''' if not silent: colortext.printf("Retrieving data from RCSB") if cached_dir: assert(os.path.exists(cached_dir)) ligand_info_path, l...
[ "def", "retrieve_data_from_rcsb", "(", "cls", ",", "ligand_code", ",", "pdb_id", "=", "None", ",", "silent", "=", "True", ",", "cached_dir", "=", "None", ")", ":", "if", "not", "silent", ":", "colortext", ".", "printf", "(", "\"Retrieving data from RCSB\"", ...
Retrieve a file from the RCSB.
[ "Retrieve", "a", "file", "from", "the", "RCSB", "." ]
python
train
bibanon/BASC-py4chan
basc_py4chan/thread.py
https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L137-L143
def file_objects(self): """Returns the :class:`basc_py4chan.File` objects of all files attached to posts in the thread.""" if self.topic.has_file: yield self.topic.file for reply in self.replies: if reply.has_file: yield reply.file
[ "def", "file_objects", "(", "self", ")", ":", "if", "self", ".", "topic", ".", "has_file", ":", "yield", "self", ".", "topic", ".", "file", "for", "reply", "in", "self", ".", "replies", ":", "if", "reply", ".", "has_file", ":", "yield", "reply", ".",...
Returns the :class:`basc_py4chan.File` objects of all files attached to posts in the thread.
[ "Returns", "the", ":", "class", ":", "basc_py4chan", ".", "File", "objects", "of", "all", "files", "attached", "to", "posts", "in", "the", "thread", "." ]
python
train
google/grr
grr/server/grr_response_server/aff4_objects/security.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/security.py#L696-L701
def BuildApprovalSymlinksUrns(self, approval_id): """Builds list of symlinks URNs for the approval object.""" return [ self.ApprovalSymlinkUrnBuilder("cron", self.subject_urn.Basename(), self.token.username, approval_id) ]
[ "def", "BuildApprovalSymlinksUrns", "(", "self", ",", "approval_id", ")", ":", "return", "[", "self", ".", "ApprovalSymlinkUrnBuilder", "(", "\"cron\"", ",", "self", ".", "subject_urn", ".", "Basename", "(", ")", ",", "self", ".", "token", ".", "username", "...
Builds list of symlinks URNs for the approval object.
[ "Builds", "list", "of", "symlinks", "URNs", "for", "the", "approval", "object", "." ]
python
train
Clinical-Genomics/scout
scout/server/blueprints/cases/views.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/cases/views.py#L736-L742
def research(institute_id, case_name): """Open the research list for a case.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) user_obj = store.user(current_user.email) link = url_for('.case', institute_id=institute_id, case_name=case_name) store.open_research(institute...
[ "def", "research", "(", "institute_id", ",", "case_name", ")", ":", "institute_obj", ",", "case_obj", "=", "institute_and_case", "(", "store", ",", "institute_id", ",", "case_name", ")", "user_obj", "=", "store", ".", "user", "(", "current_user", ".", "email",...
Open the research list for a case.
[ "Open", "the", "research", "list", "for", "a", "case", "." ]
python
test
eyurtsev/FlowCytometryTools
FlowCytometryTools/core/bases.py
https://github.com/eyurtsev/FlowCytometryTools/blob/4355632508b875273d68c7e2972c17668bcf7b40/FlowCytometryTools/core/bases.py#L327-L361
def apply(self, func, applyto='measurement', noneval=nan, setdata=False): """ Apply func either to self or to associated data. If data is not already parsed, try and read it. Parameters ---------- func : callable The function either accepts a measurement obje...
[ "def", "apply", "(", "self", ",", "func", ",", "applyto", "=", "'measurement'", ",", "noneval", "=", "nan", ",", "setdata", "=", "False", ")", ":", "applyto", "=", "applyto", ".", "lower", "(", ")", "if", "applyto", "==", "'data'", ":", "if", "self",...
Apply func either to self or to associated data. If data is not already parsed, try and read it. Parameters ---------- func : callable The function either accepts a measurement object or an FCS object. Does some calculation and returns the result. applyto...
[ "Apply", "func", "either", "to", "self", "or", "to", "associated", "data", ".", "If", "data", "is", "not", "already", "parsed", "try", "and", "read", "it", "." ]
python
train
sampsyo/confuse
confuse.py
https://github.com/sampsyo/confuse/blob/9ff0992e30470f6822824711950e6dd906e253fb/confuse.py#L989-L1029
def dump(self, full=True, redact=False): """Dump the Configuration object to a YAML file. The order of the keys is determined from the default configuration file. All keys not in the default configuration will be appended to the end of the file. :param filename: The file to du...
[ "def", "dump", "(", "self", ",", "full", "=", "True", ",", "redact", "=", "False", ")", ":", "if", "full", ":", "out_dict", "=", "self", ".", "flatten", "(", "redact", "=", "redact", ")", "else", ":", "# Exclude defaults when flattening.", "sources", "="...
Dump the Configuration object to a YAML file. The order of the keys is determined from the default configuration file. All keys not in the default configuration will be appended to the end of the file. :param filename: The file to dump the configuration to, or None ...
[ "Dump", "the", "Configuration", "object", "to", "a", "YAML", "file", "." ]
python
train
tophatmonocle/ims_lti_py
ims_lti_py/tool_config.py
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_config.py#L105-L170
def process_xml(self, xml): ''' Parse tool configuration data out of the Common Cartridge LTI link XML. ''' root = objectify.fromstring(xml, parser = etree.XMLParser()) # Parse all children of the root node for child in root.getchildren(): if 'title' in child....
[ "def", "process_xml", "(", "self", ",", "xml", ")", ":", "root", "=", "objectify", ".", "fromstring", "(", "xml", ",", "parser", "=", "etree", ".", "XMLParser", "(", ")", ")", "# Parse all children of the root node", "for", "child", "in", "root", ".", "get...
Parse tool configuration data out of the Common Cartridge LTI link XML.
[ "Parse", "tool", "configuration", "data", "out", "of", "the", "Common", "Cartridge", "LTI", "link", "XML", "." ]
python
train
wtsi-hgi/python-baton-wrapper
baton/collections.py
https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/collections.py#L79-L86
def get_by_number(self, number: int) -> Optional[DataObjectReplica]: """ Gets the data object replica in this collection with the given number. Will return `None` if such replica does not exist. :param number: the number of the data object replica to get :return: the data object ...
[ "def", "get_by_number", "(", "self", ",", "number", ":", "int", ")", "->", "Optional", "[", "DataObjectReplica", "]", ":", "return", "self", ".", "_data", ".", "get", "(", "number", ",", "None", ")" ]
Gets the data object replica in this collection with the given number. Will return `None` if such replica does not exist. :param number: the number of the data object replica to get :return: the data object replica in this collection with the given number
[ "Gets", "the", "data", "object", "replica", "in", "this", "collection", "with", "the", "given", "number", ".", "Will", "return", "None", "if", "such", "replica", "does", "not", "exist", ".", ":", "param", "number", ":", "the", "number", "of", "the", "dat...
python
train
projectshift/shift-boiler
boiler/feature/users.py
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/feature/users.py#L72-L97
def enable_request_loader(): """ Enable request loader Optional user loader based on incomin request object. This is useful to enable on top of default user loader if you want to authenticate API requests via bearer token header. :return: """ @login_manager.request_loader def load_us...
[ "def", "enable_request_loader", "(", ")", ":", "@", "login_manager", ".", "request_loader", "def", "load_user_from_request", "(", "request", ")", ":", "user", "=", "None", "auth", "=", "request", ".", "headers", ".", "get", "(", "'Authorization'", ")", "if", ...
Enable request loader Optional user loader based on incomin request object. This is useful to enable on top of default user loader if you want to authenticate API requests via bearer token header. :return:
[ "Enable", "request", "loader", "Optional", "user", "loader", "based", "on", "incomin", "request", "object", ".", "This", "is", "useful", "to", "enable", "on", "top", "of", "default", "user", "loader", "if", "you", "want", "to", "authenticate", "API", "reques...
python
train
jurismarches/chopper
chopper/extractor.py
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/extractor.py#L142-L152
def __add(self, dest, xpath): """ Adds a Xpath expression to the dest list :param dest: The destination list to add the Xpath :type dest: list :param xpath: The Xpath expression to add :type xpath: str """ assert isinstance(xpath, string_types) de...
[ "def", "__add", "(", "self", ",", "dest", ",", "xpath", ")", ":", "assert", "isinstance", "(", "xpath", ",", "string_types", ")", "dest", ".", "append", "(", "xpath", ")" ]
Adds a Xpath expression to the dest list :param dest: The destination list to add the Xpath :type dest: list :param xpath: The Xpath expression to add :type xpath: str
[ "Adds", "a", "Xpath", "expression", "to", "the", "dest", "list" ]
python
train
SignalN/language
language/ngrams.py
https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L117-L129
def word_matches(s1, s2, n=3): """ Word-level n-grams that match between two strings Args: s1: a string s2: another string n: an int for the n in n-gram Returns: set: the n-grams found in both strings """ return __matches(s1, s2, word...
[ "def", "word_matches", "(", "s1", ",", "s2", ",", "n", "=", "3", ")", ":", "return", "__matches", "(", "s1", ",", "s2", ",", "word_ngrams", ",", "n", "=", "n", ")" ]
Word-level n-grams that match between two strings Args: s1: a string s2: another string n: an int for the n in n-gram Returns: set: the n-grams found in both strings
[ "Word", "-", "level", "n", "-", "grams", "that", "match", "between", "two", "strings" ]
python
train
Shinichi-Nakagawa/pitchpx
pitchpx/baseball/retrosheet.py
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/baseball/retrosheet.py#L154-L172
def ball_count(cls, ball_tally, strike_tally, pitch_res): """ Ball/Strike counter :param ball_tally: Ball telly :param strike_tally: Strike telly :param pitch_res: pitching result(Retrosheet format) :return: ball count, strike count """ b, s = ball_tally, ...
[ "def", "ball_count", "(", "cls", ",", "ball_tally", ",", "strike_tally", ",", "pitch_res", ")", ":", "b", ",", "s", "=", "ball_tally", ",", "strike_tally", "if", "pitch_res", "==", "\"B\"", ":", "if", "ball_tally", "<", "4", ":", "b", "+=", "1", "elif"...
Ball/Strike counter :param ball_tally: Ball telly :param strike_tally: Strike telly :param pitch_res: pitching result(Retrosheet format) :return: ball count, strike count
[ "Ball", "/", "Strike", "counter", ":", "param", "ball_tally", ":", "Ball", "telly", ":", "param", "strike_tally", ":", "Strike", "telly", ":", "param", "pitch_res", ":", "pitching", "result", "(", "Retrosheet", "format", ")", ":", "return", ":", "ball", "c...
python
train
mgraffg/EvoDAG
EvoDAG/population.py
https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/population.py#L276-L282
def trace(self, n): "Restore the position in the history of individual v's nodes" trace_map = {} self._trace(n, trace_map) s = list(trace_map.keys()) s.sort() return s
[ "def", "trace", "(", "self", ",", "n", ")", ":", "trace_map", "=", "{", "}", "self", ".", "_trace", "(", "n", ",", "trace_map", ")", "s", "=", "list", "(", "trace_map", ".", "keys", "(", ")", ")", "s", ".", "sort", "(", ")", "return", "s" ]
Restore the position in the history of individual v's nodes
[ "Restore", "the", "position", "in", "the", "history", "of", "individual", "v", "s", "nodes" ]
python
train
RI-imaging/qpformat
qpformat/file_formats/series_zip_tif_holo.py
https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_zip_tif_holo.py#L63-L80
def get_time(self, idx): """Time for each TIFF file If there are no metadata keyword arguments defined for the TIFF file format, then the zip file `date_time` value is used. """ # first try to get the time from the TIFF file # (possible meta data keywords) ...
[ "def", "get_time", "(", "self", ",", "idx", ")", ":", "# first try to get the time from the TIFF file", "# (possible meta data keywords)", "ds", "=", "self", ".", "_get_dataset", "(", "idx", ")", "thetime", "=", "ds", ".", "get_time", "(", ")", "if", "np", ".", ...
Time for each TIFF file If there are no metadata keyword arguments defined for the TIFF file format, then the zip file `date_time` value is used.
[ "Time", "for", "each", "TIFF", "file" ]
python
train
doraemonext/wechat-python-sdk
wechat_sdk/lib/crypto/pkcs7.py
https://github.com/doraemonext/wechat-python-sdk/blob/bf6f6f3d4a5440feb73a51937059d7feddc335a0/wechat_sdk/lib/crypto/pkcs7.py#L11-L24
def encode(cls, text): """ 对需要加密的明文进行填充补位 @param text: 需要进行填充补位操作的明文 @return: 补齐明文字符串 """ text_length = len(text) # 计算需要填充的位数 amount_to_pad = cls.block_size - (text_length % cls.block_size) if amount_to_pad == 0: amount_to_pad = cls.blo...
[ "def", "encode", "(", "cls", ",", "text", ")", ":", "text_length", "=", "len", "(", "text", ")", "# 计算需要填充的位数", "amount_to_pad", "=", "cls", ".", "block_size", "-", "(", "text_length", "%", "cls", ".", "block_size", ")", "if", "amount_to_pad", "==", "0",...
对需要加密的明文进行填充补位 @param text: 需要进行填充补位操作的明文 @return: 补齐明文字符串
[ "对需要加密的明文进行填充补位" ]
python
valid
saltstack/salt
salt/returners/memcache_return.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/memcache_return.py#L158-L164
def save_load(jid, load, minions=None): ''' Save the load to the specified jid ''' serv = _get_serv(ret=None) serv.set(jid, salt.utils.json.dumps(load)) _append_list(serv, 'jids', jid)
[ "def", "save_load", "(", "jid", ",", "load", ",", "minions", "=", "None", ")", ":", "serv", "=", "_get_serv", "(", "ret", "=", "None", ")", "serv", ".", "set", "(", "jid", ",", "salt", ".", "utils", ".", "json", ".", "dumps", "(", "load", ")", ...
Save the load to the specified jid
[ "Save", "the", "load", "to", "the", "specified", "jid" ]
python
train
radjkarl/imgProcessor
imgProcessor/transform/equalizeImage.py
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/equalizeImage.py#L11-L47
def equalizeImage(img, save_path=None, name_additive='_eqHist'): ''' Equalize the histogram (contrast) of an image works with RGB/multi-channel images and flat-arrays @param img - image_path or np.array @param save_path if given output images will be saved there @param name_additiv...
[ "def", "equalizeImage", "(", "img", ",", "save_path", "=", "None", ",", "name_additive", "=", "'_eqHist'", ")", ":", "if", "isinstance", "(", "img", ",", "string_types", ")", ":", "img", "=", "PathStr", "(", "img", ")", "if", "not", "img", ".", "exists...
Equalize the histogram (contrast) of an image works with RGB/multi-channel images and flat-arrays @param img - image_path or np.array @param save_path if given output images will be saved there @param name_additive if given this additive will be appended to output images @return outpu...
[ "Equalize", "the", "histogram", "(", "contrast", ")", "of", "an", "image", "works", "with", "RGB", "/", "multi", "-", "channel", "images", "and", "flat", "-", "arrays" ]
python
train
jmcgeheeiv/pyfakefs
pyfakefs/fake_filesystem.py
https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_filesystem.py#L4166-L4181
def rmdir(self, target_directory, dir_fd=None): """Remove a leaf Fake directory. Args: target_directory: (str) Name of directory to remove. dir_fd: If not `None`, the file descriptor of a directory, with `target_directory` being relative to this directory. ...
[ "def", "rmdir", "(", "self", ",", "target_directory", ",", "dir_fd", "=", "None", ")", ":", "target_directory", "=", "self", ".", "_path_with_dir_fd", "(", "target_directory", ",", "self", ".", "rmdir", ",", "dir_fd", ")", "self", ".", "filesystem", ".", "...
Remove a leaf Fake directory. Args: target_directory: (str) Name of directory to remove. dir_fd: If not `None`, the file descriptor of a directory, with `target_directory` being relative to this directory. New in Python 3.3. Raises: O...
[ "Remove", "a", "leaf", "Fake", "directory", "." ]
python
train
PeerAssets/pypeerassets
pypeerassets/pautils.py
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/pautils.py#L213-L226
def load_deck_p2th_into_local_node(provider: RpcNode, deck: Deck) -> None: ''' load deck p2th into local node via "importprivke", this allows building of proof-of-timeline for this deck ''' assert isinstance(provider, RpcNode), {"error": "You can load privkeys only into local node."} error = {"...
[ "def", "load_deck_p2th_into_local_node", "(", "provider", ":", "RpcNode", ",", "deck", ":", "Deck", ")", "->", "None", ":", "assert", "isinstance", "(", "provider", ",", "RpcNode", ")", ",", "{", "\"error\"", ":", "\"You can load privkeys only into local node.\"", ...
load deck p2th into local node via "importprivke", this allows building of proof-of-timeline for this deck
[ "load", "deck", "p2th", "into", "local", "node", "via", "importprivke", "this", "allows", "building", "of", "proof", "-", "of", "-", "timeline", "for", "this", "deck" ]
python
train
stephen-bunn/file-config
tasks/package.py
https://github.com/stephen-bunn/file-config/blob/93429360c949985202e1f2b9cd0340731819ba75/tasks/package.py#L56-L62
def check(ctx): """ Check built package is valid. """ check_command = f"twine check {ctx.directory!s}/dist/*" report.info(ctx, "package.check", "checking package") ctx.run(check_command)
[ "def", "check", "(", "ctx", ")", ":", "check_command", "=", "f\"twine check {ctx.directory!s}/dist/*\"", "report", ".", "info", "(", "ctx", ",", "\"package.check\"", ",", "\"checking package\"", ")", "ctx", ".", "run", "(", "check_command", ")" ]
Check built package is valid.
[ "Check", "built", "package", "is", "valid", "." ]
python
train
learningequality/ricecooker
ricecooker/classes/nodes.py
https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/ricecooker/classes/nodes.py#L359-L383
def to_dict(self): """ to_dict: puts Topic or Content node data into the format that Kolibri Studio expects Args: None Returns: dict of channel data """ return { "title": self.title, "language" : self.language, "description": self.descr...
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "\"title\"", ":", "self", ".", "title", ",", "\"language\"", ":", "self", ".", "language", ",", "\"description\"", ":", "self", ".", "description", ",", "\"node_id\"", ":", "self", ".", "get_node_id",...
to_dict: puts Topic or Content node data into the format that Kolibri Studio expects Args: None Returns: dict of channel data
[ "to_dict", ":", "puts", "Topic", "or", "Content", "node", "data", "into", "the", "format", "that", "Kolibri", "Studio", "expects", "Args", ":", "None", "Returns", ":", "dict", "of", "channel", "data" ]
python
train
brews/snakebacon
snakebacon/mcmcbackends/bacon/utils.py
https://github.com/brews/snakebacon/blob/f5363d0d1225912adc30031bf2c13b54000de8f2/snakebacon/mcmcbackends/bacon/utils.py#L52-L123
def calibrate_dates(chron, calib_curve, d_r, d_std, cutoff=0.0001, normal_distr=False, t_a=[3], t_b=[4]): """Get density of calendar dates for chron date segment in core Parameters ---------- chron : DatedProxy-like calib_curve : CalibCurve or list of CalibCurves d_r : scalar or ndarray ...
[ "def", "calibrate_dates", "(", "chron", ",", "calib_curve", ",", "d_r", ",", "d_std", ",", "cutoff", "=", "0.0001", ",", "normal_distr", "=", "False", ",", "t_a", "=", "[", "3", "]", ",", "t_b", "=", "[", "4", "]", ")", ":", "# Python version of .bacon...
Get density of calendar dates for chron date segment in core Parameters ---------- chron : DatedProxy-like calib_curve : CalibCurve or list of CalibCurves d_r : scalar or ndarray Carbon reservoir offset. d_std : scalar or ndarray Carbon reservoir offset error standard deviation....
[ "Get", "density", "of", "calendar", "dates", "for", "chron", "date", "segment", "in", "core" ]
python
train
lappis-unb/salic-ml
src/salicml/data/query.py
https://github.com/lappis-unb/salic-ml/blob/1b3ebc4f8067740999897ccffd9892dc94482a93/src/salicml/data/query.py#L75-L90
def get_metric(self, pronac, metric): """ Get metric for the project with the given pronac number. Usage: >>> metrics.get_metric(pronac_id, 'finance.approved_funds') """ assert isinstance(metric, str) assert '.' in metric, 'metric must declare a namespace' ...
[ "def", "get_metric", "(", "self", ",", "pronac", ",", "metric", ")", ":", "assert", "isinstance", "(", "metric", ",", "str", ")", "assert", "'.'", "in", "metric", ",", "'metric must declare a namespace'", "try", ":", "func", "=", "self", ".", "_metrics", "...
Get metric for the project with the given pronac number. Usage: >>> metrics.get_metric(pronac_id, 'finance.approved_funds')
[ "Get", "metric", "for", "the", "project", "with", "the", "given", "pronac", "number", "." ]
python
train
saltstack/salt
salt/modules/postgres.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/postgres.py#L734-L767
def tablespace_create(name, location, options=None, owner=None, user=None, host=None, port=None, maintenance_db=None, password=None, runas=None): ''' Adds a tablespace to the Postgres server. CLI Example: .. code-block:: bash salt '*' postgres.table...
[ "def", "tablespace_create", "(", "name", ",", "location", ",", "options", "=", "None", ",", "owner", "=", "None", ",", "user", "=", "None", ",", "host", "=", "None", ",", "port", "=", "None", ",", "maintenance_db", "=", "None", ",", "password", "=", ...
Adds a tablespace to the Postgres server. CLI Example: .. code-block:: bash salt '*' postgres.tablespace_create tablespacename '/path/datadir' .. versionadded:: 2015.8.0
[ "Adds", "a", "tablespace", "to", "the", "Postgres", "server", "." ]
python
train
pantsbuild/pants
src/python/pants/build_graph/build_graph.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/build_graph/build_graph.py#L182-L191
def get_derived_from(self, address): """Get the target the specified target was derived from. If a Target was injected programmatically, e.g. from codegen, this allows us to trace its ancestry. If a Target is not derived, default to returning itself. :API: public """ parent_address = self._de...
[ "def", "get_derived_from", "(", "self", ",", "address", ")", ":", "parent_address", "=", "self", ".", "_derived_from_by_derivative", ".", "get", "(", "address", ",", "address", ")", "return", "self", ".", "get_target", "(", "parent_address", ")" ]
Get the target the specified target was derived from. If a Target was injected programmatically, e.g. from codegen, this allows us to trace its ancestry. If a Target is not derived, default to returning itself. :API: public
[ "Get", "the", "target", "the", "specified", "target", "was", "derived", "from", "." ]
python
train
bokeh/bokeh
bokeh/layouts.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/layouts.py#L100-L142
def column(*args, **kwargs): """ Create a column of Bokeh Layout objects. Forces all objects to have the same sizing_mode, which is required for complex layouts to work. Args: children (list of :class:`~bokeh.models.layouts.LayoutDOM` ): A list of instances for the column. Can be any of...
[ "def", "column", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "sizing_mode", "=", "kwargs", ".", "pop", "(", "'sizing_mode'", ",", "None", ")", "children", "=", "kwargs", ".", "pop", "(", "'children'", ",", "None", ")", "children", "=", "_han...
Create a column of Bokeh Layout objects. Forces all objects to have the same sizing_mode, which is required for complex layouts to work. Args: children (list of :class:`~bokeh.models.layouts.LayoutDOM` ): A list of instances for the column. Can be any of the following - :class:`~bokeh.model...
[ "Create", "a", "column", "of", "Bokeh", "Layout", "objects", ".", "Forces", "all", "objects", "to", "have", "the", "same", "sizing_mode", "which", "is", "required", "for", "complex", "layouts", "to", "work", "." ]
python
train
kata198/indexedredis
IndexedRedis/fields/foreign.py
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/foreign.py#L243-L258
def objHasUnsavedChanges(self): ''' objHasUnsavedChanges - @see ForeignLinkData.objHasUnsavedChanges True if ANY object has unsaved changes. ''' if not self.obj: return False for thisObj in self.obj: if not thisObj: continue if thisObj.hasUnsavedChanges(cascadeObjects=True): return True...
[ "def", "objHasUnsavedChanges", "(", "self", ")", ":", "if", "not", "self", ".", "obj", ":", "return", "False", "for", "thisObj", "in", "self", ".", "obj", ":", "if", "not", "thisObj", ":", "continue", "if", "thisObj", ".", "hasUnsavedChanges", "(", "casc...
objHasUnsavedChanges - @see ForeignLinkData.objHasUnsavedChanges True if ANY object has unsaved changes.
[ "objHasUnsavedChanges", "-", "@see", "ForeignLinkData", ".", "objHasUnsavedChanges" ]
python
valid
binux/pyspider
pyspider/libs/response.py
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/response.py#L140-L147
def doc(self): """Returns a PyQuery object of the response's content""" if hasattr(self, '_doc'): return self._doc elements = self.etree doc = self._doc = PyQuery(elements) doc.make_links_absolute(utils.text(self.url)) return doc
[ "def", "doc", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_doc'", ")", ":", "return", "self", ".", "_doc", "elements", "=", "self", ".", "etree", "doc", "=", "self", ".", "_doc", "=", "PyQuery", "(", "elements", ")", "doc", ".", "...
Returns a PyQuery object of the response's content
[ "Returns", "a", "PyQuery", "object", "of", "the", "response", "s", "content" ]
python
train
jbittel/django-mama-cas
mama_cas/models.py
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L42-L56
def create_ticket(self, ticket=None, **kwargs): """ Create a new ``Ticket``. Additional arguments are passed to the ``create()`` function. Return the newly created ``Ticket``. """ if not ticket: ticket = self.create_ticket_str() if 'service' in kwargs: ...
[ "def", "create_ticket", "(", "self", ",", "ticket", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "ticket", ":", "ticket", "=", "self", ".", "create_ticket_str", "(", ")", "if", "'service'", "in", "kwargs", ":", "kwargs", "[", "'service'...
Create a new ``Ticket``. Additional arguments are passed to the ``create()`` function. Return the newly created ``Ticket``.
[ "Create", "a", "new", "Ticket", ".", "Additional", "arguments", "are", "passed", "to", "the", "create", "()", "function", ".", "Return", "the", "newly", "created", "Ticket", "." ]
python
train
PyCQA/pylint-django
pylint_django/plugin.py
https://github.com/PyCQA/pylint-django/blob/0bbee433519f48134df4a797341c4196546a454e/pylint_django/plugin.py#L24-L41
def register(linter): """ Registering additional checkers. """ # add all of the checkers register_checkers(linter) # register any checking fiddlers try: from pylint_django.augmentations import apply_augmentations apply_augmentations(linter) except ImportError: # ...
[ "def", "register", "(", "linter", ")", ":", "# add all of the checkers", "register_checkers", "(", "linter", ")", "# register any checking fiddlers", "try", ":", "from", "pylint_django", ".", "augmentations", "import", "apply_augmentations", "apply_augmentations", "(", "l...
Registering additional checkers.
[ "Registering", "additional", "checkers", "." ]
python
train
bsmurphy/PyKrige
pykrige/rk.py
https://github.com/bsmurphy/PyKrige/blob/a4db3003b0b5688658c12faeb95a5a8b2b14b433/pykrige/rk.py#L254-L273
def score(self, p, x, y, sample_weight=None): """ Overloading default regression score method Parameters ---------- p: ndarray (Ns, d) array of predictor variables (Ns samples, d dimensions) for regression x: ndarray ndarray of (x, y) ...
[ "def", "score", "(", "self", ",", "p", ",", "x", ",", "y", ",", "sample_weight", "=", "None", ")", ":", "return", "r2_score", "(", "y_pred", "=", "self", ".", "predict", "(", "p", ",", "x", ")", ",", "y_true", "=", "y", ",", "sample_weight", "=",...
Overloading default regression score method Parameters ---------- p: ndarray (Ns, d) array of predictor variables (Ns samples, d dimensions) for regression x: ndarray ndarray of (x, y) points. Needs to be a (Ns, 2) array corresponding to t...
[ "Overloading", "default", "regression", "score", "method" ]
python
train
angr/angr
angr/analyses/reassembler.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/reassembler.py#L1223-L1236
def desymbolize(self): """ We believe this was a pointer and symbolized it before. Now we want to desymbolize it. The following actions are performed: - Reload content from memory - Mark the sort as 'unknown' :return: None """ self.sort = 'unknown' ...
[ "def", "desymbolize", "(", "self", ")", ":", "self", ".", "sort", "=", "'unknown'", "content", "=", "self", ".", "binary", ".", "fast_memory_load", "(", "self", ".", "addr", ",", "self", ".", "size", ",", "bytes", ")", "self", ".", "content", "=", "[...
We believe this was a pointer and symbolized it before. Now we want to desymbolize it. The following actions are performed: - Reload content from memory - Mark the sort as 'unknown' :return: None
[ "We", "believe", "this", "was", "a", "pointer", "and", "symbolized", "it", "before", ".", "Now", "we", "want", "to", "desymbolize", "it", "." ]
python
train
JohnVinyard/zounds
zounds/timeseries/audiosamples.py
https://github.com/JohnVinyard/zounds/blob/337b3f98753d09eaab1c72dcd37bb852a3fa5ac6/zounds/timeseries/audiosamples.py#L149-L158
def mono(self): """ Return this instance summed to mono. If the instance is already mono, this is a no-op. """ if self.channels == 1: return self x = self.sum(axis=1) * 0.5 y = x * 0.5 return AudioSamples(y, self.samplerate)
[ "def", "mono", "(", "self", ")", ":", "if", "self", ".", "channels", "==", "1", ":", "return", "self", "x", "=", "self", ".", "sum", "(", "axis", "=", "1", ")", "*", "0.5", "y", "=", "x", "*", "0.5", "return", "AudioSamples", "(", "y", ",", "...
Return this instance summed to mono. If the instance is already mono, this is a no-op.
[ "Return", "this", "instance", "summed", "to", "mono", ".", "If", "the", "instance", "is", "already", "mono", "this", "is", "a", "no", "-", "op", "." ]
python
train
seme0021/python-zillow
zillow/api.py
https://github.com/seme0021/python-zillow/blob/cddb9bad91d6c0ecdb67dbb9865b9392bd5116ab/zillow/api.py#L35-L68
def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): """ The GetSearchResults API finds a property for a specified address. The content returned contains the address for the property or properties as well as the Zillow Property ID (ZPID) and current Zestimate. ...
[ "def", "GetSearchResults", "(", "self", ",", "zws_id", ",", "address", ",", "citystatezip", ",", "retnzestimate", "=", "False", ")", ":", "url", "=", "'%s/GetSearchResults.htm'", "%", "(", "self", ".", "base_url", ")", "parameters", "=", "{", "'zws-id'", ":"...
The GetSearchResults API finds a property for a specified address. The content returned contains the address for the property or properties as well as the Zillow Property ID (ZPID) and current Zestimate. It also includes the date the Zestimate was computed, a valuation range and the Zestimate ranking fo...
[ "The", "GetSearchResults", "API", "finds", "a", "property", "for", "a", "specified", "address", ".", "The", "content", "returned", "contains", "the", "address", "for", "the", "property", "or", "properties", "as", "well", "as", "the", "Zillow", "Property", "ID"...
python
train
SBRG/ssbio
ssbio/protein/structure/properties/freesasa.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/properties/freesasa.py#L43-L93
def parse_rsa_data(rsa_outfile, ignore_hets=True): """Process a NACCESS or freesasa RSA output file. Adapted from Biopython NACCESS modele. Args: rsa_outfile (str): Path to RSA output file ignore_hets (bool): If HETATMs should be excluded from the final dictionary. This is extremely importa...
[ "def", "parse_rsa_data", "(", "rsa_outfile", ",", "ignore_hets", "=", "True", ")", ":", "naccess_rel_dict", "=", "OrderedDict", "(", ")", "with", "open", "(", "rsa_outfile", ",", "'r'", ")", "as", "f", ":", "for", "line", "in", "f", ":", "if", "line", ...
Process a NACCESS or freesasa RSA output file. Adapted from Biopython NACCESS modele. Args: rsa_outfile (str): Path to RSA output file ignore_hets (bool): If HETATMs should be excluded from the final dictionary. This is extremely important when loading this information into a ChainP...
[ "Process", "a", "NACCESS", "or", "freesasa", "RSA", "output", "file", ".", "Adapted", "from", "Biopython", "NACCESS", "modele", ".", "Args", ":", "rsa_outfile", "(", "str", ")", ":", "Path", "to", "RSA", "output", "file", "ignore_hets", "(", "bool", ")", ...
python
train
mrjoes/sockjs-tornado
sockjs/tornado/transports/base.py
https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/transports/base.py#L12-L18
def get_conn_info(self): """Return `ConnectionInfo` object from current transport""" return session.ConnectionInfo(self.request.remote_ip, self.request.cookies, self.request.arguments, self....
[ "def", "get_conn_info", "(", "self", ")", ":", "return", "session", ".", "ConnectionInfo", "(", "self", ".", "request", ".", "remote_ip", ",", "self", ".", "request", ".", "cookies", ",", "self", ".", "request", ".", "arguments", ",", "self", ".", "reque...
Return `ConnectionInfo` object from current transport
[ "Return", "ConnectionInfo", "object", "from", "current", "transport" ]
python
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/config_database.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/config_database.py#L365-L375
def get_config_database_info(self): """Get memory usage and space statistics on the config database.""" max_size = self.config_database.data_size max_entries = self.config_database.max_entries() used_size = self.config_database.data_index used_entries = len(self.config_database....
[ "def", "get_config_database_info", "(", "self", ")", ":", "max_size", "=", "self", ".", "config_database", ".", "data_size", "max_entries", "=", "self", ".", "config_database", ".", "max_entries", "(", ")", "used_size", "=", "self", ".", "config_database", ".", ...
Get memory usage and space statistics on the config database.
[ "Get", "memory", "usage", "and", "space", "statistics", "on", "the", "config", "database", "." ]
python
train
MisterY/gnucash-portfolio
gnucash_portfolio/lib/datetimeutils.py
https://github.com/MisterY/gnucash-portfolio/blob/bfaad8345a5479d1cd111acee1939e25c2a638c2/gnucash_portfolio/lib/datetimeutils.py#L71-L80
def get_period_last_week() -> str: """ Returns the last week as a period string """ today = Datum() today.start_of_day() # start_date = today - timedelta(days=7) start_date = today.clone() start_date.subtract_days(7) period = get_period(start_date.value, today.value) return period
[ "def", "get_period_last_week", "(", ")", "->", "str", ":", "today", "=", "Datum", "(", ")", "today", ".", "start_of_day", "(", ")", "# start_date = today - timedelta(days=7)", "start_date", "=", "today", ".", "clone", "(", ")", "start_date", ".", "subtract_days"...
Returns the last week as a period string
[ "Returns", "the", "last", "week", "as", "a", "period", "string" ]
python
train
PMEAL/OpenPNM
openpnm/algorithms/OrdinaryPercolation.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/algorithms/OrdinaryPercolation.py#L105-L177
def setup(self, phase=None, access_limited=None, mode='', throat_entry_pressure='', pore_entry_pressure='', pore_volume='', throat_volume=''): r""" Used to specify necessary arguments to the simulation. Th...
[ "def", "setup", "(", "self", ",", "phase", "=", "None", ",", "access_limited", "=", "None", ",", "mode", "=", "''", ",", "throat_entry_pressure", "=", "''", ",", "pore_entry_pressure", "=", "''", ",", "pore_volume", "=", "''", ",", "throat_volume", "=", ...
r""" Used to specify necessary arguments to the simulation. This method is useful for resetting the algorithm or applying more explicit control. Parameters ---------- phase : OpenPNM Phase object The Phase object containing the physical properties of the invading ...
[ "r", "Used", "to", "specify", "necessary", "arguments", "to", "the", "simulation", ".", "This", "method", "is", "useful", "for", "resetting", "the", "algorithm", "or", "applying", "more", "explicit", "control", "." ]
python
train
AustralianSynchrotron/lightflow
lightflow/workflows.py
https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workflows.py#L16-L49
def start_workflow(name, config, *, queue=DefaultJobQueueName.Workflow, clear_data_store=True, store_args=None): """ Start a single workflow by sending it to the workflow queue. Args: name (str): The name of the workflow that should be started. Refers to the name of the w...
[ "def", "start_workflow", "(", "name", ",", "config", ",", "*", ",", "queue", "=", "DefaultJobQueueName", ".", "Workflow", ",", "clear_data_store", "=", "True", ",", "store_args", "=", "None", ")", ":", "try", ":", "wf", "=", "Workflow", ".", "from_name", ...
Start a single workflow by sending it to the workflow queue. Args: name (str): The name of the workflow that should be started. Refers to the name of the workflow file without the .py extension. config (Config): Reference to the configuration object from which the settings f...
[ "Start", "a", "single", "workflow", "by", "sending", "it", "to", "the", "workflow", "queue", "." ]
python
train
LogicalDash/LiSE
ELiDE/ELiDE/card.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/card.py#L961-L978
def on_deckbuilder(self, *args): """Bind my deckbuilder to update my ``scroll``, and my ``scroll`` to update my deckbuilder. """ if self.deckbuilder is None: return att = 'deck_{}_hint_offsets'.format( 'x' if self.orientation == 'horizontal' else 'y' ...
[ "def", "on_deckbuilder", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "deckbuilder", "is", "None", ":", "return", "att", "=", "'deck_{}_hint_offsets'", ".", "format", "(", "'x'", "if", "self", ".", "orientation", "==", "'horizontal'", "else"...
Bind my deckbuilder to update my ``scroll``, and my ``scroll`` to update my deckbuilder.
[ "Bind", "my", "deckbuilder", "to", "update", "my", "scroll", "and", "my", "scroll", "to", "update", "my", "deckbuilder", "." ]
python
train
saltstack/salt
salt/modules/parallels.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/parallels.py#L49-L59
def _normalize_args(args): ''' Return args as a list of strings ''' if isinstance(args, six.string_types): return shlex.split(args) if isinstance(args, (tuple, list)): return [six.text_type(arg) for arg in args] else: return [six.text_type(args)]
[ "def", "_normalize_args", "(", "args", ")", ":", "if", "isinstance", "(", "args", ",", "six", ".", "string_types", ")", ":", "return", "shlex", ".", "split", "(", "args", ")", "if", "isinstance", "(", "args", ",", "(", "tuple", ",", "list", ")", ")",...
Return args as a list of strings
[ "Return", "args", "as", "a", "list", "of", "strings" ]
python
train
gem/oq-engine
openquake/baselib/general.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/general.py#L1131-L1138
def warn(msg, *args): """ Print a warning on stderr """ if not args: sys.stderr.write('WARNING: ' + msg) else: sys.stderr.write('WARNING: ' + msg % args)
[ "def", "warn", "(", "msg", ",", "*", "args", ")", ":", "if", "not", "args", ":", "sys", ".", "stderr", ".", "write", "(", "'WARNING: '", "+", "msg", ")", "else", ":", "sys", ".", "stderr", ".", "write", "(", "'WARNING: '", "+", "msg", "%", "args"...
Print a warning on stderr
[ "Print", "a", "warning", "on", "stderr" ]
python
train
bitesofcode/projex
projex/cli.py
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/cli.py#L91-L99
def usage(self): """ Returns the usage string for this method. :return <str> """ arg_list = ' '.join(self.cmd_args).upper() name = self.interface.name() return '%s [options] %s %s' % (name, self.__name__, arg_list)
[ "def", "usage", "(", "self", ")", ":", "arg_list", "=", "' '", ".", "join", "(", "self", ".", "cmd_args", ")", ".", "upper", "(", ")", "name", "=", "self", ".", "interface", ".", "name", "(", ")", "return", "'%s [options] %s %s'", "%", "(", "name", ...
Returns the usage string for this method. :return <str>
[ "Returns", "the", "usage", "string", "for", "this", "method", ".", ":", "return", "<str", ">" ]
python
train
zerotk/easyfs
zerotk/easyfs/_easyfs.py
https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1782-L1797
def ExpandUser(path): ''' os.path.expanduser wrapper, necessary because it cannot handle unicode strings properly. This is not necessary in Python 3. :param path: .. seealso:: os.path.expanduser ''' if six.PY2: encoding = sys.getfilesystemencoding() path = path.encode(e...
[ "def", "ExpandUser", "(", "path", ")", ":", "if", "six", ".", "PY2", ":", "encoding", "=", "sys", ".", "getfilesystemencoding", "(", ")", "path", "=", "path", ".", "encode", "(", "encoding", ")", "result", "=", "os", ".", "path", ".", "expanduser", "...
os.path.expanduser wrapper, necessary because it cannot handle unicode strings properly. This is not necessary in Python 3. :param path: .. seealso:: os.path.expanduser
[ "os", ".", "path", ".", "expanduser", "wrapper", "necessary", "because", "it", "cannot", "handle", "unicode", "strings", "properly", "." ]
python
valid
cloud9ers/gurumate
environment/share/doc/ipython/examples/parallel/workflow/wmanager.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/share/doc/ipython/examples/parallel/workflow/wmanager.py#L15-L29
def cleanup(controller, engines): """Cleanup routine to shut down all subprocesses we opened.""" import signal, time print('Starting cleanup') print('Stopping engines...') for e in engines: e.send_signal(signal.SIGINT) print('Stopping controller...') # so it can shut down its qu...
[ "def", "cleanup", "(", "controller", ",", "engines", ")", ":", "import", "signal", ",", "time", "print", "(", "'Starting cleanup'", ")", "print", "(", "'Stopping engines...'", ")", "for", "e", "in", "engines", ":", "e", ".", "send_signal", "(", "signal", "...
Cleanup routine to shut down all subprocesses we opened.
[ "Cleanup", "routine", "to", "shut", "down", "all", "subprocesses", "we", "opened", "." ]
python
test
thespacedoctor/polyglot
polyglot/ebook.py
https://github.com/thespacedoctor/polyglot/blob/98038d746aa67e343b73b3ccee1e02d31dab81ec/polyglot/ebook.py#L246-L282
def _tmp_html_file( self, content): """*create a tmp html file with some content used for the header or footer of the ebook* **Key Arguments:** - ``content`` -- the content to include in the HTML file. """ self.log.debug('starting the ``_tmp_html_file...
[ "def", "_tmp_html_file", "(", "self", ",", "content", ")", ":", "self", ".", "log", ".", "debug", "(", "'starting the ``_tmp_html_file`` method'", ")", "content", "=", "\"\"\"\n\n<hr>\n<div style=\"text-align: center\">\n%(content)s\n</div>\n<hr>\n\n\"\"\"", "%", "locals", ...
*create a tmp html file with some content used for the header or footer of the ebook* **Key Arguments:** - ``content`` -- the content to include in the HTML file.
[ "*", "create", "a", "tmp", "html", "file", "with", "some", "content", "used", "for", "the", "header", "or", "footer", "of", "the", "ebook", "*" ]
python
train
gawel/panoramisk
panoramisk/fast_agi.py
https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/fast_agi.py#L108-L130
def del_route(self, path): """Delete a route for FastAGI requests: :param path: URI to answer. Ex: 'calls/start' :type path: String :Example: :: @asyncio.coroutine def start(request): print('Receive a FastAGI request') p...
[ "def", "del_route", "(", "self", ",", "path", ")", ":", "if", "path", "not", "in", "self", ".", "_route", ":", "raise", "ValueError", "(", "'This route doesn\\'t exist.'", ")", "del", "(", "self", ".", "_route", "[", "path", "]", ")" ]
Delete a route for FastAGI requests: :param path: URI to answer. Ex: 'calls/start' :type path: String :Example: :: @asyncio.coroutine def start(request): print('Receive a FastAGI request') print(['AGI variables:', request.header...
[ "Delete", "a", "route", "for", "FastAGI", "requests", ":" ]
python
test
pmacosta/peng
peng/touchstone.py
https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/peng/touchstone.py#L79-L278
def read_touchstone(fname): r""" Read a `Touchstone <https://ibis.org/connector/touchstone_spec11.pdf>`_ file. According to the specification a data line can have at most values for four complex parameters (plus potentially the frequency point), however this function is able to process malformed fi...
[ "def", "read_touchstone", "(", "fname", ")", ":", "# pylint: disable=R0912,R0915,W0702", "# Exceptions definitions", "exnports", "=", "pexdoc", ".", "exh", ".", "addex", "(", "RuntimeError", ",", "\"File *[fname]* does not have a valid extension\"", ")", "exnoopt", "=", "...
r""" Read a `Touchstone <https://ibis.org/connector/touchstone_spec11.pdf>`_ file. According to the specification a data line can have at most values for four complex parameters (plus potentially the frequency point), however this function is able to process malformed files as long as they have the ...
[ "r", "Read", "a", "Touchstone", "<https", ":", "//", "ibis", ".", "org", "/", "connector", "/", "touchstone_spec11", ".", "pdf", ">", "_", "file", "." ]
python
test
bear/bearlib
bearlib/tools.py
https://github.com/bear/bearlib/blob/30f9b8ba4b7a8db4cd2f4c6e07966ae51d0a00dd/bearlib/tools.py#L22-L34
def baseDomain(domain, includeScheme=True): """Return only the network location portion of the given domain unless includeScheme is True """ result = '' url = urlparse(domain) if includeScheme: result = '%s://' % url.scheme if len(url.netloc) == 0: result += url.path e...
[ "def", "baseDomain", "(", "domain", ",", "includeScheme", "=", "True", ")", ":", "result", "=", "''", "url", "=", "urlparse", "(", "domain", ")", "if", "includeScheme", ":", "result", "=", "'%s://'", "%", "url", ".", "scheme", "if", "len", "(", "url", ...
Return only the network location portion of the given domain unless includeScheme is True
[ "Return", "only", "the", "network", "location", "portion", "of", "the", "given", "domain", "unless", "includeScheme", "is", "True" ]
python
train
goldmann/docker-squash
docker_squash/lib/xtarfile.py
https://github.com/goldmann/docker-squash/blob/89e0297942be268791aff2098b7ebfa50d82f8e8/docker_squash/lib/xtarfile.py#L20-L81
def _proc_pax(self, filetar): """Process an extended or global header as described in POSIX.1-2001.""" # Read the header information. buf = filetar.fileobj.read(self._block(self.size)) # A pax header stores supplemental information for either # the following file (extended) or all following files ...
[ "def", "_proc_pax", "(", "self", ",", "filetar", ")", ":", "# Read the header information.", "buf", "=", "filetar", ".", "fileobj", ".", "read", "(", "self", ".", "_block", "(", "self", ".", "size", ")", ")", "# A pax header stores supplemental information for eit...
Process an extended or global header as described in POSIX.1-2001.
[ "Process", "an", "extended", "or", "global", "header", "as", "described", "in", "POSIX", ".", "1", "-", "2001", "." ]
python
train
psss/did
did/plugins/bugzilla.py
https://github.com/psss/did/blob/04e4ee6f1aa14c0cae3ba9f9803871f3f98279cb/did/plugins/bugzilla.py#L81-L119
def search(self, query, options): """ Perform Bugzilla search """ query["query_format"] = "advanced" log.debug("Search query:") log.debug(pretty(query)) # Fetch bug info try: result = self.server.query(query) except xmlrpclib.Fault as error: ...
[ "def", "search", "(", "self", ",", "query", ",", "options", ")", ":", "query", "[", "\"query_format\"", "]", "=", "\"advanced\"", "log", ".", "debug", "(", "\"Search query:\"", ")", "log", ".", "debug", "(", "pretty", "(", "query", ")", ")", "# Fetch bug...
Perform Bugzilla search
[ "Perform", "Bugzilla", "search" ]
python
train
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L3182-L3205
def dskv02(handle, dladsc, start, room): """ Fetch vertices from a type 2 DSK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskv02_c.html :param handle: DSK file handle. :type handle: int :param dladsc: DLA descriptor. :type dladsc: spiceypy.utils.support_types.SpiceDLA...
[ "def", "dskv02", "(", "handle", ",", "dladsc", ",", "start", ",", "room", ")", ":", "handle", "=", "ctypes", ".", "c_int", "(", "handle", ")", "start", "=", "ctypes", ".", "c_int", "(", "start", ")", "room", "=", "ctypes", ".", "c_int", "(", "room"...
Fetch vertices from a type 2 DSK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskv02_c.html :param handle: DSK file handle. :type handle: int :param dladsc: DLA descriptor. :type dladsc: spiceypy.utils.support_types.SpiceDLADescr :param start: Start index. :type start:...
[ "Fetch", "vertices", "from", "a", "type", "2", "DSK", "segment", "." ]
python
train
PyCQA/astroid
astroid/node_classes.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/node_classes.py#L1597-L1614
def default_value(self, argname): """Get the default value for an argument. :param argname: The name of the argument to get the default value for. :type argname: str :raises NoDefault: If there is no default value defined for the given argument. """ i = _fin...
[ "def", "default_value", "(", "self", ",", "argname", ")", ":", "i", "=", "_find_arg", "(", "argname", ",", "self", ".", "args", ")", "[", "0", "]", "if", "i", "is", "not", "None", ":", "idx", "=", "i", "-", "(", "len", "(", "self", ".", "args",...
Get the default value for an argument. :param argname: The name of the argument to get the default value for. :type argname: str :raises NoDefault: If there is no default value defined for the given argument.
[ "Get", "the", "default", "value", "for", "an", "argument", "." ]
python
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/wix.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/wix.py#L39-L63
def generate(env): """Add Builders and construction variables for WiX to an Environment.""" if not exists(env): return env['WIXCANDLEFLAGS'] = ['-nologo'] env['WIXCANDLEINCLUDE'] = [] env['WIXCANDLECOM'] = '$WIXCANDLE $WIXCANDLEFLAGS -I $WIXCANDLEINCLUDE -o ${TARGET} ${SOURCE}' env['WIXL...
[ "def", "generate", "(", "env", ")", ":", "if", "not", "exists", "(", "env", ")", ":", "return", "env", "[", "'WIXCANDLEFLAGS'", "]", "=", "[", "'-nologo'", "]", "env", "[", "'WIXCANDLEINCLUDE'", "]", "=", "[", "]", "env", "[", "'WIXCANDLECOM'", "]", ...
Add Builders and construction variables for WiX to an Environment.
[ "Add", "Builders", "and", "construction", "variables", "for", "WiX", "to", "an", "Environment", "." ]
python
train
base4sistemas/satcfe
satcfe/clientelocal.py
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/clientelocal.py#L46-L54
def ativar_sat(self, tipo_certificado, cnpj, codigo_uf): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.ativar_sat`. :return: Uma resposta SAT especilizada em ``AtivarSAT``. :rtype: satcfe.resposta.ativarsat.RespostaAtivarSAT """ retorno = super(ClienteSATLocal, self).ativar_sat( ...
[ "def", "ativar_sat", "(", "self", ",", "tipo_certificado", ",", "cnpj", ",", "codigo_uf", ")", ":", "retorno", "=", "super", "(", "ClienteSATLocal", ",", "self", ")", ".", "ativar_sat", "(", "tipo_certificado", ",", "cnpj", ",", "codigo_uf", ")", "return", ...
Sobrepõe :meth:`~satcfe.base.FuncoesSAT.ativar_sat`. :return: Uma resposta SAT especilizada em ``AtivarSAT``. :rtype: satcfe.resposta.ativarsat.RespostaAtivarSAT
[ "Sobrepõe", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "ativar_sat", "." ]
python
train
supercoderz/pyflightdata
pyflightdata/flightdata.py
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L118-L133
def get_airports(self, country): """Returns a list of all the airports For a given country this returns a list of dicts, one for each airport, with information like the iata code of the airport etc Args: country (str): The country for which the airports will be fetched Exam...
[ "def", "get_airports", "(", "self", ",", "country", ")", ":", "url", "=", "AIRPORT_BASE", ".", "format", "(", "country", ".", "replace", "(", "\" \"", ",", "\"-\"", ")", ")", "return", "self", ".", "_fr24", ".", "get_airports_data", "(", "url", ")" ]
Returns a list of all the airports For a given country this returns a list of dicts, one for each airport, with information like the iata code of the airport etc Args: country (str): The country for which the airports will be fetched Example:: from pyflightdata import ...
[ "Returns", "a", "list", "of", "all", "the", "airports", "For", "a", "given", "country", "this", "returns", "a", "list", "of", "dicts", "one", "for", "each", "airport", "with", "information", "like", "the", "iata", "code", "of", "the", "airport", "etc" ]
python
train
mdgoldberg/sportsref
sportsref/nfl/boxscores.py
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L401-L418
def snap_counts(self): """Gets the snap counts for both teams' players and returns them in a DataFrame. Note: only goes back to 2012. :returns: DataFrame of snap count data """ # TODO: combine duplicate players, see 201312150mia - ThomDa03 doc = self.get_doc() ta...
[ "def", "snap_counts", "(", "self", ")", ":", "# TODO: combine duplicate players, see 201312150mia - ThomDa03", "doc", "=", "self", ".", "get_doc", "(", ")", "table_ids", "=", "(", "'vis_snap_counts'", ",", "'home_snap_counts'", ")", "tms", "=", "(", "self", ".", "...
Gets the snap counts for both teams' players and returns them in a DataFrame. Note: only goes back to 2012. :returns: DataFrame of snap count data
[ "Gets", "the", "snap", "counts", "for", "both", "teams", "players", "and", "returns", "them", "in", "a", "DataFrame", ".", "Note", ":", "only", "goes", "back", "to", "2012", "." ]
python
test
swarmer/fridge
fridge.py
https://github.com/swarmer/fridge/blob/fcf6481307ce268c40c22f5e0062d01334f6cd95/fridge.py#L107-L116
def save(self): """ Force saving the dictionary to the file. All data in the file is discarded. This method is called automatically by :meth:`close`. """ self._check_open() self.file.truncate(0) self.file.seek(0) json.dump(self, self.file, **self.d...
[ "def", "save", "(", "self", ")", ":", "self", ".", "_check_open", "(", ")", "self", ".", "file", ".", "truncate", "(", "0", ")", "self", ".", "file", ".", "seek", "(", "0", ")", "json", ".", "dump", "(", "self", ",", "self", ".", "file", ",", ...
Force saving the dictionary to the file. All data in the file is discarded. This method is called automatically by :meth:`close`.
[ "Force", "saving", "the", "dictionary", "to", "the", "file", ".", "All", "data", "in", "the", "file", "is", "discarded", ".", "This", "method", "is", "called", "automatically", "by", ":", "meth", ":", "close", "." ]
python
test
ecederstrand/exchangelib
exchangelib/util.py
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L552-L682
def post_ratelimited(protocol, session, url, headers, data, allow_redirects=False, stream=False): """ There are two error-handling policies implemented here: a fail-fast policy intended for stand-alone scripts which fails on all responses except HTTP 200. The other policy is intended for long-running tasks ...
[ "def", "post_ratelimited", "(", "protocol", ",", "session", ",", "url", ",", "headers", ",", "data", ",", "allow_redirects", "=", "False", ",", "stream", "=", "False", ")", ":", "thread_id", "=", "get_ident", "(", ")", "wait", "=", "10", "# seconds", "re...
There are two error-handling policies implemented here: a fail-fast policy intended for stand-alone scripts which fails on all responses except HTTP 200. The other policy is intended for long-running tasks that need to respect rate-limiting errors from the server and paper over outages of up to 1 hour. Wra...
[ "There", "are", "two", "error", "-", "handling", "policies", "implemented", "here", ":", "a", "fail", "-", "fast", "policy", "intended", "for", "stand", "-", "alone", "scripts", "which", "fails", "on", "all", "responses", "except", "HTTP", "200", ".", "The...
python
train
satellogic/telluric
telluric/collections.py
https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L386-L396
def validate(self): """ if schema exists we run shape file validation code of fiona by trying to save to in MemoryFile """ if self._schema is not None: with MemoryFile() as memfile: with memfile.open(driver="ESRI Shapefile", schema=self.schema) as target: ...
[ "def", "validate", "(", "self", ")", ":", "if", "self", ".", "_schema", "is", "not", "None", ":", "with", "MemoryFile", "(", ")", "as", "memfile", ":", "with", "memfile", ".", "open", "(", "driver", "=", "\"ESRI Shapefile\"", ",", "schema", "=", "self"...
if schema exists we run shape file validation code of fiona by trying to save to in MemoryFile
[ "if", "schema", "exists", "we", "run", "shape", "file", "validation", "code", "of", "fiona", "by", "trying", "to", "save", "to", "in", "MemoryFile" ]
python
train
cokelaer/spectrum
src/spectrum/linear_prediction.py
https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/linear_prediction.py#L134-L146
def rc2ac(k, R0): """Convert reflection coefficients to autocorrelation sequence. :param k: reflection coefficients :param R0: zero-lag autocorrelation :returns: the autocorrelation sequence .. seealso:: :func:`ac2rc`, :func:`poly2rc`, :func:`ac2poly`, :func:`poly2rc`, :func:`rc2poly`. """ ...
[ "def", "rc2ac", "(", "k", ",", "R0", ")", ":", "[", "a", ",", "efinal", "]", "=", "rc2poly", "(", "k", ",", "R0", ")", "R", ",", "u", ",", "kr", ",", "e", "=", "rlevinson", "(", "a", ",", "efinal", ")", "return", "R" ]
Convert reflection coefficients to autocorrelation sequence. :param k: reflection coefficients :param R0: zero-lag autocorrelation :returns: the autocorrelation sequence .. seealso:: :func:`ac2rc`, :func:`poly2rc`, :func:`ac2poly`, :func:`poly2rc`, :func:`rc2poly`.
[ "Convert", "reflection", "coefficients", "to", "autocorrelation", "sequence", "." ]
python
valid
SKA-ScienceDataProcessor/integration-prototype
sip/science_pipeline_workflows/example_imager_mpi/example_mpi_imager.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/example_imager_mpi/example_mpi_imager.py#L130-L248
def main(): """Runs test imaging pipeline using MPI.""" # Check command line arguments. if len(sys.argv) < 2: raise RuntimeError( 'Usage: mpiexec -n <np> ' 'python mpi_imager_test.py <settings_file> <dir>') # Get the MPI communicator and initialise broadcast variables. ...
[ "def", "main", "(", ")", ":", "# Check command line arguments.", "if", "len", "(", "sys", ".", "argv", ")", "<", "2", ":", "raise", "RuntimeError", "(", "'Usage: mpiexec -n <np> '", "'python mpi_imager_test.py <settings_file> <dir>'", ")", "# Get the MPI communicator and ...
Runs test imaging pipeline using MPI.
[ "Runs", "test", "imaging", "pipeline", "using", "MPI", "." ]
python
train
tanghaibao/goatools
goatools/gosubdag/plot/plot.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/plot.py#L55-L60
def plt_goids(gosubdag, fout_img, goids, **kws_plt): """Plot GO IDs in a DAG (Directed Acyclic Graph).""" gosubdag_plt = GoSubDag(goids, gosubdag.go2obj, rcntobj=gosubdag.rcntobj, **kws_plt) godagplot = GoSubDagPlot(gosubdag_plt, **kws_plt) godagplot.plt_dag(fout_img) return godagplot
[ "def", "plt_goids", "(", "gosubdag", ",", "fout_img", ",", "goids", ",", "*", "*", "kws_plt", ")", ":", "gosubdag_plt", "=", "GoSubDag", "(", "goids", ",", "gosubdag", ".", "go2obj", ",", "rcntobj", "=", "gosubdag", ".", "rcntobj", ",", "*", "*", "kws_...
Plot GO IDs in a DAG (Directed Acyclic Graph).
[ "Plot", "GO", "IDs", "in", "a", "DAG", "(", "Directed", "Acyclic", "Graph", ")", "." ]
python
train