repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Erotemic/utool | utool/util_str.py | get_textdiff | def get_textdiff(text1, text2, num_context_lines=0, ignore_whitespace=False):
r"""
Uses difflib to return a difference string between two similar texts
Args:
text1 (str):
text2 (str):
Returns:
str: formatted difference text message
SeeAlso:
ut.color_diff_text
... | python | def get_textdiff(text1, text2, num_context_lines=0, ignore_whitespace=False):
r"""
Uses difflib to return a difference string between two similar texts
Args:
text1 (str):
text2 (str):
Returns:
str: formatted difference text message
SeeAlso:
ut.color_diff_text
... | [
"def",
"get_textdiff",
"(",
"text1",
",",
"text2",
",",
"num_context_lines",
"=",
"0",
",",
"ignore_whitespace",
"=",
"False",
")",
":",
"r",
"import",
"difflib",
"text1",
"=",
"ensure_unicode",
"(",
"text1",
")",
"text2",
"=",
"ensure_unicode",
"(",
"text2"... | r"""
Uses difflib to return a difference string between two similar texts
Args:
text1 (str):
text2 (str):
Returns:
str: formatted difference text message
SeeAlso:
ut.color_diff_text
References:
http://www.java2s.com/Code/Python/Utility/Intelligentdiffbetwe... | [
"r",
"Uses",
"difflib",
"to",
"return",
"a",
"difference",
"string",
"between",
"two",
"similar",
"texts"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L2343-L2433 | train |
Erotemic/utool | utool/util_str.py | conj_phrase | def conj_phrase(list_, cond='or'):
"""
Joins a list of words using English conjunction rules
Args:
list_ (list): of strings
cond (str): a conjunction (or, and, but)
Returns:
str: the joined cconjunction phrase
References:
http://en.wikipedia.org/wiki/Conjunction_(... | python | def conj_phrase(list_, cond='or'):
"""
Joins a list of words using English conjunction rules
Args:
list_ (list): of strings
cond (str): a conjunction (or, and, but)
Returns:
str: the joined cconjunction phrase
References:
http://en.wikipedia.org/wiki/Conjunction_(... | [
"def",
"conj_phrase",
"(",
"list_",
",",
"cond",
"=",
"'or'",
")",
":",
"if",
"len",
"(",
"list_",
")",
"==",
"0",
":",
"return",
"''",
"elif",
"len",
"(",
"list_",
")",
"==",
"1",
":",
"return",
"list_",
"[",
"0",
"]",
"elif",
"len",
"(",
"lis... | Joins a list of words using English conjunction rules
Args:
list_ (list): of strings
cond (str): a conjunction (or, and, but)
Returns:
str: the joined cconjunction phrase
References:
http://en.wikipedia.org/wiki/Conjunction_(grammar)
Example:
>>> # ENABLE_DOC... | [
"Joins",
"a",
"list",
"of",
"words",
"using",
"English",
"conjunction",
"rules"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L2439-L2477 | train |
Erotemic/utool | utool/util_str.py | bubbletext | def bubbletext(text, font='cybermedium'):
r"""
Uses pyfiglet to create bubble text.
Args:
font (str): default=cybermedium, other fonts include: cybersmall and
cyberlarge.
References:
http://www.figlet.org/
Example:
>>> # ENABLE_DOCTEST
>>> import utool ... | python | def bubbletext(text, font='cybermedium'):
r"""
Uses pyfiglet to create bubble text.
Args:
font (str): default=cybermedium, other fonts include: cybersmall and
cyberlarge.
References:
http://www.figlet.org/
Example:
>>> # ENABLE_DOCTEST
>>> import utool ... | [
"def",
"bubbletext",
"(",
"text",
",",
"font",
"=",
"'cybermedium'",
")",
":",
"r",
"import",
"utool",
"as",
"ut",
"pyfiglet",
"=",
"ut",
".",
"tryimport",
"(",
"'pyfiglet'",
",",
"'git+https://github.com/pwaller/pyfiglet'",
")",
"if",
"pyfiglet",
"is",
"None"... | r"""
Uses pyfiglet to create bubble text.
Args:
font (str): default=cybermedium, other fonts include: cybersmall and
cyberlarge.
References:
http://www.figlet.org/
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
>>> bubble_text = ut.bubbletext(... | [
"r",
"Uses",
"pyfiglet",
"to",
"create",
"bubble",
"text",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L2563-L2586 | train |
Erotemic/utool | utool/util_str.py | is_url | def is_url(str_):
""" heuristic check if str is url formatted """
return any([
str_.startswith('http://'),
str_.startswith('https://'),
str_.startswith('www.'),
'.org/' in str_,
'.com/' in str_,
]) | python | def is_url(str_):
""" heuristic check if str is url formatted """
return any([
str_.startswith('http://'),
str_.startswith('https://'),
str_.startswith('www.'),
'.org/' in str_,
'.com/' in str_,
]) | [
"def",
"is_url",
"(",
"str_",
")",
":",
"return",
"any",
"(",
"[",
"str_",
".",
"startswith",
"(",
"'http://'",
")",
",",
"str_",
".",
"startswith",
"(",
"'https://'",
")",
",",
"str_",
".",
"startswith",
"(",
"'www.'",
")",
",",
"'.org/'",
"in",
"st... | heuristic check if str is url formatted | [
"heuristic",
"check",
"if",
"str",
"is",
"url",
"formatted"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L2685-L2693 | train |
Erotemic/utool | utool/util_str.py | chr_range | def chr_range(*args, **kw):
r"""
Like range but returns characters
Args:
start (None): (default = None)
stop (None): (default = None)
step (None): (default = None)
Kwargs:
base (str): charater to start with (default='a')
Returns:
list: list of characters
... | python | def chr_range(*args, **kw):
r"""
Like range but returns characters
Args:
start (None): (default = None)
stop (None): (default = None)
step (None): (default = None)
Kwargs:
base (str): charater to start with (default='a')
Returns:
list: list of characters
... | [
"def",
"chr_range",
"(",
"*",
"args",
",",
"**",
"kw",
")",
":",
"r",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"stop",
",",
"=",
"args",
"start",
",",
"step",
"=",
"0",
",",
"1",
"elif",
"len",
"(",
"args",
")",
"==",
"2",
":",
"start... | r"""
Like range but returns characters
Args:
start (None): (default = None)
stop (None): (default = None)
step (None): (default = None)
Kwargs:
base (str): charater to start with (default='a')
Returns:
list: list of characters
CommandLine:
python -... | [
"r",
"Like",
"range",
"but",
"returns",
"characters"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L2772-L2828 | train |
Erotemic/utool | utool/util_str.py | highlight_regex | def highlight_regex(str_, pat, reflags=0, color='red'):
"""
FIXME Use pygments instead
"""
#import colorama
# from colorama import Fore, Style
#color = Fore.MAGENTA
# color = Fore.RED
#match = re.search(pat, str_, flags=reflags)
matches = list(re.finditer(pat, str_, flags=reflags))
... | python | def highlight_regex(str_, pat, reflags=0, color='red'):
"""
FIXME Use pygments instead
"""
#import colorama
# from colorama import Fore, Style
#color = Fore.MAGENTA
# color = Fore.RED
#match = re.search(pat, str_, flags=reflags)
matches = list(re.finditer(pat, str_, flags=reflags))
... | [
"def",
"highlight_regex",
"(",
"str_",
",",
"pat",
",",
"reflags",
"=",
"0",
",",
"color",
"=",
"'red'",
")",
":",
"matches",
"=",
"list",
"(",
"re",
".",
"finditer",
"(",
"pat",
",",
"str_",
",",
"flags",
"=",
"reflags",
")",
")",
"colored",
"=",
... | FIXME Use pygments instead | [
"FIXME",
"Use",
"pygments",
"instead"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L2912-L2938 | train |
Erotemic/utool | utool/util_str.py | highlight_multi_regex | def highlight_multi_regex(str_, pat_to_color, reflags=0):
"""
FIXME Use pygments instead. must be mututally exclusive
"""
#import colorama
# from colorama import Fore, Style
#color = Fore.MAGENTA
# color = Fore.RED
#match = re.search(pat, str_, flags=reflags)
colored = str_
to_... | python | def highlight_multi_regex(str_, pat_to_color, reflags=0):
"""
FIXME Use pygments instead. must be mututally exclusive
"""
#import colorama
# from colorama import Fore, Style
#color = Fore.MAGENTA
# color = Fore.RED
#match = re.search(pat, str_, flags=reflags)
colored = str_
to_... | [
"def",
"highlight_multi_regex",
"(",
"str_",
",",
"pat_to_color",
",",
"reflags",
"=",
"0",
")",
":",
"colored",
"=",
"str_",
"to_replace",
"=",
"[",
"]",
"for",
"pat",
",",
"color",
"in",
"pat_to_color",
".",
"items",
"(",
")",
":",
"matches",
"=",
"l... | FIXME Use pygments instead. must be mututally exclusive | [
"FIXME",
"Use",
"pygments",
"instead",
".",
"must",
"be",
"mututally",
"exclusive"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L2941-L2967 | train |
Erotemic/utool | utool/util_str.py | find_block_end | def find_block_end(row, line_list, sentinal, direction=1):
"""
Searches up and down until it finds the endpoints of a block Rectify
with find_paragraph_end in pyvim_funcs
"""
import re
row_ = row
line_ = line_list[row_]
flag1 = row_ == 0 or row_ == len(line_list) - 1
flag2 = re.match... | python | def find_block_end(row, line_list, sentinal, direction=1):
"""
Searches up and down until it finds the endpoints of a block Rectify
with find_paragraph_end in pyvim_funcs
"""
import re
row_ = row
line_ = line_list[row_]
flag1 = row_ == 0 or row_ == len(line_list) - 1
flag2 = re.match... | [
"def",
"find_block_end",
"(",
"row",
",",
"line_list",
",",
"sentinal",
",",
"direction",
"=",
"1",
")",
":",
"import",
"re",
"row_",
"=",
"row",
"line_",
"=",
"line_list",
"[",
"row_",
"]",
"flag1",
"=",
"row_",
"==",
"0",
"or",
"row_",
"==",
"len",... | Searches up and down until it finds the endpoints of a block Rectify
with find_paragraph_end in pyvim_funcs | [
"Searches",
"up",
"and",
"down",
"until",
"it",
"finds",
"the",
"endpoints",
"of",
"a",
"block",
"Rectify",
"with",
"find_paragraph_end",
"in",
"pyvim_funcs"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L3492-L3510 | train |
Erotemic/utool | utool/util_latex.py | compress_pdf | def compress_pdf(pdf_fpath, output_fname=None):
""" uses ghostscript to write a pdf """
import utool as ut
ut.assertpath(pdf_fpath)
suffix = '_' + ut.get_datestamp(False) + '_compressed'
print('pdf_fpath = %r' % (pdf_fpath,))
output_pdf_fpath = ut.augpath(pdf_fpath, suffix, newfname=output_fname... | python | def compress_pdf(pdf_fpath, output_fname=None):
""" uses ghostscript to write a pdf """
import utool as ut
ut.assertpath(pdf_fpath)
suffix = '_' + ut.get_datestamp(False) + '_compressed'
print('pdf_fpath = %r' % (pdf_fpath,))
output_pdf_fpath = ut.augpath(pdf_fpath, suffix, newfname=output_fname... | [
"def",
"compress_pdf",
"(",
"pdf_fpath",
",",
"output_fname",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",
"ut",
".",
"assertpath",
"(",
"pdf_fpath",
")",
"suffix",
"=",
"'_'",
"+",
"ut",
".",
"get_datestamp",
"(",
"False",
")",
"+",
"'_compress... | uses ghostscript to write a pdf | [
"uses",
"ghostscript",
"to",
"write",
"a",
"pdf"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_latex.py#L37-L57 | train |
Erotemic/utool | utool/util_latex.py | make_full_document | def make_full_document(text, title=None, preamp_decl={}, preamb_extra=None):
r"""
dummy preamble and document to wrap around latex fragment
Args:
text (str):
title (str):
Returns:
str: text_
CommandLine:
python -m utool.util_latex --test-make_full_document
Exa... | python | def make_full_document(text, title=None, preamp_decl={}, preamb_extra=None):
r"""
dummy preamble and document to wrap around latex fragment
Args:
text (str):
title (str):
Returns:
str: text_
CommandLine:
python -m utool.util_latex --test-make_full_document
Exa... | [
"def",
"make_full_document",
"(",
"text",
",",
"title",
"=",
"None",
",",
"preamp_decl",
"=",
"{",
"}",
",",
"preamb_extra",
"=",
"None",
")",
":",
"r",
"import",
"utool",
"as",
"ut",
"doc_preamb",
"=",
"ut",
".",
"codeblock",
"(",
")",
"if",
"preamb_e... | r"""
dummy preamble and document to wrap around latex fragment
Args:
text (str):
title (str):
Returns:
str: text_
CommandLine:
python -m utool.util_latex --test-make_full_document
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_latex import * #... | [
"r",
"dummy",
"preamble",
"and",
"document",
"to",
"wrap",
"around",
"latex",
"fragment"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_latex.py#L60-L125 | train |
Erotemic/utool | utool/util_latex.py | render_latex_text | def render_latex_text(input_text, nest_in_doc=False, preamb_extra=None,
appname='utool', verbose=None):
""" compiles latex and shows the result """
import utool as ut
if verbose is None:
verbose = ut.VERBOSE
dpath = ut.ensure_app_resource_dir(appname, 'latex_tmp')
# put... | python | def render_latex_text(input_text, nest_in_doc=False, preamb_extra=None,
appname='utool', verbose=None):
""" compiles latex and shows the result """
import utool as ut
if verbose is None:
verbose = ut.VERBOSE
dpath = ut.ensure_app_resource_dir(appname, 'latex_tmp')
# put... | [
"def",
"render_latex_text",
"(",
"input_text",
",",
"nest_in_doc",
"=",
"False",
",",
"preamb_extra",
"=",
"None",
",",
"appname",
"=",
"'utool'",
",",
"verbose",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",
"if",
"verbose",
"is",
"None",
":",
"... | compiles latex and shows the result | [
"compiles",
"latex",
"and",
"shows",
"the",
"result"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_latex.py#L128-L142 | train |
Erotemic/utool | utool/util_latex.py | render_latex | def render_latex(input_text, dpath=None, fname=None, preamb_extra=None,
verbose=1, **kwargs):
"""
Renders latex text into a jpeg.
Whitespace that would have appeared in the PDF is removed, so the jpeg is
cropped only the the relevant part. This is ideal for figures that only
take ... | python | def render_latex(input_text, dpath=None, fname=None, preamb_extra=None,
verbose=1, **kwargs):
"""
Renders latex text into a jpeg.
Whitespace that would have appeared in the PDF is removed, so the jpeg is
cropped only the the relevant part. This is ideal for figures that only
take ... | [
"def",
"render_latex",
"(",
"input_text",
",",
"dpath",
"=",
"None",
",",
"fname",
"=",
"None",
",",
"preamb_extra",
"=",
"None",
",",
"verbose",
"=",
"1",
",",
"**",
"kwargs",
")",
":",
"import",
"utool",
"as",
"ut",
"import",
"vtool",
"as",
"vt",
"... | Renders latex text into a jpeg.
Whitespace that would have appeared in the PDF is removed, so the jpeg is
cropped only the the relevant part. This is ideal for figures that only
take a single page.
Args:
input_text (?):
dpath (str): directory path(default = None)
fname (str):... | [
"Renders",
"latex",
"text",
"into",
"a",
"jpeg",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_latex.py#L240-L290 | train |
Erotemic/utool | utool/util_latex.py | get_latex_figure_str2 | def get_latex_figure_str2(fpath_list, cmdname, **kwargs):
""" hack for candidacy """
import utool as ut
from os.path import relpath
# Make relative paths
if kwargs.pop('relpath', True):
start = ut.truepath('~/latex/crall-candidacy-2015')
fpath_list = [relpath(fpath, start) for fpath ... | python | def get_latex_figure_str2(fpath_list, cmdname, **kwargs):
""" hack for candidacy """
import utool as ut
from os.path import relpath
# Make relative paths
if kwargs.pop('relpath', True):
start = ut.truepath('~/latex/crall-candidacy-2015')
fpath_list = [relpath(fpath, start) for fpath ... | [
"def",
"get_latex_figure_str2",
"(",
"fpath_list",
",",
"cmdname",
",",
"**",
"kwargs",
")",
":",
"import",
"utool",
"as",
"ut",
"from",
"os",
".",
"path",
"import",
"relpath",
"if",
"kwargs",
".",
"pop",
"(",
"'relpath'",
",",
"True",
")",
":",
"start",... | hack for candidacy | [
"hack",
"for",
"candidacy"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_latex.py#L711-L724 | train |
chriso/gauged | gauged/writer.py | Writer.add | def add(self, data, value=None, timestamp=None, namespace=None,
debug=False):
"""Queue a gauge or gauges to be written"""
if value is not None:
return self.add(((data, value),), timestamp=timestamp,
namespace=namespace, debug=debug)
writer = se... | python | def add(self, data, value=None, timestamp=None, namespace=None,
debug=False):
"""Queue a gauge or gauges to be written"""
if value is not None:
return self.add(((data, value),), timestamp=timestamp,
namespace=namespace, debug=debug)
writer = se... | [
"def",
"add",
"(",
"self",
",",
"data",
",",
"value",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"self",
".",
"add",
"(",
"("... | Queue a gauge or gauges to be written | [
"Queue",
"a",
"gauge",
"or",
"gauges",
"to",
"be",
"written"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L47-L128 | train |
chriso/gauged | gauged/writer.py | Writer.flush | def flush(self):
"""Flush all pending gauges"""
writer = self.writer
if writer is None:
raise GaugedUseAfterFreeError
self.flush_writer_position()
keys = self.translate_keys()
blocks = []
current_block = self.current_block
statistics = self.sta... | python | def flush(self):
"""Flush all pending gauges"""
writer = self.writer
if writer is None:
raise GaugedUseAfterFreeError
self.flush_writer_position()
keys = self.translate_keys()
blocks = []
current_block = self.current_block
statistics = self.sta... | [
"def",
"flush",
"(",
"self",
")",
":",
"writer",
"=",
"self",
".",
"writer",
"if",
"writer",
"is",
"None",
":",
"raise",
"GaugedUseAfterFreeError",
"self",
".",
"flush_writer_position",
"(",
")",
"keys",
"=",
"self",
".",
"translate_keys",
"(",
")",
"block... | Flush all pending gauges | [
"Flush",
"all",
"pending",
"gauges"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L130-L162 | train |
chriso/gauged | gauged/writer.py | Writer.resume_from | def resume_from(self):
"""Get a timestamp representing the position just after the last
written gauge"""
position = self.driver.get_writer_position(self.config.writer_name)
return position + self.config.resolution if position else 0 | python | def resume_from(self):
"""Get a timestamp representing the position just after the last
written gauge"""
position = self.driver.get_writer_position(self.config.writer_name)
return position + self.config.resolution if position else 0 | [
"def",
"resume_from",
"(",
"self",
")",
":",
"position",
"=",
"self",
".",
"driver",
".",
"get_writer_position",
"(",
"self",
".",
"config",
".",
"writer_name",
")",
"return",
"position",
"+",
"self",
".",
"config",
".",
"resolution",
"if",
"position",
"el... | Get a timestamp representing the position just after the last
written gauge | [
"Get",
"a",
"timestamp",
"representing",
"the",
"position",
"just",
"after",
"the",
"last",
"written",
"gauge"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L164-L168 | train |
chriso/gauged | gauged/writer.py | Writer.clear_from | def clear_from(self, timestamp):
"""Clear all data from `timestamp` onwards. Note that the timestamp
is rounded down to the nearest block boundary"""
block_size = self.config.block_size
offset, remainder = timestamp // block_size, timestamp % block_size
if remainder:
... | python | def clear_from(self, timestamp):
"""Clear all data from `timestamp` onwards. Note that the timestamp
is rounded down to the nearest block boundary"""
block_size = self.config.block_size
offset, remainder = timestamp // block_size, timestamp % block_size
if remainder:
... | [
"def",
"clear_from",
"(",
"self",
",",
"timestamp",
")",
":",
"block_size",
"=",
"self",
".",
"config",
".",
"block_size",
"offset",
",",
"remainder",
"=",
"timestamp",
"//",
"block_size",
",",
"timestamp",
"%",
"block_size",
"if",
"remainder",
":",
"raise",... | Clear all data from `timestamp` onwards. Note that the timestamp
is rounded down to the nearest block boundary | [
"Clear",
"all",
"data",
"from",
"timestamp",
"onwards",
".",
"Note",
"that",
"the",
"timestamp",
"is",
"rounded",
"down",
"to",
"the",
"nearest",
"block",
"boundary"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L170-L177 | train |
chriso/gauged | gauged/writer.py | Writer.clear_key_before | def clear_key_before(self, key, namespace=None, timestamp=None):
"""Clear all data before `timestamp` for a given key. Note that the
timestamp is rounded down to the nearest block boundary"""
block_size = self.config.block_size
if namespace is None:
namespace = self.config.na... | python | def clear_key_before(self, key, namespace=None, timestamp=None):
"""Clear all data before `timestamp` for a given key. Note that the
timestamp is rounded down to the nearest block boundary"""
block_size = self.config.block_size
if namespace is None:
namespace = self.config.na... | [
"def",
"clear_key_before",
"(",
"self",
",",
"key",
",",
"namespace",
"=",
"None",
",",
"timestamp",
"=",
"None",
")",
":",
"block_size",
"=",
"self",
".",
"config",
".",
"block_size",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"self",
".",
... | Clear all data before `timestamp` for a given key. Note that the
timestamp is rounded down to the nearest block boundary | [
"Clear",
"all",
"data",
"before",
"timestamp",
"for",
"a",
"given",
"key",
".",
"Note",
"that",
"the",
"timestamp",
"is",
"rounded",
"down",
"to",
"the",
"nearest",
"block",
"boundary"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L179-L194 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._to_ctfile_counts_line | def _to_ctfile_counts_line(self, key):
"""Create counts line in ``CTfile`` format.
:param str key: Counts line key.
:return: Counts line string.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(self.counts_line_format)
self[key]['number_of_atoms'] = str(len(... | python | def _to_ctfile_counts_line(self, key):
"""Create counts line in ``CTfile`` format.
:param str key: Counts line key.
:return: Counts line string.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(self.counts_line_format)
self[key]['number_of_atoms'] = str(len(... | [
"def",
"_to_ctfile_counts_line",
"(",
"self",
",",
"key",
")",
":",
"counter",
"=",
"OrderedCounter",
"(",
"self",
".",
"counts_line_format",
")",
"self",
"[",
"key",
"]",
"[",
"'number_of_atoms'",
"]",
"=",
"str",
"(",
"len",
"(",
"self",
".",
"atoms",
... | Create counts line in ``CTfile`` format.
:param str key: Counts line key.
:return: Counts line string.
:rtype: :py:class:`str` | [
"Create",
"counts",
"line",
"in",
"CTfile",
"format",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L346-L358 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._to_ctfile_atom_block | def _to_ctfile_atom_block(self, key):
"""Create atom block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab atom block.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(Atom.atom_block_format)
ctab_atom_block = '\n'.join([''.join([str(v... | python | def _to_ctfile_atom_block(self, key):
"""Create atom block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab atom block.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(Atom.atom_block_format)
ctab_atom_block = '\n'.join([''.join([str(v... | [
"def",
"_to_ctfile_atom_block",
"(",
"self",
",",
"key",
")",
":",
"counter",
"=",
"OrderedCounter",
"(",
"Atom",
".",
"atom_block_format",
")",
"ctab_atom_block",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"''",
".",
"join",
"(",
"[",
"str",
"(",
"value",
")"... | Create atom block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab atom block.
:rtype: :py:class:`str` | [
"Create",
"atom",
"block",
"in",
"CTfile",
"format",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L360-L371 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._to_ctfile_bond_block | def _to_ctfile_bond_block(self, key):
"""Create bond block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab bond block.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(Bond.bond_block_format)
ctab_bond_block = '\n'.join([''.join([str(v... | python | def _to_ctfile_bond_block(self, key):
"""Create bond block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab bond block.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(Bond.bond_block_format)
ctab_bond_block = '\n'.join([''.join([str(v... | [
"def",
"_to_ctfile_bond_block",
"(",
"self",
",",
"key",
")",
":",
"counter",
"=",
"OrderedCounter",
"(",
"Bond",
".",
"bond_block_format",
")",
"ctab_bond_block",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"''",
".",
"join",
"(",
"[",
"str",
"(",
"value",
")"... | Create bond block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab bond block.
:rtype: :py:class:`str` | [
"Create",
"bond",
"block",
"in",
"CTfile",
"format",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L373-L384 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._to_ctfile_property_block | def _to_ctfile_property_block(self):
"""Create ctab properties block in `CTfile` format from atom-specific properties.
:return: Ctab property block.
:rtype: :py:class:`str`
"""
ctab_properties_data = defaultdict(list)
for atom in self.atoms:
for ctab_property... | python | def _to_ctfile_property_block(self):
"""Create ctab properties block in `CTfile` format from atom-specific properties.
:return: Ctab property block.
:rtype: :py:class:`str`
"""
ctab_properties_data = defaultdict(list)
for atom in self.atoms:
for ctab_property... | [
"def",
"_to_ctfile_property_block",
"(",
"self",
")",
":",
"ctab_properties_data",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"atom",
"in",
"self",
".",
"atoms",
":",
"for",
"ctab_property_key",
",",
"ctab_property_value",
"in",
"atom",
".",
"_ctab_property_data... | Create ctab properties block in `CTfile` format from atom-specific properties.
:return: Ctab property block.
:rtype: :py:class:`str` | [
"Create",
"ctab",
"properties",
"block",
"in",
"CTfile",
"format",
"from",
"atom",
"-",
"specific",
"properties",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L386-L408 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab.delete_atom | def delete_atom(self, *atom_numbers):
"""Delete atoms by atom number.
:param str atom_numbers:
:return: None.
:rtype: :py:obj:`None`
"""
for atom_number in atom_numbers:
deletion_atom = self.atom_by_number(atom_number=atom_number)
# update atom ... | python | def delete_atom(self, *atom_numbers):
"""Delete atoms by atom number.
:param str atom_numbers:
:return: None.
:rtype: :py:obj:`None`
"""
for atom_number in atom_numbers:
deletion_atom = self.atom_by_number(atom_number=atom_number)
# update atom ... | [
"def",
"delete_atom",
"(",
"self",
",",
"*",
"atom_numbers",
")",
":",
"for",
"atom_number",
"in",
"atom_numbers",
":",
"deletion_atom",
"=",
"self",
".",
"atom_by_number",
"(",
"atom_number",
"=",
"atom_number",
")",
"for",
"atom",
"in",
"self",
".",
"atoms... | Delete atoms by atom number.
:param str atom_numbers:
:return: None.
:rtype: :py:obj:`None` | [
"Delete",
"atoms",
"by",
"atom",
"number",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L522-L548 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile.from_molfile | def from_molfile(cls, molfile, data=None):
"""Construct new ``SDfile`` object from ``Molfile`` object.
:param molfile: ``Molfile`` object.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:return: ``SDfile`` object.
:rtype: :class:`~ctfile.ctfile.SDfile`.
"""
if n... | python | def from_molfile(cls, molfile, data=None):
"""Construct new ``SDfile`` object from ``Molfile`` object.
:param molfile: ``Molfile`` object.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:return: ``SDfile`` object.
:rtype: :class:`~ctfile.ctfile.SDfile`.
"""
if n... | [
"def",
"from_molfile",
"(",
"cls",
",",
"molfile",
",",
"data",
"=",
"None",
")",
":",
"if",
"not",
"data",
":",
"data",
"=",
"OrderedDict",
"(",
")",
"if",
"not",
"isinstance",
"(",
"molfile",
",",
"Molfile",
")",
":",
"raise",
"ValueError",
"(",
"'... | Construct new ``SDfile`` object from ``Molfile`` object.
:param molfile: ``Molfile`` object.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:return: ``SDfile`` object.
:rtype: :class:`~ctfile.ctfile.SDfile`. | [
"Construct",
"new",
"SDfile",
"object",
"from",
"Molfile",
"object",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L768-L789 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile.add_data | def add_data(self, id, key, value):
"""Add new data item.
:param str id: Entry id within ``SDfile``.
:param str key: Data item key.
:param str value: Data item value.
:return: None.
:rtype: :py:obj:`None`.
"""
self[str(id)]['data'].setdefault(key, [])
... | python | def add_data(self, id, key, value):
"""Add new data item.
:param str id: Entry id within ``SDfile``.
:param str key: Data item key.
:param str value: Data item value.
:return: None.
:rtype: :py:obj:`None`.
"""
self[str(id)]['data'].setdefault(key, [])
... | [
"def",
"add_data",
"(",
"self",
",",
"id",
",",
"key",
",",
"value",
")",
":",
"self",
"[",
"str",
"(",
"id",
")",
"]",
"[",
"'data'",
"]",
".",
"setdefault",
"(",
"key",
",",
"[",
"]",
")",
"self",
"[",
"str",
"(",
"id",
")",
"]",
"[",
"'d... | Add new data item.
:param str id: Entry id within ``SDfile``.
:param str key: Data item key.
:param str value: Data item value.
:return: None.
:rtype: :py:obj:`None`. | [
"Add",
"new",
"data",
"item",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L791-L801 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile.add_molfile | def add_molfile(self, molfile, data):
"""Add ``Molfile`` and data to ``SDfile`` object.
:param molfile: ``Molfile`` instance.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:param dict data: Data associated with ``Molfile`` instance.
:return: None.
:rtype: :py:obj:`Non... | python | def add_molfile(self, molfile, data):
"""Add ``Molfile`` and data to ``SDfile`` object.
:param molfile: ``Molfile`` instance.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:param dict data: Data associated with ``Molfile`` instance.
:return: None.
:rtype: :py:obj:`Non... | [
"def",
"add_molfile",
"(",
"self",
",",
"molfile",
",",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"molfile",
",",
"Molfile",
")",
":",
"raise",
"ValueError",
"(",
"'Not a Molfile type: \"{}\"'",
".",
"format",
"(",
"type",
"(",
"molfile",
")",
")",... | Add ``Molfile`` and data to ``SDfile`` object.
:param molfile: ``Molfile`` instance.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:param dict data: Data associated with ``Molfile`` instance.
:return: None.
:rtype: :py:obj:`None`. | [
"Add",
"Molfile",
"and",
"data",
"to",
"SDfile",
"object",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L803-L827 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile.add_sdfile | def add_sdfile(self, sdfile):
"""Add new ``SDfile`` to current ``SDfile``.
:param sdfile: ``SDfile`` instance.
:return: None.
:rtype: :py:obj:`None`.
"""
if not isinstance(sdfile, SDfile):
raise ValueError('Not a SDfile type: "{}"'.format(type(sdfile)))
... | python | def add_sdfile(self, sdfile):
"""Add new ``SDfile`` to current ``SDfile``.
:param sdfile: ``SDfile`` instance.
:return: None.
:rtype: :py:obj:`None`.
"""
if not isinstance(sdfile, SDfile):
raise ValueError('Not a SDfile type: "{}"'.format(type(sdfile)))
... | [
"def",
"add_sdfile",
"(",
"self",
",",
"sdfile",
")",
":",
"if",
"not",
"isinstance",
"(",
"sdfile",
",",
"SDfile",
")",
":",
"raise",
"ValueError",
"(",
"'Not a SDfile type: \"{}\"'",
".",
"format",
"(",
"type",
"(",
"sdfile",
")",
")",
")",
"for",
"ent... | Add new ``SDfile`` to current ``SDfile``.
:param sdfile: ``SDfile`` instance.
:return: None.
:rtype: :py:obj:`None`. | [
"Add",
"new",
"SDfile",
"to",
"current",
"SDfile",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L829-L841 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Atom.neighbor_atoms | def neighbor_atoms(self, atom_symbol=None):
"""Access neighbor atoms.
:param str atom_symbol: Atom symbol.
:return: List of neighbor atoms.
:rtype: :py:class:`list`.
"""
if not atom_symbol:
return self.neighbors
else:
return [atom for atom... | python | def neighbor_atoms(self, atom_symbol=None):
"""Access neighbor atoms.
:param str atom_symbol: Atom symbol.
:return: List of neighbor atoms.
:rtype: :py:class:`list`.
"""
if not atom_symbol:
return self.neighbors
else:
return [atom for atom... | [
"def",
"neighbor_atoms",
"(",
"self",
",",
"atom_symbol",
"=",
"None",
")",
":",
"if",
"not",
"atom_symbol",
":",
"return",
"self",
".",
"neighbors",
"else",
":",
"return",
"[",
"atom",
"for",
"atom",
"in",
"self",
".",
"neighbors",
"if",
"atom",
"[",
... | Access neighbor atoms.
:param str atom_symbol: Atom symbol.
:return: List of neighbor atoms.
:rtype: :py:class:`list`. | [
"Access",
"neighbor",
"atoms",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L983-L993 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Bond.update_atom_numbers | def update_atom_numbers(self):
"""Update links "first_atom_number" -> "second_atom_number"
:return: None.
:rtype: :py:obj:`None`.
"""
self._ctab_data['first_atom_number'] = self.first_atom.atom_number
self._ctab_data['second_atom_number'] = self.second_atom.atom_number | python | def update_atom_numbers(self):
"""Update links "first_atom_number" -> "second_atom_number"
:return: None.
:rtype: :py:obj:`None`.
"""
self._ctab_data['first_atom_number'] = self.first_atom.atom_number
self._ctab_data['second_atom_number'] = self.second_atom.atom_number | [
"def",
"update_atom_numbers",
"(",
"self",
")",
":",
"self",
".",
"_ctab_data",
"[",
"'first_atom_number'",
"]",
"=",
"self",
".",
"first_atom",
".",
"atom_number",
"self",
".",
"_ctab_data",
"[",
"'second_atom_number'",
"]",
"=",
"self",
".",
"second_atom",
"... | Update links "first_atom_number" -> "second_atom_number"
:return: None.
:rtype: :py:obj:`None`. | [
"Update",
"links",
"first_atom_number",
"-",
">",
"second_atom_number"
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L1111-L1118 | train |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | CtabAtomBondEncoder.default | def default(self, o):
"""Default encoder.
:param o: Atom or Bond instance.
:type o: :class:`~ctfile.ctfile.Atom` or :class:`~ctfile.ctfile.Bond`.
:return: Dictionary that contains information required for atom and bond block of ``Ctab``.
:rtype: :py:class:`collections.OrderedDic... | python | def default(self, o):
"""Default encoder.
:param o: Atom or Bond instance.
:type o: :class:`~ctfile.ctfile.Atom` or :class:`~ctfile.ctfile.Bond`.
:return: Dictionary that contains information required for atom and bond block of ``Ctab``.
:rtype: :py:class:`collections.OrderedDic... | [
"def",
"default",
"(",
"self",
",",
"o",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"Atom",
")",
"or",
"isinstance",
"(",
"o",
",",
"Bond",
")",
":",
"return",
"o",
".",
"_ctab_data",
"else",
":",
"return",
"o",
".",
"__dict__"
] | Default encoder.
:param o: Atom or Bond instance.
:type o: :class:`~ctfile.ctfile.Atom` or :class:`~ctfile.ctfile.Bond`.
:return: Dictionary that contains information required for atom and bond block of ``Ctab``.
:rtype: :py:class:`collections.OrderedDict` | [
"Default",
"encoder",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L1144-L1155 | train |
product-definition-center/pdc-client | pdc_client/config.py | ServerConfigManager.get | def get(self, server):
"""
Returns ServerConfig instance with configuration given server.
:raises ServerConfigConflictError:
if configuration directory contains configuration for same server
multiple times
:raises ServerConfigMissingUrlError: if URL is not speci... | python | def get(self, server):
"""
Returns ServerConfig instance with configuration given server.
:raises ServerConfigConflictError:
if configuration directory contains configuration for same server
multiple times
:raises ServerConfigMissingUrlError: if URL is not speci... | [
"def",
"get",
"(",
"self",
",",
"server",
")",
":",
"server_config",
"=",
"self",
".",
"config",
".",
"get",
"(",
"server",
")",
"try",
":",
"while",
"server_config",
"is",
"None",
":",
"new_config",
"=",
"self",
".",
"_read_next_config",
"(",
")",
"se... | Returns ServerConfig instance with configuration given server.
:raises ServerConfigConflictError:
if configuration directory contains configuration for same server
multiple times
:raises ServerConfigMissingUrlError: if URL is not specified in the configuration
:raises ... | [
"Returns",
"ServerConfig",
"instance",
"with",
"configuration",
"given",
"server",
"."
] | 7236fd8b72e675ebb321bbe337289d9fbeb6119f | https://github.com/product-definition-center/pdc-client/blob/7236fd8b72e675ebb321bbe337289d9fbeb6119f/pdc_client/config.py#L94-L121 | train |
chriso/gauged | gauged/structures/float_array.py | FloatArray.free | def free(self):
"""Free the underlying C array"""
if self._ptr is None:
return
Gauged.array_free(self.ptr)
FloatArray.ALLOCATIONS -= 1
self._ptr = None | python | def free(self):
"""Free the underlying C array"""
if self._ptr is None:
return
Gauged.array_free(self.ptr)
FloatArray.ALLOCATIONS -= 1
self._ptr = None | [
"def",
"free",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ptr",
"is",
"None",
":",
"return",
"Gauged",
".",
"array_free",
"(",
"self",
".",
"ptr",
")",
"FloatArray",
".",
"ALLOCATIONS",
"-=",
"1",
"self",
".",
"_ptr",
"=",
"None"
] | Free the underlying C array | [
"Free",
"the",
"underlying",
"C",
"array"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/structures/float_array.py#L59-L65 | train |
glormph/msstitch | src/app/actions/mzidtsv/quant.py | generate_psms_quanted | def generate_psms_quanted(quantdb, tsvfn, isob_header, oldheader,
isobaric=False, precursor=False):
"""Takes dbfn and connects, gets quants for each line in tsvfn, sorts
them in line by using keys in quantheader list."""
allquants, sqlfields = quantdb.select_all_psm_quants(isobaric... | python | def generate_psms_quanted(quantdb, tsvfn, isob_header, oldheader,
isobaric=False, precursor=False):
"""Takes dbfn and connects, gets quants for each line in tsvfn, sorts
them in line by using keys in quantheader list."""
allquants, sqlfields = quantdb.select_all_psm_quants(isobaric... | [
"def",
"generate_psms_quanted",
"(",
"quantdb",
",",
"tsvfn",
",",
"isob_header",
",",
"oldheader",
",",
"isobaric",
"=",
"False",
",",
"precursor",
"=",
"False",
")",
":",
"allquants",
",",
"sqlfields",
"=",
"quantdb",
".",
"select_all_psm_quants",
"(",
"isob... | Takes dbfn and connects, gets quants for each line in tsvfn, sorts
them in line by using keys in quantheader list. | [
"Takes",
"dbfn",
"and",
"connects",
"gets",
"quants",
"for",
"each",
"line",
"in",
"tsvfn",
"sorts",
"them",
"in",
"line",
"by",
"using",
"keys",
"in",
"quantheader",
"list",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/quant.py#L5-L36 | train |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_BACKSPACE_CHAR | def t_escaped_BACKSPACE_CHAR(self, t):
r'\x62' # 'b'
t.lexer.pop_state()
t.value = unichr(0x0008)
return t | python | def t_escaped_BACKSPACE_CHAR(self, t):
r'\x62' # 'b'
t.lexer.pop_state()
t.value = unichr(0x0008)
return t | [
"def",
"t_escaped_BACKSPACE_CHAR",
"(",
"self",
",",
"t",
")",
":",
"r'\\x62'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x0008",
")",
"return",
"t"
] | r'\x62 | [
"r",
"\\",
"x62"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L173-L177 | train |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_FORM_FEED_CHAR | def t_escaped_FORM_FEED_CHAR(self, t):
r'\x66' # 'f'
t.lexer.pop_state()
t.value = unichr(0x000c)
return t | python | def t_escaped_FORM_FEED_CHAR(self, t):
r'\x66' # 'f'
t.lexer.pop_state()
t.value = unichr(0x000c)
return t | [
"def",
"t_escaped_FORM_FEED_CHAR",
"(",
"self",
",",
"t",
")",
":",
"r'\\x66'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x000c",
")",
"return",
"t"
] | r'\x66 | [
"r",
"\\",
"x66"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L179-L183 | train |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_CARRIAGE_RETURN_CHAR | def t_escaped_CARRIAGE_RETURN_CHAR(self, t):
r'\x72' # 'r'
t.lexer.pop_state()
t.value = unichr(0x000d)
return t | python | def t_escaped_CARRIAGE_RETURN_CHAR(self, t):
r'\x72' # 'r'
t.lexer.pop_state()
t.value = unichr(0x000d)
return t | [
"def",
"t_escaped_CARRIAGE_RETURN_CHAR",
"(",
"self",
",",
"t",
")",
":",
"r'\\x72'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x000d",
")",
"return",
"t"
] | r'\x72 | [
"r",
"\\",
"x72"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L185-L189 | train |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_LINE_FEED_CHAR | def t_escaped_LINE_FEED_CHAR(self, t):
r'\x6E' # 'n'
t.lexer.pop_state()
t.value = unichr(0x000a)
return t | python | def t_escaped_LINE_FEED_CHAR(self, t):
r'\x6E' # 'n'
t.lexer.pop_state()
t.value = unichr(0x000a)
return t | [
"def",
"t_escaped_LINE_FEED_CHAR",
"(",
"self",
",",
"t",
")",
":",
"r'\\x6E'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x000a",
")",
"return",
"t"
] | r'\x6E | [
"r",
"\\",
"x6E"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L191-L195 | train |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_TAB_CHAR | def t_escaped_TAB_CHAR(self, t):
r'\x74' # 't'
t.lexer.pop_state()
t.value = unichr(0x0009)
return t | python | def t_escaped_TAB_CHAR(self, t):
r'\x74' # 't'
t.lexer.pop_state()
t.value = unichr(0x0009)
return t | [
"def",
"t_escaped_TAB_CHAR",
"(",
"self",
",",
"t",
")",
":",
"r'\\x74'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x0009",
")",
"return",
"t"
] | r'\x74 | [
"r",
"\\",
"x74"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L197-L201 | train |
glormph/msstitch | src/app/readers/mzidplus.py | get_mzid_specfile_ids | def get_mzid_specfile_ids(mzidfn, namespace):
"""Returns mzid spectra data filenames and their IDs used in the
mzIdentML file as a dict. Keys == IDs, values == fns"""
sid_fn = {}
for specdata in mzid_specdata_generator(mzidfn, namespace):
sid_fn[specdata.attrib['id']] = specdata.attrib['name']
... | python | def get_mzid_specfile_ids(mzidfn, namespace):
"""Returns mzid spectra data filenames and their IDs used in the
mzIdentML file as a dict. Keys == IDs, values == fns"""
sid_fn = {}
for specdata in mzid_specdata_generator(mzidfn, namespace):
sid_fn[specdata.attrib['id']] = specdata.attrib['name']
... | [
"def",
"get_mzid_specfile_ids",
"(",
"mzidfn",
",",
"namespace",
")",
":",
"sid_fn",
"=",
"{",
"}",
"for",
"specdata",
"in",
"mzid_specdata_generator",
"(",
"mzidfn",
",",
"namespace",
")",
":",
"sid_fn",
"[",
"specdata",
".",
"attrib",
"[",
"'id'",
"]",
"... | Returns mzid spectra data filenames and their IDs used in the
mzIdentML file as a dict. Keys == IDs, values == fns | [
"Returns",
"mzid",
"spectra",
"data",
"filenames",
"and",
"their",
"IDs",
"used",
"in",
"the",
"mzIdentML",
"file",
"as",
"a",
"dict",
".",
"Keys",
"==",
"IDs",
"values",
"==",
"fns"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/mzidplus.py#L96-L102 | train |
glormph/msstitch | src/app/readers/mzidplus.py | get_specidentitem_percolator_data | def get_specidentitem_percolator_data(item, xmlns):
"""Loop through SpecIdentificationItem children. Find
percolator data by matching to a dict lookup. Return a
dict containing percolator data"""
percomap = {'{0}userParam'.format(xmlns): PERCO_HEADERMAP, }
percodata = {}
for child in item:
... | python | def get_specidentitem_percolator_data(item, xmlns):
"""Loop through SpecIdentificationItem children. Find
percolator data by matching to a dict lookup. Return a
dict containing percolator data"""
percomap = {'{0}userParam'.format(xmlns): PERCO_HEADERMAP, }
percodata = {}
for child in item:
... | [
"def",
"get_specidentitem_percolator_data",
"(",
"item",
",",
"xmlns",
")",
":",
"percomap",
"=",
"{",
"'{0}userParam'",
".",
"format",
"(",
"xmlns",
")",
":",
"PERCO_HEADERMAP",
",",
"}",
"percodata",
"=",
"{",
"}",
"for",
"child",
"in",
"item",
":",
"try... | Loop through SpecIdentificationItem children. Find
percolator data by matching to a dict lookup. Return a
dict containing percolator data | [
"Loop",
"through",
"SpecIdentificationItem",
"children",
".",
"Find",
"percolator",
"data",
"by",
"matching",
"to",
"a",
"dict",
"lookup",
".",
"Return",
"a",
"dict",
"containing",
"percolator",
"data"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/mzidplus.py#L115-L134 | train |
Erotemic/utool | utool/util_sysreq.py | locate_path | def locate_path(dname, recurse_down=True):
""" Search for a path """
tried_fpaths = []
root_dir = os.getcwd()
while root_dir is not None:
dpath = join(root_dir, dname)
if exists(dpath):
return dpath
else:
tried_fpaths.append(dpath)
_new_root = dirn... | python | def locate_path(dname, recurse_down=True):
""" Search for a path """
tried_fpaths = []
root_dir = os.getcwd()
while root_dir is not None:
dpath = join(root_dir, dname)
if exists(dpath):
return dpath
else:
tried_fpaths.append(dpath)
_new_root = dirn... | [
"def",
"locate_path",
"(",
"dname",
",",
"recurse_down",
"=",
"True",
")",
":",
"tried_fpaths",
"=",
"[",
"]",
"root_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"while",
"root_dir",
"is",
"not",
"None",
":",
"dpath",
"=",
"join",
"(",
"root_dir",
",",
... | Search for a path | [
"Search",
"for",
"a",
"path"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sysreq.py#L116-L137 | train |
Erotemic/utool | utool/util_sysreq.py | total_purge_developed_repo | def total_purge_developed_repo(repodir):
r"""
Outputs commands to help purge a repo
Args:
repodir (str): path to developed repository
CommandLine:
python -m utool.util_sysreq total_purge_installed_repo --show
Ignore:
repodir = ut.truepath('~/code/Lasagne')
Example:
... | python | def total_purge_developed_repo(repodir):
r"""
Outputs commands to help purge a repo
Args:
repodir (str): path to developed repository
CommandLine:
python -m utool.util_sysreq total_purge_installed_repo --show
Ignore:
repodir = ut.truepath('~/code/Lasagne')
Example:
... | [
"def",
"total_purge_developed_repo",
"(",
"repodir",
")",
":",
"r",
"assert",
"repodir",
"is",
"not",
"None",
"import",
"utool",
"as",
"ut",
"import",
"os",
"repo",
"=",
"ut",
".",
"util_git",
".",
"Repo",
"(",
"dpath",
"=",
"repodir",
")",
"user",
"=",
... | r"""
Outputs commands to help purge a repo
Args:
repodir (str): path to developed repository
CommandLine:
python -m utool.util_sysreq total_purge_installed_repo --show
Ignore:
repodir = ut.truepath('~/code/Lasagne')
Example:
>>> # DISABLE_DOCTEST
>>> from ... | [
"r",
"Outputs",
"commands",
"to",
"help",
"purge",
"a",
"repo"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sysreq.py#L151-L244 | train |
Erotemic/utool | utool/DynamicStruct.py | DynStruct.add_dict | def add_dict(self, dyn_dict):
'Adds a dictionary to the prefs'
if not isinstance(dyn_dict, dict):
raise Exception('DynStruct.add_dict expects a dictionary.' +
'Recieved: ' + six.text_type(type(dyn_dict)))
for (key, val) in six.iteritems(dyn_dict):
... | python | def add_dict(self, dyn_dict):
'Adds a dictionary to the prefs'
if not isinstance(dyn_dict, dict):
raise Exception('DynStruct.add_dict expects a dictionary.' +
'Recieved: ' + six.text_type(type(dyn_dict)))
for (key, val) in six.iteritems(dyn_dict):
... | [
"def",
"add_dict",
"(",
"self",
",",
"dyn_dict",
")",
":",
"'Adds a dictionary to the prefs'",
"if",
"not",
"isinstance",
"(",
"dyn_dict",
",",
"dict",
")",
":",
"raise",
"Exception",
"(",
"'DynStruct.add_dict expects a dictionary.'",
"+",
"'Recieved: '",
"+",
"six"... | Adds a dictionary to the prefs | [
"Adds",
"a",
"dictionary",
"to",
"the",
"prefs"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/DynamicStruct.py#L52-L58 | train |
Erotemic/utool | utool/DynamicStruct.py | DynStruct.to_dict | def to_dict(self):
"""Converts dynstruct to a dictionary. """
dyn_dict = {}
for (key, val) in six.iteritems(self.__dict__):
if key not in self._printable_exclude:
dyn_dict[key] = val
return dyn_dict | python | def to_dict(self):
"""Converts dynstruct to a dictionary. """
dyn_dict = {}
for (key, val) in six.iteritems(self.__dict__):
if key not in self._printable_exclude:
dyn_dict[key] = val
return dyn_dict | [
"def",
"to_dict",
"(",
"self",
")",
":",
"dyn_dict",
"=",
"{",
"}",
"for",
"(",
"key",
",",
"val",
")",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"__dict__",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_printable_exclude",
":",
"dyn_di... | Converts dynstruct to a dictionary. | [
"Converts",
"dynstruct",
"to",
"a",
"dictionary",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/DynamicStruct.py#L60-L66 | train |
Erotemic/utool | utool/DynamicStruct.py | DynStruct.execstr | def execstr(self, local_name):
"""returns a string which when evaluated will
add the stored variables to the current namespace
localname is the name of the variable in the current scope
* use locals().update(dyn.to_dict()) instead
"""
execstr = ''
for (k... | python | def execstr(self, local_name):
"""returns a string which when evaluated will
add the stored variables to the current namespace
localname is the name of the variable in the current scope
* use locals().update(dyn.to_dict()) instead
"""
execstr = ''
for (k... | [
"def",
"execstr",
"(",
"self",
",",
"local_name",
")",
":",
"execstr",
"=",
"''",
"for",
"(",
"key",
",",
"val",
")",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"__dict__",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_printable_exclude",
... | returns a string which when evaluated will
add the stored variables to the current namespace
localname is the name of the variable in the current scope
* use locals().update(dyn.to_dict()) instead | [
"returns",
"a",
"string",
"which",
"when",
"evaluated",
"will",
"add",
"the",
"stored",
"variables",
"to",
"the",
"current",
"namespace"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/DynamicStruct.py#L88-L99 | train |
glormph/msstitch | src/app/lookups/sqlite/proteingroups.py | ProteinGroupDB.get_proteins_for_peptide | def get_proteins_for_peptide(self, psm_id):
"""Returns list of proteins for a passed psm_id"""
protsql = self.get_sql_select(['protein_acc'], 'protein_psm')
protsql = '{0} WHERE psm_id=?'.format(protsql)
cursor = self.get_cursor()
proteins = cursor.execute(protsql, psm_id).fetcha... | python | def get_proteins_for_peptide(self, psm_id):
"""Returns list of proteins for a passed psm_id"""
protsql = self.get_sql_select(['protein_acc'], 'protein_psm')
protsql = '{0} WHERE psm_id=?'.format(protsql)
cursor = self.get_cursor()
proteins = cursor.execute(protsql, psm_id).fetcha... | [
"def",
"get_proteins_for_peptide",
"(",
"self",
",",
"psm_id",
")",
":",
"protsql",
"=",
"self",
".",
"get_sql_select",
"(",
"[",
"'protein_acc'",
"]",
",",
"'protein_psm'",
")",
"protsql",
"=",
"'{0} WHERE psm_id=?'",
".",
"format",
"(",
"protsql",
")",
"curs... | Returns list of proteins for a passed psm_id | [
"Returns",
"list",
"of",
"proteins",
"for",
"a",
"passed",
"psm_id"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/proteingroups.py#L79-L85 | train |
flyte/xbee-helper | xbee_helper/device.py | raise_if_error | def raise_if_error(frame):
"""
Checks a frame and raises the relevant exception if required.
"""
if "status" not in frame or frame["status"] == b"\x00":
return
codes_and_exceptions = {
b"\x01": exceptions.ZigBeeUnknownError,
b"\x02": exceptions.ZigBeeInvalidCommand,
b... | python | def raise_if_error(frame):
"""
Checks a frame and raises the relevant exception if required.
"""
if "status" not in frame or frame["status"] == b"\x00":
return
codes_and_exceptions = {
b"\x01": exceptions.ZigBeeUnknownError,
b"\x02": exceptions.ZigBeeInvalidCommand,
b... | [
"def",
"raise_if_error",
"(",
"frame",
")",
":",
"if",
"\"status\"",
"not",
"in",
"frame",
"or",
"frame",
"[",
"\"status\"",
"]",
"==",
"b\"\\x00\"",
":",
"return",
"codes_and_exceptions",
"=",
"{",
"b\"\\x01\"",
":",
"exceptions",
".",
"ZigBeeUnknownError",
"... | Checks a frame and raises the relevant exception if required. | [
"Checks",
"a",
"frame",
"and",
"raises",
"the",
"relevant",
"exception",
"if",
"required",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L25-L39 | train |
flyte/xbee-helper | xbee_helper/device.py | hex_to_int | def hex_to_int(value):
"""
Convert hex string like "\x0A\xE3" to 2787.
"""
if version_info.major >= 3:
return int.from_bytes(value, "big")
return int(value.encode("hex"), 16) | python | def hex_to_int(value):
"""
Convert hex string like "\x0A\xE3" to 2787.
"""
if version_info.major >= 3:
return int.from_bytes(value, "big")
return int(value.encode("hex"), 16) | [
"def",
"hex_to_int",
"(",
"value",
")",
":",
"if",
"version_info",
".",
"major",
">=",
"3",
":",
"return",
"int",
".",
"from_bytes",
"(",
"value",
",",
"\"big\"",
")",
"return",
"int",
"(",
"value",
".",
"encode",
"(",
"\"hex\"",
")",
",",
"16",
")"
... | Convert hex string like "\x0A\xE3" to 2787. | [
"Convert",
"hex",
"string",
"like",
"\\",
"x0A",
"\\",
"xE3",
"to",
"2787",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L42-L48 | train |
flyte/xbee-helper | xbee_helper/device.py | adc_to_percentage | def adc_to_percentage(value, max_volts, clamp=True):
"""
Convert the ADC raw value to a percentage.
"""
percentage = (100.0 / const.ADC_MAX_VAL) * value
return max(min(100, percentage), 0) if clamp else percentage | python | def adc_to_percentage(value, max_volts, clamp=True):
"""
Convert the ADC raw value to a percentage.
"""
percentage = (100.0 / const.ADC_MAX_VAL) * value
return max(min(100, percentage), 0) if clamp else percentage | [
"def",
"adc_to_percentage",
"(",
"value",
",",
"max_volts",
",",
"clamp",
"=",
"True",
")",
":",
"percentage",
"=",
"(",
"100.0",
"/",
"const",
".",
"ADC_MAX_VAL",
")",
"*",
"value",
"return",
"max",
"(",
"min",
"(",
"100",
",",
"percentage",
")",
",",... | Convert the ADC raw value to a percentage. | [
"Convert",
"the",
"ADC",
"raw",
"value",
"to",
"a",
"percentage",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L51-L56 | train |
flyte/xbee-helper | xbee_helper/device.py | convert_adc | def convert_adc(value, output_type, max_volts):
"""
Converts the output from the ADC into the desired type.
"""
return {
const.ADC_RAW: lambda x: x,
const.ADC_PERCENTAGE: adc_to_percentage,
const.ADC_VOLTS: adc_to_volts,
const.ADC_MILLIVOLTS: adc_to_millivolts
}[outpu... | python | def convert_adc(value, output_type, max_volts):
"""
Converts the output from the ADC into the desired type.
"""
return {
const.ADC_RAW: lambda x: x,
const.ADC_PERCENTAGE: adc_to_percentage,
const.ADC_VOLTS: adc_to_volts,
const.ADC_MILLIVOLTS: adc_to_millivolts
}[outpu... | [
"def",
"convert_adc",
"(",
"value",
",",
"output_type",
",",
"max_volts",
")",
":",
"return",
"{",
"const",
".",
"ADC_RAW",
":",
"lambda",
"x",
":",
"x",
",",
"const",
".",
"ADC_PERCENTAGE",
":",
"adc_to_percentage",
",",
"const",
".",
"ADC_VOLTS",
":",
... | Converts the output from the ADC into the desired type. | [
"Converts",
"the",
"output",
"from",
"the",
"ADC",
"into",
"the",
"desired",
"type",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L73-L82 | train |
flyte/xbee-helper | xbee_helper/device.py | ZigBee._frame_received | def _frame_received(self, frame):
"""
Put the frame into the _rx_frames dict with a key of the frame_id.
"""
try:
self._rx_frames[frame["frame_id"]] = frame
except KeyError:
# Has no frame_id, ignore?
pass
_LOGGER.debug("Frame received:... | python | def _frame_received(self, frame):
"""
Put the frame into the _rx_frames dict with a key of the frame_id.
"""
try:
self._rx_frames[frame["frame_id"]] = frame
except KeyError:
# Has no frame_id, ignore?
pass
_LOGGER.debug("Frame received:... | [
"def",
"_frame_received",
"(",
"self",
",",
"frame",
")",
":",
"try",
":",
"self",
".",
"_rx_frames",
"[",
"frame",
"[",
"\"frame_id\"",
"]",
"]",
"=",
"frame",
"except",
"KeyError",
":",
"pass",
"_LOGGER",
".",
"debug",
"(",
"\"Frame received: %s\"",
",",... | Put the frame into the _rx_frames dict with a key of the frame_id. | [
"Put",
"the",
"frame",
"into",
"the",
"_rx_frames",
"dict",
"with",
"a",
"key",
"of",
"the",
"frame_id",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L122-L134 | train |
flyte/xbee-helper | xbee_helper/device.py | ZigBee._send | def _send(self, **kwargs):
"""
Send a frame to either the local ZigBee or a remote device.
"""
if kwargs.get("dest_addr_long") is not None:
self.zb.remote_at(**kwargs)
else:
self.zb.at(**kwargs) | python | def _send(self, **kwargs):
"""
Send a frame to either the local ZigBee or a remote device.
"""
if kwargs.get("dest_addr_long") is not None:
self.zb.remote_at(**kwargs)
else:
self.zb.at(**kwargs) | [
"def",
"_send",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"\"dest_addr_long\"",
")",
"is",
"not",
"None",
":",
"self",
".",
"zb",
".",
"remote_at",
"(",
"**",
"kwargs",
")",
"else",
":",
"self",
".",
"zb",
".",
... | Send a frame to either the local ZigBee or a remote device. | [
"Send",
"a",
"frame",
"to",
"either",
"the",
"local",
"ZigBee",
"or",
"a",
"remote",
"device",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L136-L143 | train |
flyte/xbee-helper | xbee_helper/device.py | ZigBee._send_and_wait | def _send_and_wait(self, **kwargs):
"""
Send a frame to either the local ZigBee or a remote device and wait
for a pre-defined amount of time for its response.
"""
frame_id = self.next_frame_id
kwargs.update(dict(frame_id=frame_id))
self._send(**kwargs)
tim... | python | def _send_and_wait(self, **kwargs):
"""
Send a frame to either the local ZigBee or a remote device and wait
for a pre-defined amount of time for its response.
"""
frame_id = self.next_frame_id
kwargs.update(dict(frame_id=frame_id))
self._send(**kwargs)
tim... | [
"def",
"_send_and_wait",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"frame_id",
"=",
"self",
".",
"next_frame_id",
"kwargs",
".",
"update",
"(",
"dict",
"(",
"frame_id",
"=",
"frame_id",
")",
")",
"self",
".",
"_send",
"(",
"**",
"kwargs",
")",
"timeo... | Send a frame to either the local ZigBee or a remote device and wait
for a pre-defined amount of time for its response. | [
"Send",
"a",
"frame",
"to",
"either",
"the",
"local",
"ZigBee",
"or",
"a",
"remote",
"device",
"and",
"wait",
"for",
"a",
"pre",
"-",
"defined",
"amount",
"of",
"time",
"for",
"its",
"response",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L145-L164 | train |
flyte/xbee-helper | xbee_helper/device.py | ZigBee._get_parameter | def _get_parameter(self, parameter, dest_addr_long=None):
"""
Fetches and returns the value of the specified parameter.
"""
frame = self._send_and_wait(
command=parameter, dest_addr_long=dest_addr_long)
return frame["parameter"] | python | def _get_parameter(self, parameter, dest_addr_long=None):
"""
Fetches and returns the value of the specified parameter.
"""
frame = self._send_and_wait(
command=parameter, dest_addr_long=dest_addr_long)
return frame["parameter"] | [
"def",
"_get_parameter",
"(",
"self",
",",
"parameter",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"frame",
"=",
"self",
".",
"_send_and_wait",
"(",
"command",
"=",
"parameter",
",",
"dest_addr_long",
"=",
"dest_addr_long",
")",
"return",
"frame",
"[",
"\... | Fetches and returns the value of the specified parameter. | [
"Fetches",
"and",
"returns",
"the",
"value",
"of",
"the",
"specified",
"parameter",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L166-L172 | train |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.get_sample | def get_sample(self, dest_addr_long=None):
"""
Initiate a sample and return its data.
"""
frame = self._send_and_wait(
command=b"IS", dest_addr_long=dest_addr_long)
if "parameter" in frame:
# @TODO: Is there always one value? Is it always a list?
... | python | def get_sample(self, dest_addr_long=None):
"""
Initiate a sample and return its data.
"""
frame = self._send_and_wait(
command=b"IS", dest_addr_long=dest_addr_long)
if "parameter" in frame:
# @TODO: Is there always one value? Is it always a list?
... | [
"def",
"get_sample",
"(",
"self",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"frame",
"=",
"self",
".",
"_send_and_wait",
"(",
"command",
"=",
"b\"IS\"",
",",
"dest_addr_long",
"=",
"dest_addr_long",
")",
"if",
"\"parameter\"",
"in",
"frame",
":",
"return... | Initiate a sample and return its data. | [
"Initiate",
"a",
"sample",
"and",
"return",
"its",
"data",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L188-L197 | train |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.read_digital_pin | def read_digital_pin(self, pin_number, dest_addr_long=None):
"""
Fetches a sample and returns the boolean value of the requested digital
pin.
"""
sample = self.get_sample(dest_addr_long=dest_addr_long)
try:
return sample[const.DIGITAL_PINS[pin_number]]
... | python | def read_digital_pin(self, pin_number, dest_addr_long=None):
"""
Fetches a sample and returns the boolean value of the requested digital
pin.
"""
sample = self.get_sample(dest_addr_long=dest_addr_long)
try:
return sample[const.DIGITAL_PINS[pin_number]]
... | [
"def",
"read_digital_pin",
"(",
"self",
",",
"pin_number",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"sample",
"=",
"self",
".",
"get_sample",
"(",
"dest_addr_long",
"=",
"dest_addr_long",
")",
"try",
":",
"return",
"sample",
"[",
"const",
".",
"DIGITAL_... | Fetches a sample and returns the boolean value of the requested digital
pin. | [
"Fetches",
"a",
"sample",
"and",
"returns",
"the",
"boolean",
"value",
"of",
"the",
"requested",
"digital",
"pin",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L199-L210 | train |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.set_gpio_pin | def set_gpio_pin(self, pin_number, setting, dest_addr_long=None):
"""
Set a gpio pin setting.
"""
assert setting in const.GPIO_SETTINGS.values()
self._send_and_wait(
command=const.IO_PIN_COMMANDS[pin_number],
parameter=setting.value,
dest_addr_... | python | def set_gpio_pin(self, pin_number, setting, dest_addr_long=None):
"""
Set a gpio pin setting.
"""
assert setting in const.GPIO_SETTINGS.values()
self._send_and_wait(
command=const.IO_PIN_COMMANDS[pin_number],
parameter=setting.value,
dest_addr_... | [
"def",
"set_gpio_pin",
"(",
"self",
",",
"pin_number",
",",
"setting",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"assert",
"setting",
"in",
"const",
".",
"GPIO_SETTINGS",
".",
"values",
"(",
")",
"self",
".",
"_send_and_wait",
"(",
"command",
"=",
"con... | Set a gpio pin setting. | [
"Set",
"a",
"gpio",
"pin",
"setting",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L237-L245 | train |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.get_gpio_pin | def get_gpio_pin(self, pin_number, dest_addr_long=None):
"""
Get a gpio pin setting.
"""
frame = self._send_and_wait(
command=const.IO_PIN_COMMANDS[pin_number],
dest_addr_long=dest_addr_long
)
value = frame["parameter"]
return const.GPIO_SE... | python | def get_gpio_pin(self, pin_number, dest_addr_long=None):
"""
Get a gpio pin setting.
"""
frame = self._send_and_wait(
command=const.IO_PIN_COMMANDS[pin_number],
dest_addr_long=dest_addr_long
)
value = frame["parameter"]
return const.GPIO_SE... | [
"def",
"get_gpio_pin",
"(",
"self",
",",
"pin_number",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"frame",
"=",
"self",
".",
"_send_and_wait",
"(",
"command",
"=",
"const",
".",
"IO_PIN_COMMANDS",
"[",
"pin_number",
"]",
",",
"dest_addr_long",
"=",
"dest_... | Get a gpio pin setting. | [
"Get",
"a",
"gpio",
"pin",
"setting",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L247-L256 | train |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.get_supply_voltage | def get_supply_voltage(self, dest_addr_long=None):
"""
Fetches the value of %V and returns it as volts.
"""
value = self._get_parameter(b"%V", dest_addr_long=dest_addr_long)
return (hex_to_int(value) * (1200/1024.0)) / 1000 | python | def get_supply_voltage(self, dest_addr_long=None):
"""
Fetches the value of %V and returns it as volts.
"""
value = self._get_parameter(b"%V", dest_addr_long=dest_addr_long)
return (hex_to_int(value) * (1200/1024.0)) / 1000 | [
"def",
"get_supply_voltage",
"(",
"self",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"_get_parameter",
"(",
"b\"%V\"",
",",
"dest_addr_long",
"=",
"dest_addr_long",
")",
"return",
"(",
"hex_to_int",
"(",
"value",
")",
"*",
"(",
... | Fetches the value of %V and returns it as volts. | [
"Fetches",
"the",
"value",
"of",
"%V",
"and",
"returns",
"it",
"as",
"volts",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L258-L263 | train |
Erotemic/utool | utool/util_set.py | OrderedSet.add | def add(self, key):
""" Store new key in a new link at the end of the linked list """
if key not in self._map:
self._map[key] = link = _Link()
root = self._root
last = root.prev
link.prev, link.next, link.key = last, root, key
last.next = root.... | python | def add(self, key):
""" Store new key in a new link at the end of the linked list """
if key not in self._map:
self._map[key] = link = _Link()
root = self._root
last = root.prev
link.prev, link.next, link.key = last, root, key
last.next = root.... | [
"def",
"add",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_map",
":",
"self",
".",
"_map",
"[",
"key",
"]",
"=",
"link",
"=",
"_Link",
"(",
")",
"root",
"=",
"self",
".",
"_root",
"last",
"=",
"root",
".",
"prev... | Store new key in a new link at the end of the linked list | [
"Store",
"new",
"key",
"in",
"a",
"new",
"link",
"at",
"the",
"end",
"of",
"the",
"linked",
"list"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_set.py#L43-L50 | train |
Erotemic/utool | utool/util_set.py | OrderedSet.index | def index(self, item):
"""
Find the index of `item` in the OrderedSet
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
>>> self = ut.oset([1, 2, 3])
>>> assert self.index(1) == 0
>>> assert self.index(2) == 1
>>> assert... | python | def index(self, item):
"""
Find the index of `item` in the OrderedSet
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
>>> self = ut.oset([1, 2, 3])
>>> assert self.index(1) == 0
>>> assert self.index(2) == 1
>>> assert... | [
"def",
"index",
"(",
"self",
",",
"item",
")",
":",
"for",
"count",
",",
"other",
"in",
"enumerate",
"(",
"self",
")",
":",
"if",
"item",
"==",
"other",
":",
"return",
"count",
"raise",
"ValueError",
"(",
"'%r is not in OrderedSet'",
"%",
"(",
"item",
... | Find the index of `item` in the OrderedSet
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
>>> self = ut.oset([1, 2, 3])
>>> assert self.index(1) == 0
>>> assert self.index(2) == 1
>>> assert self.index(3) == 2
>>> ut.asse... | [
"Find",
"the",
"index",
"of",
"item",
"in",
"the",
"OrderedSet"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_set.py#L138-L154 | train |
chriso/gauged | gauged/gauged.py | Gauged.value | def value(self, key, timestamp=None, namespace=None):
"""Get the value of a gauge at the specified time"""
return self.make_context(key=key, end=timestamp,
namespace=namespace).value() | python | def value(self, key, timestamp=None, namespace=None):
"""Get the value of a gauge at the specified time"""
return self.make_context(key=key, end=timestamp,
namespace=namespace).value() | [
"def",
"value",
"(",
"self",
",",
"key",
",",
"timestamp",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"key",
"=",
"key",
",",
"end",
"=",
"timestamp",
",",
"namespace",
"=",
"namespace",
")",
"."... | Get the value of a gauge at the specified time | [
"Get",
"the",
"value",
"of",
"a",
"gauge",
"at",
"the",
"specified",
"time"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L68-L71 | train |
chriso/gauged | gauged/gauged.py | Gauged.aggregate | def aggregate(self, key, aggregate, start=None, end=None,
namespace=None, percentile=None):
"""Get an aggregate of all gauge data stored in the specified date
range"""
return self.make_context(key=key, aggregate=aggregate, start=start,
end=end, ... | python | def aggregate(self, key, aggregate, start=None, end=None,
namespace=None, percentile=None):
"""Get an aggregate of all gauge data stored in the specified date
range"""
return self.make_context(key=key, aggregate=aggregate, start=start,
end=end, ... | [
"def",
"aggregate",
"(",
"self",
",",
"key",
",",
"aggregate",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"percentile",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"key",
"=",
"key",... | Get an aggregate of all gauge data stored in the specified date
range | [
"Get",
"an",
"aggregate",
"of",
"all",
"gauge",
"data",
"stored",
"in",
"the",
"specified",
"date",
"range"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L73-L79 | train |
chriso/gauged | gauged/gauged.py | Gauged.value_series | def value_series(self, key, start=None, end=None, interval=None,
namespace=None, cache=None):
"""Get a time series of gauge values"""
return self.make_context(key=key, start=start, end=end,
interval=interval, namespace=namespace,
... | python | def value_series(self, key, start=None, end=None, interval=None,
namespace=None, cache=None):
"""Get a time series of gauge values"""
return self.make_context(key=key, start=start, end=end,
interval=interval, namespace=namespace,
... | [
"def",
"value_series",
"(",
"self",
",",
"key",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"interval",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"cache",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"key",
... | Get a time series of gauge values | [
"Get",
"a",
"time",
"series",
"of",
"gauge",
"values"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L81-L86 | train |
chriso/gauged | gauged/gauged.py | Gauged.aggregate_series | def aggregate_series(self, key, aggregate, start=None, end=None,
interval=None, namespace=None, cache=None,
percentile=None):
"""Get a time series of gauge aggregates"""
return self.make_context(key=key, aggregate=aggregate, start=start,
... | python | def aggregate_series(self, key, aggregate, start=None, end=None,
interval=None, namespace=None, cache=None,
percentile=None):
"""Get a time series of gauge aggregates"""
return self.make_context(key=key, aggregate=aggregate, start=start,
... | [
"def",
"aggregate_series",
"(",
"self",
",",
"key",
",",
"aggregate",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"interval",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"cache",
"=",
"None",
",",
"percentile",
"=",
"None",
")",
":"... | Get a time series of gauge aggregates | [
"Get",
"a",
"time",
"series",
"of",
"gauge",
"aggregates"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L88-L95 | train |
chriso/gauged | gauged/gauged.py | Gauged.keys | def keys(self, prefix=None, limit=None, offset=None, namespace=None):
"""Get gauge keys"""
return self.make_context(prefix=prefix, limit=limit, offset=offset,
namespace=namespace).keys() | python | def keys(self, prefix=None, limit=None, offset=None, namespace=None):
"""Get gauge keys"""
return self.make_context(prefix=prefix, limit=limit, offset=offset,
namespace=namespace).keys() | [
"def",
"keys",
"(",
"self",
",",
"prefix",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"prefix",
"=",
"prefix",
",",
"limit",
"=",
"limit",
... | Get gauge keys | [
"Get",
"gauge",
"keys"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L97-L100 | train |
chriso/gauged | gauged/gauged.py | Gauged.statistics | def statistics(self, start=None, end=None, namespace=None):
"""Get write statistics for the specified namespace and date range"""
return self.make_context(start=start, end=end,
namespace=namespace).statistics() | python | def statistics(self, start=None, end=None, namespace=None):
"""Get write statistics for the specified namespace and date range"""
return self.make_context(start=start, end=end,
namespace=namespace).statistics() | [
"def",
"statistics",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"start",
"=",
"start",
",",
"end",
"=",
"end",
",",
"namespace",
"=",
"namespac... | Get write statistics for the specified namespace and date range | [
"Get",
"write",
"statistics",
"for",
"the",
"specified",
"namespace",
"and",
"date",
"range"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L106-L109 | train |
chriso/gauged | gauged/gauged.py | Gauged.sync | def sync(self):
"""Create the necessary schema"""
self.driver.create_schema()
self.driver.set_metadata({
'current_version': Gauged.VERSION,
'initial_version': Gauged.VERSION,
'block_size': self.config.block_size,
'resolution': self.config.resolutio... | python | def sync(self):
"""Create the necessary schema"""
self.driver.create_schema()
self.driver.set_metadata({
'current_version': Gauged.VERSION,
'initial_version': Gauged.VERSION,
'block_size': self.config.block_size,
'resolution': self.config.resolutio... | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"driver",
".",
"create_schema",
"(",
")",
"self",
".",
"driver",
".",
"set_metadata",
"(",
"{",
"'current_version'",
":",
"Gauged",
".",
"VERSION",
",",
"'initial_version'",
":",
"Gauged",
".",
"VERSION",
... | Create the necessary schema | [
"Create",
"the",
"necessary",
"schema"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L111-L120 | train |
chriso/gauged | gauged/gauged.py | Gauged.make_context | def make_context(self, **kwargs):
"""Create a new context for reading data"""
self.check_schema()
return Context(self.driver, self.config, **kwargs) | python | def make_context(self, **kwargs):
"""Create a new context for reading data"""
self.check_schema()
return Context(self.driver, self.config, **kwargs) | [
"def",
"make_context",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"check_schema",
"(",
")",
"return",
"Context",
"(",
"self",
".",
"driver",
",",
"self",
".",
"config",
",",
"**",
"kwargs",
")"
] | Create a new context for reading data | [
"Create",
"a",
"new",
"context",
"for",
"reading",
"data"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L130-L133 | train |
chriso/gauged | gauged/gauged.py | Gauged.check_schema | def check_schema(self):
"""Check the schema exists and matches configuration"""
if self.valid_schema:
return
config = self.config
metadata = self.metadata()
if 'current_version' not in metadata:
raise GaugedSchemaError('Gauged schema not found, '
... | python | def check_schema(self):
"""Check the schema exists and matches configuration"""
if self.valid_schema:
return
config = self.config
metadata = self.metadata()
if 'current_version' not in metadata:
raise GaugedSchemaError('Gauged schema not found, '
... | [
"def",
"check_schema",
"(",
"self",
")",
":",
"if",
"self",
".",
"valid_schema",
":",
"return",
"config",
"=",
"self",
".",
"config",
"metadata",
"=",
"self",
".",
"metadata",
"(",
")",
"if",
"'current_version'",
"not",
"in",
"metadata",
":",
"raise",
"G... | Check the schema exists and matches configuration | [
"Check",
"the",
"schema",
"exists",
"and",
"matches",
"configuration"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L135-L154 | train |
Erotemic/utool | utool/util_graph.py | nx_dag_node_rank | def nx_dag_node_rank(graph, nodes=None):
"""
Returns rank of nodes that define the "level" each node is on in a
topological sort. This is the same as the Graphviz dot rank.
Ignore:
simple_graph = ut.simplify_graph(exi_graph)
adj_dict = ut.nx_to_adj_dict(simple_graph)
import plot... | python | def nx_dag_node_rank(graph, nodes=None):
"""
Returns rank of nodes that define the "level" each node is on in a
topological sort. This is the same as the Graphviz dot rank.
Ignore:
simple_graph = ut.simplify_graph(exi_graph)
adj_dict = ut.nx_to_adj_dict(simple_graph)
import plot... | [
"def",
"nx_dag_node_rank",
"(",
"graph",
",",
"nodes",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",
"source",
"=",
"list",
"(",
"ut",
".",
"nx_source_nodes",
"(",
"graph",
")",
")",
"[",
"0",
"]",
"longest_paths",
"=",
"dict",
"(",
"[",
"(",... | Returns rank of nodes that define the "level" each node is on in a
topological sort. This is the same as the Graphviz dot rank.
Ignore:
simple_graph = ut.simplify_graph(exi_graph)
adj_dict = ut.nx_to_adj_dict(simple_graph)
import plottool as pt
pt.qt4ensure()
pt.show_nx(... | [
"Returns",
"rank",
"of",
"nodes",
"that",
"define",
"the",
"level",
"each",
"node",
"is",
"on",
"in",
"a",
"topological",
"sort",
".",
"This",
"is",
"the",
"same",
"as",
"the",
"Graphviz",
"dot",
"rank",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L243-L278 | train |
Erotemic/utool | utool/util_graph.py | nx_all_nodes_between | def nx_all_nodes_between(graph, source, target, data=False):
"""
Find all nodes with on paths between source and target.
"""
import utool as ut
if source is None:
# assume there is a single source
sources = list(ut.nx_source_nodes(graph))
assert len(sources) == 1, (
... | python | def nx_all_nodes_between(graph, source, target, data=False):
"""
Find all nodes with on paths between source and target.
"""
import utool as ut
if source is None:
# assume there is a single source
sources = list(ut.nx_source_nodes(graph))
assert len(sources) == 1, (
... | [
"def",
"nx_all_nodes_between",
"(",
"graph",
",",
"source",
",",
"target",
",",
"data",
"=",
"False",
")",
":",
"import",
"utool",
"as",
"ut",
"if",
"source",
"is",
"None",
":",
"sources",
"=",
"list",
"(",
"ut",
".",
"nx_source_nodes",
"(",
"graph",
"... | Find all nodes with on paths between source and target. | [
"Find",
"all",
"nodes",
"with",
"on",
"paths",
"between",
"source",
"and",
"target",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L281-L300 | train |
Erotemic/utool | utool/util_graph.py | nx_all_simple_edge_paths | def nx_all_simple_edge_paths(G, source, target, cutoff=None, keys=False,
data=False):
"""
Returns each path from source to target as a list of edges.
This function is meant to be used with MultiGraphs or MultiDiGraphs.
When ``keys`` is True each edge in the path is returned... | python | def nx_all_simple_edge_paths(G, source, target, cutoff=None, keys=False,
data=False):
"""
Returns each path from source to target as a list of edges.
This function is meant to be used with MultiGraphs or MultiDiGraphs.
When ``keys`` is True each edge in the path is returned... | [
"def",
"nx_all_simple_edge_paths",
"(",
"G",
",",
"source",
",",
"target",
",",
"cutoff",
"=",
"None",
",",
"keys",
"=",
"False",
",",
"data",
"=",
"False",
")",
":",
"if",
"cutoff",
"is",
"None",
":",
"cutoff",
"=",
"len",
"(",
"G",
")",
"-",
"1",... | Returns each path from source to target as a list of edges.
This function is meant to be used with MultiGraphs or MultiDiGraphs.
When ``keys`` is True each edge in the path is returned with its unique key
identifier. In this case it is possible to distinguish between different
paths along different edg... | [
"Returns",
"each",
"path",
"from",
"source",
"to",
"target",
"as",
"a",
"list",
"of",
"edges",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L303-L351 | train |
Erotemic/utool | utool/util_graph.py | nx_delete_node_attr | def nx_delete_node_attr(graph, name, nodes=None):
"""
Removes node attributes
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_node_attributes(G, name='foo', values='bar')
>>> datas = nx.get_node_att... | python | def nx_delete_node_attr(graph, name, nodes=None):
"""
Removes node attributes
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_node_attributes(G, name='foo', values='bar')
>>> datas = nx.get_node_att... | [
"def",
"nx_delete_node_attr",
"(",
"graph",
",",
"name",
",",
"nodes",
"=",
"None",
")",
":",
"if",
"nodes",
"is",
"None",
":",
"nodes",
"=",
"list",
"(",
"graph",
".",
"nodes",
"(",
")",
")",
"removed",
"=",
"0",
"node_dict",
"=",
"nx_node_dict",
"(... | Removes node attributes
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_node_attributes(G, name='foo', values='bar')
>>> datas = nx.get_node_attributes(G, 'club')
>>> assert len(nx.get_node_attribut... | [
"Removes",
"node",
"attributes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L561-L601 | train |
Erotemic/utool | utool/util_graph.py | nx_delete_edge_attr | def nx_delete_edge_attr(graph, name, edges=None):
"""
Removes an attributes from specific edges in the graph
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_edge_attributes(G, name='spam', values='eggs')
... | python | def nx_delete_edge_attr(graph, name, edges=None):
"""
Removes an attributes from specific edges in the graph
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_edge_attributes(G, name='spam', values='eggs')
... | [
"def",
"nx_delete_edge_attr",
"(",
"graph",
",",
"name",
",",
"edges",
"=",
"None",
")",
":",
"removed",
"=",
"0",
"keys",
"=",
"[",
"name",
"]",
"if",
"not",
"isinstance",
"(",
"name",
",",
"(",
"list",
",",
"tuple",
")",
")",
"else",
"name",
"if"... | Removes an attributes from specific edges in the graph
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_edge_attributes(G, name='spam', values='eggs')
>>> nx.set_edge_attributes(G, name='foo', values='bar')
... | [
"Removes",
"an",
"attributes",
"from",
"specific",
"edges",
"in",
"the",
"graph"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L605-L663 | train |
Erotemic/utool | utool/util_graph.py | nx_gen_node_values | def nx_gen_node_values(G, key, nodes, default=util_const.NoParam):
"""
Generates attributes values of specific nodes
"""
node_dict = nx_node_dict(G)
if default is util_const.NoParam:
return (node_dict[n][key] for n in nodes)
else:
return (node_dict[n].get(key, default) for n in n... | python | def nx_gen_node_values(G, key, nodes, default=util_const.NoParam):
"""
Generates attributes values of specific nodes
"""
node_dict = nx_node_dict(G)
if default is util_const.NoParam:
return (node_dict[n][key] for n in nodes)
else:
return (node_dict[n].get(key, default) for n in n... | [
"def",
"nx_gen_node_values",
"(",
"G",
",",
"key",
",",
"nodes",
",",
"default",
"=",
"util_const",
".",
"NoParam",
")",
":",
"node_dict",
"=",
"nx_node_dict",
"(",
"G",
")",
"if",
"default",
"is",
"util_const",
".",
"NoParam",
":",
"return",
"(",
"node_... | Generates attributes values of specific nodes | [
"Generates",
"attributes",
"values",
"of",
"specific",
"nodes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L748-L756 | train |
Erotemic/utool | utool/util_graph.py | nx_gen_node_attrs | def nx_gen_node_attrs(G, key, nodes=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Improved generator version of nx.get_node_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', ... | python | def nx_gen_node_attrs(G, key, nodes=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Improved generator version of nx.get_node_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', ... | [
"def",
"nx_gen_node_attrs",
"(",
"G",
",",
"key",
",",
"nodes",
"=",
"None",
",",
"default",
"=",
"util_const",
".",
"NoParam",
",",
"on_missing",
"=",
"'error'",
",",
"on_keyerr",
"=",
"'default'",
")",
":",
"if",
"on_missing",
"is",
"None",
":",
"on_mi... | Improved generator version of nx.get_node_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', 'filter'}. defaults to 'error'.
on_keyerr (str): Strategy for handling keys missing from node dicts.
Can be {'error', 'defaul... | [
"Improved",
"generator",
"version",
"of",
"nx",
".",
"get_node_attributes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L759-L877 | train |
Erotemic/utool | utool/util_graph.py | nx_gen_edge_values | def nx_gen_edge_values(G, key, edges=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Generates attributes values of specific edges
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default'}. def... | python | def nx_gen_edge_values(G, key, edges=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Generates attributes values of specific edges
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default'}. def... | [
"def",
"nx_gen_edge_values",
"(",
"G",
",",
"key",
",",
"edges",
"=",
"None",
",",
"default",
"=",
"util_const",
".",
"NoParam",
",",
"on_missing",
"=",
"'error'",
",",
"on_keyerr",
"=",
"'default'",
")",
":",
"if",
"edges",
"is",
"None",
":",
"edges",
... | Generates attributes values of specific edges
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default'}. defaults to 'error'.
on_keyerr (str): Strategy for handling keys missing from node dicts.
Can be {'error', 'default'}. defaults to... | [
"Generates",
"attributes",
"values",
"of",
"specific",
"edges"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L880-L916 | train |
Erotemic/utool | utool/util_graph.py | nx_gen_edge_attrs | def nx_gen_edge_attrs(G, key, edges=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Improved generator version of nx.get_edge_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', ... | python | def nx_gen_edge_attrs(G, key, edges=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Improved generator version of nx.get_edge_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', ... | [
"def",
"nx_gen_edge_attrs",
"(",
"G",
",",
"key",
",",
"edges",
"=",
"None",
",",
"default",
"=",
"util_const",
".",
"NoParam",
",",
"on_missing",
"=",
"'error'",
",",
"on_keyerr",
"=",
"'default'",
")",
":",
"if",
"on_missing",
"is",
"None",
":",
"on_mi... | Improved generator version of nx.get_edge_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', 'filter'}. defaults to 'error'.
is on_missing is not error, then we allow any edge even if the
endpoints are not in the g... | [
"Improved",
"generator",
"version",
"of",
"nx",
".",
"get_edge_attributes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L923-L989 | train |
Erotemic/utool | utool/util_graph.py | nx_minimum_weight_component | def nx_minimum_weight_component(graph, weight='weight'):
""" A minimum weight component is an MST + all negative edges """
mwc = nx.minimum_spanning_tree(graph, weight=weight)
# negative edges only reduce the total weight
neg_edges = (e for e, w in nx_gen_edge_attrs(graph, weight) if w < 0)
mwc.add_... | python | def nx_minimum_weight_component(graph, weight='weight'):
""" A minimum weight component is an MST + all negative edges """
mwc = nx.minimum_spanning_tree(graph, weight=weight)
# negative edges only reduce the total weight
neg_edges = (e for e, w in nx_gen_edge_attrs(graph, weight) if w < 0)
mwc.add_... | [
"def",
"nx_minimum_weight_component",
"(",
"graph",
",",
"weight",
"=",
"'weight'",
")",
":",
"mwc",
"=",
"nx",
".",
"minimum_spanning_tree",
"(",
"graph",
",",
"weight",
"=",
"weight",
")",
"neg_edges",
"=",
"(",
"e",
"for",
"e",
",",
"w",
"in",
"nx_gen... | A minimum weight component is an MST + all negative edges | [
"A",
"minimum",
"weight",
"component",
"is",
"an",
"MST",
"+",
"all",
"negative",
"edges"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1037-L1043 | train |
Erotemic/utool | utool/util_graph.py | nx_ensure_agraph_color | def nx_ensure_agraph_color(graph):
""" changes colors to hex strings on graph attrs """
from plottool import color_funcs
import plottool as pt
#import six
def _fix_agraph_color(data):
try:
orig_color = data.get('color', None)
alpha = data.get('alpha', None)
... | python | def nx_ensure_agraph_color(graph):
""" changes colors to hex strings on graph attrs """
from plottool import color_funcs
import plottool as pt
#import six
def _fix_agraph_color(data):
try:
orig_color = data.get('color', None)
alpha = data.get('alpha', None)
... | [
"def",
"nx_ensure_agraph_color",
"(",
"graph",
")",
":",
"from",
"plottool",
"import",
"color_funcs",
"import",
"plottool",
"as",
"pt",
"def",
"_fix_agraph_color",
"(",
"data",
")",
":",
"try",
":",
"orig_color",
"=",
"data",
".",
"get",
"(",
"'color'",
",",... | changes colors to hex strings on graph attrs | [
"changes",
"colors",
"to",
"hex",
"strings",
"on",
"graph",
"attrs"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1075-L1113 | train |
Erotemic/utool | utool/util_graph.py | dag_longest_path | def dag_longest_path(graph, source, target):
"""
Finds the longest path in a dag between two nodes
"""
if source == target:
return [source]
allpaths = nx.all_simple_paths(graph, source, target)
longest_path = []
for l in allpaths:
if len(l) > len(longest_path):
lo... | python | def dag_longest_path(graph, source, target):
"""
Finds the longest path in a dag between two nodes
"""
if source == target:
return [source]
allpaths = nx.all_simple_paths(graph, source, target)
longest_path = []
for l in allpaths:
if len(l) > len(longest_path):
lo... | [
"def",
"dag_longest_path",
"(",
"graph",
",",
"source",
",",
"target",
")",
":",
"if",
"source",
"==",
"target",
":",
"return",
"[",
"source",
"]",
"allpaths",
"=",
"nx",
".",
"all_simple_paths",
"(",
"graph",
",",
"source",
",",
"target",
")",
"longest_... | Finds the longest path in a dag between two nodes | [
"Finds",
"the",
"longest",
"path",
"in",
"a",
"dag",
"between",
"two",
"nodes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1126-L1137 | train |
Erotemic/utool | utool/util_graph.py | simplify_graph | def simplify_graph(graph):
"""
strips out everything but connectivity
Args:
graph (nx.Graph):
Returns:
nx.Graph: new_graph
CommandLine:
python3 -m utool.util_graph simplify_graph --show
python2 -m utool.util_graph simplify_graph --show
python2 -c "import n... | python | def simplify_graph(graph):
"""
strips out everything but connectivity
Args:
graph (nx.Graph):
Returns:
nx.Graph: new_graph
CommandLine:
python3 -m utool.util_graph simplify_graph --show
python2 -m utool.util_graph simplify_graph --show
python2 -c "import n... | [
"def",
"simplify_graph",
"(",
"graph",
")",
":",
"import",
"utool",
"as",
"ut",
"nodes",
"=",
"sorted",
"(",
"list",
"(",
"graph",
".",
"nodes",
"(",
")",
")",
")",
"node_lookup",
"=",
"ut",
".",
"make_index_lookup",
"(",
"nodes",
")",
"if",
"graph",
... | strips out everything but connectivity
Args:
graph (nx.Graph):
Returns:
nx.Graph: new_graph
CommandLine:
python3 -m utool.util_graph simplify_graph --show
python2 -m utool.util_graph simplify_graph --show
python2 -c "import networkx as nx; print(nx.__version__)"
... | [
"strips",
"out",
"everything",
"but",
"connectivity"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1515-L1565 | train |
Erotemic/utool | utool/util_graph.py | subgraph_from_edges | def subgraph_from_edges(G, edge_list, ref_back=True):
"""
Creates a networkx graph that is a subgraph of G
defined by the list of edges in edge_list.
Requires G to be a networkx MultiGraph or MultiDiGraph
edge_list is a list of edges in either (u,v) or (u,v,d) form
where u and v are nodes compr... | python | def subgraph_from_edges(G, edge_list, ref_back=True):
"""
Creates a networkx graph that is a subgraph of G
defined by the list of edges in edge_list.
Requires G to be a networkx MultiGraph or MultiDiGraph
edge_list is a list of edges in either (u,v) or (u,v,d) form
where u and v are nodes compr... | [
"def",
"subgraph_from_edges",
"(",
"G",
",",
"edge_list",
",",
"ref_back",
"=",
"True",
")",
":",
"sub_nodes",
"=",
"list",
"(",
"{",
"y",
"for",
"x",
"in",
"edge_list",
"for",
"y",
"in",
"x",
"[",
"0",
":",
"2",
"]",
"}",
")",
"multi_edge_list",
"... | Creates a networkx graph that is a subgraph of G
defined by the list of edges in edge_list.
Requires G to be a networkx MultiGraph or MultiDiGraph
edge_list is a list of edges in either (u,v) or (u,v,d) form
where u and v are nodes comprising an edge,
and d would be a dictionary of edge attributes
... | [
"Creates",
"a",
"networkx",
"graph",
"that",
"is",
"a",
"subgraph",
"of",
"G",
"defined",
"by",
"the",
"list",
"of",
"edges",
"in",
"edge_list",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1568-L1603 | train |
Erotemic/utool | utool/util_graph.py | all_multi_paths | def all_multi_paths(graph, source, target, data=False):
r"""
Returns specific paths along multi-edges from the source to this table.
Multipaths are identified by edge keys.
Returns all paths from source to target. This function treats multi-edges
as distinct and returns the key value in each edge t... | python | def all_multi_paths(graph, source, target, data=False):
r"""
Returns specific paths along multi-edges from the source to this table.
Multipaths are identified by edge keys.
Returns all paths from source to target. This function treats multi-edges
as distinct and returns the key value in each edge t... | [
"def",
"all_multi_paths",
"(",
"graph",
",",
"source",
",",
"target",
",",
"data",
"=",
"False",
")",
":",
"r",
"path_multiedges",
"=",
"list",
"(",
"nx_all_simple_edge_paths",
"(",
"graph",
",",
"source",
",",
"target",
",",
"keys",
"=",
"True",
",",
"d... | r"""
Returns specific paths along multi-edges from the source to this table.
Multipaths are identified by edge keys.
Returns all paths from source to target. This function treats multi-edges
as distinct and returns the key value in each edge tuple that defines a
path.
Example:
>>> # DI... | [
"r",
"Returns",
"specific",
"paths",
"along",
"multi",
"-",
"edges",
"from",
"the",
"source",
"to",
"this",
"table",
".",
"Multipaths",
"are",
"identified",
"by",
"edge",
"keys",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1613-L1666 | train |
Erotemic/utool | utool/util_graph.py | bfs_conditional | def bfs_conditional(G, source, reverse=False, keys=True, data=False,
yield_nodes=True, yield_if=None,
continue_if=None, visited_nodes=None,
yield_source=False):
"""
Produce edges in a breadth-first-search starting at source, but only return
nodes t... | python | def bfs_conditional(G, source, reverse=False, keys=True, data=False,
yield_nodes=True, yield_if=None,
continue_if=None, visited_nodes=None,
yield_source=False):
"""
Produce edges in a breadth-first-search starting at source, but only return
nodes t... | [
"def",
"bfs_conditional",
"(",
"G",
",",
"source",
",",
"reverse",
"=",
"False",
",",
"keys",
"=",
"True",
",",
"data",
"=",
"False",
",",
"yield_nodes",
"=",
"True",
",",
"yield_if",
"=",
"None",
",",
"continue_if",
"=",
"None",
",",
"visited_nodes",
... | Produce edges in a breadth-first-search starting at source, but only return
nodes that satisfiy a condition, and only iterate past a node if it
satisfies a different condition.
conditions are callables that take (G, child, edge) and return true or false
CommandLine:
python -m utool.util_graph ... | [
"Produce",
"edges",
"in",
"a",
"breadth",
"-",
"first",
"-",
"search",
"starting",
"at",
"source",
"but",
"only",
"return",
"nodes",
"that",
"satisfiy",
"a",
"condition",
"and",
"only",
"iterate",
"past",
"a",
"node",
"if",
"it",
"satisfies",
"a",
"differe... | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1744-L1826 | train |
Erotemic/utool | utool/util_graph.py | color_nodes | def color_nodes(graph, labelattr='label', brightness=.878,
outof=None, sat_adjust=None):
""" Colors edges and nodes by nid """
import plottool as pt
import utool as ut
node_to_lbl = nx.get_node_attributes(graph, labelattr)
unique_lbls = sorted(set(node_to_lbl.values()))
ncolors =... | python | def color_nodes(graph, labelattr='label', brightness=.878,
outof=None, sat_adjust=None):
""" Colors edges and nodes by nid """
import plottool as pt
import utool as ut
node_to_lbl = nx.get_node_attributes(graph, labelattr)
unique_lbls = sorted(set(node_to_lbl.values()))
ncolors =... | [
"def",
"color_nodes",
"(",
"graph",
",",
"labelattr",
"=",
"'label'",
",",
"brightness",
"=",
".878",
",",
"outof",
"=",
"None",
",",
"sat_adjust",
"=",
"None",
")",
":",
"import",
"plottool",
"as",
"pt",
"import",
"utool",
"as",
"ut",
"node_to_lbl",
"="... | Colors edges and nodes by nid | [
"Colors",
"edges",
"and",
"nodes",
"by",
"nid"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1829-L1865 | train |
Erotemic/utool | utool/util_graph.py | approx_min_num_components | def approx_min_num_components(nodes, negative_edges):
"""
Find approximate minimum number of connected components possible
Each edge represents that two nodes must be separated
This code doesn't solve the problem. The problem is NP-complete and
reduces to minimum clique cover (MCC). This is only an... | python | def approx_min_num_components(nodes, negative_edges):
"""
Find approximate minimum number of connected components possible
Each edge represents that two nodes must be separated
This code doesn't solve the problem. The problem is NP-complete and
reduces to minimum clique cover (MCC). This is only an... | [
"def",
"approx_min_num_components",
"(",
"nodes",
",",
"negative_edges",
")",
":",
"import",
"utool",
"as",
"ut",
"num",
"=",
"0",
"g_neg",
"=",
"nx",
".",
"Graph",
"(",
")",
"g_neg",
".",
"add_nodes_from",
"(",
"nodes",
")",
"g_neg",
".",
"add_edges_from"... | Find approximate minimum number of connected components possible
Each edge represents that two nodes must be separated
This code doesn't solve the problem. The problem is NP-complete and
reduces to minimum clique cover (MCC). This is only an approximate
solution. Not sure what the approximation ratio i... | [
"Find",
"approximate",
"minimum",
"number",
"of",
"connected",
"components",
"possible",
"Each",
"edge",
"represents",
"that",
"two",
"nodes",
"must",
"be",
"separated"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L2034-L2122 | train |
walchko/pyrk | pyrk/pyrk.py | RK4.solve | def solve(self, y, h, t_end):
"""
Given a function, initial conditions, step size and end value, this will
calculate an unforced system. The default start time is t=0.0, but this
can be changed.
y - initial state
h - step size
n - stop time
"""
ts = []
ys = []
yi = y
ti = 0.0
while ti < t_end... | python | def solve(self, y, h, t_end):
"""
Given a function, initial conditions, step size and end value, this will
calculate an unforced system. The default start time is t=0.0, but this
can be changed.
y - initial state
h - step size
n - stop time
"""
ts = []
ys = []
yi = y
ti = 0.0
while ti < t_end... | [
"def",
"solve",
"(",
"self",
",",
"y",
",",
"h",
",",
"t_end",
")",
":",
"ts",
"=",
"[",
"]",
"ys",
"=",
"[",
"]",
"yi",
"=",
"y",
"ti",
"=",
"0.0",
"while",
"ti",
"<",
"t_end",
":",
"ts",
".",
"append",
"(",
"ti",
")",
"yi",
"=",
"self",... | Given a function, initial conditions, step size and end value, this will
calculate an unforced system. The default start time is t=0.0, but this
can be changed.
y - initial state
h - step size
n - stop time | [
"Given",
"a",
"function",
"initial",
"conditions",
"step",
"size",
"and",
"end",
"value",
"this",
"will",
"calculate",
"an",
"unforced",
"system",
".",
"The",
"default",
"start",
"time",
"is",
"t",
"=",
"0",
".",
"0",
"but",
"this",
"can",
"be",
"changed... | f75dce843e795343d37cfe20d780989f56f0c418 | https://github.com/walchko/pyrk/blob/f75dce843e795343d37cfe20d780989f56f0c418/pyrk/pyrk.py#L23-L42 | train |
walchko/pyrk | pyrk/pyrk.py | RK4.step | def step(self, y, u, t, h):
"""
This is called by solve, but can be called by the user who wants to
run through an integration with a control force.
y - state at t
u - control inputs at t
t - time
h - step size
"""
k1 = h * self.func(t, y, u)
k2 = h * self.func(t + .5*h, y + .5*h*k1, u)
k3 = h * ... | python | def step(self, y, u, t, h):
"""
This is called by solve, but can be called by the user who wants to
run through an integration with a control force.
y - state at t
u - control inputs at t
t - time
h - step size
"""
k1 = h * self.func(t, y, u)
k2 = h * self.func(t + .5*h, y + .5*h*k1, u)
k3 = h * ... | [
"def",
"step",
"(",
"self",
",",
"y",
",",
"u",
",",
"t",
",",
"h",
")",
":",
"k1",
"=",
"h",
"*",
"self",
".",
"func",
"(",
"t",
",",
"y",
",",
"u",
")",
"k2",
"=",
"h",
"*",
"self",
".",
"func",
"(",
"t",
"+",
".5",
"*",
"h",
",",
... | This is called by solve, but can be called by the user who wants to
run through an integration with a control force.
y - state at t
u - control inputs at t
t - time
h - step size | [
"This",
"is",
"called",
"by",
"solve",
"but",
"can",
"be",
"called",
"by",
"the",
"user",
"who",
"wants",
"to",
"run",
"through",
"an",
"integration",
"with",
"a",
"control",
"force",
"."
] | f75dce843e795343d37cfe20d780989f56f0c418 | https://github.com/walchko/pyrk/blob/f75dce843e795343d37cfe20d780989f56f0c418/pyrk/pyrk.py#L44-L58 | train |
glormph/msstitch | src/app/actions/prottable/bestpeptide.py | generate_proteins | def generate_proteins(pepfn, proteins, pepheader, scorecol, minlog,
higherbetter=True, protcol=False):
"""Best peptide for each protein in a table"""
protein_peptides = {}
if minlog:
higherbetter = False
if not protcol:
protcol = peptabledata.HEADER_MASTERPROTEINS
... | python | def generate_proteins(pepfn, proteins, pepheader, scorecol, minlog,
higherbetter=True, protcol=False):
"""Best peptide for each protein in a table"""
protein_peptides = {}
if minlog:
higherbetter = False
if not protcol:
protcol = peptabledata.HEADER_MASTERPROTEINS
... | [
"def",
"generate_proteins",
"(",
"pepfn",
",",
"proteins",
",",
"pepheader",
",",
"scorecol",
",",
"minlog",
",",
"higherbetter",
"=",
"True",
",",
"protcol",
"=",
"False",
")",
":",
"protein_peptides",
"=",
"{",
"}",
"if",
"minlog",
":",
"higherbetter",
"... | Best peptide for each protein in a table | [
"Best",
"peptide",
"for",
"each",
"protein",
"in",
"a",
"table"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/bestpeptide.py#L8-L46 | train |
LEMS/pylems | lems/model/simulation.py | Simulation.add | def add(self, child):
"""
Adds a typed child object to the simulation spec.
@param child: Child object to be added.
"""
if isinstance(child, Run):
self.add_run(child)
elif isinstance(child, Record):
self.add_record(child)
elif isinstance(... | python | def add(self, child):
"""
Adds a typed child object to the simulation spec.
@param child: Child object to be added.
"""
if isinstance(child, Run):
self.add_run(child)
elif isinstance(child, Record):
self.add_record(child)
elif isinstance(... | [
"def",
"add",
"(",
"self",
",",
"child",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"Run",
")",
":",
"self",
".",
"add_run",
"(",
"child",
")",
"elif",
"isinstance",
"(",
"child",
",",
"Record",
")",
":",
"self",
".",
"add_record",
"(",
"chil... | Adds a typed child object to the simulation spec.
@param child: Child object to be added. | [
"Adds",
"a",
"typed",
"child",
"object",
"to",
"the",
"simulation",
"spec",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/simulation.py#L345-L365 | train |
steveYeah/PyBomb | pybomb/clients/game_client.py | GameClient.fetch | def fetch(self, id_, return_fields=None):
"""
Wrapper for fetching details of game by ID
:param id_: int
:param return_fields: tuple
:return: pybomb.clients.Response
"""
game_params = {"id": id_}
if return_fields is not None:
self._validate_... | python | def fetch(self, id_, return_fields=None):
"""
Wrapper for fetching details of game by ID
:param id_: int
:param return_fields: tuple
:return: pybomb.clients.Response
"""
game_params = {"id": id_}
if return_fields is not None:
self._validate_... | [
"def",
"fetch",
"(",
"self",
",",
"id_",
",",
"return_fields",
"=",
"None",
")",
":",
"game_params",
"=",
"{",
"\"id\"",
":",
"id_",
"}",
"if",
"return_fields",
"is",
"not",
"None",
":",
"self",
".",
"_validate_return_fields",
"(",
"return_fields",
")",
... | Wrapper for fetching details of game by ID
:param id_: int
:param return_fields: tuple
:return: pybomb.clients.Response | [
"Wrapper",
"for",
"fetching",
"details",
"of",
"game",
"by",
"ID"
] | 54045d74e642f8a1c4366c24bd6a330ae3da6257 | https://github.com/steveYeah/PyBomb/blob/54045d74e642f8a1c4366c24bd6a330ae3da6257/pybomb/clients/game_client.py#L57-L76 | train |
glormph/msstitch | src/app/drivers/base.py | BaseDriver.define_options | def define_options(self, names, parser_options=None):
"""Given a list of option names, this returns a list of dicts
defined in all_options and self.shared_options. These can then
be used to populate the argparser with"""
def copy_option(options, name):
return {k: v for k, v i... | python | def define_options(self, names, parser_options=None):
"""Given a list of option names, this returns a list of dicts
defined in all_options and self.shared_options. These can then
be used to populate the argparser with"""
def copy_option(options, name):
return {k: v for k, v i... | [
"def",
"define_options",
"(",
"self",
",",
"names",
",",
"parser_options",
"=",
"None",
")",
":",
"def",
"copy_option",
"(",
"options",
",",
"name",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"options",
"[",
"name",
"]",
".... | Given a list of option names, this returns a list of dicts
defined in all_options and self.shared_options. These can then
be used to populate the argparser with | [
"Given",
"a",
"list",
"of",
"option",
"names",
"this",
"returns",
"a",
"list",
"of",
"dicts",
"defined",
"in",
"all_options",
"and",
"self",
".",
"shared_options",
".",
"These",
"can",
"then",
"be",
"used",
"to",
"populate",
"the",
"argparser",
"with"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/base.py#L30-L48 | train |
Erotemic/utool | utool/util_resources.py | current_memory_usage | def current_memory_usage():
"""
Returns this programs current memory usage in bytes
"""
import psutil
proc = psutil.Process(os.getpid())
#meminfo = proc.get_memory_info()
meminfo = proc.memory_info()
rss = meminfo[0] # Resident Set Size / Mem Usage
vms = meminfo[1] # Virtual Memory... | python | def current_memory_usage():
"""
Returns this programs current memory usage in bytes
"""
import psutil
proc = psutil.Process(os.getpid())
#meminfo = proc.get_memory_info()
meminfo = proc.memory_info()
rss = meminfo[0] # Resident Set Size / Mem Usage
vms = meminfo[1] # Virtual Memory... | [
"def",
"current_memory_usage",
"(",
")",
":",
"import",
"psutil",
"proc",
"=",
"psutil",
".",
"Process",
"(",
"os",
".",
"getpid",
"(",
")",
")",
"meminfo",
"=",
"proc",
".",
"memory_info",
"(",
")",
"rss",
"=",
"meminfo",
"[",
"0",
"]",
"vms",
"=",
... | Returns this programs current memory usage in bytes | [
"Returns",
"this",
"programs",
"current",
"memory",
"usage",
"in",
"bytes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_resources.py#L120-L130 | train |
Erotemic/utool | utool/util_resources.py | num_unused_cpus | def num_unused_cpus(thresh=10):
"""
Returns the number of cpus with utilization less than `thresh` percent
"""
import psutil
cpu_usage = psutil.cpu_percent(percpu=True)
return sum([p < thresh for p in cpu_usage]) | python | def num_unused_cpus(thresh=10):
"""
Returns the number of cpus with utilization less than `thresh` percent
"""
import psutil
cpu_usage = psutil.cpu_percent(percpu=True)
return sum([p < thresh for p in cpu_usage]) | [
"def",
"num_unused_cpus",
"(",
"thresh",
"=",
"10",
")",
":",
"import",
"psutil",
"cpu_usage",
"=",
"psutil",
".",
"cpu_percent",
"(",
"percpu",
"=",
"True",
")",
"return",
"sum",
"(",
"[",
"p",
"<",
"thresh",
"for",
"p",
"in",
"cpu_usage",
"]",
")"
] | Returns the number of cpus with utilization less than `thresh` percent | [
"Returns",
"the",
"number",
"of",
"cpus",
"with",
"utilization",
"less",
"than",
"thresh",
"percent"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_resources.py#L185-L191 | train |
glormph/msstitch | src/app/actions/mslookup/proteingrouping.py | get_protein_group_content | def get_protein_group_content(pgmap, master):
"""For each master protein, we generate the protein group proteins
complete with sequences, psm_ids and scores. Master proteins are included
in this group.
Returns a list of [protein, master, pep_hits, psm_hits, protein_score],
which is ready to enter t... | python | def get_protein_group_content(pgmap, master):
"""For each master protein, we generate the protein group proteins
complete with sequences, psm_ids and scores. Master proteins are included
in this group.
Returns a list of [protein, master, pep_hits, psm_hits, protein_score],
which is ready to enter t... | [
"def",
"get_protein_group_content",
"(",
"pgmap",
",",
"master",
")",
":",
"pg_content",
"=",
"[",
"[",
"0",
",",
"master",
",",
"protein",
",",
"len",
"(",
"peptides",
")",
",",
"len",
"(",
"[",
"psm",
"for",
"pgpsms",
"in",
"peptides",
".",
"values",... | For each master protein, we generate the protein group proteins
complete with sequences, psm_ids and scores. Master proteins are included
in this group.
Returns a list of [protein, master, pep_hits, psm_hits, protein_score],
which is ready to enter the DB table. | [
"For",
"each",
"master",
"protein",
"we",
"generate",
"the",
"protein",
"group",
"proteins",
"complete",
"with",
"sequences",
"psm_ids",
"and",
"scores",
".",
"Master",
"proteins",
"are",
"included",
"in",
"this",
"group",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteingrouping.py#L180-L200 | train |
glormph/msstitch | src/app/actions/peptable/merge.py | get_protein_data | def get_protein_data(peptide, pdata, headerfields, accfield):
"""These fields are currently not pool dependent so headerfields
is ignored"""
report = get_proteins(peptide, pdata, headerfields)
return get_cov_descriptions(peptide, pdata, report) | python | def get_protein_data(peptide, pdata, headerfields, accfield):
"""These fields are currently not pool dependent so headerfields
is ignored"""
report = get_proteins(peptide, pdata, headerfields)
return get_cov_descriptions(peptide, pdata, report) | [
"def",
"get_protein_data",
"(",
"peptide",
",",
"pdata",
",",
"headerfields",
",",
"accfield",
")",
":",
"report",
"=",
"get_proteins",
"(",
"peptide",
",",
"pdata",
",",
"headerfields",
")",
"return",
"get_cov_descriptions",
"(",
"peptide",
",",
"pdata",
",",... | These fields are currently not pool dependent so headerfields
is ignored | [
"These",
"fields",
"are",
"currently",
"not",
"pool",
"dependent",
"so",
"headerfields",
"is",
"ignored"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/peptable/merge.py#L81-L85 | train |
Erotemic/utool | utool/util_progress.py | get_num_chunks | def get_num_chunks(length, chunksize):
r"""
Returns the number of chunks that a list will be split into given a
chunksize.
Args:
length (int):
chunksize (int):
Returns:
int: n_chunks
CommandLine:
python -m utool.util_progress --exec-get_num_chunks:0
Exampl... | python | def get_num_chunks(length, chunksize):
r"""
Returns the number of chunks that a list will be split into given a
chunksize.
Args:
length (int):
chunksize (int):
Returns:
int: n_chunks
CommandLine:
python -m utool.util_progress --exec-get_num_chunks:0
Exampl... | [
"def",
"get_num_chunks",
"(",
"length",
",",
"chunksize",
")",
":",
"r",
"n_chunks",
"=",
"int",
"(",
"math",
".",
"ceil",
"(",
"length",
"/",
"chunksize",
")",
")",
"return",
"n_chunks"
] | r"""
Returns the number of chunks that a list will be split into given a
chunksize.
Args:
length (int):
chunksize (int):
Returns:
int: n_chunks
CommandLine:
python -m utool.util_progress --exec-get_num_chunks:0
Example0:
>>> # ENABLE_DOCTEST
>>... | [
"r",
"Returns",
"the",
"number",
"of",
"chunks",
"that",
"a",
"list",
"will",
"be",
"split",
"into",
"given",
"a",
"chunksize",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L116-L142 | train |
Erotemic/utool | utool/util_progress.py | ProgChunks | def ProgChunks(list_, chunksize, nInput=None, **kwargs):
"""
Yeilds an iterator in chunks and computes progress
Progress version of ut.ichunks
Args:
list_ (list):
chunksize (?):
nInput (None): (default = None)
Kwargs:
length, freq
Returns:
ProgressIter:... | python | def ProgChunks(list_, chunksize, nInput=None, **kwargs):
"""
Yeilds an iterator in chunks and computes progress
Progress version of ut.ichunks
Args:
list_ (list):
chunksize (?):
nInput (None): (default = None)
Kwargs:
length, freq
Returns:
ProgressIter:... | [
"def",
"ProgChunks",
"(",
"list_",
",",
"chunksize",
",",
"nInput",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"nInput",
"is",
"None",
":",
"nInput",
"=",
"len",
"(",
"list_",
")",
"n_chunks",
"=",
"get_num_chunks",
"(",
"nInput",
",",
"chunksiz... | Yeilds an iterator in chunks and computes progress
Progress version of ut.ichunks
Args:
list_ (list):
chunksize (?):
nInput (None): (default = None)
Kwargs:
length, freq
Returns:
ProgressIter: progiter_
CommandLine:
python -m utool.util_progress Pr... | [
"Yeilds",
"an",
"iterator",
"in",
"chunks",
"and",
"computes",
"progress",
"Progress",
"version",
"of",
"ut",
".",
"ichunks"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L145-L186 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.