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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
quikmile/trellio | trellio/services.py | publish | def publish(func):
"""
publish the return value of this function as a message from this endpoint
"""
@wraps(func)
def wrapper(self, *args, **kwargs): # outgoing
payload = func(self, *args, **kwargs)
payload.pop('self', None)
self._publish(func.__name__, payload)
ret... | python | def publish(func):
"""
publish the return value of this function as a message from this endpoint
"""
@wraps(func)
def wrapper(self, *args, **kwargs): # outgoing
payload = func(self, *args, **kwargs)
payload.pop('self', None)
self._publish(func.__name__, payload)
ret... | [
"def",
"publish",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"payload",
"=",
"func",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
"payload",
... | publish the return value of this function as a message from this endpoint | [
"publish",
"the",
"return",
"value",
"of",
"this",
"function",
"as",
"a",
"message",
"from",
"this",
"endpoint"
] | e8b050077562acf32805fcbb9c0c162248a23c62 | https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/services.py#L26-L40 | train |
quikmile/trellio | trellio/services.py | request | def request(func=None, timeout=600):
"""
use to request an api call from a specific endpoint
"""
if func is None:
return partial(request, timeout=timeout)
@wraps(func)
def wrapper(self, *args, **kwargs):
params = func(self, *args, **kwargs)
self = params.pop('self', None... | python | def request(func=None, timeout=600):
"""
use to request an api call from a specific endpoint
"""
if func is None:
return partial(request, timeout=timeout)
@wraps(func)
def wrapper(self, *args, **kwargs):
params = func(self, *args, **kwargs)
self = params.pop('self', None... | [
"def",
"request",
"(",
"func",
"=",
"None",
",",
"timeout",
"=",
"600",
")",
":",
"if",
"func",
"is",
"None",
":",
"return",
"partial",
"(",
"request",
",",
"timeout",
"=",
"timeout",
")",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"sel... | use to request an api call from a specific endpoint | [
"use",
"to",
"request",
"an",
"api",
"call",
"from",
"a",
"specific",
"endpoint"
] | e8b050077562acf32805fcbb9c0c162248a23c62 | https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/services.py#L83-L102 | train |
grktsh/falcon-oas | src/falcon_oas/problems.py | serialize_problem | def serialize_problem(req, resp, problem):
"""Serialize the given instance of Problem."""
preferred = req.client_prefers(
('application/json', 'application/problem+json')
)
if preferred is None:
preferred = 'application/json'
resp.data = problem.to_json().encode('utf-8')
resp.co... | python | def serialize_problem(req, resp, problem):
"""Serialize the given instance of Problem."""
preferred = req.client_prefers(
('application/json', 'application/problem+json')
)
if preferred is None:
preferred = 'application/json'
resp.data = problem.to_json().encode('utf-8')
resp.co... | [
"def",
"serialize_problem",
"(",
"req",
",",
"resp",
",",
"problem",
")",
":",
"preferred",
"=",
"req",
".",
"client_prefers",
"(",
"(",
"'application/json'",
",",
"'application/problem+json'",
")",
")",
"if",
"preferred",
"is",
"None",
":",
"preferred",
"=",
... | Serialize the given instance of Problem. | [
"Serialize",
"the",
"given",
"instance",
"of",
"Problem",
"."
] | 380921e82a50b565b3df6e494b06cc9dba961db7 | https://github.com/grktsh/falcon-oas/blob/380921e82a50b565b3df6e494b06cc9dba961db7/src/falcon_oas/problems.py#L52-L62 | train |
glormph/msstitch | src/app/actions/proteindata.py | add_psms_to_proteindata | def add_psms_to_proteindata(proteindata, p_acc, pool, psmdata):
"""Fill function for create_featuredata_map"""
seq, psm_id = psmdata[2], psmdata[3]
try:
proteindata[p_acc]['pools'][pool]['psms'].add(psm_id)
except KeyError:
emptyinfo = {'psms': set(), 'peptides': set(), 'unipeps': 0}
... | python | def add_psms_to_proteindata(proteindata, p_acc, pool, psmdata):
"""Fill function for create_featuredata_map"""
seq, psm_id = psmdata[2], psmdata[3]
try:
proteindata[p_acc]['pools'][pool]['psms'].add(psm_id)
except KeyError:
emptyinfo = {'psms': set(), 'peptides': set(), 'unipeps': 0}
... | [
"def",
"add_psms_to_proteindata",
"(",
"proteindata",
",",
"p_acc",
",",
"pool",
",",
"psmdata",
")",
":",
"seq",
",",
"psm_id",
"=",
"psmdata",
"[",
"2",
"]",
",",
"psmdata",
"[",
"3",
"]",
"try",
":",
"proteindata",
"[",
"p_acc",
"]",
"[",
"'pools'",... | Fill function for create_featuredata_map | [
"Fill",
"function",
"for",
"create_featuredata_map"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/proteindata.py#L27-L39 | train |
Erotemic/utool | utool/util_dbg.py | print_traceback | def print_traceback(with_colors=True):
"""
prints current stack
"""
#traceback.print_tb()
import traceback
stack = traceback.extract_stack()
stack_lines = traceback.format_list(stack)
tbtext = ''.join(stack_lines)
if with_colors:
try:
from pygments import highligh... | python | def print_traceback(with_colors=True):
"""
prints current stack
"""
#traceback.print_tb()
import traceback
stack = traceback.extract_stack()
stack_lines = traceback.format_list(stack)
tbtext = ''.join(stack_lines)
if with_colors:
try:
from pygments import highligh... | [
"def",
"print_traceback",
"(",
"with_colors",
"=",
"True",
")",
":",
"import",
"traceback",
"stack",
"=",
"traceback",
".",
"extract_stack",
"(",
")",
"stack_lines",
"=",
"traceback",
".",
"format_list",
"(",
"stack",
")",
"tbtext",
"=",
"''",
".",
"join",
... | prints current stack | [
"prints",
"current",
"stack"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L40-L61 | train |
Erotemic/utool | utool/util_dbg.py | is_valid_varname | def is_valid_varname(varname):
""" Checks syntax and validity of a variable name """
if not isinstance(varname, six.string_types):
return False
match_obj = re.match(varname_regex, varname)
valid_syntax = match_obj is not None
valid_name = not keyword.iskeyword(varname)
isvalid = valid_sy... | python | def is_valid_varname(varname):
""" Checks syntax and validity of a variable name """
if not isinstance(varname, six.string_types):
return False
match_obj = re.match(varname_regex, varname)
valid_syntax = match_obj is not None
valid_name = not keyword.iskeyword(varname)
isvalid = valid_sy... | [
"def",
"is_valid_varname",
"(",
"varname",
")",
":",
"if",
"not",
"isinstance",
"(",
"varname",
",",
"six",
".",
"string_types",
")",
":",
"return",
"False",
"match_obj",
"=",
"re",
".",
"match",
"(",
"varname_regex",
",",
"varname",
")",
"valid_syntax",
"... | Checks syntax and validity of a variable name | [
"Checks",
"syntax",
"and",
"validity",
"of",
"a",
"variable",
"name"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L101-L109 | train |
Erotemic/utool | utool/util_dbg.py | execstr_dict | def execstr_dict(dict_, local_name=None, exclude_list=None, explicit=False):
"""
returns execable python code that declares variables using keys and values
execstr_dict
Args:
dict_ (dict):
local_name (str): optional: local name of dictionary. Specifying this
is much safer
... | python | def execstr_dict(dict_, local_name=None, exclude_list=None, explicit=False):
"""
returns execable python code that declares variables using keys and values
execstr_dict
Args:
dict_ (dict):
local_name (str): optional: local name of dictionary. Specifying this
is much safer
... | [
"def",
"execstr_dict",
"(",
"dict_",
",",
"local_name",
"=",
"None",
",",
"exclude_list",
"=",
"None",
",",
"explicit",
"=",
"False",
")",
":",
"import",
"utool",
"as",
"ut",
"if",
"explicit",
":",
"expr_list",
"=",
"[",
"]",
"for",
"(",
"key",
",",
... | returns execable python code that declares variables using keys and values
execstr_dict
Args:
dict_ (dict):
local_name (str): optional: local name of dictionary. Specifying this
is much safer
exclude_list (list):
Returns:
str: execstr --- the executable string ... | [
"returns",
"execable",
"python",
"code",
"that",
"declares",
"variables",
"using",
"keys",
"and",
"values"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L112-L203 | train |
Erotemic/utool | utool/util_dbg.py | embed2 | def embed2(**kwargs):
"""
Modified from IPython.terminal.embed.embed so I can mess with stack_depth
"""
config = kwargs.get('config')
header = kwargs.pop('header', u'')
stack_depth = kwargs.pop('stack_depth', 2)
compile_flags = kwargs.pop('compile_flags', None)
import IPython
from IP... | python | def embed2(**kwargs):
"""
Modified from IPython.terminal.embed.embed so I can mess with stack_depth
"""
config = kwargs.get('config')
header = kwargs.pop('header', u'')
stack_depth = kwargs.pop('stack_depth', 2)
compile_flags = kwargs.pop('compile_flags', None)
import IPython
from IP... | [
"def",
"embed2",
"(",
"**",
"kwargs",
")",
":",
"config",
"=",
"kwargs",
".",
"get",
"(",
"'config'",
")",
"header",
"=",
"kwargs",
".",
"pop",
"(",
"'header'",
",",
"u''",
")",
"stack_depth",
"=",
"kwargs",
".",
"pop",
"(",
"'stack_depth'",
",",
"2"... | Modified from IPython.terminal.embed.embed so I can mess with stack_depth | [
"Modified",
"from",
"IPython",
".",
"terminal",
".",
"embed",
".",
"embed",
"so",
"I",
"can",
"mess",
"with",
"stack_depth"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L559-L598 | train |
Erotemic/utool | utool/util_dbg.py | search_stack_for_localvar | def search_stack_for_localvar(varname):
"""
Finds a local varable somewhere in the stack and returns the value
Args:
varname (str): variable name
Returns:
None if varname is not found else its value
"""
curr_frame = inspect.currentframe()
print(' * Searching parent frames f... | python | def search_stack_for_localvar(varname):
"""
Finds a local varable somewhere in the stack and returns the value
Args:
varname (str): variable name
Returns:
None if varname is not found else its value
"""
curr_frame = inspect.currentframe()
print(' * Searching parent frames f... | [
"def",
"search_stack_for_localvar",
"(",
"varname",
")",
":",
"curr_frame",
"=",
"inspect",
".",
"currentframe",
"(",
")",
"print",
"(",
"' * Searching parent frames for: '",
"+",
"six",
".",
"text_type",
"(",
"varname",
")",
")",
"frame_no",
"=",
"0",
"while",
... | Finds a local varable somewhere in the stack and returns the value
Args:
varname (str): variable name
Returns:
None if varname is not found else its value | [
"Finds",
"a",
"local",
"varable",
"somewhere",
"in",
"the",
"stack",
"and",
"returns",
"the",
"value"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L684-L704 | train |
Erotemic/utool | utool/util_dbg.py | formatex | def formatex(ex, msg='[!?] Caught exception',
prefix=None, key_list=[], locals_=None, iswarning=False, tb=False,
N=0, keys=None, colored=None):
r"""
Formats an exception with relevant info
Args:
ex (Exception): exception to print
msg (unicode): a message to displa... | python | def formatex(ex, msg='[!?] Caught exception',
prefix=None, key_list=[], locals_=None, iswarning=False, tb=False,
N=0, keys=None, colored=None):
r"""
Formats an exception with relevant info
Args:
ex (Exception): exception to print
msg (unicode): a message to displa... | [
"def",
"formatex",
"(",
"ex",
",",
"msg",
"=",
"'[!?] Caught exception'",
",",
"prefix",
"=",
"None",
",",
"key_list",
"=",
"[",
"]",
",",
"locals_",
"=",
"None",
",",
"iswarning",
"=",
"False",
",",
"tb",
"=",
"False",
",",
"N",
"=",
"0",
",",
"ke... | r"""
Formats an exception with relevant info
Args:
ex (Exception): exception to print
msg (unicode): a message to display to the user (default = u'[!?] Caught exception')
keys (None): a list of strings denoting variables or expressions of interest (default = [])
iswarning (bool... | [
"r",
"Formats",
"an",
"exception",
"with",
"relevant",
"info"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L1090-L1170 | train |
Erotemic/utool | utool/util_dbg.py | parse_locals_keylist | def parse_locals_keylist(locals_, key_list, strlist_=None, prefix=''):
""" For each key in keylist, puts its value in locals into a stringlist
Args:
locals_ (?):
key_list (list):
strlist_ (list): (default = None)
prefix (unicode): (default = u'')
Returns:
list: strl... | python | def parse_locals_keylist(locals_, key_list, strlist_=None, prefix=''):
""" For each key in keylist, puts its value in locals into a stringlist
Args:
locals_ (?):
key_list (list):
strlist_ (list): (default = None)
prefix (unicode): (default = u'')
Returns:
list: strl... | [
"def",
"parse_locals_keylist",
"(",
"locals_",
",",
"key_list",
",",
"strlist_",
"=",
"None",
",",
"prefix",
"=",
"''",
")",
":",
"from",
"utool",
"import",
"util_str",
"if",
"strlist_",
"is",
"None",
":",
"strlist_",
"=",
"[",
"]",
"for",
"key",
"in",
... | For each key in keylist, puts its value in locals into a stringlist
Args:
locals_ (?):
key_list (list):
strlist_ (list): (default = None)
prefix (unicode): (default = u'')
Returns:
list: strlist_
CommandLine:
python -m utool.util_dbg --exec-parse_locals_key... | [
"For",
"each",
"key",
"in",
"keylist",
"puts",
"its",
"value",
"in",
"locals",
"into",
"a",
"stringlist"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dbg.py#L1265-L1331 | train |
dsoprea/NsqSpinner | nsq/consumer.py | ConsumerCallbacks.__send_rdy | def __send_rdy(self, connection, command):
"""Determine the RDY value, and set it. It can either be a static value
a callback, or None. If it's None, we'll calculate the value based on
our limits and connection counts.
The documentation recommends starting with (1), but since we are alw... | python | def __send_rdy(self, connection, command):
"""Determine the RDY value, and set it. It can either be a static value
a callback, or None. If it's None, we'll calculate the value based on
our limits and connection counts.
The documentation recommends starting with (1), but since we are alw... | [
"def",
"__send_rdy",
"(",
"self",
",",
"connection",
",",
"command",
")",
":",
"if",
"self",
".",
"__consumer",
".",
"original_rdy",
"is",
"None",
":",
"node_count",
"=",
"self",
".",
"__consumer",
".",
"get_node_count_for_topic",
"(",
"connection",
".",
"co... | Determine the RDY value, and set it. It can either be a static value
a callback, or None. If it's None, we'll calculate the value based on
our limits and connection counts.
The documentation recommends starting with (1), but since we are always
dealing directly with *nsqd* servers by no... | [
"Determine",
"the",
"RDY",
"value",
"and",
"set",
"it",
".",
"It",
"can",
"either",
"be",
"a",
"static",
"value",
"a",
"callback",
"or",
"None",
".",
"If",
"it",
"s",
"None",
"we",
"ll",
"calculate",
"the",
"value",
"based",
"on",
"our",
"limits",
"a... | 972237b8ddce737983bfed001fde52e5236be695 | https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/consumer.py#L41-L153 | train |
glormph/msstitch | src/app/actions/headers/peptable.py | switch_psm_to_peptable_fields | def switch_psm_to_peptable_fields(oldheader):
"""Returns a dict map with old to new header fields"""
return {old: new for old, new in zip([mzidtsvdata.HEADER_PEPTIDE,
mzidtsvdata.HEADER_PROTEIN,
mzidtsvdata.HEADER_PEPTIDE_Q,
... | python | def switch_psm_to_peptable_fields(oldheader):
"""Returns a dict map with old to new header fields"""
return {old: new for old, new in zip([mzidtsvdata.HEADER_PEPTIDE,
mzidtsvdata.HEADER_PROTEIN,
mzidtsvdata.HEADER_PEPTIDE_Q,
... | [
"def",
"switch_psm_to_peptable_fields",
"(",
"oldheader",
")",
":",
"return",
"{",
"old",
":",
"new",
"for",
"old",
",",
"new",
"in",
"zip",
"(",
"[",
"mzidtsvdata",
".",
"HEADER_PEPTIDE",
",",
"mzidtsvdata",
".",
"HEADER_PROTEIN",
",",
"mzidtsvdata",
".",
"... | Returns a dict map with old to new header fields | [
"Returns",
"a",
"dict",
"map",
"with",
"old",
"to",
"new",
"header",
"fields"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/headers/peptable.py#L11-L20 | train |
anayjoshi/platypus | platypus/cfg/cfg.py | BasicBlock.add_instruction | def add_instruction (self, instr):
"""
Adds the argument instruction in the list of instructions of this basic block.
Also updates the variable lists (used_variables, defined_variables)
"""
assert(isinstance(instr, Instruction))
self.instruction_list.append(instr)
... | python | def add_instruction (self, instr):
"""
Adds the argument instruction in the list of instructions of this basic block.
Also updates the variable lists (used_variables, defined_variables)
"""
assert(isinstance(instr, Instruction))
self.instruction_list.append(instr)
... | [
"def",
"add_instruction",
"(",
"self",
",",
"instr",
")",
":",
"assert",
"(",
"isinstance",
"(",
"instr",
",",
"Instruction",
")",
")",
"self",
".",
"instruction_list",
".",
"append",
"(",
"instr",
")",
"if",
"instr",
".",
"lhs",
"not",
"in",
"self",
"... | Adds the argument instruction in the list of instructions of this basic block.
Also updates the variable lists (used_variables, defined_variables) | [
"Adds",
"the",
"argument",
"instruction",
"in",
"the",
"list",
"of",
"instructions",
"of",
"this",
"basic",
"block",
"."
] | 71712f58c99651efbd2e6dfd75a9b1228d42e9ef | https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L169-L190 | train |
anayjoshi/platypus | platypus/cfg/cfg.py | BasicBlock.set_condition | def set_condition(self, condition, condition_instr=None):
"""
Defines the condition which decides how the basic block exits
:param condition:
:type condition:
:param condition_instr: If the 'condition' argument is a Variable, then\
condition_instr is None, else,... | python | def set_condition(self, condition, condition_instr=None):
"""
Defines the condition which decides how the basic block exits
:param condition:
:type condition:
:param condition_instr: If the 'condition' argument is a Variable, then\
condition_instr is None, else,... | [
"def",
"set_condition",
"(",
"self",
",",
"condition",
",",
"condition_instr",
"=",
"None",
")",
":",
"assert",
"(",
"isinstance",
"(",
"condition",
",",
"Numeric",
")",
")",
"if",
"condition_instr",
"is",
"not",
"None",
":",
"assert",
"(",
"isinstance",
"... | Defines the condition which decides how the basic block exits
:param condition:
:type condition:
:param condition_instr: If the 'condition' argument is a Variable, then\
condition_instr is None, else, condition_instr should be\
of type CmpInstruction
:ty... | [
"Defines",
"the",
"condition",
"which",
"decides",
"how",
"the",
"basic",
"block",
"exits"
] | 71712f58c99651efbd2e6dfd75a9b1228d42e9ef | https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L193-L219 | train |
anayjoshi/platypus | platypus/cfg/cfg.py | Function.add_basic_block | def add_basic_block(self, basic_block):
"""Adds the given basic block in the function"""
assert(isinstance(basic_block, BasicBlock))
self.basic_block_list.append(basic_block) | python | def add_basic_block(self, basic_block):
"""Adds the given basic block in the function"""
assert(isinstance(basic_block, BasicBlock))
self.basic_block_list.append(basic_block) | [
"def",
"add_basic_block",
"(",
"self",
",",
"basic_block",
")",
":",
"assert",
"(",
"isinstance",
"(",
"basic_block",
",",
"BasicBlock",
")",
")",
"self",
".",
"basic_block_list",
".",
"append",
"(",
"basic_block",
")"
] | Adds the given basic block in the function | [
"Adds",
"the",
"given",
"basic",
"block",
"in",
"the",
"function"
] | 71712f58c99651efbd2e6dfd75a9b1228d42e9ef | https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L256-L259 | train |
anayjoshi/platypus | platypus/cfg/cfg.py | Function.get_variable | def get_variable(self, var_name):
"""
If a variable with the name var_name exists in this function's variable list, \
then that variable object is returned; else a new variable is created\
with the given name and added to the variable list of this function\
... | python | def get_variable(self, var_name):
"""
If a variable with the name var_name exists in this function's variable list, \
then that variable object is returned; else a new variable is created\
with the given name and added to the variable list of this function\
... | [
"def",
"get_variable",
"(",
"self",
",",
"var_name",
")",
":",
"assert",
"(",
"isinstance",
"(",
"var_name",
",",
"str",
")",
")",
"if",
"isinstance",
"(",
"var_name",
",",
"str",
")",
":",
"for",
"var",
"in",
"self",
".",
"variable_list",
":",
"if",
... | If a variable with the name var_name exists in this function's variable list, \
then that variable object is returned; else a new variable is created\
with the given name and added to the variable list of this function\
and returned back
:returns: A variable whic... | [
"If",
"a",
"variable",
"with",
"the",
"name",
"var_name",
"exists",
"in",
"this",
"function",
"s",
"variable",
"list",
"\\",
"then",
"that",
"variable",
"object",
"is",
"returned",
";",
"else",
"a",
"new",
"variable",
"is",
"created",
"\\",
"with",
"the",
... | 71712f58c99651efbd2e6dfd75a9b1228d42e9ef | https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L268-L285 | train |
anayjoshi/platypus | platypus/cfg/cfg.py | Function.add_input_variable | def add_input_variable(self, var):
"""Adds the argument variable as one of the input variable"""
assert(isinstance(var, Variable))
self.input_variable_list.append(var) | python | def add_input_variable(self, var):
"""Adds the argument variable as one of the input variable"""
assert(isinstance(var, Variable))
self.input_variable_list.append(var) | [
"def",
"add_input_variable",
"(",
"self",
",",
"var",
")",
":",
"assert",
"(",
"isinstance",
"(",
"var",
",",
"Variable",
")",
")",
"self",
".",
"input_variable_list",
".",
"append",
"(",
"var",
")"
] | Adds the argument variable as one of the input variable | [
"Adds",
"the",
"argument",
"variable",
"as",
"one",
"of",
"the",
"input",
"variable"
] | 71712f58c99651efbd2e6dfd75a9b1228d42e9ef | https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L287-L290 | train |
anayjoshi/platypus | platypus/cfg/cfg.py | Function.add_output_variable | def add_output_variable(self, var):
"""Adds the argument variable as one of the output variable"""
assert(isinstance(var, Variable))
self.output_variable_list.append(var) | python | def add_output_variable(self, var):
"""Adds the argument variable as one of the output variable"""
assert(isinstance(var, Variable))
self.output_variable_list.append(var) | [
"def",
"add_output_variable",
"(",
"self",
",",
"var",
")",
":",
"assert",
"(",
"isinstance",
"(",
"var",
",",
"Variable",
")",
")",
"self",
".",
"output_variable_list",
".",
"append",
"(",
"var",
")"
] | Adds the argument variable as one of the output variable | [
"Adds",
"the",
"argument",
"variable",
"as",
"one",
"of",
"the",
"output",
"variable"
] | 71712f58c99651efbd2e6dfd75a9b1228d42e9ef | https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/cfg.py#L292-L295 | train |
LEMS/pylems | lems/parser/expr.py | ExprParser.tokenize | def tokenize(self):
"""
Tokenizes the string stored in the parser object into a list
of tokens.
"""
self.token_list = []
ps = self.parse_string.strip()
i = 0
last_token = None
while i < len(ps) and ps[i].isspace():
i += 1
wh... | python | def tokenize(self):
"""
Tokenizes the string stored in the parser object into a list
of tokens.
"""
self.token_list = []
ps = self.parse_string.strip()
i = 0
last_token = None
while i < len(ps) and ps[i].isspace():
i += 1
wh... | [
"def",
"tokenize",
"(",
"self",
")",
":",
"self",
".",
"token_list",
"=",
"[",
"]",
"ps",
"=",
"self",
".",
"parse_string",
".",
"strip",
"(",
")",
"i",
"=",
"0",
"last_token",
"=",
"None",
"while",
"i",
"<",
"len",
"(",
"ps",
")",
"and",
"ps",
... | Tokenizes the string stored in the parser object into a list
of tokens. | [
"Tokenizes",
"the",
"string",
"stored",
"in",
"the",
"parser",
"object",
"into",
"a",
"list",
"of",
"tokens",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/parser/expr.py#L263-L315 | train |
LEMS/pylems | lems/parser/expr.py | ExprParser.parse | def parse(self):
"""
Tokenizes and parses an arithmetic expression into a parse tree.
@return: Returns a token string.
@rtype: lems.parser.expr.ExprNode
"""
#print("Parsing: %s"%self.parse_string)
self.tokenize()
if self.debug: print("Tokens found: %s"%se... | python | def parse(self):
"""
Tokenizes and parses an arithmetic expression into a parse tree.
@return: Returns a token string.
@rtype: lems.parser.expr.ExprNode
"""
#print("Parsing: %s"%self.parse_string)
self.tokenize()
if self.debug: print("Tokens found: %s"%se... | [
"def",
"parse",
"(",
"self",
")",
":",
"self",
".",
"tokenize",
"(",
")",
"if",
"self",
".",
"debug",
":",
"print",
"(",
"\"Tokens found: %s\"",
"%",
"self",
".",
"token_list",
")",
"try",
":",
"parse_tree",
"=",
"self",
".",
"parse2",
"(",
")",
"exc... | Tokenizes and parses an arithmetic expression into a parse tree.
@return: Returns a token string.
@rtype: lems.parser.expr.ExprNode | [
"Tokenizes",
"and",
"parses",
"an",
"arithmetic",
"expression",
"into",
"a",
"parse",
"tree",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/parser/expr.py#L478-L493 | train |
chriso/gauged | gauged/drivers/mysql.py | MySQLDriver.insert_keys | def insert_keys(self, keys):
"""Insert keys into a table which assigns an ID"""
start = 0
bulk_insert = self.bulk_insert
keys_len = len(keys)
query = 'INSERT IGNORE INTO gauged_keys (namespace, `key`) VALUES '
execute = self.cursor.execute
while start < keys_len:
... | python | def insert_keys(self, keys):
"""Insert keys into a table which assigns an ID"""
start = 0
bulk_insert = self.bulk_insert
keys_len = len(keys)
query = 'INSERT IGNORE INTO gauged_keys (namespace, `key`) VALUES '
execute = self.cursor.execute
while start < keys_len:
... | [
"def",
"insert_keys",
"(",
"self",
",",
"keys",
")",
":",
"start",
"=",
"0",
"bulk_insert",
"=",
"self",
".",
"bulk_insert",
"keys_len",
"=",
"len",
"(",
"keys",
")",
"query",
"=",
"'INSERT IGNORE INTO gauged_keys (namespace, `key`) VALUES '",
"execute",
"=",
"s... | Insert keys into a table which assigns an ID | [
"Insert",
"keys",
"into",
"a",
"table",
"which",
"assigns",
"an",
"ID"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L81-L93 | train |
chriso/gauged | gauged/drivers/mysql.py | MySQLDriver.get_writer_position | def get_writer_position(self, name):
"""Get the current writer position"""
cursor = self.cursor
cursor.execute('SELECT timestamp FROM gauged_writer_history '
'WHERE id = %s', (name,))
result = cursor.fetchone()
return result[0] if result else 0 | python | def get_writer_position(self, name):
"""Get the current writer position"""
cursor = self.cursor
cursor.execute('SELECT timestamp FROM gauged_writer_history '
'WHERE id = %s', (name,))
result = cursor.fetchone()
return result[0] if result else 0 | [
"def",
"get_writer_position",
"(",
"self",
",",
"name",
")",
":",
"cursor",
"=",
"self",
".",
"cursor",
"cursor",
".",
"execute",
"(",
"'SELECT timestamp FROM gauged_writer_history '",
"'WHERE id = %s'",
",",
"(",
"name",
",",
")",
")",
"result",
"=",
"cursor",
... | Get the current writer position | [
"Get",
"the",
"current",
"writer",
"position"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L174-L180 | train |
chriso/gauged | gauged/drivers/mysql.py | MySQLDriver.get_namespaces | def get_namespaces(self):
"""Get a list of namespaces"""
cursor = self.cursor
cursor.execute('SELECT DISTINCT namespace FROM gauged_statistics')
return [namespace for namespace, in cursor] | python | def get_namespaces(self):
"""Get a list of namespaces"""
cursor = self.cursor
cursor.execute('SELECT DISTINCT namespace FROM gauged_statistics')
return [namespace for namespace, in cursor] | [
"def",
"get_namespaces",
"(",
"self",
")",
":",
"cursor",
"=",
"self",
".",
"cursor",
"cursor",
".",
"execute",
"(",
"'SELECT DISTINCT namespace FROM gauged_statistics'",
")",
"return",
"[",
"namespace",
"for",
"namespace",
",",
"in",
"cursor",
"]"
] | Get a list of namespaces | [
"Get",
"a",
"list",
"of",
"namespaces"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L182-L186 | train |
chriso/gauged | gauged/drivers/mysql.py | MySQLDriver.remove_namespace | def remove_namespace(self, namespace):
"""Remove all data associated with the current namespace"""
params = (namespace, )
execute = self.cursor.execute
execute('DELETE FROM gauged_data WHERE namespace = %s', params)
execute('DELETE FROM gauged_statistics WHERE namespace = %s', pa... | python | def remove_namespace(self, namespace):
"""Remove all data associated with the current namespace"""
params = (namespace, )
execute = self.cursor.execute
execute('DELETE FROM gauged_data WHERE namespace = %s', params)
execute('DELETE FROM gauged_statistics WHERE namespace = %s', pa... | [
"def",
"remove_namespace",
"(",
"self",
",",
"namespace",
")",
":",
"params",
"=",
"(",
"namespace",
",",
")",
"execute",
"=",
"self",
".",
"cursor",
".",
"execute",
"execute",
"(",
"'DELETE FROM gauged_data WHERE namespace = %s'",
",",
"params",
")",
"execute",... | Remove all data associated with the current namespace | [
"Remove",
"all",
"data",
"associated",
"with",
"the",
"current",
"namespace"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L188-L195 | train |
chriso/gauged | gauged/drivers/mysql.py | MySQLDriver.remove_cache | def remove_cache(self, namespace, key=None):
"""Remove all cached values for the specified namespace,
optionally specifying a key"""
if key is None:
self.cursor.execute('DELETE FROM gauged_cache '
'WHERE namespace = %s', (namespace,))
else:
... | python | def remove_cache(self, namespace, key=None):
"""Remove all cached values for the specified namespace,
optionally specifying a key"""
if key is None:
self.cursor.execute('DELETE FROM gauged_cache '
'WHERE namespace = %s', (namespace,))
else:
... | [
"def",
"remove_cache",
"(",
"self",
",",
"namespace",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"self",
".",
"cursor",
".",
"execute",
"(",
"'DELETE FROM gauged_cache '",
"'WHERE namespace = %s'",
",",
"(",
"namespace",
",",
")",
"... | Remove all cached values for the specified namespace,
optionally specifying a key | [
"Remove",
"all",
"cached",
"values",
"for",
"the",
"specified",
"namespace",
"optionally",
"specifying",
"a",
"key"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L274-L283 | train |
chriso/gauged | gauged/drivers/mysql.py | MySQLDriver.clear_schema | def clear_schema(self):
"""Clear all gauged data"""
execute = self.cursor.execute
execute('TRUNCATE TABLE gauged_data')
execute('TRUNCATE TABLE gauged_keys')
execute('TRUNCATE TABLE gauged_writer_history')
execute('TRUNCATE TABLE gauged_cache')
execute('TRUNCATE T... | python | def clear_schema(self):
"""Clear all gauged data"""
execute = self.cursor.execute
execute('TRUNCATE TABLE gauged_data')
execute('TRUNCATE TABLE gauged_keys')
execute('TRUNCATE TABLE gauged_writer_history')
execute('TRUNCATE TABLE gauged_cache')
execute('TRUNCATE T... | [
"def",
"clear_schema",
"(",
"self",
")",
":",
"execute",
"=",
"self",
".",
"cursor",
".",
"execute",
"execute",
"(",
"'TRUNCATE TABLE gauged_data'",
")",
"execute",
"(",
"'TRUNCATE TABLE gauged_keys'",
")",
"execute",
"(",
"'TRUNCATE TABLE gauged_writer_history'",
")"... | Clear all gauged data | [
"Clear",
"all",
"gauged",
"data"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/mysql.py#L355-L363 | train |
Erotemic/utool | utool/util_numpy.py | quantum_random | def quantum_random():
""" returns a 32 bit unsigned integer quantum random number """
import quantumrandom
data16 = quantumrandom.uint16(array_length=2)
assert data16.flags['C_CONTIGUOUS']
data32 = data16.view(np.dtype('uint32'))[0]
return data32 | python | def quantum_random():
""" returns a 32 bit unsigned integer quantum random number """
import quantumrandom
data16 = quantumrandom.uint16(array_length=2)
assert data16.flags['C_CONTIGUOUS']
data32 = data16.view(np.dtype('uint32'))[0]
return data32 | [
"def",
"quantum_random",
"(",
")",
":",
"import",
"quantumrandom",
"data16",
"=",
"quantumrandom",
".",
"uint16",
"(",
"array_length",
"=",
"2",
")",
"assert",
"data16",
".",
"flags",
"[",
"'C_CONTIGUOUS'",
"]",
"data32",
"=",
"data16",
".",
"view",
"(",
"... | returns a 32 bit unsigned integer quantum random number | [
"returns",
"a",
"32",
"bit",
"unsigned",
"integer",
"quantum",
"random",
"number"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L19-L25 | train |
Erotemic/utool | utool/util_numpy.py | _npstate_to_pystate | def _npstate_to_pystate(npstate):
"""
Convert state of a NumPy RandomState object to a state
that can be used by Python's Random.
References:
https://stackoverflow.com/questions/44313620/converting-randomstate
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import *... | python | def _npstate_to_pystate(npstate):
"""
Convert state of a NumPy RandomState object to a state
that can be used by Python's Random.
References:
https://stackoverflow.com/questions/44313620/converting-randomstate
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import *... | [
"def",
"_npstate_to_pystate",
"(",
"npstate",
")",
":",
"PY_VERSION",
"=",
"3",
"version",
",",
"keys",
",",
"pos",
",",
"has_gauss",
",",
"cached_gaussian_",
"=",
"npstate",
"keys_pos",
"=",
"tuple",
"(",
"map",
"(",
"int",
",",
"keys",
")",
")",
"+",
... | Convert state of a NumPy RandomState object to a state
that can be used by Python's Random.
References:
https://stackoverflow.com/questions/44313620/converting-randomstate
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import * # NOQA
>>> from utool.util_numpy imp... | [
"Convert",
"state",
"of",
"a",
"NumPy",
"RandomState",
"object",
"to",
"a",
"state",
"that",
"can",
"be",
"used",
"by",
"Python",
"s",
"Random",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L28-L52 | train |
Erotemic/utool | utool/util_numpy.py | _pystate_to_npstate | def _pystate_to_npstate(pystate):
"""
Convert state of a Python Random object to state usable
by NumPy RandomState.
References:
https://stackoverflow.com/questions/44313620/converting-randomstate
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import * # NOQA
... | python | def _pystate_to_npstate(pystate):
"""
Convert state of a Python Random object to state usable
by NumPy RandomState.
References:
https://stackoverflow.com/questions/44313620/converting-randomstate
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import * # NOQA
... | [
"def",
"_pystate_to_npstate",
"(",
"pystate",
")",
":",
"NP_VERSION",
"=",
"'MT19937'",
"version",
",",
"keys_pos_",
",",
"cached_gaussian_",
"=",
"pystate",
"keys",
",",
"pos",
"=",
"keys_pos_",
"[",
":",
"-",
"1",
"]",
",",
"keys_pos_",
"[",
"-",
"1",
... | Convert state of a Python Random object to state usable
by NumPy RandomState.
References:
https://stackoverflow.com/questions/44313620/converting-randomstate
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import * # NOQA
>>> from utool.util_numpy import _pystate_t... | [
"Convert",
"state",
"of",
"a",
"Python",
"Random",
"object",
"to",
"state",
"usable",
"by",
"NumPy",
"RandomState",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L55-L81 | train |
Erotemic/utool | utool/util_numpy.py | ensure_rng | def ensure_rng(rng, impl='numpy'):
"""
Returns a random number generator
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import * # NOQA
>>> import utool as ut
>>> import numpy as np
>>> num = 4
>>> print('--- Python as PYTHON ---')
>>> py_rn... | python | def ensure_rng(rng, impl='numpy'):
"""
Returns a random number generator
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import * # NOQA
>>> import utool as ut
>>> import numpy as np
>>> num = 4
>>> print('--- Python as PYTHON ---')
>>> py_rn... | [
"def",
"ensure_rng",
"(",
"rng",
",",
"impl",
"=",
"'numpy'",
")",
":",
"if",
"impl",
"==",
"'numpy'",
":",
"if",
"rng",
"is",
"None",
":",
"rng",
"=",
"np",
".",
"random",
"elif",
"isinstance",
"(",
"rng",
",",
"int",
")",
":",
"rng",
"=",
"np",... | Returns a random number generator
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_numpy import * # NOQA
>>> import utool as ut
>>> import numpy as np
>>> num = 4
>>> print('--- Python as PYTHON ---')
>>> py_rng = random.Random(0)
>>> pp_nums = [py_... | [
"Returns",
"a",
"random",
"number",
"generator"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L84-L139 | train |
Erotemic/utool | utool/util_numpy.py | random_indexes | def random_indexes(max_index, subset_size=None, seed=None, rng=None):
""" random unrepeated indicies
Args:
max_index (?):
subset_size (None): (default = None)
seed (None): (default = None)
rng (RandomState): random number generator(default = None)
Returns:
?: subst... | python | def random_indexes(max_index, subset_size=None, seed=None, rng=None):
""" random unrepeated indicies
Args:
max_index (?):
subset_size (None): (default = None)
seed (None): (default = None)
rng (RandomState): random number generator(default = None)
Returns:
?: subst... | [
"def",
"random_indexes",
"(",
"max_index",
",",
"subset_size",
"=",
"None",
",",
"seed",
"=",
"None",
",",
"rng",
"=",
"None",
")",
":",
"subst_",
"=",
"np",
".",
"arange",
"(",
"0",
",",
"max_index",
")",
"rng",
"=",
"ensure_rng",
"(",
"seed",
"if",... | random unrepeated indicies
Args:
max_index (?):
subset_size (None): (default = None)
seed (None): (default = None)
rng (RandomState): random number generator(default = None)
Returns:
?: subst
CommandLine:
python -m utool.util_numpy --exec-random_indexes
... | [
"random",
"unrepeated",
"indicies"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L142-L175 | train |
Erotemic/utool | utool/util_numpy.py | spaced_indexes | def spaced_indexes(len_, n, trunc=False):
"""
Returns n evenly spaced indexes.
Returns as many as possible if trunc is true
"""
if n is None:
return np.arange(len_)
all_indexes = np.arange(len_)
if trunc:
n = min(len_, n)
if n == 0:
return np.empty(0)
stride ... | python | def spaced_indexes(len_, n, trunc=False):
"""
Returns n evenly spaced indexes.
Returns as many as possible if trunc is true
"""
if n is None:
return np.arange(len_)
all_indexes = np.arange(len_)
if trunc:
n = min(len_, n)
if n == 0:
return np.empty(0)
stride ... | [
"def",
"spaced_indexes",
"(",
"len_",
",",
"n",
",",
"trunc",
"=",
"False",
")",
":",
"if",
"n",
"is",
"None",
":",
"return",
"np",
".",
"arange",
"(",
"len_",
")",
"all_indexes",
"=",
"np",
".",
"arange",
"(",
"len_",
")",
"if",
"trunc",
":",
"n... | Returns n evenly spaced indexes.
Returns as many as possible if trunc is true | [
"Returns",
"n",
"evenly",
"spaced",
"indexes",
".",
"Returns",
"as",
"many",
"as",
"possible",
"if",
"trunc",
"is",
"true"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L201-L219 | train |
Erotemic/utool | utool/util_numpy.py | random_sample | def random_sample(list_, nSample, strict=False, rng=None, seed=None):
"""
Grabs data randomly
Args:
list_ (list):
nSample (?):
strict (bool): (default = False)
rng (module): random number generator(default = numpy.random)
seed (None): (default = None)
Returns:
... | python | def random_sample(list_, nSample, strict=False, rng=None, seed=None):
"""
Grabs data randomly
Args:
list_ (list):
nSample (?):
strict (bool): (default = False)
rng (module): random number generator(default = numpy.random)
seed (None): (default = None)
Returns:
... | [
"def",
"random_sample",
"(",
"list_",
",",
"nSample",
",",
"strict",
"=",
"False",
",",
"rng",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"rng",
"=",
"ensure_rng",
"(",
"seed",
"if",
"rng",
"is",
"None",
"else",
"rng",
")",
"if",
"isinstance",
... | Grabs data randomly
Args:
list_ (list):
nSample (?):
strict (bool): (default = False)
rng (module): random number generator(default = numpy.random)
seed (None): (default = None)
Returns:
list: sample_list
CommandLine:
python -m utool.util_numpy --e... | [
"Grabs",
"data",
"randomly"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L323-L365 | train |
Erotemic/utool | utool/util_numpy.py | deterministic_sample | def deterministic_sample(list_, nSample, seed=0, rng=None, strict=False):
""" Grabs data randomly, but in a repeatable way """
rng = ensure_rng(seed if rng is None else rng)
sample_list = random_sample(list_, nSample, strict=strict, rng=rng)
return sample_list | python | def deterministic_sample(list_, nSample, seed=0, rng=None, strict=False):
""" Grabs data randomly, but in a repeatable way """
rng = ensure_rng(seed if rng is None else rng)
sample_list = random_sample(list_, nSample, strict=strict, rng=rng)
return sample_list | [
"def",
"deterministic_sample",
"(",
"list_",
",",
"nSample",
",",
"seed",
"=",
"0",
",",
"rng",
"=",
"None",
",",
"strict",
"=",
"False",
")",
":",
"rng",
"=",
"ensure_rng",
"(",
"seed",
"if",
"rng",
"is",
"None",
"else",
"rng",
")",
"sample_list",
"... | Grabs data randomly, but in a repeatable way | [
"Grabs",
"data",
"randomly",
"but",
"in",
"a",
"repeatable",
"way"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L368-L372 | train |
Erotemic/utool | utool/util_numpy.py | spaced_items | def spaced_items(list_, n, **kwargs):
""" Returns n evenly spaced items """
indexes = spaced_indexes(len(list_), n, **kwargs)
items = list_[indexes]
return items | python | def spaced_items(list_, n, **kwargs):
""" Returns n evenly spaced items """
indexes = spaced_indexes(len(list_), n, **kwargs)
items = list_[indexes]
return items | [
"def",
"spaced_items",
"(",
"list_",
",",
"n",
",",
"**",
"kwargs",
")",
":",
"indexes",
"=",
"spaced_indexes",
"(",
"len",
"(",
"list_",
")",
",",
"n",
",",
"**",
"kwargs",
")",
"items",
"=",
"list_",
"[",
"indexes",
"]",
"return",
"items"
] | Returns n evenly spaced items | [
"Returns",
"n",
"evenly",
"spaced",
"items"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_numpy.py#L375-L379 | train |
dsoprea/NsqSpinner | nsq/node_collection.py | ServerNodes.get_servers | def get_servers(self, topic):
"""We're assuming that the static list of servers can serve the given
topic, since we have to preexisting knowledge about them.
"""
return (nsq.node.ServerNode(sh) for sh in self.__server_hosts) | python | def get_servers(self, topic):
"""We're assuming that the static list of servers can serve the given
topic, since we have to preexisting knowledge about them.
"""
return (nsq.node.ServerNode(sh) for sh in self.__server_hosts) | [
"def",
"get_servers",
"(",
"self",
",",
"topic",
")",
":",
"return",
"(",
"nsq",
".",
"node",
".",
"ServerNode",
"(",
"sh",
")",
"for",
"sh",
"in",
"self",
".",
"__server_hosts",
")"
] | We're assuming that the static list of servers can serve the given
topic, since we have to preexisting knowledge about them. | [
"We",
"re",
"assuming",
"that",
"the",
"static",
"list",
"of",
"servers",
"can",
"serve",
"the",
"given",
"topic",
"since",
"we",
"have",
"to",
"preexisting",
"knowledge",
"about",
"them",
"."
] | 972237b8ddce737983bfed001fde52e5236be695 | https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/node_collection.py#L14-L19 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/tokenizer.py | tokenizer | def tokenizer(text):
"""A lexical analyzer for the `CTfile` formatted files.
:param str text: `CTfile` formatted text.
:return: Tuples of data.
:rtype: py:class:`~collections.namedtuple`
"""
for entry in text.split('$$$$\n'):
if entry.rstrip():
lines_stream = deque(entry.spl... | python | def tokenizer(text):
"""A lexical analyzer for the `CTfile` formatted files.
:param str text: `CTfile` formatted text.
:return: Tuples of data.
:rtype: py:class:`~collections.namedtuple`
"""
for entry in text.split('$$$$\n'):
if entry.rstrip():
lines_stream = deque(entry.spl... | [
"def",
"tokenizer",
"(",
"text",
")",
":",
"for",
"entry",
"in",
"text",
".",
"split",
"(",
"'$$$$\\n'",
")",
":",
"if",
"entry",
".",
"rstrip",
"(",
")",
":",
"lines_stream",
"=",
"deque",
"(",
"entry",
".",
"split",
"(",
"'\\n'",
")",
")",
"else"... | A lexical analyzer for the `CTfile` formatted files.
:param str text: `CTfile` formatted text.
:return: Tuples of data.
:rtype: py:class:`~collections.namedtuple` | [
"A",
"lexical",
"analyzer",
"for",
"the",
"CTfile",
"formatted",
"files",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/tokenizer.py#L48-L70 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/tokenizer.py | _ctab_atom_bond_block | def _ctab_atom_bond_block(number_of_lines, block_type, stream):
"""Process atom and bond blocks of ``Ctab``.
:param number_of_lines: Number of lines to process from stream.
:param block_type: :py:class:`collections.namedtuple` to use for data processing.
:type block_type: :class:`~ctfile.tokenizer.Ctab... | python | def _ctab_atom_bond_block(number_of_lines, block_type, stream):
"""Process atom and bond blocks of ``Ctab``.
:param number_of_lines: Number of lines to process from stream.
:param block_type: :py:class:`collections.namedtuple` to use for data processing.
:type block_type: :class:`~ctfile.tokenizer.Ctab... | [
"def",
"_ctab_atom_bond_block",
"(",
"number_of_lines",
",",
"block_type",
",",
"stream",
")",
":",
"for",
"_",
"in",
"range",
"(",
"int",
"(",
"number_of_lines",
")",
")",
":",
"line",
"=",
"stream",
".",
"popleft",
"(",
")",
"yield",
"block_type",
"(",
... | Process atom and bond blocks of ``Ctab``.
:param number_of_lines: Number of lines to process from stream.
:param block_type: :py:class:`collections.namedtuple` to use for data processing.
:type block_type: :class:`~ctfile.tokenizer.CtabAtomBlockLine` or :class:`~ctfile.tokenizer.CtabBondBlockLine`
:par... | [
"Process",
"atom",
"and",
"bond",
"blocks",
"of",
"Ctab",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/tokenizer.py#L134-L147 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/tokenizer.py | _ctab_property_block | def _ctab_property_block(stream):
"""Process properties block of ``Ctab``.
:param stream: Queue containing lines of text.
:type stream: :py:class:`collections.deque`
:return: Tuples of data.
:rtype: :class:`~ctfile.tokenizer.CtabPropertiesBlockLine`
"""
line = stream.popleft()
while lin... | python | def _ctab_property_block(stream):
"""Process properties block of ``Ctab``.
:param stream: Queue containing lines of text.
:type stream: :py:class:`collections.deque`
:return: Tuples of data.
:rtype: :class:`~ctfile.tokenizer.CtabPropertiesBlockLine`
"""
line = stream.popleft()
while lin... | [
"def",
"_ctab_property_block",
"(",
"stream",
")",
":",
"line",
"=",
"stream",
".",
"popleft",
"(",
")",
"while",
"line",
"!=",
"'M END'",
":",
"name",
"=",
"line",
".",
"split",
"(",
")",
"[",
"1",
"]",
"yield",
"CtabPropertiesBlockLine",
"(",
"name",
... | Process properties block of ``Ctab``.
:param stream: Queue containing lines of text.
:type stream: :py:class:`collections.deque`
:return: Tuples of data.
:rtype: :class:`~ctfile.tokenizer.CtabPropertiesBlockLine` | [
"Process",
"properties",
"block",
"of",
"Ctab",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/tokenizer.py#L150-L162 | train |
glormph/msstitch | src/app/drivers/pycolator/qvality.py | QvalityDriver.set_features | def set_features(self):
"""Creates scorefiles for qvality's target and decoy distributions"""
self.scores = {}
for t_or_d, feats in zip(['target', 'decoy'], [self.target,
self.decoy]):
self.scores[t_or_d] = {}
self.sc... | python | def set_features(self):
"""Creates scorefiles for qvality's target and decoy distributions"""
self.scores = {}
for t_or_d, feats in zip(['target', 'decoy'], [self.target,
self.decoy]):
self.scores[t_or_d] = {}
self.sc... | [
"def",
"set_features",
"(",
"self",
")",
":",
"self",
".",
"scores",
"=",
"{",
"}",
"for",
"t_or_d",
",",
"feats",
"in",
"zip",
"(",
"[",
"'target'",
",",
"'decoy'",
"]",
",",
"[",
"self",
".",
"target",
",",
"self",
".",
"decoy",
"]",
")",
":",
... | Creates scorefiles for qvality's target and decoy distributions | [
"Creates",
"scorefiles",
"for",
"qvality",
"s",
"target",
"and",
"decoy",
"distributions"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/qvality.py#L41-L51 | train |
glormph/msstitch | src/app/drivers/pycolator/qvality.py | QvalityDriver.write | def write(self):
"""This actually runs the qvality program from PATH."""
outfn = self.create_outfilepath(self.fn, self.outsuffix)
command = ['qvality']
command.extend(self.qvalityoptions)
command.extend([self.scores['target']['fn'], self.scores['decoy']['fn'],
... | python | def write(self):
"""This actually runs the qvality program from PATH."""
outfn = self.create_outfilepath(self.fn, self.outsuffix)
command = ['qvality']
command.extend(self.qvalityoptions)
command.extend([self.scores['target']['fn'], self.scores['decoy']['fn'],
... | [
"def",
"write",
"(",
"self",
")",
":",
"outfn",
"=",
"self",
".",
"create_outfilepath",
"(",
"self",
".",
"fn",
",",
"self",
".",
"outsuffix",
")",
"command",
"=",
"[",
"'qvality'",
"]",
"command",
".",
"extend",
"(",
"self",
".",
"qvalityoptions",
")"... | This actually runs the qvality program from PATH. | [
"This",
"actually",
"runs",
"the",
"qvality",
"program",
"from",
"PATH",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/qvality.py#L53-L60 | train |
Erotemic/utool | utool/util_project.py | setup_repo | def setup_repo():
r"""
Creates default structure for a new repo
CommandLine:
python -m utool setup_repo --repo=dtool --codedir=~/code
python -m utool setup_repo --repo=dtool --codedir=~/code
python -m utool setup_repo --repo=ibeis-flukematch-module --codedir=~/code --modname=ibeis_... | python | def setup_repo():
r"""
Creates default structure for a new repo
CommandLine:
python -m utool setup_repo --repo=dtool --codedir=~/code
python -m utool setup_repo --repo=dtool --codedir=~/code
python -m utool setup_repo --repo=ibeis-flukematch-module --codedir=~/code --modname=ibeis_... | [
"def",
"setup_repo",
"(",
")",
":",
"r",
"print",
"(",
"'\\n [setup_repo]!'",
")",
"from",
"functools",
"import",
"partial",
"import",
"utool",
"as",
"ut",
"code_dpath",
"=",
"ut",
".",
"truepath",
"(",
"ut",
".",
"get_argval",
"(",
"'--code-dir'",
",",
"d... | r"""
Creates default structure for a new repo
CommandLine:
python -m utool setup_repo --repo=dtool --codedir=~/code
python -m utool setup_repo --repo=dtool --codedir=~/code
python -m utool setup_repo --repo=ibeis-flukematch-module --codedir=~/code --modname=ibeis_flukematch
pyt... | [
"r",
"Creates",
"default",
"structure",
"for",
"a",
"new",
"repo"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_project.py#L143-L499 | train |
Erotemic/utool | utool/util_project.py | grep_projects | def grep_projects(tofind_list, user_profile=None, verbose=True, new=False,
**kwargs):
r"""
Greps the projects defined in the current UserProfile
Args:
tofind_list (list):
user_profile (None): (default = None)
Kwargs:
user_profile
CommandLine:
pyth... | python | def grep_projects(tofind_list, user_profile=None, verbose=True, new=False,
**kwargs):
r"""
Greps the projects defined in the current UserProfile
Args:
tofind_list (list):
user_profile (None): (default = None)
Kwargs:
user_profile
CommandLine:
pyth... | [
"def",
"grep_projects",
"(",
"tofind_list",
",",
"user_profile",
"=",
"None",
",",
"verbose",
"=",
"True",
",",
"new",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"r",
"import",
"utool",
"as",
"ut",
"user_profile",
"=",
"ensure_user_profile",
"(",
"user_p... | r"""
Greps the projects defined in the current UserProfile
Args:
tofind_list (list):
user_profile (None): (default = None)
Kwargs:
user_profile
CommandLine:
python -m utool --tf grep_projects grep_projects
Example:
>>> # DISABLE_DOCTEST
>>> from ut... | [
"r",
"Greps",
"the",
"projects",
"defined",
"in",
"the",
"current",
"UserProfile"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_project.py#L606-L708 | train |
crdoconnor/faketime | setup.py | CustomInstall.run | def run(self):
"""Compile libfaketime."""
if sys.platform == "linux" or sys.platform == "linux2":
libname = 'libfaketime.so.1'
libnamemt = 'libfaketimeMT.so.1'
elif sys.platform == "darwin":
libname = 'libfaketime.1.dylib'
libnamemt = 'libfaketimeM... | python | def run(self):
"""Compile libfaketime."""
if sys.platform == "linux" or sys.platform == "linux2":
libname = 'libfaketime.so.1'
libnamemt = 'libfaketimeMT.so.1'
elif sys.platform == "darwin":
libname = 'libfaketime.1.dylib'
libnamemt = 'libfaketimeM... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"\"linux\"",
"or",
"sys",
".",
"platform",
"==",
"\"linux2\"",
":",
"libname",
"=",
"'libfaketime.so.1'",
"libnamemt",
"=",
"'libfaketimeMT.so.1'",
"elif",
"sys",
".",
"platform",
"==",... | Compile libfaketime. | [
"Compile",
"libfaketime",
"."
] | 6e81ca070c0e601a52507b945ed45d5d42576b21 | https://github.com/crdoconnor/faketime/blob/6e81ca070c0e601a52507b945ed45d5d42576b21/setup.py#L14-L62 | train |
Erotemic/utool | utool/util_parallel.py | generate2 | def generate2(func, args_gen, kw_gen=None, ntasks=None, ordered=True,
force_serial=False, use_pool=False, chunksize=None, nprocs=None,
progkw={}, nTasks=None, verbose=None):
r"""
Interfaces to either multiprocessing or futures.
Esentially maps ``args_gen`` onto ``func`` using poo... | python | def generate2(func, args_gen, kw_gen=None, ntasks=None, ordered=True,
force_serial=False, use_pool=False, chunksize=None, nprocs=None,
progkw={}, nTasks=None, verbose=None):
r"""
Interfaces to either multiprocessing or futures.
Esentially maps ``args_gen`` onto ``func`` using poo... | [
"def",
"generate2",
"(",
"func",
",",
"args_gen",
",",
"kw_gen",
"=",
"None",
",",
"ntasks",
"=",
"None",
",",
"ordered",
"=",
"True",
",",
"force_serial",
"=",
"False",
",",
"use_pool",
"=",
"False",
",",
"chunksize",
"=",
"None",
",",
"nprocs",
"=",
... | r"""
Interfaces to either multiprocessing or futures.
Esentially maps ``args_gen`` onto ``func`` using pool.imap.
However, args_gen must be a tuple of args that will be unpacked and send to
the function. Thus, the function can take multiple args. Also specifing
keyword args is supported.
Useful... | [
"r",
"Interfaces",
"to",
"either",
"multiprocessing",
"or",
"futures",
".",
"Esentially",
"maps",
"args_gen",
"onto",
"func",
"using",
"pool",
".",
"imap",
".",
"However",
"args_gen",
"must",
"be",
"a",
"tuple",
"of",
"args",
"that",
"will",
"be",
"unpacked"... | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_parallel.py#L51-L279 | train |
Erotemic/utool | utool/util_parallel.py | _generate_serial2 | def _generate_serial2(func, args_gen, kw_gen=None, ntasks=None, progkw={},
verbose=None, nTasks=None):
""" internal serial generator """
if verbose is None:
verbose = 2
if ntasks is None:
ntasks = nTasks
if ntasks is None:
ntasks = len(args_gen)
if verb... | python | def _generate_serial2(func, args_gen, kw_gen=None, ntasks=None, progkw={},
verbose=None, nTasks=None):
""" internal serial generator """
if verbose is None:
verbose = 2
if ntasks is None:
ntasks = nTasks
if ntasks is None:
ntasks = len(args_gen)
if verb... | [
"def",
"_generate_serial2",
"(",
"func",
",",
"args_gen",
",",
"kw_gen",
"=",
"None",
",",
"ntasks",
"=",
"None",
",",
"progkw",
"=",
"{",
"}",
",",
"verbose",
"=",
"None",
",",
"nTasks",
"=",
"None",
")",
":",
"if",
"verbose",
"is",
"None",
":",
"... | internal serial generator | [
"internal",
"serial",
"generator"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_parallel.py#L287-L316 | train |
Erotemic/utool | utool/util_parallel.py | buffered_generator | def buffered_generator(source_gen, buffer_size=2, use_multiprocessing=False):
r"""
Generator that runs a slow source generator in a separate process.
My generate function still seems faster on test cases.
However, this function is more flexible in its compatability.
Args:
source_gen (itera... | python | def buffered_generator(source_gen, buffer_size=2, use_multiprocessing=False):
r"""
Generator that runs a slow source generator in a separate process.
My generate function still seems faster on test cases.
However, this function is more flexible in its compatability.
Args:
source_gen (itera... | [
"def",
"buffered_generator",
"(",
"source_gen",
",",
"buffer_size",
"=",
"2",
",",
"use_multiprocessing",
"=",
"False",
")",
":",
"r",
"if",
"buffer_size",
"<",
"2",
":",
"raise",
"RuntimeError",
"(",
"\"Minimal buffer_ size is 2!\"",
")",
"if",
"use_multiprocessi... | r"""
Generator that runs a slow source generator in a separate process.
My generate function still seems faster on test cases.
However, this function is more flexible in its compatability.
Args:
source_gen (iterable): slow generator
buffer_size (int): the maximal number of items to pre... | [
"r",
"Generator",
"that",
"runs",
"a",
"slow",
"source",
"generator",
"in",
"a",
"separate",
"process",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_parallel.py#L669-L769 | train |
Erotemic/utool | utool/util_ubuntu.py | XCtrl.sort_window_ids | def sort_window_ids(winid_list, order='mru'):
"""
Orders window ids by most recently used
"""
import utool as ut
winid_order = XCtrl.sorted_window_ids(order)
sorted_win_ids = ut.isect(winid_order, winid_list)
return sorted_win_ids | python | def sort_window_ids(winid_list, order='mru'):
"""
Orders window ids by most recently used
"""
import utool as ut
winid_order = XCtrl.sorted_window_ids(order)
sorted_win_ids = ut.isect(winid_order, winid_list)
return sorted_win_ids | [
"def",
"sort_window_ids",
"(",
"winid_list",
",",
"order",
"=",
"'mru'",
")",
":",
"import",
"utool",
"as",
"ut",
"winid_order",
"=",
"XCtrl",
".",
"sorted_window_ids",
"(",
"order",
")",
"sorted_win_ids",
"=",
"ut",
".",
"isect",
"(",
"winid_order",
",",
... | Orders window ids by most recently used | [
"Orders",
"window",
"ids",
"by",
"most",
"recently",
"used"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L384-L391 | train |
Erotemic/utool | utool/util_ubuntu.py | XCtrl.focus_window | def focus_window(winhandle, path=None, name=None, sleeptime=.01):
"""
sudo apt-get install xautomation
apt-get install autokey-gtk
wmctrl -xa gnome-terminal.Gnome-terminal
wmctrl -xl
"""
import utool as ut
import time
print('focus: ' + winhandle)
... | python | def focus_window(winhandle, path=None, name=None, sleeptime=.01):
"""
sudo apt-get install xautomation
apt-get install autokey-gtk
wmctrl -xa gnome-terminal.Gnome-terminal
wmctrl -xl
"""
import utool as ut
import time
print('focus: ' + winhandle)
... | [
"def",
"focus_window",
"(",
"winhandle",
",",
"path",
"=",
"None",
",",
"name",
"=",
"None",
",",
"sleeptime",
"=",
".01",
")",
":",
"import",
"utool",
"as",
"ut",
"import",
"time",
"print",
"(",
"'focus: '",
"+",
"winhandle",
")",
"args",
"=",
"[",
... | sudo apt-get install xautomation
apt-get install autokey-gtk
wmctrl -xa gnome-terminal.Gnome-terminal
wmctrl -xl | [
"sudo",
"apt",
"-",
"get",
"install",
"xautomation",
"apt",
"-",
"get",
"install",
"autokey",
"-",
"gtk"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L668-L681 | train |
Erotemic/utool | utool/util_setup.py | setup_chmod | def setup_chmod(setup_fpath, setup_dir, chmod_patterns):
""" Gives files matching pattern the same chmod flags as setup.py """
#st_mode = os.stat(setup_fpath).st_mode
st_mode = 33277
for pattern in chmod_patterns:
for fpath in util_path.glob(setup_dir, pattern, recursive=True):
print... | python | def setup_chmod(setup_fpath, setup_dir, chmod_patterns):
""" Gives files matching pattern the same chmod flags as setup.py """
#st_mode = os.stat(setup_fpath).st_mode
st_mode = 33277
for pattern in chmod_patterns:
for fpath in util_path.glob(setup_dir, pattern, recursive=True):
print... | [
"def",
"setup_chmod",
"(",
"setup_fpath",
",",
"setup_dir",
",",
"chmod_patterns",
")",
":",
"st_mode",
"=",
"33277",
"for",
"pattern",
"in",
"chmod_patterns",
":",
"for",
"fpath",
"in",
"util_path",
".",
"glob",
"(",
"setup_dir",
",",
"pattern",
",",
"recur... | Gives files matching pattern the same chmod flags as setup.py | [
"Gives",
"files",
"matching",
"pattern",
"the",
"same",
"chmod",
"flags",
"as",
"setup",
".",
"py"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L103-L110 | train |
Erotemic/utool | utool/util_setup.py | __infer_setup_kwargs | def __infer_setup_kwargs(module, kwargs):
""" Implicitly build kwargs based on standard info """
# Get project name from the module
#if 'name' not in kwargs:
# kwargs['name'] = module.__name__
#else:
# raise AssertionError('must specify module name!')
name = kwargs['name']
# Our pr... | python | def __infer_setup_kwargs(module, kwargs):
""" Implicitly build kwargs based on standard info """
# Get project name from the module
#if 'name' not in kwargs:
# kwargs['name'] = module.__name__
#else:
# raise AssertionError('must specify module name!')
name = kwargs['name']
# Our pr... | [
"def",
"__infer_setup_kwargs",
"(",
"module",
",",
"kwargs",
")",
":",
"name",
"=",
"kwargs",
"[",
"'name'",
"]",
"packages",
"=",
"kwargs",
".",
"get",
"(",
"'packages'",
",",
"[",
"]",
")",
"if",
"name",
"not",
"in",
"packages",
":",
"packages",
".",... | Implicitly build kwargs based on standard info | [
"Implicitly",
"build",
"kwargs",
"based",
"on",
"standard",
"info"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L605-L643 | train |
Thermondo/django-heroku-connect | heroku_connect/admin.py | _replaced | def _replaced(__values, **__replacements):
"""
Replace elements in iterable with values from an alias dict, suppressing empty values.
Used to consistently enhance how certain fields are displayed in list and detail pages.
"""
return tuple(o for o in (__replacements.get(name, name) for name in __val... | python | def _replaced(__values, **__replacements):
"""
Replace elements in iterable with values from an alias dict, suppressing empty values.
Used to consistently enhance how certain fields are displayed in list and detail pages.
"""
return tuple(o for o in (__replacements.get(name, name) for name in __val... | [
"def",
"_replaced",
"(",
"__values",
",",
"**",
"__replacements",
")",
":",
"return",
"tuple",
"(",
"o",
"for",
"o",
"in",
"(",
"__replacements",
".",
"get",
"(",
"name",
",",
"name",
")",
"for",
"name",
"in",
"__values",
")",
"if",
"o",
")"
] | Replace elements in iterable with values from an alias dict, suppressing empty values.
Used to consistently enhance how certain fields are displayed in list and detail pages. | [
"Replace",
"elements",
"in",
"iterable",
"with",
"values",
"from",
"an",
"alias",
"dict",
"suppressing",
"empty",
"values",
"."
] | f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5 | https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L14-L20 | train |
Thermondo/django-heroku-connect | heroku_connect/admin.py | _get_admin_route_name | def _get_admin_route_name(model_or_instance):
"""
Get the base name of the admin route for a model or model instance.
For use with :func:`django.urls.reverse`, although it still needs the specific route suffix
appended, for example ``_changelist``.
"""
model = model_or_instance if isinstance(mo... | python | def _get_admin_route_name(model_or_instance):
"""
Get the base name of the admin route for a model or model instance.
For use with :func:`django.urls.reverse`, although it still needs the specific route suffix
appended, for example ``_changelist``.
"""
model = model_or_instance if isinstance(mo... | [
"def",
"_get_admin_route_name",
"(",
"model_or_instance",
")",
":",
"model",
"=",
"model_or_instance",
"if",
"isinstance",
"(",
"model_or_instance",
",",
"type",
")",
"else",
"type",
"(",
"model_or_instance",
")",
"return",
"'admin:{meta.app_label}_{meta.model_name}'",
... | Get the base name of the admin route for a model or model instance.
For use with :func:`django.urls.reverse`, although it still needs the specific route suffix
appended, for example ``_changelist``. | [
"Get",
"the",
"base",
"name",
"of",
"the",
"admin",
"route",
"for",
"a",
"model",
"or",
"model",
"instance",
"."
] | f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5 | https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L23-L31 | train |
Thermondo/django-heroku-connect | heroku_connect/admin.py | _build_admin_filter_url | def _build_admin_filter_url(model, filters):
"""Build a filter URL to an admin changelist of all objects with similar field values."""
url = reverse(_get_admin_route_name(model) + '_changelist')
parts = urlsplit(url)
query = parse_qs(parts.query)
query.update(filters)
parts_with_filter = parts._... | python | def _build_admin_filter_url(model, filters):
"""Build a filter URL to an admin changelist of all objects with similar field values."""
url = reverse(_get_admin_route_name(model) + '_changelist')
parts = urlsplit(url)
query = parse_qs(parts.query)
query.update(filters)
parts_with_filter = parts._... | [
"def",
"_build_admin_filter_url",
"(",
"model",
",",
"filters",
")",
":",
"url",
"=",
"reverse",
"(",
"_get_admin_route_name",
"(",
"model",
")",
"+",
"'_changelist'",
")",
"parts",
"=",
"urlsplit",
"(",
"url",
")",
"query",
"=",
"parse_qs",
"(",
"parts",
... | Build a filter URL to an admin changelist of all objects with similar field values. | [
"Build",
"a",
"filter",
"URL",
"to",
"an",
"admin",
"changelist",
"of",
"all",
"objects",
"with",
"similar",
"field",
"values",
"."
] | f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5 | https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L34-L41 | train |
Thermondo/django-heroku-connect | heroku_connect/admin.py | _make_admin_link_to_similar | def _make_admin_link_to_similar(primary_field, *fields, name=None):
"""Create a function that links to a changelist of all objects with similar field values."""
fields = (primary_field,) + fields
url_template = '<a href="{url}">{name_or_value}</a>'
def field_link(self, obj):
value = getattr(obj... | python | def _make_admin_link_to_similar(primary_field, *fields, name=None):
"""Create a function that links to a changelist of all objects with similar field values."""
fields = (primary_field,) + fields
url_template = '<a href="{url}">{name_or_value}</a>'
def field_link(self, obj):
value = getattr(obj... | [
"def",
"_make_admin_link_to_similar",
"(",
"primary_field",
",",
"*",
"fields",
",",
"name",
"=",
"None",
")",
":",
"fields",
"=",
"(",
"primary_field",
",",
")",
"+",
"fields",
"url_template",
"=",
"'<a href=\"{url}\">{name_or_value}</a>'",
"def",
"field_link",
"... | Create a function that links to a changelist of all objects with similar field values. | [
"Create",
"a",
"function",
"that",
"links",
"to",
"a",
"changelist",
"of",
"all",
"objects",
"with",
"similar",
"field",
"values",
"."
] | f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5 | https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L44-L60 | train |
Thermondo/django-heroku-connect | heroku_connect/admin.py | _retry_failed_log | def _retry_failed_log(failed_trigger_log):
"""
Try to re-apply a failed trigger log action.
Makes sure the argument trigger log is in a FAILED state and acquires a row lock on it.
Returns:
True if the operation succeeded
"""
model = type(failed_trigger_log)
try:
failed_t... | python | def _retry_failed_log(failed_trigger_log):
"""
Try to re-apply a failed trigger log action.
Makes sure the argument trigger log is in a FAILED state and acquires a row lock on it.
Returns:
True if the operation succeeded
"""
model = type(failed_trigger_log)
try:
failed_t... | [
"def",
"_retry_failed_log",
"(",
"failed_trigger_log",
")",
":",
"model",
"=",
"type",
"(",
"failed_trigger_log",
")",
"try",
":",
"failed_trigger_log",
"=",
"(",
"model",
".",
"objects",
".",
"select_for_update",
"(",
")",
".",
"get",
"(",
"id",
"=",
"faile... | Try to re-apply a failed trigger log action.
Makes sure the argument trigger log is in a FAILED state and acquires a row lock on it.
Returns:
True if the operation succeeded | [
"Try",
"to",
"re",
"-",
"apply",
"a",
"failed",
"trigger",
"log",
"action",
"."
] | f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5 | https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L69-L92 | train |
Thermondo/django-heroku-connect | heroku_connect/admin.py | TriggerLogAdmin.ignore_failed_logs_action | def ignore_failed_logs_action(self, request, queryset):
"""Set FAILED trigger logs in queryset to IGNORED."""
count = _ignore_failed_logs(queryset)
self.message_user(
request,
_('{count} failed trigger logs marked as ignored.').format(count=count),
) | python | def ignore_failed_logs_action(self, request, queryset):
"""Set FAILED trigger logs in queryset to IGNORED."""
count = _ignore_failed_logs(queryset)
self.message_user(
request,
_('{count} failed trigger logs marked as ignored.').format(count=count),
) | [
"def",
"ignore_failed_logs_action",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"count",
"=",
"_ignore_failed_logs",
"(",
"queryset",
")",
"self",
".",
"message_user",
"(",
"request",
",",
"_",
"(",
"'{count} failed trigger logs marked as ignored.'",
")"... | Set FAILED trigger logs in queryset to IGNORED. | [
"Set",
"FAILED",
"trigger",
"logs",
"in",
"queryset",
"to",
"IGNORED",
"."
] | f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5 | https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L156-L162 | train |
Thermondo/django-heroku-connect | heroku_connect/admin.py | TriggerLogAdmin.retry_failed_logs_action | def retry_failed_logs_action(self, request, queryset):
"""Try to re-apply FAILED trigger log actions in the queryset."""
count = 0
for trigger_log in queryset:
retried = _retry_failed_log(trigger_log)
if retried:
count += 1
self.message_user(
... | python | def retry_failed_logs_action(self, request, queryset):
"""Try to re-apply FAILED trigger log actions in the queryset."""
count = 0
for trigger_log in queryset:
retried = _retry_failed_log(trigger_log)
if retried:
count += 1
self.message_user(
... | [
"def",
"retry_failed_logs_action",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"count",
"=",
"0",
"for",
"trigger_log",
"in",
"queryset",
":",
"retried",
"=",
"_retry_failed_log",
"(",
"trigger_log",
")",
"if",
"retried",
":",
"count",
"+=",
"1",... | Try to re-apply FAILED trigger log actions in the queryset. | [
"Try",
"to",
"re",
"-",
"apply",
"FAILED",
"trigger",
"log",
"actions",
"in",
"the",
"queryset",
"."
] | f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5 | https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L165-L175 | train |
glormph/msstitch | src/app/actions/mslookup/psms.py | create_psm_lookup | def create_psm_lookup(fn, fastafn, mapfn, header, pgdb, unroll=False,
specfncol=None, decoy=False,
fastadelim=None, genefield=None):
"""Reads PSMs from file, stores them to a database backend in chunked PSMs.
"""
proteins = store_proteins_descriptions(pgdb, fastaf... | python | def create_psm_lookup(fn, fastafn, mapfn, header, pgdb, unroll=False,
specfncol=None, decoy=False,
fastadelim=None, genefield=None):
"""Reads PSMs from file, stores them to a database backend in chunked PSMs.
"""
proteins = store_proteins_descriptions(pgdb, fastaf... | [
"def",
"create_psm_lookup",
"(",
"fn",
",",
"fastafn",
",",
"mapfn",
",",
"header",
",",
"pgdb",
",",
"unroll",
"=",
"False",
",",
"specfncol",
"=",
"None",
",",
"decoy",
"=",
"False",
",",
"fastadelim",
"=",
"None",
",",
"genefield",
"=",
"None",
")",... | Reads PSMs from file, stores them to a database backend in chunked PSMs. | [
"Reads",
"PSMs",
"from",
"file",
"stores",
"them",
"to",
"a",
"database",
"backend",
"in",
"chunked",
"PSMs",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/psms.py#L9-L40 | train |
glormph/msstitch | src/app/actions/mslookup/psms.py | store_psm_protein_relations | def store_psm_protein_relations(fn, header, pgdb, proteins):
"""Reads PSMs from file, extracts their proteins and peptides and passes
them to a database backend in chunks.
"""
# TODO do we need an OrderedDict or is regular dict enough?
# Sorting for psm_id useful?
allpsms = OrderedDict()
las... | python | def store_psm_protein_relations(fn, header, pgdb, proteins):
"""Reads PSMs from file, extracts their proteins and peptides and passes
them to a database backend in chunks.
"""
# TODO do we need an OrderedDict or is regular dict enough?
# Sorting for psm_id useful?
allpsms = OrderedDict()
las... | [
"def",
"store_psm_protein_relations",
"(",
"fn",
",",
"header",
",",
"pgdb",
",",
"proteins",
")",
":",
"allpsms",
"=",
"OrderedDict",
"(",
")",
"last_id",
",",
"psmids_to_store",
"=",
"None",
",",
"set",
"(",
")",
"store_soon",
"=",
"False",
"for",
"psm",... | Reads PSMs from file, extracts their proteins and peptides and passes
them to a database backend in chunks. | [
"Reads",
"PSMs",
"from",
"file",
"extracts",
"their",
"proteins",
"and",
"peptides",
"and",
"passes",
"them",
"to",
"a",
"database",
"backend",
"in",
"chunks",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/psms.py#L92-L120 | train |
Erotemic/utool | utool/util_decor.py | on_exception_report_input | def on_exception_report_input(func_=None, force=False, keys=None):
"""
If an error is thrown in the scope of this function's stack frame then the
decorated function name and the arguments passed to it will be printed to
the utool print function.
"""
def _closure_onexceptreport(func):
if ... | python | def on_exception_report_input(func_=None, force=False, keys=None):
"""
If an error is thrown in the scope of this function's stack frame then the
decorated function name and the arguments passed to it will be printed to
the utool print function.
"""
def _closure_onexceptreport(func):
if ... | [
"def",
"on_exception_report_input",
"(",
"func_",
"=",
"None",
",",
"force",
"=",
"False",
",",
"keys",
"=",
"None",
")",
":",
"def",
"_closure_onexceptreport",
"(",
"func",
")",
":",
"if",
"not",
"ONEX_REPORT_INPUT",
"and",
"not",
"force",
":",
"return",
... | If an error is thrown in the scope of this function's stack frame then the
decorated function name and the arguments passed to it will be printed to
the utool print function. | [
"If",
"an",
"error",
"is",
"thrown",
"in",
"the",
"scope",
"of",
"this",
"function",
"s",
"stack",
"frame",
"then",
"the",
"decorated",
"function",
"name",
"and",
"the",
"arguments",
"passed",
"to",
"it",
"will",
"be",
"printed",
"to",
"the",
"utool",
"p... | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L211-L270 | train |
Erotemic/utool | utool/util_decor.py | _indent_decor | def _indent_decor(lbl):
"""
does the actual work of indent_func
"""
def closure_indent(func):
if util_arg.TRACE:
@ignores_exc_tb(outer_wrapper=False)
#@wraps(func)
def wrp_indent(*args, **kwargs):
with util_print.Indenter(lbl):
... | python | def _indent_decor(lbl):
"""
does the actual work of indent_func
"""
def closure_indent(func):
if util_arg.TRACE:
@ignores_exc_tb(outer_wrapper=False)
#@wraps(func)
def wrp_indent(*args, **kwargs):
with util_print.Indenter(lbl):
... | [
"def",
"_indent_decor",
"(",
"lbl",
")",
":",
"def",
"closure_indent",
"(",
"func",
")",
":",
"if",
"util_arg",
".",
"TRACE",
":",
"@",
"ignores_exc_tb",
"(",
"outer_wrapper",
"=",
"False",
")",
"def",
"wrp_indent",
"(",
"*",
"args",
",",
"**",
"kwargs",... | does the actual work of indent_func | [
"does",
"the",
"actual",
"work",
"of",
"indent_func"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L305-L329 | train |
Erotemic/utool | utool/util_decor.py | indent_func | def indent_func(input_):
"""
Takes either no arguments or an alias label
"""
if isinstance(input_, six.string_types):
# A label was specified
lbl = input_
return _indent_decor(lbl)
elif isinstance(input_, (bool, tuple)):
# Allow individually turning of of this decorat... | python | def indent_func(input_):
"""
Takes either no arguments or an alias label
"""
if isinstance(input_, six.string_types):
# A label was specified
lbl = input_
return _indent_decor(lbl)
elif isinstance(input_, (bool, tuple)):
# Allow individually turning of of this decorat... | [
"def",
"indent_func",
"(",
"input_",
")",
":",
"if",
"isinstance",
"(",
"input_",
",",
"six",
".",
"string_types",
")",
":",
"lbl",
"=",
"input_",
"return",
"_indent_decor",
"(",
"lbl",
")",
"elif",
"isinstance",
"(",
"input_",
",",
"(",
"bool",
",",
"... | Takes either no arguments or an alias label | [
"Takes",
"either",
"no",
"arguments",
"or",
"an",
"alias",
"label"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L332-L348 | train |
Erotemic/utool | utool/util_decor.py | tracefunc_xml | def tracefunc_xml(func):
"""
Causes output of function to be printed in an XML style block
"""
funcname = meta_util_six.get_funcname(func)
def wrp_tracefunc2(*args, **kwargs):
verbose = kwargs.get('verbose', True)
if verbose:
print('<%s>' % (funcname,))
with util_... | python | def tracefunc_xml(func):
"""
Causes output of function to be printed in an XML style block
"""
funcname = meta_util_six.get_funcname(func)
def wrp_tracefunc2(*args, **kwargs):
verbose = kwargs.get('verbose', True)
if verbose:
print('<%s>' % (funcname,))
with util_... | [
"def",
"tracefunc_xml",
"(",
"func",
")",
":",
"funcname",
"=",
"meta_util_six",
".",
"get_funcname",
"(",
"func",
")",
"def",
"wrp_tracefunc2",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"verbose",
"=",
"kwargs",
".",
"get",
"(",
"'verbose'",
",",... | Causes output of function to be printed in an XML style block | [
"Causes",
"output",
"of",
"function",
"to",
"be",
"printed",
"in",
"an",
"XML",
"style",
"block"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L351-L367 | train |
Erotemic/utool | utool/util_decor.py | accepts_scalar_input | def accepts_scalar_input(func):
"""
DEPRICATE in favor of accepts_scalar_input2
only accepts one input as vector
accepts_scalar_input is a decorator which expects to be used on class
methods. It lets the user pass either a vector or a scalar to a function,
as long as the function treats everyt... | python | def accepts_scalar_input(func):
"""
DEPRICATE in favor of accepts_scalar_input2
only accepts one input as vector
accepts_scalar_input is a decorator which expects to be used on class
methods. It lets the user pass either a vector or a scalar to a function,
as long as the function treats everyt... | [
"def",
"accepts_scalar_input",
"(",
"func",
")",
":",
"@",
"ignores_exc_tb",
"(",
"outer_wrapper",
"=",
"False",
")",
"def",
"wrp_asi",
"(",
"self",
",",
"input_",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"util_iter",
".",
"isiterable",
"("... | DEPRICATE in favor of accepts_scalar_input2
only accepts one input as vector
accepts_scalar_input is a decorator which expects to be used on class
methods. It lets the user pass either a vector or a scalar to a function,
as long as the function treats everything like a vector. Input and output
is ... | [
"DEPRICATE",
"in",
"favor",
"of",
"accepts_scalar_input2",
"only",
"accepts",
"one",
"input",
"as",
"vector"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L372-L418 | train |
Erotemic/utool | utool/util_decor.py | __assert_param_consistency | def __assert_param_consistency(args, argx_list_):
"""
debugging function for accepts_scalar_input2
checks to make sure all the iterable inputs are of the same length
"""
if util_arg.NO_ASSERTS:
return
if len(argx_list_) == 0:
return True
argx_flags = [util_iter.isiterable(arg... | python | def __assert_param_consistency(args, argx_list_):
"""
debugging function for accepts_scalar_input2
checks to make sure all the iterable inputs are of the same length
"""
if util_arg.NO_ASSERTS:
return
if len(argx_list_) == 0:
return True
argx_flags = [util_iter.isiterable(arg... | [
"def",
"__assert_param_consistency",
"(",
"args",
",",
"argx_list_",
")",
":",
"if",
"util_arg",
".",
"NO_ASSERTS",
":",
"return",
"if",
"len",
"(",
"argx_list_",
")",
"==",
"0",
":",
"return",
"True",
"argx_flags",
"=",
"[",
"util_iter",
".",
"isiterable",
... | debugging function for accepts_scalar_input2
checks to make sure all the iterable inputs are of the same length | [
"debugging",
"function",
"for",
"accepts_scalar_input2",
"checks",
"to",
"make",
"sure",
"all",
"the",
"iterable",
"inputs",
"are",
"of",
"the",
"same",
"length"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L463-L480 | train |
Erotemic/utool | utool/util_decor.py | accepts_scalar_input_vector_output | def accepts_scalar_input_vector_output(func):
"""
DEPRICATE IN FAVOR OF accepts_scalar_input2
accepts_scalar_input_vector_output
Notes:
Input: Excpeted Output 1to1 Expected Output 1toM
scalar : 1 x [X]
n... | python | def accepts_scalar_input_vector_output(func):
"""
DEPRICATE IN FAVOR OF accepts_scalar_input2
accepts_scalar_input_vector_output
Notes:
Input: Excpeted Output 1to1 Expected Output 1toM
scalar : 1 x [X]
n... | [
"def",
"accepts_scalar_input_vector_output",
"(",
"func",
")",
":",
"@",
"ignores_exc_tb",
"(",
"outer_wrapper",
"=",
"False",
")",
"def",
"wrp_asivo",
"(",
"self",
",",
"input_",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"util_iter",
".",
"is... | DEPRICATE IN FAVOR OF accepts_scalar_input2
accepts_scalar_input_vector_output
Notes:
Input: Excpeted Output 1to1 Expected Output 1toM
scalar : 1 x [X]
n element list : [1, 2, 3] [x, y, z] [[X], [... | [
"DEPRICATE",
"IN",
"FAVOR",
"OF",
"accepts_scalar_input2"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L483-L521 | train |
Erotemic/utool | utool/util_decor.py | accepts_numpy | def accepts_numpy(func):
""" Allows the first input to be a numpy array and get result in numpy form """
#@ignores_exc_tb
#@wraps(func)
def wrp_accepts_numpy(self, input_, *args, **kwargs):
if not (util_type.HAVE_NUMPY and isinstance(input_, np.ndarray)):
# If the input is not numpy,... | python | def accepts_numpy(func):
""" Allows the first input to be a numpy array and get result in numpy form """
#@ignores_exc_tb
#@wraps(func)
def wrp_accepts_numpy(self, input_, *args, **kwargs):
if not (util_type.HAVE_NUMPY and isinstance(input_, np.ndarray)):
# If the input is not numpy,... | [
"def",
"accepts_numpy",
"(",
"func",
")",
":",
"def",
"wrp_accepts_numpy",
"(",
"self",
",",
"input_",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"(",
"util_type",
".",
"HAVE_NUMPY",
"and",
"isinstance",
"(",
"input_",
",",
"np",
"."... | Allows the first input to be a numpy array and get result in numpy form | [
"Allows",
"the",
"first",
"input",
"to",
"be",
"a",
"numpy",
"array",
"and",
"get",
"result",
"in",
"numpy",
"form"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L529-L559 | train |
Erotemic/utool | utool/util_decor.py | memoize_nonzero | def memoize_nonzero(func):
"""
Memoization decorator for functions taking a nonzero number of arguments.
References:
http://code.activestate.com/recipes/578231-fastest-memoization-decorator
"""
class _memorizer(dict):
def __init__(self, func):
self.func = func
de... | python | def memoize_nonzero(func):
"""
Memoization decorator for functions taking a nonzero number of arguments.
References:
http://code.activestate.com/recipes/578231-fastest-memoization-decorator
"""
class _memorizer(dict):
def __init__(self, func):
self.func = func
de... | [
"def",
"memoize_nonzero",
"(",
"func",
")",
":",
"class",
"_memorizer",
"(",
"dict",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"func",
")",
":",
"self",
".",
"func",
"=",
"func",
"def",
"__call__",
"(",
"self",
",",
"*",
"args",
")",
":",
"ret... | Memoization decorator for functions taking a nonzero number of arguments.
References:
http://code.activestate.com/recipes/578231-fastest-memoization-decorator | [
"Memoization",
"decorator",
"for",
"functions",
"taking",
"a",
"nonzero",
"number",
"of",
"arguments",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L562-L577 | train |
Erotemic/utool | utool/util_decor.py | memoize | def memoize(func):
"""
simple memoization decorator
References:
https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize
Args:
func (function): live python function
Returns:
func:
CommandLine:
python -m utool.util_decor memoize
Example:
>>> # ... | python | def memoize(func):
"""
simple memoization decorator
References:
https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize
Args:
func (function): live python function
Returns:
func:
CommandLine:
python -m utool.util_decor memoize
Example:
>>> # ... | [
"def",
"memoize",
"(",
"func",
")",
":",
"cache",
"=",
"func",
".",
"_util_decor_memoize_cache",
"=",
"{",
"}",
"def",
"memoizer",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"key",
"=",
"str",
"(",
"args",
")",
"+",
"str",
"(",
"kwargs",
")",... | simple memoization decorator
References:
https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize
Args:
func (function): live python function
Returns:
func:
CommandLine:
python -m utool.util_decor memoize
Example:
>>> # ENABLE_DOCTEST
>>> from... | [
"simple",
"memoization",
"decorator"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L601-L651 | train |
Erotemic/utool | utool/util_decor.py | lazyfunc | def lazyfunc(func):
"""
Returns a memcached version of a function
"""
closuremem_ = [{}]
def wrapper(*args, **kwargs):
mem = closuremem_[0]
key = (repr(args), repr(kwargs))
try:
return mem[key]
except KeyError:
mem[key] = func(*args, **kwargs)
... | python | def lazyfunc(func):
"""
Returns a memcached version of a function
"""
closuremem_ = [{}]
def wrapper(*args, **kwargs):
mem = closuremem_[0]
key = (repr(args), repr(kwargs))
try:
return mem[key]
except KeyError:
mem[key] = func(*args, **kwargs)
... | [
"def",
"lazyfunc",
"(",
"func",
")",
":",
"closuremem_",
"=",
"[",
"{",
"}",
"]",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"mem",
"=",
"closuremem_",
"[",
"0",
"]",
"key",
"=",
"(",
"repr",
"(",
"args",
")",
",",
"repr... | Returns a memcached version of a function | [
"Returns",
"a",
"memcached",
"version",
"of",
"a",
"function"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L752-L765 | train |
Erotemic/utool | utool/util_decor.py | apply_docstr | def apply_docstr(docstr_func):
"""
Changes docstr of one functio to that of another
"""
def docstr_applier(func):
#docstr = meta_util_six.get_funcdoc(docstr_func)
#meta_util_six.set_funcdoc(func, docstr)
if isinstance(docstr_func, six.string_types):
olddoc = meta_util... | python | def apply_docstr(docstr_func):
"""
Changes docstr of one functio to that of another
"""
def docstr_applier(func):
#docstr = meta_util_six.get_funcdoc(docstr_func)
#meta_util_six.set_funcdoc(func, docstr)
if isinstance(docstr_func, six.string_types):
olddoc = meta_util... | [
"def",
"apply_docstr",
"(",
"docstr_func",
")",
":",
"def",
"docstr_applier",
"(",
"func",
")",
":",
"if",
"isinstance",
"(",
"docstr_func",
",",
"six",
".",
"string_types",
")",
":",
"olddoc",
"=",
"meta_util_six",
".",
"get_funcdoc",
"(",
"func",
")",
"i... | Changes docstr of one functio to that of another | [
"Changes",
"docstr",
"of",
"one",
"functio",
"to",
"that",
"of",
"another"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L768-L785 | train |
Erotemic/utool | utool/util_decor.py | preserve_sig | def preserve_sig(wrapper, orig_func, force=False):
"""
Decorates a wrapper function.
It seems impossible to presever signatures in python 2 without eval
(Maybe another option is to write to a temporary module?)
Args:
wrapper: the function wrapping orig_func to change the signature of
... | python | def preserve_sig(wrapper, orig_func, force=False):
"""
Decorates a wrapper function.
It seems impossible to presever signatures in python 2 without eval
(Maybe another option is to write to a temporary module?)
Args:
wrapper: the function wrapping orig_func to change the signature of
... | [
"def",
"preserve_sig",
"(",
"wrapper",
",",
"orig_func",
",",
"force",
"=",
"False",
")",
":",
"from",
"utool",
".",
"_internal",
"import",
"meta_util_six",
"from",
"utool",
"import",
"util_str",
"from",
"utool",
"import",
"util_inspect",
"if",
"wrapper",
"is"... | Decorates a wrapper function.
It seems impossible to presever signatures in python 2 without eval
(Maybe another option is to write to a temporary module?)
Args:
wrapper: the function wrapping orig_func to change the signature of
orig_func: the original function to take the signature from
... | [
"Decorates",
"a",
"wrapper",
"function",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L788-L935 | train |
kurtbrose/faststat | faststat/faststat.py | _sigfigs | def _sigfigs(n, sigfigs=3):
'helper function to round a number to significant figures'
n = float(n)
if n == 0 or math.isnan(n): # avoid math domain errors
return n
return round(n, -int(math.floor(math.log10(abs(n))) - sigfigs + 1)) | python | def _sigfigs(n, sigfigs=3):
'helper function to round a number to significant figures'
n = float(n)
if n == 0 or math.isnan(n): # avoid math domain errors
return n
return round(n, -int(math.floor(math.log10(abs(n))) - sigfigs + 1)) | [
"def",
"_sigfigs",
"(",
"n",
",",
"sigfigs",
"=",
"3",
")",
":",
"'helper function to round a number to significant figures'",
"n",
"=",
"float",
"(",
"n",
")",
"if",
"n",
"==",
"0",
"or",
"math",
".",
"isnan",
"(",
"n",
")",
":",
"return",
"n",
"return"... | helper function to round a number to significant figures | [
"helper",
"function",
"to",
"round",
"a",
"number",
"to",
"significant",
"figures"
] | 5060c0e10acaafd4a48de3f16869bfccc1deb44a | https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L408-L413 | train |
kurtbrose/faststat | faststat/faststat.py | merge_moments | def merge_moments(m_a, m_a2, m_a3, m_a4, n_a, m_b, m_b2, m_b3, m_b4, n_b):
'''
Merge moments of two samples A and B.
parameters are
m_a, ..., m_a4 = first through fourth moment of sample A
n_a = size of sample A
m_b, ..., m_b4 = first through fourth moment of sample B
n_b = size of s... | python | def merge_moments(m_a, m_a2, m_a3, m_a4, n_a, m_b, m_b2, m_b3, m_b4, n_b):
'''
Merge moments of two samples A and B.
parameters are
m_a, ..., m_a4 = first through fourth moment of sample A
n_a = size of sample A
m_b, ..., m_b4 = first through fourth moment of sample B
n_b = size of s... | [
"def",
"merge_moments",
"(",
"m_a",
",",
"m_a2",
",",
"m_a3",
",",
"m_a4",
",",
"n_a",
",",
"m_b",
",",
"m_b2",
",",
"m_b3",
",",
"m_b4",
",",
"n_b",
")",
":",
"delta",
"=",
"m_b",
"-",
"m_a",
"delta_2",
"=",
"delta",
"*",
"delta",
"delta_3",
"="... | Merge moments of two samples A and B.
parameters are
m_a, ..., m_a4 = first through fourth moment of sample A
n_a = size of sample A
m_b, ..., m_b4 = first through fourth moment of sample B
n_b = size of sample B | [
"Merge",
"moments",
"of",
"two",
"samples",
"A",
"and",
"B",
".",
"parameters",
"are",
"m_a",
"...",
"m_a4",
"=",
"first",
"through",
"fourth",
"moment",
"of",
"sample",
"A",
"n_a",
"=",
"size",
"of",
"sample",
"A",
"m_b",
"...",
"m_b4",
"=",
"first",
... | 5060c0e10acaafd4a48de3f16869bfccc1deb44a | https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L416-L436 | train |
kurtbrose/faststat | faststat/faststat.py | Markov._transition | def _transition(self, nxt, cur=None, since=None):
'''
Register that a transition has taken place.
nxt is an identifier for the state being entered.
cur is an identifier for the state being left.
since is the time at which the previous state was entered.
'''
... | python | def _transition(self, nxt, cur=None, since=None):
'''
Register that a transition has taken place.
nxt is an identifier for the state being entered.
cur is an identifier for the state being left.
since is the time at which the previous state was entered.
'''
... | [
"def",
"_transition",
"(",
"self",
",",
"nxt",
",",
"cur",
"=",
"None",
",",
"since",
"=",
"None",
")",
":",
"self",
".",
"transition_intervals",
"[",
"(",
"cur",
",",
"nxt",
")",
"]",
".",
"tick",
"(",
")",
"if",
"since",
":",
"self",
".",
"stat... | Register that a transition has taken place.
nxt is an identifier for the state being entered.
cur is an identifier for the state being left.
since is the time at which the previous state was entered. | [
"Register",
"that",
"a",
"transition",
"has",
"taken",
"place",
".",
"nxt",
"is",
"an",
"identifier",
"for",
"the",
"state",
"being",
"entered",
".",
"cur",
"is",
"an",
"identifier",
"for",
"the",
"state",
"being",
"left",
".",
"since",
"is",
"the",
"tim... | 5060c0e10acaafd4a48de3f16869bfccc1deb44a | https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L235-L244 | train |
kurtbrose/faststat | faststat/faststat.py | Markov._cleanup | def _cleanup(self, ref):
'cleanup after a transitor weakref fires'
self.transitor_states[self._weakref_holder[ref]] -= 1
del self._weakref_holder[ref] | python | def _cleanup(self, ref):
'cleanup after a transitor weakref fires'
self.transitor_states[self._weakref_holder[ref]] -= 1
del self._weakref_holder[ref] | [
"def",
"_cleanup",
"(",
"self",
",",
"ref",
")",
":",
"'cleanup after a transitor weakref fires'",
"self",
".",
"transitor_states",
"[",
"self",
".",
"_weakref_holder",
"[",
"ref",
"]",
"]",
"-=",
"1",
"del",
"self",
".",
"_weakref_holder",
"[",
"ref",
"]"
] | cleanup after a transitor weakref fires | [
"cleanup",
"after",
"a",
"transitor",
"weakref",
"fires"
] | 5060c0e10acaafd4a48de3f16869bfccc1deb44a | https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L252-L255 | train |
kurtbrose/faststat | faststat/faststat.py | PathStats._commit | def _commit(self, ref):
'commit a walkers data after it is collected'
path_times = self._weakref_path_map[ref]
path_times.append(nanotime())
del self._weakref_path_map[ref]
path = tuple(path_times[1::2])
times = path_times[::2]
if path not in self.path_stat... | python | def _commit(self, ref):
'commit a walkers data after it is collected'
path_times = self._weakref_path_map[ref]
path_times.append(nanotime())
del self._weakref_path_map[ref]
path = tuple(path_times[1::2])
times = path_times[::2]
if path not in self.path_stat... | [
"def",
"_commit",
"(",
"self",
",",
"ref",
")",
":",
"'commit a walkers data after it is collected'",
"path_times",
"=",
"self",
".",
"_weakref_path_map",
"[",
"ref",
"]",
"path_times",
".",
"append",
"(",
"nanotime",
"(",
")",
")",
"del",
"self",
".",
"_weakr... | commit a walkers data after it is collected | [
"commit",
"a",
"walkers",
"data",
"after",
"it",
"is",
"collected"
] | 5060c0e10acaafd4a48de3f16869bfccc1deb44a | https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L310-L323 | train |
kurtbrose/faststat | faststat/faststat.py | PathStats.pformat | def pformat(self, prefix=()):
'''
Makes a pretty ASCII format of the data, suitable for
displaying in a console or saving to a text file.
Returns a list of lines.
'''
nan = float("nan")
def sformat(segment, stat):
FMT = "n={0}, mean={1}, p50/... | python | def pformat(self, prefix=()):
'''
Makes a pretty ASCII format of the data, suitable for
displaying in a console or saving to a text file.
Returns a list of lines.
'''
nan = float("nan")
def sformat(segment, stat):
FMT = "n={0}, mean={1}, p50/... | [
"def",
"pformat",
"(",
"self",
",",
"prefix",
"=",
"(",
")",
")",
":",
"nan",
"=",
"float",
"(",
"\"nan\"",
")",
"def",
"sformat",
"(",
"segment",
",",
"stat",
")",
":",
"FMT",
"=",
"\"n={0}, mean={1}, p50/95={2}/{3}, max={4}\"",
"line_segs",
"=",
"[",
"... | Makes a pretty ASCII format of the data, suitable for
displaying in a console or saving to a text file.
Returns a list of lines. | [
"Makes",
"a",
"pretty",
"ASCII",
"format",
"of",
"the",
"data",
"suitable",
"for",
"displaying",
"in",
"a",
"console",
"or",
"saving",
"to",
"a",
"text",
"file",
".",
"Returns",
"a",
"list",
"of",
"lines",
"."
] | 5060c0e10acaafd4a48de3f16869bfccc1deb44a | https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L325-L347 | train |
glormph/msstitch | src/app/readers/openms.py | specfn_quant_generator | def specfn_quant_generator(specfiles, quantfiles, tag, ignore_tags):
"""Generates tuples of specfile and quant element for general formats"""
for specfn, qfn in zip(specfiles, quantfiles):
for quant_el in basereader.generate_xmltags(qfn, tag, ignore_tags):
yield os.path.basename(specfn), qua... | python | def specfn_quant_generator(specfiles, quantfiles, tag, ignore_tags):
"""Generates tuples of specfile and quant element for general formats"""
for specfn, qfn in zip(specfiles, quantfiles):
for quant_el in basereader.generate_xmltags(qfn, tag, ignore_tags):
yield os.path.basename(specfn), qua... | [
"def",
"specfn_quant_generator",
"(",
"specfiles",
",",
"quantfiles",
",",
"tag",
",",
"ignore_tags",
")",
":",
"for",
"specfn",
",",
"qfn",
"in",
"zip",
"(",
"specfiles",
",",
"quantfiles",
")",
":",
"for",
"quant_el",
"in",
"basereader",
".",
"generate_xml... | Generates tuples of specfile and quant element for general formats | [
"Generates",
"tuples",
"of",
"specfile",
"and",
"quant",
"element",
"for",
"general",
"formats"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/openms.py#L5-L9 | train |
glormph/msstitch | src/app/readers/openms.py | get_feature_info | def get_feature_info(feature):
"""Returns a dict with feature information"""
dimensions = feature.findall('position')
for dim in dimensions:
if dim.attrib['dim'] == '0':
rt = dim.text
elif dim.attrib['dim'] == '1':
mz = dim.text
return {'rt': float(rt), 'mz': floa... | python | def get_feature_info(feature):
"""Returns a dict with feature information"""
dimensions = feature.findall('position')
for dim in dimensions:
if dim.attrib['dim'] == '0':
rt = dim.text
elif dim.attrib['dim'] == '1':
mz = dim.text
return {'rt': float(rt), 'mz': floa... | [
"def",
"get_feature_info",
"(",
"feature",
")",
":",
"dimensions",
"=",
"feature",
".",
"findall",
"(",
"'position'",
")",
"for",
"dim",
"in",
"dimensions",
":",
"if",
"dim",
".",
"attrib",
"[",
"'dim'",
"]",
"==",
"'0'",
":",
"rt",
"=",
"dim",
".",
... | Returns a dict with feature information | [
"Returns",
"a",
"dict",
"with",
"feature",
"information"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/openms.py#L31-L42 | train |
LEMS/pylems | lems/base/util.py | merge_maps | def merge_maps(m, base):
"""
Merge in undefined map entries from given map.
@param m: Map to be merged into.
@type m: lems.util.Map
@param base: Map to be merged into.
@type base: lems.util.Map
"""
for k in base.keys():
if k not in m:
m[k] = base[k] | python | def merge_maps(m, base):
"""
Merge in undefined map entries from given map.
@param m: Map to be merged into.
@type m: lems.util.Map
@param base: Map to be merged into.
@type base: lems.util.Map
"""
for k in base.keys():
if k not in m:
m[k] = base[k] | [
"def",
"merge_maps",
"(",
"m",
",",
"base",
")",
":",
"for",
"k",
"in",
"base",
".",
"keys",
"(",
")",
":",
"if",
"k",
"not",
"in",
"m",
":",
"m",
"[",
"k",
"]",
"=",
"base",
"[",
"k",
"]"
] | Merge in undefined map entries from given map.
@param m: Map to be merged into.
@type m: lems.util.Map
@param base: Map to be merged into.
@type base: lems.util.Map | [
"Merge",
"in",
"undefined",
"map",
"entries",
"from",
"given",
"map",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/base/util.py#L16-L29 | train |
LEMS/pylems | lems/base/util.py | merge_lists | def merge_lists(l, base):
"""
Merge in undefined list entries from given list.
@param l: List to be merged into.
@type l: list
@param base: List to be merged into.
@type base: list
"""
for i in base:
if i not in l:
l.append(i) | python | def merge_lists(l, base):
"""
Merge in undefined list entries from given list.
@param l: List to be merged into.
@type l: list
@param base: List to be merged into.
@type base: list
"""
for i in base:
if i not in l:
l.append(i) | [
"def",
"merge_lists",
"(",
"l",
",",
"base",
")",
":",
"for",
"i",
"in",
"base",
":",
"if",
"i",
"not",
"in",
"l",
":",
"l",
".",
"append",
"(",
"i",
")"
] | Merge in undefined list entries from given list.
@param l: List to be merged into.
@type l: list
@param base: List to be merged into.
@type base: list | [
"Merge",
"in",
"undefined",
"list",
"entries",
"from",
"given",
"list",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/base/util.py#L31-L44 | train |
glormph/msstitch | src/app/actions/prottable/precursorarea.py | generate_top_psms | def generate_top_psms(psms, protcol):
"""Fed with a psms generator, this returns the 3 PSMs with
the highest precursor intensities (or areas, or whatever is
given in the HEADER_PRECURSOR_QUANT"""
top_ms1_psms = {}
for psm in psms:
protacc = psm[protcol]
precursor_amount = psm[mzidtsv... | python | def generate_top_psms(psms, protcol):
"""Fed with a psms generator, this returns the 3 PSMs with
the highest precursor intensities (or areas, or whatever is
given in the HEADER_PRECURSOR_QUANT"""
top_ms1_psms = {}
for psm in psms:
protacc = psm[protcol]
precursor_amount = psm[mzidtsv... | [
"def",
"generate_top_psms",
"(",
"psms",
",",
"protcol",
")",
":",
"top_ms1_psms",
"=",
"{",
"}",
"for",
"psm",
"in",
"psms",
":",
"protacc",
"=",
"psm",
"[",
"protcol",
"]",
"precursor_amount",
"=",
"psm",
"[",
"mzidtsvdata",
".",
"HEADER_PRECURSOR_QUANT",
... | Fed with a psms generator, this returns the 3 PSMs with
the highest precursor intensities (or areas, or whatever is
given in the HEADER_PRECURSOR_QUANT | [
"Fed",
"with",
"a",
"psms",
"generator",
"this",
"returns",
"the",
"3",
"PSMs",
"with",
"the",
"highest",
"precursor",
"intensities",
"(",
"or",
"areas",
"or",
"whatever",
"is",
"given",
"in",
"the",
"HEADER_PRECURSOR_QUANT"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/precursorarea.py#L5-L27 | train |
glormph/msstitch | src/app/actions/prottable/precursorarea.py | add_ms1_quant_from_top3_mzidtsv | def add_ms1_quant_from_top3_mzidtsv(proteins, psms, headerfields, protcol):
"""Collects PSMs with the highes precursor quant values,
adds sum of the top 3 of these to a protein table"""
if not protcol:
protcol = mzidtsvdata.HEADER_MASTER_PROT
top_ms1_psms = generate_top_psms(psms, protcol)
f... | python | def add_ms1_quant_from_top3_mzidtsv(proteins, psms, headerfields, protcol):
"""Collects PSMs with the highes precursor quant values,
adds sum of the top 3 of these to a protein table"""
if not protcol:
protcol = mzidtsvdata.HEADER_MASTER_PROT
top_ms1_psms = generate_top_psms(psms, protcol)
f... | [
"def",
"add_ms1_quant_from_top3_mzidtsv",
"(",
"proteins",
",",
"psms",
",",
"headerfields",
",",
"protcol",
")",
":",
"if",
"not",
"protcol",
":",
"protcol",
"=",
"mzidtsvdata",
".",
"HEADER_MASTER_PROT",
"top_ms1_psms",
"=",
"generate_top_psms",
"(",
"psms",
","... | Collects PSMs with the highes precursor quant values,
adds sum of the top 3 of these to a protein table | [
"Collects",
"PSMs",
"with",
"the",
"highes",
"precursor",
"quant",
"values",
"adds",
"sum",
"of",
"the",
"top",
"3",
"of",
"these",
"to",
"a",
"protein",
"table"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/precursorarea.py#L40-L52 | train |
Erotemic/utool | utool/util_time.py | toc | def toc(tt, return_msg=False, write_msg=True, verbose=None):
"""
similar to matlab toc
SeeAlso:
ut.tic
"""
if verbose is not None:
write_msg = verbose
(msg, start_time) = tt
ellapsed = (default_timer() - start_time)
if (not return_msg) and write_msg and msg is not None:
... | python | def toc(tt, return_msg=False, write_msg=True, verbose=None):
"""
similar to matlab toc
SeeAlso:
ut.tic
"""
if verbose is not None:
write_msg = verbose
(msg, start_time) = tt
ellapsed = (default_timer() - start_time)
if (not return_msg) and write_msg and msg is not None:
... | [
"def",
"toc",
"(",
"tt",
",",
"return_msg",
"=",
"False",
",",
"write_msg",
"=",
"True",
",",
"verbose",
"=",
"None",
")",
":",
"if",
"verbose",
"is",
"not",
"None",
":",
"write_msg",
"=",
"verbose",
"(",
"msg",
",",
"start_time",
")",
"=",
"tt",
"... | similar to matlab toc
SeeAlso:
ut.tic | [
"similar",
"to",
"matlab",
"toc"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L42-L58 | train |
Erotemic/utool | utool/util_time.py | parse_timestamp | def parse_timestamp(timestamp, zone='UTC', timestamp_format=None):
r"""
pip install delorean
Args:
timestamp (str): timestampe string
zone (bool): assumes input is zone (only if not specified) and gives
output in zone.
CommandLine:
python -m utool.util_time --test-p... | python | def parse_timestamp(timestamp, zone='UTC', timestamp_format=None):
r"""
pip install delorean
Args:
timestamp (str): timestampe string
zone (bool): assumes input is zone (only if not specified) and gives
output in zone.
CommandLine:
python -m utool.util_time --test-p... | [
"def",
"parse_timestamp",
"(",
"timestamp",
",",
"zone",
"=",
"'UTC'",
",",
"timestamp_format",
"=",
"None",
")",
":",
"r",
"if",
"timestamp",
"is",
"None",
":",
"return",
"None",
"use_delorean",
"=",
"True",
"or",
"six",
".",
"PY2",
"if",
"use_delorean",
... | r"""
pip install delorean
Args:
timestamp (str): timestampe string
zone (bool): assumes input is zone (only if not specified) and gives
output in zone.
CommandLine:
python -m utool.util_time --test-parse_timestamp
python -m utool.util_time parse_timestamp
E... | [
"r",
"pip",
"install",
"delorean"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L447-L563 | train |
Erotemic/utool | utool/util_time.py | date_to_datetime | def date_to_datetime(date, fraction=0.0):
"""
fraction is how much through the day you are. 0=start of the day, 1=end of the day.
"""
day_seconds = (60 * 60 * 24) - 1
total_seconds = int(day_seconds * fraction)
delta = datetime.timedelta(seconds=total_seconds)
time = datetime.time()
dt =... | python | def date_to_datetime(date, fraction=0.0):
"""
fraction is how much through the day you are. 0=start of the day, 1=end of the day.
"""
day_seconds = (60 * 60 * 24) - 1
total_seconds = int(day_seconds * fraction)
delta = datetime.timedelta(seconds=total_seconds)
time = datetime.time()
dt =... | [
"def",
"date_to_datetime",
"(",
"date",
",",
"fraction",
"=",
"0.0",
")",
":",
"day_seconds",
"=",
"(",
"60",
"*",
"60",
"*",
"24",
")",
"-",
"1",
"total_seconds",
"=",
"int",
"(",
"day_seconds",
"*",
"fraction",
")",
"delta",
"=",
"datetime",
".",
"... | fraction is how much through the day you are. 0=start of the day, 1=end of the day. | [
"fraction",
"is",
"how",
"much",
"through",
"the",
"day",
"you",
"are",
".",
"0",
"=",
"start",
"of",
"the",
"day",
"1",
"=",
"end",
"of",
"the",
"day",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L1115-L1124 | train |
garethr/cloth | src/cloth/utils.py | ec2_instances | def ec2_instances():
"Use the EC2 API to get a list of all machines"
region = boto.ec2.get_region(REGION)
reservations = region.connect().get_all_instances()
instances = []
for reservation in reservations:
instances += reservation.instances
return instances | python | def ec2_instances():
"Use the EC2 API to get a list of all machines"
region = boto.ec2.get_region(REGION)
reservations = region.connect().get_all_instances()
instances = []
for reservation in reservations:
instances += reservation.instances
return instances | [
"def",
"ec2_instances",
"(",
")",
":",
"\"Use the EC2 API to get a list of all machines\"",
"region",
"=",
"boto",
".",
"ec2",
".",
"get_region",
"(",
"REGION",
")",
"reservations",
"=",
"region",
".",
"connect",
"(",
")",
".",
"get_all_instances",
"(",
")",
"in... | Use the EC2 API to get a list of all machines | [
"Use",
"the",
"EC2",
"API",
"to",
"get",
"a",
"list",
"of",
"all",
"machines"
] | b50c7cd6b03f49a931ee55ec94212760c50694a9 | https://github.com/garethr/cloth/blob/b50c7cd6b03f49a931ee55ec94212760c50694a9/src/cloth/utils.py#L12-L19 | train |
garethr/cloth | src/cloth/utils.py | instances | def instances(exp=".*"):
"Filter list of machines matching an expression"
expression = re.compile(exp)
instances = []
for node in ec2_instances():
if node.tags and ip(node):
try:
if expression.match(node.tags.get("Name")):
instances.append(node)
... | python | def instances(exp=".*"):
"Filter list of machines matching an expression"
expression = re.compile(exp)
instances = []
for node in ec2_instances():
if node.tags and ip(node):
try:
if expression.match(node.tags.get("Name")):
instances.append(node)
... | [
"def",
"instances",
"(",
"exp",
"=",
"\".*\"",
")",
":",
"\"Filter list of machines matching an expression\"",
"expression",
"=",
"re",
".",
"compile",
"(",
"exp",
")",
"instances",
"=",
"[",
"]",
"for",
"node",
"in",
"ec2_instances",
"(",
")",
":",
"if",
"n... | Filter list of machines matching an expression | [
"Filter",
"list",
"of",
"machines",
"matching",
"an",
"expression"
] | b50c7cd6b03f49a931ee55ec94212760c50694a9 | https://github.com/garethr/cloth/blob/b50c7cd6b03f49a931ee55ec94212760c50694a9/src/cloth/utils.py#L27-L38 | train |
garethr/cloth | src/cloth/utils.py | use | def use(node):
"Set the fabric environment for the specifed node"
try:
role = node.tags.get("Name").split('-')[1]
env.roledefs[role] += [ip(node)]
except IndexError:
pass
env.nodes += [node]
env.hosts += [ip(node)] | python | def use(node):
"Set the fabric environment for the specifed node"
try:
role = node.tags.get("Name").split('-')[1]
env.roledefs[role] += [ip(node)]
except IndexError:
pass
env.nodes += [node]
env.hosts += [ip(node)] | [
"def",
"use",
"(",
"node",
")",
":",
"\"Set the fabric environment for the specifed node\"",
"try",
":",
"role",
"=",
"node",
".",
"tags",
".",
"get",
"(",
"\"Name\"",
")",
".",
"split",
"(",
"'-'",
")",
"[",
"1",
"]",
"env",
".",
"roledefs",
"[",
"role"... | Set the fabric environment for the specifed node | [
"Set",
"the",
"fabric",
"environment",
"for",
"the",
"specifed",
"node"
] | b50c7cd6b03f49a931ee55ec94212760c50694a9 | https://github.com/garethr/cloth/blob/b50c7cd6b03f49a931ee55ec94212760c50694a9/src/cloth/utils.py#L40-L48 | train |
Erotemic/utool | utool/util_tags.py | build_alias_map | def build_alias_map(regex_map, tag_vocab):
"""
Constructs explicit mapping. Order of items in regex map matters.
Items at top are given preference.
Example:
>>> # DISABLE_DOCTEST
>>> tags_list = [['t1', 't2'], [], ['t3'], ['t4', 't5']]
>>> tag_vocab = ut.flat_unique(*tags_list)
... | python | def build_alias_map(regex_map, tag_vocab):
"""
Constructs explicit mapping. Order of items in regex map matters.
Items at top are given preference.
Example:
>>> # DISABLE_DOCTEST
>>> tags_list = [['t1', 't2'], [], ['t3'], ['t4', 't5']]
>>> tag_vocab = ut.flat_unique(*tags_list)
... | [
"def",
"build_alias_map",
"(",
"regex_map",
",",
"tag_vocab",
")",
":",
"import",
"utool",
"as",
"ut",
"import",
"re",
"alias_map",
"=",
"ut",
".",
"odict",
"(",
"[",
"]",
")",
"for",
"pats",
",",
"new_tag",
"in",
"reversed",
"(",
"regex_map",
")",
":"... | Constructs explicit mapping. Order of items in regex map matters.
Items at top are given preference.
Example:
>>> # DISABLE_DOCTEST
>>> tags_list = [['t1', 't2'], [], ['t3'], ['t4', 't5']]
>>> tag_vocab = ut.flat_unique(*tags_list)
>>> regex_map = [('t[3-4]', 'A9'), ('t0', 'a0')... | [
"Constructs",
"explicit",
"mapping",
".",
"Order",
"of",
"items",
"in",
"regex",
"map",
"matters",
".",
"Items",
"at",
"top",
"are",
"given",
"preference",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_tags.py#L65-L89 | train |
Erotemic/utool | utool/util_tags.py | alias_tags | def alias_tags(tags_list, alias_map):
"""
update tags to new values
Args:
tags_list (list):
alias_map (list): list of 2-tuples with regex, value
Returns:
list: updated tags
CommandLine:
python -m utool.util_tags alias_tags --show
Example:
>>> # DISABLE... | python | def alias_tags(tags_list, alias_map):
"""
update tags to new values
Args:
tags_list (list):
alias_map (list): list of 2-tuples with regex, value
Returns:
list: updated tags
CommandLine:
python -m utool.util_tags alias_tags --show
Example:
>>> # DISABLE... | [
"def",
"alias_tags",
"(",
"tags_list",
",",
"alias_map",
")",
":",
"def",
"_alias_dict",
"(",
"tags",
")",
":",
"tags_",
"=",
"[",
"alias_map",
".",
"get",
"(",
"t",
",",
"t",
")",
"for",
"t",
"in",
"tags",
"]",
"return",
"list",
"(",
"set",
"(",
... | update tags to new values
Args:
tags_list (list):
alias_map (list): list of 2-tuples with regex, value
Returns:
list: updated tags
CommandLine:
python -m utool.util_tags alias_tags --show
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_tags import *... | [
"update",
"tags",
"to",
"new",
"values"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_tags.py#L92-L119 | train |
ThreatResponse/aws_ir_plugins | aws_ir_plugins/examineracl_host.py | Plugin.setup | def setup(self):
self.client = self._get_client()
sg = self._create_isolation_security_group()
if self.exists is not True:
acl = self._create_network_acl()
self._add_network_acl_entries(acl)
self._add_security_group_rule(sg)
self._add_security_group_to... | python | def setup(self):
self.client = self._get_client()
sg = self._create_isolation_security_group()
if self.exists is not True:
acl = self._create_network_acl()
self._add_network_acl_entries(acl)
self._add_security_group_rule(sg)
self._add_security_group_to... | [
"def",
"setup",
"(",
"self",
")",
":",
"self",
".",
"client",
"=",
"self",
".",
"_get_client",
"(",
")",
"sg",
"=",
"self",
".",
"_create_isolation_security_group",
"(",
")",
"if",
"self",
".",
"exists",
"is",
"not",
"True",
":",
"acl",
"=",
"self",
... | Conditions that can not be dry_run | [
"Conditions",
"that",
"can",
"not",
"be",
"dry_run"
] | b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73 | https://github.com/ThreatResponse/aws_ir_plugins/blob/b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73/aws_ir_plugins/examineracl_host.py#L23-L35 | train |
Erotemic/utool | utool/util_cache.py | _args2_fpath | def _args2_fpath(dpath, fname, cfgstr, ext):
r"""
Ensures that the filename is not too long
Internal util_cache helper function
Windows MAX_PATH=260 characters
Absolute length is limited to 32,000 characters
Each filename component is limited to 255 characters
Args:
dpath (str):
... | python | def _args2_fpath(dpath, fname, cfgstr, ext):
r"""
Ensures that the filename is not too long
Internal util_cache helper function
Windows MAX_PATH=260 characters
Absolute length is limited to 32,000 characters
Each filename component is limited to 255 characters
Args:
dpath (str):
... | [
"def",
"_args2_fpath",
"(",
"dpath",
",",
"fname",
",",
"cfgstr",
",",
"ext",
")",
":",
"r",
"if",
"len",
"(",
"ext",
")",
">",
"0",
"and",
"ext",
"[",
"0",
"]",
"!=",
"'.'",
":",
"raise",
"ValueError",
"(",
"'Please be explicit and use a dot in ext'",
... | r"""
Ensures that the filename is not too long
Internal util_cache helper function
Windows MAX_PATH=260 characters
Absolute length is limited to 32,000 characters
Each filename component is limited to 255 characters
Args:
dpath (str):
fname (str):
cfgstr (str):
... | [
"r",
"Ensures",
"that",
"the",
"filename",
"is",
"not",
"too",
"long"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L161-L207 | train |
Erotemic/utool | utool/util_cache.py | save_cache | def save_cache(dpath, fname, cfgstr, data, ext='.cPkl', verbose=None):
"""
Saves data using util_io, but smartly constructs a filename
"""
fpath = _args2_fpath(dpath, fname, cfgstr, ext)
util_io.save_data(fpath, data, verbose=verbose)
return fpath | python | def save_cache(dpath, fname, cfgstr, data, ext='.cPkl', verbose=None):
"""
Saves data using util_io, but smartly constructs a filename
"""
fpath = _args2_fpath(dpath, fname, cfgstr, ext)
util_io.save_data(fpath, data, verbose=verbose)
return fpath | [
"def",
"save_cache",
"(",
"dpath",
",",
"fname",
",",
"cfgstr",
",",
"data",
",",
"ext",
"=",
"'.cPkl'",
",",
"verbose",
"=",
"None",
")",
":",
"fpath",
"=",
"_args2_fpath",
"(",
"dpath",
",",
"fname",
",",
"cfgstr",
",",
"ext",
")",
"util_io",
".",
... | Saves data using util_io, but smartly constructs a filename | [
"Saves",
"data",
"using",
"util_io",
"but",
"smartly",
"constructs",
"a",
"filename"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L210-L216 | train |
Erotemic/utool | utool/util_cache.py | load_cache | def load_cache(dpath, fname, cfgstr, ext='.cPkl', verbose=None, enabled=True):
"""
Loads data using util_io, but smartly constructs a filename
"""
if verbose is None:
verbose = VERBOSE_CACHE
if not USE_CACHE or not enabled:
if verbose > 1:
print('[util_cache] ... cache di... | python | def load_cache(dpath, fname, cfgstr, ext='.cPkl', verbose=None, enabled=True):
"""
Loads data using util_io, but smartly constructs a filename
"""
if verbose is None:
verbose = VERBOSE_CACHE
if not USE_CACHE or not enabled:
if verbose > 1:
print('[util_cache] ... cache di... | [
"def",
"load_cache",
"(",
"dpath",
",",
"fname",
",",
"cfgstr",
",",
"ext",
"=",
"'.cPkl'",
",",
"verbose",
"=",
"None",
",",
"enabled",
"=",
"True",
")",
":",
"if",
"verbose",
"is",
"None",
":",
"verbose",
"=",
"VERBOSE_CACHE",
"if",
"not",
"USE_CACHE... | Loads data using util_io, but smartly constructs a filename | [
"Loads",
"data",
"using",
"util_io",
"but",
"smartly",
"constructs",
"a",
"filename"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L219-L260 | train |
Erotemic/utool | utool/util_cache.py | tryload_cache | def tryload_cache(dpath, fname, cfgstr, verbose=None):
"""
returns None if cache cannot be loaded
"""
try:
return load_cache(dpath, fname, cfgstr, verbose=verbose)
except IOError:
return None | python | def tryload_cache(dpath, fname, cfgstr, verbose=None):
"""
returns None if cache cannot be loaded
"""
try:
return load_cache(dpath, fname, cfgstr, verbose=verbose)
except IOError:
return None | [
"def",
"tryload_cache",
"(",
"dpath",
",",
"fname",
",",
"cfgstr",
",",
"verbose",
"=",
"None",
")",
":",
"try",
":",
"return",
"load_cache",
"(",
"dpath",
",",
"fname",
",",
"cfgstr",
",",
"verbose",
"=",
"verbose",
")",
"except",
"IOError",
":",
"ret... | returns None if cache cannot be loaded | [
"returns",
"None",
"if",
"cache",
"cannot",
"be",
"loaded"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L263-L270 | train |
Erotemic/utool | utool/util_cache.py | tryload_cache_list | def tryload_cache_list(dpath, fname, cfgstr_list, verbose=False):
"""
loads a list of similar cached datas. Returns flags that needs to be computed
"""
data_list = [tryload_cache(dpath, fname, cfgstr, verbose) for cfgstr in cfgstr_list]
ismiss_list = [data is None for data in data_list]
return d... | python | def tryload_cache_list(dpath, fname, cfgstr_list, verbose=False):
"""
loads a list of similar cached datas. Returns flags that needs to be computed
"""
data_list = [tryload_cache(dpath, fname, cfgstr, verbose) for cfgstr in cfgstr_list]
ismiss_list = [data is None for data in data_list]
return d... | [
"def",
"tryload_cache_list",
"(",
"dpath",
",",
"fname",
",",
"cfgstr_list",
",",
"verbose",
"=",
"False",
")",
":",
"data_list",
"=",
"[",
"tryload_cache",
"(",
"dpath",
",",
"fname",
",",
"cfgstr",
",",
"verbose",
")",
"for",
"cfgstr",
"in",
"cfgstr_list... | loads a list of similar cached datas. Returns flags that needs to be computed | [
"loads",
"a",
"list",
"of",
"similar",
"cached",
"datas",
".",
"Returns",
"flags",
"that",
"needs",
"to",
"be",
"computed"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L274-L280 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.