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
40,200
blockadeio/analyst_toolbench
blockade/cli/config.py
create_cloud_user
def create_cloud_user(cfg, args): """Attempt to create the user on the cloud node.""" url = cfg['api_server'] + "admin/add-user" params = {'user_email': args.user_email, 'user_name': args.user_name, 'user_role': args.user_role, 'email': cfg['email'], 'api_key': cfg['api_key']} ...
python
def create_cloud_user(cfg, args): """Attempt to create the user on the cloud node.""" url = cfg['api_server'] + "admin/add-user" params = {'user_email': args.user_email, 'user_name': args.user_name, 'user_role': args.user_role, 'email': cfg['email'], 'api_key': cfg['api_key']} ...
[ "def", "create_cloud_user", "(", "cfg", ",", "args", ")", ":", "url", "=", "cfg", "[", "'api_server'", "]", "+", "\"admin/add-user\"", "params", "=", "{", "'user_email'", ":", "args", ".", "user_email", ",", "'user_name'", ":", "args", ".", "user_name", ",...
Attempt to create the user on the cloud node.
[ "Attempt", "to", "create", "the", "user", "on", "the", "cloud", "node", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/config.py#L17-L29
40,201
chrlie/shorten
shorten/__init__.py
make_store
def make_store(name, min_length=4, **kwargs): """\ Creates a store with a reasonable keygen. .. deprecated:: 2.0.0 Instantiate stores directly e.g. ``shorten.MemoryStore(min_length=4)`` """ if name not in stores: raise ValueError('valid stores are {0}'.format(', '.join(stores))) if n...
python
def make_store(name, min_length=4, **kwargs): """\ Creates a store with a reasonable keygen. .. deprecated:: 2.0.0 Instantiate stores directly e.g. ``shorten.MemoryStore(min_length=4)`` """ if name not in stores: raise ValueError('valid stores are {0}'.format(', '.join(stores))) if n...
[ "def", "make_store", "(", "name", ",", "min_length", "=", "4", ",", "*", "*", "kwargs", ")", ":", "if", "name", "not", "in", "stores", ":", "raise", "ValueError", "(", "'valid stores are {0}'", ".", "format", "(", "', '", ".", "join", "(", "stores", ")...
\ Creates a store with a reasonable keygen. .. deprecated:: 2.0.0 Instantiate stores directly e.g. ``shorten.MemoryStore(min_length=4)``
[ "\\", "Creates", "a", "store", "with", "a", "reasonable", "keygen", "." ]
fb762a199979aefaa28c88fa035e88ea8ce4d639
https://github.com/chrlie/shorten/blob/fb762a199979aefaa28c88fa035e88ea8ce4d639/shorten/__init__.py#L23-L42
40,202
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_copy
def do_copy(self, line): ''' Copy packages between repos copy SOURCE DESTINATION Where SOURCE can be either LOCAL-FILE or REPO:PACKAGE-SPEC DESTINATION can be either a REPO: or a directory. ''' words = line.split() source, destination = words d...
python
def do_copy(self, line): ''' Copy packages between repos copy SOURCE DESTINATION Where SOURCE can be either LOCAL-FILE or REPO:PACKAGE-SPEC DESTINATION can be either a REPO: or a directory. ''' words = line.split() source, destination = words d...
[ "def", "do_copy", "(", "self", ",", "line", ")", ":", "words", "=", "line", ".", "split", "(", ")", "source", ",", "destination", "=", "words", "destination_repo", "=", "self", ".", "_get_destination_repo", "(", "destination", ")", "local_file_source", "=", ...
Copy packages between repos copy SOURCE DESTINATION Where SOURCE can be either LOCAL-FILE or REPO:PACKAGE-SPEC DESTINATION can be either a REPO: or a directory.
[ "Copy", "packages", "between", "repos" ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L192-L222
40,203
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_work_on
def do_work_on(self, repo): ''' Make repo the active one. Commands working on a repo will use it as default for repo parameter. ''' self.abort_on_nonexisting_repo(repo, 'work_on') self.network.active_repo = repo
python
def do_work_on(self, repo): ''' Make repo the active one. Commands working on a repo will use it as default for repo parameter. ''' self.abort_on_nonexisting_repo(repo, 'work_on') self.network.active_repo = repo
[ "def", "do_work_on", "(", "self", ",", "repo", ")", ":", "self", ".", "abort_on_nonexisting_repo", "(", "repo", ",", "'work_on'", ")", "self", ".", "network", ".", "active_repo", "=", "repo" ]
Make repo the active one. Commands working on a repo will use it as default for repo parameter.
[ "Make", "repo", "the", "active", "one", ".", "Commands", "working", "on", "a", "repo", "will", "use", "it", "as", "default", "for", "repo", "parameter", "." ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L224-L230
40,204
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_status
def do_status(self, line): ''' Show python packaging configuration status ''' # Pyrene version print('{} {}'.format(bold('Pyrene version'), green(get_version()))) # .pip/pip.conf - Pyrene repo name | exists or not pip_conf = os.path.expanduser('~/.pip/pip.conf') ...
python
def do_status(self, line): ''' Show python packaging configuration status ''' # Pyrene version print('{} {}'.format(bold('Pyrene version'), green(get_version()))) # .pip/pip.conf - Pyrene repo name | exists or not pip_conf = os.path.expanduser('~/.pip/pip.conf') ...
[ "def", "do_status", "(", "self", ",", "line", ")", ":", "# Pyrene version", "print", "(", "'{} {}'", ".", "format", "(", "bold", "(", "'Pyrene version'", ")", ",", "green", "(", "get_version", "(", ")", ")", ")", ")", "# .pip/pip.conf - Pyrene repo name | exis...
Show python packaging configuration status
[ "Show", "python", "packaging", "configuration", "status" ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L272-L303
40,205
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_forget
def do_forget(self, repo): ''' Drop definition of a repo. forget REPO ''' self.abort_on_nonexisting_repo(repo, 'forget') self.network.forget(repo)
python
def do_forget(self, repo): ''' Drop definition of a repo. forget REPO ''' self.abort_on_nonexisting_repo(repo, 'forget') self.network.forget(repo)
[ "def", "do_forget", "(", "self", ",", "repo", ")", ":", "self", ".", "abort_on_nonexisting_repo", "(", "repo", ",", "'forget'", ")", "self", ".", "network", ".", "forget", "(", "repo", ")" ]
Drop definition of a repo. forget REPO
[ "Drop", "definition", "of", "a", "repo", "." ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L305-L312
40,206
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_set
def do_set(self, line): ''' Set repository attributes on the active repo. set attribute=value # intended use: # directory repos: work_on developer-repo set type=directory set directory=package-directory # http repos: work_on company-pri...
python
def do_set(self, line): ''' Set repository attributes on the active repo. set attribute=value # intended use: # directory repos: work_on developer-repo set type=directory set directory=package-directory # http repos: work_on company-pri...
[ "def", "do_set", "(", "self", ",", "line", ")", ":", "self", ".", "abort_on_invalid_active_repo", "(", "'set'", ")", "repo", "=", "self", ".", "network", ".", "active_repo", "attribute", ",", "eq", ",", "value", "=", "line", ".", "partition", "(", "'='",...
Set repository attributes on the active repo. set attribute=value # intended use: # directory repos: work_on developer-repo set type=directory set directory=package-directory # http repos: work_on company-private-repo set type=http set ...
[ "Set", "repository", "attributes", "on", "the", "active", "repo", "." ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L321-L349
40,207
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_list
def do_list(self, line): ''' List known repos ''' repo_names = self.network.repo_names print('Known repos:') print(' ' + '\n '.join(repo_names))
python
def do_list(self, line): ''' List known repos ''' repo_names = self.network.repo_names print('Known repos:') print(' ' + '\n '.join(repo_names))
[ "def", "do_list", "(", "self", ",", "line", ")", ":", "repo_names", "=", "self", ".", "network", ".", "repo_names", "print", "(", "'Known repos:'", ")", "print", "(", "' '", "+", "'\\n '", ".", "join", "(", "repo_names", ")", ")" ]
List known repos
[ "List", "known", "repos" ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L386-L392
40,208
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_show
def do_show(self, repo): ''' List repo attributes ''' self.abort_on_nonexisting_effective_repo(repo, 'show') repo = self.network.get_repo(repo) repo.print_attributes()
python
def do_show(self, repo): ''' List repo attributes ''' self.abort_on_nonexisting_effective_repo(repo, 'show') repo = self.network.get_repo(repo) repo.print_attributes()
[ "def", "do_show", "(", "self", ",", "repo", ")", ":", "self", ".", "abort_on_nonexisting_effective_repo", "(", "repo", ",", "'show'", ")", "repo", "=", "self", ".", "network", ".", "get_repo", "(", "repo", ")", "repo", ".", "print_attributes", "(", ")" ]
List repo attributes
[ "List", "repo", "attributes" ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L394-L401
40,209
DS-100/nb-to-gradescope
gs100/converter.py
convert
def convert(filename, num_questions=None, solution=False, pages_per_q=DEFAULT_PAGES_PER_Q, folder='question_pdfs', output='gradescope.pdf', zoom=1): """ Public method that exports nb to PDF and pads all the questions. If num_questions ...
python
def convert(filename, num_questions=None, solution=False, pages_per_q=DEFAULT_PAGES_PER_Q, folder='question_pdfs', output='gradescope.pdf', zoom=1): """ Public method that exports nb to PDF and pads all the questions. If num_questions ...
[ "def", "convert", "(", "filename", ",", "num_questions", "=", "None", ",", "solution", "=", "False", ",", "pages_per_q", "=", "DEFAULT_PAGES_PER_Q", ",", "folder", "=", "'question_pdfs'", ",", "output", "=", "'gradescope.pdf'", ",", "zoom", "=", "1", ")", ":...
Public method that exports nb to PDF and pads all the questions. If num_questions is specified, will also check the final PDF for missing questions. If the output font size is too small/large, increase or decrease the zoom argument until the size looks correct. If solution=True, we'll export solu...
[ "Public", "method", "that", "exports", "nb", "to", "PDF", "and", "pads", "all", "the", "questions", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L36-L87
40,210
DS-100/nb-to-gradescope
gs100/converter.py
check_for_wkhtmltohtml
def check_for_wkhtmltohtml(): """ Checks to see if the wkhtmltohtml binary is installed. Raises error if not. """ locator = 'where' if sys.platform == 'win32' else 'which' wkhtmltopdf = (subprocess.Popen([locator, 'wkhtmltopdf'], stdout=subprocess.PIPE) ...
python
def check_for_wkhtmltohtml(): """ Checks to see if the wkhtmltohtml binary is installed. Raises error if not. """ locator = 'where' if sys.platform == 'win32' else 'which' wkhtmltopdf = (subprocess.Popen([locator, 'wkhtmltopdf'], stdout=subprocess.PIPE) ...
[ "def", "check_for_wkhtmltohtml", "(", ")", ":", "locator", "=", "'where'", "if", "sys", ".", "platform", "==", "'win32'", "else", "'which'", "wkhtmltopdf", "=", "(", "subprocess", ".", "Popen", "(", "[", "locator", ",", "'wkhtmltopdf'", "]", ",", "stdout", ...
Checks to see if the wkhtmltohtml binary is installed. Raises error if not.
[ "Checks", "to", "see", "if", "the", "wkhtmltohtml", "binary", "is", "installed", ".", "Raises", "error", "if", "not", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L94-L110
40,211
DS-100/nb-to-gradescope
gs100/converter.py
read_nb
def read_nb(filename, solution) -> nbformat.NotebookNode: """ Takes in a filename of a notebook and returns a notebook object containing only the cell outputs to export. """ with open(filename, 'r') as f: nb = nbformat.read(f, as_version=4) email = find_student_email(nb) preamble = ...
python
def read_nb(filename, solution) -> nbformat.NotebookNode: """ Takes in a filename of a notebook and returns a notebook object containing only the cell outputs to export. """ with open(filename, 'r') as f: nb = nbformat.read(f, as_version=4) email = find_student_email(nb) preamble = ...
[ "def", "read_nb", "(", "filename", ",", "solution", ")", "->", "nbformat", ".", "NotebookNode", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "nb", "=", "nbformat", ".", "read", "(", "f", ",", "as_version", "=", "4", ")", "...
Takes in a filename of a notebook and returns a notebook object containing only the cell outputs to export.
[ "Takes", "in", "a", "filename", "of", "a", "notebook", "and", "returns", "a", "notebook", "object", "containing", "only", "the", "cell", "outputs", "to", "export", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L180-L198
40,212
DS-100/nb-to-gradescope
gs100/converter.py
nb_to_html_cells
def nb_to_html_cells(nb) -> list: """ Converts notebook to an iterable of BS4 HTML nodes. Images are inline. """ html_exporter = HTMLExporter() html_exporter.template_file = 'basic' (body, resources) = html_exporter.from_notebook_node(nb) return BeautifulSoup(body, 'html.parser').findAll('d...
python
def nb_to_html_cells(nb) -> list: """ Converts notebook to an iterable of BS4 HTML nodes. Images are inline. """ html_exporter = HTMLExporter() html_exporter.template_file = 'basic' (body, resources) = html_exporter.from_notebook_node(nb) return BeautifulSoup(body, 'html.parser').findAll('d...
[ "def", "nb_to_html_cells", "(", "nb", ")", "->", "list", ":", "html_exporter", "=", "HTMLExporter", "(", ")", "html_exporter", ".", "template_file", "=", "'basic'", "(", "body", ",", "resources", ")", "=", "html_exporter", ".", "from_notebook_node", "(", "nb",...
Converts notebook to an iterable of BS4 HTML nodes. Images are inline.
[ "Converts", "notebook", "to", "an", "iterable", "of", "BS4", "HTML", "nodes", ".", "Images", "are", "inline", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L201-L209
40,213
DS-100/nb-to-gradescope
gs100/converter.py
nb_to_q_nums
def nb_to_q_nums(nb) -> list: """ Gets question numbers from each cell in the notebook """ def q_num(cell): assert cell.metadata.tags return first(filter(lambda t: 'q' in t, cell.metadata.tags)) return [q_num(cell) for cell in nb['cells']]
python
def nb_to_q_nums(nb) -> list: """ Gets question numbers from each cell in the notebook """ def q_num(cell): assert cell.metadata.tags return first(filter(lambda t: 'q' in t, cell.metadata.tags)) return [q_num(cell) for cell in nb['cells']]
[ "def", "nb_to_q_nums", "(", "nb", ")", "->", "list", ":", "def", "q_num", "(", "cell", ")", ":", "assert", "cell", ".", "metadata", ".", "tags", "return", "first", "(", "filter", "(", "lambda", "t", ":", "'q'", "in", "t", ",", "cell", ".", "metadat...
Gets question numbers from each cell in the notebook
[ "Gets", "question", "numbers", "from", "each", "cell", "in", "the", "notebook" ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L212-L220
40,214
DS-100/nb-to-gradescope
gs100/converter.py
pad_pdf_pages
def pad_pdf_pages(pdf_name, pages_per_q) -> None: """ Checks if PDF has the correct number of pages. If it has too many, warns the user. If it has too few, adds blank pages until the right length is reached. """ pdf = PyPDF2.PdfFileReader(pdf_name) output = PyPDF2.PdfFileWriter() num_pag...
python
def pad_pdf_pages(pdf_name, pages_per_q) -> None: """ Checks if PDF has the correct number of pages. If it has too many, warns the user. If it has too few, adds blank pages until the right length is reached. """ pdf = PyPDF2.PdfFileReader(pdf_name) output = PyPDF2.PdfFileWriter() num_pag...
[ "def", "pad_pdf_pages", "(", "pdf_name", ",", "pages_per_q", ")", "->", "None", ":", "pdf", "=", "PyPDF2", ".", "PdfFileReader", "(", "pdf_name", ")", "output", "=", "PyPDF2", ".", "PdfFileWriter", "(", ")", "num_pages", "=", "pdf", ".", "getNumPages", "("...
Checks if PDF has the correct number of pages. If it has too many, warns the user. If it has too few, adds blank pages until the right length is reached.
[ "Checks", "if", "PDF", "has", "the", "correct", "number", "of", "pages", ".", "If", "it", "has", "too", "many", "warns", "the", "user", ".", "If", "it", "has", "too", "few", "adds", "blank", "pages", "until", "the", "right", "length", "is", "reached", ...
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L223-L248
40,215
DS-100/nb-to-gradescope
gs100/converter.py
create_question_pdfs
def create_question_pdfs(nb, pages_per_q, folder, zoom) -> list: """ Converts each cells in tbe notebook to a PDF named something like 'q04c.pdf'. Places PDFs in the specified folder and returns the list of created PDF locations. """ html_cells = nb_to_html_cells(nb) q_nums = nb_to_q_nums(nb...
python
def create_question_pdfs(nb, pages_per_q, folder, zoom) -> list: """ Converts each cells in tbe notebook to a PDF named something like 'q04c.pdf'. Places PDFs in the specified folder and returns the list of created PDF locations. """ html_cells = nb_to_html_cells(nb) q_nums = nb_to_q_nums(nb...
[ "def", "create_question_pdfs", "(", "nb", ",", "pages_per_q", ",", "folder", ",", "zoom", ")", "->", "list", ":", "html_cells", "=", "nb_to_html_cells", "(", "nb", ")", "q_nums", "=", "nb_to_q_nums", "(", "nb", ")", "os", ".", "makedirs", "(", "folder", ...
Converts each cells in tbe notebook to a PDF named something like 'q04c.pdf'. Places PDFs in the specified folder and returns the list of created PDF locations.
[ "Converts", "each", "cells", "in", "tbe", "notebook", "to", "a", "PDF", "named", "something", "like", "q04c", ".", "pdf", ".", "Places", "PDFs", "in", "the", "specified", "folder", "and", "returns", "the", "list", "of", "created", "PDF", "locations", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L266-L291
40,216
DS-100/nb-to-gradescope
gs100/converter.py
merge_pdfs
def merge_pdfs(pdf_names, output) -> None: """ Merges all pdfs together into a single long PDF. """ merger = PyPDF2.PdfFileMerger() for filename in pdf_names: merger.append(filename) merger.write(output) merger.close()
python
def merge_pdfs(pdf_names, output) -> None: """ Merges all pdfs together into a single long PDF. """ merger = PyPDF2.PdfFileMerger() for filename in pdf_names: merger.append(filename) merger.write(output) merger.close()
[ "def", "merge_pdfs", "(", "pdf_names", ",", "output", ")", "->", "None", ":", "merger", "=", "PyPDF2", ".", "PdfFileMerger", "(", ")", "for", "filename", "in", "pdf_names", ":", "merger", ".", "append", "(", "filename", ")", "merger", ".", "write", "(", ...
Merges all pdfs together into a single long PDF.
[ "Merges", "all", "pdfs", "together", "into", "a", "single", "long", "PDF", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L294-L303
40,217
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.connection_count
def connection_count(self): """Number of currently open connections to the database. (Stored in table sqlarray_master.) """ return self.sql("SELECT value FROM %(master)s WHERE name = 'connection_counter'" % vars(self), cache=False, asrecarray=False)[0][0]
python
def connection_count(self): """Number of currently open connections to the database. (Stored in table sqlarray_master.) """ return self.sql("SELECT value FROM %(master)s WHERE name = 'connection_counter'" % vars(self), cache=False, asrecarray=False)[0][0]
[ "def", "connection_count", "(", "self", ")", ":", "return", "self", ".", "sql", "(", "\"SELECT value FROM %(master)s WHERE name = 'connection_counter'\"", "%", "vars", "(", "self", ")", ",", "cache", "=", "False", ",", "asrecarray", "=", "False", ")", "[", "0", ...
Number of currently open connections to the database. (Stored in table sqlarray_master.)
[ "Number", "of", "currently", "open", "connections", "to", "the", "database", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L241-L247
40,218
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.sql_select
def sql_select(self,fields,*args,**kwargs): """Execute a simple SQL ``SELECT`` statement and returns values as new numpy rec array. The arguments *fields* and the additional optional arguments are simply concatenated with additional SQL statements according to the template:: ...
python
def sql_select(self,fields,*args,**kwargs): """Execute a simple SQL ``SELECT`` statement and returns values as new numpy rec array. The arguments *fields* and the additional optional arguments are simply concatenated with additional SQL statements according to the template:: ...
[ "def", "sql_select", "(", "self", ",", "fields", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "SQL", "=", "\"SELECT \"", "+", "str", "(", "fields", ")", "+", "\" FROM __self__ \"", "+", "\" \"", ".", "join", "(", "args", ")", "return", "self"...
Execute a simple SQL ``SELECT`` statement and returns values as new numpy rec array. The arguments *fields* and the additional optional arguments are simply concatenated with additional SQL statements according to the template:: SELECT <fields> FROM __self__ [args] The simp...
[ "Execute", "a", "simple", "SQL", "SELECT", "statement", "and", "returns", "values", "as", "new", "numpy", "rec", "array", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L348-L386
40,219
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.sql
def sql(self,SQL,parameters=None,asrecarray=True,cache=True): """Execute sql statement. :Arguments: SQL : string Full SQL command; can contain the ``?`` place holder so that values supplied with the ``parameters`` keyword can be interpolated using th...
python
def sql(self,SQL,parameters=None,asrecarray=True,cache=True): """Execute sql statement. :Arguments: SQL : string Full SQL command; can contain the ``?`` place holder so that values supplied with the ``parameters`` keyword can be interpolated using th...
[ "def", "sql", "(", "self", ",", "SQL", ",", "parameters", "=", "None", ",", "asrecarray", "=", "True", ",", "cache", "=", "True", ")", ":", "SQL", "=", "SQL", ".", "replace", "(", "'__self__'", ",", "self", ".", "name", ")", "# Cache the last N (query,...
Execute sql statement. :Arguments: SQL : string Full SQL command; can contain the ``?`` place holder so that values supplied with the ``parameters`` keyword can be interpolated using the ``pysqlite`` interface. parameters : tuple Par...
[ "Execute", "sql", "statement", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L390-L464
40,220
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.limits
def limits(self,variable): """Return minimum and maximum of variable across all rows of data.""" (vmin,vmax), = self.SELECT('min(%(variable)s), max(%(variable)s)' % vars()) return vmin,vmax
python
def limits(self,variable): """Return minimum and maximum of variable across all rows of data.""" (vmin,vmax), = self.SELECT('min(%(variable)s), max(%(variable)s)' % vars()) return vmin,vmax
[ "def", "limits", "(", "self", ",", "variable", ")", ":", "(", "vmin", ",", "vmax", ")", ",", "=", "self", ".", "SELECT", "(", "'min(%(variable)s), max(%(variable)s)'", "%", "vars", "(", ")", ")", "return", "vmin", ",", "vmax" ]
Return minimum and maximum of variable across all rows of data.
[ "Return", "minimum", "and", "maximum", "of", "variable", "across", "all", "rows", "of", "data", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L466-L469
40,221
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.selection
def selection(self, SQL, parameters=None, **kwargs): """Return a new SQLarray from a SELECT selection. This method is useful to build complicated selections and essentially new tables from existing data. The result of the SQL query is stored as a new table in the database. By de...
python
def selection(self, SQL, parameters=None, **kwargs): """Return a new SQLarray from a SELECT selection. This method is useful to build complicated selections and essentially new tables from existing data. The result of the SQL query is stored as a new table in the database. By de...
[ "def", "selection", "(", "self", ",", "SQL", ",", "parameters", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# TODO: under development", "# - could use VIEW", "force", "=", "kwargs", ".", "pop", "(", "'force'", ",", "False", ")", "# pretty unsafe... I hope...
Return a new SQLarray from a SELECT selection. This method is useful to build complicated selections and essentially new tables from existing data. The result of the SQL query is stored as a new table in the database. By default, a unique name is created but this can be overridden ...
[ "Return", "a", "new", "SQLarray", "from", "a", "SELECT", "selection", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L471-L551
40,222
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray._init_sqlite_functions
def _init_sqlite_functions(self): """additional SQL functions to the database""" self.connection.create_function("sqrt", 1,sqlfunctions._sqrt) self.connection.create_function("sqr", 1,sqlfunctions._sqr) self.connection.create_function("periodic", 1,sqlfunctions._periodic) self.c...
python
def _init_sqlite_functions(self): """additional SQL functions to the database""" self.connection.create_function("sqrt", 1,sqlfunctions._sqrt) self.connection.create_function("sqr", 1,sqlfunctions._sqr) self.connection.create_function("periodic", 1,sqlfunctions._periodic) self.c...
[ "def", "_init_sqlite_functions", "(", "self", ")", ":", "self", ".", "connection", ".", "create_function", "(", "\"sqrt\"", ",", "1", ",", "sqlfunctions", ".", "_sqrt", ")", "self", ".", "connection", ".", "create_function", "(", "\"sqr\"", ",", "1", ",", ...
additional SQL functions to the database
[ "additional", "SQL", "functions", "to", "the", "database" ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L553-L574
40,223
orbeckst/RecSQL
recsql/sqlarray.py
KRingbuffer._prune
def _prune(self): """Primitive way to keep dict in sync with RB.""" delkeys = [k for k in self.keys() if k not in self.__ringbuffer] for k in delkeys: # necessary because dict is changed during iterations super(KRingbuffer,self).__delitem__(k)
python
def _prune(self): """Primitive way to keep dict in sync with RB.""" delkeys = [k for k in self.keys() if k not in self.__ringbuffer] for k in delkeys: # necessary because dict is changed during iterations super(KRingbuffer,self).__delitem__(k)
[ "def", "_prune", "(", "self", ")", ":", "delkeys", "=", "[", "k", "for", "k", "in", "self", ".", "keys", "(", ")", "if", "k", "not", "in", "self", ".", "__ringbuffer", "]", "for", "k", "in", "delkeys", ":", "# necessary because dict is changed during ite...
Primitive way to keep dict in sync with RB.
[ "Primitive", "way", "to", "keep", "dict", "in", "sync", "with", "RB", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L692-L696
40,224
CodyKochmann/generators
generators/chunk_on.py
chunk_on
def chunk_on(pipeline, new_chunk_signal, output_type=tuple): ''' split the stream into seperate chunks based on a new chunk signal ''' assert iterable(pipeline), 'chunks needs pipeline to be iterable' assert callable(new_chunk_signal), 'chunks needs new_chunk_signal to be callable' assert callable(outpu...
python
def chunk_on(pipeline, new_chunk_signal, output_type=tuple): ''' split the stream into seperate chunks based on a new chunk signal ''' assert iterable(pipeline), 'chunks needs pipeline to be iterable' assert callable(new_chunk_signal), 'chunks needs new_chunk_signal to be callable' assert callable(outpu...
[ "def", "chunk_on", "(", "pipeline", ",", "new_chunk_signal", ",", "output_type", "=", "tuple", ")", ":", "assert", "iterable", "(", "pipeline", ")", ",", "'chunks needs pipeline to be iterable'", "assert", "callable", "(", "new_chunk_signal", ")", ",", "'chunks need...
split the stream into seperate chunks based on a new chunk signal
[ "split", "the", "stream", "into", "seperate", "chunks", "based", "on", "a", "new", "chunk", "signal" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/chunk_on.py#L12-L26
40,225
XRDX/pyleap
pyleap/shape/sprite.py
Sprite.center_image
def center_image(self, img): """Sets an image's anchor point to its center""" img.anchor_x = img.width // 2 # int img.anchor_y = img.height // 2
python
def center_image(self, img): """Sets an image's anchor point to its center""" img.anchor_x = img.width // 2 # int img.anchor_y = img.height // 2
[ "def", "center_image", "(", "self", ",", "img", ")", ":", "img", ".", "anchor_x", "=", "img", ".", "width", "//", "2", "# int", "img", ".", "anchor_y", "=", "img", ".", "height", "//", "2" ]
Sets an image's anchor point to its center
[ "Sets", "an", "image", "s", "anchor", "point", "to", "its", "center" ]
234c722cfbe66814254ab0d8f67d16b0b774f4d5
https://github.com/XRDX/pyleap/blob/234c722cfbe66814254ab0d8f67d16b0b774f4d5/pyleap/shape/sprite.py#L84-L87
40,226
fantastic001/pyfb
pyfacebook/conversation.py
Conversation.get_persons
def get_persons(self): """ Returns list of strings which represents persons being chated with """ cs = self.data["to"]["data"] res = [] for c in cs: res.append(c["name"]) return res
python
def get_persons(self): """ Returns list of strings which represents persons being chated with """ cs = self.data["to"]["data"] res = [] for c in cs: res.append(c["name"]) return res
[ "def", "get_persons", "(", "self", ")", ":", "cs", "=", "self", ".", "data", "[", "\"to\"", "]", "[", "\"data\"", "]", "res", "=", "[", "]", "for", "c", "in", "cs", ":", "res", ".", "append", "(", "c", "[", "\"name\"", "]", ")", "return", "res"...
Returns list of strings which represents persons being chated with
[ "Returns", "list", "of", "strings", "which", "represents", "persons", "being", "chated", "with" ]
385a620e8c825fea5c859aec8c309ea59ef06713
https://github.com/fantastic001/pyfb/blob/385a620e8c825fea5c859aec8c309ea59ef06713/pyfacebook/conversation.py#L21-L29
40,227
fantastic001/pyfb
pyfacebook/conversation.py
Conversation.get_messages
def get_messages(self): """ Returns list of Message objects which represents messages being transported. """ cs = self.data["comments"]["data"] res = [] for c in cs: res.append(Message(c,self)) return res
python
def get_messages(self): """ Returns list of Message objects which represents messages being transported. """ cs = self.data["comments"]["data"] res = [] for c in cs: res.append(Message(c,self)) return res
[ "def", "get_messages", "(", "self", ")", ":", "cs", "=", "self", ".", "data", "[", "\"comments\"", "]", "[", "\"data\"", "]", "res", "=", "[", "]", "for", "c", "in", "cs", ":", "res", ".", "append", "(", "Message", "(", "c", ",", "self", ")", "...
Returns list of Message objects which represents messages being transported.
[ "Returns", "list", "of", "Message", "objects", "which", "represents", "messages", "being", "transported", "." ]
385a620e8c825fea5c859aec8c309ea59ef06713
https://github.com/fantastic001/pyfb/blob/385a620e8c825fea5c859aec8c309ea59ef06713/pyfacebook/conversation.py#L31-L39
40,228
fantastic001/pyfb
pyfacebook/conversation.py
Conversation.next
def next(self): """ Returns next paging """ c = Conversation(self.data, requests.get(self.data["comments"]["paging"]["next"]).json()) if "error" in c.data["comments"] and c.data["comments"]["error"]["code"] == 613: raise LimitExceededException() return c
python
def next(self): """ Returns next paging """ c = Conversation(self.data, requests.get(self.data["comments"]["paging"]["next"]).json()) if "error" in c.data["comments"] and c.data["comments"]["error"]["code"] == 613: raise LimitExceededException() return c
[ "def", "next", "(", "self", ")", ":", "c", "=", "Conversation", "(", "self", ".", "data", ",", "requests", ".", "get", "(", "self", ".", "data", "[", "\"comments\"", "]", "[", "\"paging\"", "]", "[", "\"next\"", "]", ")", ".", "json", "(", ")", "...
Returns next paging
[ "Returns", "next", "paging" ]
385a620e8c825fea5c859aec8c309ea59ef06713
https://github.com/fantastic001/pyfb/blob/385a620e8c825fea5c859aec8c309ea59ef06713/pyfacebook/conversation.py#L41-L48
40,229
jkitzes/macroeco
macroeco/empirical/_empirical.py
_subset_table
def _subset_table(full_table, subset): """ Return subtable matching all conditions in subset Parameters ---------- full_table : dataframe Entire data table subset : str String describing subset of data to use for analysis Returns ------- dataframe Subtable w...
python
def _subset_table(full_table, subset): """ Return subtable matching all conditions in subset Parameters ---------- full_table : dataframe Entire data table subset : str String describing subset of data to use for analysis Returns ------- dataframe Subtable w...
[ "def", "_subset_table", "(", "full_table", ",", "subset", ")", ":", "if", "not", "subset", ":", "return", "full_table", "# TODO: Figure out syntax for logical or", "conditions", "=", "subset", ".", "replace", "(", "' '", ",", "''", ")", ".", "split", "(", "';'...
Return subtable matching all conditions in subset Parameters ---------- full_table : dataframe Entire data table subset : str String describing subset of data to use for analysis Returns ------- dataframe Subtable with records from table meeting requirements in subs...
[ "Return", "subtable", "matching", "all", "conditions", "in", "subset" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L275-L308
40,230
jkitzes/macroeco
macroeco/empirical/_empirical.py
_subset_meta
def _subset_meta(full_meta, subset, incremented=False): """ Return metadata reflecting all conditions in subset Parameters ---------- full_meta : ConfigParser obj Metadata object subset : str String describing subset of data to use for analysis incremented : bool If ...
python
def _subset_meta(full_meta, subset, incremented=False): """ Return metadata reflecting all conditions in subset Parameters ---------- full_meta : ConfigParser obj Metadata object subset : str String describing subset of data to use for analysis incremented : bool If ...
[ "def", "_subset_meta", "(", "full_meta", ",", "subset", ",", "incremented", "=", "False", ")", ":", "if", "not", "subset", ":", "return", "full_meta", ",", "False", "meta", "=", "{", "}", "# Make deepcopy of entire meta (all section dicts in meta dict)", "for", "k...
Return metadata reflecting all conditions in subset Parameters ---------- full_meta : ConfigParser obj Metadata object subset : str String describing subset of data to use for analysis incremented : bool If True, the metadata has already been incremented Returns ---...
[ "Return", "metadata", "reflecting", "all", "conditions", "in", "subset" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L310-L373
40,231
jkitzes/macroeco
macroeco/empirical/_empirical.py
sad
def sad(patch, cols, splits, clean=True): """ Calculates an empirical species abundance distribution Parameters ---------- {0} clean : bool If True, all species with zero abundance are removed from SAD results. Default False. Returns ------- {1} Result has two colum...
python
def sad(patch, cols, splits, clean=True): """ Calculates an empirical species abundance distribution Parameters ---------- {0} clean : bool If True, all species with zero abundance are removed from SAD results. Default False. Returns ------- {1} Result has two colum...
[ "def", "sad", "(", "patch", ",", "cols", ",", "splits", ",", "clean", "=", "True", ")", ":", "(", "spp_col", ",", "count_col", ")", ",", "patch", "=", "_get_cols", "(", "[", "'spp_col'", ",", "'count_col'", "]", ",", "cols", ",", "patch", ")", "ful...
Calculates an empirical species abundance distribution Parameters ---------- {0} clean : bool If True, all species with zero abundance are removed from SAD results. Default False. Returns ------- {1} Result has two columns: spp (species identifier) and y (individuals of ...
[ "Calculates", "an", "empirical", "species", "abundance", "distribution" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L378-L504
40,232
jkitzes/macroeco
macroeco/empirical/_empirical.py
ssad
def ssad(patch, cols, splits): """ Calculates an empirical intra-specific spatial abundance distribution Parameters ---------- {0} Returns ------- {1} Result has one column giving the individuals of species in each subplot. Notes ----- {2} {3} Examples --...
python
def ssad(patch, cols, splits): """ Calculates an empirical intra-specific spatial abundance distribution Parameters ---------- {0} Returns ------- {1} Result has one column giving the individuals of species in each subplot. Notes ----- {2} {3} Examples --...
[ "def", "ssad", "(", "patch", ",", "cols", ",", "splits", ")", ":", "# Get and check SAD", "sad_results", "=", "sad", "(", "patch", ",", "cols", ",", "splits", ",", "clean", "=", "False", ")", "# Create dataframe with col for spp name and numbered col for each split"...
Calculates an empirical intra-specific spatial abundance distribution Parameters ---------- {0} Returns ------- {1} Result has one column giving the individuals of species in each subplot. Notes ----- {2} {3} Examples -------- {4} >>> # Get the spatial ...
[ "Calculates", "an", "empirical", "intra", "-", "specific", "spatial", "abundance", "distribution" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L509-L585
40,233
jkitzes/macroeco
macroeco/empirical/_empirical.py
sar
def sar(patch, cols, splits, divs, ear=False): """ Calculates an empirical species area or endemics area relationship Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. See notes. ear : bool If True, calculates an endemics area relationship ...
python
def sar(patch, cols, splits, divs, ear=False): """ Calculates an empirical species area or endemics area relationship Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. See notes. ear : bool If True, calculates an endemics area relationship ...
[ "def", "sar", "(", "patch", ",", "cols", ",", "splits", ",", "divs", ",", "ear", "=", "False", ")", ":", "def", "sar_y_func", "(", "spatial_table", ",", "all_spp", ")", ":", "return", "np", ".", "mean", "(", "spatial_table", "[", "'n_spp'", "]", ")",...
Calculates an empirical species area or endemics area relationship Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. See notes. ear : bool If True, calculates an endemics area relationship Returns ------- {1} Result has 5 columns; div, x...
[ "Calculates", "an", "empirical", "species", "area", "or", "endemics", "area", "relationship" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L591-L673
40,234
jkitzes/macroeco
macroeco/empirical/_empirical.py
_sar_ear_inner
def _sar_ear_inner(patch, cols, splits, divs, y_func): """ y_func is function calculating the mean number of species or endemics, respectively, for the SAR or EAR """ (spp_col, count_col, x_col, y_col), patch = \ _get_cols(['spp_col', 'count_col', 'x_col', 'y_col'], cols, patch) # Loop...
python
def _sar_ear_inner(patch, cols, splits, divs, y_func): """ y_func is function calculating the mean number of species or endemics, respectively, for the SAR or EAR """ (spp_col, count_col, x_col, y_col), patch = \ _get_cols(['spp_col', 'count_col', 'x_col', 'y_col'], cols, patch) # Loop...
[ "def", "_sar_ear_inner", "(", "patch", ",", "cols", ",", "splits", ",", "divs", ",", "y_func", ")", ":", "(", "spp_col", ",", "count_col", ",", "x_col", ",", "y_col", ")", ",", "patch", "=", "_get_cols", "(", "[", "'spp_col'", ",", "'count_col'", ",", ...
y_func is function calculating the mean number of species or endemics, respectively, for the SAR or EAR
[ "y_func", "is", "function", "calculating", "the", "mean", "number", "of", "species", "or", "endemics", "respectively", "for", "the", "SAR", "or", "EAR" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L676-L713
40,235
jkitzes/macroeco
macroeco/empirical/_empirical.py
comm_grid
def comm_grid(patch, cols, splits, divs, metric='Sorensen'): """ Calculates commonality as a function of distance for a gridded patch Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. Unlike SAR and EAR, only one division can be given at a time. ...
python
def comm_grid(patch, cols, splits, divs, metric='Sorensen'): """ Calculates commonality as a function of distance for a gridded patch Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. Unlike SAR and EAR, only one division can be given at a time. ...
[ "def", "comm_grid", "(", "patch", ",", "cols", ",", "splits", ",", "divs", ",", "metric", "=", "'Sorensen'", ")", ":", "(", "spp_col", ",", "count_col", ",", "x_col", ",", "y_col", ")", ",", "patch", "=", "_get_cols", "(", "[", "'spp_col'", ",", "'co...
Calculates commonality as a function of distance for a gridded patch Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. Unlike SAR and EAR, only one division can be given at a time. See notes. metric : str One of Sorensen or Jaccard, giving th...
[ "Calculates", "commonality", "as", "a", "function", "of", "distance", "for", "a", "gridded", "patch" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L729-L804
40,236
jkitzes/macroeco
macroeco/empirical/_empirical.py
_yield_spatial_table
def _yield_spatial_table(patch, div, spp_col, count_col, x_col, y_col): """ Calculates an empirical spatial table Yields ------- DataFrame Spatial table for each division. See Notes. Notes ----- The spatial table is the precursor to the SAR, EAR, and grid-based commonality ...
python
def _yield_spatial_table(patch, div, spp_col, count_col, x_col, y_col): """ Calculates an empirical spatial table Yields ------- DataFrame Spatial table for each division. See Notes. Notes ----- The spatial table is the precursor to the SAR, EAR, and grid-based commonality ...
[ "def", "_yield_spatial_table", "(", "patch", ",", "div", ",", "spp_col", ",", "count_col", ",", "x_col", ",", "y_col", ")", ":", "# Catch error if you don't use ; after divs in comm_grid in MacroecoDesktop", "try", ":", "div_split_list", "=", "div", ".", "replace", "(...
Calculates an empirical spatial table Yields ------- DataFrame Spatial table for each division. See Notes. Notes ----- The spatial table is the precursor to the SAR, EAR, and grid-based commonality metrics. Each row in the table corresponds to a cell created by a given division...
[ "Calculates", "an", "empirical", "spatial", "table" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L807-L860
40,237
jkitzes/macroeco
macroeco/empirical/_empirical.py
_get_cols
def _get_cols(special_col_names, cols, patch): """ Retrieve values of special_cols from cols string or patch metadata """ # If cols not given, try to fall back on cols from metadata if not cols: if 'cols' in patch.meta['Description'].keys(): cols = patch.meta['Description']['col...
python
def _get_cols(special_col_names, cols, patch): """ Retrieve values of special_cols from cols string or patch metadata """ # If cols not given, try to fall back on cols from metadata if not cols: if 'cols' in patch.meta['Description'].keys(): cols = patch.meta['Description']['col...
[ "def", "_get_cols", "(", "special_col_names", ",", "cols", ",", "patch", ")", ":", "# If cols not given, try to fall back on cols from metadata", "if", "not", "cols", ":", "if", "'cols'", "in", "patch", ".", "meta", "[", "'Description'", "]", ".", "keys", "(", "...
Retrieve values of special_cols from cols string or patch metadata
[ "Retrieve", "values", "of", "special_cols", "from", "cols", "string", "or", "patch", "metadata" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1146-L1181
40,238
jkitzes/macroeco
macroeco/empirical/_empirical.py
_yield_subpatches
def _yield_subpatches(patch, splits, name='split'): """ Iterator for subtables defined by a splits string Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Yields ------ ...
python
def _yield_subpatches(patch, splits, name='split'): """ Iterator for subtables defined by a splits string Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Yields ------ ...
[ "def", "_yield_subpatches", "(", "patch", ",", "splits", ",", "name", "=", "'split'", ")", ":", "if", "splits", ":", "subset_list", "=", "_parse_splits", "(", "patch", ",", "splits", ")", "for", "subset", "in", "subset_list", ":", "logging", ".", "info", ...
Iterator for subtables defined by a splits string Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Yields ------ tuple First element is subset string, second is subt...
[ "Iterator", "for", "subtables", "defined", "by", "a", "splits", "string" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1185-L1218
40,239
jkitzes/macroeco
macroeco/empirical/_empirical.py
_parse_splits
def _parse_splits(patch, splits): """ Parse splits string to get list of all associated subset strings. Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Returns ------- ...
python
def _parse_splits(patch, splits): """ Parse splits string to get list of all associated subset strings. Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Returns ------- ...
[ "def", "_parse_splits", "(", "patch", ",", "splits", ")", ":", "split_list", "=", "splits", ".", "replace", "(", "' '", ",", "''", ")", ".", "split", "(", "';'", ")", "subset_list", "=", "[", "]", "# List of all subset strings", "for", "split", "in", "sp...
Parse splits string to get list of all associated subset strings. Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Returns ------- list List of subset strings derive...
[ "Parse", "splits", "string", "to", "get", "list", "of", "all", "associated", "subset", "strings", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1222-L1264
40,240
jkitzes/macroeco
macroeco/empirical/_empirical.py
_product
def _product(*args, **kwds): """ Generates cartesian product of lists given as arguments From itertools.product documentation """ pools = map(tuple, args) * kwds.get('repeat', 1) result = [[]] for pool in pools: result = [x+[y] for x in result for y in pool] return result
python
def _product(*args, **kwds): """ Generates cartesian product of lists given as arguments From itertools.product documentation """ pools = map(tuple, args) * kwds.get('repeat', 1) result = [[]] for pool in pools: result = [x+[y] for x in result for y in pool] return result
[ "def", "_product", "(", "*", "args", ",", "*", "*", "kwds", ")", ":", "pools", "=", "map", "(", "tuple", ",", "args", ")", "*", "kwds", ".", "get", "(", "'repeat'", ",", "1", ")", "result", "=", "[", "[", "]", "]", "for", "pool", "in", "pools...
Generates cartesian product of lists given as arguments From itertools.product documentation
[ "Generates", "cartesian", "product", "of", "lists", "given", "as", "arguments" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1296-L1307
40,241
jkitzes/macroeco
macroeco/empirical/_empirical.py
empirical_cdf
def empirical_cdf(data): """ Generates an empirical cdf from data Parameters ---------- data : iterable Empirical data Returns -------- DataFrame Columns 'data' and 'ecdf'. 'data' contains ordered data and 'ecdf' contains the corresponding ecdf values for the da...
python
def empirical_cdf(data): """ Generates an empirical cdf from data Parameters ---------- data : iterable Empirical data Returns -------- DataFrame Columns 'data' and 'ecdf'. 'data' contains ordered data and 'ecdf' contains the corresponding ecdf values for the da...
[ "def", "empirical_cdf", "(", "data", ")", ":", "vals", "=", "pd", ".", "Series", "(", "data", ")", ".", "value_counts", "(", ")", "ecdf", "=", "pd", ".", "DataFrame", "(", "data", ")", ".", "set_index", "(", "keys", "=", "0", ")", "probs", "=", "...
Generates an empirical cdf from data Parameters ---------- data : iterable Empirical data Returns -------- DataFrame Columns 'data' and 'ecdf'. 'data' contains ordered data and 'ecdf' contains the corresponding ecdf values for the data.
[ "Generates", "an", "empirical", "cdf", "from", "data" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1341-L1365
40,242
jkitzes/macroeco
macroeco/empirical/_empirical.py
Patch._load_table
def _load_table(self, metadata_path, data_path): """ Load data table, taking subset if needed Parameters ---------- metadata_path : str Path to metadata file data_path : str Path to data file, absolute or relative to metadata file Returns...
python
def _load_table(self, metadata_path, data_path): """ Load data table, taking subset if needed Parameters ---------- metadata_path : str Path to metadata file data_path : str Path to data file, absolute or relative to metadata file Returns...
[ "def", "_load_table", "(", "self", ",", "metadata_path", ",", "data_path", ")", ":", "metadata_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "expanduser", "(", "metadata_path", ")", ")", "data_path", "=", "os", ".", "path", ...
Load data table, taking subset if needed Parameters ---------- metadata_path : str Path to metadata file data_path : str Path to data file, absolute or relative to metadata file Returns ------- dataframe Table for analysis
[ "Load", "data", "table", "taking", "subset", "if", "needed" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L177-L211
40,243
jkitzes/macroeco
macroeco/empirical/_empirical.py
Patch._get_db_table
def _get_db_table(self, data_path, extension): """ Query a database and return query result as a recarray Parameters ---------- data_path : str Path to the database file extension : str Type of database, either sql or db Returns -...
python
def _get_db_table(self, data_path, extension): """ Query a database and return query result as a recarray Parameters ---------- data_path : str Path to the database file extension : str Type of database, either sql or db Returns -...
[ "def", "_get_db_table", "(", "self", ",", "data_path", ",", "extension", ")", ":", "# TODO: This is probably broken", "raise", "NotImplementedError", ",", "\"SQL and db file formats not yet supported\"", "# Load table", "if", "extension", "==", "'sql'", ":", "con", "=", ...
Query a database and return query result as a recarray Parameters ---------- data_path : str Path to the database file extension : str Type of database, either sql or db Returns ------- table : recarray The database query as a...
[ "Query", "a", "database", "and", "return", "query", "result", "as", "a", "recarray" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L213-L272
40,244
jkitzes/macroeco
macroeco/misc/misc.py
doc_sub
def doc_sub(*sub): """ Decorator for performing substitutions in docstrings. Using @doc_sub(some_note, other_note) on a function with {0} and {1} in the docstring will substitute the contents of some_note and other_note for {0} and {1}, respectively. Decorator appears to work properly both wit...
python
def doc_sub(*sub): """ Decorator for performing substitutions in docstrings. Using @doc_sub(some_note, other_note) on a function with {0} and {1} in the docstring will substitute the contents of some_note and other_note for {0} and {1}, respectively. Decorator appears to work properly both wit...
[ "def", "doc_sub", "(", "*", "sub", ")", ":", "def", "dec", "(", "obj", ")", ":", "obj", ".", "__doc__", "=", "obj", ".", "__doc__", ".", "format", "(", "*", "sub", ")", "return", "obj", "return", "dec" ]
Decorator for performing substitutions in docstrings. Using @doc_sub(some_note, other_note) on a function with {0} and {1} in the docstring will substitute the contents of some_note and other_note for {0} and {1}, respectively. Decorator appears to work properly both with IPython help (tab completion ...
[ "Decorator", "for", "performing", "substitutions", "in", "docstrings", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/misc/misc.py#L60-L75
40,245
jkitzes/macroeco
macroeco/misc/misc.py
log_start_end
def log_start_end(f): """ Decorator to log start and end of function Use of decorator module here ensures that argspec will inspect wrapped function, not the decorator itself. http://micheles.googlecode.com/hg/decorator/documentation.html """ def inner(f, *args, **kwargs): logging.i...
python
def log_start_end(f): """ Decorator to log start and end of function Use of decorator module here ensures that argspec will inspect wrapped function, not the decorator itself. http://micheles.googlecode.com/hg/decorator/documentation.html """ def inner(f, *args, **kwargs): logging.i...
[ "def", "log_start_end", "(", "f", ")", ":", "def", "inner", "(", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logging", ".", "info", "(", "'Starting %s'", "%", "f", ".", "__name__", ")", "res", "=", "f", "(", "*", "args", ",", "*"...
Decorator to log start and end of function Use of decorator module here ensures that argspec will inspect wrapped function, not the decorator itself. http://micheles.googlecode.com/hg/decorator/documentation.html
[ "Decorator", "to", "log", "start", "and", "end", "of", "function" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/misc/misc.py#L77-L90
40,246
jkitzes/macroeco
macroeco/misc/misc.py
check_parameter_file
def check_parameter_file(filename): """ Function does a rudimentary check whether the cols, splits and divs columns in the parameter files are formatted properly. Just provides a preliminary check. Will only catch basic mistakes Parameters ---------- filename : str Path to paramete...
python
def check_parameter_file(filename): """ Function does a rudimentary check whether the cols, splits and divs columns in the parameter files are formatted properly. Just provides a preliminary check. Will only catch basic mistakes Parameters ---------- filename : str Path to paramete...
[ "def", "check_parameter_file", "(", "filename", ")", ":", "# Load file", "with", "open", "(", "filename", ",", "\"r\"", ")", "as", "fin", ":", "content", "=", "fin", ".", "read", "(", ")", "# Check cols and splits strings", "bad_names", "=", "[", "]", "line_...
Function does a rudimentary check whether the cols, splits and divs columns in the parameter files are formatted properly. Just provides a preliminary check. Will only catch basic mistakes Parameters ---------- filename : str Path to parameters file Returns ------- : list ...
[ "Function", "does", "a", "rudimentary", "check", "whether", "the", "cols", "splits", "and", "divs", "columns", "in", "the", "parameter", "files", "are", "formatted", "properly", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/misc/misc.py#L93-L147
40,247
inveniosoftware-attic/invenio-utils
invenio_utils/htmlwasher.py
EmailWasher.handle_starttag
def handle_starttag(self, tag, attrs): """Function called for new opening tags""" if tag.lower() in self.allowed_tag_whitelist: if tag.lower() == 'ol': # we need a list to store the last # number used in the previous ordered lists self.previou...
python
def handle_starttag(self, tag, attrs): """Function called for new opening tags""" if tag.lower() in self.allowed_tag_whitelist: if tag.lower() == 'ol': # we need a list to store the last # number used in the previous ordered lists self.previou...
[ "def", "handle_starttag", "(", "self", ",", "tag", ",", "attrs", ")", ":", "if", "tag", ".", "lower", "(", ")", "in", "self", ".", "allowed_tag_whitelist", ":", "if", "tag", ".", "lower", "(", ")", "==", "'ol'", ":", "# we need a list to store the last", ...
Function called for new opening tags
[ "Function", "called", "for", "new", "opening", "tags" ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/htmlwasher.py#L37-L72
40,248
inveniosoftware-attic/invenio-utils
invenio_utils/htmlwasher.py
EmailWasher.handle_entityref
def handle_entityref(self, name): """Process a general entity reference of the form "&name;". Transform to text whenever possible.""" char_code = html_entities.name2codepoint.get(name, None) if char_code is not None: try: self.result += unichr(char_code).encod...
python
def handle_entityref(self, name): """Process a general entity reference of the form "&name;". Transform to text whenever possible.""" char_code = html_entities.name2codepoint.get(name, None) if char_code is not None: try: self.result += unichr(char_code).encod...
[ "def", "handle_entityref", "(", "self", ",", "name", ")", ":", "char_code", "=", "html_entities", ".", "name2codepoint", ".", "get", "(", "name", ",", "None", ")", "if", "char_code", "is", "not", "None", ":", "try", ":", "self", ".", "result", "+=", "u...
Process a general entity reference of the form "&name;". Transform to text whenever possible.
[ "Process", "a", "general", "entity", "reference", "of", "the", "form", "&name", ";", ".", "Transform", "to", "text", "whenever", "possible", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/htmlwasher.py#L117-L125
40,249
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_lattice
def bethe_lattice(energy, hopping): """Bethe lattice in inf dim density of states""" energy = np.asarray(energy).clip(-2*hopping, 2*hopping) return np.sqrt(4*hopping**2 - energy**2) / (2*np.pi*hopping**2)
python
def bethe_lattice(energy, hopping): """Bethe lattice in inf dim density of states""" energy = np.asarray(energy).clip(-2*hopping, 2*hopping) return np.sqrt(4*hopping**2 - energy**2) / (2*np.pi*hopping**2)
[ "def", "bethe_lattice", "(", "energy", ",", "hopping", ")", ":", "energy", "=", "np", ".", "asarray", "(", "energy", ")", ".", "clip", "(", "-", "2", "*", "hopping", ",", "2", "*", "hopping", ")", "return", "np", ".", "sqrt", "(", "4", "*", "hopp...
Bethe lattice in inf dim density of states
[ "Bethe", "lattice", "in", "inf", "dim", "density", "of", "states" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L11-L14
40,250
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_fermi
def bethe_fermi(energy, quasipart, shift, hopping, beta): """product of the bethe lattice dos, fermi distribution""" return fermi_dist(quasipart * energy - shift, beta) \ * bethe_lattice(energy, hopping)
python
def bethe_fermi(energy, quasipart, shift, hopping, beta): """product of the bethe lattice dos, fermi distribution""" return fermi_dist(quasipart * energy - shift, beta) \ * bethe_lattice(energy, hopping)
[ "def", "bethe_fermi", "(", "energy", ",", "quasipart", ",", "shift", ",", "hopping", ",", "beta", ")", ":", "return", "fermi_dist", "(", "quasipart", "*", "energy", "-", "shift", ",", "beta", ")", "*", "bethe_lattice", "(", "energy", ",", "hopping", ")" ...
product of the bethe lattice dos, fermi distribution
[ "product", "of", "the", "bethe", "lattice", "dos", "fermi", "distribution" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L16-L19
40,251
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_fermi_ene
def bethe_fermi_ene(energy, quasipart, shift, hopping, beta): """product of the bethe lattice dos, fermi distribution an weighted by energy""" return energy * bethe_fermi(energy, quasipart, shift, hopping, beta)
python
def bethe_fermi_ene(energy, quasipart, shift, hopping, beta): """product of the bethe lattice dos, fermi distribution an weighted by energy""" return energy * bethe_fermi(energy, quasipart, shift, hopping, beta)
[ "def", "bethe_fermi_ene", "(", "energy", ",", "quasipart", ",", "shift", ",", "hopping", ",", "beta", ")", ":", "return", "energy", "*", "bethe_fermi", "(", "energy", ",", "quasipart", ",", "shift", ",", "hopping", ",", "beta", ")" ]
product of the bethe lattice dos, fermi distribution an weighted by energy
[ "product", "of", "the", "bethe", "lattice", "dos", "fermi", "distribution", "an", "weighted", "by", "energy" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L21-L24
40,252
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_filling_zeroT
def bethe_filling_zeroT(fermi_energy, hopping): """Returns the particle average count given a certan fermi energy, for the semicircular density of states of the bethe lattice""" fermi_energy = np.asarray(fermi_energy).clip(-2*hopping, 2*hopping) return 1/2. + fermi_energy/2 * bethe_lattice(fermi_ener...
python
def bethe_filling_zeroT(fermi_energy, hopping): """Returns the particle average count given a certan fermi energy, for the semicircular density of states of the bethe lattice""" fermi_energy = np.asarray(fermi_energy).clip(-2*hopping, 2*hopping) return 1/2. + fermi_energy/2 * bethe_lattice(fermi_ener...
[ "def", "bethe_filling_zeroT", "(", "fermi_energy", ",", "hopping", ")", ":", "fermi_energy", "=", "np", ".", "asarray", "(", "fermi_energy", ")", ".", "clip", "(", "-", "2", "*", "hopping", ",", "2", "*", "hopping", ")", "return", "1", "/", "2.", "+", ...
Returns the particle average count given a certan fermi energy, for the semicircular density of states of the bethe lattice
[ "Returns", "the", "particle", "average", "count", "given", "a", "certan", "fermi", "energy", "for", "the", "semicircular", "density", "of", "states", "of", "the", "bethe", "lattice" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L27-L32
40,253
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_findfill_zeroT
def bethe_findfill_zeroT(particles, orbital_e, hopping): """Return the fermi energy that correspond to the given particle quantity in a semicircular density of states of a bethe lattice in a multi orbital case that can be non-degenerate""" assert 0. <= particles <= len(orbital_e) zero = lamb...
python
def bethe_findfill_zeroT(particles, orbital_e, hopping): """Return the fermi energy that correspond to the given particle quantity in a semicircular density of states of a bethe lattice in a multi orbital case that can be non-degenerate""" assert 0. <= particles <= len(orbital_e) zero = lamb...
[ "def", "bethe_findfill_zeroT", "(", "particles", ",", "orbital_e", ",", "hopping", ")", ":", "assert", "0.", "<=", "particles", "<=", "len", "(", "orbital_e", ")", "zero", "=", "lambda", "e", ":", "np", ".", "sum", "(", "[", "bethe_filling_zeroT", "(", "...
Return the fermi energy that correspond to the given particle quantity in a semicircular density of states of a bethe lattice in a multi orbital case that can be non-degenerate
[ "Return", "the", "fermi", "energy", "that", "correspond", "to", "the", "given", "particle", "quantity", "in", "a", "semicircular", "density", "of", "states", "of", "a", "bethe", "lattice", "in", "a", "multi", "orbital", "case", "that", "can", "be", "non", ...
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L35-L44
40,254
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_find_crystalfield
def bethe_find_crystalfield(populations, hopping): """Return the orbital energies to have the system populates as desired by the given individual populations""" zero = lambda orb: [bethe_filling_zeroT(-em, tz) - pop \ for em, tz, pop in zip(orb, hopping, populations)] return...
python
def bethe_find_crystalfield(populations, hopping): """Return the orbital energies to have the system populates as desired by the given individual populations""" zero = lambda orb: [bethe_filling_zeroT(-em, tz) - pop \ for em, tz, pop in zip(orb, hopping, populations)] return...
[ "def", "bethe_find_crystalfield", "(", "populations", ",", "hopping", ")", ":", "zero", "=", "lambda", "orb", ":", "[", "bethe_filling_zeroT", "(", "-", "em", ",", "tz", ")", "-", "pop", "for", "em", ",", "tz", ",", "pop", "in", "zip", "(", "orb", ",...
Return the orbital energies to have the system populates as desired by the given individual populations
[ "Return", "the", "orbital", "energies", "to", "have", "the", "system", "populates", "as", "desired", "by", "the", "given", "individual", "populations" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L46-L53
40,255
wuher/devil
devil/perm/management.py
_get_var_from_string
def _get_var_from_string(item): """ Get resource variable. """ modname, varname = _split_mod_var_names(item) if modname: mod = __import__(modname, globals(), locals(), [varname], -1) return getattr(mod, varname) else: return globals()[varname]
python
def _get_var_from_string(item): """ Get resource variable. """ modname, varname = _split_mod_var_names(item) if modname: mod = __import__(modname, globals(), locals(), [varname], -1) return getattr(mod, varname) else: return globals()[varname]
[ "def", "_get_var_from_string", "(", "item", ")", ":", "modname", ",", "varname", "=", "_split_mod_var_names", "(", "item", ")", "if", "modname", ":", "mod", "=", "__import__", "(", "modname", ",", "globals", "(", ")", ",", "locals", "(", ")", ",", "[", ...
Get resource variable.
[ "Get", "resource", "variable", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L28-L35
40,256
wuher/devil
devil/perm/management.py
_handle_list
def _handle_list(reclist): """ Return list of resources that have access_controller defined. """ ret = [] for item in reclist: recs = _handle_resource_setting(item) ret += [resource for resource in recs if resource.access_controller] return ret
python
def _handle_list(reclist): """ Return list of resources that have access_controller defined. """ ret = [] for item in reclist: recs = _handle_resource_setting(item) ret += [resource for resource in recs if resource.access_controller] return ret
[ "def", "_handle_list", "(", "reclist", ")", ":", "ret", "=", "[", "]", "for", "item", "in", "reclist", ":", "recs", "=", "_handle_resource_setting", "(", "item", ")", "ret", "+=", "[", "resource", "for", "resource", "in", "recs", "if", "resource", ".", ...
Return list of resources that have access_controller defined.
[ "Return", "list", "of", "resources", "that", "have", "access_controller", "defined", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L76-L82
40,257
wuher/devil
devil/perm/management.py
_ensure_content_type
def _ensure_content_type(): """ Add the bulldog content type to the database if it's missing. """ from django.contrib.contenttypes.models import ContentType try: row = ContentType.objects.get(app_label=PERM_APP_NAME) except ContentType.DoesNotExist: row = ContentType(name=PERM_APP_NAME, ...
python
def _ensure_content_type(): """ Add the bulldog content type to the database if it's missing. """ from django.contrib.contenttypes.models import ContentType try: row = ContentType.objects.get(app_label=PERM_APP_NAME) except ContentType.DoesNotExist: row = ContentType(name=PERM_APP_NAME, ...
[ "def", "_ensure_content_type", "(", ")", ":", "from", "django", ".", "contrib", ".", "contenttypes", ".", "models", "import", "ContentType", "try", ":", "row", "=", "ContentType", ".", "objects", ".", "get", "(", "app_label", "=", "PERM_APP_NAME", ")", "exce...
Add the bulldog content type to the database if it's missing.
[ "Add", "the", "bulldog", "content", "type", "to", "the", "database", "if", "it", "s", "missing", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L96-L104
40,258
wuher/devil
devil/perm/management.py
_get_permission_description
def _get_permission_description(permission_name): """ Generate a descriptive string based on the permission name. For example: 'resource_Order_get' -> 'Can GET order' todo: add support for the resource name to have underscores """ parts = permission_name.split('_') parts.pop(0) method =...
python
def _get_permission_description(permission_name): """ Generate a descriptive string based on the permission name. For example: 'resource_Order_get' -> 'Can GET order' todo: add support for the resource name to have underscores """ parts = permission_name.split('_') parts.pop(0) method =...
[ "def", "_get_permission_description", "(", "permission_name", ")", ":", "parts", "=", "permission_name", ".", "split", "(", "'_'", ")", "parts", ".", "pop", "(", "0", ")", "method", "=", "parts", ".", "pop", "(", ")", "resource", "=", "(", "'_'", ".", ...
Generate a descriptive string based on the permission name. For example: 'resource_Order_get' -> 'Can GET order' todo: add support for the resource name to have underscores
[ "Generate", "a", "descriptive", "string", "based", "on", "the", "permission", "name", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L107-L119
40,259
wuher/devil
devil/perm/management.py
_populate_permissions
def _populate_permissions(resources, content_type_id): """ Add all missing permissions to the database. """ from django.contrib.auth.models import Permission # read the whole auth_permission table into memory db_perms = [perm.codename for perm in Permission.objects.all()] for resource in resources:...
python
def _populate_permissions(resources, content_type_id): """ Add all missing permissions to the database. """ from django.contrib.auth.models import Permission # read the whole auth_permission table into memory db_perms = [perm.codename for perm in Permission.objects.all()] for resource in resources:...
[ "def", "_populate_permissions", "(", "resources", ",", "content_type_id", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "models", "import", "Permission", "# read the whole auth_permission table into memory", "db_perms", "=", "[", "perm", ".", "codename...
Add all missing permissions to the database.
[ "Add", "all", "missing", "permissions", "to", "the", "database", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L133-L143
40,260
trevisanj/f311
f311/filetypes/filesqlitedb.py
FileSQLiteDB.init_default
def init_default(self): """Overriden to take default database and save locally The issue was that init_default() sets self.filename to None; however there can be no SQLite database without a corresponding file (not using *memory* here) Should not keep default file open either (as it is...
python
def init_default(self): """Overriden to take default database and save locally The issue was that init_default() sets self.filename to None; however there can be no SQLite database without a corresponding file (not using *memory* here) Should not keep default file open either (as it is...
[ "def", "init_default", "(", "self", ")", ":", "import", "f311", "if", "self", ".", "default_filename", "is", "None", ":", "raise", "RuntimeError", "(", "\"Class '{}' has no default filename\"", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ")", ...
Overriden to take default database and save locally The issue was that init_default() sets self.filename to None; however there can be no SQLite database without a corresponding file (not using *memory* here) Should not keep default file open either (as it is in the API directory and shouldn't...
[ "Overriden", "to", "take", "default", "database", "and", "save", "locally" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filesqlitedb.py#L54-L70
40,261
trevisanj/f311
f311/filetypes/filesqlitedb.py
FileSQLiteDB._do_save_as
def _do_save_as(self, filename): """Closes connection, copies DB file, and opens again pointing to new file **Note** if filename equals current filename, does nothing! """ if filename != self.filename: self._ensure_filename() self._close_if_open() shu...
python
def _do_save_as(self, filename): """Closes connection, copies DB file, and opens again pointing to new file **Note** if filename equals current filename, does nothing! """ if filename != self.filename: self._ensure_filename() self._close_if_open() shu...
[ "def", "_do_save_as", "(", "self", ",", "filename", ")", ":", "if", "filename", "!=", "self", ".", "filename", ":", "self", ".", "_ensure_filename", "(", ")", "self", ".", "_close_if_open", "(", ")", "shutil", ".", "copyfile", "(", "self", ".", "filename...
Closes connection, copies DB file, and opens again pointing to new file **Note** if filename equals current filename, does nothing!
[ "Closes", "connection", "copies", "DB", "file", "and", "opens", "again", "pointing", "to", "new", "file" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filesqlitedb.py#L77-L86
40,262
trevisanj/f311
f311/filetypes/filesqlitedb.py
FileSQLiteDB.ensure_schema
def ensure_schema(self): """Create file and schema if it does not exist yet.""" self._ensure_filename() if not os.path.isfile(self.filename): self.create_schema()
python
def ensure_schema(self): """Create file and schema if it does not exist yet.""" self._ensure_filename() if not os.path.isfile(self.filename): self.create_schema()
[ "def", "ensure_schema", "(", "self", ")", ":", "self", ".", "_ensure_filename", "(", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "self", ".", "filename", ")", ":", "self", ".", "create_schema", "(", ")" ]
Create file and schema if it does not exist yet.
[ "Create", "file", "and", "schema", "if", "it", "does", "not", "exist", "yet", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filesqlitedb.py#L103-L107
40,263
trevisanj/f311
f311/filetypes/filesqlitedb.py
FileSQLiteDB.get_table_info
def get_table_info(self, tablename): """Returns information about fields of a specific table Returns: OrderedDict(("fieldname", MyDBRow), ...)) **Note** Fields "caption" and "tooltip" are added to rows using information in moldb.gui_info """ conn = self.__get_conn() r...
python
def get_table_info(self, tablename): """Returns information about fields of a specific table Returns: OrderedDict(("fieldname", MyDBRow), ...)) **Note** Fields "caption" and "tooltip" are added to rows using information in moldb.gui_info """ conn = self.__get_conn() r...
[ "def", "get_table_info", "(", "self", ",", "tablename", ")", ":", "conn", "=", "self", ".", "__get_conn", "(", ")", "ret", "=", "a99", ".", "get_table_info", "(", "conn", ",", "tablename", ")", "if", "len", "(", "ret", ")", "==", "0", ":", "raise", ...
Returns information about fields of a specific table Returns: OrderedDict(("fieldname", MyDBRow), ...)) **Note** Fields "caption" and "tooltip" are added to rows using information in moldb.gui_info
[ "Returns", "information", "about", "fields", "of", "a", "specific", "table" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filesqlitedb.py#L143-L167
40,264
trevisanj/f311
f311/filetypes/filesqlitedb.py
FileSQLiteDB.__get_conn
def __get_conn(self, flag_force_new=False, filename=None): """Returns connection to database. Tries to return existing connection, unless flag_force_new Args: flag_force_new: filename: Returns: sqlite3.Connection object **Note** this is a private method because...
python
def __get_conn(self, flag_force_new=False, filename=None): """Returns connection to database. Tries to return existing connection, unless flag_force_new Args: flag_force_new: filename: Returns: sqlite3.Connection object **Note** this is a private method because...
[ "def", "__get_conn", "(", "self", ",", "flag_force_new", "=", "False", ",", "filename", "=", "None", ")", ":", "flag_open_new", "=", "flag_force_new", "or", "not", "self", ".", "_conn_is_open", "(", ")", "if", "flag_open_new", ":", "if", "filename", "is", ...
Returns connection to database. Tries to return existing connection, unless flag_force_new Args: flag_force_new: filename: Returns: sqlite3.Connection object **Note** this is a private method because you can get a connection to any file, so it has to b...
[ "Returns", "connection", "to", "database", ".", "Tries", "to", "return", "existing", "connection", "unless", "flag_force_new" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filesqlitedb.py#L179-L201
40,265
inveniosoftware-attic/invenio-utils
invenio_utils/datastructures.py
flatten_multidict
def flatten_multidict(multidict): """Return flattened dictionary from ``MultiDict``.""" return dict([(key, value if len(value) > 1 else value[0]) for (key, value) in multidict.iterlists()])
python
def flatten_multidict(multidict): """Return flattened dictionary from ``MultiDict``.""" return dict([(key, value if len(value) > 1 else value[0]) for (key, value) in multidict.iterlists()])
[ "def", "flatten_multidict", "(", "multidict", ")", ":", "return", "dict", "(", "[", "(", "key", ",", "value", "if", "len", "(", "value", ")", ">", "1", "else", "value", "[", "0", "]", ")", "for", "(", "key", ",", "value", ")", "in", "multidict", ...
Return flattened dictionary from ``MultiDict``.
[ "Return", "flattened", "dictionary", "from", "MultiDict", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/datastructures.py#L418-L421
40,266
inveniosoftware-attic/invenio-utils
invenio_utils/datastructures.py
SmartDict.__setitem
def __setitem(self, chunk, key, keys, value, extend=False): """Helper function to fill up the dictionary.""" def setitem(chunk): if keys: return self.__setitem(chunk, keys[0], keys[1:], value, extend) else: return value if key in ['.', ']'...
python
def __setitem(self, chunk, key, keys, value, extend=False): """Helper function to fill up the dictionary.""" def setitem(chunk): if keys: return self.__setitem(chunk, keys[0], keys[1:], value, extend) else: return value if key in ['.', ']'...
[ "def", "__setitem", "(", "self", ",", "chunk", ",", "key", ",", "keys", ",", "value", ",", "extend", "=", "False", ")", ":", "def", "setitem", "(", "chunk", ")", ":", "if", "keys", ":", "return", "self", ".", "__setitem", "(", "chunk", ",", "keys",...
Helper function to fill up the dictionary.
[ "Helper", "function", "to", "fill", "up", "the", "dictionary", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/datastructures.py#L323-L373
40,267
inveniosoftware-attic/invenio-utils
invenio_utils/datastructures.py
SmartDict.set
def set(self, key, value, extend=False, **kwargs): """Extended standard set function.""" self.__setitem__(key, value, extend, **kwargs)
python
def set(self, key, value, extend=False, **kwargs): """Extended standard set function.""" self.__setitem__(key, value, extend, **kwargs)
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "extend", "=", "False", ",", "*", "*", "kwargs", ")", ":", "self", ".", "__setitem__", "(", "key", ",", "value", ",", "extend", ",", "*", "*", "kwargs", ")" ]
Extended standard set function.
[ "Extended", "standard", "set", "function", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/datastructures.py#L382-L384
40,268
volfpeter/graphscraper
src/graphscraper/spotifyartist.py
SpotifyArtistGraph.create_default_database
def create_default_database(reset: bool = False) -> GraphDatabaseInterface: """ Creates and returns a default SQLAlchemy database interface to use. Arguments: reset (bool): Whether to reset the database if it happens to exist already. """ import sqlalchemy fr...
python
def create_default_database(reset: bool = False) -> GraphDatabaseInterface: """ Creates and returns a default SQLAlchemy database interface to use. Arguments: reset (bool): Whether to reset the database if it happens to exist already. """ import sqlalchemy fr...
[ "def", "create_default_database", "(", "reset", ":", "bool", "=", "False", ")", "->", "GraphDatabaseInterface", ":", "import", "sqlalchemy", "from", "sqlalchemy", ".", "ext", ".", "declarative", "import", "declarative_base", "from", "sqlalchemy", ".", "orm", "impo...
Creates and returns a default SQLAlchemy database interface to use. Arguments: reset (bool): Whether to reset the database if it happens to exist already.
[ "Creates", "and", "returns", "a", "default", "SQLAlchemy", "database", "interface", "to", "use", "." ]
11d407509956a282ee25190ed6491a162fc0fe7f
https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/spotifyartist.py#L95-L119
40,269
volfpeter/graphscraper
src/graphscraper/spotifyartist.py
SpotifyArtistNodeList._create_node
def _create_node(self, index: int, name: str, external_id: Optional[str] = None) -> SpotifyArtistNode: """ Returns a new `SpotifyArtistNode` instance with the given index and name. Arguments: index (int): The index of the node to create. name (str): The name of the node ...
python
def _create_node(self, index: int, name: str, external_id: Optional[str] = None) -> SpotifyArtistNode: """ Returns a new `SpotifyArtistNode` instance with the given index and name. Arguments: index (int): The index of the node to create. name (str): The name of the node ...
[ "def", "_create_node", "(", "self", ",", "index", ":", "int", ",", "name", ":", "str", ",", "external_id", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "SpotifyArtistNode", ":", "if", "external_id", "is", "None", ":", "graph", ":", "Spotif...
Returns a new `SpotifyArtistNode` instance with the given index and name. Arguments: index (int): The index of the node to create. name (str): The name of the node to create. external_id (Optional[str]): The external ID of the node.
[ "Returns", "a", "new", "SpotifyArtistNode", "instance", "with", "the", "given", "index", "and", "name", "." ]
11d407509956a282ee25190ed6491a162fc0fe7f
https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/spotifyartist.py#L222-L239
40,270
volfpeter/graphscraper
src/graphscraper/spotifyartist.py
SpotifyClientTokenWrapper.access_token
def access_token(self) -> str: """ The access token stored within the requested token. """ if self._token_expires_at < time.time() + self._REFRESH_THRESHOLD: self.request_token() return self._token["access_token"]
python
def access_token(self) -> str: """ The access token stored within the requested token. """ if self._token_expires_at < time.time() + self._REFRESH_THRESHOLD: self.request_token() return self._token["access_token"]
[ "def", "access_token", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_token_expires_at", "<", "time", ".", "time", "(", ")", "+", "self", ".", "_REFRESH_THRESHOLD", ":", "self", ".", "request_token", "(", ")", "return", "self", ".", "_token", ...
The access token stored within the requested token.
[ "The", "access", "token", "stored", "within", "the", "requested", "token", "." ]
11d407509956a282ee25190ed6491a162fc0fe7f
https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/spotifyartist.py#L296-L303
40,271
volfpeter/graphscraper
src/graphscraper/spotifyartist.py
SpotifyClientTokenWrapper.request_token
def request_token(self) -> None: """ Requests a new Client Credentials Flow authentication token from the Spotify API and stores it in the `token` property of the object. Raises: requests.HTTPError: If an HTTP error occurred during the request. """ response: ...
python
def request_token(self) -> None: """ Requests a new Client Credentials Flow authentication token from the Spotify API and stores it in the `token` property of the object. Raises: requests.HTTPError: If an HTTP error occurred during the request. """ response: ...
[ "def", "request_token", "(", "self", ")", "->", "None", ":", "response", ":", "requests", ".", "Response", "=", "requests", ".", "post", "(", "self", ".", "_TOKEN_URL", ",", "auth", "=", "HTTPBasicAuth", "(", "self", ".", "_client_id", ",", "self", ".", ...
Requests a new Client Credentials Flow authentication token from the Spotify API and stores it in the `token` property of the object. Raises: requests.HTTPError: If an HTTP error occurred during the request.
[ "Requests", "a", "new", "Client", "Credentials", "Flow", "authentication", "token", "from", "the", "Spotify", "API", "and", "stores", "it", "in", "the", "token", "property", "of", "the", "object", "." ]
11d407509956a282ee25190ed6491a162fc0fe7f
https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/spotifyartist.py#L305-L321
40,272
volfpeter/graphscraper
src/graphscraper/spotifyartist.py
SpotifyClient.search_artists_by_name
def search_artists_by_name(self, artist_name: str, limit: int = 5) -> List[NameExternalIDPair]: """ Returns zero or more artist name - external ID pairs that match the specified artist name. Arguments: artist_name (str): The artist name to search in the Spotify API. limi...
python
def search_artists_by_name(self, artist_name: str, limit: int = 5) -> List[NameExternalIDPair]: """ Returns zero or more artist name - external ID pairs that match the specified artist name. Arguments: artist_name (str): The artist name to search in the Spotify API. limi...
[ "def", "search_artists_by_name", "(", "self", ",", "artist_name", ":", "str", ",", "limit", ":", "int", "=", "5", ")", "->", "List", "[", "NameExternalIDPair", "]", ":", "response", ":", "requests", ".", "Response", "=", "requests", ".", "get", "(", "sel...
Returns zero or more artist name - external ID pairs that match the specified artist name. Arguments: artist_name (str): The artist name to search in the Spotify API. limit (int): The maximum number of results to return. Returns: Zero or more artist name - external ...
[ "Returns", "zero", "or", "more", "artist", "name", "-", "external", "ID", "pairs", "that", "match", "the", "specified", "artist", "name", "." ]
11d407509956a282ee25190ed6491a162fc0fe7f
https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/spotifyartist.py#L347-L382
40,273
hackedd/gw2api
gw2api/misc.py
colors
def colors(lang="en"): """This resource returns all dyes in the game, including localized names and their color component information. :param lang: The language to query the names for. The response is a dictionary where color ids are mapped to an dictionary containing the following properties: ...
python
def colors(lang="en"): """This resource returns all dyes in the game, including localized names and their color component information. :param lang: The language to query the names for. The response is a dictionary where color ids are mapped to an dictionary containing the following properties: ...
[ "def", "colors", "(", "lang", "=", "\"en\"", ")", ":", "cache_name", "=", "\"colors.%s.json\"", "%", "lang", "data", "=", "get_cached", "(", "\"colors.json\"", ",", "cache_name", ",", "params", "=", "dict", "(", "lang", "=", "lang", ")", ")", "return", "...
This resource returns all dyes in the game, including localized names and their color component information. :param lang: The language to query the names for. The response is a dictionary where color ids are mapped to an dictionary containing the following properties: name (string): The n...
[ "This", "resource", "returns", "all", "dyes", "in", "the", "game", "including", "localized", "names", "and", "their", "color", "component", "information", "." ]
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/misc.py#L15-L62
40,274
hackedd/gw2api
gw2api/events.py
event_names
def event_names(lang="en"): """This resource returns an unordered list of the localized event names for the specified language. :param lang: The language to query the names for. :return: A dictionary where the key is the event id and the value is the name of the event in the specified lang...
python
def event_names(lang="en"): """This resource returns an unordered list of the localized event names for the specified language. :param lang: The language to query the names for. :return: A dictionary where the key is the event id and the value is the name of the event in the specified lang...
[ "def", "event_names", "(", "lang", "=", "\"en\"", ")", ":", "cache_name", "=", "\"event_names.%s.json\"", "%", "lang", "data", "=", "get_cached", "(", "\"event_names.json\"", ",", "cache_name", ",", "params", "=", "dict", "(", "lang", "=", "lang", ")", ")", ...
This resource returns an unordered list of the localized event names for the specified language. :param lang: The language to query the names for. :return: A dictionary where the key is the event id and the value is the name of the event in the specified language.
[ "This", "resource", "returns", "an", "unordered", "list", "of", "the", "localized", "event", "names", "for", "the", "specified", "language", "." ]
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/events.py#L7-L18
40,275
hackedd/gw2api
gw2api/events.py
event_details
def event_details(event_id=None, lang="en"): """This resource returns static details about available events. :param event_id: Only list this event. :param lang: Show localized texts in the specified language. The response is a dictionary where the key is the event id, and the value is a dictionary...
python
def event_details(event_id=None, lang="en"): """This resource returns static details about available events. :param event_id: Only list this event. :param lang: Show localized texts in the specified language. The response is a dictionary where the key is the event id, and the value is a dictionary...
[ "def", "event_details", "(", "event_id", "=", "None", ",", "lang", "=", "\"en\"", ")", ":", "if", "event_id", ":", "cache_name", "=", "\"event_details.%s.%s.json\"", "%", "(", "event_id", ",", "lang", ")", "params", "=", "{", "\"event_id\"", ":", "event_id",...
This resource returns static details about available events. :param event_id: Only list this event. :param lang: Show localized texts in the specified language. The response is a dictionary where the key is the event id, and the value is a dictionary containing the following properties: name (str...
[ "This", "resource", "returns", "static", "details", "about", "available", "events", "." ]
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/events.py#L21-L79
40,276
nuSTORM/gnomon
gnomon/MagneticField.py
WandsToroidField.PhenomModel
def PhenomModel(self, r): """Fit to field map A phenomenological fit by Ryan Bayes (Glasgow) to a field map generated by Bob Wands (FNAL). It assumes a 1 cm plate. This is dated January 30th, 2012. Not defined for r <= 0""" if r <= 0: raise ValueError fiel...
python
def PhenomModel(self, r): """Fit to field map A phenomenological fit by Ryan Bayes (Glasgow) to a field map generated by Bob Wands (FNAL). It assumes a 1 cm plate. This is dated January 30th, 2012. Not defined for r <= 0""" if r <= 0: raise ValueError fiel...
[ "def", "PhenomModel", "(", "self", ",", "r", ")", ":", "if", "r", "<=", "0", ":", "raise", "ValueError", "field", "=", "self", ".", "B0", "+", "self", ".", "B1", "*", "G4", ".", "m", "/", "r", "+", "self", ".", "B2", "*", "math", ".", "exp", ...
Fit to field map A phenomenological fit by Ryan Bayes (Glasgow) to a field map generated by Bob Wands (FNAL). It assumes a 1 cm plate. This is dated January 30th, 2012. Not defined for r <= 0
[ "Fit", "to", "field", "map" ]
7616486ecd6e26b76f677c380e62db1c0ade558a
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/MagneticField.py#L37-L46
40,277
trevisanj/f311
f311/explorer/gui/a_XExplorer.py
XExplorer.set_dir
def set_dir(self, dir_): """Sets directory, auto-loads, updates all GUI contents.""" self.__lock_set_dir(dir_) self.__lock_auto_load() self.__lock_update_table() self.__update_info() self.__update_window_title()
python
def set_dir(self, dir_): """Sets directory, auto-loads, updates all GUI contents.""" self.__lock_set_dir(dir_) self.__lock_auto_load() self.__lock_update_table() self.__update_info() self.__update_window_title()
[ "def", "set_dir", "(", "self", ",", "dir_", ")", ":", "self", ".", "__lock_set_dir", "(", "dir_", ")", "self", ".", "__lock_auto_load", "(", ")", "self", ".", "__lock_update_table", "(", ")", "self", ".", "__update_info", "(", ")", "self", ".", "__update...
Sets directory, auto-loads, updates all GUI contents.
[ "Sets", "directory", "auto", "-", "loads", "updates", "all", "GUI", "contents", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XExplorer.py#L320-L327
40,278
trevisanj/f311
f311/explorer/gui/a_XExplorer.py
XExplorer.__update_info
def __update_info(self): """Updates "visualization options" and "file info" areas.""" from f311 import explorer as ex import f311 t = self.tableWidget z = self.listWidgetVis z.clear() classes = self.__vis_classes = [] propss = self.__lock_get_current_pro...
python
def __update_info(self): """Updates "visualization options" and "file info" areas.""" from f311 import explorer as ex import f311 t = self.tableWidget z = self.listWidgetVis z.clear() classes = self.__vis_classes = [] propss = self.__lock_get_current_pro...
[ "def", "__update_info", "(", "self", ")", ":", "from", "f311", "import", "explorer", "as", "ex", "import", "f311", "t", "=", "self", ".", "tableWidget", "z", "=", "self", ".", "listWidgetVis", "z", ".", "clear", "(", ")", "classes", "=", "self", ".", ...
Updates "visualization options" and "file info" areas.
[ "Updates", "visualization", "options", "and", "file", "info", "areas", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XExplorer.py#L454-L524
40,279
wuher/devil
devil/fields/fields.py
DevilField.validate
def validate(self, value): """ This was overridden to have our own ``empty_values``. """ if value in self.empty_values and self.required: raise ValidationError(self.error_messages['required'])
python
def validate(self, value): """ This was overridden to have our own ``empty_values``. """ if value in self.empty_values and self.required: raise ValidationError(self.error_messages['required'])
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "value", "in", "self", ".", "empty_values", "and", "self", ".", "required", ":", "raise", "ValidationError", "(", "self", ".", "error_messages", "[", "'required'", "]", ")" ]
This was overridden to have our own ``empty_values``.
[ "This", "was", "overridden", "to", "have", "our", "own", "empty_values", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/fields/fields.py#L72-L75
40,280
wuher/devil
devil/fields/fields.py
NestedField.clean
def clean(self, value): """ Clean the data and validate the nested spec. Implementation is the same as for other fields but in addition, this will propagate the validation to the nested spec. """ obj = self.factory.create(value) # todo: what if the field defines proper...
python
def clean(self, value): """ Clean the data and validate the nested spec. Implementation is the same as for other fields but in addition, this will propagate the validation to the nested spec. """ obj = self.factory.create(value) # todo: what if the field defines proper...
[ "def", "clean", "(", "self", ",", "value", ")", ":", "obj", "=", "self", ".", "factory", ".", "create", "(", "value", ")", "# todo: what if the field defines properties that have any of", "# these names:", "if", "obj", ":", "del", "obj", ".", "fields", "del", ...
Clean the data and validate the nested spec. Implementation is the same as for other fields but in addition, this will propagate the validation to the nested spec.
[ "Clean", "the", "data", "and", "validate", "the", "nested", "spec", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/fields/fields.py#L102-L128
40,281
wuher/devil
devil/fields/fields.py
NestedField.serialize
def serialize(self, value, entity, request): """ Propagate to nested fields. :returns: data dictionary or ``None`` if no fields are present. """ self._validate_existence(value) self._run_validators(value) if not value: return value return self.fact...
python
def serialize(self, value, entity, request): """ Propagate to nested fields. :returns: data dictionary or ``None`` if no fields are present. """ self._validate_existence(value) self._run_validators(value) if not value: return value return self.fact...
[ "def", "serialize", "(", "self", ",", "value", ",", "entity", ",", "request", ")", ":", "self", ".", "_validate_existence", "(", "value", ")", "self", ".", "_run_validators", "(", "value", ")", "if", "not", "value", ":", "return", "value", "return", "sel...
Propagate to nested fields. :returns: data dictionary or ``None`` if no fields are present.
[ "Propagate", "to", "nested", "fields", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/fields/fields.py#L130-L142
40,282
wuher/devil
devil/fields/fields.py
NestedField._run_validators
def _run_validators(self, value): """ Execute all associated validators. """ errors = [] for v in self.validators: try: v(value) except ValidationError, e: errors.extend(e.messages) if errors: raise ValidationError(error...
python
def _run_validators(self, value): """ Execute all associated validators. """ errors = [] for v in self.validators: try: v(value) except ValidationError, e: errors.extend(e.messages) if errors: raise ValidationError(error...
[ "def", "_run_validators", "(", "self", ",", "value", ")", ":", "errors", "=", "[", "]", "for", "v", "in", "self", ".", "validators", ":", "try", ":", "v", "(", "value", ")", "except", "ValidationError", ",", "e", ":", "errors", ".", "extend", "(", ...
Execute all associated validators.
[ "Execute", "all", "associated", "validators", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/fields/fields.py#L155-L164
40,283
rlepore/django-sticky-messages
stickymessages/models.py
MessageManager.get_all_active
def get_all_active(self): """ Get all of the active messages ordered by the active_datetime. """ now = timezone.now() return self.select_related().filter(active_datetime__lte=now, inactive_datetime__gte=now).order_by('active_datetime'...
python
def get_all_active(self): """ Get all of the active messages ordered by the active_datetime. """ now = timezone.now() return self.select_related().filter(active_datetime__lte=now, inactive_datetime__gte=now).order_by('active_datetime'...
[ "def", "get_all_active", "(", "self", ")", ":", "now", "=", "timezone", ".", "now", "(", ")", "return", "self", ".", "select_related", "(", ")", ".", "filter", "(", "active_datetime__lte", "=", "now", ",", "inactive_datetime__gte", "=", "now", ")", ".", ...
Get all of the active messages ordered by the active_datetime.
[ "Get", "all", "of", "the", "active", "messages", "ordered", "by", "the", "active_datetime", "." ]
6e8c519b982c2ff6c18bc5002160ac7108320652
https://github.com/rlepore/django-sticky-messages/blob/6e8c519b982c2ff6c18bc5002160ac7108320652/stickymessages/models.py#L8-L14
40,284
NickMonzillo/SmartCloud
SmartCloud/__init__.py
Cloud.render_word
def render_word(self,word,size,color): '''Creates a surface that contains a word.''' pygame.font.init() font = pygame.font.Font(None,size) self.rendered_word = font.render(word,0,color) self.word_size = font.size(word)
python
def render_word(self,word,size,color): '''Creates a surface that contains a word.''' pygame.font.init() font = pygame.font.Font(None,size) self.rendered_word = font.render(word,0,color) self.word_size = font.size(word)
[ "def", "render_word", "(", "self", ",", "word", ",", "size", ",", "color", ")", ":", "pygame", ".", "font", ".", "init", "(", ")", "font", "=", "pygame", ".", "font", ".", "Font", "(", "None", ",", "size", ")", "self", ".", "rendered_word", "=", ...
Creates a surface that contains a word.
[ "Creates", "a", "surface", "that", "contains", "a", "word", "." ]
481d1ef428427b452a8a787999c1d4a8868a3824
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L16-L21
40,285
NickMonzillo/SmartCloud
SmartCloud/__init__.py
Cloud.plot_word
def plot_word(self,position): '''Blits a rendered word on to the main display surface''' posrectangle = pygame.Rect(position,self.word_size) self.used_pos.append(posrectangle) self.cloud.blit(self.rendered_word,position)
python
def plot_word(self,position): '''Blits a rendered word on to the main display surface''' posrectangle = pygame.Rect(position,self.word_size) self.used_pos.append(posrectangle) self.cloud.blit(self.rendered_word,position)
[ "def", "plot_word", "(", "self", ",", "position", ")", ":", "posrectangle", "=", "pygame", ".", "Rect", "(", "position", ",", "self", ".", "word_size", ")", "self", ".", "used_pos", ".", "append", "(", "posrectangle", ")", "self", ".", "cloud", ".", "b...
Blits a rendered word on to the main display surface
[ "Blits", "a", "rendered", "word", "on", "to", "the", "main", "display", "surface" ]
481d1ef428427b452a8a787999c1d4a8868a3824
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L23-L27
40,286
NickMonzillo/SmartCloud
SmartCloud/__init__.py
Cloud.collides
def collides(self,position,size): '''Returns True if the word collides with another plotted word.''' word_rect = pygame.Rect(position,self.word_size) if word_rect.collidelistall(self.used_pos) == []: return False else: return True
python
def collides(self,position,size): '''Returns True if the word collides with another plotted word.''' word_rect = pygame.Rect(position,self.word_size) if word_rect.collidelistall(self.used_pos) == []: return False else: return True
[ "def", "collides", "(", "self", ",", "position", ",", "size", ")", ":", "word_rect", "=", "pygame", ".", "Rect", "(", "position", ",", "self", ".", "word_size", ")", "if", "word_rect", ".", "collidelistall", "(", "self", ".", "used_pos", ")", "==", "["...
Returns True if the word collides with another plotted word.
[ "Returns", "True", "if", "the", "word", "collides", "with", "another", "plotted", "word", "." ]
481d1ef428427b452a8a787999c1d4a8868a3824
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L29-L35
40,287
NickMonzillo/SmartCloud
SmartCloud/__init__.py
Cloud.expand
def expand(self,delta_width,delta_height): '''Makes the cloud surface bigger. Maintains all word positions.''' temp_surface = pygame.Surface((self.width + delta_width,self.height + delta_height)) (self.width,self.height) = (self.width + delta_width, self.height + delta_height) temp_surfa...
python
def expand(self,delta_width,delta_height): '''Makes the cloud surface bigger. Maintains all word positions.''' temp_surface = pygame.Surface((self.width + delta_width,self.height + delta_height)) (self.width,self.height) = (self.width + delta_width, self.height + delta_height) temp_surfa...
[ "def", "expand", "(", "self", ",", "delta_width", ",", "delta_height", ")", ":", "temp_surface", "=", "pygame", ".", "Surface", "(", "(", "self", ".", "width", "+", "delta_width", ",", "self", ".", "height", "+", "delta_height", ")", ")", "(", "self", ...
Makes the cloud surface bigger. Maintains all word positions.
[ "Makes", "the", "cloud", "surface", "bigger", ".", "Maintains", "all", "word", "positions", "." ]
481d1ef428427b452a8a787999c1d4a8868a3824
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L37-L42
40,288
NickMonzillo/SmartCloud
SmartCloud/__init__.py
Cloud.smart_cloud
def smart_cloud(self,input,max_text_size=72,min_text_size=12,exclude_words = True): '''Creates a word cloud using the input. Input can be a file, directory, or text. Set exclude_words to true if you want to eliminate words that only occur once.''' self.exclude_words = exclude_words...
python
def smart_cloud(self,input,max_text_size=72,min_text_size=12,exclude_words = True): '''Creates a word cloud using the input. Input can be a file, directory, or text. Set exclude_words to true if you want to eliminate words that only occur once.''' self.exclude_words = exclude_words...
[ "def", "smart_cloud", "(", "self", ",", "input", ",", "max_text_size", "=", "72", ",", "min_text_size", "=", "12", ",", "exclude_words", "=", "True", ")", ":", "self", ".", "exclude_words", "=", "exclude_words", "if", "isdir", "(", "input", ")", ":", "se...
Creates a word cloud using the input. Input can be a file, directory, or text. Set exclude_words to true if you want to eliminate words that only occur once.
[ "Creates", "a", "word", "cloud", "using", "the", "input", ".", "Input", "can", "be", "a", "file", "directory", "or", "text", ".", "Set", "exclude_words", "to", "true", "if", "you", "want", "to", "eliminate", "words", "that", "only", "occur", "once", "." ...
481d1ef428427b452a8a787999c1d4a8868a3824
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L44-L58
40,289
NickMonzillo/SmartCloud
SmartCloud/__init__.py
Cloud.directory_cloud
def directory_cloud(self,directory,max_text_size=72,min_text_size=12,expand_width=50,expand_height=50,max_count=100000): '''Creates a word cloud using files from a directory. The color of the words correspond to the amount of documents the word occurs in.''' worddict = assign_fonts(tuplecount(re...
python
def directory_cloud(self,directory,max_text_size=72,min_text_size=12,expand_width=50,expand_height=50,max_count=100000): '''Creates a word cloud using files from a directory. The color of the words correspond to the amount of documents the word occurs in.''' worddict = assign_fonts(tuplecount(re...
[ "def", "directory_cloud", "(", "self", ",", "directory", ",", "max_text_size", "=", "72", ",", "min_text_size", "=", "12", ",", "expand_width", "=", "50", ",", "expand_height", "=", "50", ",", "max_count", "=", "100000", ")", ":", "worddict", "=", "assign_...
Creates a word cloud using files from a directory. The color of the words correspond to the amount of documents the word occurs in.
[ "Creates", "a", "word", "cloud", "using", "files", "from", "a", "directory", ".", "The", "color", "of", "the", "words", "correspond", "to", "the", "amount", "of", "documents", "the", "word", "occurs", "in", "." ]
481d1ef428427b452a8a787999c1d4a8868a3824
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L60-L85
40,290
NickMonzillo/SmartCloud
SmartCloud/__init__.py
Cloud.text_cloud
def text_cloud(self,text,max_text_size=72,min_text_size=12,expand_width=50,expand_height=50,max_count=100000): '''Creates a word cloud using plain text.''' worddict = assign_fonts(tuplecount(text),max_text_size,min_text_size,self.exclude_words) sorted_worddict = list(reversed(sorted(worddict.key...
python
def text_cloud(self,text,max_text_size=72,min_text_size=12,expand_width=50,expand_height=50,max_count=100000): '''Creates a word cloud using plain text.''' worddict = assign_fonts(tuplecount(text),max_text_size,min_text_size,self.exclude_words) sorted_worddict = list(reversed(sorted(worddict.key...
[ "def", "text_cloud", "(", "self", ",", "text", ",", "max_text_size", "=", "72", ",", "min_text_size", "=", "12", ",", "expand_width", "=", "50", ",", "expand_height", "=", "50", ",", "max_count", "=", "100000", ")", ":", "worddict", "=", "assign_fonts", ...
Creates a word cloud using plain text.
[ "Creates", "a", "word", "cloud", "using", "plain", "text", "." ]
481d1ef428427b452a8a787999c1d4a8868a3824
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L87-L107
40,291
NickMonzillo/SmartCloud
SmartCloud/__init__.py
Cloud.display
def display(self): '''Displays the word cloud to the screen.''' pygame.init() self.display = pygame.display.set_mode((self.width,self.height)) self.display.blit(self.cloud,(0,0)) pygame.display.update() while True: for event in pygame.event.get(): ...
python
def display(self): '''Displays the word cloud to the screen.''' pygame.init() self.display = pygame.display.set_mode((self.width,self.height)) self.display.blit(self.cloud,(0,0)) pygame.display.update() while True: for event in pygame.event.get(): ...
[ "def", "display", "(", "self", ")", ":", "pygame", ".", "init", "(", ")", "self", ".", "display", "=", "pygame", ".", "display", ".", "set_mode", "(", "(", "self", ".", "width", ",", "self", ".", "height", ")", ")", "self", ".", "display", ".", "...
Displays the word cloud to the screen.
[ "Displays", "the", "word", "cloud", "to", "the", "screen", "." ]
481d1ef428427b452a8a787999c1d4a8868a3824
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L109-L119
40,292
Titan-C/slaveparticles
slaveparticles/quantum/operators.py
fermi_dist
def fermi_dist(energy, beta): """ Fermi Dirac distribution""" exponent = np.asarray(beta*energy).clip(-600, 600) return 1./(np.exp(exponent) + 1)
python
def fermi_dist(energy, beta): """ Fermi Dirac distribution""" exponent = np.asarray(beta*energy).clip(-600, 600) return 1./(np.exp(exponent) + 1)
[ "def", "fermi_dist", "(", "energy", ",", "beta", ")", ":", "exponent", "=", "np", ".", "asarray", "(", "beta", "*", "energy", ")", ".", "clip", "(", "-", "600", ",", "600", ")", "return", "1.", "/", "(", "np", ".", "exp", "(", "exponent", ")", ...
Fermi Dirac distribution
[ "Fermi", "Dirac", "distribution" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/operators.py#L12-L15
40,293
Titan-C/slaveparticles
slaveparticles/quantum/operators.py
diagonalize
def diagonalize(operator): """diagonalizes single site Spin Hamiltonian""" eig_values, eig_vecs = LA.eigh(operator) emin = np.amin(eig_values) eig_values -= emin return eig_values, eig_vecs
python
def diagonalize(operator): """diagonalizes single site Spin Hamiltonian""" eig_values, eig_vecs = LA.eigh(operator) emin = np.amin(eig_values) eig_values -= emin return eig_values, eig_vecs
[ "def", "diagonalize", "(", "operator", ")", ":", "eig_values", ",", "eig_vecs", "=", "LA", ".", "eigh", "(", "operator", ")", "emin", "=", "np", ".", "amin", "(", "eig_values", ")", "eig_values", "-=", "emin", "return", "eig_values", ",", "eig_vecs" ]
diagonalizes single site Spin Hamiltonian
[ "diagonalizes", "single", "site", "Spin", "Hamiltonian" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/operators.py#L35-L41
40,294
Titan-C/slaveparticles
slaveparticles/quantum/operators.py
gf_lehmann
def gf_lehmann(eig_e, eig_states, d_dag, beta, omega, d=None): """Outputs the lehmann representation of the greens function omega has to be given, as matsubara or real frequencies""" ew = np.exp(-beta*eig_e) zet = ew.sum() G = np.zeros_like(omega) basis_create = np.dot(eig_states.T, d_dag.do...
python
def gf_lehmann(eig_e, eig_states, d_dag, beta, omega, d=None): """Outputs the lehmann representation of the greens function omega has to be given, as matsubara or real frequencies""" ew = np.exp(-beta*eig_e) zet = ew.sum() G = np.zeros_like(omega) basis_create = np.dot(eig_states.T, d_dag.do...
[ "def", "gf_lehmann", "(", "eig_e", ",", "eig_states", ",", "d_dag", ",", "beta", ",", "omega", ",", "d", "=", "None", ")", ":", "ew", "=", "np", ".", "exp", "(", "-", "beta", "*", "eig_e", ")", "zet", "=", "ew", ".", "sum", "(", ")", "G", "="...
Outputs the lehmann representation of the greens function omega has to be given, as matsubara or real frequencies
[ "Outputs", "the", "lehmann", "representation", "of", "the", "greens", "function", "omega", "has", "to", "be", "given", "as", "matsubara", "or", "real", "frequencies" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/operators.py#L44-L63
40,295
Titan-C/slaveparticles
slaveparticles/quantum/operators.py
expected_value
def expected_value(operator, eig_values, eig_states, beta): """Calculates the average value of an observable it requires that states and operators have the same base""" aux = np.einsum('i,ji,ji', np.exp(-beta*eig_values), eig_states, operator.dot(eig_states)) return aux / partiti...
python
def expected_value(operator, eig_values, eig_states, beta): """Calculates the average value of an observable it requires that states and operators have the same base""" aux = np.einsum('i,ji,ji', np.exp(-beta*eig_values), eig_states, operator.dot(eig_states)) return aux / partiti...
[ "def", "expected_value", "(", "operator", ",", "eig_values", ",", "eig_states", ",", "beta", ")", ":", "aux", "=", "np", ".", "einsum", "(", "'i,ji,ji'", ",", "np", ".", "exp", "(", "-", "beta", "*", "eig_values", ")", ",", "eig_states", ",", "operator...
Calculates the average value of an observable it requires that states and operators have the same base
[ "Calculates", "the", "average", "value", "of", "an", "observable", "it", "requires", "that", "states", "and", "operators", "have", "the", "same", "base" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/operators.py#L66-L72
40,296
trevisanj/a99
a99/gui/errorcollector.py
Occurrence.get_plain_text
def get_plain_text(self): """Returns a list""" _msg = self.message if self.message is not None else [""] msg = _msg if isinstance(_msg, list) else [_msg] line = "" if not self.line else ", line {}".format(self.line) ret = ["{} found in file '{}'{}::".format(self.type.capital...
python
def get_plain_text(self): """Returns a list""" _msg = self.message if self.message is not None else [""] msg = _msg if isinstance(_msg, list) else [_msg] line = "" if not self.line else ", line {}".format(self.line) ret = ["{} found in file '{}'{}::".format(self.type.capital...
[ "def", "get_plain_text", "(", "self", ")", ":", "_msg", "=", "self", ".", "message", "if", "self", ".", "message", "is", "not", "None", "else", "[", "\"\"", "]", "msg", "=", "_msg", "if", "isinstance", "(", "_msg", ",", "list", ")", "else", "[", "_...
Returns a list
[ "Returns", "a", "list" ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/errorcollector.py#L23-L32
40,297
trevisanj/a99
a99/gui/errorcollector.py
ErrorCollector.get_plain_text
def get_plain_text(self): """Returns a list of strings""" ret = [] for occ in self.occurrences: ret.extend(occ.get_plain_text()) return ret
python
def get_plain_text(self): """Returns a list of strings""" ret = [] for occ in self.occurrences: ret.extend(occ.get_plain_text()) return ret
[ "def", "get_plain_text", "(", "self", ")", ":", "ret", "=", "[", "]", "for", "occ", "in", "self", ".", "occurrences", ":", "ret", ".", "extend", "(", "occ", ".", "get_plain_text", "(", ")", ")", "return", "ret" ]
Returns a list of strings
[ "Returns", "a", "list", "of", "strings" ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/errorcollector.py#L96-L101
40,298
trevisanj/a99
a99/fileio.py
crunch_dir
def crunch_dir(name, n=50): """Puts "..." in the middle of a directory name if lengh > n.""" if len(name) > n + 3: name = "..." + name[-n:] return name
python
def crunch_dir(name, n=50): """Puts "..." in the middle of a directory name if lengh > n.""" if len(name) > n + 3: name = "..." + name[-n:] return name
[ "def", "crunch_dir", "(", "name", ",", "n", "=", "50", ")", ":", "if", "len", "(", "name", ")", ">", "n", "+", "3", ":", "name", "=", "\"...\"", "+", "name", "[", "-", "n", ":", "]", "return", "name" ]
Puts "..." in the middle of a directory name if lengh > n.
[ "Puts", "...", "in", "the", "middle", "of", "a", "directory", "name", "if", "lengh", ">", "n", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/fileio.py#L32-L36
40,299
trevisanj/f311
f311/explorer/gui/a_XFileMainWindow.py
XFileMainWindowBase._add_log_tab
def _add_log_tab(self): """Adds element to pages and new tab""" # text_tab = "Log (Alt+&{})".format(len(self.pages)+1) text_tab = "Log" self.pages.append(MyPage(text_tab=text_tab)) # ### Log tab te = self.textEdit_log = self.keep_ref(QTextEdit()) te.s...
python
def _add_log_tab(self): """Adds element to pages and new tab""" # text_tab = "Log (Alt+&{})".format(len(self.pages)+1) text_tab = "Log" self.pages.append(MyPage(text_tab=text_tab)) # ### Log tab te = self.textEdit_log = self.keep_ref(QTextEdit()) te.s...
[ "def", "_add_log_tab", "(", "self", ")", ":", "# text_tab = \"Log (Alt+&{})\".format(len(self.pages)+1)\r", "text_tab", "=", "\"Log\"", "self", ".", "pages", ".", "append", "(", "MyPage", "(", "text_tab", "=", "text_tab", ")", ")", "# ### Log tab\r", "te", "=", "s...
Adds element to pages and new tab
[ "Adds", "element", "to", "pages", "and", "new", "tab" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XFileMainWindow.py#L165-L176