repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
eaton-lab/toytree
toytree/newick.py
_get_features_string
def _get_features_string(self, features=None): """ Generates the extended newick string NHX with extra data about a node.""" string = "" if features is None: features = [] elif features == []: features = self.features for pr in features: if hasattr(self, pr): raw...
python
def _get_features_string(self, features=None): """ Generates the extended newick string NHX with extra data about a node.""" string = "" if features is None: features = [] elif features == []: features = self.features for pr in features: if hasattr(self, pr): raw...
[ "def", "_get_features_string", "(", "self", ",", "features", "=", "None", ")", ":", "string", "=", "\"\"", "if", "features", "is", "None", ":", "features", "=", "[", "]", "elif", "features", "==", "[", "]", ":", "features", "=", "self", ".", "features"...
Generates the extended newick string NHX with extra data about a node.
[ "Generates", "the", "extended", "newick", "string", "NHX", "with", "extra", "data", "about", "a", "node", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L405-L434
doakey3/DashTable
dashtable/data2md/get_column_width.py
get_column_width
def get_column_width(column, table): """ Get the character width of a column in a table Parameters ---------- column : int The column index analyze table : list of lists of str The table of rows of strings. For this to be accurate, each string must only be 1 line long. ...
python
def get_column_width(column, table): """ Get the character width of a column in a table Parameters ---------- column : int The column index analyze table : list of lists of str The table of rows of strings. For this to be accurate, each string must only be 1 line long. ...
[ "def", "get_column_width", "(", "column", ",", "table", ")", ":", "width", "=", "3", "for", "row", "in", "range", "(", "len", "(", "table", ")", ")", ":", "cell_width", "=", "len", "(", "table", "[", "row", "]", "[", "column", "]", ")", "if", "ce...
Get the character width of a column in a table Parameters ---------- column : int The column index analyze table : list of lists of str The table of rows of strings. For this to be accurate, each string must only be 1 line long. Returns ------- width : int
[ "Get", "the", "character", "width", "of", "a", "column", "in", "a", "table" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2md/get_column_width.py#L1-L24
eaton-lab/toytree
toytree/html.py
get_text_mark
def get_text_mark(ttree): """ makes a simple Text Mark object""" if ttree._orient in ["right"]: angle = 0. ypos = ttree.verts[-1*len(ttree.tree):, 1] if ttree._kwargs["tip_labels_align"]: xpos = [ttree.verts[:, 0].max()] * len(ttree.tree) start = xpos ...
python
def get_text_mark(ttree): """ makes a simple Text Mark object""" if ttree._orient in ["right"]: angle = 0. ypos = ttree.verts[-1*len(ttree.tree):, 1] if ttree._kwargs["tip_labels_align"]: xpos = [ttree.verts[:, 0].max()] * len(ttree.tree) start = xpos ...
[ "def", "get_text_mark", "(", "ttree", ")", ":", "if", "ttree", ".", "_orient", "in", "[", "\"right\"", "]", ":", "angle", "=", "0.", "ypos", "=", "ttree", ".", "verts", "[", "-", "1", "*", "len", "(", "ttree", ".", "tree", ")", ":", ",", "1", "...
makes a simple Text Mark object
[ "makes", "a", "simple", "Text", "Mark", "object" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/html.py#L196-L253
eaton-lab/toytree
toytree/html.py
get_edge_mark
def get_edge_mark(ttree): """ makes a simple Graph Mark object""" ## tree style if ttree._kwargs["tree_style"] in ["c", "cladogram"]: a=ttree.edges vcoordinates=ttree.verts else: a=ttree._lines vcoordinates=ttree._coords ## fixed args a...
python
def get_edge_mark(ttree): """ makes a simple Graph Mark object""" ## tree style if ttree._kwargs["tree_style"] in ["c", "cladogram"]: a=ttree.edges vcoordinates=ttree.verts else: a=ttree._lines vcoordinates=ttree._coords ## fixed args a...
[ "def", "get_edge_mark", "(", "ttree", ")", ":", "## tree style", "if", "ttree", ".", "_kwargs", "[", "\"tree_style\"", "]", "in", "[", "\"c\"", ",", "\"cladogram\"", "]", ":", "a", "=", "ttree", ".", "edges", "vcoordinates", "=", "ttree", ".", "verts", "...
makes a simple Graph Mark object
[ "makes", "a", "simple", "Graph", "Mark", "object" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/html.py#L257-L363
eaton-lab/toytree
toytree/html.py
split_styles
def split_styles(mark): """ get shared styles """ markers = [mark._table[key] for key in mark._marker][0] nstyles = [] for m in markers: ## fill and stroke are already rgb() since already in markers msty = toyplot.style.combine({ "fill": m.mstyle['fill'], "st...
python
def split_styles(mark): """ get shared styles """ markers = [mark._table[key] for key in mark._marker][0] nstyles = [] for m in markers: ## fill and stroke are already rgb() since already in markers msty = toyplot.style.combine({ "fill": m.mstyle['fill'], "st...
[ "def", "split_styles", "(", "mark", ")", ":", "markers", "=", "[", "mark", ".", "_table", "[", "key", "]", "for", "key", "in", "mark", ".", "_marker", "]", "[", "0", "]", "nstyles", "=", "[", "]", "for", "m", "in", "markers", ":", "## fill and stro...
get shared styles
[ "get", "shared", "styles" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/html.py#L373-L447
doakey3/DashTable
dashtable/data2rst/cell/center_cell_text.py
center_cell_text
def center_cell_text(cell): """ Horizontally center the text within a cell's grid Like this:: +---------+ +---------+ | foo | --> | foo | +---------+ +---------+ Parameters ---------- cell : dashtable.data2rst.Cell Returns ------- cell : da...
python
def center_cell_text(cell): """ Horizontally center the text within a cell's grid Like this:: +---------+ +---------+ | foo | --> | foo | +---------+ +---------+ Parameters ---------- cell : dashtable.data2rst.Cell Returns ------- cell : da...
[ "def", "center_cell_text", "(", "cell", ")", ":", "lines", "=", "cell", ".", "text", ".", "split", "(", "'\\n'", ")", "cell_width", "=", "len", "(", "lines", "[", "0", "]", ")", "-", "2", "truncated_lines", "=", "[", "''", "]", "for", "i", "in", ...
Horizontally center the text within a cell's grid Like this:: +---------+ +---------+ | foo | --> | foo | +---------+ +---------+ Parameters ---------- cell : dashtable.data2rst.Cell Returns ------- cell : dashtable.data2rst.Cell
[ "Horizontally", "center", "the", "text", "within", "a", "cell", "s", "grid" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/center_cell_text.py#L4-L50
Lilykos/pyphonetics
pyphonetics/distance_metrics/hamming.py
hamming_distance
def hamming_distance(word1, word2): """ Computes the Hamming distance. [Reference]: https://en.wikipedia.org/wiki/Hamming_distance [Article]: Hamming, Richard W. (1950), "Error detecting and error correcting codes", Bell System Technical Journal 29 (2): 147–160 """ from operator import ...
python
def hamming_distance(word1, word2): """ Computes the Hamming distance. [Reference]: https://en.wikipedia.org/wiki/Hamming_distance [Article]: Hamming, Richard W. (1950), "Error detecting and error correcting codes", Bell System Technical Journal 29 (2): 147–160 """ from operator import ...
[ "def", "hamming_distance", "(", "word1", ",", "word2", ")", ":", "from", "operator", "import", "ne", "if", "len", "(", "word1", ")", "!=", "len", "(", "word2", ")", ":", "raise", "WrongLengthException", "(", "'The words need to be of the same length!'", ")", "...
Computes the Hamming distance. [Reference]: https://en.wikipedia.org/wiki/Hamming_distance [Article]: Hamming, Richard W. (1950), "Error detecting and error correcting codes", Bell System Technical Journal 29 (2): 147–160
[ "Computes", "the", "Hamming", "distance", "." ]
train
https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/distance_metrics/hamming.py#L4-L16
quantmind/dynts
dynts/utils/populate.py
polygen
def polygen(*coefficients): '''Polynomial generating function''' if not coefficients: return lambda i: 0 else: c0 = coefficients[0] coefficients = coefficients[1:] def _(i): v = c0 for c in coefficients: v += c*i ...
python
def polygen(*coefficients): '''Polynomial generating function''' if not coefficients: return lambda i: 0 else: c0 = coefficients[0] coefficients = coefficients[1:] def _(i): v = c0 for c in coefficients: v += c*i ...
[ "def", "polygen", "(", "*", "coefficients", ")", ":", "if", "not", "coefficients", ":", "return", "lambda", "i", ":", "0", "else", ":", "c0", "=", "coefficients", "[", "0", "]", "coefficients", "=", "coefficients", "[", "1", ":", "]", "def", "_", "("...
Polynomial generating function
[ "Polynomial", "generating", "function" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/populate.py#L34-L49
quantmind/dynts
dynts/api/main.py
timeseries
def timeseries(name='', backend=None, date=None, data=None, **kwargs): '''Create a new :class:`dynts.TimeSeries` instance using a ``backend`` and populating it with provided the data. :parameter name: optional timeseries name. For multivarate timeseries the :func:`dynts.tsname` ut...
python
def timeseries(name='', backend=None, date=None, data=None, **kwargs): '''Create a new :class:`dynts.TimeSeries` instance using a ``backend`` and populating it with provided the data. :parameter name: optional timeseries name. For multivarate timeseries the :func:`dynts.tsname` ut...
[ "def", "timeseries", "(", "name", "=", "''", ",", "backend", "=", "None", ",", "date", "=", "None", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "backend", "=", "backend", "or", "settings", ".", "backend", "TS", "=", "BACKENDS", "."...
Create a new :class:`dynts.TimeSeries` instance using a ``backend`` and populating it with provided the data. :parameter name: optional timeseries name. For multivarate timeseries the :func:`dynts.tsname` utility function can be used to build it. :parameter b...
[ "Create", "a", "new", ":", "class", ":", "dynts", ".", "TimeSeries", "instance", "using", "a", "backend", "and", "populating", "it", "with", "provided", "the", "data", ".", ":", "parameter", "name", ":", "optional", "timeseries", "name", ".", "For", "multi...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/main.py#L7-L25
doakey3/DashTable
dashtable/dashutils/ensure_table_strings.py
ensure_table_strings
def ensure_table_strings(table): """ Force each cell in the table to be a string Parameters ---------- table : list of lists Returns ------- table : list of lists of str """ for row in range(len(table)): for column in range(len(table[row])): table[row][colum...
python
def ensure_table_strings(table): """ Force each cell in the table to be a string Parameters ---------- table : list of lists Returns ------- table : list of lists of str """ for row in range(len(table)): for column in range(len(table[row])): table[row][colum...
[ "def", "ensure_table_strings", "(", "table", ")", ":", "for", "row", "in", "range", "(", "len", "(", "table", ")", ")", ":", "for", "column", "in", "range", "(", "len", "(", "table", "[", "row", "]", ")", ")", ":", "table", "[", "row", "]", "[", ...
Force each cell in the table to be a string Parameters ---------- table : list of lists Returns ------- table : list of lists of str
[ "Force", "each", "cell", "in", "the", "table", "to", "be", "a", "string" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/ensure_table_strings.py#L1-L16
doakey3/DashTable
dashtable/data2rst/cell/cell.py
Cell.left_sections
def left_sections(self): """ The number of sections that touch the left side. During merging, the cell's text will grow to include other cells. This property keeps track of the number of sections that are touching the left side. For example:: +-----+----...
python
def left_sections(self): """ The number of sections that touch the left side. During merging, the cell's text will grow to include other cells. This property keeps track of the number of sections that are touching the left side. For example:: +-----+----...
[ "def", "left_sections", "(", "self", ")", ":", "lines", "=", "self", ".", "text", ".", "split", "(", "'\\n'", ")", "sections", "=", "0", "for", "i", "in", "range", "(", "len", "(", "lines", ")", ")", ":", "if", "lines", "[", "i", "]", ".", "sta...
The number of sections that touch the left side. During merging, the cell's text will grow to include other cells. This property keeps track of the number of sections that are touching the left side. For example:: +-----+-----+ section --> | foo | dog | <-- ...
[ "The", "number", "of", "sections", "that", "touch", "the", "left", "side", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L37-L66
doakey3/DashTable
dashtable/data2rst/cell/cell.py
Cell.right_sections
def right_sections(self): """ The number of sections that touch the right side. Returns ------- sections : int The number of sections on the right """ lines = self.text.split('\n') sections = 0 for i in range(len(lines)): i...
python
def right_sections(self): """ The number of sections that touch the right side. Returns ------- sections : int The number of sections on the right """ lines = self.text.split('\n') sections = 0 for i in range(len(lines)): i...
[ "def", "right_sections", "(", "self", ")", ":", "lines", "=", "self", ".", "text", ".", "split", "(", "'\\n'", ")", "sections", "=", "0", "for", "i", "in", "range", "(", "len", "(", "lines", ")", ")", ":", "if", "lines", "[", "i", "]", ".", "en...
The number of sections that touch the right side. Returns ------- sections : int The number of sections on the right
[ "The", "number", "of", "sections", "that", "touch", "the", "right", "side", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L69-L83
doakey3/DashTable
dashtable/data2rst/cell/cell.py
Cell.top_sections
def top_sections(self): """ The number of sections that touch the top side. Returns ------- sections : int The number of sections on the top """ top_line = self.text.split('\n')[0] sections = len(top_line.split('+')) - 2 return secti...
python
def top_sections(self): """ The number of sections that touch the top side. Returns ------- sections : int The number of sections on the top """ top_line = self.text.split('\n')[0] sections = len(top_line.split('+')) - 2 return secti...
[ "def", "top_sections", "(", "self", ")", ":", "top_line", "=", "self", ".", "text", ".", "split", "(", "'\\n'", ")", "[", "0", "]", "sections", "=", "len", "(", "top_line", ".", "split", "(", "'+'", ")", ")", "-", "2", "return", "sections" ]
The number of sections that touch the top side. Returns ------- sections : int The number of sections on the top
[ "The", "number", "of", "sections", "that", "touch", "the", "top", "side", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L86-L99
doakey3/DashTable
dashtable/data2rst/cell/cell.py
Cell.bottom_sections
def bottom_sections(self): """ The number of cells that touch the bottom side. Returns ------- sections : int The number of sections on the top """ bottom_line = self.text.split('\n')[-1] sections = len(bottom_line.split('+')) - 2 ret...
python
def bottom_sections(self): """ The number of cells that touch the bottom side. Returns ------- sections : int The number of sections on the top """ bottom_line = self.text.split('\n')[-1] sections = len(bottom_line.split('+')) - 2 ret...
[ "def", "bottom_sections", "(", "self", ")", ":", "bottom_line", "=", "self", ".", "text", ".", "split", "(", "'\\n'", ")", "[", "-", "1", "]", "sections", "=", "len", "(", "bottom_line", ".", "split", "(", "'+'", ")", ")", "-", "2", "return", "sect...
The number of cells that touch the bottom side. Returns ------- sections : int The number of sections on the top
[ "The", "number", "of", "cells", "that", "touch", "the", "bottom", "side", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L102-L114
doakey3/DashTable
dashtable/data2rst/cell/cell.py
Cell.is_header
def is_header(self): """ Whether or not the cell is a header Any header cell will have "=" instead of "-" on its border. For example, this is a header cell:: +-----+ | foo | +=====+ while this cell is not:: +-----+ ...
python
def is_header(self): """ Whether or not the cell is a header Any header cell will have "=" instead of "-" on its border. For example, this is a header cell:: +-----+ | foo | +=====+ while this cell is not:: +-----+ ...
[ "def", "is_header", "(", "self", ")", ":", "bottom_line", "=", "self", ".", "text", ".", "split", "(", "'\\n'", ")", "[", "-", "1", "]", "if", "is_only", "(", "bottom_line", ",", "[", "'+'", ",", "'='", "]", ")", ":", "return", "True", "return", ...
Whether or not the cell is a header Any header cell will have "=" instead of "-" on its border. For example, this is a header cell:: +-----+ | foo | +=====+ while this cell is not:: +-----+ | foo | +-----+ Retu...
[ "Whether", "or", "not", "the", "cell", "is", "a", "header" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L117-L145
quantmind/dynts
dynts/utils/version.py
get_git_changeset
def get_git_changeset(filename=None): """Returns a numeric identifier of the latest git changeset. The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. This value isn't guaranteed to be unique, but collisions are very unlikely, so it's sufficient for generating the developmen...
python
def get_git_changeset(filename=None): """Returns a numeric identifier of the latest git changeset. The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. This value isn't guaranteed to be unique, but collisions are very unlikely, so it's sufficient for generating the developmen...
[ "def", "get_git_changeset", "(", "filename", "=", "None", ")", ":", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "filename", "or", "__file__", ")", "git_show", "=", "sh", "(", "'git show --pretty=format:%ct --quiet HEAD'", ",", "cwd", "=", "dirname"...
Returns a numeric identifier of the latest git changeset. The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. This value isn't guaranteed to be unique, but collisions are very unlikely, so it's sufficient for generating the development version numbers.
[ "Returns", "a", "numeric", "identifier", "of", "the", "latest", "git", "changeset", ".", "The", "result", "is", "the", "UTC", "timestamp", "of", "the", "changeset", "in", "YYYYMMDDHHMMSS", "format", ".", "This", "value", "isn", "t", "guaranteed", "to", "be",...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/version.py#L31-L46
doakey3/DashTable
dashtable/html2data/headers_present.py
headers_present
def headers_present(html_string): """ Checks if the html table contains headers and returns True/False Parameters ---------- html_string : str Returns ------- bool """ try: from bs4 import BeautifulSoup except ImportError: print("ERROR: You must have Beautif...
python
def headers_present(html_string): """ Checks if the html table contains headers and returns True/False Parameters ---------- html_string : str Returns ------- bool """ try: from bs4 import BeautifulSoup except ImportError: print("ERROR: You must have Beautif...
[ "def", "headers_present", "(", "html_string", ")", ":", "try", ":", "from", "bs4", "import", "BeautifulSoup", "except", "ImportError", ":", "print", "(", "\"ERROR: You must have BeautifulSoup to use html2data\"", ")", "return", "soup", "=", "BeautifulSoup", "(", "html...
Checks if the html table contains headers and returns True/False Parameters ---------- html_string : str Returns ------- bool
[ "Checks", "if", "the", "html", "table", "contains", "headers", "and", "returns", "True", "/", "False" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/headers_present.py#L1-L28
doakey3/DashTable
dashtable/html2data/extract_spans.py
extract_spans
def extract_spans(html_string): """ Creates a list of the spanned cell groups of [row, column] pairs. Parameters ---------- html_string : str Returns ------- list of lists of lists of int """ try: from bs4 import BeautifulSoup except ImportError: print("ERRO...
python
def extract_spans(html_string): """ Creates a list of the spanned cell groups of [row, column] pairs. Parameters ---------- html_string : str Returns ------- list of lists of lists of int """ try: from bs4 import BeautifulSoup except ImportError: print("ERRO...
[ "def", "extract_spans", "(", "html_string", ")", ":", "try", ":", "from", "bs4", "import", "BeautifulSoup", "except", "ImportError", ":", "print", "(", "\"ERROR: You must have BeautifulSoup to use html2data\"", ")", "return", "soup", "=", "BeautifulSoup", "(", "html_s...
Creates a list of the spanned cell groups of [row, column] pairs. Parameters ---------- html_string : str Returns ------- list of lists of lists of int
[ "Creates", "a", "list", "of", "the", "spanned", "cell", "groups", "of", "[", "row", "column", "]", "pairs", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/extract_spans.py#L4-L64
Lilykos/pyphonetics
pyphonetics/utils.py
translation
def translation(first, second): """Create an index of mapped letters (zip to dict).""" if len(first) != len(second): raise WrongLengthException('The lists are not of the same length!') return dict(zip(first, second))
python
def translation(first, second): """Create an index of mapped letters (zip to dict).""" if len(first) != len(second): raise WrongLengthException('The lists are not of the same length!') return dict(zip(first, second))
[ "def", "translation", "(", "first", ",", "second", ")", ":", "if", "len", "(", "first", ")", "!=", "len", "(", "second", ")", ":", "raise", "WrongLengthException", "(", "'The lists are not of the same length!'", ")", "return", "dict", "(", "zip", "(", "first...
Create an index of mapped letters (zip to dict).
[ "Create", "an", "index", "of", "mapped", "letters", "(", "zip", "to", "dict", ")", "." ]
train
https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/utils.py#L6-L10
doakey3/DashTable
dashtable/html2data/restructify/process_tag.py
process_tag
def process_tag(node): """ Recursively go through a tag's children, converting them, then convert the tag itself. """ text = '' exceptions = ['table'] for element in node.children: if isinstance(element, NavigableString): text += element elif not node.name in e...
python
def process_tag(node): """ Recursively go through a tag's children, converting them, then convert the tag itself. """ text = '' exceptions = ['table'] for element in node.children: if isinstance(element, NavigableString): text += element elif not node.name in e...
[ "def", "process_tag", "(", "node", ")", ":", "text", "=", "''", "exceptions", "=", "[", "'table'", "]", "for", "element", "in", "node", ".", "children", ":", "if", "isinstance", "(", "element", ",", "NavigableString", ")", ":", "text", "+=", "element", ...
Recursively go through a tag's children, converting them, then convert the tag itself.
[ "Recursively", "go", "through", "a", "tag", "s", "children", "converting", "them", "then", "convert", "the", "tag", "itself", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/restructify/process_tag.py#L13-L36
quantmind/dynts
dynts/utils/iterators.py
laggeddates
def laggeddates(ts, step=1): '''Lagged iterator over dates''' if step == 1: dates = ts.dates() if not hasattr(dates, 'next'): dates = dates.__iter__() dt0 = next(dates) for dt1 in dates: yield dt1, dt0 dt0 = dt1 else: whi...
python
def laggeddates(ts, step=1): '''Lagged iterator over dates''' if step == 1: dates = ts.dates() if not hasattr(dates, 'next'): dates = dates.__iter__() dt0 = next(dates) for dt1 in dates: yield dt1, dt0 dt0 = dt1 else: whi...
[ "def", "laggeddates", "(", "ts", ",", "step", "=", "1", ")", ":", "if", "step", "==", "1", ":", "dates", "=", "ts", ".", "dates", "(", ")", "if", "not", "hasattr", "(", "dates", ",", "'next'", ")", ":", "dates", "=", "dates", ".", "__iter__", "...
Lagged iterator over dates
[ "Lagged", "iterator", "over", "dates" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/iterators.py#L4-L20
quantmind/dynts
dynts/lib/__init__.py
make_skiplist
def make_skiplist(*args, use_fallback=False): '''Create a new skiplist''' sl = fallback.Skiplist if use_fallback else Skiplist return sl(*args)
python
def make_skiplist(*args, use_fallback=False): '''Create a new skiplist''' sl = fallback.Skiplist if use_fallback else Skiplist return sl(*args)
[ "def", "make_skiplist", "(", "*", "args", ",", "use_fallback", "=", "False", ")", ":", "sl", "=", "fallback", ".", "Skiplist", "if", "use_fallback", "else", "Skiplist", "return", "sl", "(", "*", "args", ")" ]
Create a new skiplist
[ "Create", "a", "new", "skiplist" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/__init__.py#L6-L9
doakey3/DashTable
dashtable/data2md/data2md.py
data2md
def data2md(table): """ Creates a markdown table. The first row will be headers. Parameters ---------- table : list of lists of str A list of rows containing strings. If any of these strings consist of multiple lines, they will be converted to single line because markdown ta...
python
def data2md(table): """ Creates a markdown table. The first row will be headers. Parameters ---------- table : list of lists of str A list of rows containing strings. If any of these strings consist of multiple lines, they will be converted to single line because markdown ta...
[ "def", "data2md", "(", "table", ")", ":", "table", "=", "copy", ".", "deepcopy", "(", "table", ")", "table", "=", "ensure_table_strings", "(", "table", ")", "table", "=", "multis_2_mono", "(", "table", ")", "table", "=", "add_cushions", "(", "table", ")"...
Creates a markdown table. The first row will be headers. Parameters ---------- table : list of lists of str A list of rows containing strings. If any of these strings consist of multiple lines, they will be converted to single line because markdown tables do not support multiline ce...
[ "Creates", "a", "markdown", "table", ".", "The", "first", "row", "will", "be", "headers", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2md/data2md.py#L10-L73
doakey3/DashTable
dashtable/data2rst/cell/v_center_cell_text.py
v_center_cell_text
def v_center_cell_text(cell): """ Vertically center the text within the cell's grid. Like this:: +--------+ +--------+ | foobar | | | | | | | | | --> | foobar | | | | | | | | | ...
python
def v_center_cell_text(cell): """ Vertically center the text within the cell's grid. Like this:: +--------+ +--------+ | foobar | | | | | | | | | --> | foobar | | | | | | | | | ...
[ "def", "v_center_cell_text", "(", "cell", ")", ":", "lines", "=", "cell", ".", "text", ".", "split", "(", "'\\n'", ")", "cell_width", "=", "len", "(", "lines", "[", "0", "]", ")", "-", "2", "truncated_lines", "=", "[", "]", "for", "i", "in", "range...
Vertically center the text within the cell's grid. Like this:: +--------+ +--------+ | foobar | | | | | | | | | --> | foobar | | | | | | | | | +--------+ +--------+ Paramete...
[ "Vertically", "center", "the", "text", "within", "the", "cell", "s", "grid", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/v_center_cell_text.py#L4-L73
doakey3/DashTable
dashtable/data2rst/data2rst.py
data2rst
def data2rst(table, spans=[[[0, 0]]], use_headers=True, center_cells=False, center_headers=False): """ Convert a list of lists of str into a reStructuredText Grid Table Parameters ---------- table : list of lists of str spans : list of lists of lists of int, optional These ...
python
def data2rst(table, spans=[[[0, 0]]], use_headers=True, center_cells=False, center_headers=False): """ Convert a list of lists of str into a reStructuredText Grid Table Parameters ---------- table : list of lists of str spans : list of lists of lists of int, optional These ...
[ "def", "data2rst", "(", "table", ",", "spans", "=", "[", "[", "[", "0", ",", "0", "]", "]", "]", ",", "use_headers", "=", "True", ",", "center_cells", "=", "False", ",", "center_headers", "=", "False", ")", ":", "table", "=", "copy", ".", "deepcopy...
Convert a list of lists of str into a reStructuredText Grid Table Parameters ---------- table : list of lists of str spans : list of lists of lists of int, optional These are [row, column] pairs of cells that are merged in the table. Rows and columns start in the top left of the table.F...
[ "Convert", "a", "list", "of", "lists", "of", "str", "into", "a", "reStructuredText", "Grid", "Table" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/data2rst.py#L19-L119
eaton-lab/toytree
toytree/MultiDrawing.py
CloudTree.set_dims_from_tree_size
def set_dims_from_tree_size(self): "Calculate reasonable height and width for tree given N tips" tlen = len(self.treelist[0]) if self.style.orient in ("right", "left"): # long tip-wise dimension if not self.style.height: self.style.height = max(275, min(10...
python
def set_dims_from_tree_size(self): "Calculate reasonable height and width for tree given N tips" tlen = len(self.treelist[0]) if self.style.orient in ("right", "left"): # long tip-wise dimension if not self.style.height: self.style.height = max(275, min(10...
[ "def", "set_dims_from_tree_size", "(", "self", ")", ":", "tlen", "=", "len", "(", "self", ".", "treelist", "[", "0", "]", ")", "if", "self", ".", "style", ".", "orient", "in", "(", "\"right\"", ",", "\"left\"", ")", ":", "# long tip-wise dimension", "if"...
Calculate reasonable height and width for tree given N tips
[ "Calculate", "reasonable", "height", "and", "width", "for", "tree", "given", "N", "tips" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/MultiDrawing.py#L153-L167
eaton-lab/toytree
toytree/MultiDrawing.py
CloudTree.add_tip_labels_to_axes
def add_tip_labels_to_axes(self): """ Add text offset from tips of tree with correction for orientation, and fixed_order which is usually used in multitree plotting. """ # get tip-coords and replace if using fixed_order if self.style.orient in ("up", "down"): ...
python
def add_tip_labels_to_axes(self): """ Add text offset from tips of tree with correction for orientation, and fixed_order which is usually used in multitree plotting. """ # get tip-coords and replace if using fixed_order if self.style.orient in ("up", "down"): ...
[ "def", "add_tip_labels_to_axes", "(", "self", ")", ":", "# get tip-coords and replace if using fixed_order", "if", "self", ".", "style", ".", "orient", "in", "(", "\"up\"", ",", "\"down\"", ")", ":", "ypos", "=", "np", ".", "zeros", "(", "self", ".", "ntips", ...
Add text offset from tips of tree with correction for orientation, and fixed_order which is usually used in multitree plotting.
[ "Add", "text", "offset", "from", "tips", "of", "tree", "with", "correction", "for", "orientation", "and", "fixed_order", "which", "is", "usually", "used", "in", "multitree", "plotting", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/MultiDrawing.py#L170-L206
eaton-lab/toytree
toytree/MultiDrawing.py
CloudTree.fit_tip_labels
def fit_tip_labels(self): """ Modifies display range to ensure tip labels fit. This is a bit hackish still. The problem is that the 'extents' range of the rendered text is totally correct. So we add a little buffer here. Should add for user to be able to modify this if needed. I...
python
def fit_tip_labels(self): """ Modifies display range to ensure tip labels fit. This is a bit hackish still. The problem is that the 'extents' range of the rendered text is totally correct. So we add a little buffer here. Should add for user to be able to modify this if needed. I...
[ "def", "fit_tip_labels", "(", "self", ")", ":", "if", "not", "self", ".", "tip_labels", ":", "return", "# longest name (this will include html hacks)", "longest_name", "=", "max", "(", "[", "len", "(", "i", ")", "for", "i", "in", "self", ".", "tip_labels", "...
Modifies display range to ensure tip labels fit. This is a bit hackish still. The problem is that the 'extents' range of the rendered text is totally correct. So we add a little buffer here. Should add for user to be able to modify this if needed. If not using edge lengths then need to ...
[ "Modifies", "display", "range", "to", "ensure", "tip", "labels", "fit", ".", "This", "is", "a", "bit", "hackish", "still", ".", "The", "problem", "is", "that", "the", "extents", "range", "of", "the", "rendered", "text", "is", "totally", "correct", ".", "...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/MultiDrawing.py#L209-L238
doakey3/DashTable
dashtable/html2data/restructify/converters/convert_p.py
convert_p
def convert_p(element, text): """ Adds 2 newlines to the end of text """ depth = -1 while element: if (not element.name == '[document]' and not element.parent.get('id') == '__RESTRUCTIFY_WRAPPER__'): depth += 1 element = element.parent if text: ...
python
def convert_p(element, text): """ Adds 2 newlines to the end of text """ depth = -1 while element: if (not element.name == '[document]' and not element.parent.get('id') == '__RESTRUCTIFY_WRAPPER__'): depth += 1 element = element.parent if text: ...
[ "def", "convert_p", "(", "element", ",", "text", ")", ":", "depth", "=", "-", "1", "while", "element", ":", "if", "(", "not", "element", ".", "name", "==", "'[document]'", "and", "not", "element", ".", "parent", ".", "get", "(", "'id'", ")", "==", ...
Adds 2 newlines to the end of text
[ "Adds", "2", "newlines", "to", "the", "end", "of", "text" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/restructify/converters/convert_p.py#L1-L15
doakey3/DashTable
dashtable/simple2data/simple2data.py
simple2data
def simple2data(text): """ Convert a simple table to data (the kind used by DashTable) Parameters ---------- text : str A valid simple rst table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a [row, column] pair that de...
python
def simple2data(text): """ Convert a simple table to data (the kind used by DashTable) Parameters ---------- text : str A valid simple rst table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a [row, column] pair that de...
[ "def", "simple2data", "(", "text", ")", ":", "try", ":", "import", "docutils", ".", "statemachine", "import", "docutils", ".", "parsers", ".", "rst", ".", "tableparser", "except", "ImportError", ":", "print", "(", "\"ERROR: You must install the docutils library to u...
Convert a simple table to data (the kind used by DashTable) Parameters ---------- text : str A valid simple rst table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a [row, column] pair that defines a group of merged cel...
[ "Convert", "a", "simple", "table", "to", "data", "(", "the", "kind", "used", "by", "DashTable", ")" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/simple2data/simple2data.py#L9-L121
doakey3/DashTable
dashtable/data2rst/get_output_column_widths.py
get_output_column_widths
def get_output_column_widths(table, spans): """ Gets the widths of the columns of the output table Parameters ---------- table : list of lists of str The table of rows of text spans : list of lists of int The [row, column] pairs of combined cells Returns ------- wid...
python
def get_output_column_widths(table, spans): """ Gets the widths of the columns of the output table Parameters ---------- table : list of lists of str The table of rows of text spans : list of lists of int The [row, column] pairs of combined cells Returns ------- wid...
[ "def", "get_output_column_widths", "(", "table", ",", "spans", ")", ":", "widths", "=", "[", "]", "for", "column", "in", "table", "[", "0", "]", ":", "widths", ".", "append", "(", "3", ")", "for", "row", "in", "range", "(", "len", "(", "table", ")"...
Gets the widths of the columns of the output table Parameters ---------- table : list of lists of str The table of rows of text spans : list of lists of int The [row, column] pairs of combined cells Returns ------- widths : list of int The widths of each column in t...
[ "Gets", "the", "widths", "of", "the", "columns", "of", "the", "output", "table" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/get_output_column_widths.py#L5-L69
doakey3/DashTable
dashtable/dashutils/make_empty_table.py
make_empty_table
def make_empty_table(row_count, column_count): """ Make an empty table Parameters ---------- row_count : int The number of rows in the new table column_count : int The number of columns in the new table Returns ------- table : list of lists of str Each cell ...
python
def make_empty_table(row_count, column_count): """ Make an empty table Parameters ---------- row_count : int The number of rows in the new table column_count : int The number of columns in the new table Returns ------- table : list of lists of str Each cell ...
[ "def", "make_empty_table", "(", "row_count", ",", "column_count", ")", ":", "table", "=", "[", "]", "while", "row_count", ">", "0", ":", "row", "=", "[", "]", "for", "column", "in", "range", "(", "column_count", ")", ":", "row", ".", "append", "(", "...
Make an empty table Parameters ---------- row_count : int The number of rows in the new table column_count : int The number of columns in the new table Returns ------- table : list of lists of str Each cell will be an empty str ('')
[ "Make", "an", "empty", "table" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/make_empty_table.py#L1-L24
quantmind/dynts
dynts/lib/fallback/ols.py
ols.beta
def beta(self): '''\ The linear estimation of the parameter vector :math:`\beta` given by .. math:: \beta = (X^T X)^-1 X^T y ''' t = self.X.transpose() XX = dot(t,self.X) XY = dot(t,self.y) return linalg.solve(XX,XY)
python
def beta(self): '''\ The linear estimation of the parameter vector :math:`\beta` given by .. math:: \beta = (X^T X)^-1 X^T y ''' t = self.X.transpose() XX = dot(t,self.X) XY = dot(t,self.y) return linalg.solve(XX,XY)
[ "def", "beta", "(", "self", ")", ":", "t", "=", "self", ".", "X", ".", "transpose", "(", ")", "XX", "=", "dot", "(", "t", ",", "self", ".", "X", ")", "XY", "=", "dot", "(", "t", ",", "self", ".", "y", ")", "return", "linalg", ".", "solve", ...
\ The linear estimation of the parameter vector :math:`\beta` given by .. math:: \beta = (X^T X)^-1 X^T y
[ "\\", "The", "linear", "estimation", "of", "the", "parameter", "vector", ":", "math", ":", "\\", "beta", "given", "by" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/ols.py#L30-L42
quantmind/dynts
dynts/api/data.py
FormatterDict.oftype
def oftype(self, typ): '''Return a generator of formatters codes of type typ''' for key, val in self.items(): if val.type == typ: yield key
python
def oftype(self, typ): '''Return a generator of formatters codes of type typ''' for key, val in self.items(): if val.type == typ: yield key
[ "def", "oftype", "(", "self", ",", "typ", ")", ":", "for", "key", ",", "val", "in", "self", ".", "items", "(", ")", ":", "if", "val", ".", "type", "==", "typ", ":", "yield", "key" ]
Return a generator of formatters codes of type typ
[ "Return", "a", "generator", "of", "formatters", "codes", "of", "type", "typ" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/data.py#L7-L11
quantmind/dynts
dynts/api/data.py
Data.names
def names(self, with_namespace=False): '''List of names for series in dataset. It will always return a list or names with length given by :class:`~.DynData.count`. ''' N = self.count() names = self.name.split(settings.splittingnames)[:N] n = 0 while len(n...
python
def names(self, with_namespace=False): '''List of names for series in dataset. It will always return a list or names with length given by :class:`~.DynData.count`. ''' N = self.count() names = self.name.split(settings.splittingnames)[:N] n = 0 while len(n...
[ "def", "names", "(", "self", ",", "with_namespace", "=", "False", ")", ":", "N", "=", "self", ".", "count", "(", ")", "names", "=", "self", ".", "name", ".", "split", "(", "settings", ".", "splittingnames", ")", "[", ":", "N", "]", "n", "=", "0",...
List of names for series in dataset. It will always return a list or names with length given by :class:`~.DynData.count`.
[ "List", "of", "names", "for", "series", "in", "dataset", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/data.py#L50-L67
quantmind/dynts
dynts/api/data.py
Data.dump
def dump(self, format=None, **kwargs): """Dump the timeseries using a specific ``format``. """ formatter = Formatters.get(format, None) if not format: return self.display() elif not formatter: raise FormattingException('Formatter %s not available' % format...
python
def dump(self, format=None, **kwargs): """Dump the timeseries using a specific ``format``. """ formatter = Formatters.get(format, None) if not format: return self.display() elif not formatter: raise FormattingException('Formatter %s not available' % format...
[ "def", "dump", "(", "self", ",", "format", "=", "None", ",", "*", "*", "kwargs", ")", ":", "formatter", "=", "Formatters", ".", "get", "(", "format", ",", "None", ")", "if", "not", "format", ":", "return", "self", ".", "display", "(", ")", "elif", ...
Dump the timeseries using a specific ``format``.
[ "Dump", "the", "timeseries", "using", "a", "specific", "format", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/data.py#L88-L97
quantmind/dynts
dynts/dsl/grammar.py
p_expression_binop
def p_expression_binop(p): '''expression : expression PLUS expression | expression MINUS expression | expression TIMES expression | expression DIVIDE expression | expression EQUAL expression | expression CONCAT expressio...
python
def p_expression_binop(p): '''expression : expression PLUS expression | expression MINUS expression | expression TIMES expression | expression DIVIDE expression | expression EQUAL expression | expression CONCAT expressio...
[ "def", "p_expression_binop", "(", "p", ")", ":", "v", "=", "p", "[", "2", "]", "if", "v", "==", "'+'", ":", "p", "[", "0", "]", "=", "PlusOp", "(", "p", "[", "1", "]", ",", "p", "[", "3", "]", ")", "elif", "v", "==", "'-'", ":", "p", "[...
expression : expression PLUS expression | expression MINUS expression | expression TIMES expression | expression DIVIDE expression | expression EQUAL expression | expression CONCAT expression | expression S...
[ "expression", ":", "expression", "PLUS", "expression", "|", "expression", "MINUS", "expression", "|", "expression", "TIMES", "expression", "|", "expression", "DIVIDE", "expression", "|", "expression", "EQUAL", "expression", "|", "expression", "CONCAT", "expression", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/grammar.py#L15-L39
quantmind/dynts
dynts/dsl/grammar.py
p_expression_group
def p_expression_group(p): '''expression : LPAREN expression RPAREN | LSQUARE expression RSQUARE''' v = p[1] if v == '(': p[0] = functionarguments(p[2]) elif v == '[': p[0] = tsentry(p[2])
python
def p_expression_group(p): '''expression : LPAREN expression RPAREN | LSQUARE expression RSQUARE''' v = p[1] if v == '(': p[0] = functionarguments(p[2]) elif v == '[': p[0] = tsentry(p[2])
[ "def", "p_expression_group", "(", "p", ")", ":", "v", "=", "p", "[", "1", "]", "if", "v", "==", "'('", ":", "p", "[", "0", "]", "=", "functionarguments", "(", "p", "[", "2", "]", ")", "elif", "v", "==", "'['", ":", "p", "[", "0", "]", "=", ...
expression : LPAREN expression RPAREN | LSQUARE expression RSQUARE
[ "expression", ":", "LPAREN", "expression", "RPAREN", "|", "LSQUARE", "expression", "RSQUARE" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/grammar.py#L42-L49
doakey3/DashTable
dashtable/data2rst/cell/merge_cells.py
merge_cells
def merge_cells(cell1, cell2, direction): """ Combine the side of cell1's grid text with cell2's text. For example:: cell1 cell2 merge "RIGHT" +-----+ +------+ +-----+------+ | foo | | dog | | foo | dog | | | +------+ | +------+ | | ...
python
def merge_cells(cell1, cell2, direction): """ Combine the side of cell1's grid text with cell2's text. For example:: cell1 cell2 merge "RIGHT" +-----+ +------+ +-----+------+ | foo | | dog | | foo | dog | | | +------+ | +------+ | | ...
[ "def", "merge_cells", "(", "cell1", ",", "cell2", ",", "direction", ")", ":", "cell1_lines", "=", "cell1", ".", "text", ".", "split", "(", "\"\\n\"", ")", "cell2_lines", "=", "cell2", ".", "text", ".", "split", "(", "\"\\n\"", ")", "if", "direction", "...
Combine the side of cell1's grid text with cell2's text. For example:: cell1 cell2 merge "RIGHT" +-----+ +------+ +-----+------+ | foo | | dog | | foo | dog | | | +------+ | +------+ | | | cat | | | cat | | | +------+ ...
[ "Combine", "the", "side", "of", "cell1", "s", "grid", "text", "with", "cell2", "s", "text", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/merge_cells.py#L1-L59
rbarrois/xworkflows
src/xworkflows/utils.py
iterclass
def iterclass(cls): """Iterates over (valid) attributes of a class. Args: cls (object): the class to iterate over Yields: (str, obj) tuples: the class-level attributes. """ for field in dir(cls): if hasattr(cls, field): value = getattr(cls, field) yi...
python
def iterclass(cls): """Iterates over (valid) attributes of a class. Args: cls (object): the class to iterate over Yields: (str, obj) tuples: the class-level attributes. """ for field in dir(cls): if hasattr(cls, field): value = getattr(cls, field) yi...
[ "def", "iterclass", "(", "cls", ")", ":", "for", "field", "in", "dir", "(", "cls", ")", ":", "if", "hasattr", "(", "cls", ",", "field", ")", ":", "value", "=", "getattr", "(", "cls", ",", "field", ")", "yield", "field", ",", "value" ]
Iterates over (valid) attributes of a class. Args: cls (object): the class to iterate over Yields: (str, obj) tuples: the class-level attributes.
[ "Iterates", "over", "(", "valid", ")", "attributes", "of", "a", "class", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/utils.py#L9-L21
orionvm/potsdb
potsdb/client.py
_mksocket
def _mksocket(host, port, q, done, stop): """Returns a tcp socket to (host/port). Retries forever if connection fails""" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(2) attempt = 0 while not stop.is_set(): try: s.connect((host, port)) return s ...
python
def _mksocket(host, port, q, done, stop): """Returns a tcp socket to (host/port). Retries forever if connection fails""" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(2) attempt = 0 while not stop.is_set(): try: s.connect((host, port)) return s ...
[ "def", "_mksocket", "(", "host", ",", "port", ",", "q", ",", "done", ",", "stop", ")", ":", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "s", ".", "settimeout", "(", "2", ")", "attempt", ...
Returns a tcp socket to (host/port). Retries forever if connection fails
[ "Returns", "a", "tcp", "socket", "to", "(", "host", "/", "port", ")", ".", "Retries", "forever", "if", "connection", "fails" ]
train
https://github.com/orionvm/potsdb/blob/f242f8ad97c4e5887b3c39a082f6bdc4be46661c/potsdb/client.py#L21-L33
orionvm/potsdb
potsdb/client.py
_push
def _push(host, port, q, done, mps, stop, test_mode): """Worker thread. Connect to host/port, pull data from q until done is set""" sock = None retry_line = None while not ( stop.is_set() or ( done.is_set() and retry_line == None and q.empty()) ): stime = time.time() if sock == None and...
python
def _push(host, port, q, done, mps, stop, test_mode): """Worker thread. Connect to host/port, pull data from q until done is set""" sock = None retry_line = None while not ( stop.is_set() or ( done.is_set() and retry_line == None and q.empty()) ): stime = time.time() if sock == None and...
[ "def", "_push", "(", "host", ",", "port", ",", "q", ",", "done", ",", "mps", ",", "stop", ",", "test_mode", ")", ":", "sock", "=", "None", "retry_line", "=", "None", "while", "not", "(", "stop", ".", "is_set", "(", ")", "or", "(", "done", ".", ...
Worker thread. Connect to host/port, pull data from q until done is set
[ "Worker", "thread", ".", "Connect", "to", "host", "/", "port", "pull", "data", "from", "q", "until", "done", "is", "set" ]
train
https://github.com/orionvm/potsdb/blob/f242f8ad97c4e5887b3c39a082f6bdc4be46661c/potsdb/client.py#L35-L76
orionvm/potsdb
potsdb/client.py
Client.log
def log(self, name, val, **tags): """Log metric name with value val. You must include at least one tag as a kwarg""" global _last_timestamp, _last_metrics # do not allow .log after closing assert not self.done.is_set(), "worker thread has been closed" # check if valid metric nam...
python
def log(self, name, val, **tags): """Log metric name with value val. You must include at least one tag as a kwarg""" global _last_timestamp, _last_metrics # do not allow .log after closing assert not self.done.is_set(), "worker thread has been closed" # check if valid metric nam...
[ "def", "log", "(", "self", ",", "name", ",", "val", ",", "*", "*", "tags", ")", ":", "global", "_last_timestamp", ",", "_last_metrics", "# do not allow .log after closing", "assert", "not", "self", ".", "done", ".", "is_set", "(", ")", ",", "\"worker thread ...
Log metric name with value val. You must include at least one tag as a kwarg
[ "Log", "metric", "name", "with", "value", "val", ".", "You", "must", "include", "at", "least", "one", "tag", "as", "a", "kwarg" ]
train
https://github.com/orionvm/potsdb/blob/f242f8ad97c4e5887b3c39a082f6bdc4be46661c/potsdb/client.py#L112-L159
cedrus-opensource/pyxid
pyxid/serial_wrapper.py
GenericSerialPort.available_ports
def available_ports(): """ Scans COM1 through COM255 for available serial ports returns a list of available ports """ ports = [] for i in range(256): try: p = Serial('COM%d' % i) p.close() ports.append(p) ...
python
def available_ports(): """ Scans COM1 through COM255 for available serial ports returns a list of available ports """ ports = [] for i in range(256): try: p = Serial('COM%d' % i) p.close() ports.append(p) ...
[ "def", "available_ports", "(", ")", ":", "ports", "=", "[", "]", "for", "i", "in", "range", "(", "256", ")", ":", "try", ":", "p", "=", "Serial", "(", "'COM%d'", "%", "i", ")", "p", ".", "close", "(", ")", "ports", ".", "append", "(", "p", ")...
Scans COM1 through COM255 for available serial ports returns a list of available ports
[ "Scans", "COM1", "through", "COM255", "for", "available", "serial", "ports" ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/serial_wrapper.py#L62-L78
cedrus-opensource/pyxid
pyxid/internal.py
XidConnection.get_current_response
def get_current_response(self): """ reads the current response data from the object and returns it in a dict. Currently 'time' is reported as 0 until clock drift issues are resolved. """ response = {'port': 0, 'pressed': False, ...
python
def get_current_response(self): """ reads the current response data from the object and returns it in a dict. Currently 'time' is reported as 0 until clock drift issues are resolved. """ response = {'port': 0, 'pressed': False, ...
[ "def", "get_current_response", "(", "self", ")", ":", "response", "=", "{", "'port'", ":", "0", ",", "'pressed'", ":", "False", ",", "'key'", ":", "0", ",", "'time'", ":", "0", "}", "if", "len", "(", "self", ".", "__response_structs_queue", ")", ">", ...
reads the current response data from the object and returns it in a dict. Currently 'time' is reported as 0 until clock drift issues are resolved.
[ "reads", "the", "current", "response", "data", "from", "the", "object", "and", "returns", "it", "in", "a", "dict", "." ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/internal.py#L230-L250
cedrus-opensource/pyxid
pyxid/pyxid_impl.py
XidScanner.detect_xid_devices
def detect_xid_devices(self): """ For all of the com ports connected to the computer, send an XID command '_c1'. If the device response with '_xid', it is an xid device. """ self.__xid_cons = [] for c in self.__com_ports: device_found = False ...
python
def detect_xid_devices(self): """ For all of the com ports connected to the computer, send an XID command '_c1'. If the device response with '_xid', it is an xid device. """ self.__xid_cons = [] for c in self.__com_ports: device_found = False ...
[ "def", "detect_xid_devices", "(", "self", ")", ":", "self", ".", "__xid_cons", "=", "[", "]", "for", "c", "in", "self", ".", "__com_ports", ":", "device_found", "=", "False", "for", "b", "in", "[", "115200", ",", "19200", ",", "9600", ",", "57600", "...
For all of the com ports connected to the computer, send an XID command '_c1'. If the device response with '_xid', it is an xid device.
[ "For", "all", "of", "the", "com", "ports", "connected", "to", "the", "computer", "send", "an", "XID", "command", "_c1", ".", "If", "the", "device", "response", "with", "_xid", "it", "is", "an", "xid", "device", "." ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L21-L61
cedrus-opensource/pyxid
pyxid/pyxid_impl.py
XidScanner.device_at_index
def device_at_index(self, index): """ Returns the device at the specified index """ if index >= len(self.__xid_cons): raise ValueError("Invalid device index") return self.__xid_cons[index]
python
def device_at_index(self, index): """ Returns the device at the specified index """ if index >= len(self.__xid_cons): raise ValueError("Invalid device index") return self.__xid_cons[index]
[ "def", "device_at_index", "(", "self", ",", "index", ")", ":", "if", "index", ">=", "len", "(", "self", ".", "__xid_cons", ")", ":", "raise", "ValueError", "(", "\"Invalid device index\"", ")", "return", "self", ".", "__xid_cons", "[", "index", "]" ]
Returns the device at the specified index
[ "Returns", "the", "device", "at", "the", "specified", "index" ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L63-L70
cedrus-opensource/pyxid
pyxid/pyxid_impl.py
BaseDevice.query_base_timer
def query_base_timer(self): """ gets the value from the device's base timer """ (_, _, time) = unpack('<ccI', self.con.send_xid_command("e3", 6)) return time
python
def query_base_timer(self): """ gets the value from the device's base timer """ (_, _, time) = unpack('<ccI', self.con.send_xid_command("e3", 6)) return time
[ "def", "query_base_timer", "(", "self", ")", ":", "(", "_", ",", "_", ",", "time", ")", "=", "unpack", "(", "'<ccI'", ",", "self", ".", "con", ".", "send_xid_command", "(", "\"e3\"", ",", "6", ")", ")", "return", "time" ]
gets the value from the device's base timer
[ "gets", "the", "value", "from", "the", "device", "s", "base", "timer" ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L96-L101
cedrus-opensource/pyxid
pyxid/pyxid_impl.py
ResponseDevice.poll_for_response
def poll_for_response(self): """ Polls the device for user input If there is a keymapping for the device, the key map is applied to the key reported from the device. If a response is waiting to be processed, the response is appended to the internal response_queue ...
python
def poll_for_response(self): """ Polls the device for user input If there is a keymapping for the device, the key map is applied to the key reported from the device. If a response is waiting to be processed, the response is appended to the internal response_queue ...
[ "def", "poll_for_response", "(", "self", ")", ":", "key_state", "=", "self", ".", "con", ".", "check_for_keypress", "(", ")", "if", "key_state", "!=", "NO_KEY_DETECTED", ":", "response", "=", "self", ".", "con", ".", "get_current_response", "(", ")", "if", ...
Polls the device for user input If there is a keymapping for the device, the key map is applied to the key reported from the device. If a response is waiting to be processed, the response is appended to the internal response_queue
[ "Polls", "the", "device", "for", "user", "input" ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L114-L134
cedrus-opensource/pyxid
pyxid/pyxid_impl.py
StimTracker.set_pulse_duration
def set_pulse_duration(self, duration): """ Sets the pulse duration for events in miliseconds when activate_line is called """ if duration > 4294967295: raise ValueError('Duration is too long. Please choose a value ' 'less than 4294967296....
python
def set_pulse_duration(self, duration): """ Sets the pulse duration for events in miliseconds when activate_line is called """ if duration > 4294967295: raise ValueError('Duration is too long. Please choose a value ' 'less than 4294967296....
[ "def", "set_pulse_duration", "(", "self", ",", "duration", ")", ":", "if", "duration", ">", "4294967295", ":", "raise", "ValueError", "(", "'Duration is too long. Please choose a value '", "'less than 4294967296.'", ")", "big_endian", "=", "hex", "(", "duration", ")",...
Sets the pulse duration for events in miliseconds when activate_line is called
[ "Sets", "the", "pulse", "duration", "for", "events", "in", "miliseconds", "when", "activate_line", "is", "called" ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L196-L221
cedrus-opensource/pyxid
pyxid/pyxid_impl.py
StimTracker.activate_line
def activate_line(self, lines=None, bitmask=None, leave_remaining_lines=False): """ Triggers an output line on StimTracker. There are 8 output lines on StimTracker that can be raised in any combination. To raise lines 1 and 7, for example, you pass in the ...
python
def activate_line(self, lines=None, bitmask=None, leave_remaining_lines=False): """ Triggers an output line on StimTracker. There are 8 output lines on StimTracker that can be raised in any combination. To raise lines 1 and 7, for example, you pass in the ...
[ "def", "activate_line", "(", "self", ",", "lines", "=", "None", ",", "bitmask", "=", "None", ",", "leave_remaining_lines", "=", "False", ")", ":", "if", "lines", "is", "None", "and", "bitmask", "is", "None", ":", "raise", "ValueError", "(", "'Must set one ...
Triggers an output line on StimTracker. There are 8 output lines on StimTracker that can be raised in any combination. To raise lines 1 and 7, for example, you pass in the list: activate_line(lines=[1, 7]). To raise a single line, pass in just an integer, or a list with a sing...
[ "Triggers", "an", "output", "line", "on", "StimTracker", "." ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L223-L287
cedrus-opensource/pyxid
pyxid/pyxid_impl.py
StimTracker.clear_line
def clear_line(self, lines=None, bitmask=None, leave_remaining_lines=False): """ The inverse of activate_line. If a line is active, it deactivates it. This has the same parameters as activate_line() """ if lines is None and bitmask is None: raise ...
python
def clear_line(self, lines=None, bitmask=None, leave_remaining_lines=False): """ The inverse of activate_line. If a line is active, it deactivates it. This has the same parameters as activate_line() """ if lines is None and bitmask is None: raise ...
[ "def", "clear_line", "(", "self", ",", "lines", "=", "None", ",", "bitmask", "=", "None", ",", "leave_remaining_lines", "=", "False", ")", ":", "if", "lines", "is", "None", "and", "bitmask", "is", "None", ":", "raise", "ValueError", "(", "'Must set one of ...
The inverse of activate_line. If a line is active, it deactivates it. This has the same parameters as activate_line()
[ "The", "inverse", "of", "activate_line", ".", "If", "a", "line", "is", "active", "it", "deactivates", "it", "." ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L289-L317
cedrus-opensource/pyxid
pyxid/pyxid_impl.py
XidDevice.init_device
def init_device(self): """ Initializes the device with the proper keymaps and name """ try: product_id = int(self._send_command('_d2', 1)) except ValueError: product_id = self._send_command('_d2', 1) if product_id == 0: self._impl = Re...
python
def init_device(self): """ Initializes the device with the proper keymaps and name """ try: product_id = int(self._send_command('_d2', 1)) except ValueError: product_id = self._send_command('_d2', 1) if product_id == 0: self._impl = Re...
[ "def", "init_device", "(", "self", ")", ":", "try", ":", "product_id", "=", "int", "(", "self", ".", "_send_command", "(", "'_d2'", ",", "1", ")", ")", "except", "ValueError", ":", "product_id", "=", "self", ".", "_send_command", "(", "'_d2'", ",", "1"...
Initializes the device with the proper keymaps and name
[ "Initializes", "the", "device", "with", "the", "proper", "keymaps", "and", "name" ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L363-L417
cedrus-opensource/pyxid
pyxid/pyxid_impl.py
XidDevice._send_command
def _send_command(self, command, expected_bytes): """ Send an XID command to the device """ response = self.con.send_xid_command(command, expected_bytes) return response
python
def _send_command(self, command, expected_bytes): """ Send an XID command to the device """ response = self.con.send_xid_command(command, expected_bytes) return response
[ "def", "_send_command", "(", "self", ",", "command", ",", "expected_bytes", ")", ":", "response", "=", "self", ".", "con", ".", "send_xid_command", "(", "command", ",", "expected_bytes", ")", "return", "response" ]
Send an XID command to the device
[ "Send", "an", "XID", "command", "to", "the", "device" ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L419-L425
cedrus-opensource/pyxid
pyxid/__init__.py
get_xid_devices
def get_xid_devices(): """ Returns a list of all Xid devices connected to your computer. """ devices = [] scanner = XidScanner() for i in range(scanner.device_count()): com = scanner.device_at_index(i) com.open() device = XidDevice(com) devices.append(device) ...
python
def get_xid_devices(): """ Returns a list of all Xid devices connected to your computer. """ devices = [] scanner = XidScanner() for i in range(scanner.device_count()): com = scanner.device_at_index(i) com.open() device = XidDevice(com) devices.append(device) ...
[ "def", "get_xid_devices", "(", ")", ":", "devices", "=", "[", "]", "scanner", "=", "XidScanner", "(", ")", "for", "i", "in", "range", "(", "scanner", ".", "device_count", "(", ")", ")", ":", "com", "=", "scanner", ".", "device_at_index", "(", "i", ")...
Returns a list of all Xid devices connected to your computer.
[ "Returns", "a", "list", "of", "all", "Xid", "devices", "connected", "to", "your", "computer", "." ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/__init__.py#L14-L25
cedrus-opensource/pyxid
pyxid/__init__.py
get_xid_device
def get_xid_device(device_number): """ returns device at a given index. Raises ValueError if the device at the passed in index doesn't exist. """ scanner = XidScanner() com = scanner.device_at_index(device_number) com.open() return XidDevice(com)
python
def get_xid_device(device_number): """ returns device at a given index. Raises ValueError if the device at the passed in index doesn't exist. """ scanner = XidScanner() com = scanner.device_at_index(device_number) com.open() return XidDevice(com)
[ "def", "get_xid_device", "(", "device_number", ")", ":", "scanner", "=", "XidScanner", "(", ")", "com", "=", "scanner", ".", "device_at_index", "(", "device_number", ")", "com", ".", "open", "(", ")", "return", "XidDevice", "(", "com", ")" ]
returns device at a given index. Raises ValueError if the device at the passed in index doesn't exist.
[ "returns", "device", "at", "a", "given", "index", "." ]
train
https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/__init__.py#L28-L38
klen/flask-pw
flask_pw/models.py
Signal.connect
def connect(self, receiver): """Append receiver.""" if not callable(receiver): raise ValueError('Invalid receiver: %s' % receiver) self.receivers.append(receiver)
python
def connect(self, receiver): """Append receiver.""" if not callable(receiver): raise ValueError('Invalid receiver: %s' % receiver) self.receivers.append(receiver)
[ "def", "connect", "(", "self", ",", "receiver", ")", ":", "if", "not", "callable", "(", "receiver", ")", ":", "raise", "ValueError", "(", "'Invalid receiver: %s'", "%", "receiver", ")", "self", ".", "receivers", ".", "append", "(", "receiver", ")" ]
Append receiver.
[ "Append", "receiver", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/models.py#L56-L60
klen/flask-pw
flask_pw/models.py
Signal.disconnect
def disconnect(self, receiver): """Remove receiver.""" try: self.receivers.remove(receiver) except ValueError: raise ValueError('Unknown receiver: %s' % receiver)
python
def disconnect(self, receiver): """Remove receiver.""" try: self.receivers.remove(receiver) except ValueError: raise ValueError('Unknown receiver: %s' % receiver)
[ "def", "disconnect", "(", "self", ",", "receiver", ")", ":", "try", ":", "self", ".", "receivers", ".", "remove", "(", "receiver", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "'Unknown receiver: %s'", "%", "receiver", ")" ]
Remove receiver.
[ "Remove", "receiver", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/models.py#L67-L72
klen/flask-pw
flask_pw/models.py
Signal.send
def send(self, instance, *args, **kwargs): """Send signal.""" for receiver in self.receivers: receiver(instance, *args, **kwargs)
python
def send(self, instance, *args, **kwargs): """Send signal.""" for receiver in self.receivers: receiver(instance, *args, **kwargs)
[ "def", "send", "(", "self", ",", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "receiver", "in", "self", ".", "receivers", ":", "receiver", "(", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Send signal.
[ "Send", "signal", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/models.py#L74-L77
klen/flask-pw
flask_pw/models.py
Model.select
def select(cls, *args, **kwargs): """Support read slaves.""" query = super(Model, cls).select(*args, **kwargs) query.database = cls._get_read_database() return query
python
def select(cls, *args, **kwargs): """Support read slaves.""" query = super(Model, cls).select(*args, **kwargs) query.database = cls._get_read_database() return query
[ "def", "select", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "query", "=", "super", "(", "Model", ",", "cls", ")", ".", "select", "(", "*", "args", ",", "*", "*", "kwargs", ")", "query", ".", "database", "=", "cls", ".", ...
Support read slaves.
[ "Support", "read", "slaves", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/models.py#L105-L109
klen/flask-pw
flask_pw/models.py
Model.save
def save(self, force_insert=False, **kwargs): """Send signals.""" created = force_insert or not bool(self.pk) self.pre_save.send(self, created=created) super(Model, self).save(force_insert=force_insert, **kwargs) self.post_save.send(self, created=created)
python
def save(self, force_insert=False, **kwargs): """Send signals.""" created = force_insert or not bool(self.pk) self.pre_save.send(self, created=created) super(Model, self).save(force_insert=force_insert, **kwargs) self.post_save.send(self, created=created)
[ "def", "save", "(", "self", ",", "force_insert", "=", "False", ",", "*", "*", "kwargs", ")", ":", "created", "=", "force_insert", "or", "not", "bool", "(", "self", ".", "pk", ")", "self", ".", "pre_save", ".", "send", "(", "self", ",", "created", "...
Send signals.
[ "Send", "signals", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/models.py#L130-L135
klen/flask-pw
flask_pw/models.py
Model.delete_instance
def delete_instance(self, *args, **kwargs): """Send signals.""" self.pre_delete.send(self) super(Model, self).delete_instance(*args, **kwargs) self.post_delete.send(self)
python
def delete_instance(self, *args, **kwargs): """Send signals.""" self.pre_delete.send(self) super(Model, self).delete_instance(*args, **kwargs) self.post_delete.send(self)
[ "def", "delete_instance", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "pre_delete", ".", "send", "(", "self", ")", "super", "(", "Model", ",", "self", ")", ".", "delete_instance", "(", "*", "args", ",", "*", "*", ...
Send signals.
[ "Send", "signals", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/models.py#L137-L141
klen/flask-pw
flask_pw/__init__.py
get_database
def get_database(obj, **params): """Get database from given URI/Object.""" if isinstance(obj, string_types): return connect(obj, **params) return obj
python
def get_database(obj, **params): """Get database from given URI/Object.""" if isinstance(obj, string_types): return connect(obj, **params) return obj
[ "def", "get_database", "(", "obj", ",", "*", "*", "params", ")", ":", "if", "isinstance", "(", "obj", ",", "string_types", ")", ":", "return", "connect", "(", "obj", ",", "*", "*", "params", ")", "return", "obj" ]
Get database from given URI/Object.
[ "Get", "database", "from", "given", "URI", "/", "Object", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L244-L248
klen/flask-pw
flask_pw/__init__.py
Peewee.init_app
def init_app(self, app, database=None): """Initialize application.""" # Register application if not app: raise RuntimeError('Invalid application.') self.app = app if not hasattr(app, 'extensions'): app.extensions = {} app.extensions['peewee'] = se...
python
def init_app(self, app, database=None): """Initialize application.""" # Register application if not app: raise RuntimeError('Invalid application.') self.app = app if not hasattr(app, 'extensions'): app.extensions = {} app.extensions['peewee'] = se...
[ "def", "init_app", "(", "self", ",", "app", ",", "database", "=", "None", ")", ":", "# Register application", "if", "not", "app", ":", "raise", "RuntimeError", "(", "'Invalid application.'", ")", "self", ".", "app", "=", "app", "if", "not", "hasattr", "(",...
Initialize application.
[ "Initialize", "application", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L30-L70
klen/flask-pw
flask_pw/__init__.py
Peewee.close
def close(self, response): """Close connection to database.""" LOGGER.info('Closing [%s]', os.getpid()) if not self.database.is_closed(): self.database.close() return response
python
def close(self, response): """Close connection to database.""" LOGGER.info('Closing [%s]', os.getpid()) if not self.database.is_closed(): self.database.close() return response
[ "def", "close", "(", "self", ",", "response", ")", ":", "LOGGER", ".", "info", "(", "'Closing [%s]'", ",", "os", ".", "getpid", "(", ")", ")", "if", "not", "self", ".", "database", ".", "is_closed", "(", ")", ":", "self", ".", "database", ".", "clo...
Close connection to database.
[ "Close", "connection", "to", "database", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L77-L82
klen/flask-pw
flask_pw/__init__.py
Peewee.Model
def Model(self): """Bind model to self database.""" Model_ = self.app.config['PEEWEE_MODELS_CLASS'] meta_params = {'database': self.database} if self.slaves and self.app.config['PEEWEE_USE_READ_SLAVES']: meta_params['read_slaves'] = self.slaves Meta = type('Meta', ()...
python
def Model(self): """Bind model to self database.""" Model_ = self.app.config['PEEWEE_MODELS_CLASS'] meta_params = {'database': self.database} if self.slaves and self.app.config['PEEWEE_USE_READ_SLAVES']: meta_params['read_slaves'] = self.slaves Meta = type('Meta', ()...
[ "def", "Model", "(", "self", ")", ":", "Model_", "=", "self", ".", "app", ".", "config", "[", "'PEEWEE_MODELS_CLASS'", "]", "meta_params", "=", "{", "'database'", ":", "self", ".", "database", "}", "if", "self", ".", "slaves", "and", "self", ".", "app"...
Bind model to self database.
[ "Bind", "model", "to", "self", "database", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L85-L93
klen/flask-pw
flask_pw/__init__.py
Peewee.models
def models(self): """Return self.application models.""" Model_ = self.app.config['PEEWEE_MODELS_CLASS'] ignore = self.app.config['PEEWEE_MODELS_IGNORE'] models = [] if Model_ is not Model: try: mod = import_module(self.app.config['PEEWEE_MODELS_MODULE...
python
def models(self): """Return self.application models.""" Model_ = self.app.config['PEEWEE_MODELS_CLASS'] ignore = self.app.config['PEEWEE_MODELS_IGNORE'] models = [] if Model_ is not Model: try: mod = import_module(self.app.config['PEEWEE_MODELS_MODULE...
[ "def", "models", "(", "self", ")", ":", "Model_", "=", "self", ".", "app", ".", "config", "[", "'PEEWEE_MODELS_CLASS'", "]", "ignore", "=", "self", ".", "app", ".", "config", "[", "'PEEWEE_MODELS_IGNORE'", "]", "models", "=", "[", "]", "if", "Model_", ...
Return self.application models.
[ "Return", "self", ".", "application", "models", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L96-L115
klen/flask-pw
flask_pw/__init__.py
Peewee.cmd_create
def cmd_create(self, name, auto=False): """Create a new migration.""" LOGGER.setLevel('INFO') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], migrate_table=self.app.config['PEEWEE_MIG...
python
def cmd_create(self, name, auto=False): """Create a new migration.""" LOGGER.setLevel('INFO') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], migrate_table=self.app.config['PEEWEE_MIG...
[ "def", "cmd_create", "(", "self", ",", "name", ",", "auto", "=", "False", ")", ":", "LOGGER", ".", "setLevel", "(", "'INFO'", ")", "LOGGER", ".", "propagate", "=", "0", "router", "=", "Router", "(", "self", ".", "database", ",", "migrate_dir", "=", "...
Create a new migration.
[ "Create", "a", "new", "migration", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L117-L130
klen/flask-pw
flask_pw/__init__.py
Peewee.cmd_migrate
def cmd_migrate(self, name=None, fake=False): """Run migrations.""" from peewee_migrate.router import Router, LOGGER LOGGER.setLevel('INFO') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], ...
python
def cmd_migrate(self, name=None, fake=False): """Run migrations.""" from peewee_migrate.router import Router, LOGGER LOGGER.setLevel('INFO') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], ...
[ "def", "cmd_migrate", "(", "self", ",", "name", "=", "None", ",", "fake", "=", "False", ")", ":", "from", "peewee_migrate", ".", "router", "import", "Router", ",", "LOGGER", "LOGGER", ".", "setLevel", "(", "'INFO'", ")", "LOGGER", ".", "propagate", "=", ...
Run migrations.
[ "Run", "migrations", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L132-L145
klen/flask-pw
flask_pw/__init__.py
Peewee.cmd_rollback
def cmd_rollback(self, name): """Rollback migrations.""" from peewee_migrate.router import Router, LOGGER LOGGER.setLevel('INFO') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], ...
python
def cmd_rollback(self, name): """Rollback migrations.""" from peewee_migrate.router import Router, LOGGER LOGGER.setLevel('INFO') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], ...
[ "def", "cmd_rollback", "(", "self", ",", "name", ")", ":", "from", "peewee_migrate", ".", "router", "import", "Router", ",", "LOGGER", "LOGGER", ".", "setLevel", "(", "'INFO'", ")", "LOGGER", ".", "propagate", "=", "0", "router", "=", "Router", "(", "sel...
Rollback migrations.
[ "Rollback", "migrations", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L147-L158
klen/flask-pw
flask_pw/__init__.py
Peewee.cmd_list
def cmd_list(self): """List migrations.""" from peewee_migrate.router import Router, LOGGER LOGGER.setLevel('DEBUG') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], migrate_ta...
python
def cmd_list(self): """List migrations.""" from peewee_migrate.router import Router, LOGGER LOGGER.setLevel('DEBUG') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], migrate_ta...
[ "def", "cmd_list", "(", "self", ")", ":", "from", "peewee_migrate", ".", "router", "import", "Router", ",", "LOGGER", "LOGGER", ".", "setLevel", "(", "'DEBUG'", ")", "LOGGER", ".", "propagate", "=", "0", "router", "=", "Router", "(", "self", ".", "databa...
List migrations.
[ "List", "migrations", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L160-L175
klen/flask-pw
flask_pw/__init__.py
Peewee.cmd_merge
def cmd_merge(self): """Merge migrations.""" from peewee_migrate.router import Router, LOGGER LOGGER.setLevel('DEBUG') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], migrate_...
python
def cmd_merge(self): """Merge migrations.""" from peewee_migrate.router import Router, LOGGER LOGGER.setLevel('DEBUG') LOGGER.propagate = 0 router = Router(self.database, migrate_dir=self.app.config['PEEWEE_MIGRATE_DIR'], migrate_...
[ "def", "cmd_merge", "(", "self", ")", ":", "from", "peewee_migrate", ".", "router", "import", "Router", ",", "LOGGER", "LOGGER", ".", "setLevel", "(", "'DEBUG'", ")", "LOGGER", ".", "propagate", "=", "0", "router", "=", "Router", "(", "self", ".", "datab...
Merge migrations.
[ "Merge", "migrations", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L177-L188
klen/flask-pw
flask_pw/__init__.py
Peewee.manager
def manager(self): """Integrate a Flask-Script.""" from flask_script import Manager, Command manager = Manager(usage="Migrate database.") manager.add_command('create', Command(self.cmd_create)) manager.add_command('migrate', Command(self.cmd_migrate)) manager.add_command...
python
def manager(self): """Integrate a Flask-Script.""" from flask_script import Manager, Command manager = Manager(usage="Migrate database.") manager.add_command('create', Command(self.cmd_create)) manager.add_command('migrate', Command(self.cmd_migrate)) manager.add_command...
[ "def", "manager", "(", "self", ")", ":", "from", "flask_script", "import", "Manager", ",", "Command", "manager", "=", "Manager", "(", "usage", "=", "\"Migrate database.\"", ")", "manager", ".", "add_command", "(", "'create'", ",", "Command", "(", "self", "."...
Integrate a Flask-Script.
[ "Integrate", "a", "Flask", "-", "Script", "." ]
train
https://github.com/klen/flask-pw/blob/04d7846f0c89f2b2331b238b1c8223368c2a40a7/flask_pw/__init__.py#L191-L202
pimusicbox/mopidy-websettings
mopidy_websettings/__init__.py
restart_program
def restart_program(): """ DOES NOT WORK WELL WITH MOPIDY Hack from https://www.daniweb.com/software-development/python/code/260268/restart-your-python-program to support updating the settings, since mopidy is not able to do that yet Restarts the current program Note: this function does not ...
python
def restart_program(): """ DOES NOT WORK WELL WITH MOPIDY Hack from https://www.daniweb.com/software-development/python/code/260268/restart-your-python-program to support updating the settings, since mopidy is not able to do that yet Restarts the current program Note: this function does not ...
[ "def", "restart_program", "(", ")", ":", "python", "=", "sys", ".", "executable", "os", ".", "execl", "(", "python", ",", "python", ",", "*", "sys", ".", "argv", ")" ]
DOES NOT WORK WELL WITH MOPIDY Hack from https://www.daniweb.com/software-development/python/code/260268/restart-your-python-program to support updating the settings, since mopidy is not able to do that yet Restarts the current program Note: this function does not return. Any cleanup action (like ...
[ "DOES", "NOT", "WORK", "WELL", "WITH", "MOPIDY", "Hack", "from", "https", ":", "//", "www", ".", "daniweb", ".", "com", "/", "software", "-", "development", "/", "python", "/", "code", "/", "260268", "/", "restart", "-", "your", "-", "python", "-", "...
train
https://github.com/pimusicbox/mopidy-websettings/blob/a9aca8e15a29f323e7d91e3f2237f4605e2892e3/mopidy_websettings/__init__.py#L33-L45
garicchi/arff2pandas
arff2pandas/a2p.py
__load
def __load(arff): """ load liac-arff to pandas DataFrame :param dict arff:arff dict created liac-arff :rtype: DataFrame :return: pandas DataFrame """ attrs = arff['attributes'] attrs_t = [] for attr in attrs: if isinstance(attr[1], list): attrs_t.append("%s@{%s}" ...
python
def __load(arff): """ load liac-arff to pandas DataFrame :param dict arff:arff dict created liac-arff :rtype: DataFrame :return: pandas DataFrame """ attrs = arff['attributes'] attrs_t = [] for attr in attrs: if isinstance(attr[1], list): attrs_t.append("%s@{%s}" ...
[ "def", "__load", "(", "arff", ")", ":", "attrs", "=", "arff", "[", "'attributes'", "]", "attrs_t", "=", "[", "]", "for", "attr", "in", "attrs", ":", "if", "isinstance", "(", "attr", "[", "1", "]", ",", "list", ")", ":", "attrs_t", ".", "append", ...
load liac-arff to pandas DataFrame :param dict arff:arff dict created liac-arff :rtype: DataFrame :return: pandas DataFrame
[ "load", "liac", "-", "arff", "to", "pandas", "DataFrame", ":", "param", "dict", "arff", ":", "arff", "dict", "created", "liac", "-", "arff", ":", "rtype", ":", "DataFrame", ":", "return", ":", "pandas", "DataFrame" ]
train
https://github.com/garicchi/arff2pandas/blob/6698a3f57a9c227c8f38deb827b53b80b8c6a231/arff2pandas/a2p.py#L5-L21
garicchi/arff2pandas
arff2pandas/a2p.py
__dump
def __dump(df,relation='data',description=''): """ dump DataFrame to liac-arff :param DataFrame df: :param str relation: :param str description: :rtype: dict :return: liac-arff dict """ attrs = [] for col in df.columns: attr = col.split('@') if attr[1].count('...
python
def __dump(df,relation='data',description=''): """ dump DataFrame to liac-arff :param DataFrame df: :param str relation: :param str description: :rtype: dict :return: liac-arff dict """ attrs = [] for col in df.columns: attr = col.split('@') if attr[1].count('...
[ "def", "__dump", "(", "df", ",", "relation", "=", "'data'", ",", "description", "=", "''", ")", ":", "attrs", "=", "[", "]", "for", "col", "in", "df", ".", "columns", ":", "attr", "=", "col", ".", "split", "(", "'@'", ")", "if", "attr", "[", "1...
dump DataFrame to liac-arff :param DataFrame df: :param str relation: :param str description: :rtype: dict :return: liac-arff dict
[ "dump", "DataFrame", "to", "liac", "-", "arff", ":", "param", "DataFrame", "df", ":", ":", "param", "str", "relation", ":", ":", "param", "str", "description", ":", ":", "rtype", ":", "dict", ":", "return", ":", "liac", "-", "arff", "dict" ]
train
https://github.com/garicchi/arff2pandas/blob/6698a3f57a9c227c8f38deb827b53b80b8c6a231/arff2pandas/a2p.py#L46-L71
garicchi/arff2pandas
arff2pandas/a2p.py
dump
def dump(df,fp): """ dump DataFrame to file :param DataFrame df: :param file fp: """ arff = __dump(df) liacarff.dump(arff,fp)
python
def dump(df,fp): """ dump DataFrame to file :param DataFrame df: :param file fp: """ arff = __dump(df) liacarff.dump(arff,fp)
[ "def", "dump", "(", "df", ",", "fp", ")", ":", "arff", "=", "__dump", "(", "df", ")", "liacarff", ".", "dump", "(", "arff", ",", "fp", ")" ]
dump DataFrame to file :param DataFrame df: :param file fp:
[ "dump", "DataFrame", "to", "file", ":", "param", "DataFrame", "df", ":", ":", "param", "file", "fp", ":" ]
train
https://github.com/garicchi/arff2pandas/blob/6698a3f57a9c227c8f38deb827b53b80b8c6a231/arff2pandas/a2p.py#L74-L81
eerimoq/textparser
textparser.py
markup_line
def markup_line(text, offset, marker='>>!<<'): """Insert `marker` at `offset` into `text`, and return the marked line. .. code-block:: python >>> markup_line('0\\n1234\\n56', 3) 1>>!<<234 """ begin = text.rfind('\n', 0, offset) begin += 1 end = text.find('\n', offset) ...
python
def markup_line(text, offset, marker='>>!<<'): """Insert `marker` at `offset` into `text`, and return the marked line. .. code-block:: python >>> markup_line('0\\n1234\\n56', 3) 1>>!<<234 """ begin = text.rfind('\n', 0, offset) begin += 1 end = text.find('\n', offset) ...
[ "def", "markup_line", "(", "text", ",", "offset", ",", "marker", "=", "'>>!<<'", ")", ":", "begin", "=", "text", ".", "rfind", "(", "'\\n'", ",", "0", ",", "offset", ")", "begin", "+=", "1", "end", "=", "text", ".", "find", "(", "'\\n'", ",", "of...
Insert `marker` at `offset` into `text`, and return the marked line. .. code-block:: python >>> markup_line('0\\n1234\\n56', 3) 1>>!<<234
[ "Insert", "marker", "at", "offset", "into", "text", "and", "return", "the", "marked", "line", "." ]
train
https://github.com/eerimoq/textparser/blob/5f158210cfd3a20b19775191e92f22a13054a852/textparser.py#L698-L717
eerimoq/textparser
textparser.py
tokenize_init
def tokenize_init(spec): """Initialize a tokenizer. Should only be called by the :func:`~textparser.Parser.tokenize` method in the parser. """ tokens = [Token('__SOF__', '__SOF__', 0)] re_token = '|'.join([ '(?P<{}>{})'.format(name, regex) for name, regex in spec ]) return tokens,...
python
def tokenize_init(spec): """Initialize a tokenizer. Should only be called by the :func:`~textparser.Parser.tokenize` method in the parser. """ tokens = [Token('__SOF__', '__SOF__', 0)] re_token = '|'.join([ '(?P<{}>{})'.format(name, regex) for name, regex in spec ]) return tokens,...
[ "def", "tokenize_init", "(", "spec", ")", ":", "tokens", "=", "[", "Token", "(", "'__SOF__'", ",", "'__SOF__'", ",", "0", ")", "]", "re_token", "=", "'|'", ".", "join", "(", "[", "'(?P<{}>{})'", ".", "format", "(", "name", ",", "regex", ")", "for", ...
Initialize a tokenizer. Should only be called by the :func:`~textparser.Parser.tokenize` method in the parser.
[ "Initialize", "a", "tokenizer", ".", "Should", "only", "be", "called", "by", "the", ":", "func", ":", "~textparser", ".", "Parser", ".", "tokenize", "method", "in", "the", "parser", "." ]
train
https://github.com/eerimoq/textparser/blob/5f158210cfd3a20b19775191e92f22a13054a852/textparser.py#L730-L741
eerimoq/textparser
textparser.py
Parser.tokenize
def tokenize(self, text): """Tokenize given string `text`, and return a list of tokens. Raises :class:`~textparser.TokenizeError` on failure. This method should only be called by :func:`~textparser.Parser.parse()`, but may very well be overridden if the default implementation do...
python
def tokenize(self, text): """Tokenize given string `text`, and return a list of tokens. Raises :class:`~textparser.TokenizeError` on failure. This method should only be called by :func:`~textparser.Parser.parse()`, but may very well be overridden if the default implementation do...
[ "def", "tokenize", "(", "self", ",", "text", ")", ":", "names", ",", "specs", "=", "self", ".", "_unpack_token_specs", "(", ")", "keywords", "=", "self", ".", "keywords", "(", ")", "tokens", ",", "re_token", "=", "tokenize_init", "(", "specs", ")", "fo...
Tokenize given string `text`, and return a list of tokens. Raises :class:`~textparser.TokenizeError` on failure. This method should only be called by :func:`~textparser.Parser.parse()`, but may very well be overridden if the default implementation does not match the parser needs...
[ "Tokenize", "given", "string", "text", "and", "return", "a", "list", "of", "tokens", ".", "Raises", ":", "class", ":", "~textparser", ".", "TokenizeError", "on", "failure", "." ]
train
https://github.com/eerimoq/textparser/blob/5f158210cfd3a20b19775191e92f22a13054a852/textparser.py#L809-L842
eerimoq/textparser
textparser.py
Parser.parse
def parse(self, text, token_tree=False, match_sof=False): """Parse given string `text` and return the parse tree. Raises :class:`~textparser.ParseError` on failure. Returns a parse tree of tokens if `token_tree` is ``True``. .. code-block:: python >>> MyParser().parse('Hell...
python
def parse(self, text, token_tree=False, match_sof=False): """Parse given string `text` and return the parse tree. Raises :class:`~textparser.ParseError` on failure. Returns a parse tree of tokens if `token_tree` is ``True``. .. code-block:: python >>> MyParser().parse('Hell...
[ "def", "parse", "(", "self", ",", "text", ",", "token_tree", "=", "False", ",", "match_sof", "=", "False", ")", ":", "try", ":", "tokens", "=", "self", ".", "tokenize", "(", "text", ")", "if", "len", "(", "tokens", ")", "==", "0", "or", "tokens", ...
Parse given string `text` and return the parse tree. Raises :class:`~textparser.ParseError` on failure. Returns a parse tree of tokens if `token_tree` is ``True``. .. code-block:: python >>> MyParser().parse('Hello, World!') ['Hello', ',', 'World', '!'] >>> tr...
[ "Parse", "given", "string", "text", "and", "return", "the", "parse", "tree", ".", "Raises", ":", "class", ":", "~textparser", ".", "ParseError", "on", "failure", "." ]
train
https://github.com/eerimoq/textparser/blob/5f158210cfd3a20b19775191e92f22a13054a852/textparser.py#L854-L886
DataMedSci/beprof
beprof/profile.py
Profile.x_at_y
def x_at_y(self, y, reverse=False): """ Calculates inverse profile - for given y returns x such that f(x) = y If given y is not found in the self.y, then interpolation is used. By default returns first result looking from left, if reverse argument set to True, looks from ...
python
def x_at_y(self, y, reverse=False): """ Calculates inverse profile - for given y returns x such that f(x) = y If given y is not found in the self.y, then interpolation is used. By default returns first result looking from left, if reverse argument set to True, looks from ...
[ "def", "x_at_y", "(", "self", ",", "y", ",", "reverse", "=", "False", ")", ":", "logger", ".", "info", "(", "'Running %(name)s.y_at_x(y=%(y)s, reverse=%(rev)s)'", ",", "{", "\"name\"", ":", "self", ".", "__class__", ",", "\"y\"", ":", "y", ",", "\"rev\"", ...
Calculates inverse profile - for given y returns x such that f(x) = y If given y is not found in the self.y, then interpolation is used. By default returns first result looking from left, if reverse argument set to True, looks from right. If y is outside range of self.y then np.n...
[ "Calculates", "inverse", "profile", "-", "for", "given", "y", "returns", "x", "such", "that", "f", "(", "x", ")", "=", "y", "If", "given", "y", "is", "not", "found", "in", "the", "self", ".", "y", "then", "interpolation", "is", "used", ".", "By", "...
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/profile.py#L31-L117
DataMedSci/beprof
beprof/profile.py
Profile.width
def width(self, level): """ Width at given level :param level: :return: """ return self.x_at_y(level, reverse=True) - self.x_at_y(level)
python
def width(self, level): """ Width at given level :param level: :return: """ return self.x_at_y(level, reverse=True) - self.x_at_y(level)
[ "def", "width", "(", "self", ",", "level", ")", ":", "return", "self", ".", "x_at_y", "(", "level", ",", "reverse", "=", "True", ")", "-", "self", ".", "x_at_y", "(", "level", ")" ]
Width at given level :param level: :return:
[ "Width", "at", "given", "level", ":", "param", "level", ":", ":", "return", ":" ]
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/profile.py#L119-L125
DataMedSci/beprof
beprof/profile.py
Profile.normalize
def normalize(self, dt, allow_cast=True): """ Normalize to 1 over [-dt, +dt] area, if allow_cast is set to True, division not in place and casting may occur. If division in place is not possible and allow_cast is False an exception is raised. >>> a = Profile([[0, 0], [1,...
python
def normalize(self, dt, allow_cast=True): """ Normalize to 1 over [-dt, +dt] area, if allow_cast is set to True, division not in place and casting may occur. If division in place is not possible and allow_cast is False an exception is raised. >>> a = Profile([[0, 0], [1,...
[ "def", "normalize", "(", "self", ",", "dt", ",", "allow_cast", "=", "True", ")", ":", "if", "dt", "<=", "0", ":", "raise", "ValueError", "(", "\"Expected positive input\"", ")", "logger", ".", "info", "(", "'Running %(name)s.normalize(dt=%(dt)s)'", ",", "{", ...
Normalize to 1 over [-dt, +dt] area, if allow_cast is set to True, division not in place and casting may occur. If division in place is not possible and allow_cast is False an exception is raised. >>> a = Profile([[0, 0], [1, 5], [2, 10], [3, 5], [4, 0]]) >>> a.normalize(1, allo...
[ "Normalize", "to", "1", "over", "[", "-", "dt", "+", "dt", "]", "area", "if", "allow_cast", "is", "set", "to", "True", "division", "not", "in", "place", "and", "casting", "may", "occur", ".", "If", "division", "in", "place", "is", "not", "possible", ...
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/profile.py#L135-L166
DataMedSci/beprof
beprof/curve.py
Curve.rescale
def rescale(self, factor=1.0, allow_cast=True): """ Rescales self.y by given factor, if allow_cast is set to True and division in place is impossible - casting and not in place division may occur occur. If in place is impossible and allow_cast is set to False - an exception is ra...
python
def rescale(self, factor=1.0, allow_cast=True): """ Rescales self.y by given factor, if allow_cast is set to True and division in place is impossible - casting and not in place division may occur occur. If in place is impossible and allow_cast is set to False - an exception is ra...
[ "def", "rescale", "(", "self", ",", "factor", "=", "1.0", ",", "allow_cast", "=", "True", ")", ":", "try", ":", "self", ".", "y", "/=", "factor", "except", "TypeError", "as", "e", ":", "logger", ".", "warning", "(", "\"Division in place is impossible: %s\"...
Rescales self.y by given factor, if allow_cast is set to True and division in place is impossible - casting and not in place division may occur occur. If in place is impossible and allow_cast is set to False - an exception is raised. Check simple rescaling by 2 with no casting >...
[ "Rescales", "self", ".", "y", "by", "given", "factor", "if", "allow_cast", "is", "set", "to", "True", "and", "division", "in", "place", "is", "impossible", "-", "casting", "and", "not", "in", "place", "division", "may", "occur", "occur", ".", "If", "in",...
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/curve.py#L80-L115
DataMedSci/beprof
beprof/curve.py
Curve.change_domain
def change_domain(self, domain): """ Creating new Curve object in memory with domain passed as a parameter. New domain must include in the original domain. Copies values from original curve and uses interpolation to calculate values for new points in domain. Calculate y ...
python
def change_domain(self, domain): """ Creating new Curve object in memory with domain passed as a parameter. New domain must include in the original domain. Copies values from original curve and uses interpolation to calculate values for new points in domain. Calculate y ...
[ "def", "change_domain", "(", "self", ",", "domain", ")", ":", "logger", ".", "info", "(", "'Running %(name)s.change_domain() with new domain range:[%(ymin)s, %(ymax)s]'", ",", "{", "\"name\"", ":", "self", ".", "__class__", ",", "\"ymin\"", ":", "np", ".", "min", ...
Creating new Curve object in memory with domain passed as a parameter. New domain must include in the original domain. Copies values from original curve and uses interpolation to calculate values for new points in domain. Calculate y - values of example curve with changed domain: ...
[ "Creating", "new", "Curve", "object", "in", "memory", "with", "domain", "passed", "as", "a", "parameter", ".", "New", "domain", "must", "include", "in", "the", "original", "domain", ".", "Copies", "values", "from", "original", "curve", "and", "uses", "interp...
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/curve.py#L125-L160
DataMedSci/beprof
beprof/curve.py
Curve.rebinned
def rebinned(self, step=0.1, fixp=0): """ Provides effective way to compute new domain basing on step and fixp parameters. Then using change_domain() method to create new object with calculated domain and returns it. fixp doesn't have to be inside original domain. Retur...
python
def rebinned(self, step=0.1, fixp=0): """ Provides effective way to compute new domain basing on step and fixp parameters. Then using change_domain() method to create new object with calculated domain and returns it. fixp doesn't have to be inside original domain. Retur...
[ "def", "rebinned", "(", "self", ",", "step", "=", "0.1", ",", "fixp", "=", "0", ")", ":", "logger", ".", "info", "(", "'Running %(name)s.rebinned(step=%(st)s, fixp=%(fx)s)'", ",", "{", "\"name\"", ":", "self", ".", "__class__", ",", "\"st\"", ":", "step", ...
Provides effective way to compute new domain basing on step and fixp parameters. Then using change_domain() method to create new object with calculated domain and returns it. fixp doesn't have to be inside original domain. Return domain of a new curve specified by fixp=0 and st...
[ "Provides", "effective", "way", "to", "compute", "new", "domain", "basing", "on", "step", "and", "fixp", "parameters", ".", "Then", "using", "change_domain", "()", "method", "to", "create", "new", "object", "with", "calculated", "domain", "and", "returns", "it...
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/curve.py#L162-L199
DataMedSci/beprof
beprof/curve.py
Curve.evaluate_at_x
def evaluate_at_x(self, arg, def_val=0): """ Returns Y value at arg of self. Arg can be a scalar, but also might be np.array or other iterable (like list). If domain of self is not wide enough to interpolate the value of Y, method will return def_val for those arguments i...
python
def evaluate_at_x(self, arg, def_val=0): """ Returns Y value at arg of self. Arg can be a scalar, but also might be np.array or other iterable (like list). If domain of self is not wide enough to interpolate the value of Y, method will return def_val for those arguments i...
[ "def", "evaluate_at_x", "(", "self", ",", "arg", ",", "def_val", "=", "0", ")", ":", "y", "=", "np", ".", "interp", "(", "arg", ",", "self", ".", "x", ",", "self", ".", "y", ",", "left", "=", "def_val", ",", "right", "=", "def_val", ")", "retur...
Returns Y value at arg of self. Arg can be a scalar, but also might be np.array or other iterable (like list). If domain of self is not wide enough to interpolate the value of Y, method will return def_val for those arguments instead. Check the interpolation when arg in domain o...
[ "Returns", "Y", "value", "at", "arg", "of", "self", ".", "Arg", "can", "be", "a", "scalar", "but", "also", "might", "be", "np", ".", "array", "or", "other", "iterable", "(", "like", "list", ")", ".", "If", "domain", "of", "self", "is", "not", "wide...
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/curve.py#L201-L225
DataMedSci/beprof
beprof/curve.py
Curve.subtract
def subtract(self, curve2, new_obj=False): """ Method that calculates difference between 2 curves (or subclasses of curves). Domain of self must be in domain of curve2 what means min(self.x) >= min(curve2.x) and max(self.x) <= max(curve2.x). Might modify self, and can ret...
python
def subtract(self, curve2, new_obj=False): """ Method that calculates difference between 2 curves (or subclasses of curves). Domain of self must be in domain of curve2 what means min(self.x) >= min(curve2.x) and max(self.x) <= max(curve2.x). Might modify self, and can ret...
[ "def", "subtract", "(", "self", ",", "curve2", ",", "new_obj", "=", "False", ")", ":", "# domain1 = [a1, b1]", "# domain2 = [a2, b2]", "a1", ",", "b1", "=", "np", ".", "min", "(", "self", ".", "x", ")", ",", "np", ".", "max", "(", "self", ".", "x", ...
Method that calculates difference between 2 curves (or subclasses of curves). Domain of self must be in domain of curve2 what means min(self.x) >= min(curve2.x) and max(self.x) <= max(curve2.x). Might modify self, and can return the result or None Use subtract as -= operator, ch...
[ "Method", "that", "calculates", "difference", "between", "2", "curves", "(", "or", "subclasses", "of", "curves", ")", ".", "Domain", "of", "self", "must", "be", "in", "domain", "of", "curve2", "what", "means", "min", "(", "self", ".", "x", ")", ">", "=...
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/curve.py#L227-L275
asweigart/PyMsgBox
pymsgbox/_native_win.py
alert
def alert(text='', title='', button='OK'): """Displays a simple message box with text and a single OK button. Returns the text of the button clicked on.""" messageBoxFunc(0, text, title, MB_OK | MB_SETFOREGROUND | MB_TOPMOST) return button
python
def alert(text='', title='', button='OK'): """Displays a simple message box with text and a single OK button. Returns the text of the button clicked on.""" messageBoxFunc(0, text, title, MB_OK | MB_SETFOREGROUND | MB_TOPMOST) return button
[ "def", "alert", "(", "text", "=", "''", ",", "title", "=", "''", ",", "button", "=", "'OK'", ")", ":", "messageBoxFunc", "(", "0", ",", "text", ",", "title", ",", "MB_OK", "|", "MB_SETFOREGROUND", "|", "MB_TOPMOST", ")", "return", "button" ]
Displays a simple message box with text and a single OK button. Returns the text of the button clicked on.
[ "Displays", "a", "simple", "message", "box", "with", "text", "and", "a", "single", "OK", "button", ".", "Returns", "the", "text", "of", "the", "button", "clicked", "on", "." ]
train
https://github.com/asweigart/PyMsgBox/blob/c94325d21c08690dd89ebf9ebf1cf1b6ed54a1da/pymsgbox/_native_win.py#L39-L42
asweigart/PyMsgBox
pymsgbox/_native_win.py
confirm
def confirm(text='', title='', buttons=['OK', 'Cancel']): """Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on.""" retVal = messageBoxFunc(0, text, title, MB_OKCANCEL | MB_ICONQUESTION | MB_SETFOREGROUND | MB_TOPMOST) i...
python
def confirm(text='', title='', buttons=['OK', 'Cancel']): """Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on.""" retVal = messageBoxFunc(0, text, title, MB_OKCANCEL | MB_ICONQUESTION | MB_SETFOREGROUND | MB_TOPMOST) i...
[ "def", "confirm", "(", "text", "=", "''", ",", "title", "=", "''", ",", "buttons", "=", "[", "'OK'", ",", "'Cancel'", "]", ")", ":", "retVal", "=", "messageBoxFunc", "(", "0", ",", "text", ",", "title", ",", "MB_OKCANCEL", "|", "MB_ICONQUESTION", "|"...
Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on.
[ "Displays", "a", "message", "box", "with", "OK", "and", "Cancel", "buttons", ".", "Number", "and", "text", "of", "buttons", "can", "be", "customized", ".", "Returns", "the", "text", "of", "the", "button", "clicked", "on", "." ]
train
https://github.com/asweigart/PyMsgBox/blob/c94325d21c08690dd89ebf9ebf1cf1b6ed54a1da/pymsgbox/_native_win.py#L44-L52
DataMedSci/beprof
beprof/functions.py
subtract
def subtract(curve1, curve2, def_val=0): """ Function calculates difference between curve1 and curve2 and returns new object which domain is an union of curve1 and curve2 domains Returned object is of type type(curve1) and has same metadata as curve1 object :param curve1: first curve to cal...
python
def subtract(curve1, curve2, def_val=0): """ Function calculates difference between curve1 and curve2 and returns new object which domain is an union of curve1 and curve2 domains Returned object is of type type(curve1) and has same metadata as curve1 object :param curve1: first curve to cal...
[ "def", "subtract", "(", "curve1", ",", "curve2", ",", "def_val", "=", "0", ")", ":", "coord1", "=", "np", ".", "union1d", "(", "curve1", ".", "x", ",", "curve2", ".", "x", ")", "y1", "=", "curve1", ".", "evaluate_at_x", "(", "coord1", ",", "def_val...
Function calculates difference between curve1 and curve2 and returns new object which domain is an union of curve1 and curve2 domains Returned object is of type type(curve1) and has same metadata as curve1 object :param curve1: first curve to calculate the difference :param curve2: second curve...
[ "Function", "calculates", "difference", "between", "curve1", "and", "curve2", "and", "returns", "new", "object", "which", "domain", "is", "an", "union", "of", "curve1", "and", "curve2", "domains", "Returned", "object", "is", "of", "type", "type", "(", "curve1"...
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/functions.py#L4-L24
DataMedSci/beprof
beprof/functions.py
medfilt
def medfilt(vector, window): """ Apply a window-length median filter to a 1D array vector. Should get rid of 'spike' value 15. >>> print(medfilt(np.array([1., 15., 1., 1., 1.]), 3)) [1. 1. 1. 1. 1.] The 'edge' case is a bit tricky... >>> print(medfilt(np.array([15., 1., 1., 1., 1.]), 3)) ...
python
def medfilt(vector, window): """ Apply a window-length median filter to a 1D array vector. Should get rid of 'spike' value 15. >>> print(medfilt(np.array([1., 15., 1., 1., 1.]), 3)) [1. 1. 1. 1. 1.] The 'edge' case is a bit tricky... >>> print(medfilt(np.array([15., 1., 1., 1., 1.]), 3)) ...
[ "def", "medfilt", "(", "vector", ",", "window", ")", ":", "if", "not", "window", "%", "2", "==", "1", ":", "raise", "ValueError", "(", "\"Median filter length must be odd.\"", ")", "if", "not", "vector", ".", "ndim", "==", "1", ":", "raise", "ValueError", ...
Apply a window-length median filter to a 1D array vector. Should get rid of 'spike' value 15. >>> print(medfilt(np.array([1., 15., 1., 1., 1.]), 3)) [1. 1. 1. 1. 1.] The 'edge' case is a bit tricky... >>> print(medfilt(np.array([15., 1., 1., 1., 1.]), 3)) [15. 1. 1. 1. 1.] Inspired by...
[ "Apply", "a", "window", "-", "length", "median", "filter", "to", "a", "1D", "array", "vector", "." ]
train
https://github.com/DataMedSci/beprof/blob/f94c10929ea357bd0e5ead8f7a2d3061acfd6494/beprof/functions.py#L27-L56
JohannesBuchner/regulargrid
regulargrid/interpn.py
interpn
def interpn(*args, **kw): """Interpolation on N-D. ai = interpn(x, y, z, ..., a, xi, yi, zi, ...) where the arrays x, y, z, ... define a rectangular grid and a.shape == (len(x), len(y), len(z), ...) are the values interpolate at xi, yi, zi, ... """ method = kw.pop('method', 'cubic') if kw: raise ValueError(...
python
def interpn(*args, **kw): """Interpolation on N-D. ai = interpn(x, y, z, ..., a, xi, yi, zi, ...) where the arrays x, y, z, ... define a rectangular grid and a.shape == (len(x), len(y), len(z), ...) are the values interpolate at xi, yi, zi, ... """ method = kw.pop('method', 'cubic') if kw: raise ValueError(...
[ "def", "interpn", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "method", "=", "kw", ".", "pop", "(", "'method'", ",", "'cubic'", ")", "if", "kw", ":", "raise", "ValueError", "(", "\"Unknown arguments: \"", "%", "kw", ".", "keys", "(", ")", ")",...
Interpolation on N-D. ai = interpn(x, y, z, ..., a, xi, yi, zi, ...) where the arrays x, y, z, ... define a rectangular grid and a.shape == (len(x), len(y), len(z), ...) are the values interpolate at xi, yi, zi, ...
[ "Interpolation", "on", "N", "-", "D", "." ]
train
https://github.com/JohannesBuchner/regulargrid/blob/8803d8367c6b413d7a70ec474c67cc45ad8c00c8/regulargrid/interpn.py#L4-L24
JohannesBuchner/regulargrid
regulargrid/interpn.py
npinterpn
def npinterpn(*args, **kw): """Interpolation on N-D. ai = interpn(x, y, z, ..., a, xi, yi, zi, ...) where the arrays x, y, z, ... define a rectangular grid and a.shape == (len(x), len(y), len(z), ...) are the values interpolate at xi, yi, zi, ... """ method = kw.pop('method', 'cubic') if kw: raise ValueErro...
python
def npinterpn(*args, **kw): """Interpolation on N-D. ai = interpn(x, y, z, ..., a, xi, yi, zi, ...) where the arrays x, y, z, ... define a rectangular grid and a.shape == (len(x), len(y), len(z), ...) are the values interpolate at xi, yi, zi, ... """ method = kw.pop('method', 'cubic') if kw: raise ValueErro...
[ "def", "npinterpn", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "method", "=", "kw", ".", "pop", "(", "'method'", ",", "'cubic'", ")", "if", "kw", ":", "raise", "ValueError", "(", "\"Unknown arguments: \"", "%", "kw", ".", "keys", "(", ")", ")...
Interpolation on N-D. ai = interpn(x, y, z, ..., a, xi, yi, zi, ...) where the arrays x, y, z, ... define a rectangular grid and a.shape == (len(x), len(y), len(z), ...) are the values interpolate at xi, yi, zi, ...
[ "Interpolation", "on", "N", "-", "D", "." ]
train
https://github.com/JohannesBuchner/regulargrid/blob/8803d8367c6b413d7a70ec474c67cc45ad8c00c8/regulargrid/interpn.py#L26-L46
coleifer/wtf-peewee
wtfpeewee/orm.py
model_fields
def model_fields(model, allow_pk=False, only=None, exclude=None, field_args=None, converter=None): """ Generate a dictionary of fields for a given Peewee model. See `model_form` docstring for description of parameters. """ converter = converter or ModelConverter() field_args = ...
python
def model_fields(model, allow_pk=False, only=None, exclude=None, field_args=None, converter=None): """ Generate a dictionary of fields for a given Peewee model. See `model_form` docstring for description of parameters. """ converter = converter or ModelConverter() field_args = ...
[ "def", "model_fields", "(", "model", ",", "allow_pk", "=", "False", ",", "only", "=", "None", ",", "exclude", "=", "None", ",", "field_args", "=", "None", ",", "converter", "=", "None", ")", ":", "converter", "=", "converter", "or", "ModelConverter", "("...
Generate a dictionary of fields for a given Peewee model. See `model_form` docstring for description of parameters.
[ "Generate", "a", "dictionary", "of", "fields", "for", "a", "given", "Peewee", "model", "." ]
train
https://github.com/coleifer/wtf-peewee/blob/f062c59b05ce9ba74467514a272d353f803f37d1/wtfpeewee/orm.py#L194-L221
coleifer/wtf-peewee
wtfpeewee/orm.py
model_form
def model_form(model, base_class=Form, allow_pk=False, only=None, exclude=None, field_args=None, converter=None): """ Create a wtforms Form for a given Peewee model class:: from wtfpeewee.orm import model_form from myproject.myapp.models import User UserForm = model_form(...
python
def model_form(model, base_class=Form, allow_pk=False, only=None, exclude=None, field_args=None, converter=None): """ Create a wtforms Form for a given Peewee model class:: from wtfpeewee.orm import model_form from myproject.myapp.models import User UserForm = model_form(...
[ "def", "model_form", "(", "model", ",", "base_class", "=", "Form", ",", "allow_pk", "=", "False", ",", "only", "=", "None", ",", "exclude", "=", "None", ",", "field_args", "=", "None", ",", "converter", "=", "None", ")", ":", "field_dict", "=", "model_...
Create a wtforms Form for a given Peewee model class:: from wtfpeewee.orm import model_form from myproject.myapp.models import User UserForm = model_form(User) :param model: A Peewee model class :param base_class: Base form class to extend from. Must be a ``wtforms.Form...
[ "Create", "a", "wtforms", "Form", "for", "a", "given", "Peewee", "model", "class", "::" ]
train
https://github.com/coleifer/wtf-peewee/blob/f062c59b05ce9ba74467514a272d353f803f37d1/wtfpeewee/orm.py#L224-L251
asweigart/PyMsgBox
pymsgbox/__init__.py
alert
def alert(text='', title='', button=OK_TEXT, root=None, timeout=None): """Displays a simple message box with text and a single OK button. Returns the text of the button clicked on.""" assert TKINTER_IMPORT_SUCCEEDED, 'Tkinter is required for pymsgbox' return _buttonbox(msg=text, title=title, choices=[str(bu...
python
def alert(text='', title='', button=OK_TEXT, root=None, timeout=None): """Displays a simple message box with text and a single OK button. Returns the text of the button clicked on.""" assert TKINTER_IMPORT_SUCCEEDED, 'Tkinter is required for pymsgbox' return _buttonbox(msg=text, title=title, choices=[str(bu...
[ "def", "alert", "(", "text", "=", "''", ",", "title", "=", "''", ",", "button", "=", "OK_TEXT", ",", "root", "=", "None", ",", "timeout", "=", "None", ")", ":", "assert", "TKINTER_IMPORT_SUCCEEDED", ",", "'Tkinter is required for pymsgbox'", "return", "_butt...
Displays a simple message box with text and a single OK button. Returns the text of the button clicked on.
[ "Displays", "a", "simple", "message", "box", "with", "text", "and", "a", "single", "OK", "button", ".", "Returns", "the", "text", "of", "the", "button", "clicked", "on", "." ]
train
https://github.com/asweigart/PyMsgBox/blob/c94325d21c08690dd89ebf9ebf1cf1b6ed54a1da/pymsgbox/__init__.py#L97-L100
asweigart/PyMsgBox
pymsgbox/__init__.py
confirm
def confirm(text='', title='', buttons=[OK_TEXT, CANCEL_TEXT], root=None, timeout=None): """Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on.""" assert TKINTER_IMPORT_SUCCEEDED, 'Tkinter is required for pymsgbox' retur...
python
def confirm(text='', title='', buttons=[OK_TEXT, CANCEL_TEXT], root=None, timeout=None): """Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on.""" assert TKINTER_IMPORT_SUCCEEDED, 'Tkinter is required for pymsgbox' retur...
[ "def", "confirm", "(", "text", "=", "''", ",", "title", "=", "''", ",", "buttons", "=", "[", "OK_TEXT", ",", "CANCEL_TEXT", "]", ",", "root", "=", "None", ",", "timeout", "=", "None", ")", ":", "assert", "TKINTER_IMPORT_SUCCEEDED", ",", "'Tkinter is requ...
Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on.
[ "Displays", "a", "message", "box", "with", "OK", "and", "Cancel", "buttons", ".", "Number", "and", "text", "of", "buttons", "can", "be", "customized", ".", "Returns", "the", "text", "of", "the", "button", "clicked", "on", "." ]
train
https://github.com/asweigart/PyMsgBox/blob/c94325d21c08690dd89ebf9ebf1cf1b6ed54a1da/pymsgbox/__init__.py#L103-L106
asweigart/PyMsgBox
pymsgbox/__init__.py
prompt
def prompt(text='', title='' , default='', root=None, timeout=None): """Displays a message box with text input, and OK & Cancel buttons. Returns the text entered, or None if Cancel was clicked.""" assert TKINTER_IMPORT_SUCCEEDED, 'Tkinter is required for pymsgbox' return __fillablebox(text, title, default=d...
python
def prompt(text='', title='' , default='', root=None, timeout=None): """Displays a message box with text input, and OK & Cancel buttons. Returns the text entered, or None if Cancel was clicked.""" assert TKINTER_IMPORT_SUCCEEDED, 'Tkinter is required for pymsgbox' return __fillablebox(text, title, default=d...
[ "def", "prompt", "(", "text", "=", "''", ",", "title", "=", "''", ",", "default", "=", "''", ",", "root", "=", "None", ",", "timeout", "=", "None", ")", ":", "assert", "TKINTER_IMPORT_SUCCEEDED", ",", "'Tkinter is required for pymsgbox'", "return", "__fillab...
Displays a message box with text input, and OK & Cancel buttons. Returns the text entered, or None if Cancel was clicked.
[ "Displays", "a", "message", "box", "with", "text", "input", "and", "OK", "&", "Cancel", "buttons", ".", "Returns", "the", "text", "entered", "or", "None", "if", "Cancel", "was", "clicked", "." ]
train
https://github.com/asweigart/PyMsgBox/blob/c94325d21c08690dd89ebf9ebf1cf1b6ed54a1da/pymsgbox/__init__.py#L109-L112