repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
Erotemic/utool
utool/experimental/euler_tour_tree_avl.py
avl_release_kids
def avl_release_kids(node): """ splits a node from its kids maintaining parent pointers """ left, right = node.left, node.right if left is not None: # assert left.parent is node left.parent = None if right is not None: # assert right.parent is node right.parent = ...
python
def avl_release_kids(node): """ splits a node from its kids maintaining parent pointers """ left, right = node.left, node.right if left is not None: # assert left.parent is node left.parent = None if right is not None: # assert right.parent is node right.parent = ...
[ "def", "avl_release_kids", "(", "node", ")", ":", "left", ",", "right", "=", "node", ".", "left", ",", "node", ".", "right", "if", "left", "is", "not", "None", ":", "left", ".", "parent", "=", "None", "if", "right", "is", "not", "None", ":", "right...
splits a node from its kids maintaining parent pointers
[ "splits", "a", "node", "from", "its", "kids", "maintaining", "parent", "pointers" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L500-L514
train
Erotemic/utool
utool/experimental/euler_tour_tree_avl.py
avl_release_parent
def avl_release_parent(node): """ removes the parent of a child """ parent = node.parent if parent is not None: if parent.right is node: parent.right = None elif parent.left is node: parent.left = None else: raise AssertionError('impossible...
python
def avl_release_parent(node): """ removes the parent of a child """ parent = node.parent if parent is not None: if parent.right is node: parent.right = None elif parent.left is node: parent.left = None else: raise AssertionError('impossible...
[ "def", "avl_release_parent", "(", "node", ")", ":", "parent", "=", "node", ".", "parent", "if", "parent", "is", "not", "None", ":", "if", "parent", ".", "right", "is", "node", ":", "parent", ".", "right", "=", "None", "elif", "parent", ".", "left", "...
removes the parent of a child
[ "removes", "the", "parent", "of", "a", "child" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L517-L531
train
Erotemic/utool
utool/experimental/euler_tour_tree_avl.py
avl_join
def avl_join(t1, t2, node): """ Joins two trees `t1` and `t1` with an intermediate key-value pair CommandLine: python -m utool.experimental.euler_tour_tree_avl avl_join Example: >>> # DISABLE_DOCTEST >>> from utool.experimental.euler_tour_tree_avl import * # NOQA >>> s...
python
def avl_join(t1, t2, node): """ Joins two trees `t1` and `t1` with an intermediate key-value pair CommandLine: python -m utool.experimental.euler_tour_tree_avl avl_join Example: >>> # DISABLE_DOCTEST >>> from utool.experimental.euler_tour_tree_avl import * # NOQA >>> s...
[ "def", "avl_join", "(", "t1", ",", "t2", ",", "node", ")", ":", "if", "DEBUG_JOIN", ":", "print", "(", "'-- JOIN node=%r'", "%", "(", "node", ",", ")", ")", "if", "t1", "is", "None", "and", "t2", "is", "None", ":", "if", "DEBUG_JOIN", ":", "print",...
Joins two trees `t1` and `t1` with an intermediate key-value pair CommandLine: python -m utool.experimental.euler_tour_tree_avl avl_join Example: >>> # DISABLE_DOCTEST >>> from utool.experimental.euler_tour_tree_avl import * # NOQA >>> self = EulerTourTree(['a', 'b', 'c', 'b',...
[ "Joins", "two", "trees", "t1", "and", "t1", "with", "an", "intermediate", "key", "-", "value", "pair" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L667-L746
train
Erotemic/utool
utool/experimental/euler_tour_tree_avl.py
avl_split_last
def avl_split_last(root): """ Removes the maximum element from the tree Returns: tuple: new_root, last_node O(log(n)) = O(height(root)) """ if root is None: raise IndexError('Empty tree has no maximum element') root, left, right = avl_release_kids(root) if right is None...
python
def avl_split_last(root): """ Removes the maximum element from the tree Returns: tuple: new_root, last_node O(log(n)) = O(height(root)) """ if root is None: raise IndexError('Empty tree has no maximum element') root, left, right = avl_release_kids(root) if right is None...
[ "def", "avl_split_last", "(", "root", ")", ":", "if", "root", "is", "None", ":", "raise", "IndexError", "(", "'Empty tree has no maximum element'", ")", "root", ",", "left", ",", "right", "=", "avl_release_kids", "(", "root", ")", "if", "right", "is", "None"...
Removes the maximum element from the tree Returns: tuple: new_root, last_node O(log(n)) = O(height(root))
[ "Removes", "the", "maximum", "element", "from", "the", "tree" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L749-L766
train
Erotemic/utool
utool/experimental/euler_tour_tree_avl.py
avl_split_first
def avl_split_first(root): """ Removes the minimum element from the tree Returns: tuple: new_root, first_node O(log(n)) = O(height(root)) """ if root is None: raise IndexError('Empty tree has no maximum element') root, left, right = avl_release_kids(root) if left is Non...
python
def avl_split_first(root): """ Removes the minimum element from the tree Returns: tuple: new_root, first_node O(log(n)) = O(height(root)) """ if root is None: raise IndexError('Empty tree has no maximum element') root, left, right = avl_release_kids(root) if left is Non...
[ "def", "avl_split_first", "(", "root", ")", ":", "if", "root", "is", "None", ":", "raise", "IndexError", "(", "'Empty tree has no maximum element'", ")", "root", ",", "left", ",", "right", "=", "avl_release_kids", "(", "root", ")", "if", "left", "is", "None"...
Removes the minimum element from the tree Returns: tuple: new_root, first_node O(log(n)) = O(height(root))
[ "Removes", "the", "minimum", "element", "from", "the", "tree" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L769-L786
train
Erotemic/utool
utool/experimental/euler_tour_tree_avl.py
avl_join2
def avl_join2(t1, t2): """ join two trees without any intermediate key Returns: Node: new_root O(log(n) + log(m)) = O(r(t1) + r(t2)) For AVL-Trees the rank r(t1) = height(t1) - 1 """ if t1 is None and t2 is None: new_root = None elif t2 is None: new_root = t1 ...
python
def avl_join2(t1, t2): """ join two trees without any intermediate key Returns: Node: new_root O(log(n) + log(m)) = O(r(t1) + r(t2)) For AVL-Trees the rank r(t1) = height(t1) - 1 """ if t1 is None and t2 is None: new_root = None elif t2 is None: new_root = t1 ...
[ "def", "avl_join2", "(", "t1", ",", "t2", ")", ":", "if", "t1", "is", "None", "and", "t2", "is", "None", ":", "new_root", "=", "None", "elif", "t2", "is", "None", ":", "new_root", "=", "t1", "elif", "t1", "is", "None", ":", "new_root", "=", "t2",...
join two trees without any intermediate key Returns: Node: new_root O(log(n) + log(m)) = O(r(t1) + r(t2)) For AVL-Trees the rank r(t1) = height(t1) - 1
[ "join", "two", "trees", "without", "any", "intermediate", "key" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L789-L831
train
Erotemic/utool
utool/experimental/euler_tour_tree_avl.py
EulerTourTree.to_networkx
def to_networkx(self, labels=None, edge_labels=False): """ Get a networkx representation of the binary search tree. """ import networkx as nx graph = nx.DiGraph() for node in self._traverse_nodes(): u = node.key graph.add_node(u) # Minor redundancy # ...
python
def to_networkx(self, labels=None, edge_labels=False): """ Get a networkx representation of the binary search tree. """ import networkx as nx graph = nx.DiGraph() for node in self._traverse_nodes(): u = node.key graph.add_node(u) # Minor redundancy # ...
[ "def", "to_networkx", "(", "self", ",", "labels", "=", "None", ",", "edge_labels", "=", "False", ")", ":", "import", "networkx", "as", "nx", "graph", "=", "nx", ".", "DiGraph", "(", ")", "for", "node", "in", "self", ".", "_traverse_nodes", "(", ")", ...
Get a networkx representation of the binary search tree.
[ "Get", "a", "networkx", "representation", "of", "the", "binary", "search", "tree", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L395-L419
train
Erotemic/utool
utool/experimental/euler_tour_tree_avl.py
EulerTourTree.repr_tree
def repr_tree(self): """ reconstruct represented tree as a DiGraph to preserve the current rootedness """ import utool as ut import networkx as nx repr_tree = nx.DiGraph() for u, v in ut.itertwo(self.values()): if not repr_tree.has_edge(v, u): ...
python
def repr_tree(self): """ reconstruct represented tree as a DiGraph to preserve the current rootedness """ import utool as ut import networkx as nx repr_tree = nx.DiGraph() for u, v in ut.itertwo(self.values()): if not repr_tree.has_edge(v, u): ...
[ "def", "repr_tree", "(", "self", ")", ":", "import", "utool", "as", "ut", "import", "networkx", "as", "nx", "repr_tree", "=", "nx", ".", "DiGraph", "(", ")", "for", "u", ",", "v", "in", "ut", ".", "itertwo", "(", "self", ".", "values", "(", ")", ...
reconstruct represented tree as a DiGraph to preserve the current rootedness
[ "reconstruct", "represented", "tree", "as", "a", "DiGraph", "to", "preserve", "the", "current", "rootedness" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L422-L433
train
Erotemic/utool
utool/_internal/meta_util_path.py
unixjoin
def unixjoin(*args): """ Like os.path.join, but uses forward slashes on win32 """ isabs_list = list(map(isabs, args)) if any(isabs_list): poslist = [count for count, flag in enumerate(isabs_list) if flag] pos = poslist[-1] return '/'.join(args[pos:]) else: return ...
python
def unixjoin(*args): """ Like os.path.join, but uses forward slashes on win32 """ isabs_list = list(map(isabs, args)) if any(isabs_list): poslist = [count for count, flag in enumerate(isabs_list) if flag] pos = poslist[-1] return '/'.join(args[pos:]) else: return ...
[ "def", "unixjoin", "(", "*", "args", ")", ":", "isabs_list", "=", "list", "(", "map", "(", "isabs", ",", "args", ")", ")", "if", "any", "(", "isabs_list", ")", ":", "poslist", "=", "[", "count", "for", "count", ",", "flag", "in", "enumerate", "(", ...
Like os.path.join, but uses forward slashes on win32
[ "Like", "os", ".", "path", ".", "join", "but", "uses", "forward", "slashes", "on", "win32" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/meta_util_path.py#L25-L35
train
glormph/msstitch
src/app/actions/pycolator/splitmerge.py
create_merge_psm_map
def create_merge_psm_map(peptides, ns): """Loops through peptides, stores sequences mapped to PSM ids.""" psmmap = {} for peptide in peptides: seq = reader.get_peptide_seq(peptide, ns) psm_ids = reader.get_psm_ids_from_peptide(peptide, ns) for psm_id in psm_ids: try: ...
python
def create_merge_psm_map(peptides, ns): """Loops through peptides, stores sequences mapped to PSM ids.""" psmmap = {} for peptide in peptides: seq = reader.get_peptide_seq(peptide, ns) psm_ids = reader.get_psm_ids_from_peptide(peptide, ns) for psm_id in psm_ids: try: ...
[ "def", "create_merge_psm_map", "(", "peptides", ",", "ns", ")", ":", "psmmap", "=", "{", "}", "for", "peptide", "in", "peptides", ":", "seq", "=", "reader", ".", "get_peptide_seq", "(", "peptide", ",", "ns", ")", "psm_ids", "=", "reader", ".", "get_psm_i...
Loops through peptides, stores sequences mapped to PSM ids.
[ "Loops", "through", "peptides", "stores", "sequences", "mapped", "to", "PSM", "ids", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/pycolator/splitmerge.py#L8-L21
train
samuelcolvin/buildpg
buildpg/asyncpg.py
create_pool_b
def create_pool_b( dsn=None, *, min_size=10, max_size=10, max_queries=50000, max_inactive_connection_lifetime=300.0, setup=None, init=None, loop=None, connection_class=BuildPgConnection, **connect_kwargs, ): """ Create a connection pool. Can be used either with a...
python
def create_pool_b( dsn=None, *, min_size=10, max_size=10, max_queries=50000, max_inactive_connection_lifetime=300.0, setup=None, init=None, loop=None, connection_class=BuildPgConnection, **connect_kwargs, ): """ Create a connection pool. Can be used either with a...
[ "def", "create_pool_b", "(", "dsn", "=", "None", ",", "*", ",", "min_size", "=", "10", ",", "max_size", "=", "10", ",", "max_queries", "=", "50000", ",", "max_inactive_connection_lifetime", "=", "300.0", ",", "setup", "=", "None", ",", "init", "=", "None...
Create a connection pool. Can be used either with an ``async with`` block: Identical to ``asyncpg.create_pool`` except that both the pool and connection have the *_b varients of ``execute``, ``fetch``, ``fetchval``, ``fetchrow`` etc Arguments are exactly the same as ``asyncpg.create_pool``.
[ "Create", "a", "connection", "pool", "." ]
33cccff45279834d02ec7e97d8417da8fd2a875d
https://github.com/samuelcolvin/buildpg/blob/33cccff45279834d02ec7e97d8417da8fd2a875d/buildpg/asyncpg.py#L85-L119
train
LEMS/pylems
lems/sim/sim.py
Simulation.add_runnable
def add_runnable(self, runnable): """ Adds a runnable component to the list of runnable components in this simulation. @param runnable: A runnable component @type runnable: lems.sim.runnable.Runnable """ if runnable.id in self.runnables: raise SimErr...
python
def add_runnable(self, runnable): """ Adds a runnable component to the list of runnable components in this simulation. @param runnable: A runnable component @type runnable: lems.sim.runnable.Runnable """ if runnable.id in self.runnables: raise SimErr...
[ "def", "add_runnable", "(", "self", ",", "runnable", ")", ":", "if", "runnable", ".", "id", "in", "self", ".", "runnables", ":", "raise", "SimError", "(", "'Duplicate runnable component {0}'", ".", "format", "(", "runnable", ".", "id", ")", ")", "self", "....
Adds a runnable component to the list of runnable components in this simulation. @param runnable: A runnable component @type runnable: lems.sim.runnable.Runnable
[ "Adds", "a", "runnable", "component", "to", "the", "list", "of", "runnable", "components", "in", "this", "simulation", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/sim/sim.py#L37-L49
train
LEMS/pylems
lems/sim/sim.py
Simulation.run
def run(self): """ Runs the simulation. """ self.init_run() if self.debug: self.dump("AfterInit: ") #print("++++++++++++++++ Time: %f"%self.current_time) while self.step(): #self.dump("Time: %f"%self.current_time) #print("++++++++++++++++ ...
python
def run(self): """ Runs the simulation. """ self.init_run() if self.debug: self.dump("AfterInit: ") #print("++++++++++++++++ Time: %f"%self.current_time) while self.step(): #self.dump("Time: %f"%self.current_time) #print("++++++++++++++++ ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "init_run", "(", ")", "if", "self", ".", "debug", ":", "self", ".", "dump", "(", "\"AfterInit: \"", ")", "while", "self", ".", "step", "(", ")", ":", "pass" ]
Runs the simulation.
[ "Runs", "the", "simulation", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/sim/sim.py#L86-L97
train
moluwole/Bast
bast/cli.py
controller_creatr
def controller_creatr(filename): """Name of the controller file to be created""" if not check(): click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:controller command') return path = os.path.abspath('.') + '/controller' if not os.path.exists(path): os.m...
python
def controller_creatr(filename): """Name of the controller file to be created""" if not check(): click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:controller command') return path = os.path.abspath('.') + '/controller' if not os.path.exists(path): os.m...
[ "def", "controller_creatr", "(", "filename", ")", ":", "if", "not", "check", "(", ")", ":", "click", ".", "echo", "(", "Fore", ".", "RED", "+", "'ERROR: Ensure you are in a bast app to run the create:controller command'", ")", "return", "path", "=", "os", ".", "...
Name of the controller file to be created
[ "Name", "of", "the", "controller", "file", "to", "be", "created" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/cli.py#L41-L61
train
moluwole/Bast
bast/cli.py
view_creatr
def view_creatr(filename): """Name of the View File to be created""" if not check(): click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:view command') return path = os.path.abspath('.') + '/public/templates' if not os.path.exists(path): os.makedirs(path...
python
def view_creatr(filename): """Name of the View File to be created""" if not check(): click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:view command') return path = os.path.abspath('.') + '/public/templates' if not os.path.exists(path): os.makedirs(path...
[ "def", "view_creatr", "(", "filename", ")", ":", "if", "not", "check", "(", ")", ":", "click", ".", "echo", "(", "Fore", ".", "RED", "+", "'ERROR: Ensure you are in a bast app to run the create:view command'", ")", "return", "path", "=", "os", ".", "path", "."...
Name of the View File to be created
[ "Name", "of", "the", "View", "File", "to", "be", "created" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/cli.py#L85-L99
train
moluwole/Bast
bast/cli.py
migration_creatr
def migration_creatr(migration_file, create, table): """Name of the migration file""" if not check(): click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:migration command') return migration = CreateMigration() if table is None: table = snake_case(migrat...
python
def migration_creatr(migration_file, create, table): """Name of the migration file""" if not check(): click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:migration command') return migration = CreateMigration() if table is None: table = snake_case(migrat...
[ "def", "migration_creatr", "(", "migration_file", ",", "create", ",", "table", ")", ":", "if", "not", "check", "(", ")", ":", "click", ".", "echo", "(", "Fore", ".", "RED", "+", "'ERROR: Ensure you are in a bast app to run the create:migration command'", ")", "ret...
Name of the migration file
[ "Name", "of", "the", "migration", "file" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/cli.py#L175-L185
train
mbunse/socket_client_server
socket_client_server/socket_client_server.py
Sock_Server.quit
def quit(self): """ Quit socket server """ logging.info("quiting sock server") if self.__quit is not None: self.__quit.set() self.join() return
python
def quit(self): """ Quit socket server """ logging.info("quiting sock server") if self.__quit is not None: self.__quit.set() self.join() return
[ "def", "quit", "(", "self", ")", ":", "logging", ".", "info", "(", "\"quiting sock server\"", ")", "if", "self", ".", "__quit", "is", "not", "None", ":", "self", ".", "__quit", ".", "set", "(", ")", "self", ".", "join", "(", ")", "return" ]
Quit socket server
[ "Quit", "socket", "server" ]
8e884925cf887d386554c1859f626d8f01bd0036
https://github.com/mbunse/socket_client_server/blob/8e884925cf887d386554c1859f626d8f01bd0036/socket_client_server/socket_client_server.py#L146-L154
train
glormph/msstitch
src/app/actions/peptable/psmtopeptable.py
get_quantcols
def get_quantcols(pattern, oldheader, coltype): """Searches for quantification columns using pattern and header list. Calls reader function to do regexp. Returns a single column for precursor quant.""" if pattern is None: return False if coltype == 'precur': return reader.get_cols_in_...
python
def get_quantcols(pattern, oldheader, coltype): """Searches for quantification columns using pattern and header list. Calls reader function to do regexp. Returns a single column for precursor quant.""" if pattern is None: return False if coltype == 'precur': return reader.get_cols_in_...
[ "def", "get_quantcols", "(", "pattern", ",", "oldheader", ",", "coltype", ")", ":", "if", "pattern", "is", "None", ":", "return", "False", "if", "coltype", "==", "'precur'", ":", "return", "reader", ".", "get_cols_in_file", "(", "pattern", ",", "oldheader", ...
Searches for quantification columns using pattern and header list. Calls reader function to do regexp. Returns a single column for precursor quant.
[ "Searches", "for", "quantification", "columns", "using", "pattern", "and", "header", "list", ".", "Calls", "reader", "function", "to", "do", "regexp", ".", "Returns", "a", "single", "column", "for", "precursor", "quant", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/peptable/psmtopeptable.py#L10-L17
train
glormph/msstitch
src/app/actions/peptable/psmtopeptable.py
get_peptide_quant
def get_peptide_quant(quantdata, quanttype): """Parses lists of quantdata and returns maxvalue from them. Strips NA""" parsefnx = {'precur': max} quantfloats = [] for q in quantdata: try: quantfloats.append(float(q)) except(TypeError, ValueError): pass if not ...
python
def get_peptide_quant(quantdata, quanttype): """Parses lists of quantdata and returns maxvalue from them. Strips NA""" parsefnx = {'precur': max} quantfloats = [] for q in quantdata: try: quantfloats.append(float(q)) except(TypeError, ValueError): pass if not ...
[ "def", "get_peptide_quant", "(", "quantdata", ",", "quanttype", ")", ":", "parsefnx", "=", "{", "'precur'", ":", "max", "}", "quantfloats", "=", "[", "]", "for", "q", "in", "quantdata", ":", "try", ":", "quantfloats", ".", "append", "(", "float", "(", ...
Parses lists of quantdata and returns maxvalue from them. Strips NA
[ "Parses", "lists", "of", "quantdata", "and", "returns", "maxvalue", "from", "them", ".", "Strips", "NA" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/peptable/psmtopeptable.py#L50-L61
train
Erotemic/utool
utool/util_csv.py
read_csv
def read_csv(fpath): """ reads csv in unicode """ import csv import utool as ut #csvfile = open(fpath, 'rb') with open(fpath, 'rb') as csvfile: row_iter = csv.reader(csvfile, delimiter=str(','), quotechar=str('|')) row_list = [ut.lmap(ut.ensure_unicode, row) for row in row_iter] ...
python
def read_csv(fpath): """ reads csv in unicode """ import csv import utool as ut #csvfile = open(fpath, 'rb') with open(fpath, 'rb') as csvfile: row_iter = csv.reader(csvfile, delimiter=str(','), quotechar=str('|')) row_list = [ut.lmap(ut.ensure_unicode, row) for row in row_iter] ...
[ "def", "read_csv", "(", "fpath", ")", ":", "import", "csv", "import", "utool", "as", "ut", "with", "open", "(", "fpath", ",", "'rb'", ")", "as", "csvfile", ":", "row_iter", "=", "csv", ".", "reader", "(", "csvfile", ",", "delimiter", "=", "str", "(",...
reads csv in unicode
[ "reads", "csv", "in", "unicode" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_csv.py#L151-L159
train
Erotemic/utool
utool/_internal/meta_util_dbg.py
get_caller_name
def get_caller_name(N=0, strict=True): """ Standalone version of get_caller_name """ if isinstance(N, (list, tuple)): name_list = [] for N_ in N: try: name_list.append(get_caller_name(N_)) except AssertionError: name_list.append('X') ...
python
def get_caller_name(N=0, strict=True): """ Standalone version of get_caller_name """ if isinstance(N, (list, tuple)): name_list = [] for N_ in N: try: name_list.append(get_caller_name(N_)) except AssertionError: name_list.append('X') ...
[ "def", "get_caller_name", "(", "N", "=", "0", ",", "strict", "=", "True", ")", ":", "if", "isinstance", "(", "N", ",", "(", "list", ",", "tuple", ")", ")", ":", "name_list", "=", "[", "]", "for", "N_", "in", "N", ":", "try", ":", "name_list", "...
Standalone version of get_caller_name
[ "Standalone", "version", "of", "get_caller_name" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/meta_util_dbg.py#L27-L47
train
quikmile/trellio
trellio/registry.py
Registry._handle_ping
def _handle_ping(self, packet, protocol): """ Responds to pings from registry_client only if the node_ids present in the ping payload are registered :param packet: The 'ping' packet received :param protocol: The protocol on which the pong should be sent """ if 'payload' in packe...
python
def _handle_ping(self, packet, protocol): """ Responds to pings from registry_client only if the node_ids present in the ping payload are registered :param packet: The 'ping' packet received :param protocol: The protocol on which the pong should be sent """ if 'payload' in packe...
[ "def", "_handle_ping", "(", "self", ",", "packet", ",", "protocol", ")", ":", "if", "'payload'", "in", "packet", ":", "is_valid_node", "=", "True", "node_ids", "=", "list", "(", "packet", "[", "'payload'", "]", ".", "values", "(", ")", ")", "for", "nod...
Responds to pings from registry_client only if the node_ids present in the ping payload are registered :param packet: The 'ping' packet received :param protocol: The protocol on which the pong should be sent
[ "Responds", "to", "pings", "from", "registry_client", "only", "if", "the", "node_ids", "present", "in", "the", "ping", "payload", "are", "registered" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/registry.py#L379-L395
train
glormph/msstitch
src/app/drivers/pycolator/splitmerge.py
MergeDriver.set_features
def set_features(self): """"Merge all psms and peptides""" allpsms_str = readers.generate_psms_multiple_fractions_strings( self.mergefiles, self.ns) allpeps = preparation.merge_peptides(self.mergefiles, self.ns) self.features = {'psm': allpsms_str, 'peptide': allpeps}
python
def set_features(self): """"Merge all psms and peptides""" allpsms_str = readers.generate_psms_multiple_fractions_strings( self.mergefiles, self.ns) allpeps = preparation.merge_peptides(self.mergefiles, self.ns) self.features = {'psm': allpsms_str, 'peptide': allpeps}
[ "def", "set_features", "(", "self", ")", ":", "allpsms_str", "=", "readers", ".", "generate_psms_multiple_fractions_strings", "(", "self", ".", "mergefiles", ",", "self", ".", "ns", ")", "allpeps", "=", "preparation", ".", "merge_peptides", "(", "self", ".", "...
Merge all psms and peptides
[ "Merge", "all", "psms", "and", "peptides" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/splitmerge.py#L94-L99
train
Erotemic/utool
utool/util_git.py
git_sequence_editor_squash
def git_sequence_editor_squash(fpath): r""" squashes wip messages CommandLine: python -m utool.util_git --exec-git_sequence_editor_squash Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> import utool as ut >>> from utool.util_git import * # NOQA >>> fpat...
python
def git_sequence_editor_squash(fpath): r""" squashes wip messages CommandLine: python -m utool.util_git --exec-git_sequence_editor_squash Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> import utool as ut >>> from utool.util_git import * # NOQA >>> fpat...
[ "def", "git_sequence_editor_squash", "(", "fpath", ")", ":", "r", "import", "utool", "as", "ut", "text", "=", "ut", ".", "read_from", "(", "fpath", ")", "print", "(", "text", ")", "prev_msg", "=", "None", "prev_dt", "=", "None", "new_lines", "=", "[", ...
r""" squashes wip messages CommandLine: python -m utool.util_git --exec-git_sequence_editor_squash Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> import utool as ut >>> from utool.util_git import * # NOQA >>> fpath = ut.get_argval('--fpath', str, default=N...
[ "r", "squashes", "wip", "messages" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_git.py#L876-L1016
train
Erotemic/utool
utool/util_git.py
std_build_command
def std_build_command(repo='.'): """ DEPRICATE My standard build script names. Calls mingw_build.bat on windows and unix_build.sh on unix """ import utool as ut print('+**** stdbuild *******') print('repo = %r' % (repo,)) if sys.platform.startswith('win32'): # vtool --rebui...
python
def std_build_command(repo='.'): """ DEPRICATE My standard build script names. Calls mingw_build.bat on windows and unix_build.sh on unix """ import utool as ut print('+**** stdbuild *******') print('repo = %r' % (repo,)) if sys.platform.startswith('win32'): # vtool --rebui...
[ "def", "std_build_command", "(", "repo", "=", "'.'", ")", ":", "import", "utool", "as", "ut", "print", "(", "'+**** stdbuild *******'", ")", "print", "(", "'repo = %r'", "%", "(", "repo", ",", ")", ")", "if", "sys", ".", "platform", ".", "startswith", "(...
DEPRICATE My standard build script names. Calls mingw_build.bat on windows and unix_build.sh on unix
[ "DEPRICATE", "My", "standard", "build", "script", "names", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_git.py#L1019-L1047
train
Thermondo/django-heroku-connect
heroku_connect/management/commands/import_mappings.py
Command.wait_for_import
def wait_for_import(self, connection_id, wait_interval): """ Wait until connection state is no longer ``IMPORT_CONFIGURATION``. Args: connection_id (str): Heroku Connect connection to monitor. wait_interval (int): How frequently to poll in seconds. Raises: ...
python
def wait_for_import(self, connection_id, wait_interval): """ Wait until connection state is no longer ``IMPORT_CONFIGURATION``. Args: connection_id (str): Heroku Connect connection to monitor. wait_interval (int): How frequently to poll in seconds. Raises: ...
[ "def", "wait_for_import", "(", "self", ",", "connection_id", ",", "wait_interval", ")", ":", "self", ".", "stdout", ".", "write", "(", "self", ".", "style", ".", "NOTICE", "(", "'Waiting for import'", ")", ",", "ending", "=", "''", ")", "state", "=", "ut...
Wait until connection state is no longer ``IMPORT_CONFIGURATION``. Args: connection_id (str): Heroku Connect connection to monitor. wait_interval (int): How frequently to poll in seconds. Raises: CommandError: If fetch connection information fails.
[ "Wait", "until", "connection", "state", "is", "no", "longer", "IMPORT_CONFIGURATION", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/management/commands/import_mappings.py#L76-L100
train
ThreatResponse/aws_ir_plugins
aws_ir_plugins/disableaccess_key.py
Plugin.setup
def setup(self): """Method runs the plugin""" if self.dry_run is not True: self.client = self._get_client() self._disable_access_key()
python
def setup(self): """Method runs the plugin""" if self.dry_run is not True: self.client = self._get_client() self._disable_access_key()
[ "def", "setup", "(", "self", ")", ":", "if", "self", ".", "dry_run", "is", "not", "True", ":", "self", ".", "client", "=", "self", ".", "_get_client", "(", ")", "self", ".", "_disable_access_key", "(", ")" ]
Method runs the plugin
[ "Method", "runs", "the", "plugin" ]
b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73
https://github.com/ThreatResponse/aws_ir_plugins/blob/b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73/aws_ir_plugins/disableaccess_key.py#L29-L33
train
ThreatResponse/aws_ir_plugins
aws_ir_plugins/disableaccess_key.py
Plugin.validate
def validate(self): """Returns whether this plugin does what it claims to have done""" try: response = self.client.get_access_key_last_used( AccessKeyId=self.access_key_id ) username = response['UserName'] access_keys = self.client.list_ac...
python
def validate(self): """Returns whether this plugin does what it claims to have done""" try: response = self.client.get_access_key_last_used( AccessKeyId=self.access_key_id ) username = response['UserName'] access_keys = self.client.list_ac...
[ "def", "validate", "(", "self", ")", ":", "try", ":", "response", "=", "self", ".", "client", ".", "get_access_key_last_used", "(", "AccessKeyId", "=", "self", ".", "access_key_id", ")", "username", "=", "response", "[", "'UserName'", "]", "access_keys", "="...
Returns whether this plugin does what it claims to have done
[ "Returns", "whether", "this", "plugin", "does", "what", "it", "claims", "to", "have", "done" ]
b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73
https://github.com/ThreatResponse/aws_ir_plugins/blob/b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73/aws_ir_plugins/disableaccess_key.py#L35-L61
train
ThreatResponse/aws_ir_plugins
aws_ir_plugins/disableaccess_key.py
Plugin._disable_access_key
def _disable_access_key(self, force_disable_self=False): """This function first checks to see if the key is already disabled\ if not then it goes to disabling """ client = self.client if self.validate is True: return else: try: cli...
python
def _disable_access_key(self, force_disable_self=False): """This function first checks to see if the key is already disabled\ if not then it goes to disabling """ client = self.client if self.validate is True: return else: try: cli...
[ "def", "_disable_access_key", "(", "self", ",", "force_disable_self", "=", "False", ")", ":", "client", "=", "self", ".", "client", "if", "self", ".", "validate", "is", "True", ":", "return", "else", ":", "try", ":", "client", ".", "update_access_key", "("...
This function first checks to see if the key is already disabled\ if not then it goes to disabling
[ "This", "function", "first", "checks", "to", "see", "if", "the", "key", "is", "already", "disabled", "\\" ]
b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73
https://github.com/ThreatResponse/aws_ir_plugins/blob/b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73/aws_ir_plugins/disableaccess_key.py#L90-L115
train
glormph/msstitch
src/app/actions/prottable/create_empty.py
generate_master_proteins
def generate_master_proteins(psms, protcol): """Fed with a psms generator, this returns the master proteins present in the PSM table. PSMs with multiple master proteins are excluded.""" master_proteins = {} if not protcol: protcol = mzidtsvdata.HEADER_MASTER_PROT for psm in psms: pro...
python
def generate_master_proteins(psms, protcol): """Fed with a psms generator, this returns the master proteins present in the PSM table. PSMs with multiple master proteins are excluded.""" master_proteins = {} if not protcol: protcol = mzidtsvdata.HEADER_MASTER_PROT for psm in psms: pro...
[ "def", "generate_master_proteins", "(", "psms", ",", "protcol", ")", ":", "master_proteins", "=", "{", "}", "if", "not", "protcol", ":", "protcol", "=", "mzidtsvdata", ".", "HEADER_MASTER_PROT", "for", "psm", "in", "psms", ":", "protacc", "=", "psm", "[", ...
Fed with a psms generator, this returns the master proteins present in the PSM table. PSMs with multiple master proteins are excluded.
[ "Fed", "with", "a", "psms", "generator", "this", "returns", "the", "master", "proteins", "present", "in", "the", "PSM", "table", ".", "PSMs", "with", "multiple", "master", "proteins", "are", "excluded", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/create_empty.py#L5-L21
train
glormph/msstitch
src/app/drivers/pycolator/base.py
PycolatorDriver.prepare_percolator_output
def prepare_percolator_output(self, fn): """Returns namespace and static xml from percolator output file""" ns = xml.get_namespace(fn) static = readers.get_percolator_static_xml(fn, ns) return ns, static
python
def prepare_percolator_output(self, fn): """Returns namespace and static xml from percolator output file""" ns = xml.get_namespace(fn) static = readers.get_percolator_static_xml(fn, ns) return ns, static
[ "def", "prepare_percolator_output", "(", "self", ",", "fn", ")", ":", "ns", "=", "xml", ".", "get_namespace", "(", "fn", ")", "static", "=", "readers", ".", "get_percolator_static_xml", "(", "fn", ",", "ns", ")", "return", "ns", ",", "static" ]
Returns namespace and static xml from percolator output file
[ "Returns", "namespace", "and", "static", "xml", "from", "percolator", "output", "file" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/base.py#L13-L17
train
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/decorators.py
git_available
def git_available(func): """ Check, if a git repository exists in the given folder. """ def inner(*args): os.chdir(APISettings.GIT_DIR) if call(['git', 'rev-parse']) == 0: return func(*args) Shell.fail('There is no git repository!') return exit(1) retur...
python
def git_available(func): """ Check, if a git repository exists in the given folder. """ def inner(*args): os.chdir(APISettings.GIT_DIR) if call(['git', 'rev-parse']) == 0: return func(*args) Shell.fail('There is no git repository!') return exit(1) retur...
[ "def", "git_available", "(", "func", ")", ":", "def", "inner", "(", "*", "args", ")", ":", "os", ".", "chdir", "(", "APISettings", ".", "GIT_DIR", ")", "if", "call", "(", "[", "'git'", ",", "'rev-parse'", "]", ")", "==", "0", ":", "return", "func",...
Check, if a git repository exists in the given folder.
[ "Check", "if", "a", "git", "repository", "exists", "in", "the", "given", "folder", "." ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/decorators.py#L8-L21
train
YuriyGuts/pygoose
pygoose/kg/gpu.py
_cuda_get_gpu_spec_string
def _cuda_get_gpu_spec_string(gpu_ids=None): """ Build a GPU id string to be used for CUDA_VISIBLE_DEVICES. """ if gpu_ids is None: return '' if isinstance(gpu_ids, list): return ','.join(str(gpu_id) for gpu_id in gpu_ids) if isinstance(gpu_ids, int): return str(gpu_id...
python
def _cuda_get_gpu_spec_string(gpu_ids=None): """ Build a GPU id string to be used for CUDA_VISIBLE_DEVICES. """ if gpu_ids is None: return '' if isinstance(gpu_ids, list): return ','.join(str(gpu_id) for gpu_id in gpu_ids) if isinstance(gpu_ids, int): return str(gpu_id...
[ "def", "_cuda_get_gpu_spec_string", "(", "gpu_ids", "=", "None", ")", ":", "if", "gpu_ids", "is", "None", ":", "return", "''", "if", "isinstance", "(", "gpu_ids", ",", "list", ")", ":", "return", "','", ".", "join", "(", "str", "(", "gpu_id", ")", "for...
Build a GPU id string to be used for CUDA_VISIBLE_DEVICES.
[ "Build", "a", "GPU", "id", "string", "to", "be", "used", "for", "CUDA_VISIBLE_DEVICES", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/gpu.py#L4-L18
train
moluwole/Bast
bast/controller.py
Controller.write_error
def write_error(self, status_code, **kwargs): """ Handle Exceptions from the server. Formats the HTML into readable form """ reason = self._reason if self.settings.get("serve_traceback") and "exc_info" in kwargs: error = [] for line in traceback.format_ex...
python
def write_error(self, status_code, **kwargs): """ Handle Exceptions from the server. Formats the HTML into readable form """ reason = self._reason if self.settings.get("serve_traceback") and "exc_info" in kwargs: error = [] for line in traceback.format_ex...
[ "def", "write_error", "(", "self", ",", "status_code", ",", "**", "kwargs", ")", ":", "reason", "=", "self", ".", "_reason", "if", "self", ".", "settings", ".", "get", "(", "\"serve_traceback\"", ")", "and", "\"exc_info\"", "in", "kwargs", ":", "error", ...
Handle Exceptions from the server. Formats the HTML into readable form
[ "Handle", "Exceptions", "from", "the", "server", ".", "Formats", "the", "HTML", "into", "readable", "form" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L37-L51
train
moluwole/Bast
bast/controller.py
Controller.view
def view(self, template_name, kwargs=None): """ Used to render template to view Sample usage +++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): self.view('index...
python
def view(self, template_name, kwargs=None): """ Used to render template to view Sample usage +++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): self.view('index...
[ "def", "view", "(", "self", ",", "template_name", ",", "kwargs", "=", "None", ")", ":", "if", "kwargs", "is", "None", ":", "kwargs", "=", "dict", "(", ")", "self", ".", "add_", "(", "'session'", ",", "self", ".", "session", ")", "content", "=", "se...
Used to render template to view Sample usage +++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): self.view('index.html')
[ "Used", "to", "render", "template", "to", "view" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L53-L73
train
moluwole/Bast
bast/controller.py
Controller.initialize
def initialize(self, method, middleware, request_type): """ Overridden initialize method from Tornado. Assigns the controller method and middleware attached to the route being executed to global variables to be used """ self.method = method self.middleware = middleware ...
python
def initialize(self, method, middleware, request_type): """ Overridden initialize method from Tornado. Assigns the controller method and middleware attached to the route being executed to global variables to be used """ self.method = method self.middleware = middleware ...
[ "def", "initialize", "(", "self", ",", "method", ",", "middleware", ",", "request_type", ")", ":", "self", ".", "method", "=", "method", "self", ".", "middleware", "=", "middleware", "self", ".", "request_type", "=", "request_type" ]
Overridden initialize method from Tornado. Assigns the controller method and middleware attached to the route being executed to global variables to be used
[ "Overridden", "initialize", "method", "from", "Tornado", ".", "Assigns", "the", "controller", "method", "and", "middleware", "attached", "to", "the", "route", "being", "executed", "to", "global", "variables", "to", "be", "used" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L98-L105
train
moluwole/Bast
bast/controller.py
Controller.only
def only(self, arguments): """ returns the key, value pair of the arguments passed as a dict object Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): ...
python
def only(self, arguments): """ returns the key, value pair of the arguments passed as a dict object Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): ...
[ "def", "only", "(", "self", ",", "arguments", ")", ":", "data", "=", "{", "}", "if", "not", "isinstance", "(", "arguments", ",", "list", ")", ":", "arguments", "=", "list", "(", "arguments", ")", "for", "i", "in", "arguments", ":", "data", "[", "i"...
returns the key, value pair of the arguments passed as a dict object Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.only(['username']) Re...
[ "returns", "the", "key", "value", "pair", "of", "the", "arguments", "passed", "as", "a", "dict", "object" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L107-L129
train
moluwole/Bast
bast/controller.py
Controller.all
def all(self): """ Returns all the arguments passed with the request Sample Usage ++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.all() R...
python
def all(self): """ Returns all the arguments passed with the request Sample Usage ++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.all() R...
[ "def", "all", "(", "self", ")", ":", "data", "=", "{", "}", "args", "=", "self", ".", "request", ".", "arguments", "for", "key", ",", "value", "in", "args", ".", "items", "(", ")", ":", "data", "[", "key", "]", "=", "self", ".", "get_argument", ...
Returns all the arguments passed with the request Sample Usage ++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.all() Returns a dictionary of all the requ...
[ "Returns", "all", "the", "arguments", "passed", "with", "the", "request" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L131-L153
train
moluwole/Bast
bast/controller.py
Controller.except_
def except_(self, arguments): """ returns the arguments passed to the route except that set by user Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): ...
python
def except_(self, arguments): """ returns the arguments passed to the route except that set by user Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): ...
[ "def", "except_", "(", "self", ",", "arguments", ")", ":", "if", "not", "isinstance", "(", "arguments", ",", "list", ")", ":", "arguments", "=", "list", "(", "arguments", ")", "args", "=", "self", ".", "request", ".", "arguments", "data", "=", "{", "...
returns the arguments passed to the route except that set by user Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.except_(['arg_name']) Re...
[ "returns", "the", "arguments", "passed", "to", "the", "route", "except", "that", "set", "by", "user" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L155-L180
train
neithere/monk
monk/mongo.py
MongoBoundDictMixin.get_one
def get_one(cls, db, *args, **kwargs): """ Returns an object that corresponds to given query or ``None``. Example:: item = Item.get_one(db, {'title': u'Hello'}) """ data = db[cls.collection].find_one(*args, **kwargs) if data: return cls.wrap_inc...
python
def get_one(cls, db, *args, **kwargs): """ Returns an object that corresponds to given query or ``None``. Example:: item = Item.get_one(db, {'title': u'Hello'}) """ data = db[cls.collection].find_one(*args, **kwargs) if data: return cls.wrap_inc...
[ "def", "get_one", "(", "cls", ",", "db", ",", "*", "args", ",", "**", "kwargs", ")", ":", "data", "=", "db", "[", "cls", ".", "collection", "]", ".", "find_one", "(", "*", "args", ",", "**", "kwargs", ")", "if", "data", ":", "return", "cls", "....
Returns an object that corresponds to given query or ``None``. Example:: item = Item.get_one(db, {'title': u'Hello'})
[ "Returns", "an", "object", "that", "corresponds", "to", "given", "query", "or", "None", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/mongo.py#L186-L199
train
neithere/monk
monk/mongo.py
MongoBoundDictMixin.get_id
def get_id(self): """ Returns object id or ``None``. """ import warnings warnings.warn('{0}.get_id() is deprecated, ' 'use {0}.id instead'.format(type(self).__name__), DeprecationWarning) return self.get('_id')
python
def get_id(self): """ Returns object id or ``None``. """ import warnings warnings.warn('{0}.get_id() is deprecated, ' 'use {0}.id instead'.format(type(self).__name__), DeprecationWarning) return self.get('_id')
[ "def", "get_id", "(", "self", ")", ":", "import", "warnings", "warnings", ".", "warn", "(", "'{0}.get_id() is deprecated, '", "'use {0}.id instead'", ".", "format", "(", "type", "(", "self", ")", ".", "__name__", ")", ",", "DeprecationWarning", ")", "return", ...
Returns object id or ``None``.
[ "Returns", "object", "id", "or", "None", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/mongo.py#L232-L239
train
neithere/monk
monk/mongo.py
MongoBoundDictMixin.get_ref
def get_ref(self): """ Returns a `DBRef` for this object or ``None``. """ _id = self.id if _id is None: return None else: return DBRef(self.collection, _id)
python
def get_ref(self): """ Returns a `DBRef` for this object or ``None``. """ _id = self.id if _id is None: return None else: return DBRef(self.collection, _id)
[ "def", "get_ref", "(", "self", ")", ":", "_id", "=", "self", ".", "id", "if", "_id", "is", "None", ":", "return", "None", "else", ":", "return", "DBRef", "(", "self", ".", "collection", ",", "_id", ")" ]
Returns a `DBRef` for this object or ``None``.
[ "Returns", "a", "DBRef", "for", "this", "object", "or", "None", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/mongo.py#L241-L248
train
quikmile/trellio
trellio/utils/log.py
CustomTimeLoggingFormatter.formatTime
def formatTime(self, record, datefmt=None): # noqa """ Overrides formatTime method to use datetime module instead of time module to display time in microseconds. Time module by default does not resolve time to microseconds. """ if datefmt: s = datetime.dateti...
python
def formatTime(self, record, datefmt=None): # noqa """ Overrides formatTime method to use datetime module instead of time module to display time in microseconds. Time module by default does not resolve time to microseconds. """ if datefmt: s = datetime.dateti...
[ "def", "formatTime", "(", "self", ",", "record", ",", "datefmt", "=", "None", ")", ":", "if", "datefmt", ":", "s", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "datefmt", ")", "else", ":", "t", "=", "datetime", ".",...
Overrides formatTime method to use datetime module instead of time module to display time in microseconds. Time module by default does not resolve time to microseconds.
[ "Overrides", "formatTime", "method", "to", "use", "datetime", "module", "instead", "of", "time", "module", "to", "display", "time", "in", "microseconds", ".", "Time", "module", "by", "default", "does", "not", "resolve", "time", "to", "microseconds", "." ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/utils/log.py#L21-L32
train
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogQuerySet.related_to
def related_to(self, instance): """Filter for all log objects of the same connected model as the given instance.""" return self.filter(table_name=instance.table_name, record_id=instance.record_id)
python
def related_to(self, instance): """Filter for all log objects of the same connected model as the given instance.""" return self.filter(table_name=instance.table_name, record_id=instance.record_id)
[ "def", "related_to", "(", "self", ",", "instance", ")", ":", "return", "self", ".", "filter", "(", "table_name", "=", "instance", ".", "table_name", ",", "record_id", "=", "instance", ".", "record_id", ")" ]
Filter for all log objects of the same connected model as the given instance.
[ "Filter", "for", "all", "log", "objects", "of", "the", "same", "connected", "model", "as", "the", "given", "instance", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L18-L20
train
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.capture_insert_from_model
def capture_insert_from_model(cls, table_name, record_id, *, exclude_fields=()): """ Create a fresh insert record from the current model state in the database. For read-write connected models, this will lead to the attempted creation of a corresponding object in Salesforce. Arg...
python
def capture_insert_from_model(cls, table_name, record_id, *, exclude_fields=()): """ Create a fresh insert record from the current model state in the database. For read-write connected models, this will lead to the attempted creation of a corresponding object in Salesforce. Arg...
[ "def", "capture_insert_from_model", "(", "cls", ",", "table_name", ",", "record_id", ",", "*", ",", "exclude_fields", "=", "(", ")", ")", ":", "exclude_cols", "=", "(", ")", "if", "exclude_fields", ":", "model_cls", "=", "get_connected_model_for_table_name", "("...
Create a fresh insert record from the current model state in the database. For read-write connected models, this will lead to the attempted creation of a corresponding object in Salesforce. Args: table_name (str): The name of the table backing the connected model (without schema) ...
[ "Create", "a", "fresh", "insert", "record", "from", "the", "current", "model", "state", "in", "the", "database", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L130-L170
train
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.capture_update_from_model
def capture_update_from_model(cls, table_name, record_id, *, update_fields=()): """ Create a fresh update record from the current model state in the database. For read-write connected models, this will lead to the attempted update of the values of a corresponding object in Salesforce. ...
python
def capture_update_from_model(cls, table_name, record_id, *, update_fields=()): """ Create a fresh update record from the current model state in the database. For read-write connected models, this will lead to the attempted update of the values of a corresponding object in Salesforce. ...
[ "def", "capture_update_from_model", "(", "cls", ",", "table_name", ",", "record_id", ",", "*", ",", "update_fields", "=", "(", ")", ")", ":", "include_cols", "=", "(", ")", "if", "update_fields", ":", "model_cls", "=", "get_connected_model_for_table_name", "(", ...
Create a fresh update record from the current model state in the database. For read-write connected models, this will lead to the attempted update of the values of a corresponding object in Salesforce. Args: table_name (str): The name of the table backing the connected model (witho...
[ "Create", "a", "fresh", "update", "record", "from", "the", "current", "model", "state", "in", "the", "database", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L173-L212
train
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.get_model
def get_model(self): """ Fetch the instance of the connected model referenced by this log record. Returns: The connected instance, or ``None`` if it does not exists. """ model_cls = get_connected_model_for_table_name(self.table_name) return model_cls._defaul...
python
def get_model(self): """ Fetch the instance of the connected model referenced by this log record. Returns: The connected instance, or ``None`` if it does not exists. """ model_cls = get_connected_model_for_table_name(self.table_name) return model_cls._defaul...
[ "def", "get_model", "(", "self", ")", ":", "model_cls", "=", "get_connected_model_for_table_name", "(", "self", ".", "table_name", ")", "return", "model_cls", ".", "_default_manager", ".", "filter", "(", "id", "=", "self", ".", "record_id", ")", ".", "first", ...
Fetch the instance of the connected model referenced by this log record. Returns: The connected instance, or ``None`` if it does not exists.
[ "Fetch", "the", "instance", "of", "the", "connected", "model", "referenced", "by", "this", "log", "record", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L223-L232
train
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.related
def related(self, *, exclude_self=False): """ Get a QuerySet for all trigger log objects for the same connected model. Args: exclude_self (bool): Whether to exclude this log object from the result list """ manager = type(self)._default_manager queryset = mana...
python
def related(self, *, exclude_self=False): """ Get a QuerySet for all trigger log objects for the same connected model. Args: exclude_self (bool): Whether to exclude this log object from the result list """ manager = type(self)._default_manager queryset = mana...
[ "def", "related", "(", "self", ",", "*", ",", "exclude_self", "=", "False", ")", ":", "manager", "=", "type", "(", "self", ")", ".", "_default_manager", "queryset", "=", "manager", ".", "related_to", "(", "self", ")", "if", "exclude_self", ":", "queryset...
Get a QuerySet for all trigger log objects for the same connected model. Args: exclude_self (bool): Whether to exclude this log object from the result list
[ "Get", "a", "QuerySet", "for", "all", "trigger", "log", "objects", "for", "the", "same", "connected", "model", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L234-L245
train
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract._fieldnames_to_colnames
def _fieldnames_to_colnames(model_cls, fieldnames): """Get the names of columns referenced by the given model fields.""" get_field = model_cls._meta.get_field fields = map(get_field, fieldnames) return {f.column for f in fields}
python
def _fieldnames_to_colnames(model_cls, fieldnames): """Get the names of columns referenced by the given model fields.""" get_field = model_cls._meta.get_field fields = map(get_field, fieldnames) return {f.column for f in fields}
[ "def", "_fieldnames_to_colnames", "(", "model_cls", ",", "fieldnames", ")", ":", "get_field", "=", "model_cls", ".", "_meta", ".", "get_field", "fields", "=", "map", "(", "get_field", ",", "fieldnames", ")", "return", "{", "f", ".", "column", "for", "f", "...
Get the names of columns referenced by the given model fields.
[ "Get", "the", "names", "of", "columns", "referenced", "by", "the", "given", "model", "fields", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L258-L262
train
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogArchive.redo
def redo(self): """ Re-sync the change recorded in this trigger log. Creates a ``NEW`` live trigger log from the data in this archived trigger log and sets the state of this archived instance to ``REQUEUED``. .. seealso:: :meth:`.TriggerLog.redo` Returns: T...
python
def redo(self): """ Re-sync the change recorded in this trigger log. Creates a ``NEW`` live trigger log from the data in this archived trigger log and sets the state of this archived instance to ``REQUEUED``. .. seealso:: :meth:`.TriggerLog.redo` Returns: T...
[ "def", "redo", "(", "self", ")", ":", "trigger_log", "=", "self", ".", "_to_live_trigger_log", "(", "state", "=", "TRIGGER_LOG_STATE", "[", "'NEW'", "]", ")", "trigger_log", ".", "save", "(", "force_insert", "=", "True", ")", "self", ".", "state", "=", "...
Re-sync the change recorded in this trigger log. Creates a ``NEW`` live trigger log from the data in this archived trigger log and sets the state of this archived instance to ``REQUEUED``. .. seealso:: :meth:`.TriggerLog.redo` Returns: The :class:`.TriggerLog` instance tha...
[ "Re", "-", "sync", "the", "change", "recorded", "in", "this", "trigger", "log", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L308-L325
train
glormph/msstitch
src/app/actions/prottable/isoquant.py
add_isoquant_data
def add_isoquant_data(proteins, quantproteins, quantacc, quantfields): """Runs through a protein table and adds quant data from ANOTHER protein table that contains that data.""" for protein in base_add_isoquant_data(proteins, quantproteins, prottabledata.HEADER_PROT...
python
def add_isoquant_data(proteins, quantproteins, quantacc, quantfields): """Runs through a protein table and adds quant data from ANOTHER protein table that contains that data.""" for protein in base_add_isoquant_data(proteins, quantproteins, prottabledata.HEADER_PROT...
[ "def", "add_isoquant_data", "(", "proteins", ",", "quantproteins", ",", "quantacc", ",", "quantfields", ")", ":", "for", "protein", "in", "base_add_isoquant_data", "(", "proteins", ",", "quantproteins", ",", "prottabledata", ".", "HEADER_PROTEIN", ",", "quantacc", ...
Runs through a protein table and adds quant data from ANOTHER protein table that contains that data.
[ "Runs", "through", "a", "protein", "table", "and", "adds", "quant", "data", "from", "ANOTHER", "protein", "table", "that", "contains", "that", "data", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/isoquant.py#L15-L21
train
glormph/msstitch
src/app/actions/peptable/isoquant.py
add_isoquant_data
def add_isoquant_data(peptides, quantpeptides, quantacc, quantfields): """Runs through a peptide table and adds quant data from ANOTHER peptide table that contains that data.""" for peptide in base_add_isoquant_data(peptides, quantpeptides, peptabledata.HEADER_PEP...
python
def add_isoquant_data(peptides, quantpeptides, quantacc, quantfields): """Runs through a peptide table and adds quant data from ANOTHER peptide table that contains that data.""" for peptide in base_add_isoquant_data(peptides, quantpeptides, peptabledata.HEADER_PEP...
[ "def", "add_isoquant_data", "(", "peptides", ",", "quantpeptides", ",", "quantacc", ",", "quantfields", ")", ":", "for", "peptide", "in", "base_add_isoquant_data", "(", "peptides", ",", "quantpeptides", ",", "peptabledata", ".", "HEADER_PEPTIDE", ",", "quantacc", ...
Runs through a peptide table and adds quant data from ANOTHER peptide table that contains that data.
[ "Runs", "through", "a", "peptide", "table", "and", "adds", "quant", "data", "from", "ANOTHER", "peptide", "table", "that", "contains", "that", "data", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/peptable/isoquant.py#L5-L11
train
chriso/gauged
gauged/results/time_series.py
TimeSeries.map
def map(self, fn): """Run a map function across all y points in the series""" return TimeSeries([(x, fn(y)) for x, y in self.points])
python
def map(self, fn): """Run a map function across all y points in the series""" return TimeSeries([(x, fn(y)) for x, y in self.points])
[ "def", "map", "(", "self", ",", "fn", ")", ":", "return", "TimeSeries", "(", "[", "(", "x", ",", "fn", "(", "y", ")", ")", "for", "x", ",", "y", "in", "self", ".", "points", "]", ")" ]
Run a map function across all y points in the series
[ "Run", "a", "map", "function", "across", "all", "y", "points", "in", "the", "series" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/results/time_series.py#L43-L45
train
glormph/msstitch
src/app/actions/prottable/merge.py
build_proteintable
def build_proteintable(pqdb, headerfields, mergecutoff, isobaric=False, precursor=False, probability=False, fdr=False, pep=False, genecentric=False): """Fetches proteins and quants from joined lookup table, loops through them and when all of a protein's quants have ...
python
def build_proteintable(pqdb, headerfields, mergecutoff, isobaric=False, precursor=False, probability=False, fdr=False, pep=False, genecentric=False): """Fetches proteins and quants from joined lookup table, loops through them and when all of a protein's quants have ...
[ "def", "build_proteintable", "(", "pqdb", ",", "headerfields", ",", "mergecutoff", ",", "isobaric", "=", "False", ",", "precursor", "=", "False", ",", "probability", "=", "False", ",", "fdr", "=", "False", ",", "pep", "=", "False", ",", "genecentric", "=",...
Fetches proteins and quants from joined lookup table, loops through them and when all of a protein's quants have been collected, yields the protein quant information.
[ "Fetches", "proteins", "and", "quants", "from", "joined", "lookup", "table", "loops", "through", "them", "and", "when", "all", "of", "a", "protein", "s", "quants", "have", "been", "collected", "yields", "the", "protein", "quant", "information", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/merge.py#L9-L60
train
glormph/msstitch
src/app/actions/mzidtsv/proteingrouping.py
count_protein_group_hits
def count_protein_group_hits(lineproteins, groups): """Takes a list of protein accessions and a list of protein groups content from DB. Counts for each group in list how many proteins are found in lineproteins. Returns list of str amounts. """ hits = [] for group in groups: hits.append(0...
python
def count_protein_group_hits(lineproteins, groups): """Takes a list of protein accessions and a list of protein groups content from DB. Counts for each group in list how many proteins are found in lineproteins. Returns list of str amounts. """ hits = [] for group in groups: hits.append(0...
[ "def", "count_protein_group_hits", "(", "lineproteins", ",", "groups", ")", ":", "hits", "=", "[", "]", "for", "group", "in", "groups", ":", "hits", ".", "append", "(", "0", ")", "for", "protein", "in", "lineproteins", ":", "if", "protein", "in", "group"...
Takes a list of protein accessions and a list of protein groups content from DB. Counts for each group in list how many proteins are found in lineproteins. Returns list of str amounts.
[ "Takes", "a", "list", "of", "protein", "accessions", "and", "a", "list", "of", "protein", "groups", "content", "from", "DB", ".", "Counts", "for", "each", "group", "in", "list", "how", "many", "proteins", "are", "found", "in", "lineproteins", ".", "Returns...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/proteingrouping.py#L57-L68
train
Erotemic/utool
utool/util_logging.py
get_logging_dir
def get_logging_dir(appname='default'): """ The default log dir is in the system resource directory But the utool global cache allows for the user to override where the logs for a specific app should be stored. Returns: log_dir_realpath (str): real path to logging directory """ from...
python
def get_logging_dir(appname='default'): """ The default log dir is in the system resource directory But the utool global cache allows for the user to override where the logs for a specific app should be stored. Returns: log_dir_realpath (str): real path to logging directory """ from...
[ "def", "get_logging_dir", "(", "appname", "=", "'default'", ")", ":", "from", "utool", ".", "_internal", "import", "meta_util_cache", "from", "utool", ".", "_internal", "import", "meta_util_cplat", "from", "utool", "import", "util_cache", "if", "appname", "is", ...
The default log dir is in the system resource directory But the utool global cache allows for the user to override where the logs for a specific app should be stored. Returns: log_dir_realpath (str): real path to logging directory
[ "The", "default", "log", "dir", "is", "in", "the", "system", "resource", "directory", "But", "the", "utool", "global", "cache", "allows", "for", "the", "user", "to", "override", "where", "the", "logs", "for", "a", "specific", "app", "should", "be", "stored...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L186-L208
train
Erotemic/utool
utool/util_logging.py
add_logging_handler
def add_logging_handler(handler, format_='file'): """ mostly for util_logging internals """ global __UTOOL_ROOT_LOGGER__ if __UTOOL_ROOT_LOGGER__ is None: builtins.print('[WARNING] logger not started, cannot add handler') return # create formatter and add it to the handlers #...
python
def add_logging_handler(handler, format_='file'): """ mostly for util_logging internals """ global __UTOOL_ROOT_LOGGER__ if __UTOOL_ROOT_LOGGER__ is None: builtins.print('[WARNING] logger not started, cannot add handler') return # create formatter and add it to the handlers #...
[ "def", "add_logging_handler", "(", "handler", ",", "format_", "=", "'file'", ")", ":", "global", "__UTOOL_ROOT_LOGGER__", "if", "__UTOOL_ROOT_LOGGER__", "is", "None", ":", "builtins", ".", "print", "(", "'[WARNING] logger not started, cannot add handler'", ")", "return"...
mostly for util_logging internals
[ "mostly", "for", "util_logging", "internals" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L280-L302
train
Erotemic/utool
utool/util_logging.py
start_logging
def start_logging(log_fpath=None, mode='a', appname='default', log_dir=None): r""" Overwrites utool print functions to use a logger CommandLine: python -m utool.util_logging --test-start_logging:0 python -m utool.util_logging --test-start_logging:1 Example0: >>> # DISABLE_DOCTE...
python
def start_logging(log_fpath=None, mode='a', appname='default', log_dir=None): r""" Overwrites utool print functions to use a logger CommandLine: python -m utool.util_logging --test-start_logging:0 python -m utool.util_logging --test-start_logging:1 Example0: >>> # DISABLE_DOCTE...
[ "def", "start_logging", "(", "log_fpath", "=", "None", ",", "mode", "=", "'a'", ",", "appname", "=", "'default'", ",", "log_dir", "=", "None", ")", ":", "r", "global", "__UTOOL_ROOT_LOGGER__", "global", "__UTOOL_PRINT__", "global", "__UTOOL_WRITE__", "global", ...
r""" Overwrites utool print functions to use a logger CommandLine: python -m utool.util_logging --test-start_logging:0 python -m utool.util_logging --test-start_logging:1 Example0: >>> # DISABLE_DOCTEST >>> import sys >>> sys.argv.append('--verb-logging') >>...
[ "r", "Overwrites", "utool", "print", "functions", "to", "use", "a", "logger" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L375-L520
train
Erotemic/utool
utool/util_logging.py
stop_logging
def stop_logging(): """ Restores utool print functions to python defaults """ global __UTOOL_ROOT_LOGGER__ global __UTOOL_PRINT__ global __UTOOL_WRITE__ global __UTOOL_FLUSH__ if __UTOOL_ROOT_LOGGER__ is not None: # Flush remaining buffer if VERBOSE or LOGGING_VERBOSE: ...
python
def stop_logging(): """ Restores utool print functions to python defaults """ global __UTOOL_ROOT_LOGGER__ global __UTOOL_PRINT__ global __UTOOL_WRITE__ global __UTOOL_FLUSH__ if __UTOOL_ROOT_LOGGER__ is not None: # Flush remaining buffer if VERBOSE or LOGGING_VERBOSE: ...
[ "def", "stop_logging", "(", ")", ":", "global", "__UTOOL_ROOT_LOGGER__", "global", "__UTOOL_PRINT__", "global", "__UTOOL_WRITE__", "global", "__UTOOL_FLUSH__", "if", "__UTOOL_ROOT_LOGGER__", "is", "not", "None", ":", "if", "VERBOSE", "or", "LOGGING_VERBOSE", ":", "_ut...
Restores utool print functions to python defaults
[ "Restores", "utool", "print", "functions", "to", "python", "defaults" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L523-L543
train
Erotemic/utool
utool/util_list.py
replace_nones
def replace_nones(list_, repl=-1): r""" Recursively removes Nones in all lists and sublists and replaces them with the repl variable Args: list_ (list): repl (obj): replacement value Returns: list CommandLine: python -m utool.util_list --test-replace_nones ...
python
def replace_nones(list_, repl=-1): r""" Recursively removes Nones in all lists and sublists and replaces them with the repl variable Args: list_ (list): repl (obj): replacement value Returns: list CommandLine: python -m utool.util_list --test-replace_nones ...
[ "def", "replace_nones", "(", "list_", ",", "repl", "=", "-", "1", ")", ":", "r", "repl_list", "=", "[", "repl", "if", "item", "is", "None", "else", "(", "replace_nones", "(", "item", ",", "repl", ")", "if", "isinstance", "(", "item", ",", "list", "...
r""" Recursively removes Nones in all lists and sublists and replaces them with the repl variable Args: list_ (list): repl (obj): replacement value Returns: list CommandLine: python -m utool.util_list --test-replace_nones Example: >>> # ENABLE_DOCTEST ...
[ "r", "Recursively", "removes", "Nones", "in", "all", "lists", "and", "sublists", "and", "replaces", "them", "with", "the", "repl", "variable" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L78-L113
train
Erotemic/utool
utool/util_list.py
recursive_replace
def recursive_replace(list_, target, repl=-1): r""" Recursively removes target in all lists and sublists and replaces them with the repl variable """ repl_list = [ recursive_replace(item, target, repl) if isinstance(item, (list, np.ndarray)) else (repl if item == target else item) ...
python
def recursive_replace(list_, target, repl=-1): r""" Recursively removes target in all lists and sublists and replaces them with the repl variable """ repl_list = [ recursive_replace(item, target, repl) if isinstance(item, (list, np.ndarray)) else (repl if item == target else item) ...
[ "def", "recursive_replace", "(", "list_", ",", "target", ",", "repl", "=", "-", "1", ")", ":", "r", "repl_list", "=", "[", "recursive_replace", "(", "item", ",", "target", ",", "repl", ")", "if", "isinstance", "(", "item", ",", "(", "list", ",", "np"...
r""" Recursively removes target in all lists and sublists and replaces them with the repl variable
[ "r", "Recursively", "removes", "target", "in", "all", "lists", "and", "sublists", "and", "replaces", "them", "with", "the", "repl", "variable" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L116-L126
train
Erotemic/utool
utool/util_list.py
ensure_list_size
def ensure_list_size(list_, size_): """ Allocates more space if needbe. Ensures len(``list_``) == ``size_``. Args: list_ (list): ``list`` to extend size_ (int): amount to exent by """ lendiff = (size_) - len(list_) if lendiff > 0: extension = [None for _ in range(lendif...
python
def ensure_list_size(list_, size_): """ Allocates more space if needbe. Ensures len(``list_``) == ``size_``. Args: list_ (list): ``list`` to extend size_ (int): amount to exent by """ lendiff = (size_) - len(list_) if lendiff > 0: extension = [None for _ in range(lendif...
[ "def", "ensure_list_size", "(", "list_", ",", "size_", ")", ":", "lendiff", "=", "(", "size_", ")", "-", "len", "(", "list_", ")", "if", "lendiff", ">", "0", ":", "extension", "=", "[", "None", "for", "_", "in", "range", "(", "lendiff", ")", "]", ...
Allocates more space if needbe. Ensures len(``list_``) == ``size_``. Args: list_ (list): ``list`` to extend size_ (int): amount to exent by
[ "Allocates", "more", "space", "if", "needbe", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L150-L162
train
Erotemic/utool
utool/util_list.py
multi_replace
def multi_replace(instr, search_list=[], repl_list=None): """ Does a string replace with a list of search and replacements TODO: rename """ repl_list = [''] * len(search_list) if repl_list is None else repl_list for ser, repl in zip(search_list, repl_list): instr = instr.replace(ser, re...
python
def multi_replace(instr, search_list=[], repl_list=None): """ Does a string replace with a list of search and replacements TODO: rename """ repl_list = [''] * len(search_list) if repl_list is None else repl_list for ser, repl in zip(search_list, repl_list): instr = instr.replace(ser, re...
[ "def", "multi_replace", "(", "instr", ",", "search_list", "=", "[", "]", ",", "repl_list", "=", "None", ")", ":", "repl_list", "=", "[", "''", "]", "*", "len", "(", "search_list", ")", "if", "repl_list", "is", "None", "else", "repl_list", "for", "ser",...
Does a string replace with a list of search and replacements TODO: rename
[ "Does", "a", "string", "replace", "with", "a", "list", "of", "search", "and", "replacements" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L387-L396
train
Erotemic/utool
utool/util_list.py
invertible_flatten1
def invertible_flatten1(unflat_list): r""" Flattens `unflat_list` but remember how to reconstruct the `unflat_list` Returns `flat_list` and the `reverse_list` with indexes into the `flat_list` Args: unflat_list (list): list of nested lists that we will flatten. Returns: tuple :...
python
def invertible_flatten1(unflat_list): r""" Flattens `unflat_list` but remember how to reconstruct the `unflat_list` Returns `flat_list` and the `reverse_list` with indexes into the `flat_list` Args: unflat_list (list): list of nested lists that we will flatten. Returns: tuple :...
[ "def", "invertible_flatten1", "(", "unflat_list", ")", ":", "r", "nextnum", "=", "functools", ".", "partial", "(", "six", ".", "next", ",", "itertools", ".", "count", "(", "0", ")", ")", "reverse_list", "=", "[", "[", "nextnum", "(", ")", "for", "_", ...
r""" Flattens `unflat_list` but remember how to reconstruct the `unflat_list` Returns `flat_list` and the `reverse_list` with indexes into the `flat_list` Args: unflat_list (list): list of nested lists that we will flatten. Returns: tuple : (flat_list, reverse_list) CommandLin...
[ "r", "Flattens", "unflat_list", "but", "remember", "how", "to", "reconstruct", "the", "unflat_list", "Returns", "flat_list", "and", "the", "reverse_list", "with", "indexes", "into", "the", "flat_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L423-L454
train
Erotemic/utool
utool/util_list.py
invertible_flatten2
def invertible_flatten2(unflat_list): """ An alternative to invertible_flatten1 which uses cumsum Flattens ``list`` but remember how to reconstruct the unflat ``list`` Returns flat ``list`` and the unflat ``list`` with indexes into the flat ``list`` Args: unflat_list (list): Retur...
python
def invertible_flatten2(unflat_list): """ An alternative to invertible_flatten1 which uses cumsum Flattens ``list`` but remember how to reconstruct the unflat ``list`` Returns flat ``list`` and the unflat ``list`` with indexes into the flat ``list`` Args: unflat_list (list): Retur...
[ "def", "invertible_flatten2", "(", "unflat_list", ")", ":", "sublen_list", "=", "list", "(", "map", "(", "len", ",", "unflat_list", ")", ")", "if", "not", "util_type", ".", "HAVE_NUMPY", ":", "cumlen_list", "=", "np", ".", "cumsum", "(", "sublen_list", ")"...
An alternative to invertible_flatten1 which uses cumsum Flattens ``list`` but remember how to reconstruct the unflat ``list`` Returns flat ``list`` and the unflat ``list`` with indexes into the flat ``list`` Args: unflat_list (list): Returns: tuple: flat_list, cumlen_list See...
[ "An", "alternative", "to", "invertible_flatten1", "which", "uses", "cumsum" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L594-L665
train
Erotemic/utool
utool/util_list.py
invertible_flatten2_numpy
def invertible_flatten2_numpy(unflat_arrs, axis=0): """ more numpy version TODO: move to vtool Args: unflat_arrs (list): list of ndarrays Returns: tuple: (flat_list, cumlen_list) CommandLine: python -m utool.util_list --test-invertible_flatten2_numpy Example: ...
python
def invertible_flatten2_numpy(unflat_arrs, axis=0): """ more numpy version TODO: move to vtool Args: unflat_arrs (list): list of ndarrays Returns: tuple: (flat_list, cumlen_list) CommandLine: python -m utool.util_list --test-invertible_flatten2_numpy Example: ...
[ "def", "invertible_flatten2_numpy", "(", "unflat_arrs", ",", "axis", "=", "0", ")", ":", "cumlen_list", "=", "np", ".", "cumsum", "(", "[", "arr", ".", "shape", "[", "axis", "]", "for", "arr", "in", "unflat_arrs", "]", ")", "flat_list", "=", "np", ".",...
more numpy version TODO: move to vtool Args: unflat_arrs (list): list of ndarrays Returns: tuple: (flat_list, cumlen_list) CommandLine: python -m utool.util_list --test-invertible_flatten2_numpy Example: >>> # ENABLE_DOCTET >>> from utool.util_list impor...
[ "more", "numpy", "version" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L668-L693
train
Erotemic/utool
utool/util_list.py
unflat_unique_rowid_map
def unflat_unique_rowid_map(func, unflat_rowids, **kwargs): """ performs only one call to the underlying func with unique rowids the func must be some lookup function TODO: move this to a better place. CommandLine: python -m utool.util_list --test-unflat_unique_rowid_map:0 python -...
python
def unflat_unique_rowid_map(func, unflat_rowids, **kwargs): """ performs only one call to the underlying func with unique rowids the func must be some lookup function TODO: move this to a better place. CommandLine: python -m utool.util_list --test-unflat_unique_rowid_map:0 python -...
[ "def", "unflat_unique_rowid_map", "(", "func", ",", "unflat_rowids", ",", "**", "kwargs", ")", ":", "import", "utool", "as", "ut", "flat_rowids", ",", "reverse_list", "=", "ut", ".", "invertible_flatten2", "(", "unflat_rowids", ")", "flat_rowids_arr", "=", "np",...
performs only one call to the underlying func with unique rowids the func must be some lookup function TODO: move this to a better place. CommandLine: python -m utool.util_list --test-unflat_unique_rowid_map:0 python -m utool.util_list --test-unflat_unique_rowid_map:1 Example0: ...
[ "performs", "only", "one", "call", "to", "the", "underlying", "func", "with", "unique", "rowids", "the", "func", "must", "be", "some", "lookup", "function" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L728-L796
train
Erotemic/utool
utool/util_list.py
allsame
def allsame(list_, strict=True): """ checks to see if list is equal everywhere Args: list_ (list): Returns: True if all items in the list are equal """ if len(list_) == 0: return True first_item = list_[0] return list_all_eq_to(list_, first_item, strict)
python
def allsame(list_, strict=True): """ checks to see if list is equal everywhere Args: list_ (list): Returns: True if all items in the list are equal """ if len(list_) == 0: return True first_item = list_[0] return list_all_eq_to(list_, first_item, strict)
[ "def", "allsame", "(", "list_", ",", "strict", "=", "True", ")", ":", "if", "len", "(", "list_", ")", "==", "0", ":", "return", "True", "first_item", "=", "list_", "[", "0", "]", "return", "list_all_eq_to", "(", "list_", ",", "first_item", ",", "stri...
checks to see if list is equal everywhere Args: list_ (list): Returns: True if all items in the list are equal
[ "checks", "to", "see", "if", "list", "is", "equal", "everywhere" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L832-L845
train
Erotemic/utool
utool/util_list.py
list_all_eq_to
def list_all_eq_to(list_, val, strict=True): """ checks to see if list is equal everywhere to a value Args: list_ (list): val : value to check against Returns: True if all items in the list are equal to val """ if util_type.HAVE_NUMPY and isinstance(val, np.ndarray): ...
python
def list_all_eq_to(list_, val, strict=True): """ checks to see if list is equal everywhere to a value Args: list_ (list): val : value to check against Returns: True if all items in the list are equal to val """ if util_type.HAVE_NUMPY and isinstance(val, np.ndarray): ...
[ "def", "list_all_eq_to", "(", "list_", ",", "val", ",", "strict", "=", "True", ")", ":", "if", "util_type", ".", "HAVE_NUMPY", "and", "isinstance", "(", "val", ",", "np", ".", "ndarray", ")", ":", "return", "all", "(", "[", "np", ".", "all", "(", "...
checks to see if list is equal everywhere to a value Args: list_ (list): val : value to check against Returns: True if all items in the list are equal to val
[ "checks", "to", "see", "if", "list", "is", "equal", "everywhere", "to", "a", "value" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L848-L874
train
Erotemic/utool
utool/util_list.py
get_dirty_items
def get_dirty_items(item_list, flag_list): """ Returns each item in item_list where not flag in flag_list Args: item_list (list): flag_list (list): Returns: dirty_items """ assert len(item_list) == len(flag_list) dirty_items = [item for (item, flag) in ...
python
def get_dirty_items(item_list, flag_list): """ Returns each item in item_list where not flag in flag_list Args: item_list (list): flag_list (list): Returns: dirty_items """ assert len(item_list) == len(flag_list) dirty_items = [item for (item, flag) in ...
[ "def", "get_dirty_items", "(", "item_list", ",", "flag_list", ")", ":", "assert", "len", "(", "item_list", ")", "==", "len", "(", "flag_list", ")", "dirty_items", "=", "[", "item", "for", "(", "item", ",", "flag", ")", "in", "zip", "(", "item_list", ",...
Returns each item in item_list where not flag in flag_list Args: item_list (list): flag_list (list): Returns: dirty_items
[ "Returns", "each", "item", "in", "item_list", "where", "not", "flag", "in", "flag_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L877-L895
train
Erotemic/utool
utool/util_list.py
filterfalse_items
def filterfalse_items(item_list, flag_list): """ Returns items in item list where the corresponding item in flag list is true Args: item_list (list): list of items flag_list (list): list of truthy values Returns: filtered_items : items where the corresponding flag was truthy ...
python
def filterfalse_items(item_list, flag_list): """ Returns items in item list where the corresponding item in flag list is true Args: item_list (list): list of items flag_list (list): list of truthy values Returns: filtered_items : items where the corresponding flag was truthy ...
[ "def", "filterfalse_items", "(", "item_list", ",", "flag_list", ")", ":", "assert", "len", "(", "item_list", ")", "==", "len", "(", "flag_list", ")", "filtered_items", "=", "list", "(", "util_iter", ".", "ifilterfalse_items", "(", "item_list", ",", "flag_list"...
Returns items in item list where the corresponding item in flag list is true Args: item_list (list): list of items flag_list (list): list of truthy values Returns: filtered_items : items where the corresponding flag was truthy SeeAlso: util_iter.ifilterfalse_items
[ "Returns", "items", "in", "item", "list", "where", "the", "corresponding", "item", "in", "flag", "list", "is", "true" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L966-L982
train
Erotemic/utool
utool/util_list.py
isect
def isect(list1, list2): r""" returns list1 elements that are also in list2. preserves order of list1 intersect_ordered Args: list1 (list): list2 (list): Returns: list: new_list Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import * # NOQA ...
python
def isect(list1, list2): r""" returns list1 elements that are also in list2. preserves order of list1 intersect_ordered Args: list1 (list): list2 (list): Returns: list: new_list Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import * # NOQA ...
[ "def", "isect", "(", "list1", ",", "list2", ")", ":", "r", "set2", "=", "set", "(", "list2", ")", "return", "[", "item", "for", "item", "in", "list1", "if", "item", "in", "set2", "]" ]
r""" returns list1 elements that are also in list2. preserves order of list1 intersect_ordered Args: list1 (list): list2 (list): Returns: list: new_list Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> list1 = ['featweig...
[ "r", "returns", "list1", "elements", "that", "are", "also", "in", "list2", ".", "preserves", "order", "of", "list1" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1001-L1088
train
Erotemic/utool
utool/util_list.py
is_subset_of_any
def is_subset_of_any(set_, other_sets): """ returns True if set_ is a subset of any set in other_sets Args: set_ (set): other_sets (list of sets): Returns: bool: flag CommandLine: python -m utool.util_list --test-is_subset_of_any Example: >>> # ENABLE_...
python
def is_subset_of_any(set_, other_sets): """ returns True if set_ is a subset of any set in other_sets Args: set_ (set): other_sets (list of sets): Returns: bool: flag CommandLine: python -m utool.util_list --test-is_subset_of_any Example: >>> # ENABLE_...
[ "def", "is_subset_of_any", "(", "set_", ",", "other_sets", ")", ":", "set_", "=", "set", "(", "set_", ")", "other_sets", "=", "map", "(", "set", ",", "other_sets", ")", "return", "any", "(", "[", "set_", ".", "issubset", "(", "other_set", ")", "for", ...
returns True if set_ is a subset of any set in other_sets Args: set_ (set): other_sets (list of sets): Returns: bool: flag CommandLine: python -m utool.util_list --test-is_subset_of_any Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * #...
[ "returns", "True", "if", "set_", "is", "a", "subset", "of", "any", "set", "in", "other_sets" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1157-L1197
train
Erotemic/utool
utool/util_list.py
unique_ordered
def unique_ordered(list_): """ Returns unique items in ``list_`` in the order they were seen. Args: list_ (list): Returns: list: unique_list - unique list which maintains order CommandLine: python -m utool.util_list --exec-unique_ordered Example: >>> # ENABLE_...
python
def unique_ordered(list_): """ Returns unique items in ``list_`` in the order they were seen. Args: list_ (list): Returns: list: unique_list - unique list which maintains order CommandLine: python -m utool.util_list --exec-unique_ordered Example: >>> # ENABLE_...
[ "def", "unique_ordered", "(", "list_", ")", ":", "list_", "=", "list", "(", "list_", ")", "flag_list", "=", "flag_unique_items", "(", "list_", ")", "unique_list", "=", "compress", "(", "list_", ",", "flag_list", ")", "return", "unique_list" ]
Returns unique items in ``list_`` in the order they were seen. Args: list_ (list): Returns: list: unique_list - unique list which maintains order CommandLine: python -m utool.util_list --exec-unique_ordered Example: >>> # ENABLE_DOCTEST >>> from utool.util_lis...
[ "Returns", "unique", "items", "in", "list_", "in", "the", "order", "they", "were", "seen", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1352-L1377
train
Erotemic/utool
utool/util_list.py
setdiff
def setdiff(list1, list2): """ returns list1 elements that are not in list2. preserves order of list1 Args: list1 (list): list2 (list): Returns: list: new_list Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool ...
python
def setdiff(list1, list2): """ returns list1 elements that are not in list2. preserves order of list1 Args: list1 (list): list2 (list): Returns: list: new_list Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool ...
[ "def", "setdiff", "(", "list1", ",", "list2", ")", ":", "set2", "=", "set", "(", "list2", ")", "return", "[", "item", "for", "item", "in", "list1", "if", "item", "not", "in", "set2", "]" ]
returns list1 elements that are not in list2. preserves order of list1 Args: list1 (list): list2 (list): Returns: list: new_list Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool as ut >>> list1 = ['featweight_...
[ "returns", "list1", "elements", "that", "are", "not", "in", "list2", ".", "preserves", "order", "of", "list1" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1407-L1430
train
Erotemic/utool
utool/util_list.py
isetdiff_flags
def isetdiff_flags(list1, list2): """ move to util_iter """ set2 = set(list2) return (item not in set2 for item in list1)
python
def isetdiff_flags(list1, list2): """ move to util_iter """ set2 = set(list2) return (item not in set2 for item in list1)
[ "def", "isetdiff_flags", "(", "list1", ",", "list2", ")", ":", "set2", "=", "set", "(", "list2", ")", "return", "(", "item", "not", "in", "set2", "for", "item", "in", "list1", ")" ]
move to util_iter
[ "move", "to", "util_iter" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1437-L1442
train
Erotemic/utool
utool/util_list.py
unflat_take
def unflat_take(items_list, unflat_index_list): r""" Returns nested subset of items_list Args: items_list (list): unflat_index_list (list): nested list of indices CommandLine: python -m utool.util_list --exec-unflat_take SeeAlso: ut.take Example: >>> #...
python
def unflat_take(items_list, unflat_index_list): r""" Returns nested subset of items_list Args: items_list (list): unflat_index_list (list): nested list of indices CommandLine: python -m utool.util_list --exec-unflat_take SeeAlso: ut.take Example: >>> #...
[ "def", "unflat_take", "(", "items_list", ",", "unflat_index_list", ")", ":", "r", "return", "[", "unflat_take", "(", "items_list", ",", "xs", ")", "if", "isinstance", "(", "xs", ",", "list", ")", "else", "take", "(", "items_list", ",", "xs", ")", "for", ...
r""" Returns nested subset of items_list Args: items_list (list): unflat_index_list (list): nested list of indices CommandLine: python -m utool.util_list --exec-unflat_take SeeAlso: ut.take Example: >>> # DISABLE_DOCTEST >>> from utool.util_list im...
[ "r", "Returns", "nested", "subset", "of", "items_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1568-L1594
train
Erotemic/utool
utool/util_list.py
argsort
def argsort(*args, **kwargs): """ like np.argsort but for lists Args: *args: multiple lists to sort by **kwargs: reverse (bool): sort order is descending if True else acscending CommandLine: python -m utool.util_list argsort Example: >>> # DISABLE_DOCTE...
python
def argsort(*args, **kwargs): """ like np.argsort but for lists Args: *args: multiple lists to sort by **kwargs: reverse (bool): sort order is descending if True else acscending CommandLine: python -m utool.util_list argsort Example: >>> # DISABLE_DOCTE...
[ "def", "argsort", "(", "*", "args", ",", "**", "kwargs", ")", ":", "if", "len", "(", "args", ")", "==", "1", "and", "isinstance", "(", "args", "[", "0", "]", ",", "dict", ")", ":", "dict_", "=", "args", "[", "0", "]", "index_list", "=", "list",...
like np.argsort but for lists Args: *args: multiple lists to sort by **kwargs: reverse (bool): sort order is descending if True else acscending CommandLine: python -m utool.util_list argsort Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import...
[ "like", "np", ".", "argsort", "but", "for", "lists" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1597-L1622
train
Erotemic/utool
utool/util_list.py
argsort2
def argsort2(indexable, key=None, reverse=False): """ Returns the indices that would sort a indexable object. This is similar to np.argsort, but it is written in pure python and works on both lists and dictionaries. Args: indexable (list or dict): indexable to sort by Returns: ...
python
def argsort2(indexable, key=None, reverse=False): """ Returns the indices that would sort a indexable object. This is similar to np.argsort, but it is written in pure python and works on both lists and dictionaries. Args: indexable (list or dict): indexable to sort by Returns: ...
[ "def", "argsort2", "(", "indexable", ",", "key", "=", "None", ",", "reverse", "=", "False", ")", ":", "if", "isinstance", "(", "indexable", ",", "dict", ")", ":", "vk_iter", "=", "(", "(", "v", ",", "k", ")", "for", "k", ",", "v", "in", "indexabl...
Returns the indices that would sort a indexable object. This is similar to np.argsort, but it is written in pure python and works on both lists and dictionaries. Args: indexable (list or dict): indexable to sort by Returns: list: indices: list of indices such that sorts the indexable ...
[ "Returns", "the", "indices", "that", "would", "sort", "a", "indexable", "object", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1625-L1665
train
Erotemic/utool
utool/util_list.py
index_complement
def index_complement(index_list, len_=None): """ Returns the other indicies in a list of length ``len_`` """ mask1 = index_to_boolmask(index_list, len_) mask2 = not_list(mask1) index_list_bar = list_where(mask2) return index_list_bar
python
def index_complement(index_list, len_=None): """ Returns the other indicies in a list of length ``len_`` """ mask1 = index_to_boolmask(index_list, len_) mask2 = not_list(mask1) index_list_bar = list_where(mask2) return index_list_bar
[ "def", "index_complement", "(", "index_list", ",", "len_", "=", "None", ")", ":", "mask1", "=", "index_to_boolmask", "(", "index_list", ",", "len_", ")", "mask2", "=", "not_list", "(", "mask1", ")", "index_list_bar", "=", "list_where", "(", "mask2", ")", "...
Returns the other indicies in a list of length ``len_``
[ "Returns", "the", "other", "indicies", "in", "a", "list", "of", "length", "len_" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1746-L1753
train
Erotemic/utool
utool/util_list.py
take_complement
def take_complement(list_, index_list): """ Returns items in ``list_`` not indexed by index_list """ mask = not_list(index_to_boolmask(index_list, len(list_))) return compress(list_, mask)
python
def take_complement(list_, index_list): """ Returns items in ``list_`` not indexed by index_list """ mask = not_list(index_to_boolmask(index_list, len(list_))) return compress(list_, mask)
[ "def", "take_complement", "(", "list_", ",", "index_list", ")", ":", "mask", "=", "not_list", "(", "index_to_boolmask", "(", "index_list", ",", "len", "(", "list_", ")", ")", ")", "return", "compress", "(", "list_", ",", "mask", ")" ]
Returns items in ``list_`` not indexed by index_list
[ "Returns", "items", "in", "list_", "not", "indexed", "by", "index_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1756-L1759
train
Erotemic/utool
utool/util_list.py
take
def take(list_, index_list): """ Selects a subset of a list based on a list of indices. This is similar to np.take, but pure python. Args: list_ (list): some indexable object index_list (list, slice, int): some indexing object Returns: list or scalar: subset of the list ...
python
def take(list_, index_list): """ Selects a subset of a list based on a list of indices. This is similar to np.take, but pure python. Args: list_ (list): some indexable object index_list (list, slice, int): some indexing object Returns: list or scalar: subset of the list ...
[ "def", "take", "(", "list_", ",", "index_list", ")", ":", "try", ":", "return", "[", "list_", "[", "index", "]", "for", "index", "in", "index_list", "]", "except", "TypeError", ":", "return", "list_", "[", "index_list", "]" ]
Selects a subset of a list based on a list of indices. This is similar to np.take, but pure python. Args: list_ (list): some indexable object index_list (list, slice, int): some indexing object Returns: list or scalar: subset of the list CommandLine: python -m utool.ut...
[ "Selects", "a", "subset", "of", "a", "list", "based", "on", "a", "list", "of", "indices", ".", "This", "is", "similar", "to", "np", ".", "take", "but", "pure", "python", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1772-L1823
train
Erotemic/utool
utool/util_list.py
take_percentile
def take_percentile(arr, percent): """ take the top `percent` items in a list rounding up """ size = len(arr) stop = min(int(size * percent), len(arr)) return arr[0:stop]
python
def take_percentile(arr, percent): """ take the top `percent` items in a list rounding up """ size = len(arr) stop = min(int(size * percent), len(arr)) return arr[0:stop]
[ "def", "take_percentile", "(", "arr", ",", "percent", ")", ":", "size", "=", "len", "(", "arr", ")", "stop", "=", "min", "(", "int", "(", "size", "*", "percent", ")", ",", "len", "(", "arr", ")", ")", "return", "arr", "[", "0", ":", "stop", "]"...
take the top `percent` items in a list rounding up
[ "take", "the", "top", "percent", "items", "in", "a", "list", "rounding", "up" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1834-L1838
train
Erotemic/utool
utool/util_list.py
snapped_slice
def snapped_slice(size, frac, n): r""" Creates a slice spanning `n` items in a list of length `size` at position `frac`. Args: size (int): length of the list frac (float): position in the range [0, 1] n (int): number of items in the slice Returns: slice: slice objec...
python
def snapped_slice(size, frac, n): r""" Creates a slice spanning `n` items in a list of length `size` at position `frac`. Args: size (int): length of the list frac (float): position in the range [0, 1] n (int): number of items in the slice Returns: slice: slice objec...
[ "def", "snapped_slice", "(", "size", ",", "frac", ",", "n", ")", ":", "r", "if", "size", "<", "n", ":", "n", "=", "size", "start", "=", "int", "(", "size", "*", "frac", "-", "ceil", "(", "n", "/", "2", ")", ")", "+", "1", "stop", "=", "int"...
r""" Creates a slice spanning `n` items in a list of length `size` at position `frac`. Args: size (int): length of the list frac (float): position in the range [0, 1] n (int): number of items in the slice Returns: slice: slice object that best fits the criteria See...
[ "r", "Creates", "a", "slice", "spanning", "n", "items", "in", "a", "list", "of", "length", "size", "at", "position", "frac", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1841-L1884
train
Erotemic/utool
utool/util_list.py
take_percentile_parts
def take_percentile_parts(arr, front=None, mid=None, back=None): r""" Take parts from front, back, or middle of a list Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool as ut >>> arr = list(range(20)) >>> front = 3 >>> m...
python
def take_percentile_parts(arr, front=None, mid=None, back=None): r""" Take parts from front, back, or middle of a list Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool as ut >>> arr = list(range(20)) >>> front = 3 >>> m...
[ "def", "take_percentile_parts", "(", "arr", ",", "front", "=", "None", ",", "mid", "=", "None", ",", "back", "=", "None", ")", ":", "r", "slices", "=", "[", "]", "if", "front", ":", "slices", "+=", "[", "snapped_slice", "(", "len", "(", "arr", ")",...
r""" Take parts from front, back, or middle of a list Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool as ut >>> arr = list(range(20)) >>> front = 3 >>> mid = 3 >>> back = 3 >>> result = take_percentile_part...
[ "r", "Take", "parts", "from", "front", "back", "or", "middle", "of", "a", "list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1907-L1931
train
Erotemic/utool
utool/util_list.py
broadcast_zip
def broadcast_zip(list1, list2): r""" Zips elementwise pairs between list1 and list2. Broadcasts the first dimension if a single list is of length 1. Aliased as bzip Args: list1 (list): list2 (list): Returns: list: list of pairs SeeAlso: util_dict.dzip ...
python
def broadcast_zip(list1, list2): r""" Zips elementwise pairs between list1 and list2. Broadcasts the first dimension if a single list is of length 1. Aliased as bzip Args: list1 (list): list2 (list): Returns: list: list of pairs SeeAlso: util_dict.dzip ...
[ "def", "broadcast_zip", "(", "list1", ",", "list2", ")", ":", "r", "try", ":", "len", "(", "list1", ")", "except", "TypeError", ":", "list1", "=", "list", "(", "list1", ")", "try", ":", "len", "(", "list2", ")", "except", "TypeError", ":", "list2", ...
r""" Zips elementwise pairs between list1 and list2. Broadcasts the first dimension if a single list is of length 1. Aliased as bzip Args: list1 (list): list2 (list): Returns: list: list of pairs SeeAlso: util_dict.dzip Raises: ValueError: if the ...
[ "r", "Zips", "elementwise", "pairs", "between", "list1", "and", "list2", ".", "Broadcasts", "the", "first", "dimension", "if", "a", "single", "list", "is", "of", "length", "1", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1979-L2031
train
Erotemic/utool
utool/util_list.py
equal
def equal(list1, list2): """ takes flags returns indexes of True values """ return [item1 == item2 for item1, item2 in broadcast_zip(list1, list2)]
python
def equal(list1, list2): """ takes flags returns indexes of True values """ return [item1 == item2 for item1, item2 in broadcast_zip(list1, list2)]
[ "def", "equal", "(", "list1", ",", "list2", ")", ":", "return", "[", "item1", "==", "item2", "for", "item1", ",", "item2", "in", "broadcast_zip", "(", "list1", ",", "list2", ")", "]" ]
takes flags returns indexes of True values
[ "takes", "flags", "returns", "indexes", "of", "True", "values" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2039-L2041
train
Erotemic/utool
utool/util_list.py
scalar_input_map
def scalar_input_map(func, input_): """ Map like function Args: func: function to apply input_ : either an iterable or scalar value Returns: If ``input_`` is iterable this function behaves like map otherwise applies func to ``input_`` """ if util_iter.isiterable...
python
def scalar_input_map(func, input_): """ Map like function Args: func: function to apply input_ : either an iterable or scalar value Returns: If ``input_`` is iterable this function behaves like map otherwise applies func to ``input_`` """ if util_iter.isiterable...
[ "def", "scalar_input_map", "(", "func", ",", "input_", ")", ":", "if", "util_iter", ".", "isiterable", "(", "input_", ")", ":", "return", "list", "(", "map", "(", "func", ",", "input_", ")", ")", "else", ":", "return", "func", "(", "input_", ")" ]
Map like function Args: func: function to apply input_ : either an iterable or scalar value Returns: If ``input_`` is iterable this function behaves like map otherwise applies func to ``input_``
[ "Map", "like", "function" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2061-L2076
train
Erotemic/utool
utool/util_list.py
partial_imap_1to1
def partial_imap_1to1(func, si_func): """ a bit messy DEPRICATE """ @functools.wraps(si_func) def wrapper(input_): if not util_iter.isiterable(input_): return func(si_func(input_)) else: return list(map(func, si_func(input_))) set_funcname(wrapper, util_s...
python
def partial_imap_1to1(func, si_func): """ a bit messy DEPRICATE """ @functools.wraps(si_func) def wrapper(input_): if not util_iter.isiterable(input_): return func(si_func(input_)) else: return list(map(func, si_func(input_))) set_funcname(wrapper, util_s...
[ "def", "partial_imap_1to1", "(", "func", ",", "si_func", ")", ":", "@", "functools", ".", "wraps", "(", "si_func", ")", "def", "wrapper", "(", "input_", ")", ":", "if", "not", "util_iter", ".", "isiterable", "(", "input_", ")", ":", "return", "func", "...
a bit messy DEPRICATE
[ "a", "bit", "messy" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2079-L2091
train
Erotemic/utool
utool/util_list.py
sample_zip
def sample_zip(items_list, num_samples, allow_overflow=False, per_bin=1): """ Helper for sampling Given a list of lists, samples one item for each list and bins them into num_samples bins. If all sublists are of equal size this is equivilent to a zip, but otherewise consecutive bins will have monotonic...
python
def sample_zip(items_list, num_samples, allow_overflow=False, per_bin=1): """ Helper for sampling Given a list of lists, samples one item for each list and bins them into num_samples bins. If all sublists are of equal size this is equivilent to a zip, but otherewise consecutive bins will have monotonic...
[ "def", "sample_zip", "(", "items_list", ",", "num_samples", ",", "allow_overflow", "=", "False", ",", "per_bin", "=", "1", ")", ":", "samples_list", "=", "[", "[", "]", "for", "_", "in", "range", "(", "num_samples", ")", "]", "samples_iter", "=", "zip_lo...
Helper for sampling Given a list of lists, samples one item for each list and bins them into num_samples bins. If all sublists are of equal size this is equivilent to a zip, but otherewise consecutive bins will have monotonically less elemements # Doctest doesn't work with assertionerror #util...
[ "Helper", "for", "sampling" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2094-L2152
train
Erotemic/utool
utool/util_list.py
issorted
def issorted(list_, op=operator.le): """ Determines if a list is sorted Args: list_ (list): op (func): sorted operation (default=operator.le) Returns: bool : True if the list is sorted """ return all(op(list_[ix], list_[ix + 1]) for ix in range(len(list_) - 1))
python
def issorted(list_, op=operator.le): """ Determines if a list is sorted Args: list_ (list): op (func): sorted operation (default=operator.le) Returns: bool : True if the list is sorted """ return all(op(list_[ix], list_[ix + 1]) for ix in range(len(list_) - 1))
[ "def", "issorted", "(", "list_", ",", "op", "=", "operator", ".", "le", ")", ":", "return", "all", "(", "op", "(", "list_", "[", "ix", "]", ",", "list_", "[", "ix", "+", "1", "]", ")", "for", "ix", "in", "range", "(", "len", "(", "list_", ")"...
Determines if a list is sorted Args: list_ (list): op (func): sorted operation (default=operator.le) Returns: bool : True if the list is sorted
[ "Determines", "if", "a", "list", "is", "sorted" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2213-L2224
train
Erotemic/utool
utool/util_list.py
list_depth
def list_depth(list_, func=max, _depth=0): """ Returns the deepest level of nesting within a list of lists Args: list_ : a nested listlike object func : depth aggregation strategy (defaults to max) _depth : internal var Example: >>> # ENABLE_DOCTEST >>> from uto...
python
def list_depth(list_, func=max, _depth=0): """ Returns the deepest level of nesting within a list of lists Args: list_ : a nested listlike object func : depth aggregation strategy (defaults to max) _depth : internal var Example: >>> # ENABLE_DOCTEST >>> from uto...
[ "def", "list_depth", "(", "list_", ",", "func", "=", "max", ",", "_depth", "=", "0", ")", ":", "depth_list", "=", "[", "list_depth", "(", "item", ",", "func", "=", "func", ",", "_depth", "=", "_depth", "+", "1", ")", "for", "item", "in", "list_", ...
Returns the deepest level of nesting within a list of lists Args: list_ : a nested listlike object func : depth aggregation strategy (defaults to max) _depth : internal var Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> list_ = [[[[[...
[ "Returns", "the", "deepest", "level", "of", "nesting", "within", "a", "list", "of", "lists" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2434-L2456
train
Erotemic/utool
utool/util_list.py
depth
def depth(sequence, func=max, _depth=0): """ Find the nesting depth of a nested sequence """ if isinstance(sequence, dict): sequence = list(sequence.values()) depth_list = [depth(item, func=func, _depth=_depth + 1) for item in sequence if (isinstance(item, dict) or util_typ...
python
def depth(sequence, func=max, _depth=0): """ Find the nesting depth of a nested sequence """ if isinstance(sequence, dict): sequence = list(sequence.values()) depth_list = [depth(item, func=func, _depth=_depth + 1) for item in sequence if (isinstance(item, dict) or util_typ...
[ "def", "depth", "(", "sequence", ",", "func", "=", "max", ",", "_depth", "=", "0", ")", ":", "if", "isinstance", "(", "sequence", ",", "dict", ")", ":", "sequence", "=", "list", "(", "sequence", ".", "values", "(", ")", ")", "depth_list", "=", "[",...
Find the nesting depth of a nested sequence
[ "Find", "the", "nesting", "depth", "of", "a", "nested", "sequence" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2459-L2470
train
Erotemic/utool
utool/util_list.py
list_deep_types
def list_deep_types(list_): """ Returns all types in a deep list """ type_list = [] for item in list_: if util_type.is_listlike(item): type_list.extend(list_deep_types(item)) else: type_list.append(type(item)) return type_list
python
def list_deep_types(list_): """ Returns all types in a deep list """ type_list = [] for item in list_: if util_type.is_listlike(item): type_list.extend(list_deep_types(item)) else: type_list.append(type(item)) return type_list
[ "def", "list_deep_types", "(", "list_", ")", ":", "type_list", "=", "[", "]", "for", "item", "in", "list_", ":", "if", "util_type", ".", "is_listlike", "(", "item", ")", ":", "type_list", ".", "extend", "(", "list_deep_types", "(", "item", ")", ")", "e...
Returns all types in a deep list
[ "Returns", "all", "types", "in", "a", "deep", "list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2473-L2483
train
Erotemic/utool
utool/util_list.py
depth_profile
def depth_profile(list_, max_depth=None, compress_homogenous=True, compress_consecutive=False, new_depth=False): r""" Returns a nested list corresponding the shape of the nested structures lists represent depth, tuples represent shape. The values of the items do not matter. only the lengths. Args: ...
python
def depth_profile(list_, max_depth=None, compress_homogenous=True, compress_consecutive=False, new_depth=False): r""" Returns a nested list corresponding the shape of the nested structures lists represent depth, tuples represent shape. The values of the items do not matter. only the lengths. Args: ...
[ "def", "depth_profile", "(", "list_", ",", "max_depth", "=", "None", ",", "compress_homogenous", "=", "True", ",", "compress_consecutive", "=", "False", ",", "new_depth", "=", "False", ")", ":", "r", "if", "isinstance", "(", "list_", ",", "dict", ")", ":",...
r""" Returns a nested list corresponding the shape of the nested structures lists represent depth, tuples represent shape. The values of the items do not matter. only the lengths. Args: list_ (list): max_depth (None): compress_homogenous (bool): compress_consecutive (boo...
[ "r", "Returns", "a", "nested", "list", "corresponding", "the", "shape", "of", "the", "nested", "structures", "lists", "represent", "depth", "tuples", "represent", "shape", ".", "The", "values", "of", "the", "items", "do", "not", "matter", ".", "only", "the",...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2486-L2665
train
Erotemic/utool
utool/util_list.py
list_cover
def list_cover(list1, list2): r""" returns boolean for each position in list1 if it is in list2 Args: list1 (list): list2 (list): Returns: list: incover_list - true where list1 intersects list2 CommandLine: python -m utool.util_list --test-list_cover Example: ...
python
def list_cover(list1, list2): r""" returns boolean for each position in list1 if it is in list2 Args: list1 (list): list2 (list): Returns: list: incover_list - true where list1 intersects list2 CommandLine: python -m utool.util_list --test-list_cover Example: ...
[ "def", "list_cover", "(", "list1", ",", "list2", ")", ":", "r", "set2", "=", "set", "(", "list2", ")", "incover_list", "=", "[", "item1", "in", "set2", "for", "item1", "in", "list1", "]", "return", "incover_list" ]
r""" returns boolean for each position in list1 if it is in list2 Args: list1 (list): list2 (list): Returns: list: incover_list - true where list1 intersects list2 CommandLine: python -m utool.util_list --test-list_cover Example: >>> # DISABLE_DOCTEST ...
[ "r", "returns", "boolean", "for", "each", "position", "in", "list1", "if", "it", "is", "in", "list2" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L2846-L2875
train
Erotemic/utool
utool/util_list.py
list_alignment
def list_alignment(list1, list2, missing=False): """ Assumes list items are unique Args: list1 (list): a list of unique items to be aligned list2 (list): a list of unique items in a desired ordering missing (bool): True if list2 can contain items not in list1 Returns: l...
python
def list_alignment(list1, list2, missing=False): """ Assumes list items are unique Args: list1 (list): a list of unique items to be aligned list2 (list): a list of unique items in a desired ordering missing (bool): True if list2 can contain items not in list1 Returns: l...
[ "def", "list_alignment", "(", "list1", ",", "list2", ",", "missing", "=", "False", ")", ":", "import", "utool", "as", "ut", "item1_to_idx", "=", "make_index_lookup", "(", "list1", ")", "if", "missing", ":", "sortx", "=", "ut", ".", "dict_take", "(", "ite...
Assumes list items are unique Args: list1 (list): a list of unique items to be aligned list2 (list): a list of unique items in a desired ordering missing (bool): True if list2 can contain items not in list1 Returns: list: sorting that will map list1 onto list2 CommandLine:...
[ "Assumes", "list", "items", "are", "unique" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L3008-L3052
train
Erotemic/utool
utool/util_list.py
list_transpose
def list_transpose(list_, shape=None): r""" Swaps rows and columns. nCols should be specified if the initial list is empty. Args: list_ (list): Returns: list: CommandLine: python -m utool.util_list --test-list_transpose Example: >>> # ENABLE_DOCTEST ...
python
def list_transpose(list_, shape=None): r""" Swaps rows and columns. nCols should be specified if the initial list is empty. Args: list_ (list): Returns: list: CommandLine: python -m utool.util_list --test-list_transpose Example: >>> # ENABLE_DOCTEST ...
[ "def", "list_transpose", "(", "list_", ",", "shape", "=", "None", ")", ":", "r", "num_cols_set", "=", "unique", "(", "[", "len", "(", "x", ")", "for", "x", "in", "list_", "]", ")", "if", "shape", "is", "None", ":", "if", "len", "(", "num_cols_set",...
r""" Swaps rows and columns. nCols should be specified if the initial list is empty. Args: list_ (list): Returns: list: CommandLine: python -m utool.util_list --test-list_transpose Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA...
[ "r", "Swaps", "rows", "and", "columns", ".", "nCols", "should", "be", "specified", "if", "the", "initial", "list", "is", "empty", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L3065-L3122
train
Erotemic/utool
utool/util_list.py
delete_items_by_index
def delete_items_by_index(list_, index_list, copy=False): """ Remove items from ``list_`` at positions specified in ``index_list`` The original ``list_`` is preserved if ``copy`` is True Args: list_ (list): index_list (list): copy (bool): preserves original list if True Exa...
python
def delete_items_by_index(list_, index_list, copy=False): """ Remove items from ``list_`` at positions specified in ``index_list`` The original ``list_`` is preserved if ``copy`` is True Args: list_ (list): index_list (list): copy (bool): preserves original list if True Exa...
[ "def", "delete_items_by_index", "(", "list_", ",", "index_list", ",", "copy", "=", "False", ")", ":", "if", "copy", ":", "list_", "=", "list_", "[", ":", "]", "index_list_", "=", "[", "(", "len", "(", "list_", ")", "+", "x", "if", "x", "<", "0", ...
Remove items from ``list_`` at positions specified in ``index_list`` The original ``list_`` is preserved if ``copy`` is True Args: list_ (list): index_list (list): copy (bool): preserves original list if True Example: >>> # ENABLE_DOCTEST >>> from utool.util_list im...
[ "Remove", "items", "from", "list_", "at", "positions", "specified", "in", "index_list", "The", "original", "list_", "is", "preserved", "if", "copy", "is", "True" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L3128-L3155
train
Erotemic/utool
utool/util_list.py
delete_list_items
def delete_list_items(list_, item_list, copy=False): r""" Remove items in ``item_list`` from ``list_``. The original ``list_`` is preserved if ``copy`` is True """ if copy: list_ = list_[:] for item in item_list: list_.remove(item) return list_
python
def delete_list_items(list_, item_list, copy=False): r""" Remove items in ``item_list`` from ``list_``. The original ``list_`` is preserved if ``copy`` is True """ if copy: list_ = list_[:] for item in item_list: list_.remove(item) return list_
[ "def", "delete_list_items", "(", "list_", ",", "item_list", ",", "copy", "=", "False", ")", ":", "r", "if", "copy", ":", "list_", "=", "list_", "[", ":", "]", "for", "item", "in", "item_list", ":", "list_", ".", "remove", "(", "item", ")", "return", ...
r""" Remove items in ``item_list`` from ``list_``. The original ``list_`` is preserved if ``copy`` is True
[ "r", "Remove", "items", "in", "item_list", "from", "list_", ".", "The", "original", "list_", "is", "preserved", "if", "copy", "is", "True" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L3158-L3167
train