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
chriso/gauged
gauged/drivers/postgresql.py
PostgreSQLDriver.add_namespace_statistics
def add_namespace_statistics(self, namespace, offset, data_points, byte_count): """Update namespace statistics for the period identified by offset""" query = 'UPDATE gauged_statistics ' \ 'SET data_points = data_points + %s,' \ 'byte_count...
python
def add_namespace_statistics(self, namespace, offset, data_points, byte_count): """Update namespace statistics for the period identified by offset""" query = 'UPDATE gauged_statistics ' \ 'SET data_points = data_points + %s,' \ 'byte_count...
[ "def", "add_namespace_statistics", "(", "self", ",", "namespace", ",", "offset", ",", "data_points", ",", "byte_count", ")", ":", "query", "=", "'UPDATE gauged_statistics '", "'SET data_points = data_points + %s,'", "'byte_count = byte_count + %s WHERE namespace = %s '", "'AND ...
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/postgresql.py#L285-L298
train
Update the namespace statistics for the period identified by namespace and offset.
chriso/gauged
gauged/drivers/postgresql.py
PostgreSQLDriver.create_schema
def create_schema(self): """Create all necessary tables""" execute = self.cursor.execute try: return execute('SELECT 1 FROM gauged_statistics') except self.psycopg2.ProgrammingError: pass self.db.rollback() execute("""CREATE TABLE IF NOT EXISTS gau...
python
def create_schema(self): """Create all necessary tables""" execute = self.cursor.execute try: return execute('SELECT 1 FROM gauged_statistics') except self.psycopg2.ProgrammingError: pass self.db.rollback() execute("""CREATE TABLE IF NOT EXISTS gau...
[ "def", "create_schema", "(", "self", ")", ":", "execute", "=", "self", ".", "cursor", ".", "execute", "try", ":", "return", "execute", "(", "'SELECT 1 FROM gauged_statistics'", ")", "except", "self", ".", "psycopg2", ".", "ProgrammingError", ":", "pass", "self...
Create all necessary tables
[ "Create", "all", "necessary", "tables" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/postgresql.py#L310-L366
train
Create all necessary tables for the given object.
chriso/gauged
gauged/drivers/postgresql.py
PostgreSQLDriver.drop_schema
def drop_schema(self): """Drop all gauged tables""" try: self.cursor.execute(""" DROP TABLE IF EXISTS gauged_data; DROP TABLE IF EXISTS gauged_keys; DROP TABLE IF EXISTS gauged_writer_history; DROP TABLE IF EXISTS gauged_cache; ...
python
def drop_schema(self): """Drop all gauged tables""" try: self.cursor.execute(""" DROP TABLE IF EXISTS gauged_data; DROP TABLE IF EXISTS gauged_keys; DROP TABLE IF EXISTS gauged_writer_history; DROP TABLE IF EXISTS gauged_cache; ...
[ "def", "drop_schema", "(", "self", ")", ":", "try", ":", "self", ".", "cursor", ".", "execute", "(", "\"\"\"\n DROP TABLE IF EXISTS gauged_data;\n DROP TABLE IF EXISTS gauged_keys;\n DROP TABLE IF EXISTS gauged_writer_history;\n ...
Drop all gauged tables
[ "Drop", "all", "gauged", "tables" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/postgresql.py#L378-L390
train
Drop all gauged tables and all tables in the database.
crdoconnor/faketime
faketime/__init__.py
get_environment_vars
def get_environment_vars(filename): """Return a dict of environment variables required to run a service under faketime.""" if sys.platform == "linux" or sys.platform == "linux2": return { 'LD_PRELOAD': path.join(LIBFAKETIME_DIR, "libfaketime.so.1"), 'FAKETIME_SKIP_CMDS': 'nodejs'...
python
def get_environment_vars(filename): """Return a dict of environment variables required to run a service under faketime.""" if sys.platform == "linux" or sys.platform == "linux2": return { 'LD_PRELOAD': path.join(LIBFAKETIME_DIR, "libfaketime.so.1"), 'FAKETIME_SKIP_CMDS': 'nodejs'...
[ "def", "get_environment_vars", "(", "filename", ")", ":", "if", "sys", ".", "platform", "==", "\"linux\"", "or", "sys", ".", "platform", "==", "\"linux2\"", ":", "return", "{", "'LD_PRELOAD'", ":", "path", ".", "join", "(", "LIBFAKETIME_DIR", ",", "\"libfake...
Return a dict of environment variables required to run a service under faketime.
[ "Return", "a", "dict", "of", "environment", "variables", "required", "to", "run", "a", "service", "under", "faketime", "." ]
6e81ca070c0e601a52507b945ed45d5d42576b21
https://github.com/crdoconnor/faketime/blob/6e81ca070c0e601a52507b945ed45d5d42576b21/faketime/__init__.py#L9-L24
train
Return a dict of environment variables required to run a service under faketime.
crdoconnor/faketime
faketime/__init__.py
change_time
def change_time(filename, newtime): """Change the time of a process or group of processes by writing a new time to the time file.""" with open(filename, "w") as faketimetxt_handle: faketimetxt_handle.write("@" + newtime.strftime("%Y-%m-%d %H:%M:%S"))
python
def change_time(filename, newtime): """Change the time of a process or group of processes by writing a new time to the time file.""" with open(filename, "w") as faketimetxt_handle: faketimetxt_handle.write("@" + newtime.strftime("%Y-%m-%d %H:%M:%S"))
[ "def", "change_time", "(", "filename", ",", "newtime", ")", ":", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "faketimetxt_handle", ":", "faketimetxt_handle", ".", "write", "(", "\"@\"", "+", "newtime", ".", "strftime", "(", "\"%Y-%m-%d %H:%M:%S\"...
Change the time of a process or group of processes by writing a new time to the time file.
[ "Change", "the", "time", "of", "a", "process", "or", "group", "of", "processes", "by", "writing", "a", "new", "time", "to", "the", "time", "file", "." ]
6e81ca070c0e601a52507b945ed45d5d42576b21
https://github.com/crdoconnor/faketime/blob/6e81ca070c0e601a52507b945ed45d5d42576b21/faketime/__init__.py#L27-L30
train
Change the time of a process or group of processes by writing a new time to the time file.
glormph/msstitch
src/app/actions/pycolator/filters.py
filter_known_searchspace
def filter_known_searchspace(elements, seqtype, lookup, ns, ntermwildcards, deamidation): """Yields peptides from generator as long as their sequence is not found in known search space dict. Useful for excluding peptides that are found in e.g. ENSEMBL or similar""" for eleme...
python
def filter_known_searchspace(elements, seqtype, lookup, ns, ntermwildcards, deamidation): """Yields peptides from generator as long as their sequence is not found in known search space dict. Useful for excluding peptides that are found in e.g. ENSEMBL or similar""" for eleme...
[ "def", "filter_known_searchspace", "(", "elements", ",", "seqtype", ",", "lookup", ",", "ns", ",", "ntermwildcards", ",", "deamidation", ")", ":", "for", "element", "in", "elements", ":", "seq_is_known", "=", "False", "for", "seq", "in", "get_seqs_from_element",...
Yields peptides from generator as long as their sequence is not found in known search space dict. Useful for excluding peptides that are found in e.g. ENSEMBL or similar
[ "Yields", "peptides", "from", "generator", "as", "long", "as", "their", "sequence", "is", "not", "found", "in", "known", "search", "space", "dict", ".", "Useful", "for", "excluding", "peptides", "that", "are", "found", "in", "e", ".", "g", ".", "ENSEMBL", ...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/pycolator/filters.py#L67-L81
train
Yields peptides from generator as long as their sequence is not found in the known search space dict. Useful for excluding peptides that are not found in the known search space.
glormph/msstitch
src/app/actions/pycolator/filters.py
filter_unique_peptides
def filter_unique_peptides(peptides, score, ns): """ Filters unique peptides from multiple Percolator output XML files. Takes a dir with a set of XMLs, a score to filter on and a namespace. Outputs an ElementTree. """ scores = {'q': 'q_value', 'pep': 'pep', 'p': '...
python
def filter_unique_peptides(peptides, score, ns): """ Filters unique peptides from multiple Percolator output XML files. Takes a dir with a set of XMLs, a score to filter on and a namespace. Outputs an ElementTree. """ scores = {'q': 'q_value', 'pep': 'pep', 'p': '...
[ "def", "filter_unique_peptides", "(", "peptides", ",", "score", ",", "ns", ")", ":", "scores", "=", "{", "'q'", ":", "'q_value'", ",", "'pep'", ":", "'pep'", ",", "'p'", ":", "'p_value'", ",", "'svm'", ":", "'svm_score'", "}", "highest", "=", "{", "}",...
Filters unique peptides from multiple Percolator output XML files. Takes a dir with a set of XMLs, a score to filter on and a namespace. Outputs an ElementTree.
[ "Filters", "unique", "peptides", "from", "multiple", "Percolator", "output", "XML", "files", ".", "Takes", "a", "dir", "with", "a", "set", "of", "XMLs", "a", "score", "to", "filter", "on", "and", "a", "namespace", ".", "Outputs", "an", "ElementTree", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/pycolator/filters.py#L102-L136
train
Filters unique peptides from multiple Percolator output XML files.
timedata-org/loady
loady/importer.py
import_symbol
def import_symbol(name=None, path=None, typename=None, base_path=None): """ Import a module, or a typename within a module from its name. Arguments: name: An absolute or relative (starts with a .) Python path path: If name is relative, path is prepended to it. base_path: (DEPRECATED) Same as p...
python
def import_symbol(name=None, path=None, typename=None, base_path=None): """ Import a module, or a typename within a module from its name. Arguments: name: An absolute or relative (starts with a .) Python path path: If name is relative, path is prepended to it. base_path: (DEPRECATED) Same as p...
[ "def", "import_symbol", "(", "name", "=", "None", ",", "path", "=", "None", ",", "typename", "=", "None", ",", "base_path", "=", "None", ")", ":", "_", ",", "symbol", "=", "_import", "(", "name", "or", "typename", ",", "path", "or", "base_path", ")",...
Import a module, or a typename within a module from its name. Arguments: name: An absolute or relative (starts with a .) Python path path: If name is relative, path is prepended to it. base_path: (DEPRECATED) Same as path typename: (DEPRECATED) Same as path
[ "Import", "a", "module", "or", "a", "typename", "within", "a", "module", "from", "its", "name", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/importer.py#L35-L47
train
Imports a module or a typename within a module from its name.
Erotemic/utool
utool/util_win32.py
add_to_win32_PATH
def add_to_win32_PATH(script_fpath, *add_path_list): r""" Writes a registery script to update the PATH variable into the sync registry CommandLine: python -m utool.util_win32 --test-add_to_win32_PATH --newpath "C:\Program Files (x86)\Graphviz2.38\bin" Example: >>> # DISABLE_DOCTEST ...
python
def add_to_win32_PATH(script_fpath, *add_path_list): r""" Writes a registery script to update the PATH variable into the sync registry CommandLine: python -m utool.util_win32 --test-add_to_win32_PATH --newpath "C:\Program Files (x86)\Graphviz2.38\bin" Example: >>> # DISABLE_DOCTEST ...
[ "def", "add_to_win32_PATH", "(", "script_fpath", ",", "*", "add_path_list", ")", ":", "import", "utool", "as", "ut", "write_dir", "=", "dirname", "(", "script_fpath", ")", "key", "=", "'[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment]'"...
r""" Writes a registery script to update the PATH variable into the sync registry CommandLine: python -m utool.util_win32 --test-add_to_win32_PATH --newpath "C:\Program Files (x86)\Graphviz2.38\bin" Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> from utool.util_win32 impor...
[ "r", "Writes", "a", "registery", "script", "to", "update", "the", "PATH", "variable", "into", "the", "sync", "registry" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_win32.py#L60-L91
train
r Adds a registery script to update the PATH variable in the sync registry
Erotemic/utool
utool/util_dict.py
dzip
def dzip(list1, list2): r""" Zips elementwise pairs between list1 and list2 into a dictionary. Values from list2 can be broadcast onto list1. Args: list1 (sequence): full sequence list2 (sequence): can either be a sequence of one item or a sequence of equal length to `list1`...
python
def dzip(list1, list2): r""" Zips elementwise pairs between list1 and list2 into a dictionary. Values from list2 can be broadcast onto list1. Args: list1 (sequence): full sequence list2 (sequence): can either be a sequence of one item or a sequence of equal length to `list1`...
[ "def", "dzip", "(", "list1", ",", "list2", ")", ":", "try", ":", "len", "(", "list1", ")", "except", "TypeError", ":", "list1", "=", "list", "(", "list1", ")", "try", ":", "len", "(", "list2", ")", "except", "TypeError", ":", "list2", "=", "list", ...
r""" Zips elementwise pairs between list1 and list2 into a dictionary. Values from list2 can be broadcast onto list1. Args: list1 (sequence): full sequence list2 (sequence): can either be a sequence of one item or a sequence of equal length to `list1` SeeAlso: util_...
[ "r", "Zips", "elementwise", "pairs", "between", "list1", "and", "list2", "into", "a", "dictionary", ".", "Values", "from", "list2", "can", "be", "broadcast", "onto", "list1", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L25-L76
train
r Dzips elements of list1 and list2 into a dictionary.
Erotemic/utool
utool/util_dict.py
get_dict_hashid
def get_dict_hashid(dict_): r""" Args: dict_ (dict): Returns: int: id hash References: http://stackoverflow.com/questions/5884066/hashing-a-python-dictionary CommandLine: python -m utool.util_dict --test-get_dict_hashid python3 -m utool.util_dict --test-get...
python
def get_dict_hashid(dict_): r""" Args: dict_ (dict): Returns: int: id hash References: http://stackoverflow.com/questions/5884066/hashing-a-python-dictionary CommandLine: python -m utool.util_dict --test-get_dict_hashid python3 -m utool.util_dict --test-get...
[ "def", "get_dict_hashid", "(", "dict_", ")", ":", "import", "utool", "as", "ut", "raw_text", "=", "ut", ".", "repr4", "(", "dict_", ",", "sorted_", "=", "True", ",", "strvals", "=", "True", ",", "nl", "=", "2", ")", "#print('raw_text = %r' % (raw_text,))",...
r""" Args: dict_ (dict): Returns: int: id hash References: http://stackoverflow.com/questions/5884066/hashing-a-python-dictionary CommandLine: python -m utool.util_dict --test-get_dict_hashid python3 -m utool.util_dict --test-get_dict_hashid Example: ...
[ "r", "Args", ":", "dict_", "(", "dict", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L228-L265
train
r Returns the hashid of the dict
Erotemic/utool
utool/util_dict.py
dict_stack
def dict_stack(dict_list, key_prefix=''): r""" stacks values from two dicts into a new dict where the values are list of the input values. the keys are the same. DEPRICATE in favor of dict_stack2 Args: dict_list (list): list of dicts with similar keys Returns: dict dict_stacke...
python
def dict_stack(dict_list, key_prefix=''): r""" stacks values from two dicts into a new dict where the values are list of the input values. the keys are the same. DEPRICATE in favor of dict_stack2 Args: dict_list (list): list of dicts with similar keys Returns: dict dict_stacke...
[ "def", "dict_stack", "(", "dict_list", ",", "key_prefix", "=", "''", ")", ":", "dict_stacked_", "=", "defaultdict", "(", "list", ")", "for", "dict_", "in", "dict_list", ":", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "dict_", ")", ":...
r""" stacks values from two dicts into a new dict where the values are list of the input values. the keys are the same. DEPRICATE in favor of dict_stack2 Args: dict_list (list): list of dicts with similar keys Returns: dict dict_stacked CommandLine: python -m utool.ut...
[ "r", "stacks", "values", "from", "two", "dicts", "into", "a", "new", "dict", "where", "the", "values", "are", "list", "of", "the", "input", "values", ".", "the", "keys", "are", "the", "same", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L332-L379
train
r Stacks values from two dicts into a new dict where the keys are the same.
Erotemic/utool
utool/util_dict.py
dict_stack2
def dict_stack2(dict_list, key_suffix=None, default=None): """ Stacks vals from a list of dicts into a dict of lists. Inserts Nones in place of empty items to preserve order. Args: dict_list (list): list of dicts key_suffix (str): (default = None) Returns: dict: stacked_dic...
python
def dict_stack2(dict_list, key_suffix=None, default=None): """ Stacks vals from a list of dicts into a dict of lists. Inserts Nones in place of empty items to preserve order. Args: dict_list (list): list of dicts key_suffix (str): (default = None) Returns: dict: stacked_dic...
[ "def", "dict_stack2", "(", "dict_list", ",", "key_suffix", "=", "None", ",", "default", "=", "None", ")", ":", "if", "len", "(", "dict_list", ")", ">", "0", ":", "dict_list_", "=", "[", "map_dict_vals", "(", "lambda", "x", ":", "[", "x", "]", ",", ...
Stacks vals from a list of dicts into a dict of lists. Inserts Nones in place of empty items to preserve order. Args: dict_list (list): list of dicts key_suffix (str): (default = None) Returns: dict: stacked_dict Example: >>> # ENABLE_DOCTEST >>> # Usual case: ...
[ "Stacks", "vals", "from", "a", "list", "of", "dicts", "into", "a", "dict", "of", "lists", ".", "Inserts", "Nones", "in", "place", "of", "empty", "items", "to", "preserve", "order", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L382-L496
train
This function will stacks vals from a list of dicts into a dict of lists.
Erotemic/utool
utool/util_dict.py
invert_dict
def invert_dict(dict_, unique_vals=True): """ Reverses the keys and values in a dictionary. Set unique_vals to False if the values in the dict are not unique. Args: dict_ (dict_): dictionary unique_vals (bool): if False, inverted keys are returned in a list. Returns: dict: ...
python
def invert_dict(dict_, unique_vals=True): """ Reverses the keys and values in a dictionary. Set unique_vals to False if the values in the dict are not unique. Args: dict_ (dict_): dictionary unique_vals (bool): if False, inverted keys are returned in a list. Returns: dict: ...
[ "def", "invert_dict", "(", "dict_", ",", "unique_vals", "=", "True", ")", ":", "if", "unique_vals", ":", "inverted_items", "=", "[", "(", "val", ",", "key", ")", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "dict_", ")", "]", "invert...
Reverses the keys and values in a dictionary. Set unique_vals to False if the values in the dict are not unique. Args: dict_ (dict_): dictionary unique_vals (bool): if False, inverted keys are returned in a list. Returns: dict: inverted_dict CommandLine: python -m utoo...
[ "Reverses", "the", "keys", "and", "values", "in", "a", "dictionary", ".", "Set", "unique_vals", "to", "False", "if", "the", "values", "in", "the", "dict", "are", "not", "unique", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L499-L550
train
Invert the keys and values of a dictionary.
Erotemic/utool
utool/util_dict.py
iter_all_dict_combinations_ordered
def iter_all_dict_combinations_ordered(varied_dict): """ Same as all_dict_combinations but preserves order """ tups_list = [[(key, val) for val in val_list] for (key, val_list) in six.iteritems(varied_dict)] dict_iter = (OrderedDict(tups) for tups in it.product(*tups_list)) retu...
python
def iter_all_dict_combinations_ordered(varied_dict): """ Same as all_dict_combinations but preserves order """ tups_list = [[(key, val) for val in val_list] for (key, val_list) in six.iteritems(varied_dict)] dict_iter = (OrderedDict(tups) for tups in it.product(*tups_list)) retu...
[ "def", "iter_all_dict_combinations_ordered", "(", "varied_dict", ")", ":", "tups_list", "=", "[", "[", "(", "key", ",", "val", ")", "for", "val", "in", "val_list", "]", "for", "(", "key", ",", "val_list", ")", "in", "six", ".", "iteritems", "(", "varied_...
Same as all_dict_combinations but preserves order
[ "Same", "as", "all_dict_combinations", "but", "preserves", "order" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L553-L560
train
Same as all_dict_combinations but preserves order
Erotemic/utool
utool/util_dict.py
all_dict_combinations
def all_dict_combinations(varied_dict): """ all_dict_combinations Args: varied_dict (dict): a dict with lists of possible parameter settings Returns: list: dict_list a list of dicts correpsonding to all combinations of params settings CommandLine: python -m utool.util_dic...
python
def all_dict_combinations(varied_dict): """ all_dict_combinations Args: varied_dict (dict): a dict with lists of possible parameter settings Returns: list: dict_list a list of dicts correpsonding to all combinations of params settings CommandLine: python -m utool.util_dic...
[ "def", "all_dict_combinations", "(", "varied_dict", ")", ":", "#tups_list = [[(key, val) for val in val_list]", "# if isinstance(val_list, (list, tuple))", "# else [(key, val_list)]", "# for (key, val_list) in six.iteritems(varied_dict)]", "tups_list", "=", ...
all_dict_combinations Args: varied_dict (dict): a dict with lists of possible parameter settings Returns: list: dict_list a list of dicts correpsonding to all combinations of params settings CommandLine: python -m utool.util_dict --test-all_dict_combinations Example: ...
[ "all_dict_combinations" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L571-L614
train
A function that returns a list of dicts correpsonding to all combinations of params settings
Erotemic/utool
utool/util_dict.py
all_dict_combinations_lbls
def all_dict_combinations_lbls(varied_dict, remove_singles=True, allow_lone_singles=False): """ returns a label for each variation in a varydict. It tries to not be oververbose and returns only what parameters are varied in each label. CommandLine: python -m utool.util_dict --test-all_dict...
python
def all_dict_combinations_lbls(varied_dict, remove_singles=True, allow_lone_singles=False): """ returns a label for each variation in a varydict. It tries to not be oververbose and returns only what parameters are varied in each label. CommandLine: python -m utool.util_dict --test-all_dict...
[ "def", "all_dict_combinations_lbls", "(", "varied_dict", ",", "remove_singles", "=", "True", ",", "allow_lone_singles", "=", "False", ")", ":", "is_lone_single", "=", "all", "(", "[", "isinstance", "(", "val_list", ",", "(", "list", ",", "tuple", ")", ")", "...
returns a label for each variation in a varydict. It tries to not be oververbose and returns only what parameters are varied in each label. CommandLine: python -m utool.util_dict --test-all_dict_combinations_lbls python -m utool.util_dict --exec-all_dict_combinations_lbls:1 Example: ...
[ "returns", "a", "label", "for", "each", "variation", "in", "a", "varydict", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L617-L681
train
This function returns a list of all the varied_dict combinations of the varied_dict.
Erotemic/utool
utool/util_dict.py
build_conflict_dict
def build_conflict_dict(key_list, val_list): """ Builds dict where a list of values is associated with more than one key Args: key_list (list): val_list (list): Returns: dict: key_to_vals CommandLine: python -m utool.util_dict --test-build_conflict_dict Exampl...
python
def build_conflict_dict(key_list, val_list): """ Builds dict where a list of values is associated with more than one key Args: key_list (list): val_list (list): Returns: dict: key_to_vals CommandLine: python -m utool.util_dict --test-build_conflict_dict Exampl...
[ "def", "build_conflict_dict", "(", "key_list", ",", "val_list", ")", ":", "key_to_vals", "=", "defaultdict", "(", "list", ")", "for", "key", ",", "val", "in", "zip", "(", "key_list", ",", "val_list", ")", ":", "key_to_vals", "[", "key", "]", ".", "append...
Builds dict where a list of values is associated with more than one key Args: key_list (list): val_list (list): Returns: dict: key_to_vals CommandLine: python -m utool.util_dict --test-build_conflict_dict Example: >>> # ENABLE_DOCTEST >>> from utool.ut...
[ "Builds", "dict", "where", "a", "list", "of", "values", "is", "associated", "with", "more", "than", "one", "key" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L692-L724
train
Build dict where a list of values is associated with more than one key
Erotemic/utool
utool/util_dict.py
assert_keys_are_subset
def assert_keys_are_subset(dict1, dict2): """ Example: >>> # DISABLE_DOCTEST >>> dict1 = {1:1, 2:2, 3:3} >>> dict2 = {2:3, 3:3} >>> assert_keys_are_subset(dict1, dict2) >>> #dict2 = {4:3, 3:3} """ keys1 = set(dict1.keys()) keys2 = set(dict2.keys()) unknown...
python
def assert_keys_are_subset(dict1, dict2): """ Example: >>> # DISABLE_DOCTEST >>> dict1 = {1:1, 2:2, 3:3} >>> dict2 = {2:3, 3:3} >>> assert_keys_are_subset(dict1, dict2) >>> #dict2 = {4:3, 3:3} """ keys1 = set(dict1.keys()) keys2 = set(dict2.keys()) unknown...
[ "def", "assert_keys_are_subset", "(", "dict1", ",", "dict2", ")", ":", "keys1", "=", "set", "(", "dict1", ".", "keys", "(", ")", ")", "keys2", "=", "set", "(", "dict2", ".", "keys", "(", ")", ")", "unknown_keys", "=", "keys2", ".", "difference", "(",...
Example: >>> # DISABLE_DOCTEST >>> dict1 = {1:1, 2:2, 3:3} >>> dict2 = {2:3, 3:3} >>> assert_keys_are_subset(dict1, dict2) >>> #dict2 = {4:3, 3:3}
[ "Example", ":", ">>>", "#", "DISABLE_DOCTEST", ">>>", "dict1", "=", "{", "1", ":", "1", "2", ":", "2", "3", ":", "3", "}", ">>>", "dict2", "=", "{", "2", ":", "3", "3", ":", "3", "}", ">>>", "assert_keys_are_subset", "(", "dict1", "dict2", ")", ...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L727-L739
train
Test that the keys of dict1 and dict2 are a subset of those keys.
Erotemic/utool
utool/util_dict.py
update_existing
def update_existing(dict1, dict2, copy=False, assert_exists=False, iswarning=False, alias_dict=None): r""" updates vals in dict1 using vals from dict2 only if the key is already in dict1. Args: dict1 (dict): dict2 (dict): copy (bool): if true modifies diction...
python
def update_existing(dict1, dict2, copy=False, assert_exists=False, iswarning=False, alias_dict=None): r""" updates vals in dict1 using vals from dict2 only if the key is already in dict1. Args: dict1 (dict): dict2 (dict): copy (bool): if true modifies diction...
[ "def", "update_existing", "(", "dict1", ",", "dict2", ",", "copy", "=", "False", ",", "assert_exists", "=", "False", ",", "iswarning", "=", "False", ",", "alias_dict", "=", "None", ")", ":", "if", "assert_exists", ":", "try", ":", "assert_keys_are_subset", ...
r""" updates vals in dict1 using vals from dict2 only if the key is already in dict1. Args: dict1 (dict): dict2 (dict): copy (bool): if true modifies dictionary in place (default = False) assert_exists (bool): if True throws error if new key specified (default = False) ...
[ "r", "updates", "vals", "in", "dict1", "using", "vals", "from", "dict2", "only", "if", "the", "key", "is", "already", "in", "dict1", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L751-L796
train
r Updates the values in dict1 using vals from dict2 only if the key is already in dict1.
Erotemic/utool
utool/util_dict.py
dict_update_newkeys
def dict_update_newkeys(dict_, dict2): """ Like dict.update, but does not overwrite items """ for key, val in six.iteritems(dict2): if key not in dict_: dict_[key] = val
python
def dict_update_newkeys(dict_, dict2): """ Like dict.update, but does not overwrite items """ for key, val in six.iteritems(dict2): if key not in dict_: dict_[key] = val
[ "def", "dict_update_newkeys", "(", "dict_", ",", "dict2", ")", ":", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "dict2", ")", ":", "if", "key", "not", "in", "dict_", ":", "dict_", "[", "key", "]", "=", "val" ]
Like dict.update, but does not overwrite items
[ "Like", "dict", ".", "update", "but", "does", "not", "overwrite", "items" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L810-L814
train
Like dict. update but does not overwrite items
Erotemic/utool
utool/util_dict.py
is_dicteq
def is_dicteq(dict1_, dict2_, almosteq_ok=True, verbose_err=True): """ Checks to see if dicts are the same. Performs recursion. Handles numpy """ import utool as ut assert len(dict1_) == len(dict2_), 'dicts are not of same length' try: for (key1, val1), (key2, val2) in zip(dict1_.items(), dict2_...
python
def is_dicteq(dict1_, dict2_, almosteq_ok=True, verbose_err=True): """ Checks to see if dicts are the same. Performs recursion. Handles numpy """ import utool as ut assert len(dict1_) == len(dict2_), 'dicts are not of same length' try: for (key1, val1), (key2, val2) in zip(dict1_.items(), dict2_...
[ "def", "is_dicteq", "(", "dict1_", ",", "dict2_", ",", "almosteq_ok", "=", "True", ",", "verbose_err", "=", "True", ")", ":", "import", "utool", "as", "ut", "assert", "len", "(", "dict1_", ")", "==", "len", "(", "dict2_", ")", ",", "'dicts are not of sam...
Checks to see if dicts are the same. Performs recursion. Handles numpy
[ "Checks", "to", "see", "if", "dicts", "are", "the", "same", ".", "Performs", "recursion", ".", "Handles", "numpy" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L817-L838
train
Checks to see if dicts are the same.
Erotemic/utool
utool/util_dict.py
dict_subset
def dict_subset(dict_, keys, default=util_const.NoParam): r""" Args: dict_ (dict): keys (list): Returns: dict: subset dictionary Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> dict_ = {'K': 3, '...
python
def dict_subset(dict_, keys, default=util_const.NoParam): r""" Args: dict_ (dict): keys (list): Returns: dict: subset dictionary Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> dict_ = {'K': 3, '...
[ "def", "dict_subset", "(", "dict_", ",", "keys", ",", "default", "=", "util_const", ".", "NoParam", ")", ":", "if", "default", "is", "util_const", ".", "NoParam", ":", "items", "=", "dict_take", "(", "dict_", ",", "keys", ")", "else", ":", "items", "="...
r""" Args: dict_ (dict): keys (list): Returns: dict: subset dictionary Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> dict_ = {'K': 3, 'dcvs_clip_max': 0.2, 'p': 0.1} >>> keys = ['K', 'dcvs_...
[ "r", "Args", ":", "dict_", "(", "dict", ")", ":", "keys", "(", "list", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L841-L870
train
r Returns a subset of a dictionary
Erotemic/utool
utool/util_dict.py
dict_setdiff
def dict_setdiff(dict_, negative_keys): r""" returns a copy of dict_ without keys in the negative_keys list Args: dict_ (dict): negative_keys (list): """ keys = [key for key in six.iterkeys(dict_) if key not in set(negative_keys)] subdict_ = dict_subset(dict_, keys) ...
python
def dict_setdiff(dict_, negative_keys): r""" returns a copy of dict_ without keys in the negative_keys list Args: dict_ (dict): negative_keys (list): """ keys = [key for key in six.iterkeys(dict_) if key not in set(negative_keys)] subdict_ = dict_subset(dict_, keys) ...
[ "def", "dict_setdiff", "(", "dict_", ",", "negative_keys", ")", ":", "keys", "=", "[", "key", "for", "key", "in", "six", ".", "iterkeys", "(", "dict_", ")", "if", "key", "not", "in", "set", "(", "negative_keys", ")", "]", "subdict_", "=", "dict_subset"...
r""" returns a copy of dict_ without keys in the negative_keys list Args: dict_ (dict): negative_keys (list):
[ "r", "returns", "a", "copy", "of", "dict_", "without", "keys", "in", "the", "negative_keys", "list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L877-L888
train
r Returns a copy of dict_ with keys in the negative_keys list
Erotemic/utool
utool/util_dict.py
delete_dict_keys
def delete_dict_keys(dict_, key_list): r""" Removes items from a dictionary inplace. Keys that do not exist are ignored. Args: dict_ (dict): dict like object with a __del__ attribute key_list (list): list of keys that specify the items to remove CommandLine: python -m utool...
python
def delete_dict_keys(dict_, key_list): r""" Removes items from a dictionary inplace. Keys that do not exist are ignored. Args: dict_ (dict): dict like object with a __del__ attribute key_list (list): list of keys that specify the items to remove CommandLine: python -m utool...
[ "def", "delete_dict_keys", "(", "dict_", ",", "key_list", ")", ":", "invalid_keys", "=", "set", "(", "key_list", ")", "-", "set", "(", "dict_", ".", "keys", "(", ")", ")", "valid_keys", "=", "set", "(", "key_list", ")", "-", "invalid_keys", "for", "key...
r""" Removes items from a dictionary inplace. Keys that do not exist are ignored. Args: dict_ (dict): dict like object with a __del__ attribute key_list (list): list of keys that specify the items to remove CommandLine: python -m utool.util_dict --test-delete_dict_keys Exa...
[ "r", "Removes", "items", "from", "a", "dictionary", "inplace", ".", "Keys", "that", "do", "not", "exist", "are", "ignored", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L891-L919
train
r Delete items from a dictionary inplace.
Erotemic/utool
utool/util_dict.py
dict_take_gen
def dict_take_gen(dict_, keys, *d): r""" generate multiple values from a dictionary Args: dict_ (dict): keys (list): Varargs: d: if specified is default for key errors CommandLine: python -m utool.util_dict --test-dict_take_gen Example1: >>> # ENABLE_D...
python
def dict_take_gen(dict_, keys, *d): r""" generate multiple values from a dictionary Args: dict_ (dict): keys (list): Varargs: d: if specified is default for key errors CommandLine: python -m utool.util_dict --test-dict_take_gen Example1: >>> # ENABLE_D...
[ "def", "dict_take_gen", "(", "dict_", ",", "keys", ",", "*", "d", ")", ":", "if", "isinstance", "(", "keys", ",", "six", ".", "string_types", ")", ":", "# hack for string keys that makes copy-past easier", "keys", "=", "keys", ".", "split", "(", "', '", ")",...
r""" generate multiple values from a dictionary Args: dict_ (dict): keys (list): Varargs: d: if specified is default for key errors CommandLine: python -m utool.util_dict --test-dict_take_gen Example1: >>> # ENABLE_DOCTEST >>> from utool.util_dict ...
[ "r", "generate", "multiple", "values", "from", "a", "dictionary" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L925-L979
train
r generator function for generating multiple values from a dictionary
Erotemic/utool
utool/util_dict.py
dict_take
def dict_take(dict_, keys, *d): """ get multiple values from a dictionary """ try: return list(dict_take_gen(dict_, keys, *d)) except TypeError: return list(dict_take_gen(dict_, keys, *d))[0]
python
def dict_take(dict_, keys, *d): """ get multiple values from a dictionary """ try: return list(dict_take_gen(dict_, keys, *d)) except TypeError: return list(dict_take_gen(dict_, keys, *d))[0]
[ "def", "dict_take", "(", "dict_", ",", "keys", ",", "*", "d", ")", ":", "try", ":", "return", "list", "(", "dict_take_gen", "(", "dict_", ",", "keys", ",", "*", "d", ")", ")", "except", "TypeError", ":", "return", "list", "(", "dict_take_gen", "(", ...
get multiple values from a dictionary
[ "get", "multiple", "values", "from", "a", "dictionary" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L982-L987
train
get multiple values from a dictionary
Erotemic/utool
utool/util_dict.py
dict_take_pop
def dict_take_pop(dict_, keys, *d): """ like dict_take but pops values off CommandLine: python -m utool.util_dict --test-dict_take_pop Example1: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> dict_ = {1: 'a', 'other': None,...
python
def dict_take_pop(dict_, keys, *d): """ like dict_take but pops values off CommandLine: python -m utool.util_dict --test-dict_take_pop Example1: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> dict_ = {1: 'a', 'other': None,...
[ "def", "dict_take_pop", "(", "dict_", ",", "keys", ",", "*", "d", ")", ":", "if", "len", "(", "d", ")", "==", "0", ":", "return", "[", "dict_", ".", "pop", "(", "key", ")", "for", "key", "in", "keys", "]", "elif", "len", "(", "d", ")", "==", ...
like dict_take but pops values off CommandLine: python -m utool.util_dict --test-dict_take_pop Example1: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> dict_ = {1: 'a', 'other': None, 'another': 'foo', 2: 'b', 3: 'c'} >...
[ "like", "dict_take", "but", "pops", "values", "off" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1014-L1057
train
like dict_take but pops values off
Erotemic/utool
utool/util_dict.py
dict_assign
def dict_assign(dict_, keys, vals): """ simple method for assigning or setting values with a similar interface to dict_take """ for key, val in zip(keys, vals): dict_[key] = val
python
def dict_assign(dict_, keys, vals): """ simple method for assigning or setting values with a similar interface to dict_take """ for key, val in zip(keys, vals): dict_[key] = val
[ "def", "dict_assign", "(", "dict_", ",", "keys", ",", "vals", ")", ":", "for", "key", ",", "val", "in", "zip", "(", "keys", ",", "vals", ")", ":", "dict_", "[", "key", "]", "=", "val" ]
simple method for assigning or setting values with a similar interface to dict_take
[ "simple", "method", "for", "assigning", "or", "setting", "values", "with", "a", "similar", "interface", "to", "dict_take" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1060-L1064
train
assigns values to the dict
Erotemic/utool
utool/util_dict.py
dict_where_len0
def dict_where_len0(dict_): """ Accepts a dict of lists. Returns keys that have vals with no length """ keys = np.array(dict_.keys()) flags = np.array(list(map(len, dict_.values()))) == 0 indices = np.where(flags)[0] return keys[indices]
python
def dict_where_len0(dict_): """ Accepts a dict of lists. Returns keys that have vals with no length """ keys = np.array(dict_.keys()) flags = np.array(list(map(len, dict_.values()))) == 0 indices = np.where(flags)[0] return keys[indices]
[ "def", "dict_where_len0", "(", "dict_", ")", ":", "keys", "=", "np", ".", "array", "(", "dict_", ".", "keys", "(", ")", ")", "flags", "=", "np", ".", "array", "(", "list", "(", "map", "(", "len", ",", "dict_", ".", "values", "(", ")", ")", ")",...
Accepts a dict of lists. Returns keys that have vals with no length
[ "Accepts", "a", "dict", "of", "lists", ".", "Returns", "keys", "that", "have", "vals", "with", "no", "length" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1067-L1074
train
Takes a dict of lists. Returns keys that have vals with no length. Returns keys that have vals with no length. Returns keys that have vals with no length.
Erotemic/utool
utool/util_dict.py
get_dict_column
def get_dict_column(dict_, colx): r""" Args: dict_ (dict_): a dictionary of lists colx (int): CommandLine: python -m utool.util_dict --test-get_dict_column Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut ...
python
def get_dict_column(dict_, colx): r""" Args: dict_ (dict_): a dictionary of lists colx (int): CommandLine: python -m utool.util_dict --test-get_dict_column Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut ...
[ "def", "get_dict_column", "(", "dict_", ",", "colx", ")", ":", "retdict_", "=", "{", "key", ":", "util_list", ".", "list_take", "(", "val", ",", "colx", ")", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "dict_", ")", "}", "return", ...
r""" Args: dict_ (dict_): a dictionary of lists colx (int): CommandLine: python -m utool.util_dict --test-get_dict_column Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> dict_ = {'a': [0, 1, 2], 'b':...
[ "r", "Args", ":", "dict_", "(", "dict_", ")", ":", "a", "dictionary", "of", "lists", "colx", "(", "int", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1077-L1099
train
r Returns a dictionary of lists with the values in the given column
Erotemic/utool
utool/util_dict.py
dictinfo
def dictinfo(dict_): """ dictinfo In depth debugging info Args: dict_ (dict): Returns: str Example: >>> # DISABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> dict_ = {} >>> result = dictinfo(dict_) >>> print(result) """ ...
python
def dictinfo(dict_): """ dictinfo In depth debugging info Args: dict_ (dict): Returns: str Example: >>> # DISABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> dict_ = {} >>> result = dictinfo(dict_) >>> print(result) """ ...
[ "def", "dictinfo", "(", "dict_", ")", ":", "import", "utool", "as", "ut", "if", "not", "isinstance", "(", "dict_", ",", "dict", ")", ":", "return", "'expected dict got %r'", "%", "type", "(", "dict_", ")", "keys", "=", "list", "(", "dict_", ".", "keys"...
dictinfo In depth debugging info Args: dict_ (dict): Returns: str Example: >>> # DISABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> dict_ = {} >>> result = dictinfo(dict_) >>> print(result)
[ "dictinfo" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1111-L1181
train
In depth debugging info Taxonomy
Erotemic/utool
utool/util_dict.py
dict_find_keys
def dict_find_keys(dict_, val_list): r""" Args: dict_ (dict): val_list (list): Returns: dict: found_dict CommandLine: python -m utool.util_dict --test-dict_find_keys Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>>...
python
def dict_find_keys(dict_, val_list): r""" Args: dict_ (dict): val_list (list): Returns: dict: found_dict CommandLine: python -m utool.util_dict --test-dict_find_keys Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>>...
[ "def", "dict_find_keys", "(", "dict_", ",", "val_list", ")", ":", "found_dict", "=", "{", "search_val", ":", "[", "key", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "dict_", ")", "if", "val", "==", "search_val", "]", "for", "search_va...
r""" Args: dict_ (dict): val_list (list): Returns: dict: found_dict CommandLine: python -m utool.util_dict --test-dict_find_keys Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> dict_ = {...
[ "r", "Args", ":", "dict_", "(", "dict", ")", ":", "val_list", "(", "list", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1184-L1214
train
r Finds the keys in a dictionary that are in val_list
Erotemic/utool
utool/util_dict.py
dict_find_other_sameval_keys
def dict_find_other_sameval_keys(dict_, key): """ Example: >>> # DISABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> dict_ = {'default': 1, 'hierarchical': 5, 'linear': 0, 'kdtree': 1, ... 'composite': 3, 'autotuned': 255, 'saved': 254, 'kmeans': 2, ......
python
def dict_find_other_sameval_keys(dict_, key): """ Example: >>> # DISABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> dict_ = {'default': 1, 'hierarchical': 5, 'linear': 0, 'kdtree': 1, ... 'composite': 3, 'autotuned': 255, 'saved': 254, 'kmeans': 2, ......
[ "def", "dict_find_other_sameval_keys", "(", "dict_", ",", "key", ")", ":", "value", "=", "dict_", "[", "key", "]", "found_dict", "=", "dict_find_keys", "(", "dict_", ",", "[", "value", "]", ")", "other_keys", "=", "found_dict", "[", "value", "]", "other_ke...
Example: >>> # DISABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> dict_ = {'default': 1, 'hierarchical': 5, 'linear': 0, 'kdtree': 1, ... 'composite': 3, 'autotuned': 255, 'saved': 254, 'kmeans': 2, ... 'lsh': 6, 'kdtree_single': 4} >>> key = ...
[ "Example", ":", ">>>", "#", "DISABLE_DOCTEST", ">>>", "from", "utool", ".", "util_dict", "import", "*", "#", "NOQA", ">>>", "dict_", "=", "{", "default", ":", "1", "hierarchical", ":", "5", "linear", ":", "0", "kdtree", ":", "1", "...", "composite", ":...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1217-L1232
train
Find other keys in dict that have the same value
Erotemic/utool
utool/util_dict.py
dict_hist
def dict_hist(item_list, weight_list=None, ordered=False, labels=None): r""" Builds a histogram of items in item_list Args: item_list (list): list with hashable items (usually containing duplicates) Returns: dict : dictionary where the keys are items in item_list, and the values ...
python
def dict_hist(item_list, weight_list=None, ordered=False, labels=None): r""" Builds a histogram of items in item_list Args: item_list (list): list with hashable items (usually containing duplicates) Returns: dict : dictionary where the keys are items in item_list, and the values ...
[ "def", "dict_hist", "(", "item_list", ",", "weight_list", "=", "None", ",", "ordered", "=", "False", ",", "labels", "=", "None", ")", ":", "if", "labels", "is", "None", ":", "# hist_ = defaultdict(lambda: 0)", "hist_", "=", "defaultdict", "(", "int", ")", ...
r""" Builds a histogram of items in item_list Args: item_list (list): list with hashable items (usually containing duplicates) Returns: dict : dictionary where the keys are items in item_list, and the values are the number of times the item appears in item_list. CommandLine:...
[ "r", "Builds", "a", "histogram", "of", "items", "in", "item_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1236-L1279
train
r Builds a histogram of items in item_list
Erotemic/utool
utool/util_dict.py
range_hist
def range_hist(items, bins): """ Bins items into a discrete histogram by values and/or ranges. items = [1, 2, 3, 4, 5, 6, 7] bins = [0, 1, 2, (3, float('inf'))] ut.range_hist(items, bins) """ big_hist = ut.dict_hist(items) hist = ut.odict([(b, 0) for b in bins]) for k, ...
python
def range_hist(items, bins): """ Bins items into a discrete histogram by values and/or ranges. items = [1, 2, 3, 4, 5, 6, 7] bins = [0, 1, 2, (3, float('inf'))] ut.range_hist(items, bins) """ big_hist = ut.dict_hist(items) hist = ut.odict([(b, 0) for b in bins]) for k, ...
[ "def", "range_hist", "(", "items", ",", "bins", ")", ":", "big_hist", "=", "ut", ".", "dict_hist", "(", "items", ")", "hist", "=", "ut", ".", "odict", "(", "[", "(", "b", ",", "0", ")", "for", "b", "in", "bins", "]", ")", "for", "k", ",", "v"...
Bins items into a discrete histogram by values and/or ranges. items = [1, 2, 3, 4, 5, 6, 7] bins = [0, 1, 2, (3, float('inf'))] ut.range_hist(items, bins)
[ "Bins", "items", "into", "a", "discrete", "histogram", "by", "values", "and", "/", "or", "ranges", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1282-L1300
train
Returns a discrete histogram of items into a discrete histogram by values and or ranges.
Erotemic/utool
utool/util_dict.py
dict_hist_cumsum
def dict_hist_cumsum(hist_, reverse=True): """ VERY HACKY """ import utool as ut items = hist_.items() if reverse: items = sorted(items)[::-1] else: items = sorted(items) key_list = ut.get_list_column(items, 0) val_list = ut.get_list_column(items, 1) cumhist_ = dict(zip(k...
python
def dict_hist_cumsum(hist_, reverse=True): """ VERY HACKY """ import utool as ut items = hist_.items() if reverse: items = sorted(items)[::-1] else: items = sorted(items) key_list = ut.get_list_column(items, 0) val_list = ut.get_list_column(items, 1) cumhist_ = dict(zip(k...
[ "def", "dict_hist_cumsum", "(", "hist_", ",", "reverse", "=", "True", ")", ":", "import", "utool", "as", "ut", "items", "=", "hist_", ".", "items", "(", ")", "if", "reverse", ":", "items", "=", "sorted", "(", "items", ")", "[", ":", ":", "-", "1", ...
VERY HACKY
[ "VERY", "HACKY" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1303-L1314
train
A dict that returns the cumulative sum of the histogram
Erotemic/utool
utool/util_dict.py
merge_dicts
def merge_dicts(*args): r""" add / concatenate / union / join / merge / combine dictionaries Copies the first dictionary given and then repeatedly calls update using the rest of the dicts given in args. Duplicate keys will receive the last value specified the list of dictionaries. Returns: ...
python
def merge_dicts(*args): r""" add / concatenate / union / join / merge / combine dictionaries Copies the first dictionary given and then repeatedly calls update using the rest of the dicts given in args. Duplicate keys will receive the last value specified the list of dictionaries. Returns: ...
[ "def", "merge_dicts", "(", "*", "args", ")", ":", "iter_", "=", "iter", "(", "args", ")", "mergedict_", "=", "six", ".", "next", "(", "iter_", ")", ".", "copy", "(", ")", "for", "dict_", "in", "iter_", ":", "mergedict_", ".", "update", "(", "dict_"...
r""" add / concatenate / union / join / merge / combine dictionaries Copies the first dictionary given and then repeatedly calls update using the rest of the dicts given in args. Duplicate keys will receive the last value specified the list of dictionaries. Returns: dict: mergedict_ C...
[ "r", "add", "/", "concatenate", "/", "union", "/", "join", "/", "merge", "/", "combine", "dictionaries" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1317-L1350
train
r Merge dictionaries in a single dictionary into a single dictionary.
Erotemic/utool
utool/util_dict.py
dict_union3
def dict_union3(dict1, dict2, combine_op=op.add): r""" Args: dict1 (dict): dict2 (dict): combine_op (func): (default=op.add) Returns: dict: mergedict_ CommandLine: python -m utool.util_dict --exec-dict_union3 Example: >>> # ENABLE_DOCTEST >>...
python
def dict_union3(dict1, dict2, combine_op=op.add): r""" Args: dict1 (dict): dict2 (dict): combine_op (func): (default=op.add) Returns: dict: mergedict_ CommandLine: python -m utool.util_dict --exec-dict_union3 Example: >>> # ENABLE_DOCTEST >>...
[ "def", "dict_union3", "(", "dict1", ",", "dict2", ",", "combine_op", "=", "op", ".", "add", ")", ":", "keys1", "=", "set", "(", "dict1", ".", "keys", "(", ")", ")", "keys2", "=", "set", "(", "dict2", ".", "keys", "(", ")", ")", "# Combine common ke...
r""" Args: dict1 (dict): dict2 (dict): combine_op (func): (default=op.add) Returns: dict: mergedict_ CommandLine: python -m utool.util_dict --exec-dict_union3 Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> im...
[ "r", "Args", ":", "dict1", "(", "dict", ")", ":", "dict2", "(", "dict", ")", ":", "combine_op", "(", "func", ")", ":", "(", "default", "=", "op", ".", "add", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1353-L1390
train
r Returns a dict that is the union of two dictionaries
Erotemic/utool
utool/util_dict.py
dict_intersection
def dict_intersection(dict1, dict2, combine=False, combine_op=op.add): r""" Args: dict1 (dict): dict2 (dict): combine (bool): Combines keys only if the values are equal if False else values are combined using combine_op (default = False) combine_op (func): (default = ...
python
def dict_intersection(dict1, dict2, combine=False, combine_op=op.add): r""" Args: dict1 (dict): dict2 (dict): combine (bool): Combines keys only if the values are equal if False else values are combined using combine_op (default = False) combine_op (func): (default = ...
[ "def", "dict_intersection", "(", "dict1", ",", "dict2", ",", "combine", "=", "False", ",", "combine_op", "=", "op", ".", "add", ")", ":", "isect_keys", "=", "set", "(", "dict1", ".", "keys", "(", ")", ")", ".", "intersection", "(", "set", "(", "dict2...
r""" Args: dict1 (dict): dict2 (dict): combine (bool): Combines keys only if the values are equal if False else values are combined using combine_op (default = False) combine_op (func): (default = op.add) Returns: dict: mergedict_ CommandLine: py...
[ "r", "Args", ":", "dict1", "(", "dict", ")", ":", "dict2", "(", "dict", ")", ":", "combine", "(", "bool", ")", ":", "Combines", "keys", "only", "if", "the", "values", "are", "equal", "if", "False", "else", "values", "are", "combined", "using", "combi...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1393-L1435
train
r Returns the intersection of two dictionaries
Erotemic/utool
utool/util_dict.py
dict_isect_combine
def dict_isect_combine(dict1, dict2, combine_op=op.add): """ Intersection of dict keys and combination of dict values """ keys3 = set(dict1.keys()).intersection(set(dict2.keys())) dict3 = {key: combine_op(dict1[key], dict2[key]) for key in keys3} return dict3
python
def dict_isect_combine(dict1, dict2, combine_op=op.add): """ Intersection of dict keys and combination of dict values """ keys3 = set(dict1.keys()).intersection(set(dict2.keys())) dict3 = {key: combine_op(dict1[key], dict2[key]) for key in keys3} return dict3
[ "def", "dict_isect_combine", "(", "dict1", ",", "dict2", ",", "combine_op", "=", "op", ".", "add", ")", ":", "keys3", "=", "set", "(", "dict1", ".", "keys", "(", ")", ")", ".", "intersection", "(", "set", "(", "dict2", ".", "keys", "(", ")", ")", ...
Intersection of dict keys and combination of dict values
[ "Intersection", "of", "dict", "keys", "and", "combination", "of", "dict", "values" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1438-L1442
train
Intersects dict keys and combination of dict values
Erotemic/utool
utool/util_dict.py
dict_union_combine
def dict_union_combine(dict1, dict2, combine_op=op.add, default=util_const.NoParam, default2=util_const.NoParam): """ Combine of dict keys and uses dfault value when key does not exist CAREFUL WHEN USING THIS WITH REDUCE. Use dict_stack2 instead """ key...
python
def dict_union_combine(dict1, dict2, combine_op=op.add, default=util_const.NoParam, default2=util_const.NoParam): """ Combine of dict keys and uses dfault value when key does not exist CAREFUL WHEN USING THIS WITH REDUCE. Use dict_stack2 instead """ key...
[ "def", "dict_union_combine", "(", "dict1", ",", "dict2", ",", "combine_op", "=", "op", ".", "add", ",", "default", "=", "util_const", ".", "NoParam", ",", "default2", "=", "util_const", ".", "NoParam", ")", ":", "keys3", "=", "set", "(", "dict1", ".", ...
Combine of dict keys and uses dfault value when key does not exist CAREFUL WHEN USING THIS WITH REDUCE. Use dict_stack2 instead
[ "Combine", "of", "dict", "keys", "and", "uses", "dfault", "value", "when", "key", "does", "not", "exist" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1445-L1461
train
Combine dict1 and dict2 into a single dict.
Erotemic/utool
utool/util_dict.py
dict_filter_nones
def dict_filter_nones(dict_): r""" Removes None values Args: dict_ (dict): a dictionary Returns: dict: CommandLine: python -m utool.util_dict --exec-dict_filter_nones Example: >>> # DISABLE_DOCTEST >>> # UNSTABLE_DOCTEST >>> # fails on python ...
python
def dict_filter_nones(dict_): r""" Removes None values Args: dict_ (dict): a dictionary Returns: dict: CommandLine: python -m utool.util_dict --exec-dict_filter_nones Example: >>> # DISABLE_DOCTEST >>> # UNSTABLE_DOCTEST >>> # fails on python ...
[ "def", "dict_filter_nones", "(", "dict_", ")", ":", "dict2_", "=", "{", "key", ":", "val", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "dict_", ")", "if", "val", "is", "not", "None", "}", "return", "dict2_" ]
r""" Removes None values Args: dict_ (dict): a dictionary Returns: dict: CommandLine: python -m utool.util_dict --exec-dict_filter_nones Example: >>> # DISABLE_DOCTEST >>> # UNSTABLE_DOCTEST >>> # fails on python 3 because of dict None order ...
[ "r", "Removes", "None", "values" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1474-L1504
train
r Removes None values from a dictionary
Erotemic/utool
utool/util_dict.py
groupby_tags
def groupby_tags(item_list, tags_list): r""" case where an item can belong to multiple groups Args: item_list (list): tags_list (list): Returns: dict: groupid_to_items CommandLine: python -m utool.util_dict --test-groupby_tags Example: >>> # ENABLE_DOC...
python
def groupby_tags(item_list, tags_list): r""" case where an item can belong to multiple groups Args: item_list (list): tags_list (list): Returns: dict: groupid_to_items CommandLine: python -m utool.util_dict --test-groupby_tags Example: >>> # ENABLE_DOC...
[ "def", "groupby_tags", "(", "item_list", ",", "tags_list", ")", ":", "groupid_to_items", "=", "defaultdict", "(", "list", ")", "for", "tags", ",", "item", "in", "zip", "(", "tags_list", ",", "item_list", ")", ":", "for", "tag", "in", "tags", ":", "groupi...
r""" case where an item can belong to multiple groups Args: item_list (list): tags_list (list): Returns: dict: groupid_to_items CommandLine: python -m utool.util_dict --test-groupby_tags Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import...
[ "r", "case", "where", "an", "item", "can", "belong", "to", "multiple", "groups" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1507-L1552
train
r Returns a dict of items that belong to multiple groups
Erotemic/utool
utool/util_dict.py
group_pairs
def group_pairs(pair_list): """ Groups a list of items using the first element in each pair as the item and the second element as the groupid. Args: pair_list (list): list of 2-tuples (item, groupid) Returns: dict: groupid_to_items: maps a groupid to a list of items SeeAlso: ...
python
def group_pairs(pair_list): """ Groups a list of items using the first element in each pair as the item and the second element as the groupid. Args: pair_list (list): list of 2-tuples (item, groupid) Returns: dict: groupid_to_items: maps a groupid to a list of items SeeAlso: ...
[ "def", "group_pairs", "(", "pair_list", ")", ":", "# Initialize dict of lists", "groupid_to_items", "=", "defaultdict", "(", "list", ")", "# Insert each item into the correct group", "for", "item", ",", "groupid", "in", "pair_list", ":", "groupid_to_items", "[", "groupi...
Groups a list of items using the first element in each pair as the item and the second element as the groupid. Args: pair_list (list): list of 2-tuples (item, groupid) Returns: dict: groupid_to_items: maps a groupid to a list of items SeeAlso: group_items
[ "Groups", "a", "list", "of", "items", "using", "the", "first", "element", "in", "each", "pair", "as", "the", "item", "and", "the", "second", "element", "as", "the", "groupid", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1560-L1579
train
Groups a list of items using the first element in each pair as the item and the second element as the groupid.
Erotemic/utool
utool/util_dict.py
group_items
def group_items(items, by=None, sorted_=True): """ Groups a list of items by group id. Args: items (list): a list of the values to be grouped. if `by` is None, then each item is assumed to be a (groupid, value) pair. by (list): a corresponding list to group items by....
python
def group_items(items, by=None, sorted_=True): """ Groups a list of items by group id. Args: items (list): a list of the values to be grouped. if `by` is None, then each item is assumed to be a (groupid, value) pair. by (list): a corresponding list to group items by....
[ "def", "group_items", "(", "items", ",", "by", "=", "None", ",", "sorted_", "=", "True", ")", ":", "if", "by", "is", "not", "None", ":", "pairs", "=", "list", "(", "zip", "(", "by", ",", "items", ")", ")", "if", "sorted_", ":", "# Sort by groupid f...
Groups a list of items by group id. Args: items (list): a list of the values to be grouped. if `by` is None, then each item is assumed to be a (groupid, value) pair. by (list): a corresponding list to group items by. if specified, these are used as the keys to gr...
[ "Groups", "a", "list", "of", "items", "by", "group", "id", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1582-L1635
train
Groups a list of items by a given group id.
Erotemic/utool
utool/util_dict.py
hierarchical_group_items
def hierarchical_group_items(item_list, groupids_list): """ Generalization of group_item. Convert a flast list of ids into a heirarchical dictionary. TODO: move to util_dict Reference: http://stackoverflow.com/questions/10193235/python-translate-a-table-to-a-hierarchical-dictionary Args: ...
python
def hierarchical_group_items(item_list, groupids_list): """ Generalization of group_item. Convert a flast list of ids into a heirarchical dictionary. TODO: move to util_dict Reference: http://stackoverflow.com/questions/10193235/python-translate-a-table-to-a-hierarchical-dictionary Args: ...
[ "def", "hierarchical_group_items", "(", "item_list", ",", "groupids_list", ")", ":", "# Construct a defaultdict type with the appropriate number of levels", "num_groups", "=", "len", "(", "groupids_list", ")", "leaf_type", "=", "partial", "(", "defaultdict", ",", "list", ...
Generalization of group_item. Convert a flast list of ids into a heirarchical dictionary. TODO: move to util_dict Reference: http://stackoverflow.com/questions/10193235/python-translate-a-table-to-a-hierarchical-dictionary Args: item_list (list): groupids_list (list): Command...
[ "Generalization", "of", "group_item", ".", "Convert", "a", "flast", "list", "of", "ids", "into", "a", "heirarchical", "dictionary", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1638-L1719
train
This function converts a list of items into a heirarchical dictionary.
Erotemic/utool
utool/util_dict.py
iflatten_dict_values
def iflatten_dict_values(node, depth=0): """ >>> from utool.util_dict import * # NOQA """ if isinstance(node, dict): _iter = (iflatten_dict_values(value) for value in six.itervalues(node)) return util_iter.iflatten(_iter) else: return node
python
def iflatten_dict_values(node, depth=0): """ >>> from utool.util_dict import * # NOQA """ if isinstance(node, dict): _iter = (iflatten_dict_values(value) for value in six.itervalues(node)) return util_iter.iflatten(_iter) else: return node
[ "def", "iflatten_dict_values", "(", "node", ",", "depth", "=", "0", ")", ":", "if", "isinstance", "(", "node", ",", "dict", ")", ":", "_iter", "=", "(", "iflatten_dict_values", "(", "value", ")", "for", "value", "in", "six", ".", "itervalues", "(", "no...
>>> from utool.util_dict import * # NOQA
[ ">>>", "from", "utool", ".", "util_dict", "import", "*", "#", "NOQA" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1722-L1730
train
Return a list of all the keys in a dict
Erotemic/utool
utool/util_dict.py
hierarchical_map_vals
def hierarchical_map_vals(func, node, max_depth=None, depth=0): """ node is a dict tree like structure with leaves of type list TODO: move to util_dict CommandLine: python -m utool.util_dict --exec-hierarchical_map_vals Example: >>> # ENABLE_DOCTEST >>> from utool.util_dic...
python
def hierarchical_map_vals(func, node, max_depth=None, depth=0): """ node is a dict tree like structure with leaves of type list TODO: move to util_dict CommandLine: python -m utool.util_dict --exec-hierarchical_map_vals Example: >>> # ENABLE_DOCTEST >>> from utool.util_dic...
[ "def", "hierarchical_map_vals", "(", "func", ",", "node", ",", "max_depth", "=", "None", ",", "depth", "=", "0", ")", ":", "#if not isinstance(node, dict):", "if", "not", "hasattr", "(", "node", ",", "'items'", ")", ":", "return", "func", "(", "node", ")",...
node is a dict tree like structure with leaves of type list TODO: move to util_dict CommandLine: python -m utool.util_dict --exec-hierarchical_map_vals Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> item_list ...
[ "node", "is", "a", "dict", "tree", "like", "structure", "with", "leaves", "of", "type", "list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1750-L1821
train
This function maps the values of a dict tree like structure with leaves of type list
Erotemic/utool
utool/util_dict.py
move_odict_item
def move_odict_item(odict, key, newpos): """ References: http://stackoverflow.com/questions/22663966/changing-order-of-ordered-dictionary-in-python CommandLine: python -m utool.util_dict --exec-move_odict_item Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict impor...
python
def move_odict_item(odict, key, newpos): """ References: http://stackoverflow.com/questions/22663966/changing-order-of-ordered-dictionary-in-python CommandLine: python -m utool.util_dict --exec-move_odict_item Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict impor...
[ "def", "move_odict_item", "(", "odict", ",", "key", ",", "newpos", ")", ":", "odict", "[", "key", "]", "=", "odict", ".", "pop", "(", "key", ")", "for", "i", ",", "otherkey", "in", "enumerate", "(", "list", "(", "odict", ".", "keys", "(", ")", ")...
References: http://stackoverflow.com/questions/22663966/changing-order-of-ordered-dictionary-in-python CommandLine: python -m utool.util_dict --exec-move_odict_item Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>...
[ "References", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "22663966", "/", "changing", "-", "order", "-", "of", "-", "ordered", "-", "dictionary", "-", "in", "-", "python" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1824-L1857
train
Move the item at the given position in the dictionary odict to the given newpos.
Erotemic/utool
utool/util_dict.py
sort_dict
def sort_dict(dict_, part='keys', key=None, reverse=False): """ sorts a dictionary by its values or its keys Args: dict_ (dict_): a dictionary part (str): specifies to sort by keys or values key (Optional[func]): a function that takes specified part and returns a sortab...
python
def sort_dict(dict_, part='keys', key=None, reverse=False): """ sorts a dictionary by its values or its keys Args: dict_ (dict_): a dictionary part (str): specifies to sort by keys or values key (Optional[func]): a function that takes specified part and returns a sortab...
[ "def", "sort_dict", "(", "dict_", ",", "part", "=", "'keys'", ",", "key", "=", "None", ",", "reverse", "=", "False", ")", ":", "if", "part", "==", "'keys'", ":", "index", "=", "0", "elif", "part", "in", "{", "'vals'", ",", "'values'", "}", ":", "...
sorts a dictionary by its values or its keys Args: dict_ (dict_): a dictionary part (str): specifies to sort by keys or values key (Optional[func]): a function that takes specified part and returns a sortable value reverse (bool): (Defaults to False) - True for descindi...
[ "sorts", "a", "dictionary", "by", "its", "values", "or", "its", "keys" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1955-L2003
train
Sort a dictionary by keys or values or keys
Erotemic/utool
utool/util_dict.py
order_dict_by
def order_dict_by(dict_, key_order): r""" Reorders items in a dictionary according to a custom key order Args: dict_ (dict_): a dictionary key_order (list): custom key order Returns: OrderedDict: sorted_dict CommandLine: python -m utool.util_dict --exec-order_dict...
python
def order_dict_by(dict_, key_order): r""" Reorders items in a dictionary according to a custom key order Args: dict_ (dict_): a dictionary key_order (list): custom key order Returns: OrderedDict: sorted_dict CommandLine: python -m utool.util_dict --exec-order_dict...
[ "def", "order_dict_by", "(", "dict_", ",", "key_order", ")", ":", "dict_keys", "=", "set", "(", "dict_", ".", "keys", "(", ")", ")", "other_keys", "=", "dict_keys", "-", "set", "(", "key_order", ")", "key_order", "=", "it", ".", "chain", "(", "key_orde...
r""" Reorders items in a dictionary according to a custom key order Args: dict_ (dict_): a dictionary key_order (list): custom key order Returns: OrderedDict: sorted_dict CommandLine: python -m utool.util_dict --exec-order_dict_by Example: >>> # ENABLE_DO...
[ "r", "Reorders", "items", "in", "a", "dictionary", "according", "to", "a", "custom", "key", "order" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L2006-L2038
train
r Reorders items in a dictionary according to a custom key order
Erotemic/utool
utool/util_dict.py
iteritems_sorted
def iteritems_sorted(dict_): """ change to iteritems ordered """ if isinstance(dict_, OrderedDict): return six.iteritems(dict_) else: return iter(sorted(six.iteritems(dict_)))
python
def iteritems_sorted(dict_): """ change to iteritems ordered """ if isinstance(dict_, OrderedDict): return six.iteritems(dict_) else: return iter(sorted(six.iteritems(dict_)))
[ "def", "iteritems_sorted", "(", "dict_", ")", ":", "if", "isinstance", "(", "dict_", ",", "OrderedDict", ")", ":", "return", "six", ".", "iteritems", "(", "dict_", ")", "else", ":", "return", "iter", "(", "sorted", "(", "six", ".", "iteritems", "(", "d...
change to iteritems ordered
[ "change", "to", "iteritems", "ordered" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L2041-L2046
train
change to iteritems ordered
Erotemic/utool
utool/util_dict.py
flatten_dict_vals
def flatten_dict_vals(dict_): """ Flattens only values in a heirarchical dictionary, keys are nested. """ if isinstance(dict_, dict): return dict([ ((key, augkey), augval) for key, val in dict_.items() for augkey, augval in flatten_dict_vals(val).items() ...
python
def flatten_dict_vals(dict_): """ Flattens only values in a heirarchical dictionary, keys are nested. """ if isinstance(dict_, dict): return dict([ ((key, augkey), augval) for key, val in dict_.items() for augkey, augval in flatten_dict_vals(val).items() ...
[ "def", "flatten_dict_vals", "(", "dict_", ")", ":", "if", "isinstance", "(", "dict_", ",", "dict", ")", ":", "return", "dict", "(", "[", "(", "(", "key", ",", "augkey", ")", ",", "augval", ")", "for", "key", ",", "val", "in", "dict_", ".", "items",...
Flattens only values in a heirarchical dictionary, keys are nested.
[ "Flattens", "only", "values", "in", "a", "heirarchical", "dictionary", "keys", "are", "nested", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L2054-L2065
train
Flattens only values in a heirarchical dictionary keys are nested.
Erotemic/utool
utool/util_dict.py
flatten_dict_items
def flatten_dict_items(dict_): """ Flattens keys / values in a heirarchical dictionary Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> item_list = [1, 2, 3, 4] >>> groupids_list = [[1, 1, 1, 2], [1, 2, 2, 2], [1,...
python
def flatten_dict_items(dict_): """ Flattens keys / values in a heirarchical dictionary Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> item_list = [1, 2, 3, 4] >>> groupids_list = [[1, 1, 1, 2], [1, 2, 2, 2], [1,...
[ "def", "flatten_dict_items", "(", "dict_", ")", ":", "import", "utool", "as", "ut", "flat_dict", "=", "ut", ".", "flatten_dict_vals", "(", "dict_", ")", "flatter_dict", "=", "dict", "(", "[", "(", "tuple", "(", "ut", ".", "unpack_iterables", "(", "key", ...
Flattens keys / values in a heirarchical dictionary Example: >>> # ENABLE_DOCTEST >>> from utool.util_dict import * # NOQA >>> import utool as ut >>> item_list = [1, 2, 3, 4] >>> groupids_list = [[1, 1, 1, 2], [1, 2, 2, 2], [1, 3, 1, 1]] >>> dict_ = hierarchical...
[ "Flattens", "keys", "/", "values", "in", "a", "heirarchical", "dictionary" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L2068-L2093
train
Flattens a dictionary into a flat dict
Erotemic/utool
utool/util_dict.py
depth_atleast
def depth_atleast(list_, depth): r""" Returns if depth of list is at least ``depth`` Args: list_ (list): depth (int): Returns: bool: True CommandLine: python -m utool.util_dict --exec-depth_atleast --show Example: >>> # DISABLE_DOCTEST >>> from...
python
def depth_atleast(list_, depth): r""" Returns if depth of list is at least ``depth`` Args: list_ (list): depth (int): Returns: bool: True CommandLine: python -m utool.util_dict --exec-depth_atleast --show Example: >>> # DISABLE_DOCTEST >>> from...
[ "def", "depth_atleast", "(", "list_", ",", "depth", ")", ":", "if", "depth", "==", "0", ":", "return", "True", "else", ":", "try", ":", "return", "all", "(", "[", "depth_atleast", "(", "item", ",", "depth", "-", "1", ")", "for", "item", "in", "list...
r""" Returns if depth of list is at least ``depth`` Args: list_ (list): depth (int): Returns: bool: True CommandLine: python -m utool.util_dict --exec-depth_atleast --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_dict import * # NOQA ...
[ "r", "Returns", "if", "depth", "of", "list", "is", "at", "least", "depth" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L2096-L2125
train
r Returns if depth of list is at least depth
glormph/msstitch
src/app/writers/pycolator.py
write_percolator_xml
def write_percolator_xml(staticxml, feats, fn): """Given the static percolator xml root and process info nodes, and all psms and peptides as iterators in a dict {'peptide': pep_iterator, 'psm': psm_iterator}, this generates percolator out data into a file.""" # First get xml until psms opening element ...
python
def write_percolator_xml(staticxml, feats, fn): """Given the static percolator xml root and process info nodes, and all psms and peptides as iterators in a dict {'peptide': pep_iterator, 'psm': psm_iterator}, this generates percolator out data into a file.""" # First get xml until psms opening element ...
[ "def", "write_percolator_xml", "(", "staticxml", ",", "feats", ",", "fn", ")", ":", "# First get xml until psms opening element is found.", "etree", ".", "SubElement", "(", "staticxml", ",", "'psms'", ")", ".", "text", "=", "'***psms***'", "root", "=", "etree", "....
Given the static percolator xml root and process info nodes, and all psms and peptides as iterators in a dict {'peptide': pep_iterator, 'psm': psm_iterator}, this generates percolator out data into a file.
[ "Given", "the", "static", "percolator", "xml", "root", "and", "process", "info", "nodes", "and", "all", "psms", "and", "peptides", "as", "iterators", "in", "a", "dict", "{", "peptide", ":", "pep_iterator", "psm", ":", "psm_iterator", "}", "this", "generates"...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/writers/pycolator.py#L4-L37
train
This function takes the xml root and a dict containing the psms and peptides and outputs the xml and features as iterators and writes out the xml and features as percolator output files.
glormph/msstitch
src/app/actions/mzidtsv/splitmerge.py
get_splitcolnr
def get_splitcolnr(header, bioset, splitcol): """Returns column nr on which to split PSM table. Chooses from flags given via bioset and splitcol""" if bioset: return header.index(mzidtsvdata.HEADER_SETNAME) elif splitcol is not None: return splitcol - 1 else: raise RuntimeErr...
python
def get_splitcolnr(header, bioset, splitcol): """Returns column nr on which to split PSM table. Chooses from flags given via bioset and splitcol""" if bioset: return header.index(mzidtsvdata.HEADER_SETNAME) elif splitcol is not None: return splitcol - 1 else: raise RuntimeErr...
[ "def", "get_splitcolnr", "(", "header", ",", "bioset", ",", "splitcol", ")", ":", "if", "bioset", ":", "return", "header", ".", "index", "(", "mzidtsvdata", ".", "HEADER_SETNAME", ")", "elif", "splitcol", "is", "not", "None", ":", "return", "splitcol", "-"...
Returns column nr on which to split PSM table. Chooses from flags given via bioset and splitcol
[ "Returns", "column", "nr", "on", "which", "to", "split", "PSM", "table", ".", "Chooses", "from", "flags", "given", "via", "bioset", "and", "splitcol" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/splitmerge.py#L14-L22
train
Returns the column nr on which to split PSM table given via flags bioset and splitcol
glormph/msstitch
src/app/actions/mzidtsv/splitmerge.py
generate_psms_split
def generate_psms_split(fn, oldheader, bioset, splitcol): """Loops PSMs and outputs dictionaries passed to writer. Dictionaries contain the PSMs and info to which split pool the respective PSM belongs""" try: splitcolnr = get_splitcolnr(oldheader, bioset, splitcol) except IndexError: ...
python
def generate_psms_split(fn, oldheader, bioset, splitcol): """Loops PSMs and outputs dictionaries passed to writer. Dictionaries contain the PSMs and info to which split pool the respective PSM belongs""" try: splitcolnr = get_splitcolnr(oldheader, bioset, splitcol) except IndexError: ...
[ "def", "generate_psms_split", "(", "fn", ",", "oldheader", ",", "bioset", ",", "splitcol", ")", ":", "try", ":", "splitcolnr", "=", "get_splitcolnr", "(", "oldheader", ",", "bioset", ",", "splitcol", ")", "except", "IndexError", ":", "raise", "RuntimeError", ...
Loops PSMs and outputs dictionaries passed to writer. Dictionaries contain the PSMs and info to which split pool the respective PSM belongs
[ "Loops", "PSMs", "and", "outputs", "dictionaries", "passed", "to", "writer", ".", "Dictionaries", "contain", "the", "PSMs", "and", "info", "to", "which", "split", "pool", "the", "respective", "PSM", "belongs" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/splitmerge.py#L25-L38
train
Yields PSMs and outputs dictionaries containing the PSMs and info to which split pool the respective PSM belongs to.
Erotemic/utool
utool/_internal/randomwrap.py
rnumlistwithoutreplacement
def rnumlistwithoutreplacement(min, max): """Returns a randomly ordered list of the integers between min and max""" if checkquota() < 1: raise Exception("Your www.random.org quota has already run out.") requestparam = build_request_parameterNR(min, max) request = urllib.request.Request(requestpa...
python
def rnumlistwithoutreplacement(min, max): """Returns a randomly ordered list of the integers between min and max""" if checkquota() < 1: raise Exception("Your www.random.org quota has already run out.") requestparam = build_request_parameterNR(min, max) request = urllib.request.Request(requestpa...
[ "def", "rnumlistwithoutreplacement", "(", "min", ",", "max", ")", ":", "if", "checkquota", "(", ")", "<", "1", ":", "raise", "Exception", "(", "\"Your www.random.org quota has already run out.\"", ")", "requestparam", "=", "build_request_parameterNR", "(", "min", ",...
Returns a randomly ordered list of the integers between min and max
[ "Returns", "a", "randomly", "ordered", "list", "of", "the", "integers", "between", "min", "and", "max" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/randomwrap.py#L54-L63
train
Returns a randomly ordered list of the integers between min and max
Erotemic/utool
utool/_internal/randomwrap.py
rnumlistwithreplacement
def rnumlistwithreplacement(howmany, max, min=0): """Returns a list of howmany integers with a maximum value = max. The minimum value defaults to zero.""" if checkquota() < 1: raise Exception("Your www.random.org quota has already run out.") requestparam = build_request_parameterWR(howmany, min,...
python
def rnumlistwithreplacement(howmany, max, min=0): """Returns a list of howmany integers with a maximum value = max. The minimum value defaults to zero.""" if checkquota() < 1: raise Exception("Your www.random.org quota has already run out.") requestparam = build_request_parameterWR(howmany, min,...
[ "def", "rnumlistwithreplacement", "(", "howmany", ",", "max", ",", "min", "=", "0", ")", ":", "if", "checkquota", "(", ")", "<", "1", ":", "raise", "Exception", "(", "\"Your www.random.org quota has already run out.\"", ")", "requestparam", "=", "build_request_par...
Returns a list of howmany integers with a maximum value = max. The minimum value defaults to zero.
[ "Returns", "a", "list", "of", "howmany", "integers", "with", "a", "maximum", "value", "=", "max", ".", "The", "minimum", "value", "defaults", "to", "zero", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/randomwrap.py#L75-L85
train
Returns a list of howmany integers with a maximum value = max.
Erotemic/utool
utool/_internal/randomwrap.py
rrandom
def rrandom(): """Get the next random number in the range [0.0, 1.0]. Returns a float.""" import urllib.request import urllib.error import urllib.parse if checkquota() < 1: raise Exception("Your www.random.org quota has already run out.") request = urllib.request.Request( 'ht...
python
def rrandom(): """Get the next random number in the range [0.0, 1.0]. Returns a float.""" import urllib.request import urllib.error import urllib.parse if checkquota() < 1: raise Exception("Your www.random.org quota has already run out.") request = urllib.request.Request( 'ht...
[ "def", "rrandom", "(", ")", ":", "import", "urllib", ".", "request", "import", "urllib", ".", "error", "import", "urllib", ".", "parse", "if", "checkquota", "(", ")", "<", "1", ":", "raise", "Exception", "(", "\"Your www.random.org quota has already run out.\"",...
Get the next random number in the range [0.0, 1.0]. Returns a float.
[ "Get", "the", "next", "random", "number", "in", "the", "range", "[", "0", ".", "0", "1", ".", "0", "]", ".", "Returns", "a", "float", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/randomwrap.py#L110-L124
train
Get the next random number in the range [ 0 1. 0 ) Returns a float.
Erotemic/utool
utool/util_num.py
sigfig_str
def sigfig_str(number, sigfig): """ References: http://stackoverflow.com/questions/2663612/nicely-repr-float-in-python """ assert(sigfig > 0) try: d = decimal.Decimal(number) except TypeError: d = float_to_decimal(float(number)) sign, digits, exponent = d.as_tuple() ...
python
def sigfig_str(number, sigfig): """ References: http://stackoverflow.com/questions/2663612/nicely-repr-float-in-python """ assert(sigfig > 0) try: d = decimal.Decimal(number) except TypeError: d = float_to_decimal(float(number)) sign, digits, exponent = d.as_tuple() ...
[ "def", "sigfig_str", "(", "number", ",", "sigfig", ")", ":", "assert", "(", "sigfig", ">", "0", ")", "try", ":", "d", "=", "decimal", ".", "Decimal", "(", "number", ")", "except", "TypeError", ":", "d", "=", "float_to_decimal", "(", "float", "(", "nu...
References: http://stackoverflow.com/questions/2663612/nicely-repr-float-in-python
[ "References", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "2663612", "/", "nicely", "-", "repr", "-", "float", "-", "in", "-", "python" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_num.py#L38-L75
train
Returns a string representation of a number in a random number.
Erotemic/utool
utool/util_num.py
num_fmt
def num_fmt(num, max_digits=None): r""" Weird function. Not very well written. Very special case-y Args: num (int or float): max_digits (int): Returns: str: CommandLine: python -m utool.util_num --test-num_fmt Example: >>> # DISABLE_DOCTEST >>>...
python
def num_fmt(num, max_digits=None): r""" Weird function. Not very well written. Very special case-y Args: num (int or float): max_digits (int): Returns: str: CommandLine: python -m utool.util_num --test-num_fmt Example: >>> # DISABLE_DOCTEST >>>...
[ "def", "num_fmt", "(", "num", ",", "max_digits", "=", "None", ")", ":", "if", "num", "is", "None", ":", "return", "'None'", "def", "num_in_mag", "(", "num", ",", "mag", ")", ":", "return", "mag", ">", "num", "and", "num", ">", "(", "-", "1", "*",...
r""" Weird function. Not very well written. Very special case-y Args: num (int or float): max_digits (int): Returns: str: CommandLine: python -m utool.util_num --test-num_fmt Example: >>> # DISABLE_DOCTEST >>> from utool.util_num import * # NOQA ...
[ "r", "Weird", "function", ".", "Not", "very", "well", "written", ".", "Very", "special", "case", "-", "y" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_num.py#L82-L133
train
r Return a string representation of a number in the current language.
YuriyGuts/pygoose
pygoose/kg/project.py
Project.load_feature_lists
def load_feature_lists(self, feature_lists): """ Load pickled features for train and test sets, assuming they are saved in the `features` folder along with their column names. Args: feature_lists: A list containing the names of the feature lists to load. Returns: ...
python
def load_feature_lists(self, feature_lists): """ Load pickled features for train and test sets, assuming they are saved in the `features` folder along with their column names. Args: feature_lists: A list containing the names of the feature lists to load. Returns: ...
[ "def", "load_feature_lists", "(", "self", ",", "feature_lists", ")", ":", "column_names", "=", "[", "]", "feature_ranges", "=", "[", "]", "running_feature_count", "=", "0", "for", "list_id", "in", "feature_lists", ":", "feature_list_names", "=", "load_lines", "(...
Load pickled features for train and test sets, assuming they are saved in the `features` folder along with their column names. Args: feature_lists: A list containing the names of the feature lists to load. Returns: A tuple containing 3 items: train dataframe, test dataf...
[ "Load", "pickled", "features", "for", "train", "and", "test", "sets", "assuming", "they", "are", "saved", "in", "the", "features", "folder", "along", "with", "their", "column", "names", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/project.py#L89-L126
train
Load pickled features for train and test sets assuming they are saved in the features folder along with their column names.
YuriyGuts/pygoose
pygoose/kg/project.py
Project.save_features
def save_features(self, train_features, test_features, feature_names, feature_list_id): """ Save features for the training and test sets to disk, along with their metadata. Args: train_features: A NumPy array of features for the training set. test_features: A NumPy array...
python
def save_features(self, train_features, test_features, feature_names, feature_list_id): """ Save features for the training and test sets to disk, along with their metadata. Args: train_features: A NumPy array of features for the training set. test_features: A NumPy array...
[ "def", "save_features", "(", "self", ",", "train_features", ",", "test_features", ",", "feature_names", ",", "feature_list_id", ")", ":", "self", ".", "save_feature_names", "(", "feature_names", ",", "feature_list_id", ")", "self", ".", "save_feature_list", "(", "...
Save features for the training and test sets to disk, along with their metadata. Args: train_features: A NumPy array of features for the training set. test_features: A NumPy array of features for the test set. feature_names: A list containing the names of the feature columns...
[ "Save", "features", "for", "the", "training", "and", "test", "sets", "to", "disk", "along", "with", "their", "metadata", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/project.py#L128-L141
train
Save the training and test sets to disk along with their metadata.
YuriyGuts/pygoose
pygoose/kg/project.py
Project.save_feature_names
def save_feature_names(self, feature_names, feature_list_id): """ Save the names of the features for the given feature list to a metadata file. Example: `save_feature_names(['num_employees', 'stock_price'], 'company')`. Args: feature_names: A list containing the names of the...
python
def save_feature_names(self, feature_names, feature_list_id): """ Save the names of the features for the given feature list to a metadata file. Example: `save_feature_names(['num_employees', 'stock_price'], 'company')`. Args: feature_names: A list containing the names of the...
[ "def", "save_feature_names", "(", "self", ",", "feature_names", ",", "feature_list_id", ")", ":", "save_lines", "(", "feature_names", ",", "self", ".", "features_dir", "+", "'X_train_{}.names'", ".", "format", "(", "feature_list_id", ")", ")" ]
Save the names of the features for the given feature list to a metadata file. Example: `save_feature_names(['num_employees', 'stock_price'], 'company')`. Args: feature_names: A list containing the names of the features, matching the column order. feature_list_id: The name for th...
[ "Save", "the", "names", "of", "the", "features", "for", "the", "given", "feature", "list", "to", "a", "metadata", "file", ".", "Example", ":", "save_feature_names", "(", "[", "num_employees", "stock_price", "]", "company", ")", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/project.py#L143-L153
train
Save the names of the features for the given feature list to a metadata file.
YuriyGuts/pygoose
pygoose/kg/project.py
Project.save_feature_list
def save_feature_list(self, obj, set_id, feature_list_id): """ Pickle the specified feature list to a file. Example: `save_feature_list(project, X_tfidf_train, 'train', 'tfidf')`. Args: obj: The object to pickle (e.g., a numpy array or a Pandas dataframe) project...
python
def save_feature_list(self, obj, set_id, feature_list_id): """ Pickle the specified feature list to a file. Example: `save_feature_list(project, X_tfidf_train, 'train', 'tfidf')`. Args: obj: The object to pickle (e.g., a numpy array or a Pandas dataframe) project...
[ "def", "save_feature_list", "(", "self", ",", "obj", ",", "set_id", ",", "feature_list_id", ")", ":", "save", "(", "obj", ",", "self", ".", "features_dir", "+", "'X_{}_{}.pickle'", ".", "format", "(", "set_id", ",", "feature_list_id", ")", ")" ]
Pickle the specified feature list to a file. Example: `save_feature_list(project, X_tfidf_train, 'train', 'tfidf')`. Args: obj: The object to pickle (e.g., a numpy array or a Pandas dataframe) project: An instance of pygoose project. set_id: The id of the subset (e.g...
[ "Pickle", "the", "specified", "feature", "list", "to", "a", "file", ".", "Example", ":", "save_feature_list", "(", "project", "X_tfidf_train", "train", "tfidf", ")", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/project.py#L155-L167
train
Save the specified feature list to a file.
YuriyGuts/pygoose
pygoose/kg/project.py
Project.discover
def discover(): """ Automatically discover the paths to various data folders in this project and compose a Project instance. Returns: A constructed Project object. Raises: ValueError: if the paths could not be figured out automatically. I...
python
def discover(): """ Automatically discover the paths to various data folders in this project and compose a Project instance. Returns: A constructed Project object. Raises: ValueError: if the paths could not be figured out automatically. I...
[ "def", "discover", "(", ")", ":", "# Try ../data: we're most likely running a Jupyter notebook from the 'notebooks' directory", "candidate_path", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "curdir", ",", "os", ".", ...
Automatically discover the paths to various data folders in this project and compose a Project instance. Returns: A constructed Project object. Raises: ValueError: if the paths could not be figured out automatically. In this case, you have to create a Pr...
[ "Automatically", "discover", "the", "paths", "to", "various", "data", "folders", "in", "this", "project", "and", "compose", "a", "Project", "instance", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/project.py#L170-L199
train
Automatically discover the paths to various data folders in this project and compose a Project instance.
YuriyGuts/pygoose
pygoose/kg/project.py
Project.init
def init(): """ Creates the project infrastructure assuming the current directory is the project root. Typically used as a command-line entry point called by `pygoose init`. """ project = Project(os.path.abspath(os.getcwd())) paths_to_create = [ project.data_...
python
def init(): """ Creates the project infrastructure assuming the current directory is the project root. Typically used as a command-line entry point called by `pygoose init`. """ project = Project(os.path.abspath(os.getcwd())) paths_to_create = [ project.data_...
[ "def", "init", "(", ")", ":", "project", "=", "Project", "(", "os", ".", "path", ".", "abspath", "(", "os", ".", "getcwd", "(", ")", ")", ")", "paths_to_create", "=", "[", "project", ".", "data_dir", ",", "project", ".", "notebooks_dir", ",", "projec...
Creates the project infrastructure assuming the current directory is the project root. Typically used as a command-line entry point called by `pygoose init`.
[ "Creates", "the", "project", "infrastructure", "assuming", "the", "current", "directory", "is", "the", "project", "root", ".", "Typically", "used", "as", "a", "command", "-", "line", "entry", "point", "called", "by", "pygoose", "init", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/project.py#L202-L221
train
Creates the project infrastructure assuming the current directory is the project root.
tmr232/awesomelib
awesome/iterator.py
pairwise
def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) return izip(a, b)
python
def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) return izip(a, b)
[ "def", "pairwise", "(", "iterable", ")", ":", "a", ",", "b", "=", "tee", "(", "iterable", ")", "next", "(", "b", ",", "None", ")", "return", "izip", "(", "a", ",", "b", ")" ]
s -> (s0,s1), (s1,s2), (s2, s3), ...
[ "s", "-", ">", "(", "s0", "s1", ")", "(", "s1", "s2", ")", "(", "s2", "s3", ")", "..." ]
69a63466a63679f9e2abac8a719853a5e527219c
https://github.com/tmr232/awesomelib/blob/69a63466a63679f9e2abac8a719853a5e527219c/awesome/iterator.py#L70-L74
train
s -> s0 s1 s2 s3...
tmr232/awesomelib
awesome/iterator.py
unique_justseen
def unique_justseen(iterable, key=None): "List unique elements, preserving order. Remember only the element just seen." # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B # unique_justseen('ABBCcAD', str.lower) --> A B C A D return imap(next, imap(operator.itemgetter(1), groupby(iterable, key)))
python
def unique_justseen(iterable, key=None): "List unique elements, preserving order. Remember only the element just seen." # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B # unique_justseen('ABBCcAD', str.lower) --> A B C A D return imap(next, imap(operator.itemgetter(1), groupby(iterable, key)))
[ "def", "unique_justseen", "(", "iterable", ",", "key", "=", "None", ")", ":", "# unique_justseen('AAAABBBCCDAABBB') --> A B C D A B", "# unique_justseen('ABBCcAD', str.lower) --> A B C A D", "return", "imap", "(", "next", ",", "imap", "(", "operator", ".", "itemgetter", "...
List unique elements, preserving order. Remember only the element just seen.
[ "List", "unique", "elements", "preserving", "order", ".", "Remember", "only", "the", "element", "just", "seen", "." ]
69a63466a63679f9e2abac8a719853a5e527219c
https://github.com/tmr232/awesomelib/blob/69a63466a63679f9e2abac8a719853a5e527219c/awesome/iterator.py#L122-L126
train
List unique elements preserving order. Remember only the element just seen.
Erotemic/utool
utool/util_inject.py
_get_module
def _get_module(module_name=None, module=None, register=True): """ finds module in sys.modules based on module name unless the module has already been found and is passed in """ if module is None and module_name is not None: try: module = sys.modules[module_name] except KeyError ...
python
def _get_module(module_name=None, module=None, register=True): """ finds module in sys.modules based on module name unless the module has already been found and is passed in """ if module is None and module_name is not None: try: module = sys.modules[module_name] except KeyError ...
[ "def", "_get_module", "(", "module_name", "=", "None", ",", "module", "=", "None", ",", "register", "=", "True", ")", ":", "if", "module", "is", "None", "and", "module_name", "is", "not", "None", ":", "try", ":", "module", "=", "sys", ".", "modules", ...
finds module in sys.modules based on module name unless the module has already been found and is passed in
[ "finds", "module", "in", "sys", ".", "modules", "based", "on", "module", "name", "unless", "the", "module", "has", "already", "been", "found", "and", "is", "passed", "in" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L86-L102
train
returns module if module_name is not None and module is not None
Erotemic/utool
utool/util_inject.py
colored_pygments_excepthook
def colored_pygments_excepthook(type_, value, tb): """ References: https://stackoverflow.com/questions/14775916/color-exceptions-python CommandLine: python -m utool.util_inject --test-colored_pygments_excepthook """ tbtext = ''.join(traceback.format_exception(type_, value, tb)) ...
python
def colored_pygments_excepthook(type_, value, tb): """ References: https://stackoverflow.com/questions/14775916/color-exceptions-python CommandLine: python -m utool.util_inject --test-colored_pygments_excepthook """ tbtext = ''.join(traceback.format_exception(type_, value, tb)) ...
[ "def", "colored_pygments_excepthook", "(", "type_", ",", "value", ",", "tb", ")", ":", "tbtext", "=", "''", ".", "join", "(", "traceback", ".", "format_exception", "(", "type_", ",", "value", ",", "tb", ")", ")", "try", ":", "from", "utool", "import", ...
References: https://stackoverflow.com/questions/14775916/color-exceptions-python CommandLine: python -m utool.util_inject --test-colored_pygments_excepthook
[ "References", ":", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "14775916", "/", "color", "-", "exceptions", "-", "python" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L105-L126
train
A python excepthook that prints a formatted traceback to stderr
Erotemic/utool
utool/util_inject.py
inject_colored_exceptions
def inject_colored_exceptions(): """ Causes exceptions to be colored if not already Hooks into sys.excepthook CommandLine: python -m utool.util_inject --test-inject_colored_exceptions Example: >>> # DISABLE_DOCTEST >>> from utool.util_inject import * # NOQA >>> pr...
python
def inject_colored_exceptions(): """ Causes exceptions to be colored if not already Hooks into sys.excepthook CommandLine: python -m utool.util_inject --test-inject_colored_exceptions Example: >>> # DISABLE_DOCTEST >>> from utool.util_inject import * # NOQA >>> pr...
[ "def", "inject_colored_exceptions", "(", ")", ":", "#COLORED_INJECTS = '--nocolorex' not in sys.argv", "#COLORED_INJECTS = '--colorex' in sys.argv", "# Ignore colored exceptions on win32", "if", "VERBOSE", ":", "print", "(", "'[inject] injecting colored exceptions'", ")", "if", "not"...
Causes exceptions to be colored if not already Hooks into sys.excepthook CommandLine: python -m utool.util_inject --test-inject_colored_exceptions Example: >>> # DISABLE_DOCTEST >>> from utool.util_inject import * # NOQA >>> print('sys.excepthook = %r ' % (sys.excepthook,...
[ "Causes", "exceptions", "to", "be", "colored", "if", "not", "already" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L135-L166
train
Injects exceptions to be colored if not already there
Erotemic/utool
utool/util_inject.py
inject_print_functions
def inject_print_functions(module_name=None, module_prefix='[???]', DEBUG=False, module=None): """ makes print functions to be injected into the module """ module = _get_module(module_name, module) if SILENT: def print(*args): """ silent builtins.print ...
python
def inject_print_functions(module_name=None, module_prefix='[???]', DEBUG=False, module=None): """ makes print functions to be injected into the module """ module = _get_module(module_name, module) if SILENT: def print(*args): """ silent builtins.print ...
[ "def", "inject_print_functions", "(", "module_name", "=", "None", ",", "module_prefix", "=", "'[???]'", ",", "DEBUG", "=", "False", ",", "module", "=", "None", ")", ":", "module", "=", "_get_module", "(", "module_name", ",", "module", ")", "if", "SILENT", ...
makes print functions to be injected into the module
[ "makes", "print", "functions", "to", "be", "injected", "into", "the", "module" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L207-L272
train
Injects print functions into the module
Erotemic/utool
utool/util_inject.py
make_module_reload_func
def make_module_reload_func(module_name=None, module_prefix='[???]', module=None): """ Injects dynamic module reloading """ module = _get_module(module_name, module, register=False) if module_name is None: module_name = str(module.__name__) def rrr(verbose=True): """ Dynamic module reloa...
python
def make_module_reload_func(module_name=None, module_prefix='[???]', module=None): """ Injects dynamic module reloading """ module = _get_module(module_name, module, register=False) if module_name is None: module_name = str(module.__name__) def rrr(verbose=True): """ Dynamic module reloa...
[ "def", "make_module_reload_func", "(", "module_name", "=", "None", ",", "module_prefix", "=", "'[???]'", ",", "module", "=", "None", ")", ":", "module", "=", "_get_module", "(", "module_name", ",", "module", ",", "register", "=", "False", ")", "if", "module_...
Injects dynamic module reloading
[ "Injects", "dynamic", "module", "reloading" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L298-L318
train
Creates a function that reloads the specified module.
Erotemic/utool
utool/util_inject.py
noinject
def noinject(module_name=None, module_prefix='[???]', DEBUG=False, module=None, N=0, via=None): """ Use in modules that do not have inject in them Does not inject anything into the module. Just lets utool know that a module is being imported so the import order can be debuged """ if PRINT_INJEC...
python
def noinject(module_name=None, module_prefix='[???]', DEBUG=False, module=None, N=0, via=None): """ Use in modules that do not have inject in them Does not inject anything into the module. Just lets utool know that a module is being imported so the import order can be debuged """ if PRINT_INJEC...
[ "def", "noinject", "(", "module_name", "=", "None", ",", "module_prefix", "=", "'[???]'", ",", "DEBUG", "=", "False", ",", "module", "=", "None", ",", "N", "=", "0", ",", "via", "=", "None", ")", ":", "if", "PRINT_INJECT_ORDER", ":", "from", "utool", ...
Use in modules that do not have inject in them Does not inject anything into the module. Just lets utool know that a module is being imported so the import order can be debuged
[ "Use", "in", "modules", "that", "do", "not", "have", "inject", "in", "them" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L441-L470
train
This function is used to not inject a module into the module
Erotemic/utool
utool/util_inject.py
inject
def inject(module_name=None, module_prefix='[???]', DEBUG=False, module=None, N=1): """ Injects your module with utool magic Utool magic is not actually magic. It just turns your ``print`` statments into logging statments, allows for your module to be used with the utool.Indent context manager and ...
python
def inject(module_name=None, module_prefix='[???]', DEBUG=False, module=None, N=1): """ Injects your module with utool magic Utool magic is not actually magic. It just turns your ``print`` statments into logging statments, allows for your module to be used with the utool.Indent context manager and ...
[ "def", "inject", "(", "module_name", "=", "None", ",", "module_prefix", "=", "'[???]'", ",", "DEBUG", "=", "False", ",", "module", "=", "None", ",", "N", "=", "1", ")", ":", "#noinject(module_name, module_prefix, DEBUG, module, N=1)", "noinject", "(", "module_na...
Injects your module with utool magic Utool magic is not actually magic. It just turns your ``print`` statments into logging statments, allows for your module to be used with the utool.Indent context manager and the and utool.indent_func decorator. ``printDBG`` will soon be deprecated as will ``print_``...
[ "Injects", "your", "module", "with", "utool", "magic" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L473-L508
train
Injects a module with utool magic
Erotemic/utool
utool/util_inject.py
inject2
def inject2(module_name=None, module_prefix=None, DEBUG=False, module=None, N=1): """ wrapper that depricates print_ and printDBG """ if module_prefix is None: module_prefix = '[%s]' % (module_name,) noinject(module_name, module_prefix, DEBUG, module, N=N) module = _get_module(module_name, modul...
python
def inject2(module_name=None, module_prefix=None, DEBUG=False, module=None, N=1): """ wrapper that depricates print_ and printDBG """ if module_prefix is None: module_prefix = '[%s]' % (module_name,) noinject(module_name, module_prefix, DEBUG, module, N=N) module = _get_module(module_name, modul...
[ "def", "inject2", "(", "module_name", "=", "None", ",", "module_prefix", "=", "None", ",", "DEBUG", "=", "False", ",", "module", "=", "None", ",", "N", "=", "1", ")", ":", "if", "module_prefix", "is", "None", ":", "module_prefix", "=", "'[%s]'", "%", ...
wrapper that depricates print_ and printDBG
[ "wrapper", "that", "depricates", "print_", "and", "printDBG" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L511-L520
train
wrapper that depricates print_ and printDBG
Erotemic/utool
utool/util_inject.py
split_python_text_into_lines
def split_python_text_into_lines(text): """ # TODO: make it so this function returns text so one statment is on one # line that means no splitting up things like function definitions into # multiple lines """ #import jedi #script = jedi.Script(text, line=1, column=None, path='') def pare...
python
def split_python_text_into_lines(text): """ # TODO: make it so this function returns text so one statment is on one # line that means no splitting up things like function definitions into # multiple lines """ #import jedi #script = jedi.Script(text, line=1, column=None, path='') def pare...
[ "def", "split_python_text_into_lines", "(", "text", ")", ":", "#import jedi", "#script = jedi.Script(text, line=1, column=None, path='')", "def", "parentesis_are_balanced", "(", "line", ")", ":", "\"\"\"\n helper\n\n References:\n http://stackoverflow.com/questio...
# TODO: make it so this function returns text so one statment is on one # line that means no splitting up things like function definitions into # multiple lines
[ "#", "TODO", ":", "make", "it", "so", "this", "function", "returns", "text", "so", "one", "statment", "is", "on", "one", "#", "line", "that", "means", "no", "splitting", "up", "things", "like", "function", "definitions", "into", "#", "multiple", "lines" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L523-L558
train
split python text into multiple lines
Erotemic/utool
utool/util_inject.py
inject_python_code2
def inject_python_code2(fpath, patch_code, tag): """ Does autogeneration stuff """ import utool as ut text = ut.readfrom(fpath) start_tag = '# <%s>' % tag end_tag = '# </%s>' % tag new_text = ut.replace_between_tags(text, patch_code, start_tag, end_tag) ut.writeto(fpath, new_text)
python
def inject_python_code2(fpath, patch_code, tag): """ Does autogeneration stuff """ import utool as ut text = ut.readfrom(fpath) start_tag = '# <%s>' % tag end_tag = '# </%s>' % tag new_text = ut.replace_between_tags(text, patch_code, start_tag, end_tag) ut.writeto(fpath, new_text)
[ "def", "inject_python_code2", "(", "fpath", ",", "patch_code", ",", "tag", ")", ":", "import", "utool", "as", "ut", "text", "=", "ut", ".", "readfrom", "(", "fpath", ")", "start_tag", "=", "'# <%s>'", "%", "tag", "end_tag", "=", "'# </%s>'", "%", "tag", ...
Does autogeneration stuff
[ "Does", "autogeneration", "stuff" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L561-L568
train
Injects python code into the tree
Erotemic/utool
utool/util_inject.py
inject_python_code
def inject_python_code(fpath, patch_code, tag=None, inject_location='after_imports'): """ DEPRICATE puts code into files on disk """ import utool as ut assert tag is not None, 'TAG MUST BE SPECIFIED IN INJECTED CODETEXT' text = ut.read_from(fpath) comment_start_tag...
python
def inject_python_code(fpath, patch_code, tag=None, inject_location='after_imports'): """ DEPRICATE puts code into files on disk """ import utool as ut assert tag is not None, 'TAG MUST BE SPECIFIED IN INJECTED CODETEXT' text = ut.read_from(fpath) comment_start_tag...
[ "def", "inject_python_code", "(", "fpath", ",", "patch_code", ",", "tag", "=", "None", ",", "inject_location", "=", "'after_imports'", ")", ":", "import", "utool", "as", "ut", "assert", "tag", "is", "not", "None", ",", "'TAG MUST BE SPECIFIED IN INJECTED CODETEXT'...
DEPRICATE puts code into files on disk
[ "DEPRICATE", "puts", "code", "into", "files", "on", "disk" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inject.py#L571-L622
train
injects code into the file
Erotemic/utool
utool/Printable.py
printableType
def printableType(val, name=None, parent=None): """ Tries to make a nice type string for a value. Can also pass in a Printable parent object """ import numpy as np if parent is not None and hasattr(parent, 'customPrintableType'): # Hack for non - trivial preference types _typestr...
python
def printableType(val, name=None, parent=None): """ Tries to make a nice type string for a value. Can also pass in a Printable parent object """ import numpy as np if parent is not None and hasattr(parent, 'customPrintableType'): # Hack for non - trivial preference types _typestr...
[ "def", "printableType", "(", "val", ",", "name", "=", "None", ",", "parent", "=", "None", ")", ":", "import", "numpy", "as", "np", "if", "parent", "is", "not", "None", "and", "hasattr", "(", "parent", ",", "'customPrintableType'", ")", ":", "# Hack for n...
Tries to make a nice type string for a value. Can also pass in a Printable parent object
[ "Tries", "to", "make", "a", "nice", "type", "string", "for", "a", "value", ".", "Can", "also", "pass", "in", "a", "Printable", "parent", "object" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Printable.py#L96-L118
train
Tries to make a nice type string for a value. Can also pass in a Printable parent object.
Erotemic/utool
utool/Printable.py
printableVal
def printableVal(val, type_bit=True, justlength=False): """ Very old way of doing pretty printing. Need to update and refactor. DEPRICATE """ from utool import util_dev # Move to util_dev # NUMPY ARRAY import numpy as np if type(val) is np.ndarray: info = npArrInfo(val) ...
python
def printableVal(val, type_bit=True, justlength=False): """ Very old way of doing pretty printing. Need to update and refactor. DEPRICATE """ from utool import util_dev # Move to util_dev # NUMPY ARRAY import numpy as np if type(val) is np.ndarray: info = npArrInfo(val) ...
[ "def", "printableVal", "(", "val", ",", "type_bit", "=", "True", ",", "justlength", "=", "False", ")", ":", "from", "utool", "import", "util_dev", "# Move to util_dev", "# NUMPY ARRAY", "import", "numpy", "as", "np", "if", "type", "(", "val", ")", "is", "n...
Very old way of doing pretty printing. Need to update and refactor. DEPRICATE
[ "Very", "old", "way", "of", "doing", "pretty", "printing", ".", "Need", "to", "update", "and", "refactor", ".", "DEPRICATE" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Printable.py#L121-L163
train
Returns a string representation of the object
Erotemic/utool
utool/Printable.py
npArrInfo
def npArrInfo(arr): """ OLD update and refactor """ from utool.DynamicStruct import DynStruct info = DynStruct() info.shapestr = '[' + ' x '.join([str(x) for x in arr.shape]) + ']' info.dtypestr = str(arr.dtype) if info.dtypestr == 'bool': info.bittotal = 'T=%d, F=%d' % (sum(ar...
python
def npArrInfo(arr): """ OLD update and refactor """ from utool.DynamicStruct import DynStruct info = DynStruct() info.shapestr = '[' + ' x '.join([str(x) for x in arr.shape]) + ']' info.dtypestr = str(arr.dtype) if info.dtypestr == 'bool': info.bittotal = 'T=%d, F=%d' % (sum(ar...
[ "def", "npArrInfo", "(", "arr", ")", ":", "from", "utool", ".", "DynamicStruct", "import", "DynStruct", "info", "=", "DynStruct", "(", ")", "info", ".", "shapestr", "=", "'['", "+", "' x '", ".", "join", "(", "[", "str", "(", "x", ")", "for", "x", ...
OLD update and refactor
[ "OLD", "update", "and", "refactor" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Printable.py#L166-L185
train
Returns a DynStruct with the information of the array
quikmile/trellio
trellio/conf_manager/conf_client.py
ConfigHandler.enable_signals
def enable_signals(self): ''' e.g signal_dict = {signal_path:signal_receiver_path_list, ....} :return: ''' signal_dict = self.settings[self.signal_key] or {} for i in signal_dict.keys(): sig_module, signal_class = self.import_class_from_path(i) for...
python
def enable_signals(self): ''' e.g signal_dict = {signal_path:signal_receiver_path_list, ....} :return: ''' signal_dict = self.settings[self.signal_key] or {} for i in signal_dict.keys(): sig_module, signal_class = self.import_class_from_path(i) for...
[ "def", "enable_signals", "(", "self", ")", ":", "signal_dict", "=", "self", ".", "settings", "[", "self", ".", "signal_key", "]", "or", "{", "}", "for", "i", "in", "signal_dict", ".", "keys", "(", ")", ":", "sig_module", ",", "signal_class", "=", "self...
e.g signal_dict = {signal_path:signal_receiver_path_list, ....} :return:
[ "e", ".", "g", "signal_dict", "=", "{", "signal_path", ":", "signal_receiver_path_list", "....", "}", ":", "return", ":" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/conf_manager/conf_client.py#L288-L298
train
Enable all the signals in the current module.
glormph/msstitch
src/app/actions/mzidtsv/isonormalize.py
get_isobaric_ratios
def get_isobaric_ratios(psmfn, psmheader, channels, denom_channels, min_int, targetfn, accessioncol, normalize, normratiofn): """Main function to calculate ratios for PSMs, peptides, proteins, genes. Can do simple ratios, median-of-ratios and median-centering normalization.""" ps...
python
def get_isobaric_ratios(psmfn, psmheader, channels, denom_channels, min_int, targetfn, accessioncol, normalize, normratiofn): """Main function to calculate ratios for PSMs, peptides, proteins, genes. Can do simple ratios, median-of-ratios and median-centering normalization.""" ps...
[ "def", "get_isobaric_ratios", "(", "psmfn", ",", "psmheader", ",", "channels", ",", "denom_channels", ",", "min_int", ",", "targetfn", ",", "accessioncol", ",", "normalize", ",", "normratiofn", ")", ":", "psm_or_feat_ratios", "=", "get_psmratios", "(", "psmfn", ...
Main function to calculate ratios for PSMs, peptides, proteins, genes. Can do simple ratios, median-of-ratios and median-centering normalization.
[ "Main", "function", "to", "calculate", "ratios", "for", "PSMs", "peptides", "proteins", "genes", ".", "Can", "do", "simple", "ratios", "median", "-", "of", "-", "ratios", "and", "median", "-", "centering", "normalization", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/isonormalize.py#L13-L45
train
Main function to calculate ratios for PSMs peptides proteins genes and their corresponding isobaric features.
glormph/msstitch
src/app/actions/mzidtsv/isonormalize.py
calculate_normalized_ratios
def calculate_normalized_ratios(ratios, ch_medians, channels): """Calculates ratios for PSM tables containing isobaric channels with raw intensities. Normalizes the ratios by median. NA values or values below min_intensity are excluded from the normalization.""" outratios = [] for quant in ratios: ...
python
def calculate_normalized_ratios(ratios, ch_medians, channels): """Calculates ratios for PSM tables containing isobaric channels with raw intensities. Normalizes the ratios by median. NA values or values below min_intensity are excluded from the normalization.""" outratios = [] for quant in ratios: ...
[ "def", "calculate_normalized_ratios", "(", "ratios", ",", "ch_medians", ",", "channels", ")", ":", "outratios", "=", "[", "]", "for", "quant", "in", "ratios", ":", "quant", ".", "update", "(", "{", "ch", ":", "str", "(", "quant", "[", "ch", "]", "/", ...
Calculates ratios for PSM tables containing isobaric channels with raw intensities. Normalizes the ratios by median. NA values or values below min_intensity are excluded from the normalization.
[ "Calculates", "ratios", "for", "PSM", "tables", "containing", "isobaric", "channels", "with", "raw", "intensities", ".", "Normalizes", "the", "ratios", "by", "median", ".", "NA", "values", "or", "values", "below", "min_intensity", "are", "excluded", "from", "the...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/isonormalize.py#L157-L166
train
Calculates the ratios for PSM tables containing isobaric channels with raw intensities. Normalizes the ratios by median. NA values are excluded from the normalization.
glormph/msstitch
src/app/actions/mzidtsv/isonormalize.py
get_normalized_ratios
def get_normalized_ratios(psmfn, header, channels, denom_channels, min_intensity, second_psmfn, secondheader): """Calculates ratios for PSM tables containing isobaric channels with raw intensities. Normalizes the ratios by median. NA values or values below min_intensity are exclude...
python
def get_normalized_ratios(psmfn, header, channels, denom_channels, min_intensity, second_psmfn, secondheader): """Calculates ratios for PSM tables containing isobaric channels with raw intensities. Normalizes the ratios by median. NA values or values below min_intensity are exclude...
[ "def", "get_normalized_ratios", "(", "psmfn", ",", "header", ",", "channels", ",", "denom_channels", ",", "min_intensity", ",", "second_psmfn", ",", "secondheader", ")", ":", "ratios", "=", "[", "]", "if", "second_psmfn", "is", "not", "None", ":", "median_psmf...
Calculates ratios for PSM tables containing isobaric channels with raw intensities. Normalizes the ratios by median. NA values or values below min_intensity are excluded from the normalization.
[ "Calculates", "ratios", "for", "PSM", "tables", "containing", "isobaric", "channels", "with", "raw", "intensities", ".", "Normalizes", "the", "ratios", "by", "median", ".", "NA", "values", "or", "values", "below", "min_intensity", "are", "excluded", "from", "the...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/isonormalize.py#L169-L195
train
Calculates ratios for PSM tables containing isobaric channels with raw intensities.
timedata-org/loady
loady/files.py
sanitize
def sanitize(value): """Strips all undesirable characters out of potential file paths.""" value = unicodedata.normalize('NFKD', value) value = value.strip() value = re.sub('[^./\w\s-]', '', value) value = re.sub('[-\s]+', '-', value) return value
python
def sanitize(value): """Strips all undesirable characters out of potential file paths.""" value = unicodedata.normalize('NFKD', value) value = value.strip() value = re.sub('[^./\w\s-]', '', value) value = re.sub('[-\s]+', '-', value) return value
[ "def", "sanitize", "(", "value", ")", ":", "value", "=", "unicodedata", ".", "normalize", "(", "'NFKD'", ",", "value", ")", "value", "=", "value", ".", "strip", "(", ")", "value", "=", "re", ".", "sub", "(", "'[^./\\w\\s-]'", ",", "''", ",", "value",...
Strips all undesirable characters out of potential file paths.
[ "Strips", "all", "undesirable", "characters", "out", "of", "potential", "file", "paths", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/files.py#L10-L18
train
Strips all undesirable characters out of potential file paths.
timedata-org/loady
loady/files.py
remove_on_exception
def remove_on_exception(dirname, remove=True): """Creates a directory, yields to the caller, and removes that directory if an exception is thrown.""" os.makedirs(dirname) try: yield except: if remove: shutil.rmtree(dirname, ignore_errors=True) raise
python
def remove_on_exception(dirname, remove=True): """Creates a directory, yields to the caller, and removes that directory if an exception is thrown.""" os.makedirs(dirname) try: yield except: if remove: shutil.rmtree(dirname, ignore_errors=True) raise
[ "def", "remove_on_exception", "(", "dirname", ",", "remove", "=", "True", ")", ":", "os", ".", "makedirs", "(", "dirname", ")", "try", ":", "yield", "except", ":", "if", "remove", ":", "shutil", ".", "rmtree", "(", "dirname", ",", "ignore_errors", "=", ...
Creates a directory, yields to the caller, and removes that directory if an exception is thrown.
[ "Creates", "a", "directory", "yields", "to", "the", "caller", "and", "removes", "that", "directory", "if", "an", "exception", "is", "thrown", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/files.py#L22-L31
train
Creates a directory and removes that directory if an exception is thrown.
glormph/msstitch
src/app/actions/mzidtsv/percolator.py
add_percolator_to_mzidtsv
def add_percolator_to_mzidtsv(mzidfn, tsvfn, multipsm, oldheader): """Takes a MSGF+ tsv and corresponding mzId, adds percolatordata to tsv lines. Generator yields the lines. Multiple PSMs per scan can be delivered, in which case rank is also reported. """ namespace = readers.get_mzid_namespace(mzidf...
python
def add_percolator_to_mzidtsv(mzidfn, tsvfn, multipsm, oldheader): """Takes a MSGF+ tsv and corresponding mzId, adds percolatordata to tsv lines. Generator yields the lines. Multiple PSMs per scan can be delivered, in which case rank is also reported. """ namespace = readers.get_mzid_namespace(mzidf...
[ "def", "add_percolator_to_mzidtsv", "(", "mzidfn", ",", "tsvfn", ",", "multipsm", ",", "oldheader", ")", ":", "namespace", "=", "readers", ".", "get_mzid_namespace", "(", "mzidfn", ")", "try", ":", "xmlns", "=", "'{%s}'", "%", "namespace", "[", "'xmlns'", "]...
Takes a MSGF+ tsv and corresponding mzId, adds percolatordata to tsv lines. Generator yields the lines. Multiple PSMs per scan can be delivered, in which case rank is also reported.
[ "Takes", "a", "MSGF", "+", "tsv", "and", "corresponding", "mzId", "adds", "percolatordata", "to", "tsv", "lines", ".", "Generator", "yields", "the", "lines", ".", "Multiple", "PSMs", "per", "scan", "can", "be", "delivered", "in", "which", "case", "rank", "...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/percolator.py#L6-L39
train
Takes a MSGF + tsv and corresponding mzId adds percolator data to tsv lines. Generator yields the lines.
Erotemic/utool
utool/util_profile.py
parse_rawprofile_blocks
def parse_rawprofile_blocks(text): """ Split the file into blocks along delimters and and put delimeters back in the list """ # The total time reported in the raw output is from pystone not kernprof # The pystone total time is actually the average time spent in the function delim = 'Total ti...
python
def parse_rawprofile_blocks(text): """ Split the file into blocks along delimters and and put delimeters back in the list """ # The total time reported in the raw output is from pystone not kernprof # The pystone total time is actually the average time spent in the function delim = 'Total ti...
[ "def", "parse_rawprofile_blocks", "(", "text", ")", ":", "# The total time reported in the raw output is from pystone not kernprof", "# The pystone total time is actually the average time spent in the function", "delim", "=", "'Total time: '", "delim2", "=", "'Pystone time: '", "#delim =...
Split the file into blocks along delimters and and put delimeters back in the list
[ "Split", "the", "file", "into", "blocks", "along", "delimters", "and", "and", "put", "delimeters", "back", "in", "the", "list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_profile.py#L78-L91
train
Split the rawprofile output into blocks along delimters and put delimeters back in
Erotemic/utool
utool/util_profile.py
parse_timemap_from_blocks
def parse_timemap_from_blocks(profile_block_list): """ Build a map from times to line_profile blocks """ prefix_list = [] timemap = ut.ddict(list) for ix in range(len(profile_block_list)): block = profile_block_list[ix] total_time = get_block_totaltime(block) # Blocks wit...
python
def parse_timemap_from_blocks(profile_block_list): """ Build a map from times to line_profile blocks """ prefix_list = [] timemap = ut.ddict(list) for ix in range(len(profile_block_list)): block = profile_block_list[ix] total_time = get_block_totaltime(block) # Blocks wit...
[ "def", "parse_timemap_from_blocks", "(", "profile_block_list", ")", ":", "prefix_list", "=", "[", "]", "timemap", "=", "ut", ".", "ddict", "(", "list", ")", "for", "ix", "in", "range", "(", "len", "(", "profile_block_list", ")", ")", ":", "block", "=", "...
Build a map from times to line_profile blocks
[ "Build", "a", "map", "from", "times", "to", "line_profile", "blocks" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_profile.py#L123-L138
train
Build a map from times to line_profile blocks
Erotemic/utool
utool/util_profile.py
get_summary
def get_summary(profile_block_list, maxlines=20): """ References: https://github.com/rkern/line_profiler """ time_list = [get_block_totaltime(block) for block in profile_block_list] time_list = [time if time is not None else -1 for time in time_list] blockid_list = [get_block_id(block) f...
python
def get_summary(profile_block_list, maxlines=20): """ References: https://github.com/rkern/line_profiler """ time_list = [get_block_totaltime(block) for block in profile_block_list] time_list = [time if time is not None else -1 for time in time_list] blockid_list = [get_block_id(block) f...
[ "def", "get_summary", "(", "profile_block_list", ",", "maxlines", "=", "20", ")", ":", "time_list", "=", "[", "get_block_totaltime", "(", "block", ")", "for", "block", "in", "profile_block_list", "]", "time_list", "=", "[", "time", "if", "time", "is", "not",...
References: https://github.com/rkern/line_profiler
[ "References", ":", "https", ":", "//", "github", ".", "com", "/", "rkern", "/", "line_profiler" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_profile.py#L141-L170
train
Returns a summary of the profile_block_list.
Erotemic/utool
utool/util_profile.py
clean_line_profile_text
def clean_line_profile_text(text): """ Sorts the output from line profile by execution time Removes entries which were not run """ # profile_block_list = parse_rawprofile_blocks(text) #profile_block_list = fix_rawprofile_blocks(profile_block_list) #--- # FIXME can be written much nic...
python
def clean_line_profile_text(text): """ Sorts the output from line profile by execution time Removes entries which were not run """ # profile_block_list = parse_rawprofile_blocks(text) #profile_block_list = fix_rawprofile_blocks(profile_block_list) #--- # FIXME can be written much nic...
[ "def", "clean_line_profile_text", "(", "text", ")", ":", "#", "profile_block_list", "=", "parse_rawprofile_blocks", "(", "text", ")", "#profile_block_list = fix_rawprofile_blocks(profile_block_list)", "#---", "# FIXME can be written much nicer", "prefix_list", ",", "timemap", "...
Sorts the output from line profile by execution time Removes entries which were not run
[ "Sorts", "the", "output", "from", "line", "profile", "by", "execution", "time", "Removes", "entries", "which", "were", "not", "run" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_profile.py#L191-L213
train
Takes the output of line profile and returns the output text and summary text
Erotemic/utool
utool/util_profile.py
clean_lprof_file
def clean_lprof_file(input_fname, output_fname=None): """ Reads a .lprof file and cleans it """ # Read the raw .lprof text dump text = ut.read_from(input_fname) # Sort and clean the text output_text = clean_line_profile_text(text) return output_text
python
def clean_lprof_file(input_fname, output_fname=None): """ Reads a .lprof file and cleans it """ # Read the raw .lprof text dump text = ut.read_from(input_fname) # Sort and clean the text output_text = clean_line_profile_text(text) return output_text
[ "def", "clean_lprof_file", "(", "input_fname", ",", "output_fname", "=", "None", ")", ":", "# Read the raw .lprof text dump", "text", "=", "ut", ".", "read_from", "(", "input_fname", ")", "# Sort and clean the text", "output_text", "=", "clean_line_profile_text", "(", ...
Reads a .lprof file and cleans it
[ "Reads", "a", ".", "lprof", "file", "and", "cleans", "it" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_profile.py#L216-L222
train
Reads a. lprof file and cleans it
YuriyGuts/pygoose
pygoose/kg/keras.py
get_class_weights
def get_class_weights(y, smooth_factor=0): """ Returns the weights for each class based on the frequencies of the samples. Args: y: A list of true labels (the labels must be hashable). smooth_factor: A factor that smooths extremely uneven weights. Returns: A dictionary with the...
python
def get_class_weights(y, smooth_factor=0): """ Returns the weights for each class based on the frequencies of the samples. Args: y: A list of true labels (the labels must be hashable). smooth_factor: A factor that smooths extremely uneven weights. Returns: A dictionary with the...
[ "def", "get_class_weights", "(", "y", ",", "smooth_factor", "=", "0", ")", ":", "from", "collections", "import", "Counter", "counter", "=", "Counter", "(", "y", ")", "if", "smooth_factor", ">", "0", ":", "p", "=", "max", "(", "counter", ".", "values", ...
Returns the weights for each class based on the frequencies of the samples. Args: y: A list of true labels (the labels must be hashable). smooth_factor: A factor that smooths extremely uneven weights. Returns: A dictionary with the weight for each class.
[ "Returns", "the", "weights", "for", "each", "class", "based", "on", "the", "frequencies", "of", "the", "samples", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/keras.py#L4-L26
train
Returns the weights for each class based on the frequencies of the samples.
YuriyGuts/pygoose
pygoose/kg/keras.py
plot_loss_history
def plot_loss_history(history, figsize=(15, 8)): """ Plots the learning history for a Keras model, assuming the validation data was provided to the 'fit' function. Args: history: The return value from the 'fit' function. figsize: The size of the plot. """ plt.figure(figsize=fig...
python
def plot_loss_history(history, figsize=(15, 8)): """ Plots the learning history for a Keras model, assuming the validation data was provided to the 'fit' function. Args: history: The return value from the 'fit' function. figsize: The size of the plot. """ plt.figure(figsize=fig...
[ "def", "plot_loss_history", "(", "history", ",", "figsize", "=", "(", "15", ",", "8", ")", ")", ":", "plt", ".", "figure", "(", "figsize", "=", "figsize", ")", "plt", ".", "plot", "(", "history", ".", "history", "[", "\"loss\"", "]", ")", "plt", "....
Plots the learning history for a Keras model, assuming the validation data was provided to the 'fit' function. Args: history: The return value from the 'fit' function. figsize: The size of the plot.
[ "Plots", "the", "learning", "history", "for", "a", "Keras", "model", "assuming", "the", "validation", "data", "was", "provided", "to", "the", "fit", "function", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/keras.py#L29-L49
train
Plots the learning history for a Keras model