id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
249,500
pavelsof/ipatok
ipatok/ipa.py
is_suprasegmental
def is_suprasegmental(char, strict=True): """ Check whether the character is a suprasegmental according to the IPA spec. This includes tones, word accents, and length markers. In strict mode return True only if the diacritic is part of the IPA spec. """ if (char in chart.suprasegmentals) or (char in chart.length...
python
def is_suprasegmental(char, strict=True): """ Check whether the character is a suprasegmental according to the IPA spec. This includes tones, word accents, and length markers. In strict mode return True only if the diacritic is part of the IPA spec. """ if (char in chart.suprasegmentals) or (char in chart.length...
[ "def", "is_suprasegmental", "(", "char", ",", "strict", "=", "True", ")", ":", "if", "(", "char", "in", "chart", ".", "suprasegmentals", ")", "or", "(", "char", "in", "chart", ".", "lengths", ")", ":", "return", "True", "return", "is_tone", "(", "char"...
Check whether the character is a suprasegmental according to the IPA spec. This includes tones, word accents, and length markers. In strict mode return True only if the diacritic is part of the IPA spec.
[ "Check", "whether", "the", "character", "is", "a", "suprasegmental", "according", "to", "the", "IPA", "spec", ".", "This", "includes", "tones", "word", "accents", "and", "length", "markers", "." ]
fde3c334b8573315fd1073f14341b71f50f7f006
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L152-L162
249,501
pavelsof/ipatok
ipatok/ipa.py
replace_substitutes
def replace_substitutes(string): """ Return the given string with all known common substitutes replaced with their IPA-compliant counterparts. """ for non_ipa, ipa in chart.replacements.items(): string = string.replace(non_ipa, ipa) return string
python
def replace_substitutes(string): """ Return the given string with all known common substitutes replaced with their IPA-compliant counterparts. """ for non_ipa, ipa in chart.replacements.items(): string = string.replace(non_ipa, ipa) return string
[ "def", "replace_substitutes", "(", "string", ")", ":", "for", "non_ipa", ",", "ipa", "in", "chart", ".", "replacements", ".", "items", "(", ")", ":", "string", "=", "string", ".", "replace", "(", "non_ipa", ",", "ipa", ")", "return", "string" ]
Return the given string with all known common substitutes replaced with their IPA-compliant counterparts.
[ "Return", "the", "given", "string", "with", "all", "known", "common", "substitutes", "replaced", "with", "their", "IPA", "-", "compliant", "counterparts", "." ]
fde3c334b8573315fd1073f14341b71f50f7f006
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L203-L211
249,502
pavelsof/ipatok
ipatok/ipa.py
Chart.load_ipa
def load_ipa(self, file_path): """ Populate the instance's set properties using the specified file. """ sections = { '# consonants (pulmonic)': self.consonants, '# consonants (non-pulmonic)': self.consonants, '# other symbols': self.consonants, '# tie bars': self.tie_bars, '# vowels': self.vowels...
python
def load_ipa(self, file_path): """ Populate the instance's set properties using the specified file. """ sections = { '# consonants (pulmonic)': self.consonants, '# consonants (non-pulmonic)': self.consonants, '# other symbols': self.consonants, '# tie bars': self.tie_bars, '# vowels': self.vowels...
[ "def", "load_ipa", "(", "self", ",", "file_path", ")", ":", "sections", "=", "{", "'# consonants (pulmonic)'", ":", "self", ".", "consonants", ",", "'# consonants (non-pulmonic)'", ":", "self", ".", "consonants", ",", "'# other symbols'", ":", "self", ".", "cons...
Populate the instance's set properties using the specified file.
[ "Populate", "the", "instance", "s", "set", "properties", "using", "the", "specified", "file", "." ]
fde3c334b8573315fd1073f14341b71f50f7f006
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L39-L65
249,503
pavelsof/ipatok
ipatok/ipa.py
Chart.load_replacements
def load_replacements(self, file_path): """ Populate self.replacements using the specified file. """ with open(file_path, encoding='utf-8') as f: for line in map(lambda x: x.strip(), f): if line: line = line.split('\t') self.replacements[line[0]] = line[1]
python
def load_replacements(self, file_path): """ Populate self.replacements using the specified file. """ with open(file_path, encoding='utf-8') as f: for line in map(lambda x: x.strip(), f): if line: line = line.split('\t') self.replacements[line[0]] = line[1]
[ "def", "load_replacements", "(", "self", ",", "file_path", ")", ":", "with", "open", "(", "file_path", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "for", "line", "in", "map", "(", "lambda", "x", ":", "x", ".", "strip", "(", ")", ",", "f",...
Populate self.replacements using the specified file.
[ "Populate", "self", ".", "replacements", "using", "the", "specified", "file", "." ]
fde3c334b8573315fd1073f14341b71f50f7f006
https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L67-L75
249,504
pmichali/whodunit
whodunit/__init__.py
sort_by_name
def sort_by_name(names): """Sort by last name, uniquely.""" def last_name_key(full_name): parts = full_name.split(' ') if len(parts) == 1: return full_name.upper() last_first = parts[-1] + ' ' + ' '.join(parts[:-1]) return last_first.upper() return sorted(set(na...
python
def sort_by_name(names): """Sort by last name, uniquely.""" def last_name_key(full_name): parts = full_name.split(' ') if len(parts) == 1: return full_name.upper() last_first = parts[-1] + ' ' + ' '.join(parts[:-1]) return last_first.upper() return sorted(set(na...
[ "def", "sort_by_name", "(", "names", ")", ":", "def", "last_name_key", "(", "full_name", ")", ":", "parts", "=", "full_name", ".", "split", "(", "' '", ")", "if", "len", "(", "parts", ")", "==", "1", ":", "return", "full_name", ".", "upper", "(", ")"...
Sort by last name, uniquely.
[ "Sort", "by", "last", "name", "uniquely", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L467-L477
249,505
pmichali/whodunit
whodunit/__init__.py
BlameRecord.store_attribute
def store_attribute(self, key, value): """Store blame info we are interested in.""" if key == 'summary' or key == 'filename' or key == 'previous': return attr = key.replace('-', '_') if key.endswith('-time'): value = int(value) setattr(self, attr, value)
python
def store_attribute(self, key, value): """Store blame info we are interested in.""" if key == 'summary' or key == 'filename' or key == 'previous': return attr = key.replace('-', '_') if key.endswith('-time'): value = int(value) setattr(self, attr, value)
[ "def", "store_attribute", "(", "self", ",", "key", ",", "value", ")", ":", "if", "key", "==", "'summary'", "or", "key", "==", "'filename'", "or", "key", "==", "'previous'", ":", "return", "attr", "=", "key", ".", "replace", "(", "'-'", ",", "'_'", ")...
Store blame info we are interested in.
[ "Store", "blame", "info", "we", "are", "interested", "in", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L111-L118
249,506
pmichali/whodunit
whodunit/__init__.py
Owners.is_git_file
def is_git_file(cls, path, name): """Determine if file is known by git.""" os.chdir(path) p = subprocess.Popen(['git', 'ls-files', '--error-unmatch', name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.wait() return p.returncode == 0
python
def is_git_file(cls, path, name): """Determine if file is known by git.""" os.chdir(path) p = subprocess.Popen(['git', 'ls-files', '--error-unmatch', name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.wait() return p.returncode == 0
[ "def", "is_git_file", "(", "cls", ",", "path", ",", "name", ")", ":", "os", ".", "chdir", "(", "path", ")", "p", "=", "subprocess", ".", "Popen", "(", "[", "'git'", ",", "'ls-files'", ",", "'--error-unmatch'", ",", "name", "]", ",", "stdout", "=", ...
Determine if file is known by git.
[ "Determine", "if", "file", "is", "known", "by", "git", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L175-L181
249,507
pmichali/whodunit
whodunit/__init__.py
Owners.collect_modules
def collect_modules(self): """Generator to look for git files in tree. Will handle all lines.""" for path, dirlist, filelist in os.walk(self.root): for name in fnmatch.filter(filelist, self.filter): if self.is_git_file(path, name): yield (os.path.join(path...
python
def collect_modules(self): """Generator to look for git files in tree. Will handle all lines.""" for path, dirlist, filelist in os.walk(self.root): for name in fnmatch.filter(filelist, self.filter): if self.is_git_file(path, name): yield (os.path.join(path...
[ "def", "collect_modules", "(", "self", ")", ":", "for", "path", ",", "dirlist", ",", "filelist", "in", "os", ".", "walk", "(", "self", ".", "root", ")", ":", "for", "name", "in", "fnmatch", ".", "filter", "(", "filelist", ",", "self", ".", "filter", ...
Generator to look for git files in tree. Will handle all lines.
[ "Generator", "to", "look", "for", "git", "files", "in", "tree", ".", "Will", "handle", "all", "lines", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L183-L188
249,508
pmichali/whodunit
whodunit/__init__.py
Owners.collect_blame_info
def collect_blame_info(cls, matches): """Runs git blame on files, for the specified sets of line ranges. If no line range tuples are provided, it will do all lines. """ old_area = None for filename, ranges in matches: area, name = os.path.split(filename) ...
python
def collect_blame_info(cls, matches): """Runs git blame on files, for the specified sets of line ranges. If no line range tuples are provided, it will do all lines. """ old_area = None for filename, ranges in matches: area, name = os.path.split(filename) ...
[ "def", "collect_blame_info", "(", "cls", ",", "matches", ")", ":", "old_area", "=", "None", "for", "filename", ",", "ranges", "in", "matches", ":", "area", ",", "name", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "if", "not", "area", ...
Runs git blame on files, for the specified sets of line ranges. If no line range tuples are provided, it will do all lines.
[ "Runs", "git", "blame", "on", "files", "for", "the", "specified", "sets", "of", "line", "ranges", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L195-L218
249,509
pmichali/whodunit
whodunit/__init__.py
Owners.unique_authors
def unique_authors(self, limit): """Unique list of authors, but preserving order.""" seen = set() if limit == 0: limit = None seen_add = seen.add # Assign to variable, so not resolved each time return [x.author for x in self.sorted_commits[:limit] if ...
python
def unique_authors(self, limit): """Unique list of authors, but preserving order.""" seen = set() if limit == 0: limit = None seen_add = seen.add # Assign to variable, so not resolved each time return [x.author for x in self.sorted_commits[:limit] if ...
[ "def", "unique_authors", "(", "self", ",", "limit", ")", ":", "seen", "=", "set", "(", ")", "if", "limit", "==", "0", ":", "limit", "=", "None", "seen_add", "=", "seen", ".", "add", "# Assign to variable, so not resolved each time", "return", "[", "x", "."...
Unique list of authors, but preserving order.
[ "Unique", "list", "of", "authors", "but", "preserving", "order", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L247-L254
249,510
pmichali/whodunit
whodunit/__init__.py
Owners.show
def show(self, commit): """Display one commit line. The output will be: <uuid> <#lines> <author> <short-commit-date> If verbose flag set, the output will be: <uuid> <#lines> <author+email> <long-date> <committer+email> """ author = commit.author ...
python
def show(self, commit): """Display one commit line. The output will be: <uuid> <#lines> <author> <short-commit-date> If verbose flag set, the output will be: <uuid> <#lines> <author+email> <long-date> <committer+email> """ author = commit.author ...
[ "def", "show", "(", "self", ",", "commit", ")", ":", "author", "=", "commit", ".", "author", "author_width", "=", "25", "committer", "=", "''", "commit_date", "=", "date_to_str", "(", "commit", ".", "committer_time", ",", "commit", ".", "committer_tz", ","...
Display one commit line. The output will be: <uuid> <#lines> <author> <short-commit-date> If verbose flag set, the output will be: <uuid> <#lines> <author+email> <long-date> <committer+email>
[ "Display", "one", "commit", "line", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L262-L282
249,511
pmichali/whodunit
whodunit/__init__.py
SizeOwners.merge_user_commits
def merge_user_commits(cls, commits): """Merge all the commits for the user. Aggregate line counts, and use the most recent commit (by date/time) as the representative commit for the user. """ user = None for commit in commits: if not user: us...
python
def merge_user_commits(cls, commits): """Merge all the commits for the user. Aggregate line counts, and use the most recent commit (by date/time) as the representative commit for the user. """ user = None for commit in commits: if not user: us...
[ "def", "merge_user_commits", "(", "cls", ",", "commits", ")", ":", "user", "=", "None", "for", "commit", "in", "commits", ":", "if", "not", "user", ":", "user", "=", "commit", "else", ":", "if", "commit", ".", "committer_time", ">", "user", ".", "commi...
Merge all the commits for the user. Aggregate line counts, and use the most recent commit (by date/time) as the representative commit for the user.
[ "Merge", "all", "the", "commits", "for", "the", "user", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L288-L304
249,512
pmichali/whodunit
whodunit/__init__.py
SizeOwners.sort
def sort(self): """Sort by commit size, per author.""" # First sort commits by author email users = [] # Group commits by author email, so they can be merged for _, group in itertools.groupby(sorted(self.commits), operator.attrgetter('aut...
python
def sort(self): """Sort by commit size, per author.""" # First sort commits by author email users = [] # Group commits by author email, so they can be merged for _, group in itertools.groupby(sorted(self.commits), operator.attrgetter('aut...
[ "def", "sort", "(", "self", ")", ":", "# First sort commits by author email", "users", "=", "[", "]", "# Group commits by author email, so they can be merged", "for", "_", ",", "group", "in", "itertools", ".", "groupby", "(", "sorted", "(", "self", ".", "commits", ...
Sort by commit size, per author.
[ "Sort", "by", "commit", "size", "per", "author", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L306-L319
249,513
pmichali/whodunit
whodunit/__init__.py
CoverageOwners.make_ranges
def make_ranges(cls, lines): """Convert list of lines into list of line range tuples. Only will be called if there is one or more entries in the list. Single lines, will be coverted into tuple with same line. """ start_line = last_line = lines.pop(0) ranges = [] ...
python
def make_ranges(cls, lines): """Convert list of lines into list of line range tuples. Only will be called if there is one or more entries in the list. Single lines, will be coverted into tuple with same line. """ start_line = last_line = lines.pop(0) ranges = [] ...
[ "def", "make_ranges", "(", "cls", ",", "lines", ")", ":", "start_line", "=", "last_line", "=", "lines", ".", "pop", "(", "0", ")", "ranges", "=", "[", "]", "for", "line", "in", "lines", ":", "if", "line", "==", "(", "last_line", "+", "1", ")", ":...
Convert list of lines into list of line range tuples. Only will be called if there is one or more entries in the list. Single lines, will be coverted into tuple with same line.
[ "Convert", "list", "of", "lines", "into", "list", "of", "line", "range", "tuples", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L340-L356
249,514
pmichali/whodunit
whodunit/__init__.py
CoverageOwners.determine_coverage
def determine_coverage(cls, coverage_file): """Scan the summary section of report looking for coverage data. Will see CSS class with "stm mis" (missing coverage), or "stm par" (partial coverage), and can extract line number. Will get file name from title tag. """ lines =...
python
def determine_coverage(cls, coverage_file): """Scan the summary section of report looking for coverage data. Will see CSS class with "stm mis" (missing coverage), or "stm par" (partial coverage), and can extract line number. Will get file name from title tag. """ lines =...
[ "def", "determine_coverage", "(", "cls", ",", "coverage_file", ")", ":", "lines", "=", "[", "]", "source_file", "=", "'ERROR'", "for", "line", "in", "coverage_file", ":", "m", "=", "title_re", ".", "match", "(", "line", ")", "if", "m", ":", "if", "m", ...
Scan the summary section of report looking for coverage data. Will see CSS class with "stm mis" (missing coverage), or "stm par" (partial coverage), and can extract line number. Will get file name from title tag.
[ "Scan", "the", "summary", "section", "of", "report", "looking", "for", "coverage", "data", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L359-L382
249,515
pmichali/whodunit
whodunit/__init__.py
CoverageOwners.collect_modules
def collect_modules(self): """Generator to obtain lines of interest from coverage report files. Will verify that the source file is within the project tree, relative to the coverage directory. """ coverage_dir = os.path.join(self.root, 'cover') for name in fnmatch.filter...
python
def collect_modules(self): """Generator to obtain lines of interest from coverage report files. Will verify that the source file is within the project tree, relative to the coverage directory. """ coverage_dir = os.path.join(self.root, 'cover') for name in fnmatch.filter...
[ "def", "collect_modules", "(", "self", ")", ":", "coverage_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "root", ",", "'cover'", ")", "for", "name", "in", "fnmatch", ".", "filter", "(", "os", ".", "listdir", "(", "coverage_dir", ")", "...
Generator to obtain lines of interest from coverage report files. Will verify that the source file is within the project tree, relative to the coverage directory.
[ "Generator", "to", "obtain", "lines", "of", "interest", "from", "coverage", "report", "files", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L384-L405
249,516
pmichali/whodunit
whodunit/__init__.py
CoverageOwners.sort
def sort(self): """Consolidate adjacent lines, if same commit ID. Will modify line number to be a range, when two or more lines with the same commit ID. """ self.sorted_commits = [] if not self.commits: return self.sorted_commits prev_commit = self.co...
python
def sort(self): """Consolidate adjacent lines, if same commit ID. Will modify line number to be a range, when two or more lines with the same commit ID. """ self.sorted_commits = [] if not self.commits: return self.sorted_commits prev_commit = self.co...
[ "def", "sort", "(", "self", ")", ":", "self", ".", "sorted_commits", "=", "[", "]", "if", "not", "self", ".", "commits", ":", "return", "self", ".", "sorted_commits", "prev_commit", "=", "self", ".", "commits", ".", "pop", "(", "0", ")", "prev_line", ...
Consolidate adjacent lines, if same commit ID. Will modify line number to be a range, when two or more lines with the same commit ID.
[ "Consolidate", "adjacent", "lines", "if", "same", "commit", "ID", "." ]
eed9107533766d716469e35fbb647a39dfa07035
https://github.com/pmichali/whodunit/blob/eed9107533766d716469e35fbb647a39dfa07035/whodunit/__init__.py#L414-L438
249,517
monkeython/scriba
scriba/schemes/scriba_ftps.py
write
def write(url, content, **args): """Put an object into a ftps URL.""" with FTPSResource(url, **args) as resource: resource.write(content)
python
def write(url, content, **args): """Put an object into a ftps URL.""" with FTPSResource(url, **args) as resource: resource.write(content)
[ "def", "write", "(", "url", ",", "content", ",", "*", "*", "args", ")", ":", "with", "FTPSResource", "(", "url", ",", "*", "*", "args", ")", "as", "resource", ":", "resource", ".", "write", "(", "content", ")" ]
Put an object into a ftps URL.
[ "Put", "an", "object", "into", "a", "ftps", "URL", "." ]
fb8e7636ed07c3d035433fdd153599ac8b24dfc4
https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/schemes/scriba_ftps.py#L27-L30
249,518
spookey/photon
photon/util/structures.py
yaml_str_join
def yaml_str_join(l, n): ''' YAML loader to join strings The keywords are as following: * `hostname`: Your hostname (from :func:`util.system.get_hostname`) * `timestamp`: Current timestamp (from :func:`util.system.get_timestamp`) :returns: A `non character` joined string |yaml_loader...
python
def yaml_str_join(l, n): ''' YAML loader to join strings The keywords are as following: * `hostname`: Your hostname (from :func:`util.system.get_hostname`) * `timestamp`: Current timestamp (from :func:`util.system.get_timestamp`) :returns: A `non character` joined string |yaml_loader...
[ "def", "yaml_str_join", "(", "l", ",", "n", ")", ":", "from", "photon", ".", "util", ".", "system", "import", "get_hostname", ",", "get_timestamp", "s", "=", "l", ".", "construct_sequence", "(", "n", ")", "for", "num", ",", "seq", "in", "enumerate", "(...
YAML loader to join strings The keywords are as following: * `hostname`: Your hostname (from :func:`util.system.get_hostname`) * `timestamp`: Current timestamp (from :func:`util.system.get_timestamp`) :returns: A `non character` joined string |yaml_loader_returns| .. note:: Be c...
[ "YAML", "loader", "to", "join", "strings" ]
57212a26ce713ab7723910ee49e3d0ba1697799f
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/structures.py#L11-L39
249,519
spookey/photon
photon/util/structures.py
yaml_loc_join
def yaml_loc_join(l, n): ''' YAML loader to join paths The keywords come directly from :func:`util.locations.get_locations`. See there! :returns: A `path seperator` (``/``) joined string |yaml_loader_returns| .. seealso:: |yaml_loader_seealso| ''' from photon.util.locations i...
python
def yaml_loc_join(l, n): ''' YAML loader to join paths The keywords come directly from :func:`util.locations.get_locations`. See there! :returns: A `path seperator` (``/``) joined string |yaml_loader_returns| .. seealso:: |yaml_loader_seealso| ''' from photon.util.locations i...
[ "def", "yaml_loc_join", "(", "l", ",", "n", ")", ":", "from", "photon", ".", "util", ".", "locations", "import", "get_locations", "locations", "=", "get_locations", "(", ")", "s", "=", "l", ".", "construct_sequence", "(", "n", ")", "for", "num", ",", "...
YAML loader to join paths The keywords come directly from :func:`util.locations.get_locations`. See there! :returns: A `path seperator` (``/``) joined string |yaml_loader_returns| .. seealso:: |yaml_loader_seealso|
[ "YAML", "loader", "to", "join", "paths" ]
57212a26ce713ab7723910ee49e3d0ba1697799f
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/structures.py#L42-L63
249,520
spookey/photon
photon/util/structures.py
dict_merge
def dict_merge(o, v): ''' Recursively climbs through dictionaries and merges them together. :param o: The first dictionary :param v: The second dictionary :returns: A dictionary (who would have guessed?) .. note:: Make sure `o` & `v` are indeed dictionaries, ...
python
def dict_merge(o, v): ''' Recursively climbs through dictionaries and merges them together. :param o: The first dictionary :param v: The second dictionary :returns: A dictionary (who would have guessed?) .. note:: Make sure `o` & `v` are indeed dictionaries, ...
[ "def", "dict_merge", "(", "o", ",", "v", ")", ":", "if", "not", "isinstance", "(", "v", ",", "dict", ")", ":", "return", "v", "res", "=", "_deepcopy", "(", "o", ")", "for", "key", "in", "v", ".", "keys", "(", ")", ":", "if", "res", ".", "get"...
Recursively climbs through dictionaries and merges them together. :param o: The first dictionary :param v: The second dictionary :returns: A dictionary (who would have guessed?) .. note:: Make sure `o` & `v` are indeed dictionaries, bad things will happen otherw...
[ "Recursively", "climbs", "through", "dictionaries", "and", "merges", "them", "together", "." ]
57212a26ce713ab7723910ee49e3d0ba1697799f
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/structures.py#L66-L90
249,521
spookey/photon
photon/util/structures.py
to_list
def to_list(i, use_keys=False): ''' Converts items to a list. :param i: Item to convert * If `i` is ``None``, the result is an empty list * If `i` is 'string', the result won't be \ ``['s', 't', 'r',...]`` rather more like ``['string']`` * If `i` is a nested dictionary, t...
python
def to_list(i, use_keys=False): ''' Converts items to a list. :param i: Item to convert * If `i` is ``None``, the result is an empty list * If `i` is 'string', the result won't be \ ``['s', 't', 'r',...]`` rather more like ``['string']`` * If `i` is a nested dictionary, t...
[ "def", "to_list", "(", "i", ",", "use_keys", "=", "False", ")", ":", "from", "photon", ".", "util", ".", "system", "import", "shell_notify", "if", "not", "i", ":", "return", "[", "]", "if", "isinstance", "(", "i", ",", "str", ")", ":", "return", "[...
Converts items to a list. :param i: Item to convert * If `i` is ``None``, the result is an empty list * If `i` is 'string', the result won't be \ ``['s', 't', 'r',...]`` rather more like ``['string']`` * If `i` is a nested dictionary, the result will be a flattened list. :pa...
[ "Converts", "items", "to", "a", "list", "." ]
57212a26ce713ab7723910ee49e3d0ba1697799f
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/structures.py#L93-L125
249,522
Ffisegydd/whatis
whatis/_core.py
this
def this(obj, **kwargs): """Prints series of debugging steps to user. Runs through pipeline of functions and print results of each. """ verbose = kwargs.get("verbose", True) if verbose: print('{:=^30}'.format(" whatis.this? ")) for func in pipeline: s = func(obj, **kwargs) ...
python
def this(obj, **kwargs): """Prints series of debugging steps to user. Runs through pipeline of functions and print results of each. """ verbose = kwargs.get("verbose", True) if verbose: print('{:=^30}'.format(" whatis.this? ")) for func in pipeline: s = func(obj, **kwargs) ...
[ "def", "this", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "verbose", "=", "kwargs", ".", "get", "(", "\"verbose\"", ",", "True", ")", "if", "verbose", ":", "print", "(", "'{:=^30}'", ".", "format", "(", "\" whatis.this? \"", ")", ")", "for", "fun...
Prints series of debugging steps to user. Runs through pipeline of functions and print results of each.
[ "Prints", "series", "of", "debugging", "steps", "to", "user", "." ]
eef780ced61aae6d001aeeef7574e5e27e613583
https://github.com/Ffisegydd/whatis/blob/eef780ced61aae6d001aeeef7574e5e27e613583/whatis/_core.py#L29-L45
249,523
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_get_repeat_masker_header
def _get_repeat_masker_header(pairwise_alignment): """generate header string of repeatmasker formated repr of self.""" res = "" res += str(pairwise_alignment.meta[ALIG_SCORE_KEY]) + " " res += "{:.2f}".format(pairwise_alignment.meta[PCENT_SUBS_KEY]) + " " res += "{:.2f}".format(pairwise_alignment.meta[PCENT_S...
python
def _get_repeat_masker_header(pairwise_alignment): """generate header string of repeatmasker formated repr of self.""" res = "" res += str(pairwise_alignment.meta[ALIG_SCORE_KEY]) + " " res += "{:.2f}".format(pairwise_alignment.meta[PCENT_SUBS_KEY]) + " " res += "{:.2f}".format(pairwise_alignment.meta[PCENT_S...
[ "def", "_get_repeat_masker_header", "(", "pairwise_alignment", ")", ":", "res", "=", "\"\"", "res", "+=", "str", "(", "pairwise_alignment", ".", "meta", "[", "ALIG_SCORE_KEY", "]", ")", "+", "\" \"", "res", "+=", "\"{:.2f}\"", ".", "format", "(", "pairwise_ali...
generate header string of repeatmasker formated repr of self.
[ "generate", "header", "string", "of", "repeatmasker", "formated", "repr", "of", "self", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L102-L137
249,524
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_is_alignment_line
def _rm_is_alignment_line(parts, s1_name, s2_name): """ return true if the tokenized line is a repeatmasker alignment line. :param parts: the line, already split into tokens around whitespace :param s1_name: the name of the first sequence, as extracted from the header of the element this li...
python
def _rm_is_alignment_line(parts, s1_name, s2_name): """ return true if the tokenized line is a repeatmasker alignment line. :param parts: the line, already split into tokens around whitespace :param s1_name: the name of the first sequence, as extracted from the header of the element this li...
[ "def", "_rm_is_alignment_line", "(", "parts", ",", "s1_name", ",", "s2_name", ")", ":", "if", "len", "(", "parts", ")", "<", "2", ":", "return", "False", "if", "_rm_name_match", "(", "parts", "[", "0", "]", ",", "s1_name", ")", ":", "return", "True", ...
return true if the tokenized line is a repeatmasker alignment line. :param parts: the line, already split into tokens around whitespace :param s1_name: the name of the first sequence, as extracted from the header of the element this line is in :param s2_name: the name of the second sequence, ...
[ "return", "true", "if", "the", "tokenized", "line", "is", "a", "repeatmasker", "alignment", "line", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L252-L269
249,525
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_is_header_line
def _rm_is_header_line(parts, n): """ determine whether a pre-split string is a repeat-masker alignment header. headers have no special structure or symbol to mark them, so this is based only on the number of elements, and what data type they are. """ if (n == 15 and parts[8] == "C"): return True if ...
python
def _rm_is_header_line(parts, n): """ determine whether a pre-split string is a repeat-masker alignment header. headers have no special structure or symbol to mark them, so this is based only on the number of elements, and what data type they are. """ if (n == 15 and parts[8] == "C"): return True if ...
[ "def", "_rm_is_header_line", "(", "parts", ",", "n", ")", ":", "if", "(", "n", "==", "15", "and", "parts", "[", "8", "]", "==", "\"C\"", ")", ":", "return", "True", "if", "(", "n", "==", "14", "and", "parts", "[", "0", "]", ".", "isdigit", "(",...
determine whether a pre-split string is a repeat-masker alignment header. headers have no special structure or symbol to mark them, so this is based only on the number of elements, and what data type they are.
[ "determine", "whether", "a", "pre", "-", "split", "string", "is", "a", "repeat", "-", "masker", "alignment", "header", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L272-L282
249,526
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_get_names_from_header
def _rm_get_names_from_header(parts): """ get repeat and seq. name from repeatmasker alignment header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 the genomic sequence name is always at position 4 (zero-based index); the name of the repeat is at ...
python
def _rm_get_names_from_header(parts): """ get repeat and seq. name from repeatmasker alignment header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 the genomic sequence name is always at position 4 (zero-based index); the name of the repeat is at ...
[ "def", "_rm_get_names_from_header", "(", "parts", ")", ":", "assert", "(", "(", "parts", "[", "8", "]", "==", "\"C\"", "and", "len", "(", "parts", ")", "==", "15", ")", "or", "(", "len", "(", "parts", ")", "==", "14", ")", ")", "return", "(", "pa...
get repeat and seq. name from repeatmasker alignment header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 the genomic sequence name is always at position 4 (zero-based index); the name of the repeat is at position 9 if matching the reverse complement ...
[ "get", "repeat", "and", "seq", ".", "name", "from", "repeatmasker", "alignment", "header", "line", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L333-L349
249,527
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_get_repeat_coords_from_header
def _rm_get_repeat_coords_from_header(parts): """ extract the repeat coordinates of a repeat masker match from a header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 239 29.42 1.92 0.97 chr1 11 17 (41) XX#YY 1 104 (74) m_b1s502i1 4 if the match ...
python
def _rm_get_repeat_coords_from_header(parts): """ extract the repeat coordinates of a repeat masker match from a header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 239 29.42 1.92 0.97 chr1 11 17 (41) XX#YY 1 104 (74) m_b1s502i1 4 if the match ...
[ "def", "_rm_get_repeat_coords_from_header", "(", "parts", ")", ":", "assert", "(", "(", "parts", "[", "8", "]", "==", "\"C\"", "and", "len", "(", "parts", ")", "==", "15", ")", "or", "(", "len", "(", "parts", ")", "==", "14", ")", ")", "if", "len",...
extract the repeat coordinates of a repeat masker match from a header line. An example header line is:: 239 29.42 1.92 0.97 chr1 11 17 (41) C XX#YY (74) 104 1 m_b1s502i1 4 239 29.42 1.92 0.97 chr1 11 17 (41) XX#YY 1 104 (74) m_b1s502i1 4 if the match is to the reverse complement, the start and end coordi...
[ "extract", "the", "repeat", "coordinates", "of", "a", "repeat", "masker", "match", "from", "a", "header", "line", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L374-L404
249,528
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_name_match
def _rm_name_match(s1, s2): """ determine whether two sequence names from a repeatmasker alignment match. :return: True if they are the same string, or if one forms a substring of the other, else False """ m_len = min(len(s1), len(s2)) return s1[:m_len] == s2[:m_len]
python
def _rm_name_match(s1, s2): """ determine whether two sequence names from a repeatmasker alignment match. :return: True if they are the same string, or if one forms a substring of the other, else False """ m_len = min(len(s1), len(s2)) return s1[:m_len] == s2[:m_len]
[ "def", "_rm_name_match", "(", "s1", ",", "s2", ")", ":", "m_len", "=", "min", "(", "len", "(", "s1", ")", ",", "len", "(", "s2", ")", ")", "return", "s1", "[", ":", "m_len", "]", "==", "s2", "[", ":", "m_len", "]" ]
determine whether two sequence names from a repeatmasker alignment match. :return: True if they are the same string, or if one forms a substring of the other, else False
[ "determine", "whether", "two", "sequence", "names", "from", "a", "repeatmasker", "alignment", "match", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L531-L539
249,529
pjuren/pyokit
src/pyokit/io/repeatmaskerAlignments.py
_rm_extract_sequence_and_name
def _rm_extract_sequence_and_name(alig_str_parts, s1_name, s2_name): """ parse an alignment line from a repeatmasker alignment and return the name of the sequence it si from and the sequence portion contained in the line. :param alig_str_parts: the alignment string, split around whitespace as list :param s1_...
python
def _rm_extract_sequence_and_name(alig_str_parts, s1_name, s2_name): """ parse an alignment line from a repeatmasker alignment and return the name of the sequence it si from and the sequence portion contained in the line. :param alig_str_parts: the alignment string, split around whitespace as list :param s1_...
[ "def", "_rm_extract_sequence_and_name", "(", "alig_str_parts", ",", "s1_name", ",", "s2_name", ")", ":", "# first, based on the number of parts we have we'll guess whether its a", "# reverse complement or not", "if", "len", "(", "alig_str_parts", ")", "==", "4", ":", "# expec...
parse an alignment line from a repeatmasker alignment and return the name of the sequence it si from and the sequence portion contained in the line. :param alig_str_parts: the alignment string, split around whitespace as list :param s1_name: the name of the first sequence in the alignment this line is ...
[ "parse", "an", "alignment", "line", "from", "a", "repeatmasker", "alignment", "and", "return", "the", "name", "of", "the", "sequence", "it", "si", "from", "and", "the", "sequence", "portion", "contained", "in", "the", "line", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAlignments.py#L555-L597
249,530
edeposit/edeposit.amqp.antivirus
src/edeposit/amqp/antivirus/wrappers/clamd.py
scan_file
def scan_file(path): """ Scan `path` for viruses using ``clamd`` antivirus daemon. Args: path (str): Relative or absolute path of file/directory you need to scan. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or blank dict. Raises: ValueError: ...
python
def scan_file(path): """ Scan `path` for viruses using ``clamd`` antivirus daemon. Args: path (str): Relative or absolute path of file/directory you need to scan. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or blank dict. Raises: ValueError: ...
[ "def", "scan_file", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "assert", "os", ".", "path", ".", "exists", "(", "path", ")", ",", "\"Unreachable file '%s'.\"", "%", "path", "try", ":", "cd", "=", "pyclamd...
Scan `path` for viruses using ``clamd`` antivirus daemon. Args: path (str): Relative or absolute path of file/directory you need to scan. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or blank dict. Raises: ValueError: When the server is not running. ...
[ "Scan", "path", "for", "viruses", "using", "clamd", "antivirus", "daemon", "." ]
011b38bbe920819fab99a5891b1e70732321a598
https://github.com/edeposit/edeposit.amqp.antivirus/blob/011b38bbe920819fab99a5891b1e70732321a598/src/edeposit/amqp/antivirus/wrappers/clamd.py#L16-L51
249,531
minhhoit/yacms
yacms/utils/timezone.py
get_best_local_timezone
def get_best_local_timezone(): """ Compares local timezone offset to pytz's timezone db, to determine a matching timezone name to use when TIME_ZONE is not set. """ zone_name = tzlocal.get_localzone().zone if zone_name in pytz.all_timezones: return zone_name if time.daylight: ...
python
def get_best_local_timezone(): """ Compares local timezone offset to pytz's timezone db, to determine a matching timezone name to use when TIME_ZONE is not set. """ zone_name = tzlocal.get_localzone().zone if zone_name in pytz.all_timezones: return zone_name if time.daylight: ...
[ "def", "get_best_local_timezone", "(", ")", ":", "zone_name", "=", "tzlocal", ".", "get_localzone", "(", ")", ".", "zone", "if", "zone_name", "in", "pytz", ".", "all_timezones", ":", "return", "zone_name", "if", "time", ".", "daylight", ":", "local_offset", ...
Compares local timezone offset to pytz's timezone db, to determine a matching timezone name to use when TIME_ZONE is not set.
[ "Compares", "local", "timezone", "offset", "to", "pytz", "s", "timezone", "db", "to", "determine", "a", "matching", "timezone", "name", "to", "use", "when", "TIME_ZONE", "is", "not", "set", "." ]
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/timezone.py#L9-L30
249,532
tBaxter/django-fretboard
fretboard/templatetags/fretboard_tags.py
topic_quick_links
def topic_quick_links(context, topic, latest, last_seen_time): """ Creates topic listing page links for the given topic, with the given number of posts per page. Topics with between 2 and 5 pages will have page links displayed for each page. Topics with more than 5 pages will have page links d...
python
def topic_quick_links(context, topic, latest, last_seen_time): """ Creates topic listing page links for the given topic, with the given number of posts per page. Topics with between 2 and 5 pages will have page links displayed for each page. Topics with more than 5 pages will have page links d...
[ "def", "topic_quick_links", "(", "context", ",", "topic", ",", "latest", ",", "last_seen_time", ")", ":", "output_text", "=", "u''", "pages", "=", "topic", ".", "page_count", "if", "not", "pages", "or", "pages", "==", "0", ":", "hits", "=", "topic", ".",...
Creates topic listing page links for the given topic, with the given number of posts per page. Topics with between 2 and 5 pages will have page links displayed for each page. Topics with more than 5 pages will have page links displayed for the first page and the last 3 pages.
[ "Creates", "topic", "listing", "page", "links", "for", "the", "given", "topic", "with", "the", "given", "number", "of", "posts", "per", "page", "." ]
3c3f9557089821283f315a07f3e5a57a2725ab3b
https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/templatetags/fretboard_tags.py#L46-L101
249,533
django-xxx/django-mobi2
mobi2/middleware.py
ignore_user_agent
def ignore_user_agent(user_agent): """ compare the useragent from the broswer to the ignore list This is popular if you want a mobile device to not trigger as mobile. For example iPad.""" if user_agent: for ua in MOBI_USER_AGENT_IGNORE_LIST: if ua and ua.lower() in user_agent...
python
def ignore_user_agent(user_agent): """ compare the useragent from the broswer to the ignore list This is popular if you want a mobile device to not trigger as mobile. For example iPad.""" if user_agent: for ua in MOBI_USER_AGENT_IGNORE_LIST: if ua and ua.lower() in user_agent...
[ "def", "ignore_user_agent", "(", "user_agent", ")", ":", "if", "user_agent", ":", "for", "ua", "in", "MOBI_USER_AGENT_IGNORE_LIST", ":", "if", "ua", "and", "ua", ".", "lower", "(", ")", "in", "user_agent", ".", "lower", "(", ")", ":", "return", "True", "...
compare the useragent from the broswer to the ignore list This is popular if you want a mobile device to not trigger as mobile. For example iPad.
[ "compare", "the", "useragent", "from", "the", "broswer", "to", "the", "ignore", "list", "This", "is", "popular", "if", "you", "want", "a", "mobile", "device", "to", "not", "trigger", "as", "mobile", ".", "For", "example", "iPad", "." ]
7ac323faa1a9599f3cd39acd3c49626819ce0538
https://github.com/django-xxx/django-mobi2/blob/7ac323faa1a9599f3cd39acd3c49626819ce0538/mobi2/middleware.py#L13-L21
249,534
django-xxx/django-mobi2
mobi2/middleware.py
MobileDetectionMiddleware.process_request
def process_request(request): """Adds a "mobile" attribute to the request which is True or False depending on whether the request should be considered to come from a small-screen device such as a phone or a PDA""" if 'HTTP_X_OPERAMINI_FEATURES' in request.META: # Then ...
python
def process_request(request): """Adds a "mobile" attribute to the request which is True or False depending on whether the request should be considered to come from a small-screen device such as a phone or a PDA""" if 'HTTP_X_OPERAMINI_FEATURES' in request.META: # Then ...
[ "def", "process_request", "(", "request", ")", ":", "if", "'HTTP_X_OPERAMINI_FEATURES'", "in", "request", ".", "META", ":", "# Then it's running opera mini. 'Nuff said.", "# Reference from:", "# http://dev.opera.com/articles/view/opera-mini-request-headers/", "request", ".", "mob...
Adds a "mobile" attribute to the request which is True or False depending on whether the request should be considered to come from a small-screen device such as a phone or a PDA
[ "Adds", "a", "mobile", "attribute", "to", "the", "request", "which", "is", "True", "or", "False", "depending", "on", "whether", "the", "request", "should", "be", "considered", "to", "come", "from", "a", "small", "-", "screen", "device", "such", "as", "a", ...
7ac323faa1a9599f3cd39acd3c49626819ce0538
https://github.com/django-xxx/django-mobi2/blob/7ac323faa1a9599f3cd39acd3c49626819ce0538/mobi2/middleware.py#L26-L64
249,535
veltzer/pydmt
pydmt/core/pydmt.py
PyDMT.build_by_builder
def build_by_builder(self, builder: Builder, stats: BuildProcessStats): """ run one builder, return statistics about the run """ logger = logging.getLogger(__name__) target_signature = builder.get_signature() assert target_signature is not None, "builder signature is None" if sel...
python
def build_by_builder(self, builder: Builder, stats: BuildProcessStats): """ run one builder, return statistics about the run """ logger = logging.getLogger(__name__) target_signature = builder.get_signature() assert target_signature is not None, "builder signature is None" if sel...
[ "def", "build_by_builder", "(", "self", ",", "builder", ":", "Builder", ",", "stats", ":", "BuildProcessStats", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "target_signature", "=", "builder", ".", "get_signature", "(", ")", "a...
run one builder, return statistics about the run
[ "run", "one", "builder", "return", "statistics", "about", "the", "run" ]
11d3db7ea079756c1e4137d3dd8a2cabbcc98bf7
https://github.com/veltzer/pydmt/blob/11d3db7ea079756c1e4137d3dd8a2cabbcc98bf7/pydmt/core/pydmt.py#L53-L109
249,536
rgmining/ria
ria/bipartite.py
Reviewer.anomalous_score
def anomalous_score(self): """Anomalous score of this reviewer. Initial anomalous score is :math:`1 / |R|` where :math:`R` is a set of reviewers. """ return self._anomalous if self._anomalous else 1. / len(self._graph.reviewers)
python
def anomalous_score(self): """Anomalous score of this reviewer. Initial anomalous score is :math:`1 / |R|` where :math:`R` is a set of reviewers. """ return self._anomalous if self._anomalous else 1. / len(self._graph.reviewers)
[ "def", "anomalous_score", "(", "self", ")", ":", "return", "self", ".", "_anomalous", "if", "self", ".", "_anomalous", "else", "1.", "/", "len", "(", "self", ".", "_graph", ".", "reviewers", ")" ]
Anomalous score of this reviewer. Initial anomalous score is :math:`1 / |R|` where :math:`R` is a set of reviewers.
[ "Anomalous", "score", "of", "this", "reviewer", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L151-L157
249,537
rgmining/ria
ria/bipartite.py
Product.summary
def summary(self): """Summary of reviews for this product. Initial summary is computed by .. math:: \\frac{1}{|R|} \\sum_{r \\in R} \\mbox{review}(r), where :math:`\\mbox{review}(r)` means review from reviewer :math:`r`. """ if self._summary: r...
python
def summary(self): """Summary of reviews for this product. Initial summary is computed by .. math:: \\frac{1}{|R|} \\sum_{r \\in R} \\mbox{review}(r), where :math:`\\mbox{review}(r)` means review from reviewer :math:`r`. """ if self._summary: r...
[ "def", "summary", "(", "self", ")", ":", "if", "self", ".", "_summary", ":", "return", "self", ".", "_summary", "reviewers", "=", "self", ".", "_graph", ".", "retrieve_reviewers", "(", "self", ")", "return", "self", ".", "_summary_cls", "(", "[", "self",...
Summary of reviews for this product. Initial summary is computed by .. math:: \\frac{1}{|R|} \\sum_{r \\in R} \\mbox{review}(r), where :math:`\\mbox{review}(r)` means review from reviewer :math:`r`.
[ "Summary", "of", "reviews", "for", "this", "product", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L226-L242
249,538
rgmining/ria
ria/bipartite.py
Product.summary
def summary(self, v): """Set summary. Args: v: A new summary. It could be a single number or lists. """ if hasattr(v, "__iter__"): self._summary = self._summary_cls(v) else: self._summary = self._summary_cls(float(v))
python
def summary(self, v): """Set summary. Args: v: A new summary. It could be a single number or lists. """ if hasattr(v, "__iter__"): self._summary = self._summary_cls(v) else: self._summary = self._summary_cls(float(v))
[ "def", "summary", "(", "self", ",", "v", ")", ":", "if", "hasattr", "(", "v", ",", "\"__iter__\"", ")", ":", "self", ".", "_summary", "=", "self", ".", "_summary_cls", "(", "v", ")", "else", ":", "self", ".", "_summary", "=", "self", ".", "_summary...
Set summary. Args: v: A new summary. It could be a single number or lists.
[ "Set", "summary", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L245-L254
249,539
rgmining/ria
ria/bipartite.py
Product.update_summary
def update_summary(self, w): """Update summary. The new summary is a weighted average of reviews i.e. .. math:: \\frac{\\sum_{r \\in R} \\mbox{weight}(r) \\times \\mbox{review}(r)} {\\sum_{r \\in R} \\mbox{weight}(r)}, where :math:`R` is a set of reviewers...
python
def update_summary(self, w): """Update summary. The new summary is a weighted average of reviews i.e. .. math:: \\frac{\\sum_{r \\in R} \\mbox{weight}(r) \\times \\mbox{review}(r)} {\\sum_{r \\in R} \\mbox{weight}(r)}, where :math:`R` is a set of reviewers...
[ "def", "update_summary", "(", "self", ",", "w", ")", ":", "old", "=", "self", ".", "summary", ".", "v", "# pylint: disable=no-member", "reviewers", "=", "self", ".", "_graph", ".", "retrieve_reviewers", "(", "self", ")", "reviews", "=", "[", "self", ".", ...
Update summary. The new summary is a weighted average of reviews i.e. .. math:: \\frac{\\sum_{r \\in R} \\mbox{weight}(r) \\times \\mbox{review}(r)} {\\sum_{r \\in R} \\mbox{weight}(r)}, where :math:`R` is a set of reviewers reviewing this product, :math:`...
[ "Update", "summary", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L256-L286
249,540
rgmining/ria
ria/bipartite.py
BipartiteGraph.new_reviewer
def new_reviewer(self, name, anomalous=None): """Create a new reviewer. Args: name: name of the new reviewer. anomalous: initial anomalous score. (default: None) Returns: A new reviewer instance. """ n = self._reviewer_cls( self, name=n...
python
def new_reviewer(self, name, anomalous=None): """Create a new reviewer. Args: name: name of the new reviewer. anomalous: initial anomalous score. (default: None) Returns: A new reviewer instance. """ n = self._reviewer_cls( self, name=n...
[ "def", "new_reviewer", "(", "self", ",", "name", ",", "anomalous", "=", "None", ")", ":", "n", "=", "self", ".", "_reviewer_cls", "(", "self", ",", "name", "=", "name", ",", "credibility", "=", "self", ".", "credibility", ",", "anomalous", "=", "anomal...
Create a new reviewer. Args: name: name of the new reviewer. anomalous: initial anomalous score. (default: None) Returns: A new reviewer instance.
[ "Create", "a", "new", "reviewer", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L333-L347
249,541
rgmining/ria
ria/bipartite.py
BipartiteGraph.new_product
def new_product(self, name): """Create a new product. Args: name: name of the new product. Returns: A new product instance. """ n = self._product_cls(self, name, summary_cls=self._summary_cls) self.graph.add_node(n) self.products.append(n) ...
python
def new_product(self, name): """Create a new product. Args: name: name of the new product. Returns: A new product instance. """ n = self._product_cls(self, name, summary_cls=self._summary_cls) self.graph.add_node(n) self.products.append(n) ...
[ "def", "new_product", "(", "self", ",", "name", ")", ":", "n", "=", "self", ".", "_product_cls", "(", "self", ",", "name", ",", "summary_cls", "=", "self", ".", "_summary_cls", ")", "self", ".", "graph", ".", "add_node", "(", "n", ")", "self", ".", ...
Create a new product. Args: name: name of the new product. Returns: A new product instance.
[ "Create", "a", "new", "product", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L349-L361
249,542
rgmining/ria
ria/bipartite.py
BipartiteGraph.add_review
def add_review(self, reviewer, product, review, date=None): """Add a new review from a given reviewer to a given product. Args: reviewer: an instance of Reviewer. product: an instance of Product. review: a float value. date: date the review issued. Retur...
python
def add_review(self, reviewer, product, review, date=None): """Add a new review from a given reviewer to a given product. Args: reviewer: an instance of Reviewer. product: an instance of Product. review: a float value. date: date the review issued. Retur...
[ "def", "add_review", "(", "self", ",", "reviewer", ",", "product", ",", "review", ",", "date", "=", "None", ")", ":", "if", "not", "isinstance", "(", "reviewer", ",", "self", ".", "_reviewer_cls", ")", ":", "raise", "TypeError", "(", "\"Type of given revie...
Add a new review from a given reviewer to a given product. Args: reviewer: an instance of Reviewer. product: an instance of Product. review: a float value. date: date the review issued. Returns: the added new review object. Raises: T...
[ "Add", "a", "new", "review", "from", "a", "given", "reviewer", "to", "a", "given", "product", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L363-L389
249,543
rgmining/ria
ria/bipartite.py
BipartiteGraph.retrieve_products
def retrieve_products(self, reviewer): """Retrieve products reviewed by a given reviewer. Args: reviewer: A reviewer. Returns: A list of products which the reviewer reviews. Raises: TypeError: when given reviewer isn't instance of specified reviewer ...
python
def retrieve_products(self, reviewer): """Retrieve products reviewed by a given reviewer. Args: reviewer: A reviewer. Returns: A list of products which the reviewer reviews. Raises: TypeError: when given reviewer isn't instance of specified reviewer ...
[ "def", "retrieve_products", "(", "self", ",", "reviewer", ")", ":", "if", "not", "isinstance", "(", "reviewer", ",", "self", ".", "_reviewer_cls", ")", ":", "raise", "TypeError", "(", "\"Type of given reviewer isn't acceptable:\"", ",", "reviewer", ",", "\", expec...
Retrieve products reviewed by a given reviewer. Args: reviewer: A reviewer. Returns: A list of products which the reviewer reviews. Raises: TypeError: when given reviewer isn't instance of specified reviewer class when this graph is constructed.
[ "Retrieve", "products", "reviewed", "by", "a", "given", "reviewer", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L392-L409
249,544
rgmining/ria
ria/bipartite.py
BipartiteGraph.retrieve_reviewers
def retrieve_reviewers(self, product): """Retrieve reviewers who reviewed a given product. Args: product: A product specifying reviewers. Returns: A list of reviewers who review the product. Raises: TypeError: when given product isn't instance of specifie...
python
def retrieve_reviewers(self, product): """Retrieve reviewers who reviewed a given product. Args: product: A product specifying reviewers. Returns: A list of reviewers who review the product. Raises: TypeError: when given product isn't instance of specifie...
[ "def", "retrieve_reviewers", "(", "self", ",", "product", ")", ":", "if", "not", "isinstance", "(", "product", ",", "self", ".", "_product_cls", ")", ":", "raise", "TypeError", "(", "\"Type of given product isn't acceptable:\"", ",", "product", ",", "\", expected:...
Retrieve reviewers who reviewed a given product. Args: product: A product specifying reviewers. Returns: A list of reviewers who review the product. Raises: TypeError: when given product isn't instance of specified product class when this graph is con...
[ "Retrieve", "reviewers", "who", "reviewed", "a", "given", "product", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L412-L429
249,545
rgmining/ria
ria/bipartite.py
BipartiteGraph.retrieve_review
def retrieve_review(self, reviewer, product): """Retrieve review that the given reviewer put the given product. Args: reviewer: An instance of Reviewer. product: An instance of Product. Returns: A review object. Raises: TypeError: when given rev...
python
def retrieve_review(self, reviewer, product): """Retrieve review that the given reviewer put the given product. Args: reviewer: An instance of Reviewer. product: An instance of Product. Returns: A review object. Raises: TypeError: when given rev...
[ "def", "retrieve_review", "(", "self", ",", "reviewer", ",", "product", ")", ":", "if", "not", "isinstance", "(", "reviewer", ",", "self", ".", "_reviewer_cls", ")", ":", "raise", "TypeError", "(", "\"Type of given reviewer isn't acceptable:\"", ",", "reviewer", ...
Retrieve review that the given reviewer put the given product. Args: reviewer: An instance of Reviewer. product: An instance of Product. Returns: A review object. Raises: TypeError: when given reviewer and product aren't instance of specifie...
[ "Retrieve", "review", "that", "the", "given", "reviewer", "put", "the", "given", "product", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L432-L460
249,546
rgmining/ria
ria/bipartite.py
BipartiteGraph._weight_generator
def _weight_generator(self, reviewers): """Compute a weight function for the given reviewers. Args: reviewers: a set of reviewers to compute weight function. Returns: a function computing a weight for a reviewer. """ scores = [r.anomalous_score for r in revi...
python
def _weight_generator(self, reviewers): """Compute a weight function for the given reviewers. Args: reviewers: a set of reviewers to compute weight function. Returns: a function computing a weight for a reviewer. """ scores = [r.anomalous_score for r in revi...
[ "def", "_weight_generator", "(", "self", ",", "reviewers", ")", ":", "scores", "=", "[", "r", ".", "anomalous_score", "for", "r", "in", "reviewers", "]", "mu", "=", "np", ".", "average", "(", "scores", ")", "sigma", "=", "np", ".", "std", "(", "score...
Compute a weight function for the given reviewers. Args: reviewers: a set of reviewers to compute weight function. Returns: a function computing a weight for a reviewer.
[ "Compute", "a", "weight", "function", "for", "the", "given", "reviewers", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L474-L507
249,547
rgmining/ria
ria/bipartite.py
BipartiteGraph.dump_credibilities
def dump_credibilities(self, output): """Dump credibilities of all products. Args: output: a writable object. """ for p in self.products: json.dump({ "product_id": p.name, "credibility": self.credibility(p) }, output) ...
python
def dump_credibilities(self, output): """Dump credibilities of all products. Args: output: a writable object. """ for p in self.products: json.dump({ "product_id": p.name, "credibility": self.credibility(p) }, output) ...
[ "def", "dump_credibilities", "(", "self", ",", "output", ")", ":", "for", "p", "in", "self", ".", "products", ":", "json", ".", "dump", "(", "{", "\"product_id\"", ":", "p", ".", "name", ",", "\"credibility\"", ":", "self", ".", "credibility", "(", "p"...
Dump credibilities of all products. Args: output: a writable object.
[ "Dump", "credibilities", "of", "all", "products", "." ]
39223c67b7e59e10bd8e3a9062fb13f8bf893a5d
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L509-L520
249,548
pjuren/pyokit
src/pyokit/io/maf.py
merge_dictionaries
def merge_dictionaries(a, b): """Merge two dictionaries; duplicate keys get value from b.""" res = {} for k in a: res[k] = a[k] for k in b: res[k] = b[k] return res
python
def merge_dictionaries(a, b): """Merge two dictionaries; duplicate keys get value from b.""" res = {} for k in a: res[k] = a[k] for k in b: res[k] = b[k] return res
[ "def", "merge_dictionaries", "(", "a", ",", "b", ")", ":", "res", "=", "{", "}", "for", "k", "in", "a", ":", "res", "[", "k", "]", "=", "a", "[", "k", "]", "for", "k", "in", "b", ":", "res", "[", "k", "]", "=", "b", "[", "k", "]", "retu...
Merge two dictionaries; duplicate keys get value from b.
[ "Merge", "two", "dictionaries", ";", "duplicate", "keys", "get", "value", "from", "b", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/maf.py#L73-L80
249,549
pjuren/pyokit
src/pyokit/io/maf.py
__build_sequence
def __build_sequence(parts): """Build a sequence object using the pre-tokenized parts from a MAF line. s -- a sequence line; has 6 fields in addition to 's': * source sequence, * start coord. of seq., zero-based. If -'ve strand, rel to start of rev. comp. * ungapped length...
python
def __build_sequence(parts): """Build a sequence object using the pre-tokenized parts from a MAF line. s -- a sequence line; has 6 fields in addition to 's': * source sequence, * start coord. of seq., zero-based. If -'ve strand, rel to start of rev. comp. * ungapped length...
[ "def", "__build_sequence", "(", "parts", ")", ":", "strand", "=", "parts", "[", "4", "]", "seq_length", "=", "int", "(", "parts", "[", "3", "]", ")", "total_seq_len", "=", "int", "(", "parts", "[", "5", "]", ")", "start", "=", "(", "int", "(", "p...
Build a sequence object using the pre-tokenized parts from a MAF line. s -- a sequence line; has 6 fields in addition to 's': * source sequence, * start coord. of seq., zero-based. If -'ve strand, rel to start of rev. comp. * ungapped length of the sequence * stran...
[ "Build", "a", "sequence", "object", "using", "the", "pre", "-", "tokenized", "parts", "from", "a", "MAF", "line", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/maf.py#L83-L102
249,550
pjuren/pyokit
src/pyokit/io/maf.py
__annotate_sequence_with_context
def __annotate_sequence_with_context(seq, i_line_parts): """Extract meta data from pre-tokenized maf i-line and populate sequence. i -- always come after s lines, and contain information about the context of the sequence. Five fields are given, not counting the 'i' * source sequence (must match s ...
python
def __annotate_sequence_with_context(seq, i_line_parts): """Extract meta data from pre-tokenized maf i-line and populate sequence. i -- always come after s lines, and contain information about the context of the sequence. Five fields are given, not counting the 'i' * source sequence (must match s ...
[ "def", "__annotate_sequence_with_context", "(", "seq", ",", "i_line_parts", ")", ":", "if", "i_line_parts", "[", "1", "]", "!=", "seq", ".", "name", ":", "raise", "MAFError", "(", "\"Trying to populate meta data for sequence \"", "+", "seq", ".", "name", "+", "\...
Extract meta data from pre-tokenized maf i-line and populate sequence. i -- always come after s lines, and contain information about the context of the sequence. Five fields are given, not counting the 'i' * source sequence (must match s line before this) * left status (see below) ...
[ "Extract", "meta", "data", "from", "pre", "-", "tokenized", "maf", "i", "-", "line", "and", "populate", "sequence", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/maf.py#L135-L169
249,551
pjuren/pyokit
src/pyokit/io/maf.py
__annotate_sequence_with_quality
def __annotate_sequence_with_quality(seq, q_line_parts): """Extract meta data from pre-tokenized maf q-line and populate sequence. q -- quality information about an aligned base in a species. Two fields after the 'q': the source name and a single digit for each nucleotide in its sequence (0-9 or F, o...
python
def __annotate_sequence_with_quality(seq, q_line_parts): """Extract meta data from pre-tokenized maf q-line and populate sequence. q -- quality information about an aligned base in a species. Two fields after the 'q': the source name and a single digit for each nucleotide in its sequence (0-9 or F, o...
[ "def", "__annotate_sequence_with_quality", "(", "seq", ",", "q_line_parts", ")", ":", "if", "q_line_parts", "[", "1", "]", "!=", "seq", ".", "name", ":", "raise", "MAFError", "(", "\"trying to populate meta data for sequence \"", "+", "seq", ".", "name", "+", "\...
Extract meta data from pre-tokenized maf q-line and populate sequence. q -- quality information about an aligned base in a species. Two fields after the 'q': the source name and a single digit for each nucleotide in its sequence (0-9 or F, or - to indicate a gap).
[ "Extract", "meta", "data", "from", "pre", "-", "tokenized", "maf", "q", "-", "line", "and", "populate", "sequence", "." ]
fddae123b5d817daa39496183f19c000d9c3791f
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/maf.py#L172-L188
249,552
AguaClara/aide_document-DEPRECATED
aide_document/jekyll.py
add_frontmatter
def add_frontmatter(file_name, title, makenew=False): """ Adds basic frontmatter to a MarkDown file that will be used in a Jekyll project. Parameters ========== file_name : String Relative file path from where this method is called to the location of the file that will have frontmatter adde...
python
def add_frontmatter(file_name, title, makenew=False): """ Adds basic frontmatter to a MarkDown file that will be used in a Jekyll project. Parameters ========== file_name : String Relative file path from where this method is called to the location of the file that will have frontmatter adde...
[ "def", "add_frontmatter", "(", "file_name", ",", "title", ",", "makenew", "=", "False", ")", ":", "with", "open", "(", "file_name", ",", "\"r+\"", ")", "as", "oldfile", ":", "# Creates new file and writes to it if specified", "if", "makenew", ":", "with", "open"...
Adds basic frontmatter to a MarkDown file that will be used in a Jekyll project. Parameters ========== file_name : String Relative file path from where this method is called to the location of the file that will have frontmatter added. title : String Title of the page that will go into ...
[ "Adds", "basic", "frontmatter", "to", "a", "MarkDown", "file", "that", "will", "be", "used", "in", "a", "Jekyll", "project", "." ]
3f3b5c9f321264e0e4d8ed68dfbc080762579815
https://github.com/AguaClara/aide_document-DEPRECATED/blob/3f3b5c9f321264e0e4d8ed68dfbc080762579815/aide_document/jekyll.py#L12-L50
249,553
TheSighing/climber
climber/summary.py
FrequencySummarizer.summarize
def summarize(self, text, n): """ Return a list of n sentences which represent the summary of text. """ sents = sent_tokenize(text) assert n <= len(sents) word_sent = [word_tokenize(s.lower()) for s in sents] self._freq = self._compute_frequencies(word_sent) ranking = defaultdic...
python
def summarize(self, text, n): """ Return a list of n sentences which represent the summary of text. """ sents = sent_tokenize(text) assert n <= len(sents) word_sent = [word_tokenize(s.lower()) for s in sents] self._freq = self._compute_frequencies(word_sent) ranking = defaultdic...
[ "def", "summarize", "(", "self", ",", "text", ",", "n", ")", ":", "sents", "=", "sent_tokenize", "(", "text", ")", "assert", "n", "<=", "len", "(", "sents", ")", "word_sent", "=", "[", "word_tokenize", "(", "s", ".", "lower", "(", ")", ")", "for", ...
Return a list of n sentences which represent the summary of text.
[ "Return", "a", "list", "of", "n", "sentences", "which", "represent", "the", "summary", "of", "text", "." ]
39e4e70c9a768c82a995d8704679d1c046910666
https://github.com/TheSighing/climber/blob/39e4e70c9a768c82a995d8704679d1c046910666/climber/summary.py#L39-L54
249,554
TheSighing/climber
climber/summary.py
FrequencySummarizer._rank
def _rank(self, ranking, n): """ return the first n sentences with highest ranking """ return nlargest(n, ranking, key=ranking.get)
python
def _rank(self, ranking, n): """ return the first n sentences with highest ranking """ return nlargest(n, ranking, key=ranking.get)
[ "def", "_rank", "(", "self", ",", "ranking", ",", "n", ")", ":", "return", "nlargest", "(", "n", ",", "ranking", ",", "key", "=", "ranking", ".", "get", ")" ]
return the first n sentences with highest ranking
[ "return", "the", "first", "n", "sentences", "with", "highest", "ranking" ]
39e4e70c9a768c82a995d8704679d1c046910666
https://github.com/TheSighing/climber/blob/39e4e70c9a768c82a995d8704679d1c046910666/climber/summary.py#L56-L58
249,555
sys-git/certifiable
certifiable/utils.py
make_certifier
def make_certifier(): """ Decorator that can wrap raw functions to create a certifier function. Certifier functions support partial application. If a function wrapped by `make_certifier` is called with a value as its first argument it will be certified immediately. If no value is passed, then it ...
python
def make_certifier(): """ Decorator that can wrap raw functions to create a certifier function. Certifier functions support partial application. If a function wrapped by `make_certifier` is called with a value as its first argument it will be certified immediately. If no value is passed, then it ...
[ "def", "make_certifier", "(", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "six", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "value", "=", "_undefined", ",", "*", "*", "kwargs", ")", ":", "def", "certify", "(", "val", ")", ...
Decorator that can wrap raw functions to create a certifier function. Certifier functions support partial application. If a function wrapped by `make_certifier` is called with a value as its first argument it will be certified immediately. If no value is passed, then it will return a function that ca...
[ "Decorator", "that", "can", "wrap", "raw", "functions", "to", "create", "a", "certifier", "function", "." ]
a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/utils.py#L33-L65
249,556
sys-git/certifiable
certifiable/utils.py
certify_required
def certify_required(value, required=False): """ Certify that a value is present if required. :param object value: The value that is to be certified. :param bool required: Is the value required? :raises CertifierValueError: Required value is `None`. """ # Certify ou...
python
def certify_required(value, required=False): """ Certify that a value is present if required. :param object value: The value that is to be certified. :param bool required: Is the value required? :raises CertifierValueError: Required value is `None`. """ # Certify ou...
[ "def", "certify_required", "(", "value", ",", "required", "=", "False", ")", ":", "# Certify our kwargs:", "if", "not", "isinstance", "(", "required", ",", "bool", ")", ":", "raise", "CertifierParamError", "(", "'required'", ",", "required", ",", ")", "if", ...
Certify that a value is present if required. :param object value: The value that is to be certified. :param bool required: Is the value required? :raises CertifierValueError: Required value is `None`.
[ "Certify", "that", "a", "value", "is", "present", "if", "required", "." ]
a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/utils.py#L68-L91
249,557
sys-git/certifiable
certifiable/utils.py
certify_parameter
def certify_parameter(certifier, name, value, kwargs=None): """ Internal certifier for kwargs passed to Certifiable public methods. :param callable certifier: The certifier to use :param str name: The name of the kwargs :param object value: The value of the kwarg. :param...
python
def certify_parameter(certifier, name, value, kwargs=None): """ Internal certifier for kwargs passed to Certifiable public methods. :param callable certifier: The certifier to use :param str name: The name of the kwargs :param object value: The value of the kwarg. :param...
[ "def", "certify_parameter", "(", "certifier", ",", "name", ",", "value", ",", "kwargs", "=", "None", ")", ":", "try", ":", "certifier", "(", "value", ",", "*", "*", "kwargs", "or", "{", "}", ")", "except", "CertifierError", "as", "err", ":", "six", "...
Internal certifier for kwargs passed to Certifiable public methods. :param callable certifier: The certifier to use :param str name: The name of the kwargs :param object value: The value of the kwarg. :param bool required: Is the param required. Default=False. :raise...
[ "Internal", "certifier", "for", "kwargs", "passed", "to", "Certifiable", "public", "methods", "." ]
a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/utils.py#L123-L146
249,558
sys-git/certifiable
certifiable/utils.py
enable_from_env
def enable_from_env(state=None): """ Enable certification for this thread based on the environment variable `CERTIFIABLE_STATE`. :param bool state: Default status to use. :return: The new state. :rtype: bool """ try: x = os.environ.get( ENVVAR, ...
python
def enable_from_env(state=None): """ Enable certification for this thread based on the environment variable `CERTIFIABLE_STATE`. :param bool state: Default status to use. :return: The new state. :rtype: bool """ try: x = os.environ.get( ENVVAR, ...
[ "def", "enable_from_env", "(", "state", "=", "None", ")", ":", "try", ":", "x", "=", "os", ".", "environ", ".", "get", "(", "ENVVAR", ",", "state", ",", ")", "value", "=", "bool", "(", "int", "(", "x", ")", ")", "except", "Exception", ":", "# pyl...
Enable certification for this thread based on the environment variable `CERTIFIABLE_STATE`. :param bool state: Default status to use. :return: The new state. :rtype: bool
[ "Enable", "certification", "for", "this", "thread", "based", "on", "the", "environment", "variable", "CERTIFIABLE_STATE", "." ]
a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/utils.py#L196-L216
249,559
motiejus/tictactoelib
tictactoelib/noninteractive.py
compete
def compete(source_x, source_o, timeout=None, memlimit=None, cgroup='tictactoe', cgroup_path='/sys/fs/cgroup'): """Fights two source files. Returns either: * ('ok', 'x' | 'draw' | 'o', GAMEPLAY) * ('error', GUILTY, REASON, GAMEPLAY) REASON := utf8-encoded error string (can be up to 65k...
python
def compete(source_x, source_o, timeout=None, memlimit=None, cgroup='tictactoe', cgroup_path='/sys/fs/cgroup'): """Fights two source files. Returns either: * ('ok', 'x' | 'draw' | 'o', GAMEPLAY) * ('error', GUILTY, REASON, GAMEPLAY) REASON := utf8-encoded error string (can be up to 65k...
[ "def", "compete", "(", "source_x", ",", "source_o", ",", "timeout", "=", "None", ",", "memlimit", "=", "None", ",", "cgroup", "=", "'tictactoe'", ",", "cgroup_path", "=", "'/sys/fs/cgroup'", ")", ":", "gameplay", "=", "[", "]", "for", "xo", ",", "moveres...
Fights two source files. Returns either: * ('ok', 'x' | 'draw' | 'o', GAMEPLAY) * ('error', GUILTY, REASON, GAMEPLAY) REASON := utf8-encoded error string (can be up to 65k chars) GAMEPLAY := [ NUM ] GUILTY := 'x' | 'o' (during whose turn the error occured) NUM := 1..81 | 0 NUM=0 means...
[ "Fights", "two", "source", "files", "." ]
c884e206f11d9472ce0b7d08e06f894b24a20989
https://github.com/motiejus/tictactoelib/blob/c884e206f11d9472ce0b7d08e06f894b24a20989/tictactoelib/noninteractive.py#L3-L30
249,560
dossier/dossier.fc
python/dossier/fc/string_counter.py
StringCounter._fix_key
def _fix_key(key): '''Normalize keys to Unicode strings.''' if isinstance(key, unicode): return key if isinstance(key, str): # On my system, the default encoding is `ascii`, so let's # explicitly say UTF-8? return unicode(key, 'utf-8') rais...
python
def _fix_key(key): '''Normalize keys to Unicode strings.''' if isinstance(key, unicode): return key if isinstance(key, str): # On my system, the default encoding is `ascii`, so let's # explicitly say UTF-8? return unicode(key, 'utf-8') rais...
[ "def", "_fix_key", "(", "key", ")", ":", "if", "isinstance", "(", "key", ",", "unicode", ")", ":", "return", "key", "if", "isinstance", "(", "key", ",", "str", ")", ":", "# On my system, the default encoding is `ascii`, so let's", "# explicitly say UTF-8?", "retur...
Normalize keys to Unicode strings.
[ "Normalize", "keys", "to", "Unicode", "strings", "." ]
3e969d0cb2592fc06afc1c849d2b22283450b5e2
https://github.com/dossier/dossier.fc/blob/3e969d0cb2592fc06afc1c849d2b22283450b5e2/python/dossier/fc/string_counter.py#L137-L145
249,561
dossier/dossier.fc
python/dossier/fc/string_counter.py
StringCounter.truncate_most_common
def truncate_most_common(self, truncation_length): ''' Sorts the counter and keeps only the most common items up to ``truncation_length`` in place. :type truncation_length: int ''' keep_keys = set(v[0] for v in self.most_common(truncation_length)) for key in self...
python
def truncate_most_common(self, truncation_length): ''' Sorts the counter and keeps only the most common items up to ``truncation_length`` in place. :type truncation_length: int ''' keep_keys = set(v[0] for v in self.most_common(truncation_length)) for key in self...
[ "def", "truncate_most_common", "(", "self", ",", "truncation_length", ")", ":", "keep_keys", "=", "set", "(", "v", "[", "0", "]", "for", "v", "in", "self", ".", "most_common", "(", "truncation_length", ")", ")", "for", "key", "in", "self", ".", "keys", ...
Sorts the counter and keeps only the most common items up to ``truncation_length`` in place. :type truncation_length: int
[ "Sorts", "the", "counter", "and", "keeps", "only", "the", "most", "common", "items", "up", "to", "truncation_length", "in", "place", "." ]
3e969d0cb2592fc06afc1c849d2b22283450b5e2
https://github.com/dossier/dossier.fc/blob/3e969d0cb2592fc06afc1c849d2b22283450b5e2/python/dossier/fc/string_counter.py#L194-L204
249,562
MakerReduxCorp/MARDS
MARDS/standard_types.py
rst
def rst(value_rule): '''Given the data and type information, generate a list of strings for insertion into a RST document. ''' lines = [] if value_rule.has('type'): value_type = value_rule['type'].value else: value_type = 'string' if value_type=='ignore': pass els...
python
def rst(value_rule): '''Given the data and type information, generate a list of strings for insertion into a RST document. ''' lines = [] if value_rule.has('type'): value_type = value_rule['type'].value else: value_type = 'string' if value_type=='ignore': pass els...
[ "def", "rst", "(", "value_rule", ")", ":", "lines", "=", "[", "]", "if", "value_rule", ".", "has", "(", "'type'", ")", ":", "value_type", "=", "value_rule", "[", "'type'", "]", ".", "value", "else", ":", "value_type", "=", "'string'", "if", "value_type...
Given the data and type information, generate a list of strings for insertion into a RST document.
[ "Given", "the", "data", "and", "type", "information", "generate", "a", "list", "of", "strings", "for", "insertion", "into", "a", "RST", "document", "." ]
f8ddecc70f2ce1703984cb403c9d5417895170d6
https://github.com/MakerReduxCorp/MARDS/blob/f8ddecc70f2ce1703984cb403c9d5417895170d6/MARDS/standard_types.py#L114-L176
249,563
kxgames/vecrec
vecrec/collisions.py
circle_touching_line
def circle_touching_line(center, radius, start, end): """ Return true if the given circle intersects the given segment. Note that this checks for intersection with a line segment, and not an actual line. :param center: Center of the circle. :type center: Vector :param radius: Radius of the c...
python
def circle_touching_line(center, radius, start, end): """ Return true if the given circle intersects the given segment. Note that this checks for intersection with a line segment, and not an actual line. :param center: Center of the circle. :type center: Vector :param radius: Radius of the c...
[ "def", "circle_touching_line", "(", "center", ",", "radius", ",", "start", ",", "end", ")", ":", "C", ",", "R", "=", "center", ",", "radius", "A", ",", "B", "=", "start", ",", "end", "a", "=", "(", "B", ".", "x", "-", "A", ".", "x", ")", "**"...
Return true if the given circle intersects the given segment. Note that this checks for intersection with a line segment, and not an actual line. :param center: Center of the circle. :type center: Vector :param radius: Radius of the circle. :type radius: float :param start: The first end...
[ "Return", "true", "if", "the", "given", "circle", "intersects", "the", "given", "segment", ".", "Note", "that", "this", "checks", "for", "intersection", "with", "a", "line", "segment", "and", "not", "an", "actual", "line", "." ]
18b0841419de21a644b4511e2229af853ed09529
https://github.com/kxgames/vecrec/blob/18b0841419de21a644b4511e2229af853ed09529/vecrec/collisions.py#L3-L40
249,564
nir0s/serv
serv/init/upstart.py
Upstart.generate
def generate(self, overwrite=False): """Generate a config file for an upstart service. """ super(Upstart, self).generate(overwrite=overwrite) svc_file_template = self.template_prefix + '.conf' self.svc_file_path = self.generate_into_prefix + '.conf' self.generate_file_f...
python
def generate(self, overwrite=False): """Generate a config file for an upstart service. """ super(Upstart, self).generate(overwrite=overwrite) svc_file_template = self.template_prefix + '.conf' self.svc_file_path = self.generate_into_prefix + '.conf' self.generate_file_f...
[ "def", "generate", "(", "self", ",", "overwrite", "=", "False", ")", ":", "super", "(", "Upstart", ",", "self", ")", ".", "generate", "(", "overwrite", "=", "overwrite", ")", "svc_file_template", "=", "self", ".", "template_prefix", "+", "'.conf'", "self",...
Generate a config file for an upstart service.
[ "Generate", "a", "config", "file", "for", "an", "upstart", "service", "." ]
7af724ed49c0eb766c37c4b5287b043a8cf99e9c
https://github.com/nir0s/serv/blob/7af724ed49c0eb766c37c4b5287b043a8cf99e9c/serv/init/upstart.py#L21-L30
249,565
totokaka/pySpaceGDN
pyspacegdn/requests/request.py
Request._fetch
def _fetch(self, default_path): """ Internal method for fetching. This differs from :meth:`.fetch` in that it accepts a default path as an argument. """ if not self._path: path = default_path else: path = self._path req_type = 'GET' if l...
python
def _fetch(self, default_path): """ Internal method for fetching. This differs from :meth:`.fetch` in that it accepts a default path as an argument. """ if not self._path: path = default_path else: path = self._path req_type = 'GET' if l...
[ "def", "_fetch", "(", "self", ",", "default_path", ")", ":", "if", "not", "self", ".", "_path", ":", "path", "=", "default_path", "else", ":", "path", "=", "self", ".", "_path", "req_type", "=", "'GET'", "if", "len", "(", "self", ".", "_post_params", ...
Internal method for fetching. This differs from :meth:`.fetch` in that it accepts a default path as an argument.
[ "Internal", "method", "for", "fetching", "." ]
55c8be8d751e24873e0a7f7e99d2b715442ec878
https://github.com/totokaka/pySpaceGDN/blob/55c8be8d751e24873e0a7f7e99d2b715442ec878/pyspacegdn/requests/request.py#L98-L120
249,566
dossier/dossier.fc
python/dossier/fc/feature_tokens.py
FeatureTokens.tokens
def tokens(self, si, k): '''`si` is a stream item and `k` is a key in this feature. The purpose of this method is to dereference the token pointers with respect to the given stream item. That is, it translates each sequence of token pointers to a sequence of `Token`. ''' ...
python
def tokens(self, si, k): '''`si` is a stream item and `k` is a key in this feature. The purpose of this method is to dereference the token pointers with respect to the given stream item. That is, it translates each sequence of token pointers to a sequence of `Token`. ''' ...
[ "def", "tokens", "(", "self", ",", "si", ",", "k", ")", ":", "for", "tokens", "in", "self", "[", "k", "]", ":", "yield", "[", "si", ".", "body", ".", "sentences", "[", "tagid", "]", "[", "sid", "]", ".", "tokens", "[", "tid", "]", "for", "tag...
`si` is a stream item and `k` is a key in this feature. The purpose of this method is to dereference the token pointers with respect to the given stream item. That is, it translates each sequence of token pointers to a sequence of `Token`.
[ "si", "is", "a", "stream", "item", "and", "k", "is", "a", "key", "in", "this", "feature", ".", "The", "purpose", "of", "this", "method", "is", "to", "dereference", "the", "token", "pointers", "with", "respect", "to", "the", "given", "stream", "item", "...
3e969d0cb2592fc06afc1c849d2b22283450b5e2
https://github.com/dossier/dossier.fc/blob/3e969d0cb2592fc06afc1c849d2b22283450b5e2/python/dossier/fc/feature_tokens.py#L45-L55
249,567
kyleam/wcut
wcut/io.py
get_lines
def get_lines(fname): """Return generator with line number and line for file `fname`.""" for line in fileinput.input(fname): yield fileinput.filelineno(), line.strip()
python
def get_lines(fname): """Return generator with line number and line for file `fname`.""" for line in fileinput.input(fname): yield fileinput.filelineno(), line.strip()
[ "def", "get_lines", "(", "fname", ")", ":", "for", "line", "in", "fileinput", ".", "input", "(", "fname", ")", ":", "yield", "fileinput", ".", "filelineno", "(", ")", ",", "line", ".", "strip", "(", ")" ]
Return generator with line number and line for file `fname`.
[ "Return", "generator", "with", "line", "number", "and", "line", "for", "file", "fname", "." ]
36f6e10a4c3b4dae274a55010463c6acce83bc71
https://github.com/kyleam/wcut/blob/36f6e10a4c3b4dae274a55010463c6acce83bc71/wcut/io.py#L21-L24
249,568
mkouhei/tonicdnscli
src/tonicdnscli/connect.py
get_token
def get_token(username, password, server): """Retrieve token of TonicDNS API. Arguments: usename: TonicDNS API username password: TonicDNS API password server: TonicDNS API server """ method = 'PUT' uri = 'https://' + server + '/authenticate' token = '' authinfo...
python
def get_token(username, password, server): """Retrieve token of TonicDNS API. Arguments: usename: TonicDNS API username password: TonicDNS API password server: TonicDNS API server """ method = 'PUT' uri = 'https://' + server + '/authenticate' token = '' authinfo...
[ "def", "get_token", "(", "username", ",", "password", ",", "server", ")", ":", "method", "=", "'PUT'", "uri", "=", "'https://'", "+", "server", "+", "'/authenticate'", "token", "=", "''", "authinfo", "=", "{", "\"username\"", ":", "username", ",", "\"passw...
Retrieve token of TonicDNS API. Arguments: usename: TonicDNS API username password: TonicDNS API password server: TonicDNS API server
[ "Retrieve", "token", "of", "TonicDNS", "API", "." ]
df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c
https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/connect.py#L30-L50
249,569
mkouhei/tonicdnscli
src/tonicdnscli/connect.py
tonicdns_client
def tonicdns_client(uri, method, token='', data='', keyword='', content='', raw_flag=False): """TonicDNS API client Arguments: uri: TonicDNS API URI method: TonicDNS API request method token: TonicDNS API authentication token data: Post data to...
python
def tonicdns_client(uri, method, token='', data='', keyword='', content='', raw_flag=False): """TonicDNS API client Arguments: uri: TonicDNS API URI method: TonicDNS API request method token: TonicDNS API authentication token data: Post data to...
[ "def", "tonicdns_client", "(", "uri", ",", "method", ",", "token", "=", "''", ",", "data", "=", "''", ",", "keyword", "=", "''", ",", "content", "=", "''", ",", "raw_flag", "=", "False", ")", ":", "res", "=", "request", "(", "uri", ",", "method", ...
TonicDNS API client Arguments: uri: TonicDNS API URI method: TonicDNS API request method token: TonicDNS API authentication token data: Post data to TonicDNS API keyword: Processing keyword of response content: data exist flag raw_flag: True ...
[ "TonicDNS", "API", "client" ]
df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c
https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/connect.py#L53-L89
249,570
mkouhei/tonicdnscli
src/tonicdnscli/connect.py
request
def request(uri, method, data, token=''): """Request to TonicDNS API. Arguments: uri: TonicDNS API URI method: TonicDNS API request method data: Post data to TonicDNS API token: TonicDNS API authentication token """ socket.setdefaulttimeout(__timeout__) o...
python
def request(uri, method, data, token=''): """Request to TonicDNS API. Arguments: uri: TonicDNS API URI method: TonicDNS API request method data: Post data to TonicDNS API token: TonicDNS API authentication token """ socket.setdefaulttimeout(__timeout__) o...
[ "def", "request", "(", "uri", ",", "method", ",", "data", ",", "token", "=", "''", ")", ":", "socket", ".", "setdefaulttimeout", "(", "__timeout__", ")", "obj", "=", "urllib", ".", "build_opener", "(", "urllib", ".", "HTTPHandler", ")", "# encoding json", ...
Request to TonicDNS API. Arguments: uri: TonicDNS API URI method: TonicDNS API request method data: Post data to TonicDNS API token: TonicDNS API authentication token
[ "Request", "to", "TonicDNS", "API", "." ]
df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c
https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/connect.py#L92-L132
249,571
mkouhei/tonicdnscli
src/tonicdnscli/connect.py
response
def response(uri, method, res, token='', keyword='', content='', raw_flag=False): """Response of tonicdns_client request Arguments: uri: TonicDNS API URI method: TonicDNS API request method res: Response of against request to TonicDNS API token: Toni...
python
def response(uri, method, res, token='', keyword='', content='', raw_flag=False): """Response of tonicdns_client request Arguments: uri: TonicDNS API URI method: TonicDNS API request method res: Response of against request to TonicDNS API token: Toni...
[ "def", "response", "(", "uri", ",", "method", ",", "res", ",", "token", "=", "''", ",", "keyword", "=", "''", ",", "content", "=", "''", ",", "raw_flag", "=", "False", ")", ":", "if", "method", "==", "'GET'", "or", "(", "method", "==", "'PUT'", "...
Response of tonicdns_client request Arguments: uri: TonicDNS API URI method: TonicDNS API request method res: Response of against request to TonicDNS API token: TonicDNS API token keyword: Processing keyword content: JSON data raw_flag: True...
[ "Response", "of", "tonicdns_client", "request" ]
df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c
https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/connect.py#L135-L207
249,572
mkouhei/tonicdnscli
src/tonicdnscli/connect.py
search_record
def search_record(datas, keyword): """Search target JSON -> dictionary Arguments: datas: dictionary of record datas keyword: search keyword (default is null) Key target is "name" or "content" or "type". default null. Either key and type, or on the other hand. When keyword has inc...
python
def search_record(datas, keyword): """Search target JSON -> dictionary Arguments: datas: dictionary of record datas keyword: search keyword (default is null) Key target is "name" or "content" or "type". default null. Either key and type, or on the other hand. When keyword has inc...
[ "def", "search_record", "(", "datas", ",", "keyword", ")", ":", "key_name", ",", "key_type", ",", "key_content", "=", "False", ",", "False", ",", "False", "if", "keyword", ".", "find", "(", "','", ")", ">", "-", "1", ":", "if", "len", "(", "keyword",...
Search target JSON -> dictionary Arguments: datas: dictionary of record datas keyword: search keyword (default is null) Key target is "name" or "content" or "type". default null. Either key and type, or on the other hand. When keyword has include camma ",", Separate keyword to na...
[ "Search", "target", "JSON", "-", ">", "dictionary" ]
df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c
https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/connect.py#L210-L253
249,573
mkouhei/tonicdnscli
src/tonicdnscli/connect.py
print_formatted
def print_formatted(datas): """Pretty print JSON DATA Argument: datas: dictionary of data """ if not datas: print("No data") exit(1) if isinstance(datas, list): # get all zones # API /zone without :identifier hr() print('%-20s %-8s %-12s' ...
python
def print_formatted(datas): """Pretty print JSON DATA Argument: datas: dictionary of data """ if not datas: print("No data") exit(1) if isinstance(datas, list): # get all zones # API /zone without :identifier hr() print('%-20s %-8s %-12s' ...
[ "def", "print_formatted", "(", "datas", ")", ":", "if", "not", "datas", ":", "print", "(", "\"No data\"", ")", "exit", "(", "1", ")", "if", "isinstance", "(", "datas", ",", "list", ")", ":", "# get all zones", "# API /zone without :identifier", "hr", "(", ...
Pretty print JSON DATA Argument: datas: dictionary of data
[ "Pretty", "print", "JSON", "DATA" ]
df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c
https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/connect.py#L256-L374
249,574
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.execute_deferred_effects
def execute_deferred_effects(self, pos): """ Evaluates deferred effects that are triggered by the prefix of the pos on the current beliefstate. For instance, if the effect is triggered by the 'NN' pos, then the effect will be triggered by 'NN' or 'NNS'.""" costs = 0 to_delete = [...
python
def execute_deferred_effects(self, pos): """ Evaluates deferred effects that are triggered by the prefix of the pos on the current beliefstate. For instance, if the effect is triggered by the 'NN' pos, then the effect will be triggered by 'NN' or 'NNS'.""" costs = 0 to_delete = [...
[ "def", "execute_deferred_effects", "(", "self", ",", "pos", ")", ":", "costs", "=", "0", "to_delete", "=", "[", "]", "for", "entry", "in", "self", ".", "__dict__", "[", "'deferred_effects'", "]", ":", "effect_pos", ",", "effect", "=", "entry", "if", "pos...
Evaluates deferred effects that are triggered by the prefix of the pos on the current beliefstate. For instance, if the effect is triggered by the 'NN' pos, then the effect will be triggered by 'NN' or 'NNS'.
[ "Evaluates", "deferred", "effects", "that", "are", "triggered", "by", "the", "prefix", "of", "the", "pos", "on", "the", "current", "beliefstate", ".", "For", "instance", "if", "the", "effect", "is", "triggered", "by", "the", "NN", "pos", "then", "the", "ef...
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L79-L94
249,575
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.set_environment_variable
def set_environment_variable(self, key, val): """ Sets a variable if that variable is not already set """ if self.get_environment_variable(key) in [None, val]: self.__dict__['environment_variables'][key] = val else: raise Contradiction("Could not set environment variable ...
python
def set_environment_variable(self, key, val): """ Sets a variable if that variable is not already set """ if self.get_environment_variable(key) in [None, val]: self.__dict__['environment_variables'][key] = val else: raise Contradiction("Could not set environment variable ...
[ "def", "set_environment_variable", "(", "self", ",", "key", ",", "val", ")", ":", "if", "self", ".", "get_environment_variable", "(", "key", ")", "in", "[", "None", ",", "val", "]", ":", "self", ".", "__dict__", "[", "'environment_variables'", "]", "[", ...
Sets a variable if that variable is not already set
[ "Sets", "a", "variable", "if", "that", "variable", "is", "not", "already", "set" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L96-L101
249,576
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.iter_breadth_first
def iter_breadth_first(self, root=None): """ Traverses the belief state's structure breadth-first """ if root == None: root = self yield root last = root for node in self.iter_breadth_first(root): if isinstance(node, DictCell): # recurse ...
python
def iter_breadth_first(self, root=None): """ Traverses the belief state's structure breadth-first """ if root == None: root = self yield root last = root for node in self.iter_breadth_first(root): if isinstance(node, DictCell): # recurse ...
[ "def", "iter_breadth_first", "(", "self", ",", "root", "=", "None", ")", ":", "if", "root", "==", "None", ":", "root", "=", "self", "yield", "root", "last", "=", "root", "for", "node", "in", "self", ".", "iter_breadth_first", "(", "root", ")", ":", "...
Traverses the belief state's structure breadth-first
[ "Traverses", "the", "belief", "state", "s", "structure", "breadth", "-", "first" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L119-L132
249,577
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.find_path
def find_path(self, test_function=None, on_targets=False): """ General helper method that iterates breadth-first over the referential_domain's cells and returns a path where the test_function is True """ assert self.has_referential_domain(), "need context set" if not tes...
python
def find_path(self, test_function=None, on_targets=False): """ General helper method that iterates breadth-first over the referential_domain's cells and returns a path where the test_function is True """ assert self.has_referential_domain(), "need context set" if not tes...
[ "def", "find_path", "(", "self", ",", "test_function", "=", "None", ",", "on_targets", "=", "False", ")", ":", "assert", "self", ".", "has_referential_domain", "(", ")", ",", "\"need context set\"", "if", "not", "test_function", ":", "test_function", "=", "lam...
General helper method that iterates breadth-first over the referential_domain's cells and returns a path where the test_function is True
[ "General", "helper", "method", "that", "iterates", "breadth", "-", "first", "over", "the", "referential_domain", "s", "cells", "and", "returns", "a", "path", "where", "the", "test_function", "is", "True" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L134-L169
249,578
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.get_nth_unique_value
def get_nth_unique_value(self, keypath, n, distance_from, open_interval=True): """ Returns the `n-1`th unique value, or raises a contradiction if that is out of bounds """ unique_values = self.get_ordered_values(keypath, distance_from, open_interval) if 0 <= n < len(uniqu...
python
def get_nth_unique_value(self, keypath, n, distance_from, open_interval=True): """ Returns the `n-1`th unique value, or raises a contradiction if that is out of bounds """ unique_values = self.get_ordered_values(keypath, distance_from, open_interval) if 0 <= n < len(uniqu...
[ "def", "get_nth_unique_value", "(", "self", ",", "keypath", ",", "n", ",", "distance_from", ",", "open_interval", "=", "True", ")", ":", "unique_values", "=", "self", ".", "get_ordered_values", "(", "keypath", ",", "distance_from", ",", "open_interval", ")", "...
Returns the `n-1`th unique value, or raises a contradiction if that is out of bounds
[ "Returns", "the", "n", "-", "1", "th", "unique", "value", "or", "raises", "a", "contradiction", "if", "that", "is", "out", "of", "bounds" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L172-L182
249,579
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.get_ordered_values
def get_ordered_values(self, keypath, distance_from, open_interval=True): """ Retrieves the referents's values sorted by their distance from the min, max, or mid value. """ values = [] if keypath[0] == 'target': # instances start with 'target' prefix, but ...
python
def get_ordered_values(self, keypath, distance_from, open_interval=True): """ Retrieves the referents's values sorted by their distance from the min, max, or mid value. """ values = [] if keypath[0] == 'target': # instances start with 'target' prefix, but ...
[ "def", "get_ordered_values", "(", "self", ",", "keypath", ",", "distance_from", ",", "open_interval", "=", "True", ")", ":", "values", "=", "[", "]", "if", "keypath", "[", "0", "]", "==", "'target'", ":", "# instances start with 'target' prefix, but ", "# don't ...
Retrieves the referents's values sorted by their distance from the min, max, or mid value.
[ "Retrieves", "the", "referents", "s", "values", "sorted", "by", "their", "distance", "from", "the", "min", "max", "or", "mid", "value", "." ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L184-L236
249,580
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.get_paths_for_attribute
def get_paths_for_attribute(self, attribute_name): """ Returns a path list to all attributes that have with a particular name. """ has_name = lambda name, structure: name == attribute_name return self.find_path(has_name, on_targets=True)
python
def get_paths_for_attribute(self, attribute_name): """ Returns a path list to all attributes that have with a particular name. """ has_name = lambda name, structure: name == attribute_name return self.find_path(has_name, on_targets=True)
[ "def", "get_paths_for_attribute", "(", "self", ",", "attribute_name", ")", ":", "has_name", "=", "lambda", "name", ",", "structure", ":", "name", "==", "attribute_name", "return", "self", ".", "find_path", "(", "has_name", ",", "on_targets", "=", "True", ")" ]
Returns a path list to all attributes that have with a particular name.
[ "Returns", "a", "path", "list", "to", "all", "attributes", "that", "have", "with", "a", "particular", "name", "." ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L263-L268
249,581
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.add_cell
def add_cell(self, keypath, cell): """ Adds a new cell to the end of `keypath` of type `cell`""" keypath = keypath[:] # copy inner = self # the most inner dict where cell is added cellname = keypath # the name of the cell assert keypath not in self, "Already exists: %s " % (str...
python
def add_cell(self, keypath, cell): """ Adds a new cell to the end of `keypath` of type `cell`""" keypath = keypath[:] # copy inner = self # the most inner dict where cell is added cellname = keypath # the name of the cell assert keypath not in self, "Already exists: %s " % (str...
[ "def", "add_cell", "(", "self", ",", "keypath", ",", "cell", ")", ":", "keypath", "=", "keypath", "[", ":", "]", "# copy", "inner", "=", "self", "# the most inner dict where cell is added", "cellname", "=", "keypath", "# the name of the cell", "assert", "keypath",...
Adds a new cell to the end of `keypath` of type `cell`
[ "Adds", "a", "new", "cell", "to", "the", "end", "of", "keypath", "of", "type", "cell" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L323-L338
249,582
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.size
def size(self): """ Returns the size of the belief state. Initially if there are $n$ consistent members, (the result of `self.number_of_singleton_referents()`) then there are generally $2^{n}-1$ valid belief states. """ n = self.number_of_singleton_referents() targets =...
python
def size(self): """ Returns the size of the belief state. Initially if there are $n$ consistent members, (the result of `self.number_of_singleton_referents()`) then there are generally $2^{n}-1$ valid belief states. """ n = self.number_of_singleton_referents() targets =...
[ "def", "size", "(", "self", ")", ":", "n", "=", "self", ".", "number_of_singleton_referents", "(", ")", "targets", "=", "list", "(", "self", ".", "iter_referents_tuples", "(", ")", ")", "n_targets", "=", "len", "(", "targets", ")", "if", "n", "==", "0"...
Returns the size of the belief state. Initially if there are $n$ consistent members, (the result of `self.number_of_singleton_referents()`) then there are generally $2^{n}-1$ valid belief states.
[ "Returns", "the", "size", "of", "the", "belief", "state", "." ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L402-L419
249,583
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.iter_referents
def iter_referents(self): """ Generates target sets that are compatible with the current beliefstate. """ tlow, thigh = self['targetset_arity'].get_tuple() clow, chigh = self['contrast_arity'].get_tuple() referents = list(self.iter_singleton_referents()) t = len(referents) ...
python
def iter_referents(self): """ Generates target sets that are compatible with the current beliefstate. """ tlow, thigh = self['targetset_arity'].get_tuple() clow, chigh = self['contrast_arity'].get_tuple() referents = list(self.iter_singleton_referents()) t = len(referents) ...
[ "def", "iter_referents", "(", "self", ")", ":", "tlow", ",", "thigh", "=", "self", "[", "'targetset_arity'", "]", ".", "get_tuple", "(", ")", "clow", ",", "chigh", "=", "self", "[", "'contrast_arity'", "]", ".", "get_tuple", "(", ")", "referents", "=", ...
Generates target sets that are compatible with the current beliefstate.
[ "Generates", "target", "sets", "that", "are", "compatible", "with", "the", "current", "beliefstate", "." ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L431-L444
249,584
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.number_of_singleton_referents
def number_of_singleton_referents(self): """ Returns the number of singleton elements of the referential domain that are compatible with the current belief state. This is the size of the union of all referent sets. """ if self.__dict__['referential_domain']: ...
python
def number_of_singleton_referents(self): """ Returns the number of singleton elements of the referential domain that are compatible with the current belief state. This is the size of the union of all referent sets. """ if self.__dict__['referential_domain']: ...
[ "def", "number_of_singleton_referents", "(", "self", ")", ":", "if", "self", ".", "__dict__", "[", "'referential_domain'", "]", ":", "ct", "=", "0", "for", "i", "in", "self", ".", "iter_singleton_referents", "(", ")", ":", "ct", "+=", "1", "return", "ct", ...
Returns the number of singleton elements of the referential domain that are compatible with the current belief state. This is the size of the union of all referent sets.
[ "Returns", "the", "number", "of", "singleton", "elements", "of", "the", "referential", "domain", "that", "are", "compatible", "with", "the", "current", "belief", "state", "." ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L460-L473
249,585
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.iter_singleton_referents
def iter_singleton_referents(self): """ Iterator of all of the singleton members of the context set. NOTE: this evaluates entities one-at-a-time, and does not handle relational constraints. """ try: for member in self.__dict__['referential_domain'].iter_entities(): ...
python
def iter_singleton_referents(self): """ Iterator of all of the singleton members of the context set. NOTE: this evaluates entities one-at-a-time, and does not handle relational constraints. """ try: for member in self.__dict__['referential_domain'].iter_entities(): ...
[ "def", "iter_singleton_referents", "(", "self", ")", ":", "try", ":", "for", "member", "in", "self", ".", "__dict__", "[", "'referential_domain'", "]", ".", "iter_entities", "(", ")", ":", "if", "self", "[", "'target'", "]", ".", "is_entailed_by", "(", "me...
Iterator of all of the singleton members of the context set. NOTE: this evaluates entities one-at-a-time, and does not handle relational constraints.
[ "Iterator", "of", "all", "of", "the", "singleton", "members", "of", "the", "context", "set", "." ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L475-L486
249,586
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.iter_singleton_referents_tuples
def iter_singleton_referents_tuples(self): """ Iterator of all of the singleton members's id number of the context set. NOTE: this evaluates entities one-at-a-time, and does not handle relational constraints. """ try: for member in self.__dict__['referential_domain']...
python
def iter_singleton_referents_tuples(self): """ Iterator of all of the singleton members's id number of the context set. NOTE: this evaluates entities one-at-a-time, and does not handle relational constraints. """ try: for member in self.__dict__['referential_domain']...
[ "def", "iter_singleton_referents_tuples", "(", "self", ")", ":", "try", ":", "for", "member", "in", "self", ".", "__dict__", "[", "'referential_domain'", "]", ".", "iter_entities", "(", ")", ":", "if", "self", "[", "'target'", "]", ".", "is_entailed_by", "("...
Iterator of all of the singleton members's id number of the context set. NOTE: this evaluates entities one-at-a-time, and does not handle relational constraints.
[ "Iterator", "of", "all", "of", "the", "singleton", "members", "s", "id", "number", "of", "the", "context", "set", "." ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L488-L499
249,587
EventTeam/beliefs
src/beliefs/beliefstate.py
BeliefState.copy
def copy(self): """ Copies the BeliefState by recursively deep-copying all of its parts. Domains are not copied, as they do not change during the interpretation or generation. """ copied = BeliefState(self.__dict__['referential_domain']) for key in ['environment...
python
def copy(self): """ Copies the BeliefState by recursively deep-copying all of its parts. Domains are not copied, as they do not change during the interpretation or generation. """ copied = BeliefState(self.__dict__['referential_domain']) for key in ['environment...
[ "def", "copy", "(", "self", ")", ":", "copied", "=", "BeliefState", "(", "self", ".", "__dict__", "[", "'referential_domain'", "]", ")", "for", "key", "in", "[", "'environment_variables'", ",", "'deferred_effects'", ",", "'pos'", ",", "'p'", "]", ":", "cop...
Copies the BeliefState by recursively deep-copying all of its parts. Domains are not copied, as they do not change during the interpretation or generation.
[ "Copies", "the", "BeliefState", "by", "recursively", "deep", "-", "copying", "all", "of", "its", "parts", ".", "Domains", "are", "not", "copied", "as", "they", "do", "not", "change", "during", "the", "interpretation", "or", "generation", "." ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L515-L524
249,588
tschaume/ccsgp_get_started
ccsgp_get_started/examples/gp_datdir.py
gp_datdir
def gp_datdir(initial, topN): """example for plotting from a text file via numpy.loadtxt 1. prepare input/output directories 2. load the data into an OrderedDict() [adjust axes units] 3. sort countries from highest to lowest population 4. select the <topN> most populated countries 5. call ccsgp.make_plot w...
python
def gp_datdir(initial, topN): """example for plotting from a text file via numpy.loadtxt 1. prepare input/output directories 2. load the data into an OrderedDict() [adjust axes units] 3. sort countries from highest to lowest population 4. select the <topN> most populated countries 5. call ccsgp.make_plot w...
[ "def", "gp_datdir", "(", "initial", ",", "topN", ")", ":", "# prepare input/output directories", "inDir", ",", "outDir", "=", "getWorkDirs", "(", ")", "initial", "=", "initial", ".", "capitalize", "(", ")", "inDir", "=", "os", ".", "path", ".", "join", "("...
example for plotting from a text file via numpy.loadtxt 1. prepare input/output directories 2. load the data into an OrderedDict() [adjust axes units] 3. sort countries from highest to lowest population 4. select the <topN> most populated countries 5. call ccsgp.make_plot with data from 4 Below is an outp...
[ "example", "for", "plotting", "from", "a", "text", "file", "via", "numpy", ".", "loadtxt" ]
e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2
https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/gp_datdir.py#L8-L78
249,589
ulf1/oxyba
oxyba/linreg_ols_pinv.py
linreg_ols_pinv
def linreg_ols_pinv(y, X, rcond=1e-15): """Linear Regression, OLS, by multiplying with Pseudoinverse""" import numpy as np try: # multiply with inverse to compute coefficients return np.dot(np.linalg.pinv( np.dot(X.T, X), rcond=rcond), np.dot(X.T, y)) except np.linalg.LinAlgError: ...
python
def linreg_ols_pinv(y, X, rcond=1e-15): """Linear Regression, OLS, by multiplying with Pseudoinverse""" import numpy as np try: # multiply with inverse to compute coefficients return np.dot(np.linalg.pinv( np.dot(X.T, X), rcond=rcond), np.dot(X.T, y)) except np.linalg.LinAlgError: ...
[ "def", "linreg_ols_pinv", "(", "y", ",", "X", ",", "rcond", "=", "1e-15", ")", ":", "import", "numpy", "as", "np", "try", ":", "# multiply with inverse to compute coefficients", "return", "np", ".", "dot", "(", "np", ".", "linalg", ".", "pinv", "(", "np", ...
Linear Regression, OLS, by multiplying with Pseudoinverse
[ "Linear", "Regression", "OLS", "by", "multiplying", "with", "Pseudoinverse" ]
b3043116050de275124365cb11e7df91fb40169d
https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/linreg_ols_pinv.py#L2-L10
249,590
xethorn/oto
oto/response.py
create_error_response
def create_error_response(code, message, status=status.BAD_REQUEST): """Create a fail response. Args: code (str): the code of the error. The title should be lowercase and underscore separated. message (dict, list, str): the message of the error. This can be a list, dicti...
python
def create_error_response(code, message, status=status.BAD_REQUEST): """Create a fail response. Args: code (str): the code of the error. The title should be lowercase and underscore separated. message (dict, list, str): the message of the error. This can be a list, dicti...
[ "def", "create_error_response", "(", "code", ",", "message", ",", "status", "=", "status", ".", "BAD_REQUEST", ")", ":", "errors", "=", "dict", "(", "code", "=", "code", ",", "message", "=", "message", ")", "return", "Response", "(", "errors", "=", "erro...
Create a fail response. Args: code (str): the code of the error. The title should be lowercase and underscore separated. message (dict, list, str): the message of the error. This can be a list, dictionary or simple string. status (int): the status code. Defaults to 4...
[ "Create", "a", "fail", "response", "." ]
2a76d374ccc4c85fdf81ae1c43698a94c0594d7b
https://github.com/xethorn/oto/blob/2a76d374ccc4c85fdf81ae1c43698a94c0594d7b/oto/response.py#L71-L89
249,591
kervi/kervi-core
kervi/values/__init__.py
NumberValue.display_unit
def display_unit(self): """ Display unit of value. :type: ``str`` """ if self._display_unit: return self._display_unit elif self._Q: config = Configuration.display.unit_systems default_system = Configuration.unit_system uni...
python
def display_unit(self): """ Display unit of value. :type: ``str`` """ if self._display_unit: return self._display_unit elif self._Q: config = Configuration.display.unit_systems default_system = Configuration.unit_system uni...
[ "def", "display_unit", "(", "self", ")", ":", "if", "self", ".", "_display_unit", ":", "return", "self", ".", "_display_unit", "elif", "self", ".", "_Q", ":", "config", "=", "Configuration", ".", "display", ".", "unit_systems", "default_system", "=", "Config...
Display unit of value. :type: ``str``
[ "Display", "unit", "of", "value", "." ]
3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23
https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/values/__init__.py#L129-L156
249,592
kervi/kervi-core
kervi/values/__init__.py
DateTimeValue.value
def value(self, new_value): """ Updates the value. If the change exceeds the change delta observers and linked values are notified. """ datetime_value = None if new_value: datetime_value = new_value.strftime("%Y-%M-%dT%H:%M:%SZ") self._set_value(date...
python
def value(self, new_value): """ Updates the value. If the change exceeds the change delta observers and linked values are notified. """ datetime_value = None if new_value: datetime_value = new_value.strftime("%Y-%M-%dT%H:%M:%SZ") self._set_value(date...
[ "def", "value", "(", "self", ",", "new_value", ")", ":", "datetime_value", "=", "None", "if", "new_value", ":", "datetime_value", "=", "new_value", ".", "strftime", "(", "\"%Y-%M-%dT%H:%M:%SZ\"", ")", "self", ".", "_set_value", "(", "datetime_value", ")" ]
Updates the value. If the change exceeds the change delta observers and linked values are notified.
[ "Updates", "the", "value", ".", "If", "the", "change", "exceeds", "the", "change", "delta", "observers", "and", "linked", "values", "are", "notified", "." ]
3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23
https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/values/__init__.py#L401-L409
249,593
kervi/kervi-core
kervi/values/__init__.py
EnumValue.add_option
def add_option(self, value, text, selected=False): """ Add option to select :param value: The value that the option represent. :param text: The text that should be displayer in dropdown :param selected: True if the option should be the default value. """ option...
python
def add_option(self, value, text, selected=False): """ Add option to select :param value: The value that the option represent. :param text: The text that should be displayer in dropdown :param selected: True if the option should be the default value. """ option...
[ "def", "add_option", "(", "self", ",", "value", ",", "text", ",", "selected", "=", "False", ")", ":", "option", "=", "{", "\"value\"", ":", "value", ",", "\"text\"", ":", "text", ",", "\"selected\"", ":", "selected", "}", "self", ".", "options", "+=", ...
Add option to select :param value: The value that the option represent. :param text: The text that should be displayer in dropdown :param selected: True if the option should be the default value.
[ "Add", "option", "to", "select" ]
3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23
https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/values/__init__.py#L503-L519
249,594
StanfordBioinformatics/scgpm_seqresults_dnanexus
scgpm_seqresults_dnanexus/log.py
get_logfile_name
def get_logfile_name(tags): """Formulates a log file name that incorporates the provided tags. The log file will be located in ``scgpm_seqresults_dnanexus.LOG_DIR``. Args: tags: `list` of tags to append to the log file name. Each tag will be '_' delimited. Each tag will be added in the same or...
python
def get_logfile_name(tags): """Formulates a log file name that incorporates the provided tags. The log file will be located in ``scgpm_seqresults_dnanexus.LOG_DIR``. Args: tags: `list` of tags to append to the log file name. Each tag will be '_' delimited. Each tag will be added in the same or...
[ "def", "get_logfile_name", "(", "tags", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "sd", ".", "LOG_DIR", ")", ":", "os", ".", "mkdir", "(", "sd", ".", "LOG_DIR", ")", "filename", "=", "\"log\"", "for", "tag", "in", "tags", ":", ...
Formulates a log file name that incorporates the provided tags. The log file will be located in ``scgpm_seqresults_dnanexus.LOG_DIR``. Args: tags: `list` of tags to append to the log file name. Each tag will be '_' delimited. Each tag will be added in the same order as provided.
[ "Formulates", "a", "log", "file", "name", "that", "incorporates", "the", "provided", "tags", "." ]
2bdaae5ec5d38a07fec99e0c5379074a591d77b6
https://github.com/StanfordBioinformatics/scgpm_seqresults_dnanexus/blob/2bdaae5ec5d38a07fec99e0c5379074a591d77b6/scgpm_seqresults_dnanexus/log.py#L14-L30
249,595
Othernet-Project/conz
conz/utils.py
rewrap
def rewrap(s, width=COLS): """ Join all lines from input string and wrap it at specified width """ s = ' '.join([l.strip() for l in s.strip().split('\n')]) return '\n'.join(textwrap.wrap(s, width))
python
def rewrap(s, width=COLS): """ Join all lines from input string and wrap it at specified width """ s = ' '.join([l.strip() for l in s.strip().split('\n')]) return '\n'.join(textwrap.wrap(s, width))
[ "def", "rewrap", "(", "s", ",", "width", "=", "COLS", ")", ":", "s", "=", "' '", ".", "join", "(", "[", "l", ".", "strip", "(", ")", "for", "l", "in", "s", ".", "strip", "(", ")", ".", "split", "(", "'\\n'", ")", "]", ")", "return", "'\\n'"...
Join all lines from input string and wrap it at specified width
[ "Join", "all", "lines", "from", "input", "string", "and", "wrap", "it", "at", "specified", "width" ]
051214fa95a837c21595b03426a2c54c522d07a0
https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/utils.py#L17-L20
249,596
jut-io/jut-python-tools
jut/commands/configs.py
add_configuration
def add_configuration(options): """ interactively add a new configuration """ if options.username != None: username = options.username else: username = prompt('Username: ') if options.password != None: password = options.password else: password = prompt('Pas...
python
def add_configuration(options): """ interactively add a new configuration """ if options.username != None: username = options.username else: username = prompt('Username: ') if options.password != None: password = options.password else: password = prompt('Pas...
[ "def", "add_configuration", "(", "options", ")", ":", "if", "options", ".", "username", "!=", "None", ":", "username", "=", "options", ".", "username", "else", ":", "username", "=", "prompt", "(", "'Username: '", ")", "if", "options", ".", "password", "!="...
interactively add a new configuration
[ "interactively", "add", "a", "new", "configuration" ]
65574d23f51a7bbced9bb25010d02da5ca5d906f
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/commands/configs.py#L58-L110
249,597
insilicolife/micti
build/lib/MICTI/Kmeans.py
Kmeans.get_initial_centroids
def get_initial_centroids(self): '''Randomly choose k data points as initial centroids''' if self.seed is not None: # useful for obtaining consistent results np.random.seed(self.seed) n = self.data.shape[0] # number of data points # Pick K indices from range [0, N). ...
python
def get_initial_centroids(self): '''Randomly choose k data points as initial centroids''' if self.seed is not None: # useful for obtaining consistent results np.random.seed(self.seed) n = self.data.shape[0] # number of data points # Pick K indices from range [0, N). ...
[ "def", "get_initial_centroids", "(", "self", ")", ":", "if", "self", ".", "seed", "is", "not", "None", ":", "# useful for obtaining consistent results", "np", ".", "random", ".", "seed", "(", "self", ".", "seed", ")", "n", "=", "self", ".", "data", ".", ...
Randomly choose k data points as initial centroids
[ "Randomly", "choose", "k", "data", "points", "as", "initial", "centroids" ]
f12f46724295b57c4859e6acf7eab580fc355eb1
https://github.com/insilicolife/micti/blob/f12f46724295b57c4859e6acf7eab580fc355eb1/build/lib/MICTI/Kmeans.py#L34-L48
249,598
insilicolife/micti
build/lib/MICTI/Kmeans.py
Kmeans.smart_initialize
def smart_initialize(self): '''Use k-means++ to initialize a good set of centroids''' if self.seed is not None: # useful for obtaining consistent results np.random.seed(self.seed) centroids = np.zeros((self.k, self.data.shape[1])) # Randomly choose the first centroid. ...
python
def smart_initialize(self): '''Use k-means++ to initialize a good set of centroids''' if self.seed is not None: # useful for obtaining consistent results np.random.seed(self.seed) centroids = np.zeros((self.k, self.data.shape[1])) # Randomly choose the first centroid. ...
[ "def", "smart_initialize", "(", "self", ")", ":", "if", "self", ".", "seed", "is", "not", "None", ":", "# useful for obtaining consistent results", "np", ".", "random", ".", "seed", "(", "self", ".", "seed", ")", "centroids", "=", "np", ".", "zeros", "(", ...
Use k-means++ to initialize a good set of centroids
[ "Use", "k", "-", "means", "++", "to", "initialize", "a", "good", "set", "of", "centroids" ]
f12f46724295b57c4859e6acf7eab580fc355eb1
https://github.com/insilicolife/micti/blob/f12f46724295b57c4859e6acf7eab580fc355eb1/build/lib/MICTI/Kmeans.py#L50-L70
249,599
etcher-be/elib_run
elib_run/_run/_capture_output.py
filter_line
def filter_line(line: str, context: RunContext) -> typing.Optional[str]: """ Filters out lines that match a given regex :param line: line to filter :type line: str :param context: run context :type context: _RunContext :return: line if it doesn't match the filter :rtype: optional str ...
python
def filter_line(line: str, context: RunContext) -> typing.Optional[str]: """ Filters out lines that match a given regex :param line: line to filter :type line: str :param context: run context :type context: _RunContext :return: line if it doesn't match the filter :rtype: optional str ...
[ "def", "filter_line", "(", "line", ":", "str", ",", "context", ":", "RunContext", ")", "->", "typing", ".", "Optional", "[", "str", "]", ":", "if", "context", ".", "filters", "is", "not", "None", ":", "for", "filter_", "in", "context", ".", "filters", ...
Filters out lines that match a given regex :param line: line to filter :type line: str :param context: run context :type context: _RunContext :return: line if it doesn't match the filter :rtype: optional str
[ "Filters", "out", "lines", "that", "match", "a", "given", "regex" ]
c9d8ba9f067ab90c5baa27375a92b23f1b97cdde
https://github.com/etcher-be/elib_run/blob/c9d8ba9f067ab90c5baa27375a92b23f1b97cdde/elib_run/_run/_capture_output.py#L15-L30