repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
Erotemic/utool
utool/_internal/util_importer.py
__get_from_imports
def __get_from_imports(import_tuples): """ Returns import names and fromlist import_tuples are specified as (name, fromlist, ispackage) """ from_imports = [(tup[0], tup[1]) for tup in import_tuples if tup[1] is not None and len(tup[1]) > 0] return from_imports
python
def __get_from_imports(import_tuples): """ Returns import names and fromlist import_tuples are specified as (name, fromlist, ispackage) """ from_imports = [(tup[0], tup[1]) for tup in import_tuples if tup[1] is not None and len(tup[1]) > 0] return from_imports
[ "def", "__get_from_imports", "(", "import_tuples", ")", ":", "from_imports", "=", "[", "(", "tup", "[", "0", "]", ",", "tup", "[", "1", "]", ")", "for", "tup", "in", "import_tuples", "if", "tup", "[", "1", "]", "is", "not", "None", "and", "len", "(...
Returns import names and fromlist import_tuples are specified as (name, fromlist, ispackage)
[ "Returns", "import", "names", "and", "fromlist", "import_tuples", "are", "specified", "as", "(", "name", "fromlist", "ispackage", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L139-L146
train
Returns import names and fromlist import_tuples are specified as
Erotemic/utool
utool/_internal/util_importer.py
_initstr
def _initstr(modname, imports, from_imports, inject_execstr, withheader=True): """ Calls the other string makers """ header = _make_module_header() if withheader else '' import_str = _make_imports_str(imports, modname) fromimport_str = _make_fromimport_str(from_imports, modname) initstr ...
python
def _initstr(modname, imports, from_imports, inject_execstr, withheader=True): """ Calls the other string makers """ header = _make_module_header() if withheader else '' import_str = _make_imports_str(imports, modname) fromimport_str = _make_fromimport_str(from_imports, modname) initstr ...
[ "def", "_initstr", "(", "modname", ",", "imports", ",", "from_imports", ",", "inject_execstr", ",", "withheader", "=", "True", ")", ":", "header", "=", "_make_module_header", "(", ")", "if", "withheader", "else", "''", "import_str", "=", "_make_imports_str", "...
Calls the other string makers
[ "Calls", "the", "other", "string", "makers" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L152-L163
train
Returns the string to be used in the init string of a new module.
Erotemic/utool
utool/_internal/util_importer.py
_inject_execstr
def _inject_execstr(modname, import_tuples): """ Injection and Reload String Defs """ if modname == 'utool': # Special case import of the util_inject module injecter = 'util_inject' injecter_import = '' else: # Normal case implicit import of util_inject injecter_impor...
python
def _inject_execstr(modname, import_tuples): """ Injection and Reload String Defs """ if modname == 'utool': # Special case import of the util_inject module injecter = 'util_inject' injecter_import = '' else: # Normal case implicit import of util_inject injecter_impor...
[ "def", "_inject_execstr", "(", "modname", ",", "import_tuples", ")", ":", "if", "modname", "==", "'utool'", ":", "# Special case import of the util_inject module", "injecter", "=", "'util_inject'", "injecter_import", "=", "''", "else", ":", "# Normal case implicit import ...
Injection and Reload String Defs
[ "Injection", "and", "Reload", "String", "Defs" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L196-L288
train
A function that returns the string that can be used to inject and reload strings in the module.
Erotemic/utool
utool/_internal/util_importer.py
dynamic_import
def dynamic_import(modname, import_tuples, developing=True, ignore_froms=[], dump=False, ignore_startswith=[], ignore_endswith=[], ignore_list=[], check_not_imported=True, return_initstr=False, verbose=False): """ MAIN ENTRY POINT Dynamically import ...
python
def dynamic_import(modname, import_tuples, developing=True, ignore_froms=[], dump=False, ignore_startswith=[], ignore_endswith=[], ignore_list=[], check_not_imported=True, return_initstr=False, verbose=False): """ MAIN ENTRY POINT Dynamically import ...
[ "def", "dynamic_import", "(", "modname", ",", "import_tuples", ",", "developing", "=", "True", ",", "ignore_froms", "=", "[", "]", ",", "dump", "=", "False", ",", "ignore_startswith", "=", "[", "]", ",", "ignore_endswith", "=", "[", "]", ",", "ignore_list"...
MAIN ENTRY POINT Dynamically import listed util libraries and their attributes. Create reload_subs function. Using __import__ like this is typically not considered good style However, it is better than import * and this will generate the good file text that can be used when the module is 'frozen" ...
[ "MAIN", "ENTRY", "POINT" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L294-L407
train
Dynamically imports the specified util libraries and attributes into the current object.
Erotemic/utool
utool/_internal/util_importer.py
make_initstr
def make_initstr(modname, import_tuples, verbose=False): """ Just creates the string representation. Does no importing. """ imports = [tup[0] for tup in import_tuples] from_imports = __get_from_imports(import_tuples) inject_execstr = _inject_execstr(modname, import_tuples) return _initstr(mo...
python
def make_initstr(modname, import_tuples, verbose=False): """ Just creates the string representation. Does no importing. """ imports = [tup[0] for tup in import_tuples] from_imports = __get_from_imports(import_tuples) inject_execstr = _inject_execstr(modname, import_tuples) return _initstr(mo...
[ "def", "make_initstr", "(", "modname", ",", "import_tuples", ",", "verbose", "=", "False", ")", ":", "imports", "=", "[", "tup", "[", "0", "]", "for", "tup", "in", "import_tuples", "]", "from_imports", "=", "__get_from_imports", "(", "import_tuples", ")", ...
Just creates the string representation. Does no importing.
[ "Just", "creates", "the", "string", "representation", ".", "Does", "no", "importing", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L410-L417
train
Creates the string representation of a module.
Erotemic/utool
utool/_internal/util_importer.py
make_import_tuples
def make_import_tuples(module_path, exclude_modnames=[]): """ Infer the import_tuples from a module_path """ from utool import util_path kwargs = dict(private=False, full=False) module_list = util_path.ls_modulefiles(module_path, noext=True, **kwargs) package_list = util_path.ls_moduledirs(module_p...
python
def make_import_tuples(module_path, exclude_modnames=[]): """ Infer the import_tuples from a module_path """ from utool import util_path kwargs = dict(private=False, full=False) module_list = util_path.ls_modulefiles(module_path, noext=True, **kwargs) package_list = util_path.ls_moduledirs(module_p...
[ "def", "make_import_tuples", "(", "module_path", ",", "exclude_modnames", "=", "[", "]", ")", ":", "from", "utool", "import", "util_path", "kwargs", "=", "dict", "(", "private", "=", "False", ",", "full", "=", "False", ")", "module_list", "=", "util_path", ...
Infer the import_tuples from a module_path
[ "Infer", "the", "import_tuples", "from", "a", "module_path" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L420-L432
train
Infer the import_tuples from a module_path
Erotemic/utool
utool/_internal/meta_util_cplat.py
get_resource_dir
def get_resource_dir(): """ Returns a directory which should be writable for any application """ #resource_prefix = '~' if WIN32: dpath_ = '~/AppData/Roaming' elif LINUX: dpath_ = '~/.config' elif DARWIN: dpath_ = '~/Library/Application Support' else: rai...
python
def get_resource_dir(): """ Returns a directory which should be writable for any application """ #resource_prefix = '~' if WIN32: dpath_ = '~/AppData/Roaming' elif LINUX: dpath_ = '~/.config' elif DARWIN: dpath_ = '~/Library/Application Support' else: rai...
[ "def", "get_resource_dir", "(", ")", ":", "#resource_prefix = '~'", "if", "WIN32", ":", "dpath_", "=", "'~/AppData/Roaming'", "elif", "LINUX", ":", "dpath_", "=", "'~/.config'", "elif", "DARWIN", ":", "dpath_", "=", "'~/Library/Application Support'", "else", ":", ...
Returns a directory which should be writable for any application
[ "Returns", "a", "directory", "which", "should", "be", "writable", "for", "any", "application" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/meta_util_cplat.py#L16-L30
train
Returns a directory which should be writable for any application
neithere/monk
monk/modeling.py
StructuredDictMixin._insert_defaults
def _insert_defaults(self): """ Inserts default values from :attr:`StructuredDictMixin.structure` to `self` by merging the two structures (see :func:`monk.manipulation.merge_defaults`). """ merged = merge_defaults(self.structure, self) self.update(merged)
python
def _insert_defaults(self): """ Inserts default values from :attr:`StructuredDictMixin.structure` to `self` by merging the two structures (see :func:`monk.manipulation.merge_defaults`). """ merged = merge_defaults(self.structure, self) self.update(merged)
[ "def", "_insert_defaults", "(", "self", ")", ":", "merged", "=", "merge_defaults", "(", "self", ".", "structure", ",", "self", ")", "self", ".", "update", "(", "merged", ")" ]
Inserts default values from :attr:`StructuredDictMixin.structure` to `self` by merging the two structures (see :func:`monk.manipulation.merge_defaults`).
[ "Inserts", "default", "values", "from", ":", "attr", ":", "StructuredDictMixin", ".", "structure", "to", "self", "by", "merging", "the", "two", "structures", "(", "see", ":", "func", ":", "monk", ".", "manipulation", ".", "merge_defaults", ")", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/modeling.py#L127-L133
train
Inserts default values from StructuredDictMixin. structure to self.
Erotemic/utool
utool/util_io.py
load_data
def load_data(fpath, **kwargs): """ More generic interface to load data """ ext = splitext(fpath)[1] if ext in ['.pickle', '.cPkl', '.pkl']: return load_cPkl(fpath, **kwargs) elif ext in ['.json']: return load_json(fpath, **kwargs) elif ext in ['.hdf5']: return load_hdf5(fpat...
python
def load_data(fpath, **kwargs): """ More generic interface to load data """ ext = splitext(fpath)[1] if ext in ['.pickle', '.cPkl', '.pkl']: return load_cPkl(fpath, **kwargs) elif ext in ['.json']: return load_json(fpath, **kwargs) elif ext in ['.hdf5']: return load_hdf5(fpat...
[ "def", "load_data", "(", "fpath", ",", "*", "*", "kwargs", ")", ":", "ext", "=", "splitext", "(", "fpath", ")", "[", "1", "]", "if", "ext", "in", "[", "'.pickle'", ",", "'.cPkl'", ",", "'.pkl'", "]", ":", "return", "load_cPkl", "(", "fpath", ",", ...
More generic interface to load data
[ "More", "generic", "interface", "to", "load", "data" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_io.py#L32-L46
train
Load data from file.
Erotemic/utool
utool/util_io.py
save_data
def save_data(fpath, data, **kwargs): """ More generic interface to write data """ ext = splitext(fpath)[1] if ext in ['.pickle', '.cPkl', '.pkl']: return save_cPkl(fpath, data, **kwargs) elif ext in ['.json']: return save_json(fpath, data, **kwargs) elif ext in ['.hdf5']: re...
python
def save_data(fpath, data, **kwargs): """ More generic interface to write data """ ext = splitext(fpath)[1] if ext in ['.pickle', '.cPkl', '.pkl']: return save_cPkl(fpath, data, **kwargs) elif ext in ['.json']: return save_json(fpath, data, **kwargs) elif ext in ['.hdf5']: re...
[ "def", "save_data", "(", "fpath", ",", "data", ",", "*", "*", "kwargs", ")", ":", "ext", "=", "splitext", "(", "fpath", ")", "[", "1", "]", "if", "ext", "in", "[", "'.pickle'", ",", "'.cPkl'", ",", "'.pkl'", "]", ":", "return", "save_cPkl", "(", ...
More generic interface to write data
[ "More", "generic", "interface", "to", "write", "data" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_io.py#L49-L63
train
More generic interface to write data
Erotemic/utool
utool/util_io.py
write_to
def write_to(fpath, to_write, aslines=False, verbose=None, onlyifdiff=False, mode='w', n=None): """ Writes text to a file. Automatically encodes text as utf8. Args: fpath (str): file path to_write (str): text to write (must be unicode text) aslines (bool): if True to_write ...
python
def write_to(fpath, to_write, aslines=False, verbose=None, onlyifdiff=False, mode='w', n=None): """ Writes text to a file. Automatically encodes text as utf8. Args: fpath (str): file path to_write (str): text to write (must be unicode text) aslines (bool): if True to_write ...
[ "def", "write_to", "(", "fpath", ",", "to_write", ",", "aslines", "=", "False", ",", "verbose", "=", "None", ",", "onlyifdiff", "=", "False", ",", "mode", "=", "'w'", ",", "n", "=", "None", ")", ":", "if", "onlyifdiff", ":", "import", "utool", "as", ...
Writes text to a file. Automatically encodes text as utf8. Args: fpath (str): file path to_write (str): text to write (must be unicode text) aslines (bool): if True to_write is assumed to be a list of lines verbose (bool): verbosity flag onlyifdiff (bool): only writes if nee...
[ "Writes", "text", "to", "a", "file", ".", "Automatically", "encodes", "text", "as", "utf8", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_io.py#L82-L161
train
Writes text to a file. Automatically encodes text as utf8.
Erotemic/utool
utool/util_io.py
read_from
def read_from(fpath, verbose=None, aslines=False, strict=True, n=None, errors='replace'): r""" Reads text from a file. Automatically returns utf8. Args: fpath (str): file path aslines (bool): if True returns list of lines verbose (bool): verbosity flag Returns: str: text fr...
python
def read_from(fpath, verbose=None, aslines=False, strict=True, n=None, errors='replace'): r""" Reads text from a file. Automatically returns utf8. Args: fpath (str): file path aslines (bool): if True returns list of lines verbose (bool): verbosity flag Returns: str: text fr...
[ "def", "read_from", "(", "fpath", ",", "verbose", "=", "None", ",", "aslines", "=", "False", ",", "strict", "=", "True", ",", "n", "=", "None", ",", "errors", "=", "'replace'", ")", ":", "if", "n", "is", "None", ":", "n", "=", "__READ_TAIL_N__", "v...
r""" Reads text from a file. Automatically returns utf8. Args: fpath (str): file path aslines (bool): if True returns list of lines verbose (bool): verbosity flag Returns: str: text from fpath (this is unicode) Ignore: x = b'''/whaleshark_003_fors\xc3\xb8g.wmv" />\...
[ "r", "Reads", "text", "from", "a", "file", ".", "Automatically", "returns", "utf8", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_io.py#L164-L216
train
r Reads text from a file. Automatically returns utf8.
Erotemic/utool
utool/util_io.py
save_cPkl
def save_cPkl(fpath, data, verbose=None, n=None): """ Saves data to a pickled file with optional verbosity """ verbose = _rectify_verb_write(verbose) if verbose: print('[util_io] * save_cPkl(%r, data)' % (util_path.tail(fpath, n=n),)) with open(fpath, 'wb') as file_: # Use protocol 2 to ...
python
def save_cPkl(fpath, data, verbose=None, n=None): """ Saves data to a pickled file with optional verbosity """ verbose = _rectify_verb_write(verbose) if verbose: print('[util_io] * save_cPkl(%r, data)' % (util_path.tail(fpath, n=n),)) with open(fpath, 'wb') as file_: # Use protocol 2 to ...
[ "def", "save_cPkl", "(", "fpath", ",", "data", ",", "verbose", "=", "None", ",", "n", "=", "None", ")", ":", "verbose", "=", "_rectify_verb_write", "(", "verbose", ")", "if", "verbose", ":", "print", "(", "'[util_io] * save_cPkl(%r, data)'", "%", "(", "uti...
Saves data to a pickled file with optional verbosity
[ "Saves", "data", "to", "a", "pickled", "file", "with", "optional", "verbosity" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_io.py#L249-L256
train
Save data to a pickled file.
Erotemic/utool
utool/util_io.py
load_cPkl
def load_cPkl(fpath, verbose=None, n=None): """ Loads a pickled file with optional verbosity. Aims for compatibility between python2 and python3. TestPickleExtentsSimple: >>> def makedata_simple(): >>> data = np.empty((500, 2 ** 20), dtype=np.uint8) + 1 >>> return data ...
python
def load_cPkl(fpath, verbose=None, n=None): """ Loads a pickled file with optional verbosity. Aims for compatibility between python2 and python3. TestPickleExtentsSimple: >>> def makedata_simple(): >>> data = np.empty((500, 2 ** 20), dtype=np.uint8) + 1 >>> return data ...
[ "def", "load_cPkl", "(", "fpath", ",", "verbose", "=", "None", ",", "n", "=", "None", ")", ":", "verbose", "=", "_rectify_verb_read", "(", "verbose", ")", "if", "verbose", ":", "print", "(", "'[util_io] * load_cPkl(%r)'", "%", "(", "util_path", ".", "tail"...
Loads a pickled file with optional verbosity. Aims for compatibility between python2 and python3. TestPickleExtentsSimple: >>> def makedata_simple(): >>> data = np.empty((500, 2 ** 20), dtype=np.uint8) + 1 >>> return data >>> memtrack = ut.MemoryTracker() >>> # ...
[ "Loads", "a", "pickled", "file", "with", "optional", "verbosity", ".", "Aims", "for", "compatibility", "between", "python2", "and", "python3", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_io.py#L259-L354
train
Load a pickled file with optional verbosity.
Erotemic/utool
utool/util_io.py
_python2_load_cpkl
def _python2_load_cpkl(fpath): """ References: https://stackoverflow.com/questions/41720952/unpickle-sklearn-tree-descisiontreeregressor-in-python-2-from-python3 """ from lib2to3.fixes.fix_imports import MAPPING import sys import pickle # MAPPING maps Python 2 names to Python 3 name...
python
def _python2_load_cpkl(fpath): """ References: https://stackoverflow.com/questions/41720952/unpickle-sklearn-tree-descisiontreeregressor-in-python-2-from-python3 """ from lib2to3.fixes.fix_imports import MAPPING import sys import pickle # MAPPING maps Python 2 names to Python 3 name...
[ "def", "_python2_load_cpkl", "(", "fpath", ")", ":", "from", "lib2to3", ".", "fixes", ".", "fix_imports", "import", "MAPPING", "import", "sys", "import", "pickle", "# MAPPING maps Python 2 names to Python 3 names. We want this in reverse.", "REVERSE_MAPPING", "=", "{", "}...
References: https://stackoverflow.com/questions/41720952/unpickle-sklearn-tree-descisiontreeregressor-in-python-2-from-python3
[ "References", ":", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "41720952", "/", "unpickle", "-", "sklearn", "-", "tree", "-", "descisiontreeregressor", "-", "in", "-", "python", "-", "2", "-", "from", "-", "python3" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_io.py#L357-L385
train
Load a C ++ file from Python 2 and Python 3.
Erotemic/utool
utool/util_io.py
save_hdf5
def save_hdf5(fpath, data, verbose=None, compression='lzf'): r""" Restricted save of data using hdf5. Can only save ndarrays and dicts of ndarrays. Args: fpath (str): data (ndarray): compression (str): DEFLATE/GZIP - standard LZF - fast SHUFF...
python
def save_hdf5(fpath, data, verbose=None, compression='lzf'): r""" Restricted save of data using hdf5. Can only save ndarrays and dicts of ndarrays. Args: fpath (str): data (ndarray): compression (str): DEFLATE/GZIP - standard LZF - fast SHUFF...
[ "def", "save_hdf5", "(", "fpath", ",", "data", ",", "verbose", "=", "None", ",", "compression", "=", "'lzf'", ")", ":", "import", "h5py", "verbose", "=", "_rectify_verb_write", "(", "verbose", ")", "if", "verbose", ":", "print", "(", "'[util_io] * save_hdf5(...
r""" Restricted save of data using hdf5. Can only save ndarrays and dicts of ndarrays. Args: fpath (str): data (ndarray): compression (str): DEFLATE/GZIP - standard LZF - fast SHUFFLE - compression ratio FLETCHER32 - error detection ...
[ "r", "Restricted", "save", "of", "data", "using", "hdf5", ".", "Can", "only", "save", "ndarrays", "and", "dicts", "of", "ndarrays", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_io.py#L398-L612
train
r Save a set of data using hdf5.
Erotemic/utool
utool/util_io.py
save_pytables
def save_pytables(fpath, data, verbose=False): """ sudo pip install numexpr sudo pip install tables References: https://pytables.github.io/cookbook/py2exe_howto.html https://gist.github.com/andrewgiessel/7515520 http://stackoverflow.com/questions/8843062/python-how-to-store-a-nu...
python
def save_pytables(fpath, data, verbose=False): """ sudo pip install numexpr sudo pip install tables References: https://pytables.github.io/cookbook/py2exe_howto.html https://gist.github.com/andrewgiessel/7515520 http://stackoverflow.com/questions/8843062/python-how-to-store-a-nu...
[ "def", "save_pytables", "(", "fpath", ",", "data", ",", "verbose", "=", "False", ")", ":", "import", "tables", "#from os.path import basename", "#fname = basename(fpath)", "#shape = data.shape", "#dtype = data.dtype", "#file_ = tables.open_file(fpath)", "verbose", "=", "_re...
sudo pip install numexpr sudo pip install tables References: https://pytables.github.io/cookbook/py2exe_howto.html https://gist.github.com/andrewgiessel/7515520 http://stackoverflow.com/questions/8843062/python-how-to-store-a-numpy-multidimensional-array-in-pytables http://pytab...
[ "sudo", "pip", "install", "numexpr", "sudo", "pip", "install", "tables" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_io.py#L648-L693
train
Save a numpy array to a HDF5 file.
Erotemic/utool
utool/util_web.py
is_local_port_open
def is_local_port_open(port): """ Args: port (int): Returns: bool: References: http://stackoverflow.com/questions/7436801/identifying-listening-ports-using-python CommandLine: python -m utool.util_web is_local_port_open --show Example: >>> # DISABLE_DO...
python
def is_local_port_open(port): """ Args: port (int): Returns: bool: References: http://stackoverflow.com/questions/7436801/identifying-listening-ports-using-python CommandLine: python -m utool.util_web is_local_port_open --show Example: >>> # DISABLE_DO...
[ "def", "is_local_port_open", "(", "port", ")", ":", "import", "socket", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "result", "=", "s", ".", "connect_ex", "(", "(", "'127.0.0.1'", ",", "port",...
Args: port (int): Returns: bool: References: http://stackoverflow.com/questions/7436801/identifying-listening-ports-using-python CommandLine: python -m utool.util_web is_local_port_open --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_web impo...
[ "Args", ":", "port", "(", "int", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_web.py#L7-L32
train
Check if a local port is open
Erotemic/utool
utool/util_web.py
start_simple_webserver
def start_simple_webserver(domain=None, port=5832): r""" simple webserver that echos its arguments Args: domain (None): (default = None) port (int): (default = 5832) CommandLine: python -m utool.util_web --exec-start_simple_webserver:0 python -m utool.util_web --exec-st...
python
def start_simple_webserver(domain=None, port=5832): r""" simple webserver that echos its arguments Args: domain (None): (default = None) port (int): (default = 5832) CommandLine: python -m utool.util_web --exec-start_simple_webserver:0 python -m utool.util_web --exec-st...
[ "def", "start_simple_webserver", "(", "domain", "=", "None", ",", "port", "=", "5832", ")", ":", "import", "tornado", ".", "ioloop", "import", "tornado", ".", "web", "import", "tornado", ".", "httpserver", "import", "tornado", ".", "wsgi", "import", "flask",...
r""" simple webserver that echos its arguments Args: domain (None): (default = None) port (int): (default = 5832) CommandLine: python -m utool.util_web --exec-start_simple_webserver:0 python -m utool.util_web --exec-start_simple_webserver:1 Example: >>> # DISAB...
[ "r", "simple", "webserver", "that", "echos", "its", "arguments" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_web.py#L66-L110
train
r Start a simple webserver that echos its arguments
Erotemic/utool
utool/util_web.py
render_html
def render_html(html_str): """ makes a temporary html rendering """ import utool as ut from os.path import abspath import webbrowser try: html_str = html_str.decode('utf8') except Exception: pass html_dpath = ut.ensure_app_resource_dir('utool', 'temp_html') fpat...
python
def render_html(html_str): """ makes a temporary html rendering """ import utool as ut from os.path import abspath import webbrowser try: html_str = html_str.decode('utf8') except Exception: pass html_dpath = ut.ensure_app_resource_dir('utool', 'temp_html') fpat...
[ "def", "render_html", "(", "html_str", ")", ":", "import", "utool", "as", "ut", "from", "os", ".", "path", "import", "abspath", "import", "webbrowser", "try", ":", "html_str", "=", "html_str", ".", "decode", "(", "'utf8'", ")", "except", "Exception", ":", ...
makes a temporary html rendering
[ "makes", "a", "temporary", "html", "rendering" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_web.py#L113-L130
train
Renders a temporary html string
quikmile/trellio
trellio/services.py
publish
def publish(func): """ publish the return value of this function as a message from this endpoint """ @wraps(func) def wrapper(self, *args, **kwargs): # outgoing payload = func(self, *args, **kwargs) payload.pop('self', None) self._publish(func.__name__, payload) ret...
python
def publish(func): """ publish the return value of this function as a message from this endpoint """ @wraps(func) def wrapper(self, *args, **kwargs): # outgoing payload = func(self, *args, **kwargs) payload.pop('self', None) self._publish(func.__name__, payload) ret...
[ "def", "publish", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# outgoing", "payload", "=", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kw...
publish the return value of this function as a message from this endpoint
[ "publish", "the", "return", "value", "of", "this", "function", "as", "a", "message", "from", "this", "endpoint" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/services.py#L26-L40
train
publish the return value of this function as a message from this endpoint
quikmile/trellio
trellio/services.py
xsubscribe
def xsubscribe(func=None, strategy='DESIGNATION'): """ Used to listen for publications from a specific endpoint of a service. If multiple instances subscribe to an endpoint, only one of them receives the event. And the publish event is retried till an acknowledgment is received from the other end. :...
python
def xsubscribe(func=None, strategy='DESIGNATION'): """ Used to listen for publications from a specific endpoint of a service. If multiple instances subscribe to an endpoint, only one of them receives the event. And the publish event is retried till an acknowledgment is received from the other end. :...
[ "def", "xsubscribe", "(", "func", "=", "None", ",", "strategy", "=", "'DESIGNATION'", ")", ":", "if", "func", "is", "None", ":", "return", "partial", "(", "xsubscribe", ",", "strategy", "=", "strategy", ")", "else", ":", "wrapper", "=", "_get_subscribe_dec...
Used to listen for publications from a specific endpoint of a service. If multiple instances subscribe to an endpoint, only one of them receives the event. And the publish event is retried till an acknowledgment is received from the other end. :param func: the function to decorate with. The name of the func...
[ "Used", "to", "listen", "for", "publications", "from", "a", "specific", "endpoint", "of", "a", "service", ".", "If", "multiple", "instances", "subscribe", "to", "an", "endpoint", "only", "one", "of", "them", "receives", "the", "event", ".", "And", "the", "...
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/services.py#L53-L69
train
Decorator to subscribe to events from a specific endpoint of a service.
quikmile/trellio
trellio/services.py
request
def request(func=None, timeout=600): """ use to request an api call from a specific endpoint """ if func is None: return partial(request, timeout=timeout) @wraps(func) def wrapper(self, *args, **kwargs): params = func(self, *args, **kwargs) self = params.pop('self', None...
python
def request(func=None, timeout=600): """ use to request an api call from a specific endpoint """ if func is None: return partial(request, timeout=timeout) @wraps(func) def wrapper(self, *args, **kwargs): params = func(self, *args, **kwargs) self = params.pop('self', None...
[ "def", "request", "(", "func", "=", "None", ",", "timeout", "=", "600", ")", ":", "if", "func", "is", "None", ":", "return", "partial", "(", "request", ",", "timeout", "=", "timeout", ")", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "sel...
use to request an api call from a specific endpoint
[ "use", "to", "request", "an", "api", "call", "from", "a", "specific", "endpoint" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/services.py#L83-L102
train
Decorator to request a specific api call from a specific endpoint
quikmile/trellio
trellio/services.py
api
def api(func=None, timeout=API_TIMEOUT): # incoming """ provide a request/response api receives any requests here and return value is the response all functions must have the following signature - request_id - entity (partition/routing key) followed by kwargs """ if func...
python
def api(func=None, timeout=API_TIMEOUT): # incoming """ provide a request/response api receives any requests here and return value is the response all functions must have the following signature - request_id - entity (partition/routing key) followed by kwargs """ if func...
[ "def", "api", "(", "func", "=", "None", ",", "timeout", "=", "API_TIMEOUT", ")", ":", "# incoming", "if", "func", "is", "None", ":", "return", "partial", "(", "api", ",", "timeout", "=", "timeout", ")", "else", ":", "wrapper", "=", "_get_api_decorator", ...
provide a request/response api receives any requests here and return value is the response all functions must have the following signature - request_id - entity (partition/routing key) followed by kwargs
[ "provide", "a", "request", "/", "response", "api", "receives", "any", "requests", "here", "and", "return", "value", "is", "the", "response", "all", "functions", "must", "have", "the", "following", "signature", "-", "request_id", "-", "entity", "(", "partition"...
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/services.py#L105-L118
train
Decorator for handling API requests and responses.
grktsh/falcon-oas
src/falcon_oas/problems.py
serialize_problem
def serialize_problem(req, resp, problem): """Serialize the given instance of Problem.""" preferred = req.client_prefers( ('application/json', 'application/problem+json') ) if preferred is None: preferred = 'application/json' resp.data = problem.to_json().encode('utf-8') resp.co...
python
def serialize_problem(req, resp, problem): """Serialize the given instance of Problem.""" preferred = req.client_prefers( ('application/json', 'application/problem+json') ) if preferred is None: preferred = 'application/json' resp.data = problem.to_json().encode('utf-8') resp.co...
[ "def", "serialize_problem", "(", "req", ",", "resp", ",", "problem", ")", ":", "preferred", "=", "req", ".", "client_prefers", "(", "(", "'application/json'", ",", "'application/problem+json'", ")", ")", "if", "preferred", "is", "None", ":", "preferred", "=", ...
Serialize the given instance of Problem.
[ "Serialize", "the", "given", "instance", "of", "Problem", "." ]
380921e82a50b565b3df6e494b06cc9dba961db7
https://github.com/grktsh/falcon-oas/blob/380921e82a50b565b3df6e494b06cc9dba961db7/src/falcon_oas/problems.py#L52-L62
train
Serialize the given instance of Problem into the response.
anayjoshi/platypus
platypus/simulator/simulator.py
get_ir
def get_ir(cfg_func): """ Converts the given CFG function into IR entities """ ir_func = ir.Function() ir_var_list = [] cfg_var_list = [] ir_bb_label_list = [] for cfg_var in cfg_func.variable_list: ir_var = ir.Variable(cfg_var.name) ir_var_list.append(ir_var) cfg...
python
def get_ir(cfg_func): """ Converts the given CFG function into IR entities """ ir_func = ir.Function() ir_var_list = [] cfg_var_list = [] ir_bb_label_list = [] for cfg_var in cfg_func.variable_list: ir_var = ir.Variable(cfg_var.name) ir_var_list.append(ir_var) cfg...
[ "def", "get_ir", "(", "cfg_func", ")", ":", "ir_func", "=", "ir", ".", "Function", "(", ")", "ir_var_list", "=", "[", "]", "cfg_var_list", "=", "[", "]", "ir_bb_label_list", "=", "[", "]", "for", "cfg_var", "in", "cfg_func", ".", "variable_list", ":", ...
Converts the given CFG function into IR entities
[ "Converts", "the", "given", "CFG", "function", "into", "IR", "entities" ]
71712f58c99651efbd2e6dfd75a9b1228d42e9ef
https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/simulator/simulator.py#L5-L94
train
Converts the given CFG function into IR entities
glormph/msstitch
src/app/actions/proteindata.py
add_psms_to_proteindata
def add_psms_to_proteindata(proteindata, p_acc, pool, psmdata): """Fill function for create_featuredata_map""" seq, psm_id = psmdata[2], psmdata[3] try: proteindata[p_acc]['pools'][pool]['psms'].add(psm_id) except KeyError: emptyinfo = {'psms': set(), 'peptides': set(), 'unipeps': 0} ...
python
def add_psms_to_proteindata(proteindata, p_acc, pool, psmdata): """Fill function for create_featuredata_map""" seq, psm_id = psmdata[2], psmdata[3] try: proteindata[p_acc]['pools'][pool]['psms'].add(psm_id) except KeyError: emptyinfo = {'psms': set(), 'peptides': set(), 'unipeps': 0} ...
[ "def", "add_psms_to_proteindata", "(", "proteindata", ",", "p_acc", ",", "pool", ",", "psmdata", ")", ":", "seq", ",", "psm_id", "=", "psmdata", "[", "2", "]", ",", "psmdata", "[", "3", "]", "try", ":", "proteindata", "[", "p_acc", "]", "[", "'pools'",...
Fill function for create_featuredata_map
[ "Fill", "function", "for", "create_featuredata_map" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/proteindata.py#L27-L39
train
Fill function for create_featuredata_map
glormph/msstitch
src/app/actions/proteindata.py
create_featuredata_map
def create_featuredata_map(pgdb, psm_fill_fun, pgene_fill_fun, genecentric=False, count_fun=None, pool_to_output=False, get_uniques=False, is_peptides=False): """Creates dict of protein data containing PSMs, peptides, proteins in protein group, unique peptides, description and coverage. Loops through ...
python
def create_featuredata_map(pgdb, psm_fill_fun, pgene_fill_fun, genecentric=False, count_fun=None, pool_to_output=False, get_uniques=False, is_peptides=False): """Creates dict of protein data containing PSMs, peptides, proteins in protein group, unique peptides, description and coverage. Loops through ...
[ "def", "create_featuredata_map", "(", "pgdb", ",", "psm_fill_fun", ",", "pgene_fill_fun", ",", "genecentric", "=", "False", ",", "count_fun", "=", "None", ",", "pool_to_output", "=", "False", ",", "get_uniques", "=", "False", ",", "is_peptides", "=", "False", ...
Creates dict of protein data containing PSMs, peptides, proteins in protein group, unique peptides, description and coverage. Loops through PSM/protein matches and uses a passed fill_fun function to actually fill the outputted map.
[ "Creates", "dict", "of", "protein", "data", "containing", "PSMs", "peptides", "proteins", "in", "protein", "group", "unique", "peptides", "description", "and", "coverage", ".", "Loops", "through", "PSM", "/", "protein", "matches", "and", "uses", "a", "passed", ...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/proteindata.py#L42-L81
train
Creates a dictionary of protein data containing PSMs peptides description and coverage. Loops through the protein data and fills the outputted map.
LEMS/pylems
lems/model/fundamental.py
Dimension.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Dimension name="{0}"'.format(self.name) +\ (' m = "{0}"'.format(self.m) if self.m != 0 else '') +\ (' l = "{0}"'.format(self.l) if self.l != 0 else '') +\ (' t = "{0}"'.format(self...
python
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Dimension name="{0}"'.format(self.name) +\ (' m = "{0}"'.format(self.m) if self.m != 0 else '') +\ (' l = "{0}"'.format(self.l) if self.l != 0 else '') +\ (' t = "{0}"'.format(self...
[ "def", "toxml", "(", "self", ")", ":", "return", "'<Dimension name=\"{0}\"'", ".", "format", "(", "self", ".", "name", ")", "+", "(", "' m = \"{0}\"'", ".", "format", "(", "self", ".", "m", ")", "if", "self", ".", "m", "!=", "0", "else", "''", ")", ...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/fundamental.py#L91-L104
train
Returns a LEMS XML string representation of the Dimension object.
LEMS/pylems
lems/model/fundamental.py
Unit.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ # Probably name should be removed altogether until its usage is decided, see # https://github.com/LEMS/LEMS/issues/4 # '''(' name = "{0}"'.format(self.name) if self.name else '') +\''' return '...
python
def toxml(self): """ Exports this object into a LEMS XML object """ # Probably name should be removed altogether until its usage is decided, see # https://github.com/LEMS/LEMS/issues/4 # '''(' name = "{0}"'.format(self.name) if self.name else '') +\''' return '...
[ "def", "toxml", "(", "self", ")", ":", "# Probably name should be removed altogether until its usage is decided, see", "# https://github.com/LEMS/LEMS/issues/4", "# '''(' name = \"{0}\"'.format(self.name) if self.name else '') +\\'''", "return", "'<Unit'", "+", "(", "' symbol = \"{0}\"'",...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/fundamental.py#L146-L162
train
Returns a LEMS XML string representation of the object.
Erotemic/utool
utool/util_dbg.py
print_traceback
def print_traceback(with_colors=True): """ prints current stack """ #traceback.print_tb() import traceback stack = traceback.extract_stack() stack_lines = traceback.format_list(stack) tbtext = ''.join(stack_lines) if with_colors: try: from pygments import highligh...
python
def print_traceback(with_colors=True): """ prints current stack """ #traceback.print_tb() import traceback stack = traceback.extract_stack() stack_lines = traceback.format_list(stack) tbtext = ''.join(stack_lines) if with_colors: try: from pygments import highligh...
[ "def", "print_traceback", "(", "with_colors", "=", "True", ")", ":", "#traceback.print_tb()", "import", "traceback", "stack", "=", "traceback", ".", "extract_stack", "(", ")", "stack_lines", "=", "traceback", ".", "format_list", "(", "stack", ")", "tbtext", "=",...
prints current stack
[ "prints", "current", "stack" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L40-L61
train
Print the traceback to the screen.
Erotemic/utool
utool/util_dbg.py
is_valid_varname
def is_valid_varname(varname): """ Checks syntax and validity of a variable name """ if not isinstance(varname, six.string_types): return False match_obj = re.match(varname_regex, varname) valid_syntax = match_obj is not None valid_name = not keyword.iskeyword(varname) isvalid = valid_sy...
python
def is_valid_varname(varname): """ Checks syntax and validity of a variable name """ if not isinstance(varname, six.string_types): return False match_obj = re.match(varname_regex, varname) valid_syntax = match_obj is not None valid_name = not keyword.iskeyword(varname) isvalid = valid_sy...
[ "def", "is_valid_varname", "(", "varname", ")", ":", "if", "not", "isinstance", "(", "varname", ",", "six", ".", "string_types", ")", ":", "return", "False", "match_obj", "=", "re", ".", "match", "(", "varname_regex", ",", "varname", ")", "valid_syntax", "...
Checks syntax and validity of a variable name
[ "Checks", "syntax", "and", "validity", "of", "a", "variable", "name" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L101-L109
train
Checks syntax and validity of a variable name
Erotemic/utool
utool/util_dbg.py
execstr_dict
def execstr_dict(dict_, local_name=None, exclude_list=None, explicit=False): """ returns execable python code that declares variables using keys and values execstr_dict Args: dict_ (dict): local_name (str): optional: local name of dictionary. Specifying this is much safer ...
python
def execstr_dict(dict_, local_name=None, exclude_list=None, explicit=False): """ returns execable python code that declares variables using keys and values execstr_dict Args: dict_ (dict): local_name (str): optional: local name of dictionary. Specifying this is much safer ...
[ "def", "execstr_dict", "(", "dict_", ",", "local_name", "=", "None", ",", "exclude_list", "=", "None", ",", "explicit", "=", "False", ")", ":", "import", "utool", "as", "ut", "if", "explicit", ":", "expr_list", "=", "[", "]", "for", "(", "key", ",", ...
returns execable python code that declares variables using keys and values execstr_dict Args: dict_ (dict): local_name (str): optional: local name of dictionary. Specifying this is much safer exclude_list (list): Returns: str: execstr --- the executable string ...
[ "returns", "execable", "python", "code", "that", "declares", "variables", "using", "keys", "and", "values" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L112-L203
train
Returns the executable string that declares variables using keys and values from dict_
Erotemic/utool
utool/util_dbg.py
fix_embed_globals
def fix_embed_globals(): """ HACK adds current locals() to globals(). Can be dangerous. """ frame = get_stack_frame(N=1) frame.f_globals.update(frame.f_locals) frame.f_globals['_did_embed_fix'] = True """ def fix_embed_globals(N=0): import inspect # Get the parent fra...
python
def fix_embed_globals(): """ HACK adds current locals() to globals(). Can be dangerous. """ frame = get_stack_frame(N=1) frame.f_globals.update(frame.f_locals) frame.f_globals['_did_embed_fix'] = True """ def fix_embed_globals(N=0): import inspect # Get the parent fra...
[ "def", "fix_embed_globals", "(", ")", ":", "frame", "=", "get_stack_frame", "(", "N", "=", "1", ")", "frame", ".", "f_globals", ".", "update", "(", "frame", ".", "f_locals", ")", "frame", ".", "f_globals", "[", "'_did_embed_fix'", "]", "=", "True", "\"\"...
HACK adds current locals() to globals(). Can be dangerous.
[ "HACK", "adds", "current", "locals", "()", "to", "globals", "()", ".", "Can", "be", "dangerous", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L278-L301
train
HACK adds current locals to globals.
Erotemic/utool
utool/util_dbg.py
_wip_embed
def _wip_embed(parent_locals=None, parent_globals=None, exec_lines=None, remove_pyqt_hook=True, N=0): """ Starts interactive session. Similar to keyboard command in matlab. Wrapper around IPython.embed Notes: #https://github.com/ipython/ipython/wiki/Cookbook%3a-Updating-code-for-...
python
def _wip_embed(parent_locals=None, parent_globals=None, exec_lines=None, remove_pyqt_hook=True, N=0): """ Starts interactive session. Similar to keyboard command in matlab. Wrapper around IPython.embed Notes: #https://github.com/ipython/ipython/wiki/Cookbook%3a-Updating-code-for-...
[ "def", "_wip_embed", "(", "parent_locals", "=", "None", ",", "parent_globals", "=", "None", ",", "exec_lines", "=", "None", ",", "remove_pyqt_hook", "=", "True", ",", "N", "=", "0", ")", ":", "import", "utool", "as", "ut", "from", "functools", "import", ...
Starts interactive session. Similar to keyboard command in matlab. Wrapper around IPython.embed Notes: #https://github.com/ipython/ipython/wiki/Cookbook%3a-Updating-code-for-use-with-IPython-0.11-and-later import IPython x = 3 IPython.embed() c = IPython.Config() ...
[ "Starts", "interactive", "session", ".", "Similar", "to", "keyboard", "command", "in", "matlab", ".", "Wrapper", "around", "IPython", ".", "embed" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L303-L453
train
This function is used to start an interactive session in matlab.
Erotemic/utool
utool/util_dbg.py
embed
def embed(parent_locals=None, parent_globals=None, exec_lines=None, remove_pyqt_hook=True, N=0): """ Starts interactive session. Similar to keyboard command in matlab. Wrapper around IPython.embed """ import utool as ut from functools import partial import IPython if parent_g...
python
def embed(parent_locals=None, parent_globals=None, exec_lines=None, remove_pyqt_hook=True, N=0): """ Starts interactive session. Similar to keyboard command in matlab. Wrapper around IPython.embed """ import utool as ut from functools import partial import IPython if parent_g...
[ "def", "embed", "(", "parent_locals", "=", "None", ",", "parent_globals", "=", "None", ",", "exec_lines", "=", "None", ",", "remove_pyqt_hook", "=", "True", ",", "N", "=", "0", ")", ":", "import", "utool", "as", "ut", "from", "functools", "import", "part...
Starts interactive session. Similar to keyboard command in matlab. Wrapper around IPython.embed
[ "Starts", "interactive", "session", ".", "Similar", "to", "keyboard", "command", "in", "matlab", ".", "Wrapper", "around", "IPython", ".", "embed" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L456-L556
train
Wrapper around IPython. embed
Erotemic/utool
utool/util_dbg.py
embed2
def embed2(**kwargs): """ Modified from IPython.terminal.embed.embed so I can mess with stack_depth """ config = kwargs.get('config') header = kwargs.pop('header', u'') stack_depth = kwargs.pop('stack_depth', 2) compile_flags = kwargs.pop('compile_flags', None) import IPython from IP...
python
def embed2(**kwargs): """ Modified from IPython.terminal.embed.embed so I can mess with stack_depth """ config = kwargs.get('config') header = kwargs.pop('header', u'') stack_depth = kwargs.pop('stack_depth', 2) compile_flags = kwargs.pop('compile_flags', None) import IPython from IP...
[ "def", "embed2", "(", "*", "*", "kwargs", ")", ":", "config", "=", "kwargs", ".", "get", "(", "'config'", ")", "header", "=", "kwargs", ".", "pop", "(", "'header'", ",", "u''", ")", "stack_depth", "=", "kwargs", ".", "pop", "(", "'stack_depth'", ",",...
Modified from IPython.terminal.embed.embed so I can mess with stack_depth
[ "Modified", "from", "IPython", ".", "terminal", ".", "embed", ".", "embed", "so", "I", "can", "mess", "with", "stack_depth" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L559-L598
train
Embeds a single terminal into another terminal.
Erotemic/utool
utool/util_dbg.py
in_jupyter_notebook
def in_jupyter_notebook(): """ http://stackoverflow.com/questions/15411967/how-can-i-check-if-code-is-executed-in-the-ipython-notebook """ try: cfg = get_ipython().config #print('cfg = %s' % (ut.repr4(cfg),)) #x = cfg['IPKernelApp']['parent_appname'] # might not work if u...
python
def in_jupyter_notebook(): """ http://stackoverflow.com/questions/15411967/how-can-i-check-if-code-is-executed-in-the-ipython-notebook """ try: cfg = get_ipython().config #print('cfg = %s' % (ut.repr4(cfg),)) #x = cfg['IPKernelApp']['parent_appname'] # might not work if u...
[ "def", "in_jupyter_notebook", "(", ")", ":", "try", ":", "cfg", "=", "get_ipython", "(", ")", ".", "config", "#print('cfg = %s' % (ut.repr4(cfg),))", "#x = cfg['IPKernelApp']['parent_appname']", "# might not work if using jupyter-console", "if", "cfg", "[", "'IPKernelApp'", ...
http://stackoverflow.com/questions/15411967/how-can-i-check-if-code-is-executed-in-the-ipython-notebook
[ "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "15411967", "/", "how", "-", "can", "-", "i", "-", "check", "-", "if", "-", "code", "-", "is", "-", "executed", "-", "in", "-", "the", "-", "ipython", "-", "notebook" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L631-L645
train
Check if code is executed in the jupyter notebook.
Erotemic/utool
utool/util_dbg.py
search_stack_for_localvar
def search_stack_for_localvar(varname): """ Finds a local varable somewhere in the stack and returns the value Args: varname (str): variable name Returns: None if varname is not found else its value """ curr_frame = inspect.currentframe() print(' * Searching parent frames f...
python
def search_stack_for_localvar(varname): """ Finds a local varable somewhere in the stack and returns the value Args: varname (str): variable name Returns: None if varname is not found else its value """ curr_frame = inspect.currentframe() print(' * Searching parent frames f...
[ "def", "search_stack_for_localvar", "(", "varname", ")", ":", "curr_frame", "=", "inspect", ".", "currentframe", "(", ")", "print", "(", "' * Searching parent frames for: '", "+", "six", ".", "text_type", "(", "varname", ")", ")", "frame_no", "=", "0", "while", ...
Finds a local varable somewhere in the stack and returns the value Args: varname (str): variable name Returns: None if varname is not found else its value
[ "Finds", "a", "local", "varable", "somewhere", "in", "the", "stack", "and", "returns", "the", "value" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L684-L704
train
Searches the stack for a local varable somewhere in the stack and returns its value.
Erotemic/utool
utool/util_dbg.py
search_stack_for_var
def search_stack_for_var(varname, verbose=util_arg.NOT_QUIET): """ Finds a varable (local or global) somewhere in the stack and returns the value Args: varname (str): variable name Returns: None if varname is not found else its value """ curr_frame = inspect.currentframe() ...
python
def search_stack_for_var(varname, verbose=util_arg.NOT_QUIET): """ Finds a varable (local or global) somewhere in the stack and returns the value Args: varname (str): variable name Returns: None if varname is not found else its value """ curr_frame = inspect.currentframe() ...
[ "def", "search_stack_for_var", "(", "varname", ",", "verbose", "=", "util_arg", ".", "NOT_QUIET", ")", ":", "curr_frame", "=", "inspect", ".", "currentframe", "(", ")", "if", "verbose", ":", "print", "(", "' * Searching parent frames for: '", "+", "six", ".", ...
Finds a varable (local or global) somewhere in the stack and returns the value Args: varname (str): variable name Returns: None if varname is not found else its value
[ "Finds", "a", "varable", "(", "local", "or", "global", ")", "somewhere", "in", "the", "stack", "and", "returns", "the", "value" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L707-L734
train
Searches the stack for a variable in the current context and returns the value.
Erotemic/utool
utool/util_dbg.py
get_stack_frame
def get_stack_frame(N=0, strict=True): """ Args: N (int): N=0 means the frame you called this function in. N=1 is the parent frame. strict (bool): (default = True) """ frame_cur = inspect.currentframe() for _ix in range(N + 1): # always skip the frame of this...
python
def get_stack_frame(N=0, strict=True): """ Args: N (int): N=0 means the frame you called this function in. N=1 is the parent frame. strict (bool): (default = True) """ frame_cur = inspect.currentframe() for _ix in range(N + 1): # always skip the frame of this...
[ "def", "get_stack_frame", "(", "N", "=", "0", ",", "strict", "=", "True", ")", ":", "frame_cur", "=", "inspect", ".", "currentframe", "(", ")", "for", "_ix", "in", "range", "(", "N", "+", "1", ")", ":", "# always skip the frame of this function", "frame_ne...
Args: N (int): N=0 means the frame you called this function in. N=1 is the parent frame. strict (bool): (default = True)
[ "Args", ":", "N", "(", "int", ")", ":", "N", "=", "0", "means", "the", "frame", "you", "called", "this", "function", "in", ".", "N", "=", "1", "is", "the", "parent", "frame", ".", "strict", "(", "bool", ")", ":", "(", "default", "=", "True", ")...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L741-L758
train
Returns the frame of the current stack.
Erotemic/utool
utool/util_dbg.py
printex
def printex(ex, msg='[!?] Caught exception', prefix=None, key_list=[], locals_=None, iswarning=False, tb=TB, pad_stdout=True, N=0, use_stdout=False, reraise=False, msg_=None, keys=None, colored=None): """ Prints (and/or logs) an exception with relevant info Args: ...
python
def printex(ex, msg='[!?] Caught exception', prefix=None, key_list=[], locals_=None, iswarning=False, tb=TB, pad_stdout=True, N=0, use_stdout=False, reraise=False, msg_=None, keys=None, colored=None): """ Prints (and/or logs) an exception with relevant info Args: ...
[ "def", "printex", "(", "ex", ",", "msg", "=", "'[!?] Caught exception'", ",", "prefix", "=", "None", ",", "key_list", "=", "[", "]", ",", "locals_", "=", "None", ",", "iswarning", "=", "False", ",", "tb", "=", "TB", ",", "pad_stdout", "=", "True", ",...
Prints (and/or logs) an exception with relevant info Args: ex (Exception): exception to print msg (str): a message to display to the user keys (None): a list of strings denoting variables or expressions of interest iswarning (bool): prints as a warning rather than an error if True (...
[ "Prints", "(", "and", "/", "or", "logs", ")", "an", "exception", "with", "relevant", "info" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L1022-L1087
train
Print an exception to the log
Erotemic/utool
utool/util_dbg.py
formatex
def formatex(ex, msg='[!?] Caught exception', prefix=None, key_list=[], locals_=None, iswarning=False, tb=False, N=0, keys=None, colored=None): r""" Formats an exception with relevant info Args: ex (Exception): exception to print msg (unicode): a message to displa...
python
def formatex(ex, msg='[!?] Caught exception', prefix=None, key_list=[], locals_=None, iswarning=False, tb=False, N=0, keys=None, colored=None): r""" Formats an exception with relevant info Args: ex (Exception): exception to print msg (unicode): a message to displa...
[ "def", "formatex", "(", "ex", ",", "msg", "=", "'[!?] Caught exception'", ",", "prefix", "=", "None", ",", "key_list", "=", "[", "]", ",", "locals_", "=", "None", ",", "iswarning", "=", "False", ",", "tb", "=", "False", ",", "N", "=", "0", ",", "ke...
r""" Formats an exception with relevant info Args: ex (Exception): exception to print msg (unicode): a message to display to the user (default = u'[!?] Caught exception') keys (None): a list of strings denoting variables or expressions of interest (default = []) iswarning (bool...
[ "r", "Formats", "an", "exception", "with", "relevant", "info" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L1090-L1170
train
r This function formats an exception with relevant info
Erotemic/utool
utool/util_dbg.py
get_varname_from_locals
def get_varname_from_locals(val, locals_, default='varname-not-found', strict=False, cmpfunc_=operator.is_): """ Finds the string name which has where locals_[name] is val Check the varname is in the parent namespace This will only work with objects not primatives Args: ...
python
def get_varname_from_locals(val, locals_, default='varname-not-found', strict=False, cmpfunc_=operator.is_): """ Finds the string name which has where locals_[name] is val Check the varname is in the parent namespace This will only work with objects not primatives Args: ...
[ "def", "get_varname_from_locals", "(", "val", ",", "locals_", ",", "default", "=", "'varname-not-found'", ",", "strict", "=", "False", ",", "cmpfunc_", "=", "operator", ".", "is_", ")", ":", "if", "val", "is", "None", "or", "isinstance", "(", "val", ",", ...
Finds the string name which has where locals_[name] is val Check the varname is in the parent namespace This will only work with objects not primatives Args: val (): some value locals_ (dict): local dictionary to search default (str): strict (bool): Returns: st...
[ "Finds", "the", "string", "name", "which", "has", "where", "locals_", "[", "name", "]", "is", "val" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L1177-L1206
train
Returns the varname which is val in the parent namespace
Erotemic/utool
utool/util_dbg.py
get_varval_from_locals
def get_varval_from_locals(key, locals_, strict=False): """ Returns a variable value from locals. Different from locals()['varname'] because get_varval_from_locals('varname.attribute', locals()) is allowed """ assert isinstance(key, six.string_types), 'must have parsed key into a string alre...
python
def get_varval_from_locals(key, locals_, strict=False): """ Returns a variable value from locals. Different from locals()['varname'] because get_varval_from_locals('varname.attribute', locals()) is allowed """ assert isinstance(key, six.string_types), 'must have parsed key into a string alre...
[ "def", "get_varval_from_locals", "(", "key", ",", "locals_", ",", "strict", "=", "False", ")", ":", "assert", "isinstance", "(", "key", ",", "six", ".", "string_types", ")", ",", "'must have parsed key into a string already'", "if", "key", "not", "in", "locals_"...
Returns a variable value from locals. Different from locals()['varname'] because get_varval_from_locals('varname.attribute', locals()) is allowed
[ "Returns", "a", "variable", "value", "from", "locals", ".", "Different", "from", "locals", "()", "[", "varname", "]", "because", "get_varval_from_locals", "(", "varname", ".", "attribute", "locals", "()", ")", "is", "allowed" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L1209-L1233
train
Returns a variable value from locals.
Erotemic/utool
utool/util_dbg.py
parse_locals_keylist
def parse_locals_keylist(locals_, key_list, strlist_=None, prefix=''): """ For each key in keylist, puts its value in locals into a stringlist Args: locals_ (?): key_list (list): strlist_ (list): (default = None) prefix (unicode): (default = u'') Returns: list: strl...
python
def parse_locals_keylist(locals_, key_list, strlist_=None, prefix=''): """ For each key in keylist, puts its value in locals into a stringlist Args: locals_ (?): key_list (list): strlist_ (list): (default = None) prefix (unicode): (default = u'') Returns: list: strl...
[ "def", "parse_locals_keylist", "(", "locals_", ",", "key_list", ",", "strlist_", "=", "None", ",", "prefix", "=", "''", ")", ":", "from", "utool", "import", "util_str", "if", "strlist_", "is", "None", ":", "strlist_", "=", "[", "]", "for", "key", "in", ...
For each key in keylist, puts its value in locals into a stringlist Args: locals_ (?): key_list (list): strlist_ (list): (default = None) prefix (unicode): (default = u'') Returns: list: strlist_ CommandLine: python -m utool.util_dbg --exec-parse_locals_key...
[ "For", "each", "key", "in", "keylist", "puts", "its", "value", "in", "locals", "into", "a", "stringlist" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L1265-L1331
train
This function parses the keylist into a stringlist of the appropriate type
dsoprea/NsqSpinner
nsq/consumer.py
ConsumerCallbacks.__send_rdy
def __send_rdy(self, connection, command): """Determine the RDY value, and set it. It can either be a static value a callback, or None. If it's None, we'll calculate the value based on our limits and connection counts. The documentation recommends starting with (1), but since we are alw...
python
def __send_rdy(self, connection, command): """Determine the RDY value, and set it. It can either be a static value a callback, or None. If it's None, we'll calculate the value based on our limits and connection counts. The documentation recommends starting with (1), but since we are alw...
[ "def", "__send_rdy", "(", "self", ",", "connection", ",", "command", ")", ":", "if", "self", ".", "__consumer", ".", "original_rdy", "is", "None", ":", "node_count", "=", "self", ".", "__consumer", ".", "get_node_count_for_topic", "(", "connection", ".", "co...
Determine the RDY value, and set it. It can either be a static value a callback, or None. If it's None, we'll calculate the value based on our limits and connection counts. The documentation recommends starting with (1), but since we are always dealing directly with *nsqd* servers by no...
[ "Determine", "the", "RDY", "value", "and", "set", "it", ".", "It", "can", "either", "be", "a", "static", "value", "a", "callback", "or", "None", ".", "If", "it", "s", "None", "we", "ll", "calculate", "the", "value", "based", "on", "our", "limits", "a...
972237b8ddce737983bfed001fde52e5236be695
https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/consumer.py#L41-L153
train
Send the RDY command to the specified master.
glormph/msstitch
src/app/actions/headers/peptable.py
switch_psm_to_peptable_fields
def switch_psm_to_peptable_fields(oldheader): """Returns a dict map with old to new header fields""" return {old: new for old, new in zip([mzidtsvdata.HEADER_PEPTIDE, mzidtsvdata.HEADER_PROTEIN, mzidtsvdata.HEADER_PEPTIDE_Q, ...
python
def switch_psm_to_peptable_fields(oldheader): """Returns a dict map with old to new header fields""" return {old: new for old, new in zip([mzidtsvdata.HEADER_PEPTIDE, mzidtsvdata.HEADER_PROTEIN, mzidtsvdata.HEADER_PEPTIDE_Q, ...
[ "def", "switch_psm_to_peptable_fields", "(", "oldheader", ")", ":", "return", "{", "old", ":", "new", "for", "old", ",", "new", "in", "zip", "(", "[", "mzidtsvdata", ".", "HEADER_PEPTIDE", ",", "mzidtsvdata", ".", "HEADER_PROTEIN", ",", "mzidtsvdata", ".", "...
Returns a dict map with old to new header fields
[ "Returns", "a", "dict", "map", "with", "old", "to", "new", "header", "fields" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/headers/peptable.py#L11-L20
train
Returns a dict map with old to new header fields
glormph/msstitch
src/app/actions/headers/peptable.py
generate_header
def generate_header(headerfields, oldheader, group_by_field): """Returns a header as a list, ready to write to TSV file""" fieldtypes = ['peptidefdr', 'peptidepep', 'nopsms', 'proteindata', 'precursorquant', 'isoquant'] return generate_general_header(headerfields, fieldtypes, ...
python
def generate_header(headerfields, oldheader, group_by_field): """Returns a header as a list, ready to write to TSV file""" fieldtypes = ['peptidefdr', 'peptidepep', 'nopsms', 'proteindata', 'precursorquant', 'isoquant'] return generate_general_header(headerfields, fieldtypes, ...
[ "def", "generate_header", "(", "headerfields", ",", "oldheader", ",", "group_by_field", ")", ":", "fieldtypes", "=", "[", "'peptidefdr'", ",", "'peptidepep'", ",", "'nopsms'", ",", "'proteindata'", ",", "'precursorquant'", ",", "'isoquant'", "]", "return", "genera...
Returns a header as a list, ready to write to TSV file
[ "Returns", "a", "header", "as", "a", "list", "ready", "to", "write", "to", "TSV", "file" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/headers/peptable.py#L49-L55
train
Generates a header as a list ready to write to TSV file
glormph/msstitch
src/app/actions/headers/peptable.py
get_peptable_headerfields
def get_peptable_headerfields(headertypes, lookup=False, poolnames=False): """Called by driver to generate headerfields object""" field_defs = {'isoquant': get_isoquant_fields, 'precursorquant': get_precursorquant_fields, 'peptidefdr': get_peptidefdr_fields, ...
python
def get_peptable_headerfields(headertypes, lookup=False, poolnames=False): """Called by driver to generate headerfields object""" field_defs = {'isoquant': get_isoquant_fields, 'precursorquant': get_precursorquant_fields, 'peptidefdr': get_peptidefdr_fields, ...
[ "def", "get_peptable_headerfields", "(", "headertypes", ",", "lookup", "=", "False", ",", "poolnames", "=", "False", ")", ":", "field_defs", "=", "{", "'isoquant'", ":", "get_isoquant_fields", ",", "'precursorquant'", ":", "get_precursorquant_fields", ",", "'peptide...
Called by driver to generate headerfields object
[ "Called", "by", "driver", "to", "generate", "headerfields", "object" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/headers/peptable.py#L58-L66
train
Returns a generator object that can be used to generate headerfields objects for a given list of headype
glormph/msstitch
src/app/actions/headers/peptable.py
get_proteininfo_fields
def get_proteininfo_fields(poolnames=False, genecentric=False): """Returns header fields for protein (group) information.""" allfields = OrderedDict() basefields = [peptabledata.HEADER_PROTEINS, peptabledata.HEADER_GENES, peptabledata.HEADER_ASSOCIATED, ...
python
def get_proteininfo_fields(poolnames=False, genecentric=False): """Returns header fields for protein (group) information.""" allfields = OrderedDict() basefields = [peptabledata.HEADER_PROTEINS, peptabledata.HEADER_GENES, peptabledata.HEADER_ASSOCIATED, ...
[ "def", "get_proteininfo_fields", "(", "poolnames", "=", "False", ",", "genecentric", "=", "False", ")", ":", "allfields", "=", "OrderedDict", "(", ")", "basefields", "=", "[", "peptabledata", ".", "HEADER_PROTEINS", ",", "peptabledata", ".", "HEADER_GENES", ",",...
Returns header fields for protein (group) information.
[ "Returns", "header", "fields", "for", "protein", "(", "group", ")", "information", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/headers/peptable.py#L81-L94
train
Returns header fields for protein group information.
Erotemic/utool
utool/_internal/meta_util_arg.py
get_argval
def get_argval(argstr, type_=None, default=None): r""" Returns a value of an argument specified on the command line after some flag CommandLine: python -c "import utool; print([(type(x), x) for x in [utool.get_argval('--quest')]])" --quest="holy grail" python -c "import utool; print([(type(...
python
def get_argval(argstr, type_=None, default=None): r""" Returns a value of an argument specified on the command line after some flag CommandLine: python -c "import utool; print([(type(x), x) for x in [utool.get_argval('--quest')]])" --quest="holy grail" python -c "import utool; print([(type(...
[ "def", "get_argval", "(", "argstr", ",", "type_", "=", "None", ",", "default", "=", "None", ")", ":", "arg_after", "=", "default", "if", "type_", "is", "bool", ":", "arg_after", "=", "False", "if", "default", "is", "None", "else", "default", "try", ":"...
r""" Returns a value of an argument specified on the command line after some flag CommandLine: python -c "import utool; print([(type(x), x) for x in [utool.get_argval('--quest')]])" --quest="holy grail" python -c "import utool; print([(type(x), x) for x in [utool.get_argval('--quest')]])" --que...
[ "r", "Returns", "a", "value", "of", "an", "argument", "specified", "on", "the", "command", "line", "after", "some", "flag" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/meta_util_arg.py#L63-L103
train
r Returns a value of an argument specified on the command line after some flag Insights
anayjoshi/platypus
platypus/cfg/cfg.py
BasicBlock.add_instruction
def add_instruction (self, instr): """ Adds the argument instruction in the list of instructions of this basic block. Also updates the variable lists (used_variables, defined_variables) """ assert(isinstance(instr, Instruction)) self.instruction_list.append(instr) ...
python
def add_instruction (self, instr): """ Adds the argument instruction in the list of instructions of this basic block. Also updates the variable lists (used_variables, defined_variables) """ assert(isinstance(instr, Instruction)) self.instruction_list.append(instr) ...
[ "def", "add_instruction", "(", "self", ",", "instr", ")", ":", "assert", "(", "isinstance", "(", "instr", ",", "Instruction", ")", ")", "self", ".", "instruction_list", ".", "append", "(", "instr", ")", "if", "instr", ".", "lhs", "not", "in", "self", "...
Adds the argument instruction in the list of instructions of this basic block. Also updates the variable lists (used_variables, defined_variables)
[ "Adds", "the", "argument", "instruction", "in", "the", "list", "of", "instructions", "of", "this", "basic", "block", "." ]
71712f58c99651efbd2e6dfd75a9b1228d42e9ef
https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L169-L190
train
Adds the argument instruction to the list of instructions of this basic block.
anayjoshi/platypus
platypus/cfg/cfg.py
BasicBlock.set_condition
def set_condition(self, condition, condition_instr=None): """ Defines the condition which decides how the basic block exits :param condition: :type condition: :param condition_instr: If the 'condition' argument is a Variable, then\ condition_instr is None, else,...
python
def set_condition(self, condition, condition_instr=None): """ Defines the condition which decides how the basic block exits :param condition: :type condition: :param condition_instr: If the 'condition' argument is a Variable, then\ condition_instr is None, else,...
[ "def", "set_condition", "(", "self", ",", "condition", ",", "condition_instr", "=", "None", ")", ":", "assert", "(", "isinstance", "(", "condition", ",", "Numeric", ")", ")", "if", "condition_instr", "is", "not", "None", ":", "assert", "(", "isinstance", "...
Defines the condition which decides how the basic block exits :param condition: :type condition: :param condition_instr: If the 'condition' argument is a Variable, then\ condition_instr is None, else, condition_instr should be\ of type CmpInstruction :ty...
[ "Defines", "the", "condition", "which", "decides", "how", "the", "basic", "block", "exits" ]
71712f58c99651efbd2e6dfd75a9b1228d42e9ef
https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L193-L219
train
Sets the condition which decides how the basic block exits.
anayjoshi/platypus
platypus/cfg/cfg.py
Function.add_basic_block
def add_basic_block(self, basic_block): """Adds the given basic block in the function""" assert(isinstance(basic_block, BasicBlock)) self.basic_block_list.append(basic_block)
python
def add_basic_block(self, basic_block): """Adds the given basic block in the function""" assert(isinstance(basic_block, BasicBlock)) self.basic_block_list.append(basic_block)
[ "def", "add_basic_block", "(", "self", ",", "basic_block", ")", ":", "assert", "(", "isinstance", "(", "basic_block", ",", "BasicBlock", ")", ")", "self", ".", "basic_block_list", ".", "append", "(", "basic_block", ")" ]
Adds the given basic block in the function
[ "Adds", "the", "given", "basic", "block", "in", "the", "function" ]
71712f58c99651efbd2e6dfd75a9b1228d42e9ef
https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L256-L259
train
Adds the given basic block in the function
anayjoshi/platypus
platypus/cfg/cfg.py
Function.get_variable
def get_variable(self, var_name): """ If a variable with the name var_name exists in this function's variable list, \ then that variable object is returned; else a new variable is created\ with the given name and added to the variable list of this function\ ...
python
def get_variable(self, var_name): """ If a variable with the name var_name exists in this function's variable list, \ then that variable object is returned; else a new variable is created\ with the given name and added to the variable list of this function\ ...
[ "def", "get_variable", "(", "self", ",", "var_name", ")", ":", "assert", "(", "isinstance", "(", "var_name", ",", "str", ")", ")", "if", "isinstance", "(", "var_name", ",", "str", ")", ":", "for", "var", "in", "self", ".", "variable_list", ":", "if", ...
If a variable with the name var_name exists in this function's variable list, \ then that variable object is returned; else a new variable is created\ with the given name and added to the variable list of this function\ and returned back :returns: A variable whic...
[ "If", "a", "variable", "with", "the", "name", "var_name", "exists", "in", "this", "function", "s", "variable", "list", "\\", "then", "that", "variable", "object", "is", "returned", ";", "else", "a", "new", "variable", "is", "created", "\\", "with", "the", ...
71712f58c99651efbd2e6dfd75a9b1228d42e9ef
https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L268-L285
train
Returns a variable object with the given name.
anayjoshi/platypus
platypus/cfg/cfg.py
Function.add_input_variable
def add_input_variable(self, var): """Adds the argument variable as one of the input variable""" assert(isinstance(var, Variable)) self.input_variable_list.append(var)
python
def add_input_variable(self, var): """Adds the argument variable as one of the input variable""" assert(isinstance(var, Variable)) self.input_variable_list.append(var)
[ "def", "add_input_variable", "(", "self", ",", "var", ")", ":", "assert", "(", "isinstance", "(", "var", ",", "Variable", ")", ")", "self", ".", "input_variable_list", ".", "append", "(", "var", ")" ]
Adds the argument variable as one of the input variable
[ "Adds", "the", "argument", "variable", "as", "one", "of", "the", "input", "variable" ]
71712f58c99651efbd2e6dfd75a9b1228d42e9ef
https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L287-L290
train
Adds the argument variable as one of the input variable
anayjoshi/platypus
platypus/cfg/cfg.py
Function.add_output_variable
def add_output_variable(self, var): """Adds the argument variable as one of the output variable""" assert(isinstance(var, Variable)) self.output_variable_list.append(var)
python
def add_output_variable(self, var): """Adds the argument variable as one of the output variable""" assert(isinstance(var, Variable)) self.output_variable_list.append(var)
[ "def", "add_output_variable", "(", "self", ",", "var", ")", ":", "assert", "(", "isinstance", "(", "var", ",", "Variable", ")", ")", "self", ".", "output_variable_list", ".", "append", "(", "var", ")" ]
Adds the argument variable as one of the output variable
[ "Adds", "the", "argument", "variable", "as", "one", "of", "the", "output", "variable" ]
71712f58c99651efbd2e6dfd75a9b1228d42e9ef
https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L292-L295
train
Adds the argument variable as one of the output variable list
LEMS/pylems
lems/parser/expr.py
ExprParser.tokenize
def tokenize(self): """ Tokenizes the string stored in the parser object into a list of tokens. """ self.token_list = [] ps = self.parse_string.strip() i = 0 last_token = None while i < len(ps) and ps[i].isspace(): i += 1 wh...
python
def tokenize(self): """ Tokenizes the string stored in the parser object into a list of tokens. """ self.token_list = [] ps = self.parse_string.strip() i = 0 last_token = None while i < len(ps) and ps[i].isspace(): i += 1 wh...
[ "def", "tokenize", "(", "self", ")", ":", "self", ".", "token_list", "=", "[", "]", "ps", "=", "self", ".", "parse_string", ".", "strip", "(", ")", "i", "=", "0", "last_token", "=", "None", "while", "i", "<", "len", "(", "ps", ")", "and", "ps", ...
Tokenizes the string stored in the parser object into a list of tokens.
[ "Tokenizes", "the", "string", "stored", "in", "the", "parser", "object", "into", "a", "list", "of", "tokens", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/parser/expr.py#L263-L315
train
Tokenizes the string stored in the parser object into a list of tokens.
LEMS/pylems
lems/parser/expr.py
ExprParser.parse_token_list_rec
def parse_token_list_rec(self, min_precedence): """ Parses a tokenized arithmetic expression into a parse tree. It calls itself recursively to handle bracketed subexpressions. @return: Returns a token string. @rtype: lems.parser.expr.ExprNode @attention: Does not handle...
python
def parse_token_list_rec(self, min_precedence): """ Parses a tokenized arithmetic expression into a parse tree. It calls itself recursively to handle bracketed subexpressions. @return: Returns a token string. @rtype: lems.parser.expr.ExprNode @attention: Does not handle...
[ "def", "parse_token_list_rec", "(", "self", ",", "min_precedence", ")", ":", "exit_loop", "=", "False", "ExprParser", ".", "depth", "=", "ExprParser", ".", "depth", "+", "1", "if", "self", ".", "debug", ":", "print", "(", "'>>>>> Depth: %i'", "%", "ExprParse...
Parses a tokenized arithmetic expression into a parse tree. It calls itself recursively to handle bracketed subexpressions. @return: Returns a token string. @rtype: lems.parser.expr.ExprNode @attention: Does not handle unary minuses at the moment. Needs to be fixed.
[ "Parses", "a", "tokenized", "arithmetic", "expression", "into", "a", "parse", "tree", ".", "It", "calls", "itself", "recursively", "to", "handle", "bracketed", "subexpressions", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/parser/expr.py#L352-L476
train
Parses a tokenized arithmetic expression into a parse tree.
LEMS/pylems
lems/parser/expr.py
ExprParser.parse
def parse(self): """ Tokenizes and parses an arithmetic expression into a parse tree. @return: Returns a token string. @rtype: lems.parser.expr.ExprNode """ #print("Parsing: %s"%self.parse_string) self.tokenize() if self.debug: print("Tokens found: %s"%se...
python
def parse(self): """ Tokenizes and parses an arithmetic expression into a parse tree. @return: Returns a token string. @rtype: lems.parser.expr.ExprNode """ #print("Parsing: %s"%self.parse_string) self.tokenize() if self.debug: print("Tokens found: %s"%se...
[ "def", "parse", "(", "self", ")", ":", "#print(\"Parsing: %s\"%self.parse_string)", "self", ".", "tokenize", "(", ")", "if", "self", ".", "debug", ":", "print", "(", "\"Tokens found: %s\"", "%", "self", ".", "token_list", ")", "try", ":", "parse_tree", "=", ...
Tokenizes and parses an arithmetic expression into a parse tree. @return: Returns a token string. @rtype: lems.parser.expr.ExprNode
[ "Tokenizes", "and", "parses", "an", "arithmetic", "expression", "into", "a", "parse", "tree", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/parser/expr.py#L478-L493
train
Tokenizes and parses an arithmetic expression into a parse tree.
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.insert_keys
def insert_keys(self, keys): """Insert keys into a table which assigns an ID""" start = 0 bulk_insert = self.bulk_insert keys_len = len(keys) query = 'INSERT IGNORE INTO gauged_keys (namespace, `key`) VALUES ' execute = self.cursor.execute while start < keys_len: ...
python
def insert_keys(self, keys): """Insert keys into a table which assigns an ID""" start = 0 bulk_insert = self.bulk_insert keys_len = len(keys) query = 'INSERT IGNORE INTO gauged_keys (namespace, `key`) VALUES ' execute = self.cursor.execute while start < keys_len: ...
[ "def", "insert_keys", "(", "self", ",", "keys", ")", ":", "start", "=", "0", "bulk_insert", "=", "self", ".", "bulk_insert", "keys_len", "=", "len", "(", "keys", ")", "query", "=", "'INSERT IGNORE INTO gauged_keys (namespace, `key`) VALUES '", "execute", "=", "s...
Insert keys into a table which assigns an ID
[ "Insert", "keys", "into", "a", "table", "which", "assigns", "an", "ID" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L81-L93
train
Insert keys into a table which assigns an ID
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.replace_blocks
def replace_blocks(self, blocks): """Replace multiple blocks. blocks must be a list of tuples where each tuple consists of (namespace, offset, key, data)""" start = 0 bulk_insert = self.bulk_insert blocks_len = len(blocks) row = '(%s,%s,%s,%s,%s)' query = 'REPLACE...
python
def replace_blocks(self, blocks): """Replace multiple blocks. blocks must be a list of tuples where each tuple consists of (namespace, offset, key, data)""" start = 0 bulk_insert = self.bulk_insert blocks_len = len(blocks) row = '(%s,%s,%s,%s,%s)' query = 'REPLACE...
[ "def", "replace_blocks", "(", "self", ",", "blocks", ")", ":", "start", "=", "0", "bulk_insert", "=", "self", ".", "bulk_insert", "blocks_len", "=", "len", "(", "blocks", ")", "row", "=", "'(%s,%s,%s,%s,%s)'", "query", "=", "'REPLACE INTO gauged_data (namespace,...
Replace multiple blocks. blocks must be a list of tuples where each tuple consists of (namespace, offset, key, data)
[ "Replace", "multiple", "blocks", ".", "blocks", "must", "be", "a", "list", "of", "tuples", "where", "each", "tuple", "consists", "of", "(", "namespace", "offset", "key", "data", ")" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L95-L113
train
Replace multiple blocks. blocks must be a list of tuples where each tuple consists of namespace offset key data and flags.
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.get_writer_position
def get_writer_position(self, name): """Get the current writer position""" cursor = self.cursor cursor.execute('SELECT timestamp FROM gauged_writer_history ' 'WHERE id = %s', (name,)) result = cursor.fetchone() return result[0] if result else 0
python
def get_writer_position(self, name): """Get the current writer position""" cursor = self.cursor cursor.execute('SELECT timestamp FROM gauged_writer_history ' 'WHERE id = %s', (name,)) result = cursor.fetchone() return result[0] if result else 0
[ "def", "get_writer_position", "(", "self", ",", "name", ")", ":", "cursor", "=", "self", ".", "cursor", "cursor", ".", "execute", "(", "'SELECT timestamp FROM gauged_writer_history '", "'WHERE id = %s'", ",", "(", "name", ",", ")", ")", "result", "=", "cursor", ...
Get the current writer position
[ "Get", "the", "current", "writer", "position" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L174-L180
train
Get the current writer position
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.get_namespaces
def get_namespaces(self): """Get a list of namespaces""" cursor = self.cursor cursor.execute('SELECT DISTINCT namespace FROM gauged_statistics') return [namespace for namespace, in cursor]
python
def get_namespaces(self): """Get a list of namespaces""" cursor = self.cursor cursor.execute('SELECT DISTINCT namespace FROM gauged_statistics') return [namespace for namespace, in cursor]
[ "def", "get_namespaces", "(", "self", ")", ":", "cursor", "=", "self", ".", "cursor", "cursor", ".", "execute", "(", "'SELECT DISTINCT namespace FROM gauged_statistics'", ")", "return", "[", "namespace", "for", "namespace", ",", "in", "cursor", "]" ]
Get a list of namespaces
[ "Get", "a", "list", "of", "namespaces" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L182-L186
train
Get a list of namespaces
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.remove_namespace
def remove_namespace(self, namespace): """Remove all data associated with the current namespace""" params = (namespace, ) execute = self.cursor.execute execute('DELETE FROM gauged_data WHERE namespace = %s', params) execute('DELETE FROM gauged_statistics WHERE namespace = %s', pa...
python
def remove_namespace(self, namespace): """Remove all data associated with the current namespace""" params = (namespace, ) execute = self.cursor.execute execute('DELETE FROM gauged_data WHERE namespace = %s', params) execute('DELETE FROM gauged_statistics WHERE namespace = %s', pa...
[ "def", "remove_namespace", "(", "self", ",", "namespace", ")", ":", "params", "=", "(", "namespace", ",", ")", "execute", "=", "self", ".", "cursor", ".", "execute", "execute", "(", "'DELETE FROM gauged_data WHERE namespace = %s'", ",", "params", ")", "execute",...
Remove all data associated with the current namespace
[ "Remove", "all", "data", "associated", "with", "the", "current", "namespace" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L188-L195
train
Remove all data associated with the current namespace
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.remove_cache
def remove_cache(self, namespace, key=None): """Remove all cached values for the specified namespace, optionally specifying a key""" if key is None: self.cursor.execute('DELETE FROM gauged_cache ' 'WHERE namespace = %s', (namespace,)) else: ...
python
def remove_cache(self, namespace, key=None): """Remove all cached values for the specified namespace, optionally specifying a key""" if key is None: self.cursor.execute('DELETE FROM gauged_cache ' 'WHERE namespace = %s', (namespace,)) else: ...
[ "def", "remove_cache", "(", "self", ",", "namespace", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "self", ".", "cursor", ".", "execute", "(", "'DELETE FROM gauged_cache '", "'WHERE namespace = %s'", ",", "(", "namespace", ",", ")", "...
Remove all cached values for the specified namespace, optionally specifying a key
[ "Remove", "all", "cached", "values", "for", "the", "specified", "namespace", "optionally", "specifying", "a", "key" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L274-L283
train
Remove all cached values for the specified namespace optionally specifying a key
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.add_namespace_statistics
def add_namespace_statistics(self, namespace, offset, data_points, byte_count): """Update namespace statistics for the period identified by offset""" self.cursor.execute( 'INSERT INTO gauged_statistics VALUES (%s,%s,%s,%s) ON DUPLICATE ' '...
python
def add_namespace_statistics(self, namespace, offset, data_points, byte_count): """Update namespace statistics for the period identified by offset""" self.cursor.execute( 'INSERT INTO gauged_statistics VALUES (%s,%s,%s,%s) ON DUPLICATE ' '...
[ "def", "add_namespace_statistics", "(", "self", ",", "namespace", ",", "offset", ",", "data_points", ",", "byte_count", ")", ":", "self", ".", "cursor", ".", "execute", "(", "'INSERT INTO gauged_statistics VALUES (%s,%s,%s,%s) ON DUPLICATE '", "'KEY UPDATE data_points = dat...
Update namespace statistics for the period identified by offset
[ "Update", "namespace", "statistics", "for", "the", "period", "identified", "by", "offset" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L289-L297
train
Update the gauged_statistics table for the period identified by namespace and offset.
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.get_namespace_statistics
def get_namespace_statistics(self, namespace, start_offset, end_offset): """Get namespace statistics for the period between start_offset and end_offset (inclusive)""" cursor = self.cursor cursor.execute('SELECT SUM(data_points), SUM(byte_count) ' 'FROM gauged_stati...
python
def get_namespace_statistics(self, namespace, start_offset, end_offset): """Get namespace statistics for the period between start_offset and end_offset (inclusive)""" cursor = self.cursor cursor.execute('SELECT SUM(data_points), SUM(byte_count) ' 'FROM gauged_stati...
[ "def", "get_namespace_statistics", "(", "self", ",", "namespace", ",", "start_offset", ",", "end_offset", ")", ":", "cursor", "=", "self", ".", "cursor", "cursor", ".", "execute", "(", "'SELECT SUM(data_points), SUM(byte_count) '", "'FROM gauged_statistics WHERE namespace...
Get namespace statistics for the period between start_offset and end_offset (inclusive)
[ "Get", "namespace", "statistics", "for", "the", "period", "between", "start_offset", "and", "end_offset", "(", "inclusive", ")" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L299-L307
train
Get the number of data points for the period between start_offset and end_offset ( inclusive
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.create_schema
def create_schema(self): """Create all necessary tables""" cursor = self.cursor execute = cursor.execute execute('SHOW TABLES') tables = {table for table, in cursor} if 'gauged_data' not in tables: execute("""CREATE TABLE gauged_data ( namespac...
python
def create_schema(self): """Create all necessary tables""" cursor = self.cursor execute = cursor.execute execute('SHOW TABLES') tables = {table for table, in cursor} if 'gauged_data' not in tables: execute("""CREATE TABLE gauged_data ( namespac...
[ "def", "create_schema", "(", "self", ")", ":", "cursor", "=", "self", ".", "cursor", "execute", "=", "cursor", ".", "execute", "execute", "(", "'SHOW TABLES'", ")", "tables", "=", "{", "table", "for", "table", ",", "in", "cursor", "}", "if", "'gauged_dat...
Create all necessary tables
[ "Create", "all", "necessary", "tables" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L309-L353
train
Create all necessary tables and tables in the database.
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.clear_schema
def clear_schema(self): """Clear all gauged data""" execute = self.cursor.execute execute('TRUNCATE TABLE gauged_data') execute('TRUNCATE TABLE gauged_keys') execute('TRUNCATE TABLE gauged_writer_history') execute('TRUNCATE TABLE gauged_cache') execute('TRUNCATE T...
python
def clear_schema(self): """Clear all gauged data""" execute = self.cursor.execute execute('TRUNCATE TABLE gauged_data') execute('TRUNCATE TABLE gauged_keys') execute('TRUNCATE TABLE gauged_writer_history') execute('TRUNCATE TABLE gauged_cache') execute('TRUNCATE T...
[ "def", "clear_schema", "(", "self", ")", ":", "execute", "=", "self", ".", "cursor", ".", "execute", "execute", "(", "'TRUNCATE TABLE gauged_data'", ")", "execute", "(", "'TRUNCATE TABLE gauged_keys'", ")", "execute", "(", "'TRUNCATE TABLE gauged_writer_history'", ")"...
Clear all gauged data
[ "Clear", "all", "gauged", "data" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L355-L363
train
Clear all gauged data and all keys and statistics
chriso/gauged
gauged/drivers/mysql.py
MySQLDriver.drop_schema
def drop_schema(self): """Drop all gauged tables""" execute = self.cursor.execute execute('DROP TABLE IF EXISTS gauged_data') execute('DROP TABLE IF EXISTS gauged_keys') execute('DROP TABLE IF EXISTS gauged_writer_history') execute('DROP TABLE IF EXISTS gauged_cache') ...
python
def drop_schema(self): """Drop all gauged tables""" execute = self.cursor.execute execute('DROP TABLE IF EXISTS gauged_data') execute('DROP TABLE IF EXISTS gauged_keys') execute('DROP TABLE IF EXISTS gauged_writer_history') execute('DROP TABLE IF EXISTS gauged_cache') ...
[ "def", "drop_schema", "(", "self", ")", ":", "execute", "=", "self", ".", "cursor", ".", "execute", "execute", "(", "'DROP TABLE IF EXISTS gauged_data'", ")", "execute", "(", "'DROP TABLE IF EXISTS gauged_keys'", ")", "execute", "(", "'DROP TABLE IF EXISTS gauged_writer...
Drop all gauged tables
[ "Drop", "all", "gauged", "tables" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L365-L374
train
Drop all tables and tables in the database.
neithere/monk
monk/shortcuts.py
opt_key
def opt_key(spec): """ Returns a validator which allows the value to be missing. Similar to :func:`optional` but wraps a string in :class:`~monk.validators.Equals` instead of :class:`~monk.validators.IsA`. Intended for dictionary keys. :: >>> opt_key(str) == IsA(str) | ~Exists() ...
python
def opt_key(spec): """ Returns a validator which allows the value to be missing. Similar to :func:`optional` but wraps a string in :class:`~monk.validators.Equals` instead of :class:`~monk.validators.IsA`. Intended for dictionary keys. :: >>> opt_key(str) == IsA(str) | ~Exists() ...
[ "def", "opt_key", "(", "spec", ")", ":", "if", "isinstance", "(", "spec", ",", "text_types", ")", ":", "spec", "=", "Equals", "(", "spec", ")", "return", "optional", "(", "spec", ")" ]
Returns a validator which allows the value to be missing. Similar to :func:`optional` but wraps a string in :class:`~monk.validators.Equals` instead of :class:`~monk.validators.IsA`. Intended for dictionary keys. :: >>> opt_key(str) == IsA(str) | ~Exists() True >>> opt_key('foo...
[ "Returns", "a", "validator", "which", "allows", "the", "value", "to", "be", "missing", ".", "Similar", "to", ":", "func", ":", "optional", "but", "wraps", "a", "string", "in", ":", "class", ":", "~monk", ".", "validators", ".", "Equals", "instead", "of",...
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/shortcuts.py#L61-L78
train
Returns a validator which allows the value to be missing.
neithere/monk
monk/shortcuts.py
one_of
def one_of(choices, first_is_default=False, as_rules=False): """ A wrapper for :class:`Any`. :param as_rules: `bool`. If `False` (by default), each element of `choices` is wrapped in the :class:`Equals` validator so they are interpreted as literals. .. deprecated:: 0.13 ...
python
def one_of(choices, first_is_default=False, as_rules=False): """ A wrapper for :class:`Any`. :param as_rules: `bool`. If `False` (by default), each element of `choices` is wrapped in the :class:`Equals` validator so they are interpreted as literals. .. deprecated:: 0.13 ...
[ "def", "one_of", "(", "choices", ",", "first_is_default", "=", "False", ",", "as_rules", "=", "False", ")", ":", "assert", "choices", "if", "as_rules", ":", "None", "# for coverage", "else", ":", "choices", "=", "[", "Equals", "(", "x", ")", "for", "x", ...
A wrapper for :class:`Any`. :param as_rules: `bool`. If `False` (by default), each element of `choices` is wrapped in the :class:`Equals` validator so they are interpreted as literals. .. deprecated:: 0.13 Use :class:`Any` instead.
[ "A", "wrapper", "for", ":", "class", ":", "Any", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/shortcuts.py#L81-L102
train
A wrapper for Any.
neithere/monk
monk/shortcuts.py
in_range
def in_range(start, stop, first_is_default=False): """ A shortcut for a rule with :func:`~monk.validators.validate_range` validator. :: # these expressions are equal: in_range(0, 200) Rule(int, validators=[monk.validators.validate_range(0, 200)]) # default value can be ta...
python
def in_range(start, stop, first_is_default=False): """ A shortcut for a rule with :func:`~monk.validators.validate_range` validator. :: # these expressions are equal: in_range(0, 200) Rule(int, validators=[monk.validators.validate_range(0, 200)]) # default value can be ta...
[ "def", "in_range", "(", "start", ",", "stop", ",", "first_is_default", "=", "False", ")", ":", "if", "first_is_default", ":", "default_value", "=", "start", "else", ":", "default_value", "=", "None", "return", "InRange", "(", "start", ",", "stop", ",", "de...
A shortcut for a rule with :func:`~monk.validators.validate_range` validator. :: # these expressions are equal: in_range(0, 200) Rule(int, validators=[monk.validators.validate_range(0, 200)]) # default value can be taken from the first choice: in_range(0, 200, first_is_d...
[ "A", "shortcut", "for", "a", "rule", "with", ":", "func", ":", "~monk", ".", "validators", ".", "validate_range", "validator", ".", "::" ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/shortcuts.py#L105-L133
train
A function to create a new InRange object.
Erotemic/utool
utool/util_scripts/permit_gitrepo.py
permit_gitrepo
def permit_gitrepo(config_fpath, writeback=False): """ Changes https:// in .git/config files to git@ and makes appropriate changes to colons and slashses """ # Define search replace patterns username_regex = utool.named_field('username', utool.REGEX_VARNAME) username_repl = utool.backref_fie...
python
def permit_gitrepo(config_fpath, writeback=False): """ Changes https:// in .git/config files to git@ and makes appropriate changes to colons and slashses """ # Define search replace patterns username_regex = utool.named_field('username', utool.REGEX_VARNAME) username_repl = utool.backref_fie...
[ "def", "permit_gitrepo", "(", "config_fpath", ",", "writeback", "=", "False", ")", ":", "# Define search replace patterns", "username_regex", "=", "utool", ".", "named_field", "(", "'username'", ",", "utool", ".", "REGEX_VARNAME", ")", "username_repl", "=", "utool",...
Changes https:// in .git/config files to git@ and makes appropriate changes to colons and slashses
[ "Changes", "https", ":", "//", "in", ".", "git", "/", "config", "files", "to", "git" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_scripts/permit_gitrepo.py#L5-L22
train
This function allows you to permit git repository changes to colons and slashses
Erotemic/utool
utool/util_numpy.py
quantum_random
def quantum_random(): """ returns a 32 bit unsigned integer quantum random number """ import quantumrandom data16 = quantumrandom.uint16(array_length=2) assert data16.flags['C_CONTIGUOUS'] data32 = data16.view(np.dtype('uint32'))[0] return data32
python
def quantum_random(): """ returns a 32 bit unsigned integer quantum random number """ import quantumrandom data16 = quantumrandom.uint16(array_length=2) assert data16.flags['C_CONTIGUOUS'] data32 = data16.view(np.dtype('uint32'))[0] return data32
[ "def", "quantum_random", "(", ")", ":", "import", "quantumrandom", "data16", "=", "quantumrandom", ".", "uint16", "(", "array_length", "=", "2", ")", "assert", "data16", ".", "flags", "[", "'C_CONTIGUOUS'", "]", "data32", "=", "data16", ".", "view", "(", "...
returns a 32 bit unsigned integer quantum random number
[ "returns", "a", "32", "bit", "unsigned", "integer", "quantum", "random", "number" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L19-L25
train
returns a 32 bit unsigned integer quantum random number
Erotemic/utool
utool/util_numpy.py
_npstate_to_pystate
def _npstate_to_pystate(npstate): """ Convert state of a NumPy RandomState object to a state that can be used by Python's Random. References: https://stackoverflow.com/questions/44313620/converting-randomstate Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import *...
python
def _npstate_to_pystate(npstate): """ Convert state of a NumPy RandomState object to a state that can be used by Python's Random. References: https://stackoverflow.com/questions/44313620/converting-randomstate Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import *...
[ "def", "_npstate_to_pystate", "(", "npstate", ")", ":", "PY_VERSION", "=", "3", "version", ",", "keys", ",", "pos", ",", "has_gauss", ",", "cached_gaussian_", "=", "npstate", "keys_pos", "=", "tuple", "(", "map", "(", "int", ",", "keys", ")", ")", "+", ...
Convert state of a NumPy RandomState object to a state that can be used by Python's Random. References: https://stackoverflow.com/questions/44313620/converting-randomstate Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NOQA >>> from utool.util_numpy imp...
[ "Convert", "state", "of", "a", "NumPy", "RandomState", "object", "to", "a", "state", "that", "can", "be", "used", "by", "Python", "s", "Random", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L28-L52
train
Convert a NumPy RandomState object to a state that can be used by Python s Random.
Erotemic/utool
utool/util_numpy.py
_pystate_to_npstate
def _pystate_to_npstate(pystate): """ Convert state of a Python Random object to state usable by NumPy RandomState. References: https://stackoverflow.com/questions/44313620/converting-randomstate Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NOQA ...
python
def _pystate_to_npstate(pystate): """ Convert state of a Python Random object to state usable by NumPy RandomState. References: https://stackoverflow.com/questions/44313620/converting-randomstate Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NOQA ...
[ "def", "_pystate_to_npstate", "(", "pystate", ")", ":", "NP_VERSION", "=", "'MT19937'", "version", ",", "keys_pos_", ",", "cached_gaussian_", "=", "pystate", "keys", ",", "pos", "=", "keys_pos_", "[", ":", "-", "1", "]", ",", "keys_pos_", "[", "-", "1", ...
Convert state of a Python Random object to state usable by NumPy RandomState. References: https://stackoverflow.com/questions/44313620/converting-randomstate Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NOQA >>> from utool.util_numpy import _pystate_t...
[ "Convert", "state", "of", "a", "Python", "Random", "object", "to", "state", "usable", "by", "NumPy", "RandomState", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L55-L81
train
Convert a Python Random object to state usable by NumPy RandomState.
Erotemic/utool
utool/util_numpy.py
ensure_rng
def ensure_rng(rng, impl='numpy'): """ Returns a random number generator Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NOQA >>> import utool as ut >>> import numpy as np >>> num = 4 >>> print('--- Python as PYTHON ---') >>> py_rn...
python
def ensure_rng(rng, impl='numpy'): """ Returns a random number generator Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NOQA >>> import utool as ut >>> import numpy as np >>> num = 4 >>> print('--- Python as PYTHON ---') >>> py_rn...
[ "def", "ensure_rng", "(", "rng", ",", "impl", "=", "'numpy'", ")", ":", "if", "impl", "==", "'numpy'", ":", "if", "rng", "is", "None", ":", "rng", "=", "np", ".", "random", "elif", "isinstance", "(", "rng", ",", "int", ")", ":", "rng", "=", "np",...
Returns a random number generator Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NOQA >>> import utool as ut >>> import numpy as np >>> num = 4 >>> print('--- Python as PYTHON ---') >>> py_rng = random.Random(0) >>> pp_nums = [py_...
[ "Returns", "a", "random", "number", "generator" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L84-L139
train
Ensures that the random number generator is correct.
Erotemic/utool
utool/util_numpy.py
random_indexes
def random_indexes(max_index, subset_size=None, seed=None, rng=None): """ random unrepeated indicies Args: max_index (?): subset_size (None): (default = None) seed (None): (default = None) rng (RandomState): random number generator(default = None) Returns: ?: subst...
python
def random_indexes(max_index, subset_size=None, seed=None, rng=None): """ random unrepeated indicies Args: max_index (?): subset_size (None): (default = None) seed (None): (default = None) rng (RandomState): random number generator(default = None) Returns: ?: subst...
[ "def", "random_indexes", "(", "max_index", ",", "subset_size", "=", "None", ",", "seed", "=", "None", ",", "rng", "=", "None", ")", ":", "subst_", "=", "np", ".", "arange", "(", "0", ",", "max_index", ")", "rng", "=", "ensure_rng", "(", "seed", "if",...
random unrepeated indicies Args: max_index (?): subset_size (None): (default = None) seed (None): (default = None) rng (RandomState): random number generator(default = None) Returns: ?: subst CommandLine: python -m utool.util_numpy --exec-random_indexes ...
[ "random", "unrepeated", "indicies" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L142-L175
train
random unrepeated indicies
Erotemic/utool
utool/util_numpy.py
spaced_indexes
def spaced_indexes(len_, n, trunc=False): """ Returns n evenly spaced indexes. Returns as many as possible if trunc is true """ if n is None: return np.arange(len_) all_indexes = np.arange(len_) if trunc: n = min(len_, n) if n == 0: return np.empty(0) stride ...
python
def spaced_indexes(len_, n, trunc=False): """ Returns n evenly spaced indexes. Returns as many as possible if trunc is true """ if n is None: return np.arange(len_) all_indexes = np.arange(len_) if trunc: n = min(len_, n) if n == 0: return np.empty(0) stride ...
[ "def", "spaced_indexes", "(", "len_", ",", "n", ",", "trunc", "=", "False", ")", ":", "if", "n", "is", "None", ":", "return", "np", ".", "arange", "(", "len_", ")", "all_indexes", "=", "np", ".", "arange", "(", "len_", ")", "if", "trunc", ":", "n...
Returns n evenly spaced indexes. Returns as many as possible if trunc is true
[ "Returns", "n", "evenly", "spaced", "indexes", ".", "Returns", "as", "many", "as", "possible", "if", "trunc", "is", "true" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L201-L219
train
Returns n evenly spaced indexes.
Erotemic/utool
utool/util_numpy.py
intersect2d
def intersect2d(A, B): """ intersect2d intersect rows of 2d numpy arrays DEPRICATE: use intersect2d in vtool instead Args: A (ndarray[ndim=2]): B (ndarray[ndim=2]): Returns: tuple: (C, Ax, Bx) Example: >>> # ENABLE_DOCTEST >>> from utool.util_nump...
python
def intersect2d(A, B): """ intersect2d intersect rows of 2d numpy arrays DEPRICATE: use intersect2d in vtool instead Args: A (ndarray[ndim=2]): B (ndarray[ndim=2]): Returns: tuple: (C, Ax, Bx) Example: >>> # ENABLE_DOCTEST >>> from utool.util_nump...
[ "def", "intersect2d", "(", "A", ",", "B", ")", ":", "Cset", "=", "set", "(", "tuple", "(", "x", ")", "for", "x", "in", "A", ")", ".", "intersection", "(", "set", "(", "tuple", "(", "x", ")", "for", "x", "in", "B", ")", ")", "Ax", "=", "np",...
intersect2d intersect rows of 2d numpy arrays DEPRICATE: use intersect2d in vtool instead Args: A (ndarray[ndim=2]): B (ndarray[ndim=2]): Returns: tuple: (C, Ax, Bx) Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NOQA >>> impo...
[ "intersect2d" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L229-L259
train
intersect2d - function that returns the intersection of two numpy arrays
Erotemic/utool
utool/util_numpy.py
deterministic_shuffle
def deterministic_shuffle(list_, seed=0, rng=None): r""" Args: list_ (list): seed (int): Returns: list: list_ CommandLine: python -m utool.util_numpy --test-deterministic_shuffle Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NO...
python
def deterministic_shuffle(list_, seed=0, rng=None): r""" Args: list_ (list): seed (int): Returns: list: list_ CommandLine: python -m utool.util_numpy --test-deterministic_shuffle Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NO...
[ "def", "deterministic_shuffle", "(", "list_", ",", "seed", "=", "0", ",", "rng", "=", "None", ")", ":", "rng", "=", "ensure_rng", "(", "seed", "if", "rng", "is", "None", "else", "rng", ")", "rng", ".", "shuffle", "(", "list_", ")", "return", "list_" ...
r""" Args: list_ (list): seed (int): Returns: list: list_ CommandLine: python -m utool.util_numpy --test-deterministic_shuffle Example: >>> # ENABLE_DOCTEST >>> from utool.util_numpy import * # NOQA >>> list_ = [1, 2, 3, 4, 5, 6] >>> se...
[ "r", "Args", ":", "list_", "(", "list", ")", ":", "seed", "(", "int", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L270-L294
train
r Samples a list of the n - tuple of items in the order of the items in the order they appear.
Erotemic/utool
utool/util_numpy.py
random_sample
def random_sample(list_, nSample, strict=False, rng=None, seed=None): """ Grabs data randomly Args: list_ (list): nSample (?): strict (bool): (default = False) rng (module): random number generator(default = numpy.random) seed (None): (default = None) Returns: ...
python
def random_sample(list_, nSample, strict=False, rng=None, seed=None): """ Grabs data randomly Args: list_ (list): nSample (?): strict (bool): (default = False) rng (module): random number generator(default = numpy.random) seed (None): (default = None) Returns: ...
[ "def", "random_sample", "(", "list_", ",", "nSample", ",", "strict", "=", "False", ",", "rng", "=", "None", ",", "seed", "=", "None", ")", ":", "rng", "=", "ensure_rng", "(", "seed", "if", "rng", "is", "None", "else", "rng", ")", "if", "isinstance", ...
Grabs data randomly Args: list_ (list): nSample (?): strict (bool): (default = False) rng (module): random number generator(default = numpy.random) seed (None): (default = None) Returns: list: sample_list CommandLine: python -m utool.util_numpy --e...
[ "Grabs", "data", "randomly" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L323-L365
train
Returns a list of random samples from the list
Erotemic/utool
utool/util_numpy.py
deterministic_sample
def deterministic_sample(list_, nSample, seed=0, rng=None, strict=False): """ Grabs data randomly, but in a repeatable way """ rng = ensure_rng(seed if rng is None else rng) sample_list = random_sample(list_, nSample, strict=strict, rng=rng) return sample_list
python
def deterministic_sample(list_, nSample, seed=0, rng=None, strict=False): """ Grabs data randomly, but in a repeatable way """ rng = ensure_rng(seed if rng is None else rng) sample_list = random_sample(list_, nSample, strict=strict, rng=rng) return sample_list
[ "def", "deterministic_sample", "(", "list_", ",", "nSample", ",", "seed", "=", "0", ",", "rng", "=", "None", ",", "strict", "=", "False", ")", ":", "rng", "=", "ensure_rng", "(", "seed", "if", "rng", "is", "None", "else", "rng", ")", "sample_list", "...
Grabs data randomly, but in a repeatable way
[ "Grabs", "data", "randomly", "but", "in", "a", "repeatable", "way" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L368-L372
train
Grabs data randomly but in a repeatable way
Erotemic/utool
utool/util_numpy.py
spaced_items
def spaced_items(list_, n, **kwargs): """ Returns n evenly spaced items """ indexes = spaced_indexes(len(list_), n, **kwargs) items = list_[indexes] return items
python
def spaced_items(list_, n, **kwargs): """ Returns n evenly spaced items """ indexes = spaced_indexes(len(list_), n, **kwargs) items = list_[indexes] return items
[ "def", "spaced_items", "(", "list_", ",", "n", ",", "*", "*", "kwargs", ")", ":", "indexes", "=", "spaced_indexes", "(", "len", "(", "list_", ")", ",", "n", ",", "*", "*", "kwargs", ")", "items", "=", "list_", "[", "indexes", "]", "return", "items"...
Returns n evenly spaced items
[ "Returns", "n", "evenly", "spaced", "items" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L375-L379
train
Returns n evenly spaced items
Erotemic/utool
utool/util_numpy.py
sample_domain
def sample_domain(min_, max_, nSamp, mode='linear'): """ Example: >>> # ENABLE_DOCTEST >>> import utool >>> min_ = 10 >>> max_ = 1000 >>> nSamp = 7 >>> result = utool.sample_domain(min_, max_, nSamp) >>> print(result) [10, 151, 293, 434, 576, 717,...
python
def sample_domain(min_, max_, nSamp, mode='linear'): """ Example: >>> # ENABLE_DOCTEST >>> import utool >>> min_ = 10 >>> max_ = 1000 >>> nSamp = 7 >>> result = utool.sample_domain(min_, max_, nSamp) >>> print(result) [10, 151, 293, 434, 576, 717,...
[ "def", "sample_domain", "(", "min_", ",", "max_", ",", "nSamp", ",", "mode", "=", "'linear'", ")", ":", "if", "mode", "==", "'linear'", ":", "samples_", "=", "np", ".", "rint", "(", "np", ".", "linspace", "(", "min_", ",", "max_", ",", "nSamp", "+"...
Example: >>> # ENABLE_DOCTEST >>> import utool >>> min_ = 10 >>> max_ = 1000 >>> nSamp = 7 >>> result = utool.sample_domain(min_, max_, nSamp) >>> print(result) [10, 151, 293, 434, 576, 717, 859]
[ "Example", ":", ">>>", "#", "ENABLE_DOCTEST", ">>>", "import", "utool", ">>>", "min_", "=", "10", ">>>", "max_", "=", "1000", ">>>", "nSamp", "=", "7", ">>>", "result", "=", "utool", ".", "sample_domain", "(", "min_", "max_", "nSamp", ")", ">>>", "prin...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L382-L404
train
Sample the domain of the nSamp items.
dsoprea/NsqSpinner
nsq/node_collection.py
ServerNodes.get_servers
def get_servers(self, topic): """We're assuming that the static list of servers can serve the given topic, since we have to preexisting knowledge about them. """ return (nsq.node.ServerNode(sh) for sh in self.__server_hosts)
python
def get_servers(self, topic): """We're assuming that the static list of servers can serve the given topic, since we have to preexisting knowledge about them. """ return (nsq.node.ServerNode(sh) for sh in self.__server_hosts)
[ "def", "get_servers", "(", "self", ",", "topic", ")", ":", "return", "(", "nsq", ".", "node", ".", "ServerNode", "(", "sh", ")", "for", "sh", "in", "self", ".", "__server_hosts", ")" ]
We're assuming that the static list of servers can serve the given topic, since we have to preexisting knowledge about them.
[ "We", "re", "assuming", "that", "the", "static", "list", "of", "servers", "can", "serve", "the", "given", "topic", "since", "we", "have", "to", "preexisting", "knowledge", "about", "them", "." ]
972237b8ddce737983bfed001fde52e5236be695
https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/node_collection.py#L14-L19
train
Return a list of servers that can serve the given topic.
MoseleyBioinformaticsLab/ctfile
ctfile/tokenizer.py
tokenizer
def tokenizer(text): """A lexical analyzer for the `CTfile` formatted files. :param str text: `CTfile` formatted text. :return: Tuples of data. :rtype: py:class:`~collections.namedtuple` """ for entry in text.split('$$$$\n'): if entry.rstrip(): lines_stream = deque(entry.spl...
python
def tokenizer(text): """A lexical analyzer for the `CTfile` formatted files. :param str text: `CTfile` formatted text. :return: Tuples of data. :rtype: py:class:`~collections.namedtuple` """ for entry in text.split('$$$$\n'): if entry.rstrip(): lines_stream = deque(entry.spl...
[ "def", "tokenizer", "(", "text", ")", ":", "for", "entry", "in", "text", ".", "split", "(", "'$$$$\\n'", ")", ":", "if", "entry", ".", "rstrip", "(", ")", ":", "lines_stream", "=", "deque", "(", "entry", ".", "split", "(", "'\\n'", ")", ")", "else"...
A lexical analyzer for the `CTfile` formatted files. :param str text: `CTfile` formatted text. :return: Tuples of data. :rtype: py:class:`~collections.namedtuple`
[ "A", "lexical", "analyzer", "for", "the", "CTfile", "formatted", "files", "." ]
eae864126cd9102207df5d363a3222256a0f1396
https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/tokenizer.py#L48-L70
train
A lexical analyzer for the CTfile formatted text.
MoseleyBioinformaticsLab/ctfile
ctfile/tokenizer.py
_molfile
def _molfile(stream): """Process ``Molfile``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. """ yield MolfileStart() yield HeaderBlock(stream.popleft().strip(), stream.popleft().strip(), stream.popleft().strip()) ...
python
def _molfile(stream): """Process ``Molfile``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. """ yield MolfileStart() yield HeaderBlock(stream.popleft().strip(), stream.popleft().strip(), stream.popleft().strip()) ...
[ "def", "_molfile", "(", "stream", ")", ":", "yield", "MolfileStart", "(", ")", "yield", "HeaderBlock", "(", "stream", ".", "popleft", "(", ")", ".", "strip", "(", ")", ",", "stream", ".", "popleft", "(", ")", ".", "strip", "(", ")", ",", "stream", ...
Process ``Molfile``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data.
[ "Process", "Molfile", ".", ":", "param", "stream", ":", "Queue", "containing", "lines", "of", "text", ".", ":", "type", "stream", ":", ":", "py", ":", "class", ":", "collections", ".", "deque", ":", "return", ":", "Tuples", "of", "data", "." ]
eae864126cd9102207df5d363a3222256a0f1396
https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/tokenizer.py#L73-L85
train
Process Molfile.
MoseleyBioinformaticsLab/ctfile
ctfile/tokenizer.py
_ctab
def _ctab(stream): """Process ``Ctab``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. """ yield CtabBlockStart() counts_line = stream.popleft() counts_line_values = [counts_line[i:i + 3].strip() for i in range(0, ...
python
def _ctab(stream): """Process ``Ctab``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. """ yield CtabBlockStart() counts_line = stream.popleft() counts_line_values = [counts_line[i:i + 3].strip() for i in range(0, ...
[ "def", "_ctab", "(", "stream", ")", ":", "yield", "CtabBlockStart", "(", ")", "counts_line", "=", "stream", ".", "popleft", "(", ")", "counts_line_values", "=", "[", "counts_line", "[", "i", ":", "i", "+", "3", "]", ".", "strip", "(", ")", "for", "i"...
Process ``Ctab``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data.
[ "Process", "Ctab", ".", ":", "param", "stream", ":", "Queue", "containing", "lines", "of", "text", ".", ":", "type", "stream", ":", ":", "py", ":", "class", ":", "collections", ".", "deque", ":", "return", ":", "Tuples", "of", "data", "." ]
eae864126cd9102207df5d363a3222256a0f1396
https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/tokenizer.py#L102-L131
train
Process the Ctab.
MoseleyBioinformaticsLab/ctfile
ctfile/tokenizer.py
_ctab_atom_bond_block
def _ctab_atom_bond_block(number_of_lines, block_type, stream): """Process atom and bond blocks of ``Ctab``. :param number_of_lines: Number of lines to process from stream. :param block_type: :py:class:`collections.namedtuple` to use for data processing. :type block_type: :class:`~ctfile.tokenizer.Ctab...
python
def _ctab_atom_bond_block(number_of_lines, block_type, stream): """Process atom and bond blocks of ``Ctab``. :param number_of_lines: Number of lines to process from stream. :param block_type: :py:class:`collections.namedtuple` to use for data processing. :type block_type: :class:`~ctfile.tokenizer.Ctab...
[ "def", "_ctab_atom_bond_block", "(", "number_of_lines", ",", "block_type", ",", "stream", ")", ":", "for", "_", "in", "range", "(", "int", "(", "number_of_lines", ")", ")", ":", "line", "=", "stream", ".", "popleft", "(", ")", "yield", "block_type", "(", ...
Process atom and bond blocks of ``Ctab``. :param number_of_lines: Number of lines to process from stream. :param block_type: :py:class:`collections.namedtuple` to use for data processing. :type block_type: :class:`~ctfile.tokenizer.CtabAtomBlockLine` or :class:`~ctfile.tokenizer.CtabBondBlockLine` :par...
[ "Process", "atom", "and", "bond", "blocks", "of", "Ctab", "." ]
eae864126cd9102207df5d363a3222256a0f1396
https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/tokenizer.py#L134-L147
train
Process atom and bond blocks of Ctab.
MoseleyBioinformaticsLab/ctfile
ctfile/tokenizer.py
_ctab_property_block
def _ctab_property_block(stream): """Process properties block of ``Ctab``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. :rtype: :class:`~ctfile.tokenizer.CtabPropertiesBlockLine` """ line = stream.popleft() while lin...
python
def _ctab_property_block(stream): """Process properties block of ``Ctab``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. :rtype: :class:`~ctfile.tokenizer.CtabPropertiesBlockLine` """ line = stream.popleft() while lin...
[ "def", "_ctab_property_block", "(", "stream", ")", ":", "line", "=", "stream", ".", "popleft", "(", ")", "while", "line", "!=", "'M END'", ":", "name", "=", "line", ".", "split", "(", ")", "[", "1", "]", "yield", "CtabPropertiesBlockLine", "(", "name", ...
Process properties block of ``Ctab``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. :rtype: :class:`~ctfile.tokenizer.CtabPropertiesBlockLine`
[ "Process", "properties", "block", "of", "Ctab", "." ]
eae864126cd9102207df5d363a3222256a0f1396
https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/tokenizer.py#L150-L162
train
Process properties block of Ctab.
MoseleyBioinformaticsLab/ctfile
ctfile/tokenizer.py
_data_block
def _data_block(stream): """Process data block of ``CTfile``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. :rtype: :class:`~ctfile.tokenizer.DataHeader` or :class:`~ctfile.tokenizer.DataItem` """ while len(stream) > ...
python
def _data_block(stream): """Process data block of ``CTfile``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. :rtype: :class:`~ctfile.tokenizer.DataHeader` or :class:`~ctfile.tokenizer.DataItem` """ while len(stream) > ...
[ "def", "_data_block", "(", "stream", ")", ":", "while", "len", "(", "stream", ")", ">", "0", ":", "line", "=", "stream", ".", "popleft", "(", ")", "if", "line", ".", "startswith", "(", "'>'", ")", ":", "yield", "DataHeader", "(", "line", "[", "1", ...
Process data block of ``CTfile``. :param stream: Queue containing lines of text. :type stream: :py:class:`collections.deque` :return: Tuples of data. :rtype: :class:`~ctfile.tokenizer.DataHeader` or :class:`~ctfile.tokenizer.DataItem`
[ "Process", "data", "block", "of", "CTfile", ".", ":", "param", "stream", ":", "Queue", "containing", "lines", "of", "text", ".", ":", "type", "stream", ":", ":", "py", ":", "class", ":", "collections", ".", "deque", ":", "return", ":", "Tuples", "of", ...
eae864126cd9102207df5d363a3222256a0f1396
https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/tokenizer.py#L165-L183
train
Process data block of CTfile.
glormph/msstitch
src/app/drivers/pycolator/qvality.py
QvalityDriver.set_features
def set_features(self): """Creates scorefiles for qvality's target and decoy distributions""" self.scores = {} for t_or_d, feats in zip(['target', 'decoy'], [self.target, self.decoy]): self.scores[t_or_d] = {} self.sc...
python
def set_features(self): """Creates scorefiles for qvality's target and decoy distributions""" self.scores = {} for t_or_d, feats in zip(['target', 'decoy'], [self.target, self.decoy]): self.scores[t_or_d] = {} self.sc...
[ "def", "set_features", "(", "self", ")", ":", "self", ".", "scores", "=", "{", "}", "for", "t_or_d", ",", "feats", "in", "zip", "(", "[", "'target'", ",", "'decoy'", "]", ",", "[", "self", ".", "target", ",", "self", ".", "decoy", "]", ")", ":", ...
Creates scorefiles for qvality's target and decoy distributions
[ "Creates", "scorefiles", "for", "qvality", "s", "target", "and", "decoy", "distributions" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/qvality.py#L41-L51
train
Creates scorefiles for target and decoy distributions
glormph/msstitch
src/app/drivers/pycolator/qvality.py
QvalityDriver.write
def write(self): """This actually runs the qvality program from PATH.""" outfn = self.create_outfilepath(self.fn, self.outsuffix) command = ['qvality'] command.extend(self.qvalityoptions) command.extend([self.scores['target']['fn'], self.scores['decoy']['fn'], ...
python
def write(self): """This actually runs the qvality program from PATH.""" outfn = self.create_outfilepath(self.fn, self.outsuffix) command = ['qvality'] command.extend(self.qvalityoptions) command.extend([self.scores['target']['fn'], self.scores['decoy']['fn'], ...
[ "def", "write", "(", "self", ")", ":", "outfn", "=", "self", ".", "create_outfilepath", "(", "self", ".", "fn", ",", "self", ".", "outsuffix", ")", "command", "=", "[", "'qvality'", "]", "command", ".", "extend", "(", "self", ".", "qvalityoptions", ")"...
This actually runs the qvality program from PATH.
[ "This", "actually", "runs", "the", "qvality", "program", "from", "PATH", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/qvality.py#L53-L60
train
This actually runs the qvality program from PATH.
Erotemic/utool
utool/util_project.py
ensure_text
def ensure_text(fname, text, repo_dpath='.', force=None, locals_={}, chmod=None): """ Args: fname (str): file name text (str): repo_dpath (str): directory path string(default = '.') force (bool): (default = False) locals_ (dict): (default = {}) Example: >>>...
python
def ensure_text(fname, text, repo_dpath='.', force=None, locals_={}, chmod=None): """ Args: fname (str): file name text (str): repo_dpath (str): directory path string(default = '.') force (bool): (default = False) locals_ (dict): (default = {}) Example: >>>...
[ "def", "ensure_text", "(", "fname", ",", "text", ",", "repo_dpath", "=", "'.'", ",", "force", "=", "None", ",", "locals_", "=", "{", "}", ",", "chmod", "=", "None", ")", ":", "import", "utool", "as", "ut", "ut", ".", "colorprint", "(", "'Ensuring fna...
Args: fname (str): file name text (str): repo_dpath (str): directory path string(default = '.') force (bool): (default = False) locals_ (dict): (default = {}) Example: >>> # DISABLE_DOCTEST >>> from utool.util_project import * # NOQA >>> import uto...
[ "Args", ":", "fname", "(", "str", ")", ":", "file", "name", "text", "(", "str", ")", ":", "repo_dpath", "(", "str", ")", ":", "directory", "path", "string", "(", "default", "=", ".", ")", "force", "(", "bool", ")", ":", "(", "default", "=", "Fals...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_project.py#L20-L51
train
Ensures that the given text is valid.
Erotemic/utool
utool/util_project.py
setup_repo
def setup_repo(): r""" Creates default structure for a new repo CommandLine: python -m utool setup_repo --repo=dtool --codedir=~/code python -m utool setup_repo --repo=dtool --codedir=~/code python -m utool setup_repo --repo=ibeis-flukematch-module --codedir=~/code --modname=ibeis_...
python
def setup_repo(): r""" Creates default structure for a new repo CommandLine: python -m utool setup_repo --repo=dtool --codedir=~/code python -m utool setup_repo --repo=dtool --codedir=~/code python -m utool setup_repo --repo=ibeis-flukematch-module --codedir=~/code --modname=ibeis_...
[ "def", "setup_repo", "(", ")", ":", "print", "(", "'\\n [setup_repo]!'", ")", "# import os", "from", "functools", "import", "partial", "import", "utool", "as", "ut", "# import os", "code_dpath", "=", "ut", ".", "truepath", "(", "ut", ".", "get_argval", "(", ...
r""" Creates default structure for a new repo CommandLine: python -m utool setup_repo --repo=dtool --codedir=~/code python -m utool setup_repo --repo=dtool --codedir=~/code python -m utool setup_repo --repo=ibeis-flukematch-module --codedir=~/code --modname=ibeis_flukematch pyt...
[ "r", "Creates", "default", "structure", "for", "a", "new", "repo" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_project.py#L143-L499
train
r Sets up the default structure for a new repository
Erotemic/utool
utool/util_project.py
ensure_user_profile
def ensure_user_profile(user_profile=None): r""" Args: user_profile (UserProfile): (default = None) Returns: UserProfile: user_profile CommandLine: python -m utool.util_project --exec-ensure_user_profile --show Example: >>> # DISABLE_DOCTEST >>> from utool....
python
def ensure_user_profile(user_profile=None): r""" Args: user_profile (UserProfile): (default = None) Returns: UserProfile: user_profile CommandLine: python -m utool.util_project --exec-ensure_user_profile --show Example: >>> # DISABLE_DOCTEST >>> from utool....
[ "def", "ensure_user_profile", "(", "user_profile", "=", "None", ")", ":", "global", "__GLOBAL_PROFILE__", "if", "__GLOBAL_PROFILE__", "is", "None", ":", "import", "utool", "as", "ut", "if", "ut", ".", "is_developer", "(", ")", ":", "__GLOBAL_PROFILE__", "=", "...
r""" Args: user_profile (UserProfile): (default = None) Returns: UserProfile: user_profile CommandLine: python -m utool.util_project --exec-ensure_user_profile --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_project import * # NOQA >>> import...
[ "r", "Args", ":", "user_profile", "(", "UserProfile", ")", ":", "(", "default", "=", "None", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_project.py#L573-L603
train
r Ensure that the user_profile is set to the default user_profile.