hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
⌀
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
346d6db9bebd16517383c66c5e61687aef909e99
saberraz/mergin-py-client
mergin/merginproject.py
[ "MIT" ]
Python
has_unfinished_pull
<not_specific>
def has_unfinished_pull(self): """ Check if there is an unfinished pull for this project. Unfinished pull means that a previous pull_project() call has failed in the final stage due to some files being in read-only mode. When a project has unfinished pull, it has to be resolved ...
Check if there is an unfinished pull for this project. Unfinished pull means that a previous pull_project() call has failed in the final stage due to some files being in read-only mode. When a project has unfinished pull, it has to be resolved before allowing further pulls or pushes. ...
Check if there is an unfinished pull for this project. Unfinished pull means that a previous pull_project() call has failed in the final stage due to some files being in read-only mode. When a project has unfinished pull, it has to be resolved before allowing further pulls or pushes.
[ "Check", "if", "there", "is", "an", "unfinished", "pull", "for", "this", "project", ".", "Unfinished", "pull", "means", "that", "a", "previous", "pull_project", "()", "call", "has", "failed", "in", "the", "final", "stage", "due", "to", "some", "files", "be...
def has_unfinished_pull(self): return os.path.exists(self.unfinished_pull_dir)
[ "def", "has_unfinished_pull", "(", "self", ")", ":", "return", "os", ".", "path", ".", "exists", "(", "self", ".", "unfinished_pull_dir", ")" ]
Check if there is an unfinished pull for this project.
[ "Check", "if", "there", "is", "an", "unfinished", "pull", "for", "this", "project", "." ]
[ "\"\"\" Check if there is an unfinished pull for this project.\n\n Unfinished pull means that a previous pull_project() call has\n failed in the final stage due to some files being in read-only\n mode. When a project has unfinished pull, it has to be resolved\n before allowing further pu...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "whether there is an unfinished pull", "docstring_tokens": [ "whether", "there", "is", "an", "unfinished", "pull" ], "type": "bool" } ], "raises": [], "params": [ { "identifier": "self", ...
346d6db9bebd16517383c66c5e61687aef909e99
saberraz/mergin-py-client
mergin/merginproject.py
[ "MIT" ]
Python
resolve_unfinished_pull
<not_specific>
def resolve_unfinished_pull(self, user_name): """ Try to resolve unfinished pull. Unfinished pull means that a previous pull_project() call has failed in the final stage due to some files being in read-only mode. When a project has unfinished pull, it has to be resolved ...
Try to resolve unfinished pull. Unfinished pull means that a previous pull_project() call has failed in the final stage due to some files being in read-only mode. When a project has unfinished pull, it has to be resolved before allowing further pulls or pushes. Resolvi...
Try to resolve unfinished pull. Unfinished pull means that a previous pull_project() call has failed in the final stage due to some files being in read-only mode. When a project has unfinished pull, it has to be resolved before allowing further pulls or pushes. Resolving unfinihed pull means creation of the conflicted...
[ "Try", "to", "resolve", "unfinished", "pull", ".", "Unfinished", "pull", "means", "that", "a", "previous", "pull_project", "()", "call", "has", "failed", "in", "the", "final", "stage", "due", "to", "some", "files", "being", "in", "read", "-", "only", "mode...
def resolve_unfinished_pull(self, user_name): conflicts = [] if not self.has_unfinished_pull(): self.log.warning("no unfinished pulls found") return self.log.info("resolving unfinished pull") temp_dir = tempfile.mkdtemp(prefix="mergin-py-client-") for root...
[ "def", "resolve_unfinished_pull", "(", "self", ",", "user_name", ")", ":", "conflicts", "=", "[", "]", "if", "not", "self", ".", "has_unfinished_pull", "(", ")", ":", "self", ".", "log", ".", "warning", "(", "\"no unfinished pulls found\"", ")", "return", "s...
Try to resolve unfinished pull.
[ "Try", "to", "resolve", "unfinished", "pull", "." ]
[ "\"\"\"\n Try to resolve unfinished pull.\n\n Unfinished pull means that a previous pull_project() call has\n failed in the final stage due to some files being in read-only\n mode. When a project has unfinished pull, it has to be resolved\n before allowing further pulls or pushes....
[ { "param": "self", "type": null }, { "param": "user_name", "type": null } ]
{ "returns": [ { "docstring": "files where conflicts were found", "docstring_tokens": [ "files", "where", "conflicts", "were", "found" ], "type": "list[str]" } ], "raises": [], "params": [ { "identifier": "self", "type": nul...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
_print_unhandled_exception
null
def _print_unhandled_exception(): """Outputs details of an unhandled exception that is being handled right now""" click.secho("Unhandled exception!", fg="red") for line in traceback.format_exception(*sys.exc_info()): click.echo(line)
Outputs details of an unhandled exception that is being handled right now
Outputs details of an unhandled exception that is being handled right now
[ "Outputs", "details", "of", "an", "unhandled", "exception", "that", "is", "being", "handled", "right", "now" ]
def _print_unhandled_exception(): click.secho("Unhandled exception!", fg="red") for line in traceback.format_exception(*sys.exc_info()): click.echo(line)
[ "def", "_print_unhandled_exception", "(", ")", ":", "click", ".", "secho", "(", "\"Unhandled exception!\"", ",", "fg", "=", "\"red\"", ")", "for", "line", "in", "traceback", ".", "format_exception", "(", "*", "sys", ".", "exc_info", "(", ")", ")", ":", "cl...
Outputs details of an unhandled exception that is being handled right now
[ "Outputs", "details", "of", "an", "unhandled", "exception", "that", "is", "being", "handled", "right", "now" ]
[ "\"\"\"Outputs details of an unhandled exception that is being handled right now\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
cli
null
def cli(ctx, url, auth_token, username, password): """ Command line interface for the Mergin client module. For user authentication on server there are two options: 1. authorization token environment variable (MERGIN_AUTH) is defined, or 2. username and password need to be given either as environ...
Command line interface for the Mergin client module. For user authentication on server there are two options: 1. authorization token environment variable (MERGIN_AUTH) is defined, or 2. username and password need to be given either as environment variables (MERGIN_USERNAME, MERGIN_PASSWORD), or...
Command line interface for the Mergin client module. For user authentication on server there are two options. 1. authorization token environment variable (MERGIN_AUTH) is defined, or 2. username and password need to be given either as environment variables (MERGIN_USERNAME, MERGIN_PASSWORD), or as command options (--u...
[ "Command", "line", "interface", "for", "the", "Mergin", "client", "module", ".", "For", "user", "authentication", "on", "server", "there", "are", "two", "options", ".", "1", ".", "authorization", "token", "environment", "variable", "(", "MERGIN_AUTH", ")", "is...
def cli(ctx, url, auth_token, username, password): mc = get_client(url=url, auth_token=auth_token, username=username, password=password) ctx.obj = {"client": mc}
[ "def", "cli", "(", "ctx", ",", "url", ",", "auth_token", ",", "username", ",", "password", ")", ":", "mc", "=", "get_client", "(", "url", "=", "url", ",", "auth_token", "=", "auth_token", ",", "username", "=", "username", ",", "password", "=", "passwor...
Command line interface for the Mergin client module.
[ "Command", "line", "interface", "for", "the", "Mergin", "client", "module", "." ]
[ "\"\"\"\n Command line interface for the Mergin client module.\n For user authentication on server there are two options:\n\n 1. authorization token environment variable (MERGIN_AUTH) is defined, or\n 2. username and password need to be given either as environment variables (MERGIN_USERNAME, MERGIN_PA...
[ { "param": "ctx", "type": null }, { "param": "url", "type": null }, { "param": "auth_token", "type": null }, { "param": "username", "type": null }, { "param": "password", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "url", "type": null, "docstring": null, "docstring_tokens": [],...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
login
null
def login(ctx): """Login to the service and see how to set the token environment variable.""" mc = ctx.obj["client"] if mc is not None: click.secho("Login successful!", fg="green") token = mc._auth_session["token"] click.secho(f'To set the MERGIN_AUTH variable run:\nexport MERGIN_AUT...
Login to the service and see how to set the token environment variable.
Login to the service and see how to set the token environment variable.
[ "Login", "to", "the", "service", "and", "see", "how", "to", "set", "the", "token", "environment", "variable", "." ]
def login(ctx): mc = ctx.obj["client"] if mc is not None: click.secho("Login successful!", fg="green") token = mc._auth_session["token"] click.secho(f'To set the MERGIN_AUTH variable run:\nexport MERGIN_AUTH="{token}"')
[ "def", "login", "(", "ctx", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "not", "None", ":", "click", ".", "secho", "(", "\"Login successful!\"", ",", "fg", "=", "\"green\"", ")", "token", "=", "mc", ".", "_auth...
Login to the service and see how to set the token environment variable.
[ "Login", "to", "the", "service", "and", "see", "how", "to", "set", "the", "token", "environment", "variable", "." ]
[ "\"\"\"Login to the service and see how to set the token environment variable.\"\"\"" ]
[ { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
create
<not_specific>
def create(ctx, project, public, from_dir): """Create a new project on Mergin server. `project` needs to be a combination of namespace/project.""" mc = ctx.obj["client"] if mc is None: return if "/" in project: try: namespace, project = project.split("/") assert n...
Create a new project on Mergin server. `project` needs to be a combination of namespace/project.
Create a new project on Mergin server. `project` needs to be a combination of namespace/project.
[ "Create", "a", "new", "project", "on", "Mergin", "server", ".", "`", "project", "`", "needs", "to", "be", "a", "combination", "of", "namespace", "/", "project", "." ]
def create(ctx, project, public, from_dir): mc = ctx.obj["client"] if mc is None: return if "/" in project: try: namespace, project = project.split("/") assert namespace, "No namespace given" assert project, "No project name given" except (ValueErr...
[ "def", "create", "(", "ctx", ",", "project", ",", "public", ",", "from_dir", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "if", "\"/\"", "in", "project", ":", "try", ":", "namespace", ",",...
Create a new project on Mergin server.
[ "Create", "a", "new", "project", "on", "Mergin", "server", "." ]
[ "\"\"\"Create a new project on Mergin server. `project` needs to be a combination of namespace/project.\"\"\"", "# namespace not specified, use current user namespace" ]
[ { "param": "ctx", "type": null }, { "param": "project", "type": null }, { "param": "public", "type": null }, { "param": "from_dir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "project", "type": null, "docstring": null, "docstring_tokens":...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
list_projects
<not_specific>
def list_projects(ctx, flag): """List projects on the server.""" filter_str = "(filter flag={})".format(flag) if flag is not None else "(all public)" click.echo("List of projects {}:".format(filter_str)) mc = ctx.obj["client"] if mc is None: return resp = mc.paginated_projects_list(flag=...
List projects on the server.
List projects on the server.
[ "List", "projects", "on", "the", "server", "." ]
def list_projects(ctx, flag): filter_str = "(filter flag={})".format(flag) if flag is not None else "(all public)" click.echo("List of projects {}:".format(filter_str)) mc = ctx.obj["client"] if mc is None: return resp = mc.paginated_projects_list(flag=flag) projects_list = resp["project...
[ "def", "list_projects", "(", "ctx", ",", "flag", ")", ":", "filter_str", "=", "\"(filter flag={})\"", ".", "format", "(", "flag", ")", "if", "flag", "is", "not", "None", "else", "\"(all public)\"", "click", ".", "echo", "(", "\"List of projects {}:\"", ".", ...
List projects on the server.
[ "List", "projects", "on", "the", "server", "." ]
[ "\"\"\"List projects on the server.\"\"\"" ]
[ { "param": "ctx", "type": null }, { "param": "flag", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flag", "type": null, "docstring": null, "docstring_tokens": []...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
download
<not_specific>
def download(ctx, project, directory, version): """Download last version of mergin project.""" mc = ctx.obj["client"] if mc is None: return directory = directory or os.path.basename(project) click.echo("Downloading into {}".format(directory)) try: job = download_project_async(mc,...
Download last version of mergin project.
Download last version of mergin project.
[ "Download", "last", "version", "of", "mergin", "project", "." ]
def download(ctx, project, directory, version): mc = ctx.obj["client"] if mc is None: return directory = directory or os.path.basename(project) click.echo("Downloading into {}".format(directory)) try: job = download_project_async(mc, project, directory, version) with click.pr...
[ "def", "download", "(", "ctx", ",", "project", ",", "directory", ",", "version", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "directory", "=", "directory", "or", "os", ".", "path", ".", "...
Download last version of mergin project.
[ "Download", "last", "version", "of", "mergin", "project", "." ]
[ "\"\"\"Download last version of mergin project.\"\"\"", "# 100ms", "# the update() needs increment only" ]
[ { "param": "ctx", "type": null }, { "param": "project", "type": null }, { "param": "directory", "type": null }, { "param": "version", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "project", "type": null, "docstring": null, "docstring_tokens":...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
share_add
<not_specific>
def share_add(ctx, project, usernames, permissions): """Add permissions to [users] to project.""" mc = ctx.obj["client"] if mc is None: return usernames = list(usernames) mc.add_user_permissions_to_project(project, usernames, permissions)
Add permissions to [users] to project.
Add permissions to [users] to project.
[ "Add", "permissions", "to", "[", "users", "]", "to", "project", "." ]
def share_add(ctx, project, usernames, permissions): mc = ctx.obj["client"] if mc is None: return usernames = list(usernames) mc.add_user_permissions_to_project(project, usernames, permissions)
[ "def", "share_add", "(", "ctx", ",", "project", ",", "usernames", ",", "permissions", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "usernames", "=", "list", "(", "usernames", ")", "mc", ".",...
Add permissions to [users] to project.
[ "Add", "permissions", "to", "[", "users", "]", "to", "project", "." ]
[ "\"\"\"Add permissions to [users] to project.\"\"\"" ]
[ { "param": "ctx", "type": null }, { "param": "project", "type": null }, { "param": "usernames", "type": null }, { "param": "permissions", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "project", "type": null, "docstring": null, "docstring_tokens":...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
share_remove
<not_specific>
def share_remove(ctx, project, usernames): """Remove [users] permissions from project.""" mc = ctx.obj["client"] if mc is None: return usernames = list(usernames) mc.remove_user_permissions_from_project(project, usernames)
Remove [users] permissions from project.
Remove [users] permissions from project.
[ "Remove", "[", "users", "]", "permissions", "from", "project", "." ]
def share_remove(ctx, project, usernames): mc = ctx.obj["client"] if mc is None: return usernames = list(usernames) mc.remove_user_permissions_from_project(project, usernames)
[ "def", "share_remove", "(", "ctx", ",", "project", ",", "usernames", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "usernames", "=", "list", "(", "usernames", ")", "mc", ".", "remove_user_permi...
Remove [users] permissions from project.
[ "Remove", "[", "users", "]", "permissions", "from", "project", "." ]
[ "\"\"\"Remove [users] permissions from project.\"\"\"" ]
[ { "param": "ctx", "type": null }, { "param": "project", "type": null }, { "param": "usernames", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "project", "type": null, "docstring": null, "docstring_tokens":...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
download_file
<not_specific>
def download_file(ctx, filepath, output, version): """ Download project file at specified version. `project` needs to be a combination of namespace/project. If no version is given, the latest will be fetched. """ mc = ctx.obj["client"] if mc is None: return mp = MerginProject(os.getc...
Download project file at specified version. `project` needs to be a combination of namespace/project. If no version is given, the latest will be fetched.
Download project file at specified version. `project` needs to be a combination of namespace/project. If no version is given, the latest will be fetched.
[ "Download", "project", "file", "at", "specified", "version", ".", "`", "project", "`", "needs", "to", "be", "a", "combination", "of", "namespace", "/", "project", ".", "If", "no", "version", "is", "given", "the", "latest", "will", "be", "fetched", "." ]
def download_file(ctx, filepath, output, version): mc = ctx.obj["client"] if mc is None: return mp = MerginProject(os.getcwd()) project_path = mp.metadata["name"] try: job = download_file_async(mc, project_path, filepath, output, version) with click.progressbar(length=job.tot...
[ "def", "download_file", "(", "ctx", ",", "filepath", ",", "output", ",", "version", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "mp", "=", "MerginProject", "(", "os", ".", "getcwd", "(", ...
Download project file at specified version.
[ "Download", "project", "file", "at", "specified", "version", "." ]
[ "\"\"\"\n Download project file at specified version. `project` needs to be a combination of namespace/project.\n If no version is given, the latest will be fetched.\n \"\"\"", "# 100ms", "# the update() needs increment only" ]
[ { "param": "ctx", "type": null }, { "param": "filepath", "type": null }, { "param": "output", "type": null }, { "param": "version", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filepath", "type": null, "docstring": null, "docstring_tokens"...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
status
<not_specific>
def status(ctx): """Show all changes in project files - upstream and local.""" mc = ctx.obj["client"] if mc is None: return try: pull_changes, push_changes, push_changes_summary = mc.project_status(os.getcwd()) except InvalidProject as e: click.secho("Invalid project director...
Show all changes in project files - upstream and local.
Show all changes in project files - upstream and local.
[ "Show", "all", "changes", "in", "project", "files", "-", "upstream", "and", "local", "." ]
def status(ctx): mc = ctx.obj["client"] if mc is None: return try: pull_changes, push_changes, push_changes_summary = mc.project_status(os.getcwd()) except InvalidProject as e: click.secho("Invalid project directory ({})".format(str(e)), fg="red") return except Client...
[ "def", "status", "(", "ctx", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "try", ":", "pull_changes", ",", "push_changes", ",", "push_changes_summary", "=", "mc", ".", "project_status", "(", "...
Show all changes in project files - upstream and local.
[ "Show", "all", "changes", "in", "project", "files", "-", "upstream", "and", "local", "." ]
[ "\"\"\"Show all changes in project files - upstream and local.\"\"\"" ]
[ { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
push
<not_specific>
def push(ctx): """Upload local changes into Mergin repository.""" mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() try: job = push_project_async(mc, directory) if job is not None: # if job is none, we don't upload any files, and the transaction is finishe...
Upload local changes into Mergin repository.
Upload local changes into Mergin repository.
[ "Upload", "local", "changes", "into", "Mergin", "repository", "." ]
def push(ctx): mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() try: job = push_project_async(mc, directory) if job is not None: with click.progressbar(length=job.total_size) as bar: last_transferred_size = 0 while...
[ "def", "push", "(", "ctx", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "directory", "=", "os", ".", "getcwd", "(", ")", "try", ":", "job", "=", "push_project_async", "(", "mc", ",", "di...
Upload local changes into Mergin repository.
[ "Upload", "local", "changes", "into", "Mergin", "repository", "." ]
[ "\"\"\"Upload local changes into Mergin repository.\"\"\"", "# if job is none, we don't upload any files, and the transaction is finished already", "# 100ms", "# the update() needs increment only" ]
[ { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
pull
<not_specific>
def pull(ctx): """Fetch changes from Mergin repository.""" mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() try: job = pull_project_async(mc, directory) if job is None: click.echo("Project is up to date") return with click.p...
Fetch changes from Mergin repository.
Fetch changes from Mergin repository.
[ "Fetch", "changes", "from", "Mergin", "repository", "." ]
def pull(ctx): mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() try: job = pull_project_async(mc, directory) if job is None: click.echo("Project is up to date") return with click.progressbar(length=job.total_size) as bar: ...
[ "def", "pull", "(", "ctx", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "directory", "=", "os", ".", "getcwd", "(", ")", "try", ":", "job", "=", "pull_project_async", "(", "mc", ",", "di...
Fetch changes from Mergin repository.
[ "Fetch", "changes", "from", "Mergin", "repository", "." ]
[ "\"\"\"Fetch changes from Mergin repository.\"\"\"", "# 100ms", "# the update() needs increment only" ]
[ { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
show_version
<not_specific>
def show_version(ctx, version): """Displays information about a single version of a project. `version` is 'v1', 'v2', etc.""" mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() mp = MerginProject(directory) project_path = mp.metadata["name"] # TODO: handle exception...
Displays information about a single version of a project. `version` is 'v1', 'v2', etc.
Displays information about a single version of a project.
[ "Displays", "information", "about", "a", "single", "version", "of", "a", "project", "." ]
def show_version(ctx, version): mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() mp = MerginProject(directory) project_path = mp.metadata["name"] version_info_dict = mc.project_version_info(project_path, version)[0] click.secho("Project: " + version_info_dict["pro...
[ "def", "show_version", "(", "ctx", ",", "version", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "directory", "=", "os", ".", "getcwd", "(", ")", "mp", "=", "MerginProject", "(", "directory",...
Displays information about a single version of a project.
[ "Displays", "information", "about", "a", "single", "version", "of", "a", "project", "." ]
[ "\"\"\"Displays information about a single version of a project. `version` is 'v1', 'v2', etc.\"\"\"", "# TODO: handle exception when version not found" ]
[ { "param": "ctx", "type": null }, { "param": "version", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "version", "type": null, "docstring": null, "docstring_tokens":...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
show_file_history
<not_specific>
def show_file_history(ctx, path): """Displays information about a single version of a project.""" mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() mp = MerginProject(directory) project_path = mp.metadata["name"] info_dict = mc.project_file_history_info(project_pat...
Displays information about a single version of a project.
Displays information about a single version of a project.
[ "Displays", "information", "about", "a", "single", "version", "of", "a", "project", "." ]
def show_file_history(ctx, path): mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() mp = MerginProject(directory) project_path = mp.metadata["name"] info_dict = mc.project_file_history_info(project_path, path) history_dict = info_dict["history"] click.secho("Fi...
[ "def", "show_file_history", "(", "ctx", ",", "path", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "directory", "=", "os", ".", "getcwd", "(", ")", "mp", "=", "MerginProject", "(", "directory...
Displays information about a single version of a project.
[ "Displays", "information", "about", "a", "single", "version", "of", "a", "project", "." ]
[ "\"\"\"Displays information about a single version of a project.\"\"\"", "# TODO: handle exception if history not found" ]
[ { "param": "ctx", "type": null }, { "param": "path", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": []...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
show_file_changeset
<not_specific>
def show_file_changeset(ctx, path, version): """ Displays information about project changes.""" mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() mp = MerginProject(directory) project_path = mp.metadata["name"] info_dict = mc.project_file_changeset_info(project_pat...
Displays information about project changes.
Displays information about project changes.
[ "Displays", "information", "about", "project", "changes", "." ]
def show_file_changeset(ctx, path, version): mc = ctx.obj["client"] if mc is None: return directory = os.getcwd() mp = MerginProject(directory) project_path = mp.metadata["name"] info_dict = mc.project_file_changeset_info(project_path, path, version) click.secho(json.dumps(info_dict,...
[ "def", "show_file_changeset", "(", "ctx", ",", "path", ",", "version", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "directory", "=", "os", ".", "getcwd", "(", ")", "mp", "=", "MerginProject...
Displays information about project changes.
[ "Displays", "information", "about", "project", "changes", "." ]
[ "\"\"\" Displays information about project changes.\"\"\"", "# TODO: handle exception if Diff not found" ]
[ { "param": "ctx", "type": null }, { "param": "path", "type": null }, { "param": "version", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": []...
fd1d1b02950f0cb210f8c3cbf2e3485cff5b217c
saberraz/mergin-py-client
mergin/cli.py
[ "MIT" ]
Python
resolve_unfinished_pull
<not_specific>
def resolve_unfinished_pull(ctx): """Try to resolve unfinished pull.""" mc = ctx.obj["client"] if mc is None: return try: mc.resolve_unfinished_pull(os.getcwd()) click.echo("Unfinished pull successfully resolved") except InvalidProject as e: click.secho("Invalid proj...
Try to resolve unfinished pull.
Try to resolve unfinished pull.
[ "Try", "to", "resolve", "unfinished", "pull", "." ]
def resolve_unfinished_pull(ctx): mc = ctx.obj["client"] if mc is None: return try: mc.resolve_unfinished_pull(os.getcwd()) click.echo("Unfinished pull successfully resolved") except InvalidProject as e: click.secho("Invalid project directory ({})".format(str(e)), fg="red...
[ "def", "resolve_unfinished_pull", "(", "ctx", ")", ":", "mc", "=", "ctx", ".", "obj", "[", "\"client\"", "]", "if", "mc", "is", "None", ":", "return", "try", ":", "mc", ".", "resolve_unfinished_pull", "(", "os", ".", "getcwd", "(", ")", ")", "click", ...
Try to resolve unfinished pull.
[ "Try", "to", "resolve", "unfinished", "pull", "." ]
[ "\"\"\"Try to resolve unfinished pull.\"\"\"" ]
[ { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2e088bf30777b354a8c51cd002c6b31ac6568e4f
isaziconsulting/xray-desensitizer
src/clean_xrays.py
[ "MIT" ]
Python
find_files
<not_specific>
def find_files(path): '''Recursively walks input directory and find all files within subdirectories. Arguments: path: Path to the input directory. Returns: all_files: All files as a path with corresponding subdirectories. ''' all_files = [] if os.path.isdir(path): subdirs...
Recursively walks input directory and find all files within subdirectories. Arguments: path: Path to the input directory. Returns: all_files: All files as a path with corresponding subdirectories.
Recursively walks input directory and find all files within subdirectories.
[ "Recursively", "walks", "input", "directory", "and", "find", "all", "files", "within", "subdirectories", "." ]
def find_files(path): all_files = [] if os.path.isdir(path): subdirs = os.listdir(path) for subdir in subdirs: all_files += find_files(path+'/'+subdir) return all_files else: return [path]
[ "def", "find_files", "(", "path", ")", ":", "all_files", "=", "[", "]", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "subdirs", "=", "os", ".", "listdir", "(", "path", ")", "for", "subdir", "in", "subdirs", ":", "all_files", "+=", ...
Recursively walks input directory and find all files within subdirectories.
[ "Recursively", "walks", "input", "directory", "and", "find", "all", "files", "within", "subdirectories", "." ]
[ "'''Recursively walks input directory and find all files within subdirectories.\n Arguments:\n path: Path to the input directory.\n Returns:\n all_files: All files as a path with corresponding subdirectories.\n '''", "# recursively check next available directory until a file is found" ]
[ { "param": "path", "type": null } ]
{ "returns": [ { "docstring": "All files as a path with corresponding subdirectories.", "docstring_tokens": [ "All", "files", "as", "a", "path", "with", "corresponding", "subdirectories", "." ], "type": "all_files" ...
b149e9d5d453fe73322df6a1315fd7dc2ed434c9
isaziconsulting/xray-desensitizer
src/crop_xray_vector.py
[ "MIT" ]
Python
hide_names_mask
<not_specific>
def hide_names_mask(mask): '''Simple thresholding still has the text as visible, so this function dilates the image to the point where the original text is unrecognisable. Arguments: mask: Image obtained from projection. Returns: mask: Masked image after performing a dilation on the mask...
Simple thresholding still has the text as visible, so this function dilates the image to the point where the original text is unrecognisable. Arguments: mask: Image obtained from projection. Returns: mask: Masked image after performing a dilation on the mask.
Simple thresholding still has the text as visible, so this function dilates the image to the point where the original text is unrecognisable.
[ "Simple", "thresholding", "still", "has", "the", "text", "as", "visible", "so", "this", "function", "dilates", "the", "image", "to", "the", "point", "where", "the", "original", "text", "is", "unrecognisable", "." ]
def hide_names_mask(mask): kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (9, 9)) return cv2.dilate(mask, kernel, iterations=3)
[ "def", "hide_names_mask", "(", "mask", ")", ":", "kernel", "=", "cv2", ".", "getStructuringElement", "(", "cv2", ".", "MORPH_ELLIPSE", ",", "(", "9", ",", "9", ")", ")", "return", "cv2", ".", "dilate", "(", "mask", ",", "kernel", ",", "iterations", "="...
Simple thresholding still has the text as visible, so this function dilates the image to the point where the original text is unrecognisable.
[ "Simple", "thresholding", "still", "has", "the", "text", "as", "visible", "so", "this", "function", "dilates", "the", "image", "to", "the", "point", "where", "the", "original", "text", "is", "unrecognisable", "." ]
[ "'''Simple thresholding still has the text as visible, so this function\n dilates the image to the point where the original text is unrecognisable.\n Arguments:\n mask: Image obtained from projection.\n Returns:\n mask: Masked image after performing a dilation on the mask.\n '''", "# exp...
[ { "param": "mask", "type": null } ]
{ "returns": [ { "docstring": "Masked image after performing a dilation on the mask.", "docstring_tokens": [ "Masked", "image", "after", "performing", "a", "dilation", "on", "the", "mask", "." ], "type": "mask"...
b149e9d5d453fe73322df6a1315fd7dc2ed434c9
isaziconsulting/xray-desensitizer
src/crop_xray_vector.py
[ "MIT" ]
Python
run_system
<not_specific>
def run_system(img_name, proc_type='inpaint'): '''Wraps all functionality for image processing into a single function. Arguments: img_name: Path to image of interest. proc_type: Type of processing to perform. Returns: new_image: Cropped and processed image. all_images: Vector...
Wraps all functionality for image processing into a single function. Arguments: img_name: Path to image of interest. proc_type: Type of processing to perform. Returns: new_image: Cropped and processed image. all_images: Vector of all images to be used for OCR.
Wraps all functionality for image processing into a single function.
[ "Wraps", "all", "functionality", "for", "image", "processing", "into", "a", "single", "function", "." ]
def run_system(img_name, proc_type='inpaint'): img = io.imread(img_name) all_images = get_mask(img) if proc_type == 'inpaint': no_text = cv2.inpaint(img, all_images[0], 3, cv2.INPAINT_NS) elif proc_type == 'mask': all_images[0] = hide_names_mask(all_images[0]) all_images[0] = np....
[ "def", "run_system", "(", "img_name", ",", "proc_type", "=", "'inpaint'", ")", ":", "img", "=", "io", ".", "imread", "(", "img_name", ")", "all_images", "=", "get_mask", "(", "img", ")", "if", "proc_type", "==", "'inpaint'", ":", "no_text", "=", "cv2", ...
Wraps all functionality for image processing into a single function.
[ "Wraps", "all", "functionality", "for", "image", "processing", "into", "a", "single", "function", "." ]
[ "'''Wraps all functionality for image processing into a single function.\n Arguments:\n img_name: Path to image of interest.\n proc_type: Type of processing to perform.\n Returns:\n new_image: Cropped and processed image.\n all_images: Vector of all images to be used for OCR.\n ...
[ { "param": "img_name", "type": null }, { "param": "proc_type", "type": null } ]
{ "returns": [ { "docstring": "Cropped and processed image.\nall_images: Vector of all images to be used for OCR.", "docstring_tokens": [ "Cropped", "and", "processed", "image", ".", "all_images", ":", "Vector", "of", "all...
ee7593322e270c50e76f76ca88e5bc1ce184b0de
thanatos/pymbr
mbr.py
[ "MIT" ]
Python
decode_partition
<not_specific>
def decode_partition(partition_data): """Decode an MBR partition table entry. :returns: None if the partition entry is empty, otherwise, a Partition object. """ assert len(partition_data) == 16 # An unused partition is all 0x00s. if partition_data == (b'\x00' * 16): return None ...
Decode an MBR partition table entry. :returns: None if the partition entry is empty, otherwise, a Partition object.
Decode an MBR partition table entry.
[ "Decode", "an", "MBR", "partition", "table", "entry", "." ]
def decode_partition(partition_data): assert len(partition_data) == 16 if partition_data == (b'\x00' * 16): return None status = _six.indexbytes(partition_data, 0) assert status in (0, 0x80) bootable = status == 0x80 chs_first_sector = decode_chs_bytes(partition_data[1:4]) partition_...
[ "def", "decode_partition", "(", "partition_data", ")", ":", "assert", "len", "(", "partition_data", ")", "==", "16", "if", "partition_data", "==", "(", "b'\\x00'", "*", "16", ")", ":", "return", "None", "status", "=", "_six", ".", "indexbytes", "(", "parti...
Decode an MBR partition table entry.
[ "Decode", "an", "MBR", "partition", "table", "entry", "." ]
[ "\"\"\"Decode an MBR partition table entry.\n\n :returns: None if the partition entry is empty, otherwise, a Partition\n object.\n \"\"\"", "# An unused partition is all 0x00s." ]
[ { "param": "partition_data", "type": null } ]
{ "returns": [ { "docstring": "None if the partition entry is empty, otherwise, a Partition\nobject.", "docstring_tokens": [ "None", "if", "the", "partition", "entry", "is", "empty", "otherwise", "a", "Partition", ...
268cbc9326ca9776f96215fa385324941f78919d
uSlackr/keymaster
custom_components/keymaster/__init__.py
[ "MIT" ]
Python
homeassistant_started_listener
null
async def homeassistant_started_listener( hass: HomeAssistant, config_entry: ConfigEntry, locks_to_watch: List[KeymasterLock], evt: Event = None, ): """Start tracking state changes after HomeAssistant has started.""" # Listen to lock state changes so we can fire an event hass.data[DOMAIN][co...
Start tracking state changes after HomeAssistant has started.
Start tracking state changes after HomeAssistant has started.
[ "Start", "tracking", "state", "changes", "after", "HomeAssistant", "has", "started", "." ]
async def homeassistant_started_listener( hass: HomeAssistant, config_entry: ConfigEntry, locks_to_watch: List[KeymasterLock], evt: Event = None, ): hass.data[DOMAIN][config_entry.entry_id][UNSUB_LISTENERS].append( async_track_state_change( hass, [lock.lock_entity_id ...
[ "async", "def", "homeassistant_started_listener", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "locks_to_watch", ":", "List", "[", "KeymasterLock", "]", ",", "evt", ":", "Event", "=", "None", ",", ")", ":", "hass", ".", "d...
Start tracking state changes after HomeAssistant has started.
[ "Start", "tracking", "state", "changes", "after", "HomeAssistant", "has", "started", "." ]
[ "\"\"\"Start tracking state changes after HomeAssistant has started.\"\"\"", "# Listen to lock state changes so we can fire an event" ]
[ { "param": "hass", "type": "HomeAssistant" }, { "param": "config_entry", "type": "ConfigEntry" }, { "param": "locks_to_watch", "type": "List[KeymasterLock]" }, { "param": "evt", "type": "Event" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hass", "type": "HomeAssistant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config_entry", "type": "ConfigEntry", "docstring": null,...
268cbc9326ca9776f96215fa385324941f78919d
uSlackr/keymaster
custom_components/keymaster/__init__.py
[ "MIT" ]
Python
async_setup_entry
bool
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up is called when Home Assistant is loading our component.""" hass.data.setdefault(DOMAIN, {}) _LOGGER.info( "Version %s is starting, if you have any issues please report" " them here: %s", VERSION, ...
Set up is called when Home Assistant is loading our component.
Set up is called when Home Assistant is loading our component.
[ "Set", "up", "is", "called", "when", "Home", "Assistant", "is", "loading", "our", "component", "." ]
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: hass.data.setdefault(DOMAIN, {}) _LOGGER.info( "Version %s is starting, if you have any issues please report" " them here: %s", VERSION, ISSUE_URL, ) should_generate_package = config_entry.data.g...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "_LOGGER", ".", "info", "(", "\"Version %s i...
Set up is called when Home Assistant is loading our component.
[ "Set", "up", "is", "called", "when", "Home", "Assistant", "is", "loading", "our", "component", "." ]
[ "\"\"\"Set up is called when Home Assistant is loading our component.\"\"\"", "# pop CONF_GENERATE if it is in data", "# If CONF_PATH is absolute, make it relative. This can be removed in the future,", "# it is only needed for entries that are being migrated from using the old absolute", "# path", "# Remo...
[ { "param": "hass", "type": "HomeAssistant" }, { "param": "config_entry", "type": "ConfigEntry" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hass", "type": "HomeAssistant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config_entry", "type": "ConfigEntry", "docstring": null,...
268cbc9326ca9776f96215fa385324941f78919d
uSlackr/keymaster
custom_components/keymaster/__init__.py
[ "MIT" ]
Python
async_unload_entry
bool
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Handle removal of an entry.""" lockname = config_entry.data[CONF_LOCK_NAME] notification_id = f"{DOMAIN}_{lockname}_unload" async_create( hass, ( f"Removing `{lockname}` and all of the fi...
Handle removal of an entry.
Handle removal of an entry.
[ "Handle", "removal", "of", "an", "entry", "." ]
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: lockname = config_entry.data[CONF_LOCK_NAME] notification_id = f"{DOMAIN}_{lockname}_unload" async_create( hass, ( f"Removing `{lockname}` and all of the files that were generated for " ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "lockname", "=", "config_entry", ".", "data", "[", "CONF_LOCK_NAME", "]", "notification_id", "=", "f\"{DOMAIN}_{lockname}_unload...
Handle removal of an entry.
[ "Handle", "removal", "of", "an", "entry", "." ]
[ "\"\"\"Handle removal of an entry.\"\"\"", "# Remove all package files and the base folder if needed", "# Unsubscribe to any listeners" ]
[ { "param": "hass", "type": "HomeAssistant" }, { "param": "config_entry", "type": "ConfigEntry" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hass", "type": "HomeAssistant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config_entry", "type": "ConfigEntry", "docstring": null,...
268cbc9326ca9776f96215fa385324941f78919d
uSlackr/keymaster
custom_components/keymaster/__init__.py
[ "MIT" ]
Python
async_migrate_entry
bool
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Migrate an old config entry.""" version = config_entry.version # 1 -> 2: Migrate to new keys if version == 1: _LOGGER.debug("Migrating from version %s", version) data = config_entry.data.copy() ...
Migrate an old config entry.
Migrate an old config entry.
[ "Migrate", "an", "old", "config", "entry", "." ]
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: version = config_entry.version if version == 1: _LOGGER.debug("Migrating from version %s", version) data = config_entry.data.copy() data[CONF_ALARM_LEVEL_OR_USER_CODE_ENTITY_ID] = data.pop(CONF_ALARM_L...
[ "async", "def", "async_migrate_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "version", "=", "config_entry", ".", "version", "if", "version", "==", "1", ":", "_LOGGER", ".", "debug", "(", "\"Migra...
Migrate an old config entry.
[ "Migrate", "an", "old", "config", "entry", "." ]
[ "\"\"\"Migrate an old config entry.\"\"\"", "# 1 -> 2: Migrate to new keys" ]
[ { "param": "hass", "type": "HomeAssistant" }, { "param": "config_entry", "type": "ConfigEntry" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hass", "type": "HomeAssistant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config_entry", "type": "ConfigEntry", "docstring": null,...
268cbc9326ca9776f96215fa385324941f78919d
uSlackr/keymaster
custom_components/keymaster/__init__.py
[ "MIT" ]
Python
_invalid_code
<not_specific>
def _invalid_code(self, code_slot): """Return the PIN slot value as we are unable to read the slot value from the lock.""" _LOGGER.debug("Work around code in use.") # This is a fail safe and should not be needing to return "" data = "" # Build data from entities ...
Return the PIN slot value as we are unable to read the slot value from the lock.
Return the PIN slot value as we are unable to read the slot value from the lock.
[ "Return", "the", "PIN", "slot", "value", "as", "we", "are", "unable", "to", "read", "the", "slot", "value", "from", "the", "lock", "." ]
def _invalid_code(self, code_slot): _LOGGER.debug("Work around code in use.") data = "" active_binary_sensor = ( f"binary_sensor.active_{self._primary_lock.lock_name}_{code_slot}" ) active = self.hass.states.get(active_binary_sensor) pin_data = f"input_text.{s...
[ "def", "_invalid_code", "(", "self", ",", "code_slot", ")", ":", "_LOGGER", ".", "debug", "(", "\"Work around code in use.\"", ")", "data", "=", "\"\"", "active_binary_sensor", "=", "(", "f\"binary_sensor.active_{self._primary_lock.lock_name}_{code_slot}\"", ")", "active"...
Return the PIN slot value as we are unable to read the slot value from the lock.
[ "Return", "the", "PIN", "slot", "value", "as", "we", "are", "unable", "to", "read", "the", "slot", "value", "from", "the", "lock", "." ]
[ "\"\"\"Return the PIN slot value as we are unable to read the slot value\n from the lock.\"\"\"", "# This is a fail safe and should not be needing to return \"\"", "# Build data from entities", "# If slot is enabled return the PIN" ]
[ { "param": "self", "type": null }, { "param": "code_slot", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "code_slot", "type": null, "docstring": null, "docstring_token...
f1207cc82dd333eb1fe49743dcc3cb99fbe9d8f2
staadecker/switch
switch_model/transmission/transport/dispatch.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
<not_specific>
def define_components(mod): """ Adds components to a Pyomo abstract model object to describe the dispatch of transmission resources in an electric grid. This includes parameters, dispatch decisions and constraints. Unless otherwise stated, all power capacity is specified in units of MW, all ene...
Adds components to a Pyomo abstract model object to describe the dispatch of transmission resources in an electric grid. This includes parameters, dispatch decisions and constraints. Unless otherwise stated, all power capacity is specified in units of MW, all energy amounts are specified in units ...
Adds components to a Pyomo abstract model object to describe the dispatch of transmission resources in an electric grid. This includes parameters, dispatch decisions and constraints. Unless otherwise stated, all power capacity is specified in units of MW, all energy amounts are specified in units of MWh, and all sets a...
[ "Adds", "components", "to", "a", "Pyomo", "abstract", "model", "object", "to", "describe", "the", "dispatch", "of", "transmission", "resources", "in", "an", "electric", "grid", ".", "This", "includes", "parameters", "dispatch", "decisions", "and", "constraints", ...
def define_components(mod): mod.TRANS_TIMEPOINTS = Set( dimen=3, initialize=lambda m: m.DIRECTIONAL_TX * m.TIMEPOINTS ) mod.DispatchTx = Var(mod.TRANS_TIMEPOINTS, within=NonNegativeReals) mod.Maximum_DispatchTx = Constraint( mod.TRANS_TIMEPOINTS, rule=lambda m, zone_from,...
[ "def", "define_components", "(", "mod", ")", ":", "mod", ".", "TRANS_TIMEPOINTS", "=", "Set", "(", "dimen", "=", "3", ",", "initialize", "=", "lambda", "m", ":", "m", ".", "DIRECTIONAL_TX", "*", "m", ".", "TIMEPOINTS", ")", "mod", ".", "DispatchTx", "=...
Adds components to a Pyomo abstract model object to describe the dispatch of transmission resources in an electric grid.
[ "Adds", "components", "to", "a", "Pyomo", "abstract", "model", "object", "to", "describe", "the", "dispatch", "of", "transmission", "resources", "in", "an", "electric", "grid", "." ]
[ "\"\"\"\n\n Adds components to a Pyomo abstract model object to describe the\n dispatch of transmission resources in an electric grid. This\n includes parameters, dispatch decisions and constraints. Unless\n otherwise stated, all power capacity is specified in units of MW,\n all energy amounts are sp...
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e0bc887713285401325ea77c5adc83f1b1597f68
staadecker/switch
switch_model/wecc/sampling/sampler_peak_median.py
[ "ECL-2.0", "Apache-2.0" ]
Python
sample_timepoints
<not_specific>
def sample_timepoints( load_data, dates, peak, period_id, number_tps: int = 6, ): """ Returns a dataframe of timepoints for the given dates """ if number_tps != 6: raise NotImplementedError(f"{number_tps} tps is not yet implemented") columns_to_return = [ "date", ...
Returns a dataframe of timepoints for the given dates
Returns a dataframe of timepoints for the given dates
[ "Returns", "a", "dataframe", "of", "timepoints", "for", "the", "given", "dates" ]
def sample_timepoints( load_data, dates, peak, period_id, number_tps: int = 6, ): if number_tps != 6: raise NotImplementedError(f"{number_tps} tps is not yet implemented") columns_to_return = [ "date", "raw_timepoint_id", "period_id", "timestamp_utc", ...
[ "def", "sample_timepoints", "(", "load_data", ",", "dates", ",", "peak", ",", "period_id", ",", "number_tps", ":", "int", "=", "6", ",", ")", ":", "if", "number_tps", "!=", "6", ":", "raise", "NotImplementedError", "(", "f\"{number_tps} tps is not yet implemente...
Returns a dataframe of timepoints for the given dates
[ "Returns", "a", "dataframe", "of", "timepoints", "for", "the", "given", "dates" ]
[ "\"\"\"\n Returns a dataframe of timepoints for the given dates\n \"\"\"", "# FIXME: Maybe we want to only pass the data with the demand series instead of", "# having all the other columns", "# Find timepoint with peak load", "# Get a range of timepoints around the peak", "# Return the timepoints in...
[ { "param": "load_data", "type": null }, { "param": "dates", "type": null }, { "param": "peak", "type": null }, { "param": "period_id", "type": null }, { "param": "number_tps", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "load_data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dates", "type": null, "docstring": null, "docstring_toke...
e93f4f9d5ba539e0b824ff2380f14c08babe0bd0
staadecker/switch
switch_model/utilities/load_data.py
[ "ECL-2.0", "Apache-2.0" ]
Python
register_component_for_loading
null
def register_component_for_loading(component, input_file, input_column, input_optional, **kwargs): """ Adds a component to the mapping """ # By default an input is optional if there is a default for that input already specified if input_optional is None: input_optional = "default" in kwargs ...
Adds a component to the mapping
Adds a component to the mapping
[ "Adds", "a", "component", "to", "the", "mapping" ]
def register_component_for_loading(component, input_file, input_column, input_optional, **kwargs): if input_optional is None: input_optional = "default" in kwargs component.input_column = input_column component.input_optional = input_optional if input_file not in _registered_components: ...
[ "def", "register_component_for_loading", "(", "component", ",", "input_file", ",", "input_column", ",", "input_optional", ",", "**", "kwargs", ")", ":", "if", "input_optional", "is", "None", ":", "input_optional", "=", "\"default\"", "in", "kwargs", "component", "...
Adds a component to the mapping
[ "Adds", "a", "component", "to", "the", "mapping" ]
[ "\"\"\"\n Adds a component to the mapping\n \"\"\"", "# By default an input is optional if there is a default for that input already specified", "# Add the column and optional parameters to the component", "# Add the component to the mapping" ]
[ { "param": "component", "type": null }, { "param": "input_file", "type": null }, { "param": "input_column", "type": null }, { "param": "input_optional", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "component", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input_file", "type": null, "docstring": null, "docstring...
e93f4f9d5ba539e0b824ff2380f14c08babe0bd0
staadecker/switch
switch_model/utilities/load_data.py
[ "ECL-2.0", "Apache-2.0" ]
Python
load_registered_inputs
null
def load_registered_inputs(switch_data, inputs_dir): """ Gets called to load all the inputs that are registered. """ for file, components in _registered_components.items(): # We use lists since load_aug is going to convert to a list in any case params = [c for c in components if isinstan...
Gets called to load all the inputs that are registered.
Gets called to load all the inputs that are registered.
[ "Gets", "called", "to", "load", "all", "the", "inputs", "that", "are", "registered", "." ]
def load_registered_inputs(switch_data, inputs_dir): for file, components in _registered_components.items(): params = [c for c in components if isinstance(c, Param)] optional_params = [p for p in params if p.input_optional] index = [c for c in components if isinstance(c, Set)] if len...
[ "def", "load_registered_inputs", "(", "switch_data", ",", "inputs_dir", ")", ":", "for", "file", ",", "components", "in", "_registered_components", ".", "items", "(", ")", ":", "params", "=", "[", "c", "for", "c", "in", "components", "if", "isinstance", "(",...
Gets called to load all the inputs that are registered.
[ "Gets", "called", "to", "load", "all", "the", "inputs", "that", "are", "registered", "." ]
[ "\"\"\"\n Gets called to load all the inputs that are registered.\n \"\"\"", "# We use lists since load_aug is going to convert to a list in any case", "# entire file is optional if the index is optional", "# file is optional if each param is optional and no index", "# when only defining the index, we...
[ { "param": "switch_data", "type": null }, { "param": "inputs_dir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "switch_data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "inputs_dir", "type": null, "docstring": null, "docstri...
bf28fec20a2089e464503d2a5a49c804722cf470
staadecker/switch
switch_model/policies/carbon_policies.py
[ "ECL-2.0", "Apache-2.0" ]
Python
post_solve
<not_specific>
def post_solve(model, outdir): """ Export annual emissions, carbon cap, and implicit carbon costs (where appropriate). The dual values of the carbon cap constraint represent an implicit carbon cost for purely linear optimization problems. For mixed integer optimization problems, the dual values lose...
Export annual emissions, carbon cap, and implicit carbon costs (where appropriate). The dual values of the carbon cap constraint represent an implicit carbon cost for purely linear optimization problems. For mixed integer optimization problems, the dual values lose practical interpretations, so dua...
Export annual emissions, carbon cap, and implicit carbon costs (where appropriate). The dual values of the carbon cap constraint represent an implicit carbon cost for purely linear optimization problems. For mixed integer optimization problems, the dual values lose practical interpretations, so dual values are only exp...
[ "Export", "annual", "emissions", "carbon", "cap", "and", "implicit", "carbon", "costs", "(", "where", "appropriate", ")", ".", "The", "dual", "values", "of", "the", "carbon", "cap", "constraint", "represent", "an", "implicit", "carbon", "cost", "for", "purely"...
def post_solve(model, outdir): def get_row(model, period): GHGs = [ {"AnnualEmissions": model.AnnualEmissions, "cap": model.carbon_cap_tco2_per_yr, "cost_per_t": model.carbon_cost_dollar_per_tco2, "Enforce_Carbon_Cap": "Enforce_Carbon_Cap"}, {"AnnualEmissions": model.Ann...
[ "def", "post_solve", "(", "model", ",", "outdir", ")", ":", "def", "get_row", "(", "model", ",", "period", ")", ":", "GHGs", "=", "[", "{", "\"AnnualEmissions\"", ":", "model", ".", "AnnualEmissions", ",", "\"cap\"", ":", "model", ".", "carbon_cap_tco2_per...
Export annual emissions, carbon cap, and implicit carbon costs (where appropriate).
[ "Export", "annual", "emissions", "carbon", "cap", "and", "implicit", "carbon", "costs", "(", "where", "appropriate", ")", "." ]
[ "\"\"\"\n Export annual emissions, carbon cap, and implicit carbon costs (where\n appropriate). The dual values of the carbon cap constraint represent an\n implicit carbon cost for purely linear optimization problems. For mixed\n integer optimization problems, the dual values lose practical\n interpr...
[ { "param": "model", "type": null }, { "param": "outdir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outdir", "type": null, "docstring": null, "docstring_tokens"...
0c7ec1b6a950abb5d2940a6e5f82689c1165fa1c
staadecker/switch
switch_model/balancing/operating_reserves/areas.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
null
def define_components(mod): """ Augments a Pyomo abstract model object with sets and parameters that describe balancing areas. Unless otherwise stated, each set and parameter is mandatory. zone_balancing_area[z] describes which balancing area each load zone belongs to. This defaults to "system_...
Augments a Pyomo abstract model object with sets and parameters that describe balancing areas. Unless otherwise stated, each set and parameter is mandatory. zone_balancing_area[z] describes which balancing area each load zone belongs to. This defaults to "system_wide_balancing_area". BALANCIN...
Augments a Pyomo abstract model object with sets and parameters that describe balancing areas. Unless otherwise stated, each set and parameter is mandatory. zone_balancing_area[z] describes which balancing area each load zone belongs to. This defaults to "system_wide_balancing_area". BALANCING_AREAS is the set of bal...
[ "Augments", "a", "Pyomo", "abstract", "model", "object", "with", "sets", "and", "parameters", "that", "describe", "balancing", "areas", ".", "Unless", "otherwise", "stated", "each", "set", "and", "parameter", "is", "mandatory", ".", "zone_balancing_area", "[", "...
def define_components(mod): mod.zone_balancing_area = Param( mod.LOAD_ZONES, input_file="load_zones.csv", default='system_wide_balancing_area', within=Any) mod.BALANCING_AREAS = Set( ordered=False, initialize=lambda m: set( m.zone_balancing_area[z] for z in m.LOAD...
[ "def", "define_components", "(", "mod", ")", ":", "mod", ".", "zone_balancing_area", "=", "Param", "(", "mod", ".", "LOAD_ZONES", ",", "input_file", "=", "\"load_zones.csv\"", ",", "default", "=", "'system_wide_balancing_area'", ",", "within", "=", "Any", ")", ...
Augments a Pyomo abstract model object with sets and parameters that describe balancing areas.
[ "Augments", "a", "Pyomo", "abstract", "model", "object", "with", "sets", "and", "parameters", "that", "describe", "balancing", "areas", "." ]
[ "\"\"\"\n Augments a Pyomo abstract model object with sets and parameters that\n describe balancing areas. Unless otherwise stated, each set and\n parameter is mandatory.\n\n zone_balancing_area[z] describes which balancing area each load zone\n belongs to. This defaults to \"system_wide_balancing_ar...
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
graph
<not_specific>
def graph( name, title=None, supports_multi_scenario=False, requires_multi_scenario=False, is_long=False, note=None ): """ This function should be used as a decorator to register a graphing function. Graphing functions are functions that are run by 'switch gra...
This function should be used as a decorator to register a graphing function. Graphing functions are functions that are run by 'switch graph' or 'switch compare'. Graphing functions take one argument, an instance of GraphTools. @param name: name of the graph created by the decorated function. ...
This function should be used as a decorator to register a graphing function. Graphing functions are functions that are run by 'switch graph' or 'switch compare'. Graphing functions take one argument, an instance of GraphTools.
[ "This", "function", "should", "be", "used", "as", "a", "decorator", "to", "register", "a", "graphing", "function", ".", "Graphing", "functions", "are", "functions", "that", "are", "run", "by", "'", "switch", "graph", "'", "or", "'", "switch", "compare", "'...
def graph( name, title=None, supports_multi_scenario=False, requires_multi_scenario=False, is_long=False, note=None ): def decorator(func): @functools.wraps(func) @catch_exceptions("Failed to run a graphing function.", should_catch=CATCH_EXCEPTIONS) ...
[ "def", "graph", "(", "name", ",", "title", "=", "None", ",", "supports_multi_scenario", "=", "False", ",", "requires_multi_scenario", "=", "False", ",", "is_long", "=", "False", ",", "note", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":...
This function should be used as a decorator to register a graphing function.
[ "This", "function", "should", "be", "used", "as", "a", "decorator", "to", "register", "a", "graphing", "function", "." ]
[ "\"\"\"\n This function should be used as a decorator to register a graphing function.\n Graphing functions are functions that are run by 'switch graph' or 'switch compare'.\n Graphing functions take one argument, an instance of GraphTools.\n\n @param name: name of the graph created by the decorated fun...
[ { "param": "name", "type": null }, { "param": "title", "type": null }, { "param": "supports_multi_scenario", "type": null }, { "param": "requires_multi_scenario", "type": null }, { "param": "is_long", "type": null }, { "param": "note", "type": null...
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": null, "docstring": "name of the graph created by the decorated function.\nThis is used as the filename for the output.png file.", "docstring_tokens": [ "name", "of", "the", "graph...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
_load_maps
<not_specific>
def _load_maps(self): """ Plots the WECC states as a background on the provided axes and returns a dataframe with a mapping of load zones to center points. """ if self._wecc_states is None or self._center_points is None: try: import geopandas ...
Plots the WECC states as a background on the provided axes and returns a dataframe with a mapping of load zones to center points.
Plots the WECC states as a background on the provided axes and returns a dataframe with a mapping of load zones to center points.
[ "Plots", "the", "WECC", "states", "as", "a", "background", "on", "the", "provided", "axes", "and", "returns", "a", "dataframe", "with", "a", "mapping", "of", "load", "zones", "to", "center", "points", "." ]
def _load_maps(self): if self._wecc_states is None or self._center_points is None: try: import geopandas except ModuleNotFoundError: raise Exception( "Could not find package 'geopandas'. If on Windows make sure you install it through co...
[ "def", "_load_maps", "(", "self", ")", ":", "if", "self", ".", "_wecc_states", "is", "None", "or", "self", ".", "_center_points", "is", "None", ":", "try", ":", "import", "geopandas", "except", "ModuleNotFoundError", ":", "raise", "Exception", "(", "\"Could ...
Plots the WECC states as a background on the provided axes and returns a dataframe with a mapping of load zones to center points.
[ "Plots", "the", "WECC", "states", "as", "a", "background", "on", "the", "provided", "axes", "and", "returns", "a", "dataframe", "with", "a", "mapping", "of", "load", "zones", "to", "center", "points", "." ]
[ "\"\"\"\n Plots the WECC states as a background on the provided axes\n and returns a dataframe with a mapping of load zones to center points.\n \"\"\"", "# Read shape files", "# New dataframe with the centerpoint geometry" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
graph_pie_chart
<not_specific>
def graph_pie_chart(self, df, max_size=2500, ax=None): """ Graphs the data from the dataframe to a map pie chart. The dataframe should have 3 columns, gen_load_zone, gen_type and value. """ _, center_points = self._load_maps() # Scale the dataframe so the pie charts have...
Graphs the data from the dataframe to a map pie chart. The dataframe should have 3 columns, gen_load_zone, gen_type and value.
Graphs the data from the dataframe to a map pie chart. The dataframe should have 3 columns, gen_load_zone, gen_type and value.
[ "Graphs", "the", "data", "from", "the", "dataframe", "to", "a", "map", "pie", "chart", ".", "The", "dataframe", "should", "have", "3", "columns", "gen_load_zone", "gen_type", "and", "value", "." ]
def graph_pie_chart(self, df, max_size=2500, ax=None): _, center_points = self._load_maps() current_max_size = df.groupby("gen_load_zone")["value"].sum().max() df["value"] *= max_size / current_max_size if ax is None: ax = self._tools.get_axes() self._plot_states(ax) ...
[ "def", "graph_pie_chart", "(", "self", ",", "df", ",", "max_size", "=", "2500", ",", "ax", "=", "None", ")", ":", "_", ",", "center_points", "=", "self", ".", "_load_maps", "(", ")", "current_max_size", "=", "df", ".", "groupby", "(", "\"gen_load_zone\""...
Graphs the data from the dataframe to a map pie chart.
[ "Graphs", "the", "data", "from", "the", "dataframe", "to", "a", "map", "pie", "chart", "." ]
[ "\"\"\"\n Graphs the data from the dataframe to a map pie chart.\n The dataframe should have 3 columns, gen_load_zone, gen_type and value.\n \"\"\"", "# Scale the dataframe so the pie charts have the right size" ]
[ { "param": "self", "type": null }, { "param": "df", "type": null }, { "param": "max_size", "type": null }, { "param": "ax", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [],...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
graph_points
null
def graph_points(self, df, ax=None): """ Graphs a point in each load zone based on a dataframe with two columns - gen_load_zone - value """ _, center_points = self._load_maps() df = df.merge(center_points, on="gen_load_zone") # Cast to GeoDataFrame ...
Graphs a point in each load zone based on a dataframe with two columns - gen_load_zone - value
Graphs a point in each load zone based on a dataframe with two columns gen_load_zone value
[ "Graphs", "a", "point", "in", "each", "load", "zone", "based", "on", "a", "dataframe", "with", "two", "columns", "gen_load_zone", "value" ]
def graph_points(self, df, ax=None): _, center_points = self._load_maps() df = df.merge(center_points, on="gen_load_zone") df = self._geopandas.GeoDataFrame(df[["geometry", "value"]], geometry="geometry") if ax is None: ax = self._tools.get_axes() self._plot_states(ax...
[ "def", "graph_points", "(", "self", ",", "df", ",", "ax", "=", "None", ")", ":", "_", ",", "center_points", "=", "self", ".", "_load_maps", "(", ")", "df", "=", "df", ".", "merge", "(", "center_points", ",", "on", "=", "\"gen_load_zone\"", ")", "df",...
Graphs a point in each load zone based on a dataframe with two columns gen_load_zone value
[ "Graphs", "a", "point", "in", "each", "load", "zone", "based", "on", "a", "dataframe", "with", "two", "columns", "gen_load_zone", "value" ]
[ "\"\"\"\n Graphs a point in each load zone based on a dataframe with two columns\n - gen_load_zone\n - value\n \"\"\"", "# Cast to GeoDataFrame" ]
[ { "param": "self", "type": null }, { "param": "df", "type": null }, { "param": "ax", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [],...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
graph_transmission
<not_specific>
def graph_transmission(self, df, cutoff, ax=None, legend=True, zorder=-50): """ Graphs the data frame a dataframe onto a map. The dataframe should have 4 columns: - from: the load zone where we're starting from - to: the load zone where we're going to - value: the value t...
Graphs the data frame a dataframe onto a map. The dataframe should have 4 columns: - from: the load zone where we're starting from - to: the load zone where we're going to - value: the value to plot
Graphs the data frame a dataframe onto a map. The dataframe should have 4 columns: from: the load zone where we're starting from to: the load zone where we're going to value: the value to plot
[ "Graphs", "the", "data", "frame", "a", "dataframe", "onto", "a", "map", ".", "The", "dataframe", "should", "have", "4", "columns", ":", "from", ":", "the", "load", "zone", "where", "we", "'", "re", "starting", "from", "to", ":", "the", "load", "zone", ...
def graph_transmission(self, df, cutoff, ax=None, legend=True, zorder=-50): if ax is None: ax = self._tools.get_axes() _, center_points = self._load_maps() df[["from", "to"]] = df[["from", "to"]].apply(sorted, axis=1, result_type="expand") df = df.groupby(["from", "to"], as_i...
[ "def", "graph_transmission", "(", "self", ",", "df", ",", "cutoff", ",", "ax", "=", "None", ",", "legend", "=", "True", ",", "zorder", "=", "-", "50", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "self", ".", "_tools", ".", "get_axes", "("...
Graphs the data frame a dataframe onto a map.
[ "Graphs", "the", "data", "frame", "a", "dataframe", "onto", "a", "map", "." ]
[ "\"\"\"\n Graphs the data frame a dataframe onto a map.\n The dataframe should have 4 columns:\n - from: the load zone where we're starting from\n - to: the load zone where we're going to\n - value: the value to plot\n \"\"\"", "# Merge duplicate rows if table was unidire...
[ { "param": "self", "type": null }, { "param": "df", "type": null }, { "param": "cutoff", "type": null }, { "param": "ax", "type": null }, { "param": "legend", "type": null }, { "param": "zorder", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [],...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
gen_type
<not_specific>
def gen_type(self, df: pd.DataFrame, map_name='default', gen_tech_col='gen_tech', energy_source_col='gen_energy_source', drop_previous_col=True, others=None): """ Returns a dataframe that contains a column 'gen_type'. By default 'gen_type' is the aggregation of...
Returns a dataframe that contains a column 'gen_type'. By default 'gen_type' is the aggregation of 'gen_tech' + 'gen_energy_source' however this can be overidden in graph_tech_types.csv
Returns a dataframe that contains a column 'gen_type'.
[ "Returns", "a", "dataframe", "that", "contains", "a", "column", "'", "gen_type", "'", "." ]
def gen_type(self, df: pd.DataFrame, map_name='default', gen_tech_col='gen_tech', energy_source_col='gen_energy_source', drop_previous_col=True, others=None): try: cols = ["map_name", "gen_type", "gen_tech", "energy_source", "scenario_index"] tech_types ...
[ "def", "gen_type", "(", "self", ",", "df", ":", "pd", ".", "DataFrame", ",", "map_name", "=", "'default'", ",", "gen_tech_col", "=", "'gen_tech'", ",", "energy_source_col", "=", "'gen_energy_source'", ",", "drop_previous_col", "=", "True", ",", "others", "=", ...
Returns a dataframe that contains a column 'gen_type'.
[ "Returns", "a", "dataframe", "that", "contains", "a", "column", "'", "gen_type", "'", "." ]
[ "\"\"\"\n Returns a dataframe that contains a column 'gen_type'.\n\n By default 'gen_type' is the aggregation of 'gen_tech' + 'gen_energy_source'\n however this can be overidden in graph_tech_types.csv\n \"\"\"", "# If there's no mapping, we simply make the mapping the sum of both colu...
[ { "param": "self", "type": null }, { "param": "df", "type": "pd.DataFrame" }, { "param": "map_name", "type": null }, { "param": "gen_tech_col", "type": null }, { "param": "energy_source_col", "type": null }, { "param": "drop_previous_col", "type": ...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": "pd.DataFrame", "docstring": null, "docstring_to...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
build_year
<not_specific>
def build_year(self, df, build_year_col="build_year"): """ Replaces all the build years that aren't a period with the value "Pre-existing". """ # Get list of valid periods periods = self.tools.get_dataframe("periods", from_inputs=True)["INVESTMENT_PERIOD"].astype("str") d...
Replaces all the build years that aren't a period with the value "Pre-existing".
Replaces all the build years that aren't a period with the value "Pre-existing".
[ "Replaces", "all", "the", "build", "years", "that", "aren", "'", "t", "a", "period", "with", "the", "value", "\"", "Pre", "-", "existing", "\"", "." ]
def build_year(self, df, build_year_col="build_year"): periods = self.tools.get_dataframe("periods", from_inputs=True)["INVESTMENT_PERIOD"].astype("str") df = df.copy() df[build_year_col] = df[build_year_col].apply( lambda b: str(b) if str(b) in periods.values else "Pre-existing" ...
[ "def", "build_year", "(", "self", ",", "df", ",", "build_year_col", "=", "\"build_year\"", ")", ":", "periods", "=", "self", ".", "tools", ".", "get_dataframe", "(", "\"periods\"", ",", "from_inputs", "=", "True", ")", "[", "\"INVESTMENT_PERIOD\"", "]", ".",...
Replaces all the build years that aren't a period with the value "Pre-existing".
[ "Replaces", "all", "the", "build", "years", "that", "aren", "'", "t", "a", "period", "with", "the", "value", "\"", "Pre", "-", "existing", "\"", "." ]
[ "\"\"\"\n Replaces all the build years that aren't a period with the value \"Pre-existing\".\n \"\"\"", "# Get list of valid periods", "# Make copy to not modify source" ]
[ { "param": "self", "type": null }, { "param": "df", "type": null }, { "param": "build_year_col", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [],...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
load_zone
<not_specific>
def load_zone(self, df, load_zone_col="load_zone"): """ Adds a 'region' column that is usually load_zone's state. 'region' is what comes before the first underscore. If no underscores are present defaults to just using the load_zone. """ df = df.copy() # Don't modify the...
Adds a 'region' column that is usually load_zone's state. 'region' is what comes before the first underscore. If no underscores are present defaults to just using the load_zone.
Adds a 'region' column that is usually load_zone's state. 'region' is what comes before the first underscore. If no underscores are present defaults to just using the load_zone.
[ "Adds", "a", "'", "region", "'", "column", "that", "is", "usually", "load_zone", "'", "s", "state", ".", "'", "region", "'", "is", "what", "comes", "before", "the", "first", "underscore", ".", "If", "no", "underscores", "are", "present", "defaults", "to"...
def load_zone(self, df, load_zone_col="load_zone"): df = df.copy() df["region"] = df[load_zone_col].apply( lambda z: z.partition("_")[0] ) return df
[ "def", "load_zone", "(", "self", ",", "df", ",", "load_zone_col", "=", "\"load_zone\"", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "df", "[", "\"region\"", "]", "=", "df", "[", "load_zone_col", "]", ".", "apply", "(", "lambda", "z", ":", "z"...
Adds a 'region' column that is usually load_zone's state.
[ "Adds", "a", "'", "region", "'", "column", "that", "is", "usually", "load_zone", "'", "s", "state", "." ]
[ "\"\"\"\n Adds a 'region' column that is usually load_zone's state.\n 'region' is what comes before the first underscore. If no underscores are present\n defaults to just using the load_zone.\n \"\"\"", "# Don't modify the source" ]
[ { "param": "self", "type": null }, { "param": "df", "type": null }, { "param": "load_zone_col", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [],...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
_load_dataframe
pd.DataFrame
def _load_dataframe(self, path, dtype=None, **kwargs) -> pd.DataFrame: """ Reads a csv file for every scenario and returns a single dataframe containing the rows from every scenario with a column for the scenario name and index. """ if dtype is None: dtype = {"generat...
Reads a csv file for every scenario and returns a single dataframe containing the rows from every scenario with a column for the scenario name and index.
Reads a csv file for every scenario and returns a single dataframe containing the rows from every scenario with a column for the scenario name and index.
[ "Reads", "a", "csv", "file", "for", "every", "scenario", "and", "returns", "a", "single", "dataframe", "containing", "the", "rows", "from", "every", "scenario", "with", "a", "column", "for", "the", "scenario", "name", "and", "index", "." ]
def _load_dataframe(self, path, dtype=None, **kwargs) -> pd.DataFrame: if dtype is None: dtype = {"generation_project": str, "gen_dbid": str, "GENERATION_PROJECT": str} df_all_scenarios: List[pd.DataFrame] = [] for i, scenario in enumerate(self._scenarios): df = pd.read_c...
[ "def", "_load_dataframe", "(", "self", ",", "path", ",", "dtype", "=", "None", ",", "**", "kwargs", ")", "->", "pd", ".", "DataFrame", ":", "if", "dtype", "is", "None", ":", "dtype", "=", "{", "\"generation_project\"", ":", "str", ",", "\"gen_dbid\"", ...
Reads a csv file for every scenario and returns a single dataframe containing the rows from every scenario with a column for the scenario name and index.
[ "Reads", "a", "csv", "file", "for", "every", "scenario", "and", "returns", "a", "single", "dataframe", "containing", "the", "rows", "from", "every", "scenario", "with", "a", "column", "for", "the", "scenario", "name", "and", "index", "." ]
[ "\"\"\"\n Reads a csv file for every scenario and returns a single dataframe containing\n the rows from every scenario with a column for the scenario name and index.\n \"\"\"", "# Fix: force the datatype to str for some columns to avoid warnings of mismatched types" ]
[ { "param": "self", "type": null }, { "param": "path", "type": null }, { "param": "dtype", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
_create_axes
<not_specific>
def _create_axes(self, num_rows=1, size=(8, 5), ylabel=None, **kwargs): """ Create a set of matplotlib axes """ num_columns = 1 if self._is_multi_scenario_func else self.num_scenarios fig = GraphTools._create_figure( size=(size[0] * num_columns, size[1]), ...
Create a set of matplotlib axes
Create a set of matplotlib axes
[ "Create", "a", "set", "of", "matplotlib", "axes" ]
def _create_axes(self, num_rows=1, size=(8, 5), ylabel=None, **kwargs): num_columns = 1 if self._is_multi_scenario_func else self.num_scenarios fig = GraphTools._create_figure( size=(size[0] * num_columns, size[1]), **kwargs ) ax = fig.subplots(nrows=num_rows, nco...
[ "def", "_create_axes", "(", "self", ",", "num_rows", "=", "1", ",", "size", "=", "(", "8", ",", "5", ")", ",", "ylabel", "=", "None", ",", "**", "kwargs", ")", ":", "num_columns", "=", "1", "if", "self", ".", "_is_multi_scenario_func", "else", "self"...
Create a set of matplotlib axes
[ "Create", "a", "set", "of", "matplotlib", "axes" ]
[ "\"\"\"\n Create a set of matplotlib axes\n \"\"\"", "# Set a title to each subplot" ]
[ { "param": "self", "type": null }, { "param": "num_rows", "type": null }, { "param": "size", "type": null }, { "param": "ylabel", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num_rows", "type": null, "docstring": null, "docstring_tokens...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
save_figure
null
def save_figure(self, fig, filename=None): """ Gets called directly from the code to save a plotnine figure or gets called from within get_figure() """ # Add the figure to the list of figures for that scenario self._figure_handler.add_figure(fig, filename=filename)
Gets called directly from the code to save a plotnine figure or gets called from within get_figure()
Gets called directly from the code to save a plotnine figure or gets called from within get_figure()
[ "Gets", "called", "directly", "from", "the", "code", "to", "save", "a", "plotnine", "figure", "or", "gets", "called", "from", "within", "get_figure", "()" ]
def save_figure(self, fig, filename=None): self._figure_handler.add_figure(fig, filename=filename)
[ "def", "save_figure", "(", "self", ",", "fig", ",", "filename", "=", "None", ")", ":", "self", ".", "_figure_handler", ".", "add_figure", "(", "fig", ",", "filename", "=", "filename", ")" ]
Gets called directly from the code to save a plotnine figure or gets called from within get_figure()
[ "Gets", "called", "directly", "from", "the", "code", "to", "save", "a", "plotnine", "figure", "or", "gets", "called", "from", "within", "get_figure", "()" ]
[ "\"\"\"\n Gets called directly from the code to save a plotnine figure or gets called from within get_figure()\n \"\"\"", "# Add the figure to the list of figures for that scenario" ]
[ { "param": "self", "type": null }, { "param": "fig", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fig", "type": null, "docstring": null, "docstring_tokens": []...
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
read_modules
<not_specific>
def read_modules(scenarios): """Reads all the modules found in modules.txt""" def read_modules_txt(scenario): """Returns a sorted list of all the modules in a run folder (by reading modules.txt)""" with scenario: module_list = get_module_list(include_solve_module=False) retu...
Reads all the modules found in modules.txt
Reads all the modules found in modules.txt
[ "Reads", "all", "the", "modules", "found", "in", "modules", ".", "txt" ]
def read_modules(scenarios): def read_modules_txt(scenario): with scenario: module_list = get_module_list(include_solve_module=False) return np.sort(module_list) scenario_base, other_scenarios = scenarios[0], scenarios[1:] module_names = read_modules_txt(scenario_base) for sc...
[ "def", "read_modules", "(", "scenarios", ")", ":", "def", "read_modules_txt", "(", "scenario", ")", ":", "\"\"\"Returns a sorted list of all the modules in a run folder (by reading modules.txt)\"\"\"", "with", "scenario", ":", "module_list", "=", "get_module_list", "(", "incl...
Reads all the modules found in modules.txt
[ "Reads", "all", "the", "modules", "found", "in", "modules", ".", "txt" ]
[ "\"\"\"Reads all the modules found in modules.txt\"\"\"", "\"\"\"Returns a sorted list of all the modules in a run folder (by reading modules.txt)\"\"\"", "# Split compare_dirs into a base and a list of others", "# Check that all the compare_dirs have equivalent modules.txt" ]
[ { "param": "scenarios", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "scenarios", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ea7360ee74fab7814762314bbe83a16cdf9740ec
staadecker/switch
switch_model/tools/graph/main.py
[ "ECL-2.0", "Apache-2.0" ]
Python
read_modules_txt
<not_specific>
def read_modules_txt(scenario): """Returns a sorted list of all the modules in a run folder (by reading modules.txt)""" with scenario: module_list = get_module_list(include_solve_module=False) return np.sort(module_list)
Returns a sorted list of all the modules in a run folder (by reading modules.txt)
Returns a sorted list of all the modules in a run folder (by reading modules.txt)
[ "Returns", "a", "sorted", "list", "of", "all", "the", "modules", "in", "a", "run", "folder", "(", "by", "reading", "modules", ".", "txt", ")" ]
def read_modules_txt(scenario): with scenario: module_list = get_module_list(include_solve_module=False) return np.sort(module_list)
[ "def", "read_modules_txt", "(", "scenario", ")", ":", "with", "scenario", ":", "module_list", "=", "get_module_list", "(", "include_solve_module", "=", "False", ")", "return", "np", ".", "sort", "(", "module_list", ")" ]
Returns a sorted list of all the modules in a run folder (by reading modules.txt)
[ "Returns", "a", "sorted", "list", "of", "all", "the", "modules", "in", "a", "run", "folder", "(", "by", "reading", "modules", ".", "txt", ")" ]
[ "\"\"\"Returns a sorted list of all the modules in a run folder (by reading modules.txt)\"\"\"" ]
[ { "param": "scenario", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "scenario", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d98ef1124cde5e40a5b5ad7eb364a72ff9b2aaa7
staadecker/switch
switch_model/solve.py
[ "ECL-2.0", "Apache-2.0" ]
Python
warm_start_mip
<not_specific>
def warm_start_mip(instance): """ This function loads the results from a previous run into the Pyomo variables. This allows Gurobi's Mixed Integer Programming algorithm to "warm start" (start closer to the solution). Warm starting only works in Gurobi if the initial values don't violate any constraints ...
This function loads the results from a previous run into the Pyomo variables. This allows Gurobi's Mixed Integer Programming algorithm to "warm start" (start closer to the solution). Warm starting only works in Gurobi if the initial values don't violate any constraints (i.e. valid but not optimal solut...
This function loads the results from a previous run into the Pyomo variables. This allows Gurobi's Mixed Integer Programming algorithm to "warm start" (start closer to the solution). Warm starting only works in Gurobi if the initial values don't violate any constraints .
[ "This", "function", "loads", "the", "results", "from", "a", "previous", "run", "into", "the", "Pyomo", "variables", ".", "This", "allows", "Gurobi", "'", "s", "Mixed", "Integer", "Programming", "algorithm", "to", "\"", "warm", "start", "\"", "(", "start", ...
def warm_start_mip(instance): warm_start_dir = os.path.join(instance.options.warm_start_mip, "outputs") if not os.path.isdir(warm_start_dir): warnings.warn( f"Path {warm_start_dir} does not exist and cannot be used to warm start solver. Warm start skipped.") return for variable i...
[ "def", "warm_start_mip", "(", "instance", ")", ":", "warm_start_dir", "=", "os", ".", "path", ".", "join", "(", "instance", ".", "options", ".", "warm_start_mip", ",", "\"outputs\"", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "warm_start_dir",...
This function loads the results from a previous run into the Pyomo variables.
[ "This", "function", "loads", "the", "results", "from", "a", "previous", "run", "into", "the", "Pyomo", "variables", "." ]
[ "\"\"\"\n This function loads the results from a previous run into the Pyomo variables.\n This allows Gurobi's Mixed Integer Programming algorithm to \"warm start\" (start closer to the solution).\n Warm starting only works in Gurobi if the initial values don't violate any constraints\n (i.e. valid but ...
[ { "param": "instance", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "instance", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d98ef1124cde5e40a5b5ad7eb364a72ff9b2aaa7
staadecker/switch
switch_model/solve.py
[ "ECL-2.0", "Apache-2.0" ]
Python
reload_prior_solution_from_csvs
null
def reload_prior_solution_from_csvs(instance): """ Assign values to all model variables from <variable>.csv files saved after previous solution. (Not currently used.) """ import csv var_objects = instance.component_objects(Var) for var in var_objects: var_file = os.path.join(instance...
Assign values to all model variables from <variable>.csv files saved after previous solution. (Not currently used.)
Assign values to all model variables from .csv files saved after previous solution. (Not currently used.)
[ "Assign", "values", "to", "all", "model", "variables", "from", ".", "csv", "files", "saved", "after", "previous", "solution", ".", "(", "Not", "currently", "used", ".", ")" ]
def reload_prior_solution_from_csvs(instance): import csv var_objects = instance.component_objects(Var) for var in var_objects: var_file = os.path.join(instance.options.outputs_dir, '{}.csv'.format(var.name)) if not os.path.isfile(var_file): raise RuntimeError( "T...
[ "def", "reload_prior_solution_from_csvs", "(", "instance", ")", ":", "import", "csv", "var_objects", "=", "instance", ".", "component_objects", "(", "Var", ")", "for", "var", "in", "var_objects", ":", "var_file", "=", "os", ".", "path", ".", "join", "(", "in...
Assign values to all model variables from <variable>.csv files saved after previous solution.
[ "Assign", "values", "to", "all", "model", "variables", "from", "<variable", ">", ".", "csv", "files", "saved", "after", "previous", "solution", "." ]
[ "\"\"\"\n Assign values to all model variables from <variable>.csv files saved after\n previous solution. (Not currently used.)\n \"\"\"", "# check types of the first tuple of keys for this variable", "# no keys", "# skip headers", "# Variables that are not used in the model end up with no", "# v...
[ { "param": "instance", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "instance", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d98ef1124cde5e40a5b5ad7eb364a72ff9b2aaa7
staadecker/switch
switch_model/solve.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_arguments
null
def define_arguments(argparser): """callback function to define model configuration arguments while the model is built""" # These flags were already processed, we only re-add them here # so that they appear in the help text (switch solve --help) add_pre_module_args(argparser) add_module_args(argpar...
callback function to define model configuration arguments while the model is built
callback function to define model configuration arguments while the model is built
[ "callback", "function", "to", "define", "model", "configuration", "arguments", "while", "the", "model", "is", "built" ]
def define_arguments(argparser): add_pre_module_args(argparser) add_module_args(argparser) add_recommended_args(argparser) argparser.add_argument( "--iterate-list", default=None, help="Text file with a list of modules to iterate until converged (default is iterate.txt); " "e...
[ "def", "define_arguments", "(", "argparser", ")", ":", "add_pre_module_args", "(", "argparser", ")", "add_module_args", "(", "argparser", ")", "add_recommended_args", "(", "argparser", ")", "argparser", ".", "add_argument", "(", "\"--iterate-list\"", ",", "default", ...
callback function to define model configuration arguments while the model is built
[ "callback", "function", "to", "define", "model", "configuration", "arguments", "while", "the", "model", "is", "built" ]
[ "\"\"\"callback function to define model configuration arguments while the model is built\"\"\"", "# These flags were already processed, we only re-add them here", "# so that they appear in the help text (switch solve --help)", "# iteration options", "# scenario information", "# note: pyomo has a --solver...
[ { "param": "argparser", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argparser", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f99975f78deaab1e34b6aa2688812038d6802613
staadecker/switch
switch_model/generators/extensions/hydro_simple.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
null
def define_components(mod): """ HYDRO_GENS is the set of dispatchable hydro projects. This is a subet of GENERATION_PROJECTS, and is determined by the inputs file hydro_timeseries.csv. Members of this set can be called either g, or hydro_g. HYDRO_TS is the set of hydro timeseries over which the ave...
HYDRO_GENS is the set of dispatchable hydro projects. This is a subet of GENERATION_PROJECTS, and is determined by the inputs file hydro_timeseries.csv. Members of this set can be called either g, or hydro_g. HYDRO_TS is the set of hydro timeseries over which the average flow constraint is defined. ...
HYDRO_GENS is the set of dispatchable hydro projects. This is a subet of GENERATION_PROJECTS, and is determined by the inputs file hydro_timeseries.csv. Members of this set can be called either g, or hydro_g. HYDRO_TS is the set of hydro timeseries over which the average flow constraint is defined. These hydro timeser...
[ "HYDRO_GENS", "is", "the", "set", "of", "dispatchable", "hydro", "projects", ".", "This", "is", "a", "subet", "of", "GENERATION_PROJECTS", "and", "is", "determined", "by", "the", "inputs", "file", "hydro_timeseries", ".", "csv", ".", "Members", "of", "this", ...
def define_components(mod): mod.tp_to_hts = Param( mod.TIMEPOINTS, input_file='hydro_timepoints.csv', default=lambda m, tp: m.tp_ts[tp], doc="Mapping of timepoints to a hydro series.", within=Any ) mod.HYDRO_TS = Set( dimen=1, ordered=False, in...
[ "def", "define_components", "(", "mod", ")", ":", "mod", ".", "tp_to_hts", "=", "Param", "(", "mod", ".", "TIMEPOINTS", ",", "input_file", "=", "'hydro_timepoints.csv'", ",", "default", "=", "lambda", "m", ",", "tp", ":", "m", ".", "tp_ts", "[", "tp", ...
HYDRO_GENS is the set of dispatchable hydro projects.
[ "HYDRO_GENS", "is", "the", "set", "of", "dispatchable", "hydro", "projects", "." ]
[ "\"\"\"\n HYDRO_GENS is the set of dispatchable hydro projects. This is a subet\n of GENERATION_PROJECTS, and is determined by the inputs file hydro_timeseries.csv.\n Members of this set can be called either g, or hydro_g.\n\n HYDRO_TS is the set of hydro timeseries over which the average flow constrain...
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2a75c92d09d6c8a82f7bbb99d125e8dbd05439e1
staadecker/switch
switch_model/wecc/get_inputs/register_post_process.py
[ "ECL-2.0", "Apache-2.0" ]
Python
register_post_process
<not_specific>
def register_post_process( msg=None, ): """ Decorator that should be used to register a post-processing step. @param msg The message to display while running this step. @param enabled Whether we should be using this step. @param name Name of the post processing step and of the config section ...
Decorator that should be used to register a post-processing step. @param msg The message to display while running this step. @param enabled Whether we should be using this step. @param name Name of the post processing step and of the config section @param only_with_config if True the step will onl...
Decorator that should be used to register a post-processing step. @param msg The message to display while running this step. @param enabled Whether we should be using this step. @param name Name of the post processing step and of the config section @param only_with_config if True the step will only run if 'name' exists...
[ "Decorator", "that", "should", "be", "used", "to", "register", "a", "post", "-", "processing", "step", ".", "@param", "msg", "The", "message", "to", "display", "while", "running", "this", "step", ".", "@param", "enabled", "Whether", "we", "should", "be", "...
def register_post_process( msg=None, ): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): message = msg if message is None: message = f"Running {func.__name__}" print(f"\t{message}...") func(*args, **kwargs) re...
[ "def", "register_post_process", "(", "msg", "=", "None", ",", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "message", "=", "msg", "if", "mess...
Decorator that should be used to register a post-processing step.
[ "Decorator", "that", "should", "be", "used", "to", "register", "a", "post", "-", "processing", "step", "." ]
[ "\"\"\"\n Decorator that should be used to register a post-processing step.\n\n @param msg The message to display while running this step.\n @param enabled Whether we should be using this step.\n @param name Name of the post processing step and of the config section\n @param only_with_config if True ...
[ { "param": "msg", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "msg", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2a75c92d09d6c8a82f7bbb99d125e8dbd05439e1
staadecker/switch
switch_model/wecc/get_inputs/register_post_process.py
[ "ECL-2.0", "Apache-2.0" ]
Python
run_post_process
null
def run_post_process(config, step_name=None): """ Run the post processing steps. @param config The values from config.yaml (already parsed) @param step_name if step_name is None we run all the steps. If it's specified we only run that step. """ if step_name is None: for name, func in so...
Run the post processing steps. @param config The values from config.yaml (already parsed) @param step_name if step_name is None we run all the steps. If it's specified we only run that step.
Run the post processing steps. @param config The values from config.yaml (already parsed) @param step_name if step_name is None we run all the steps. If it's specified we only run that step.
[ "Run", "the", "post", "processing", "steps", ".", "@param", "config", "The", "values", "from", "config", ".", "yaml", "(", "already", "parsed", ")", "@param", "step_name", "if", "step_name", "is", "None", "we", "run", "all", "the", "steps", ".", "If", "i...
def run_post_process(config, step_name=None): if step_name is None: for name, func in sorted( _registered_steps.items(), key=lambda s: s[1].priority ): func(config.get(name, None)) else: _registered_steps[step_name](config.get(step_name, None))
[ "def", "run_post_process", "(", "config", ",", "step_name", "=", "None", ")", ":", "if", "step_name", "is", "None", ":", "for", "name", ",", "func", "in", "sorted", "(", "_registered_steps", ".", "items", "(", ")", ",", "key", "=", "lambda", "s", ":", ...
Run the post processing steps.
[ "Run", "the", "post", "processing", "steps", "." ]
[ "\"\"\"\n Run the post processing steps.\n\n @param config The values from config.yaml (already parsed)\n @param step_name if step_name is None we run all the steps. If it's specified we only run that step.\n \"\"\"" ]
[ { "param": "config", "type": null }, { "param": "step_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "config", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "step_name", "type": null, "docstring": null, "docstring_tok...
6dbd4894bbbfabff9e8a201eb893258a83adf6c1
staadecker/switch
switch_model/wecc/utilities.py
[ "ECL-2.0", "Apache-2.0" ]
Python
load_config
<not_specific>
def load_config(): """Read the config.yaml configuration file""" if not os.path.isfile("config.yaml"): raise Exception("config.yaml does not exist. Try running 'switch new scenario' to auto-create it.") with open("config.yaml") as f: return yaml.load(f, Loader=yaml.FullLoader)
Read the config.yaml configuration file
Read the config.yaml configuration file
[ "Read", "the", "config", ".", "yaml", "configuration", "file" ]
def load_config(): if not os.path.isfile("config.yaml"): raise Exception("config.yaml does not exist. Try running 'switch new scenario' to auto-create it.") with open("config.yaml") as f: return yaml.load(f, Loader=yaml.FullLoader)
[ "def", "load_config", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "\"config.yaml\"", ")", ":", "raise", "Exception", "(", "\"config.yaml does not exist. Try running 'switch new scenario' to auto-create it.\"", ")", "with", "open", "(", "\"config...
Read the config.yaml configuration file
[ "Read", "the", "config", ".", "yaml", "configuration", "file" ]
[ "\"\"\"Read the config.yaml configuration file\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
6dbd4894bbbfabff9e8a201eb893258a83adf6c1
staadecker/switch
switch_model/wecc/utilities.py
[ "ECL-2.0", "Apache-2.0" ]
Python
connect
<not_specific>
def connect(schema="switch", connection_env_var="DB_URL"): """Connects to the Postgres DB This function uses the environment variables to get the URL to connect to the DB. Both password and user should be passed directly on the URL for safety purposes. Parameters ---------- schema: str Schema ...
Connects to the Postgres DB This function uses the environment variables to get the URL to connect to the DB. Both password and user should be passed directly on the URL for safety purposes. Parameters ---------- schema: str Schema of the DB to look for tables. Default is switch connection_env...
Connects to the Postgres DB This function uses the environment variables to get the URL to connect to the DB. Both password and user should be passed directly on the URL for safety purposes. Parameters str Schema of the DB to look for tables. Default is switch connection_env_var: The environment variable to use as th...
[ "Connects", "to", "the", "Postgres", "DB", "This", "function", "uses", "the", "environment", "variables", "to", "get", "the", "URL", "to", "connect", "to", "the", "DB", ".", "Both", "password", "and", "user", "should", "be", "passed", "directly", "on", "th...
def connect(schema="switch", connection_env_var="DB_URL"): load_dotenv() db_url = os.getenv(connection_env_var) if db_url is None: raise Exception( f"Please set the environment variable '{connection_env_var}' to the database URL." "The format is normally: postgresql://<user>:...
[ "def", "connect", "(", "schema", "=", "\"switch\"", ",", "connection_env_var", "=", "\"DB_URL\"", ")", ":", "load_dotenv", "(", ")", "db_url", "=", "os", ".", "getenv", "(", "connection_env_var", ")", "if", "db_url", "is", "None", ":", "raise", "Exception", ...
Connects to the Postgres DB This function uses the environment variables to get the URL to connect to the DB.
[ "Connects", "to", "the", "Postgres", "DB", "This", "function", "uses", "the", "environment", "variables", "to", "get", "the", "URL", "to", "connect", "to", "the", "DB", "." ]
[ "\"\"\"Connects to the Postgres DB\n\n This function uses the environment variables to get the URL to connect to the DB. Both\n password and user should be passed directly on the URL for safety purposes.\n\n Parameters\n ----------\n schema: str Schema of the DB to look for tables. Default is switch\...
[ { "param": "schema", "type": null }, { "param": "connection_env_var", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "schema", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "connection_env_var", "type": null, "docstring": null, "docs...
bf56c28eeddcb951682a16c43c505827f0229dcf
staadecker/switch
switch_model/energy_sources/fuel_costs/simple.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
<not_specific>
def define_components(mod): """ Augments a Pyomo abstract model object with sets and parameters to describe simple fuel costs. Unless otherwise stated, each set and parameter is mandatory. Unless otherwise specified, all dollar values are real dollars in BASE_YEAR. ZONE_FUEL_PERIODS is a set t...
Augments a Pyomo abstract model object with sets and parameters to describe simple fuel costs. Unless otherwise stated, each set and parameter is mandatory. Unless otherwise specified, all dollar values are real dollars in BASE_YEAR. ZONE_FUEL_PERIODS is a set that describes fuel availability. Ea...
Augments a Pyomo abstract model object with sets and parameters to describe simple fuel costs. Unless otherwise stated, each set and parameter is mandatory. Unless otherwise specified, all dollar values are real dollars in BASE_YEAR. ZONE_FUEL_PERIODS is a set that describes fuel availability. Each element of the set ...
[ "Augments", "a", "Pyomo", "abstract", "model", "object", "with", "sets", "and", "parameters", "to", "describe", "simple", "fuel", "costs", ".", "Unless", "otherwise", "stated", "each", "set", "and", "parameter", "is", "mandatory", ".", "Unless", "otherwise", "...
def define_components(mod): mod.ZONE_FUEL_PERIODS = Set( dimen=3, input_file="fuel_cost.csv", validate=lambda m, z, f, p: ( z in m.LOAD_ZONES and f in m.FUELS and p in m.PERIODS)) mod.fuel_cost = Param( mod.ZONE_FUEL_PERIODS, input_file...
[ "def", "define_components", "(", "mod", ")", ":", "mod", ".", "ZONE_FUEL_PERIODS", "=", "Set", "(", "dimen", "=", "3", ",", "input_file", "=", "\"fuel_cost.csv\"", ",", "validate", "=", "lambda", "m", ",", "z", ",", "f", ",", "p", ":", "(", "z", "in"...
Augments a Pyomo abstract model object with sets and parameters to describe simple fuel costs.
[ "Augments", "a", "Pyomo", "abstract", "model", "object", "with", "sets", "and", "parameters", "to", "describe", "simple", "fuel", "costs", "." ]
[ "\"\"\"\n\n Augments a Pyomo abstract model object with sets and parameters to\n describe simple fuel costs. Unless otherwise stated, each set and\n parameter is mandatory. Unless otherwise specified, all dollar\n values are real dollars in BASE_YEAR.\n\n ZONE_FUEL_PERIODS is a set that describes fue...
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
77633d3b259172ee85d3c8dd1d2034ba553674ff
staadecker/switch
switch_model/wecc/pyspsolutionwritertemplate.py
[ "ECL-2.0", "Apache-2.0" ]
Python
write_csv_soln
null
def write_csv_soln(scenario_tree, output_file_prefix): """ Write the csv solution to a file. Args: scenario_tree: a scenario tree object populated with a solution. output_file_prefix: a string to indicate the file names for output. output_file_prefix + ".csv" ...
Write the csv solution to a file. Args: scenario_tree: a scenario tree object populated with a solution. output_file_prefix: a string to indicate the file names for output. output_file_prefix + ".csv" output_file_prefix + "_StageCostDetail.c...
Write the csv solution to a file. Args: scenario_tree: a scenario tree object populated with a solution. output_file_prefix: a string to indicate the file names for output.
[ "Write", "the", "csv", "solution", "to", "a", "file", ".", "Args", ":", "scenario_tree", ":", "a", "scenario", "tree", "object", "populated", "with", "a", "solution", ".", "output_file_prefix", ":", "a", "string", "to", "indicate", "the", "file", "names", ...
def write_csv_soln(scenario_tree, output_file_prefix): if isinstance(scenario_tree, ScenarioTree): print("Yay.") for scenario_instance in scenario_tree._scenarios: switch_model.utilities.post_solve(scenario_instance._instance, outputs_dir=os.path.join('outputs', scenario_instance.name)) ...
[ "def", "write_csv_soln", "(", "scenario_tree", ",", "output_file_prefix", ")", ":", "if", "isinstance", "(", "scenario_tree", ",", "ScenarioTree", ")", ":", "print", "(", "\"Yay.\"", ")", "for", "scenario_instance", "in", "scenario_tree", ".", "_scenarios", ":", ...
Write the csv solution to a file.
[ "Write", "the", "csv", "solution", "to", "a", "file", "." ]
[ "\"\"\"\n Write the csv solution to a file.\n Args: scenario_tree: a scenario tree object populated with a solution.\n output_file_prefix: a string to indicate the file names for output.\n output_file_prefix + \".csv\"\n output_file_prefix + \...
[ { "param": "scenario_tree", "type": null }, { "param": "output_file_prefix", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "scenario_tree", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "output_file_prefix", "type": null, "docstring": null, ...
cb8eaa5b8c6d8a6b3f0ebaa8b3cda8ff67922769
staadecker/switch
switch_model/generators/extensions/storage.py
[ "ECL-2.0", "Apache-2.0" ]
Python
post_solve
null
def post_solve(instance, outdir): """ Export storage build information to storage_builds.csv, storage capacity to storage_capacity.csv, and storage dispatch info to storage_dispatch.csv """ import switch_model.reporting as reporting # Write how much is built each build year for each project ...
Export storage build information to storage_builds.csv, storage capacity to storage_capacity.csv, and storage dispatch info to storage_dispatch.csv
Export storage build information to storage_builds.csv, storage capacity to storage_capacity.csv, and storage dispatch info to storage_dispatch.csv
[ "Export", "storage", "build", "information", "to", "storage_builds", ".", "csv", "storage", "capacity", "to", "storage_capacity", ".", "csv", "and", "storage", "dispatch", "info", "to", "storage_dispatch", ".", "csv" ]
def post_solve(instance, outdir): import switch_model.reporting as reporting reporting.write_table( instance, instance.STORAGE_GEN_BLD_YRS, output_file=os.path.join(outdir, "storage_builds.csv"), headings=("generation_project", "build_year", "load_zone", "IncrementalPow...
[ "def", "post_solve", "(", "instance", ",", "outdir", ")", ":", "import", "switch_model", ".", "reporting", "as", "reporting", "reporting", ".", "write_table", "(", "instance", ",", "instance", ".", "STORAGE_GEN_BLD_YRS", ",", "output_file", "=", "os", ".", "pa...
Export storage build information to storage_builds.csv, storage capacity to storage_capacity.csv, and storage dispatch info to storage_dispatch.csv
[ "Export", "storage", "build", "information", "to", "storage_builds", ".", "csv", "storage", "capacity", "to", "storage_capacity", ".", "csv", "and", "storage", "dispatch", "info", "to", "storage_dispatch", ".", "csv" ]
[ "\"\"\"\n Export storage build information to storage_builds.csv,\n storage capacity to storage_capacity.csv, and storage\n dispatch info to storage_dispatch.csv\n \"\"\"", "# Write how much is built each build year for each project to storage_builds.csv", "# Write the total capacity for each projec...
[ { "param": "instance", "type": null }, { "param": "outdir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "instance", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outdir", "type": null, "docstring": null, "docstring_toke...
cb8eaa5b8c6d8a6b3f0ebaa8b3cda8ff67922769
staadecker/switch
switch_model/generators/extensions/storage.py
[ "ECL-2.0", "Apache-2.0" ]
Python
graph_buildout
null
def graph_buildout(tools): """ Create graphs relating to the storage that has been built """ df = tools.get_dataframe("storage_builds.csv") df = tools.transform.load_zone(df) # Filter out rows where there's no power built df = df[df["IncrementalPowerCapacityMW"] != 0] df["duration"] = df...
Create graphs relating to the storage that has been built
Create graphs relating to the storage that has been built
[ "Create", "graphs", "relating", "to", "the", "storage", "that", "has", "been", "built" ]
def graph_buildout(tools): df = tools.get_dataframe("storage_builds.csv") df = tools.transform.load_zone(df) df = df[df["IncrementalPowerCapacityMW"] != 0] df["duration"] = df["IncrementalEnergyCapacityMWh"] / df["IncrementalPowerCapacityMW"] df["power"] = df["IncrementalPowerCapacityMW"] / 1e3 ...
[ "def", "graph_buildout", "(", "tools", ")", ":", "df", "=", "tools", ".", "get_dataframe", "(", "\"storage_builds.csv\"", ")", "df", "=", "tools", ".", "transform", ".", "load_zone", "(", "df", ")", "df", "=", "df", "[", "df", "[", "\"IncrementalPowerCapac...
Create graphs relating to the storage that has been built
[ "Create", "graphs", "relating", "to", "the", "storage", "that", "has", "been", "built" ]
[ "\"\"\"\n Create graphs relating to the storage that has been built\n \"\"\"", "# Filter out rows where there's no power built" ]
[ { "param": "tools", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tools", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
07e92ef7b6f9e46035954753aeb17c4a7d9e7e62
staadecker/switch
switch_model/balancing/load_zones.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
null
def define_components(mod): """ Augments a Pyomo abstract model object with sets and parameters that describe load zones and associated power balance equations. Unless otherwise stated, each set and parameter is mandatory. LOAD_ZONES is the set of load zones. Each zone is effectively modeled as a ...
Augments a Pyomo abstract model object with sets and parameters that describe load zones and associated power balance equations. Unless otherwise stated, each set and parameter is mandatory. LOAD_ZONES is the set of load zones. Each zone is effectively modeled as a single bus connected to the inte...
Augments a Pyomo abstract model object with sets and parameters that describe load zones and associated power balance equations. Unless otherwise stated, each set and parameter is mandatory. LOAD_ZONES is the set of load zones. Each zone is effectively modeled as a single bus connected to the inter-zonal transmission ...
[ "Augments", "a", "Pyomo", "abstract", "model", "object", "with", "sets", "and", "parameters", "that", "describe", "load", "zones", "and", "associated", "power", "balance", "equations", ".", "Unless", "otherwise", "stated", "each", "set", "and", "parameter", "is"...
def define_components(mod): mod.LOAD_ZONES = Set(dimen=1, input_file='load_zones.csv') mod.ZONE_TIMEPOINTS = Set(dimen=2, initialize=lambda m: m.LOAD_ZONES * m.TIMEPOINTS, doc="The cross product of load zones and timepoints, used for indexing.") mod.zone_demand_mw = Param( mod.ZONE_T...
[ "def", "define_components", "(", "mod", ")", ":", "mod", ".", "LOAD_ZONES", "=", "Set", "(", "dimen", "=", "1", ",", "input_file", "=", "'load_zones.csv'", ")", "mod", ".", "ZONE_TIMEPOINTS", "=", "Set", "(", "dimen", "=", "2", ",", "initialize", "=", ...
Augments a Pyomo abstract model object with sets and parameters that describe load zones and associated power balance equations.
[ "Augments", "a", "Pyomo", "abstract", "model", "object", "with", "sets", "and", "parameters", "that", "describe", "load", "zones", "and", "associated", "power", "balance", "equations", "." ]
[ "\"\"\"\n Augments a Pyomo abstract model object with sets and parameters that\n describe load zones and associated power balance equations. Unless\n otherwise stated, each set and parameter is mandatory.\n\n LOAD_ZONES is the set of load zones. Each zone is effectively modeled as a\n single bus conn...
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
07e92ef7b6f9e46035954753aeb17c4a7d9e7e62
staadecker/switch
switch_model/balancing/load_zones.py
[ "ECL-2.0", "Apache-2.0" ]
Python
post_solve
<not_specific>
def post_solve(instance, outdir): """ Exports load_balance.csv, load_balance_annual_zonal.csv, and load_balance_annual.csv. Each component registered with Zone_Power_Injections and Zone_Power_Withdrawals will become a column in these .csv files. As such, each column represents a power injection or w...
Exports load_balance.csv, load_balance_annual_zonal.csv, and load_balance_annual.csv. Each component registered with Zone_Power_Injections and Zone_Power_Withdrawals will become a column in these .csv files. As such, each column represents a power injection or withdrawal and the sum of across all colum...
load_balance.csv contains the energy balance terms for for every zone and timepoint. We also include a column called normalized_energy_balance_duals_dollar_per_mwh that is a proxy for the locational marginal pricing (LMP). This value represents the incremental cost per hour to increase the demand by 1 MW (or equivale...
[ "load_balance", ".", "csv", "contains", "the", "energy", "balance", "terms", "for", "for", "every", "zone", "and", "timepoint", ".", "We", "also", "include", "a", "column", "called", "normalized_energy_balance_duals_dollar_per_mwh", "that", "is", "a", "proxy", "fo...
def post_solve(instance, outdir): write_table( instance, instance.LOAD_ZONES, instance.TIMEPOINTS, output_file=os.path.join(outdir, "load_balance.csv"), headings=("load_zone", "timestamp", "normalized_energy_balance_duals_dollar_per_mwh",) + tuple( instance.Zone_Power_Injections ...
[ "def", "post_solve", "(", "instance", ",", "outdir", ")", ":", "write_table", "(", "instance", ",", "instance", ".", "LOAD_ZONES", ",", "instance", ".", "TIMEPOINTS", ",", "output_file", "=", "os", ".", "path", ".", "join", "(", "outdir", ",", "\"load_bala...
Exports load_balance.csv, load_balance_annual_zonal.csv, and load_balance_annual.csv.
[ "Exports", "load_balance", ".", "csv", "load_balance_annual_zonal", ".", "csv", "and", "load_balance_annual", ".", "csv", "." ]
[ "\"\"\"\n Exports load_balance.csv, load_balance_annual_zonal.csv, and load_balance_annual.csv.\n Each component registered with Zone_Power_Injections and Zone_Power_Withdrawals will\n become a column in these .csv files. As such, each column represents a power injection\n or withdrawal and the sum of a...
[ { "param": "instance", "type": null }, { "param": "outdir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "instance", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outdir", "type": null, "docstring": null, "docstring_toke...
aaae071da18289fa859f311c61b90b8ee0a8e186
staadecker/switch
switch_model/balancing/planning_reserves.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_dynamic_lists
null
def define_dynamic_lists(model): """ CAPACITY_FOR_RESERVES is a list of model components than can contribute to satisfying planning reserve requirements. REQUIREMENTS_FOR_CAPACITY_RESERVES is a corresponding list of model components that contribute to planning reserve requirements. All compone...
CAPACITY_FOR_RESERVES is a list of model components than can contribute to satisfying planning reserve requirements. REQUIREMENTS_FOR_CAPACITY_RESERVES is a corresponding list of model components that contribute to planning reserve requirements. All components of each list should be indexed by pl...
CAPACITY_FOR_RESERVES is a list of model components than can contribute to satisfying planning reserve requirements. REQUIREMENTS_FOR_CAPACITY_RESERVES is a corresponding list of model components that contribute to planning reserve requirements. All components of each list should be indexed by planning reserve requir...
[ "CAPACITY_FOR_RESERVES", "is", "a", "list", "of", "model", "components", "than", "can", "contribute", "to", "satisfying", "planning", "reserve", "requirements", ".", "REQUIREMENTS_FOR_CAPACITY_RESERVES", "is", "a", "corresponding", "list", "of", "model", "components", ...
def define_dynamic_lists(model): model.CAPACITY_FOR_RESERVES = [] model.REQUIREMENTS_FOR_CAPACITY_RESERVES = []
[ "def", "define_dynamic_lists", "(", "model", ")", ":", "model", ".", "CAPACITY_FOR_RESERVES", "=", "[", "]", "model", ".", "REQUIREMENTS_FOR_CAPACITY_RESERVES", "=", "[", "]" ]
CAPACITY_FOR_RESERVES is a list of model components than can contribute to satisfying planning reserve requirements.
[ "CAPACITY_FOR_RESERVES", "is", "a", "list", "of", "model", "components", "than", "can", "contribute", "to", "satisfying", "planning", "reserve", "requirements", "." ]
[ "\"\"\"\n CAPACITY_FOR_RESERVES is a list of model components than can contribute\n to satisfying planning reserve requirements.\n\n REQUIREMENTS_FOR_CAPACITY_RESERVES is a corresponding list of model\n components that contribute to planning reserve requirements.\n\n All components of each list shoul...
[ { "param": "model", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aaae071da18289fa859f311c61b90b8ee0a8e186
staadecker/switch
switch_model/balancing/planning_reserves.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
<not_specific>
def define_components(model): """ PLANNING_RESERVE_REQUIREMENTS is the set of planning reserve requirements. Each planning reserve requirement specifies a certain capacity reserve margin be enforced over a certain geographic area in either peak load conditions or in every timepoint. Where specified,...
PLANNING_RESERVE_REQUIREMENTS is the set of planning reserve requirements. Each planning reserve requirement specifies a certain capacity reserve margin be enforced over a certain geographic area in either peak load conditions or in every timepoint. Where specified, planning reserve requirements ar...
PLANNING_RESERVE_REQUIREMENTS is the set of planning reserve requirements. Each planning reserve requirement specifies a certain capacity reserve margin be enforced over a certain geographic area in either peak load conditions or in every timepoint. Where specified, planning reserve requirements are enforced in every i...
[ "PLANNING_RESERVE_REQUIREMENTS", "is", "the", "set", "of", "planning", "reserve", "requirements", ".", "Each", "planning", "reserve", "requirement", "specifies", "a", "certain", "capacity", "reserve", "margin", "be", "enforced", "over", "a", "certain", "geographic", ...
def define_components(model): model.PLANNING_RESERVE_REQUIREMENTS = Set( doc="Areas and times where planning reserve margins are specified.", input_file='planning_reserve_requirements.csv', dimen=1 ) model.PRR_ZONES = Set( dimen=2, input_file='planning_reserve_require...
[ "def", "define_components", "(", "model", ")", ":", "model", ".", "PLANNING_RESERVE_REQUIREMENTS", "=", "Set", "(", "doc", "=", "\"Areas and times where planning reserve margins are specified.\"", ",", "input_file", "=", "'planning_reserve_requirements.csv'", ",", "dimen", ...
PLANNING_RESERVE_REQUIREMENTS is the set of planning reserve requirements.
[ "PLANNING_RESERVE_REQUIREMENTS", "is", "the", "set", "of", "planning", "reserve", "requirements", "." ]
[ "\"\"\"\n PLANNING_RESERVE_REQUIREMENTS is the set of planning reserve requirements.\n Each planning reserve requirement specifies a certain capacity reserve\n margin be enforced over a certain geographic area in either peak load\n conditions or in every timepoint. Where specified, planning reserve\n ...
[ { "param": "model", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
75cf2334f3303beba9a1519071eb192c021734d2
staadecker/switch
switch_model/utilities/gurobi_aug.py
[ "ECL-2.0", "Apache-2.0" ]
Python
save_component
null
def save_component(self, component, val): """Add a Pyomo Component (e.g. Variable Data) to our object for later pickling""" self._names[self._next_index] = component.getname(fully_qualified=True, name_buffer=self._names_buffer) self._vals[self._next_index] = val self._next_index += 1
Add a Pyomo Component (e.g. Variable Data) to our object for later pickling
Add a Pyomo Component to our object for later pickling
[ "Add", "a", "Pyomo", "Component", "to", "our", "object", "for", "later", "pickling" ]
def save_component(self, component, val): self._names[self._next_index] = component.getname(fully_qualified=True, name_buffer=self._names_buffer) self._vals[self._next_index] = val self._next_index += 1
[ "def", "save_component", "(", "self", ",", "component", ",", "val", ")", ":", "self", ".", "_names", "[", "self", ".", "_next_index", "]", "=", "component", ".", "getname", "(", "fully_qualified", "=", "True", ",", "name_buffer", "=", "self", ".", "_name...
Add a Pyomo Component (e.g.
[ "Add", "a", "Pyomo", "Component", "(", "e", ".", "g", "." ]
[ "\"\"\"Add a Pyomo Component (e.g. Variable Data) to our object for later pickling\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "component", "type": null }, { "param": "val", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "component", "type": null, "docstring": null, "docstring_token...
75cf2334f3303beba9a1519071eb192c021734d2
staadecker/switch
switch_model/utilities/gurobi_aug.py
[ "ECL-2.0", "Apache-2.0" ]
Python
_get_dict
<not_specific>
def _get_dict(self): """Creates a dictionary based on the _names and _vals arrays.""" if self._dict is None: self._dict = {n: v for n, v in zip(self._names, self._vals)} return self._dict
Creates a dictionary based on the _names and _vals arrays.
Creates a dictionary based on the _names and _vals arrays.
[ "Creates", "a", "dictionary", "based", "on", "the", "_names", "and", "_vals", "arrays", "." ]
def _get_dict(self): if self._dict is None: self._dict = {n: v for n, v in zip(self._names, self._vals)} return self._dict
[ "def", "_get_dict", "(", "self", ")", ":", "if", "self", ".", "_dict", "is", "None", ":", "self", ".", "_dict", "=", "{", "n", ":", "v", "for", "n", ",", "v", "in", "zip", "(", "self", ".", "_names", ",", "self", ".", "_vals", ")", "}", "retu...
Creates a dictionary based on the _names and _vals arrays.
[ "Creates", "a", "dictionary", "based", "on", "the", "_names", "and", "_vals", "arrays", "." ]
[ "\"\"\"Creates a dictionary based on the _names and _vals arrays.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
75cf2334f3303beba9a1519071eb192c021734d2
staadecker/switch
switch_model/utilities/gurobi_aug.py
[ "ECL-2.0", "Apache-2.0" ]
Python
_presolve
<not_specific>
def _presolve(self, *args, **kwds): """Allows three additional parameters to be specified when calling solve() @param write_warm_start: file path of where the output warm start pickle file should be written @param read_warm_start: file path of where to read the input warm start pickle file ...
Allows three additional parameters to be specified when calling solve() @param write_warm_start: file path of where the output warm start pickle file should be written @param read_warm_start: file path of where to read the input warm start pickle file @param save_c_v_basis: If true, we save the...
Allows three additional parameters to be specified when calling solve()
[ "Allows", "three", "additional", "parameters", "to", "be", "specified", "when", "calling", "solve", "()" ]
def _presolve(self, *args, **kwds): self._write_warm_start = kwds.pop("write_warm_start", None) self._read_warm_start = kwds.pop("read_warm_start", None) self._save_c_v_basis = kwds.pop("save_c_v_basis", None) return super(GurobiAugmented, self)._presolve(*args, **kwds)
[ "def", "_presolve", "(", "self", ",", "*", "args", ",", "**", "kwds", ")", ":", "self", ".", "_write_warm_start", "=", "kwds", ".", "pop", "(", "\"write_warm_start\"", ",", "None", ")", "self", ".", "_read_warm_start", "=", "kwds", ".", "pop", "(", "\"...
Allows three additional parameters to be specified when calling solve()
[ "Allows", "three", "additional", "parameters", "to", "be", "specified", "when", "calling", "solve", "()" ]
[ "\"\"\"Allows three additional parameters to be specified when calling solve()\n\n @param write_warm_start: file path of where the output warm start pickle file should be written\n @param read_warm_start: file path of where to read the input warm start pickle file\n @param save_c_v_basis: If tr...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [ { "identifier": "write_warm_start", "type": null, "docstri...
75cf2334f3303beba9a1519071eb192c021734d2
staadecker/switch
switch_model/utilities/gurobi_aug.py
[ "ECL-2.0", "Apache-2.0" ]
Python
_warm_start
<not_specific>
def _warm_start(self): """Override the default _warm_start function that only works for MIP.""" if self._solver_model.IsMIP: return super(GurobiAugmented, self)._warm_start() time = StepTimer(msg="Loading warm start data...") if self._read_warm_start is None: rai...
Override the default _warm_start function that only works for MIP.
Override the default _warm_start function that only works for MIP.
[ "Override", "the", "default", "_warm_start", "function", "that", "only", "works", "for", "MIP", "." ]
def _warm_start(self): if self._solver_model.IsMIP: return super(GurobiAugmented, self)._warm_start() time = StepTimer(msg="Loading warm start data...") if self._read_warm_start is None: raise Exception("Must specify warm_start_in= when running solve()") self._upd...
[ "def", "_warm_start", "(", "self", ")", ":", "if", "self", ".", "_solver_model", ".", "IsMIP", ":", "return", "super", "(", "GurobiAugmented", ",", "self", ")", ".", "_warm_start", "(", ")", "time", "=", "StepTimer", "(", "msg", "=", "\"Loading warm start ...
Override the default _warm_start function that only works for MIP.
[ "Override", "the", "default", "_warm_start", "function", "that", "only", "works", "for", "MIP", "." ]
[ "\"\"\"Override the default _warm_start function that only works for MIP.\"\"\"", "# For some reason this is required. Without it warnings get thrown.", "# It seems like to set VBasis/CBasis the variables needs to already be in", "# the Gurobi model (hence why we need to call update()).", "# Load the basis ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
75cf2334f3303beba9a1519071eb192c021734d2
staadecker/switch
switch_model/utilities/gurobi_aug.py
[ "ECL-2.0", "Apache-2.0" ]
Python
_postsolve
<not_specific>
def _postsolve(self): """ Called after solving. Add option to output the VBasis/CBasis information to a pickle file. """ results = super(GurobiAugmented, self)._postsolve() if self._write_warm_start is not None: if self._solver_model.IsMIP: warnings.wa...
Called after solving. Add option to output the VBasis/CBasis information to a pickle file.
Called after solving. Add option to output the VBasis/CBasis information to a pickle file.
[ "Called", "after", "solving", ".", "Add", "option", "to", "output", "the", "VBasis", "/", "CBasis", "information", "to", "a", "pickle", "file", "." ]
def _postsolve(self): results = super(GurobiAugmented, self)._postsolve() if self._write_warm_start is not None: if self._solver_model.IsMIP: warnings.warn("--save-warm-start doesn't work for MIP models. Not creating a .pickle file.") else: timer =...
[ "def", "_postsolve", "(", "self", ")", ":", "results", "=", "super", "(", "GurobiAugmented", ",", "self", ")", ".", "_postsolve", "(", ")", "if", "self", ".", "_write_warm_start", "is", "not", "None", ":", "if", "self", ".", "_solver_model", ".", "IsMIP"...
Called after solving.
[ "Called", "after", "solving", "." ]
[ "\"\"\"\n Called after solving. Add option to output the VBasis/CBasis information to a pickle file.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
75cf2334f3303beba9a1519071eb192c021734d2
staadecker/switch
switch_model/utilities/gurobi_aug.py
[ "ECL-2.0", "Apache-2.0" ]
Python
_save_warm_start
<not_specific>
def _save_warm_start(self, save_c_v_basis): """Create a pickle file containing the CBasis/VBasis information.""" # Setup our data objects n_var = len(self._pyomo_var_to_solver_var_map) n_const = len(self._pyomo_con_to_solver_con_map) if save_c_v_basis is None: save_c...
Create a pickle file containing the CBasis/VBasis information.
Create a pickle file containing the CBasis/VBasis information.
[ "Create", "a", "pickle", "file", "containing", "the", "CBasis", "/", "VBasis", "information", "." ]
def _save_warm_start(self, save_c_v_basis): n_var = len(self._pyomo_var_to_solver_var_map) n_const = len(self._pyomo_con_to_solver_con_map) if save_c_v_basis is None: save_c_v_basis = True if save_c_v_basis: var_data = VBasis(n=n_var) const_data = CBas...
[ "def", "_save_warm_start", "(", "self", ",", "save_c_v_basis", ")", ":", "n_var", "=", "len", "(", "self", ".", "_pyomo_var_to_solver_var_map", ")", "n_const", "=", "len", "(", "self", ".", "_pyomo_con_to_solver_con_map", ")", "if", "save_c_v_basis", "is", "None...
Create a pickle file containing the CBasis/VBasis information.
[ "Create", "a", "pickle", "file", "containing", "the", "CBasis", "/", "VBasis", "information", "." ]
[ "\"\"\"Create a pickle file containing the CBasis/VBasis information.\"\"\"", "# Setup our data objects", "# Save the variable data", "# If we get an Attribute error and using c_v_basis it's probably cause", "# there was no crossover. In this case we retry without c_v_basis", "# Save the constraint data",...
[ { "param": "self", "type": null }, { "param": "save_c_v_basis", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "save_c_v_basis", "type": null, "docstring": null, "docstring_...
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
enable_duals
null
def enable_duals(self): """ Enables duals if not already enabled """ if not hasattr(self, "dual"): self.dual = Suffix(direction=Suffix.IMPORT)
Enables duals if not already enabled
Enables duals if not already enabled
[ "Enables", "duals", "if", "not", "already", "enabled" ]
def enable_duals(self): if not hasattr(self, "dual"): self.dual = Suffix(direction=Suffix.IMPORT)
[ "def", "enable_duals", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"dual\"", ")", ":", "self", ".", "dual", "=", "Suffix", "(", "direction", "=", "Suffix", ".", "IMPORT", ")" ]
Enables duals if not already enabled
[ "Enables", "duals", "if", "not", "already", "enabled" ]
[ "\"\"\"\n Enables duals if not already enabled\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
create_model
<not_specific>
def create_model(module_list=None, args=sys.argv[1:]): """ Construct a Pyomo AbstractModel using the Switch modules or packages in the given list and return the model. The following utility methods are attached to the model as class methods to simplify their use: min_data_check(), load_inputs(), pr...
Construct a Pyomo AbstractModel using the Switch modules or packages in the given list and return the model. The following utility methods are attached to the model as class methods to simplify their use: min_data_check(), load_inputs(), pre_solve(), post_solve(). This is implemented as calling t...
Construct a Pyomo AbstractModel using the Switch modules or packages in the given list and return the model. The following utility methods are attached to the model as class methods to simplify their use: min_data_check(), load_inputs(), pre_solve(), post_solve(). This is implemented as calling the following functions...
[ "Construct", "a", "Pyomo", "AbstractModel", "using", "the", "Switch", "modules", "or", "packages", "in", "the", "given", "list", "and", "return", "the", "model", ".", "The", "following", "utility", "methods", "are", "attached", "to", "the", "model", "as", "c...
def create_model(module_list=None, args=sys.argv[1:]): model = CustomModel() if module_list is None: module_list = get_module_list(args) model.module_list = module_list for m in module_list: importlib.import_module(m) _add_min_data_check(model) model.get_modules = types.MethodTyp...
[ "def", "create_model", "(", "module_list", "=", "None", ",", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", ")", ":", "model", "=", "CustomModel", "(", ")", "if", "module_list", "is", "None", ":", "module_list", "=", "get_module_list", "(", "args...
Construct a Pyomo AbstractModel using the Switch modules or packages in the given list and return the model.
[ "Construct", "a", "Pyomo", "AbstractModel", "using", "the", "Switch", "modules", "or", "packages", "in", "the", "given", "list", "and", "return", "the", "model", "." ]
[ "\"\"\"\n\n Construct a Pyomo AbstractModel using the Switch modules or packages\n in the given list and return the model. The following utility methods\n are attached to the model as class methods to simplify their use:\n min_data_check(), load_inputs(), pre_solve(), post_solve().\n\n This is implem...
[ { "param": "module_list", "type": null }, { "param": "args", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "module_list", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "args", "type": null, "docstring": null, "docstring_tok...
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
make_iterable
<not_specific>
def make_iterable(item): """Return an iterable for the one or more items passed.""" if isinstance(item, string_types): i = iter([item]) else: try: # check if it's iterable i = iter(item) except TypeError: i = iter([item]) return i
Return an iterable for the one or more items passed.
Return an iterable for the one or more items passed.
[ "Return", "an", "iterable", "for", "the", "one", "or", "more", "items", "passed", "." ]
def make_iterable(item): if isinstance(item, string_types): i = iter([item]) else: try: i = iter(item) except TypeError: i = iter([item]) return i
[ "def", "make_iterable", "(", "item", ")", ":", "if", "isinstance", "(", "item", ",", "string_types", ")", ":", "i", "=", "iter", "(", "[", "item", "]", ")", "else", ":", "try", ":", "i", "=", "iter", "(", "item", ")", "except", "TypeError", ":", ...
Return an iterable for the one or more items passed.
[ "Return", "an", "iterable", "for", "the", "one", "or", "more", "items", "passed", "." ]
[ "\"\"\"Return an iterable for the one or more items passed.\"\"\"", "# check if it's iterable" ]
[ { "param": "item", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "item", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
step_time
<not_specific>
def step_time(self): """ Reset timer to current time and return time elapsed since last step. """ last_start = self.start_time self.start_time = now = time.time() return now - last_start
Reset timer to current time and return time elapsed since last step.
Reset timer to current time and return time elapsed since last step.
[ "Reset", "timer", "to", "current", "time", "and", "return", "time", "elapsed", "since", "last", "step", "." ]
def step_time(self): last_start = self.start_time self.start_time = now = time.time() return now - last_start
[ "def", "step_time", "(", "self", ")", ":", "last_start", "=", "self", ".", "start_time", "self", ".", "start_time", "=", "now", "=", "time", ".", "time", "(", ")", "return", "now", "-", "last_start" ]
Reset timer to current time and return time elapsed since last step.
[ "Reset", "timer", "to", "current", "time", "and", "return", "time", "elapsed", "since", "last", "step", "." ]
[ "\"\"\"\n Reset timer to current time and return time elapsed since last step.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
step_time_as_str
<not_specific>
def step_time_as_str(self): """ Reset timer to current time and return time elapsed since last step as a formatted string. """ return format_seconds(self.step_time())
Reset timer to current time and return time elapsed since last step as a formatted string.
Reset timer to current time and return time elapsed since last step as a formatted string.
[ "Reset", "timer", "to", "current", "time", "and", "return", "time", "elapsed", "since", "last", "step", "as", "a", "formatted", "string", "." ]
def step_time_as_str(self): return format_seconds(self.step_time())
[ "def", "step_time_as_str", "(", "self", ")", ":", "return", "format_seconds", "(", "self", ".", "step_time", "(", ")", ")" ]
Reset timer to current time and return time elapsed since last step as a formatted string.
[ "Reset", "timer", "to", "current", "time", "and", "return", "time", "elapsed", "since", "last", "step", "as", "a", "formatted", "string", "." ]
[ "\"\"\"\n Reset timer to current time and return time elapsed since last step as a formatted string.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
format_seconds
<not_specific>
def format_seconds(seconds): """ Takes in a number of seconds and returns a string representing the seconds broken into hours, minutes and seconds. For example, format_seconds(3750.4) returns '1 h 2 min 30.40 s'. """ minutes = int(seconds // 60) hours = int(minutes // 60) remainder_sec ...
Takes in a number of seconds and returns a string representing the seconds broken into hours, minutes and seconds. For example, format_seconds(3750.4) returns '1 h 2 min 30.40 s'.
Takes in a number of seconds and returns a string representing the seconds broken into hours, minutes and seconds.
[ "Takes", "in", "a", "number", "of", "seconds", "and", "returns", "a", "string", "representing", "the", "seconds", "broken", "into", "hours", "minutes", "and", "seconds", "." ]
def format_seconds(seconds): minutes = int(seconds // 60) hours = int(minutes // 60) remainder_sec = seconds % 60 remainder_min = minutes % 60 output_str = "" if hours != 0: output_str += f"{hours} h " if minutes != 0: output_str += f"{remainder_min} min " output_str += f...
[ "def", "format_seconds", "(", "seconds", ")", ":", "minutes", "=", "int", "(", "seconds", "//", "60", ")", "hours", "=", "int", "(", "minutes", "//", "60", ")", "remainder_sec", "=", "seconds", "%", "60", "remainder_min", "=", "minutes", "%", "60", "ou...
Takes in a number of seconds and returns a string representing the seconds broken into hours, minutes and seconds.
[ "Takes", "in", "a", "number", "of", "seconds", "and", "returns", "a", "string", "representing", "the", "seconds", "broken", "into", "hours", "minutes", "and", "seconds", "." ]
[ "\"\"\"\n Takes in a number of seconds and returns a string\n representing the seconds broken into hours, minutes and seconds.\n\n For example, format_seconds(3750.4) returns '1 h 2 min 30.40 s'.\n \"\"\"" ]
[ { "param": "seconds", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "seconds", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
load_inputs
<not_specific>
def load_inputs(model, inputs_dir=None, attach_data_portal=False): """ Load input data for an AbstractModel using the modules in the given list and return a model instance. This is implemented as calling the load_inputs() function of each module, if the module has that function. """ if inputs_di...
Load input data for an AbstractModel using the modules in the given list and return a model instance. This is implemented as calling the load_inputs() function of each module, if the module has that function.
Load input data for an AbstractModel using the modules in the given list and return a model instance. This is implemented as calling the load_inputs() function of each module, if the module has that function.
[ "Load", "input", "data", "for", "an", "AbstractModel", "using", "the", "modules", "in", "the", "given", "list", "and", "return", "a", "model", "instance", ".", "This", "is", "implemented", "as", "calling", "the", "load_inputs", "()", "function", "of", "each"...
def load_inputs(model, inputs_dir=None, attach_data_portal=False): if inputs_dir is None: inputs_dir = getattr(model.options, "inputs_dir", "inputs") if model.options.verbose: print("Reading data...") timer = StepTimer() data = DataPortal(model=model) data.load_aug = types.MethodType...
[ "def", "load_inputs", "(", "model", ",", "inputs_dir", "=", "None", ",", "attach_data_portal", "=", "False", ")", ":", "if", "inputs_dir", "is", "None", ":", "inputs_dir", "=", "getattr", "(", "model", ".", "options", ",", "\"inputs_dir\"", ",", "\"inputs\""...
Load input data for an AbstractModel using the modules in the given list and return a model instance.
[ "Load", "input", "data", "for", "an", "AbstractModel", "using", "the", "modules", "in", "the", "given", "list", "and", "return", "a", "model", "instance", "." ]
[ "\"\"\"\n Load input data for an AbstractModel using the modules in the given\n list and return a model instance. This is implemented as calling the\n load_inputs() function of each module, if the module has that function.\n \"\"\"", "# Load data; add a fancier load function to the data portal", "# ...
[ { "param": "model", "type": null }, { "param": "inputs_dir", "type": null }, { "param": "attach_data_portal", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "inputs_dir", "type": null, "docstring": null, "docstring_tok...
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
save_inputs_as_dat
null
def save_inputs_as_dat(model, instance, save_path="inputs/complete_inputs.dat", exclude=[], sorted_output=False): """ Save input data to a .dat file for use with PySP or other command line tools that have not been fully integrated with DataPortal. SYNOPSIS: save_inputs_as_dat(model, instance...
Save input data to a .dat file for use with PySP or other command line tools that have not been fully integrated with DataPortal. SYNOPSIS: save_inputs_as_dat(model, instance, save_path)
Save input data to a .dat file for use with PySP or other command line tools that have not been fully integrated with DataPortal.
[ "Save", "input", "data", "to", "a", ".", "dat", "file", "for", "use", "with", "PySP", "or", "other", "command", "line", "tools", "that", "have", "not", "been", "fully", "integrated", "with", "DataPortal", "." ]
def save_inputs_as_dat(model, instance, save_path="inputs/complete_inputs.dat", exclude=[], sorted_output=False): quote_str = lambda v: '"{}"'.format(v) if isinstance(v, string_types) else '{}'.format(str(v)) from switch_model.reporting import make_iterable join_space = lambda items: ' '.join(map(str, m...
[ "def", "save_inputs_as_dat", "(", "model", ",", "instance", ",", "save_path", "=", "\"inputs/complete_inputs.dat\"", ",", "exclude", "=", "[", "]", ",", "sorted_output", "=", "False", ")", ":", "quote_str", "=", "lambda", "v", ":", "'\"{}\"'", ".", "format", ...
Save input data to a .dat file for use with PySP or other command line tools that have not been fully integrated with DataPortal.
[ "Save", "input", "data", "to", "a", ".", "dat", "file", "for", "use", "with", "PySP", "or", "other", "command", "line", "tools", "that", "have", "not", "been", "fully", "integrated", "with", "DataPortal", "." ]
[ "\"\"\"\n Save input data to a .dat file for use with PySP or other command line\n tools that have not been fully integrated with DataPortal.\n SYNOPSIS:\n save_inputs_as_dat(model, instance, save_path)\n \"\"\"", "# helper function to convert values to strings,", "# putting quotes around val...
[ { "param": "model", "type": null }, { "param": "instance", "type": null }, { "param": "save_path", "type": null }, { "param": "exclude", "type": null }, { "param": "sorted_output", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "instance", "type": null, "docstring": null, "docstring_token...
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
pre_solve
null
def pre_solve(instance, outputs_dir=None): """ Call pre-solve function (if present) in all modules used to compose this model. This function can be used to adjust the instance after it is created and before it is solved. """ for module in instance.get_modules(): if hasattr(module, 'pre_solve...
Call pre-solve function (if present) in all modules used to compose this model. This function can be used to adjust the instance after it is created and before it is solved.
Call pre-solve function (if present) in all modules used to compose this model. This function can be used to adjust the instance after it is created and before it is solved.
[ "Call", "pre", "-", "solve", "function", "(", "if", "present", ")", "in", "all", "modules", "used", "to", "compose", "this", "model", ".", "This", "function", "can", "be", "used", "to", "adjust", "the", "instance", "after", "it", "is", "created", "and", ...
def pre_solve(instance, outputs_dir=None): for module in instance.get_modules(): if hasattr(module, 'pre_solve'): module.pre_solve(instance)
[ "def", "pre_solve", "(", "instance", ",", "outputs_dir", "=", "None", ")", ":", "for", "module", "in", "instance", ".", "get_modules", "(", ")", ":", "if", "hasattr", "(", "module", ",", "'pre_solve'", ")", ":", "module", ".", "pre_solve", "(", "instance...
Call pre-solve function (if present) in all modules used to compose this model.
[ "Call", "pre", "-", "solve", "function", "(", "if", "present", ")", "in", "all", "modules", "used", "to", "compose", "this", "model", "." ]
[ "\"\"\"\n Call pre-solve function (if present) in all modules used to compose this model.\n This function can be used to adjust the instance after it is created and before it is solved.\n \"\"\"" ]
[ { "param": "instance", "type": null }, { "param": "outputs_dir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "instance", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outputs_dir", "type": null, "docstring": null, "docstring...
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
post_solve
null
def post_solve(instance, outputs_dir=None): """ Call post-solve function (if present) in all modules used to compose this model. This function can be used to report or save results from the solved model. """ if outputs_dir is None: outputs_dir = getattr(instance.options, "outputs_dir", "outp...
Call post-solve function (if present) in all modules used to compose this model. This function can be used to report or save results from the solved model.
Call post-solve function (if present) in all modules used to compose this model. This function can be used to report or save results from the solved model.
[ "Call", "post", "-", "solve", "function", "(", "if", "present", ")", "in", "all", "modules", "used", "to", "compose", "this", "model", ".", "This", "function", "can", "be", "used", "to", "report", "or", "save", "results", "from", "the", "solved", "model"...
def post_solve(instance, outputs_dir=None): if outputs_dir is None: outputs_dir = getattr(instance.options, "outputs_dir", "outputs") if not os.path.exists(outputs_dir): os.makedirs(outputs_dir) for module in instance.get_modules(): if hasattr(module, 'post_solve'): try: ...
[ "def", "post_solve", "(", "instance", ",", "outputs_dir", "=", "None", ")", ":", "if", "outputs_dir", "is", "None", ":", "outputs_dir", "=", "getattr", "(", "instance", ".", "options", ",", "\"outputs_dir\"", ",", "\"outputs\"", ")", "if", "not", "os", "."...
Call post-solve function (if present) in all modules used to compose this model.
[ "Call", "post", "-", "solve", "function", "(", "if", "present", ")", "in", "all", "modules", "used", "to", "compose", "this", "model", "." ]
[ "\"\"\"\n Call post-solve function (if present) in all modules used to compose this model.\n This function can be used to report or save results from the solved model.\n \"\"\"", "# TODO: implement a check to call post solve functions only if", "# solver termination condition is not 'infeasible' or 'un...
[ { "param": "instance", "type": null }, { "param": "outputs_dir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "instance", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outputs_dir", "type": null, "docstring": null, "docstring...
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
check_mandatory_components
<not_specific>
def check_mandatory_components(model, *mandatory_model_components): """ Checks whether mandatory elements of a Pyomo model are populated, and returns a clear error message if they don't exist. Typically, this method is not used directly. Instead, the min_data_check() method will set up a BuildCheck...
Checks whether mandatory elements of a Pyomo model are populated, and returns a clear error message if they don't exist. Typically, this method is not used directly. Instead, the min_data_check() method will set up a BuildCheck that uses this function. If an argument is a set, it must have no...
Checks whether mandatory elements of a Pyomo model are populated, and returns a clear error message if they don't exist. Typically, this method is not used directly. Instead, the min_data_check() method will set up a BuildCheck that uses this function. If an argument is a set, it must have non-zero length. If an arg...
[ "Checks", "whether", "mandatory", "elements", "of", "a", "Pyomo", "model", "are", "populated", "and", "returns", "a", "clear", "error", "message", "if", "they", "don", "'", "t", "exist", ".", "Typically", "this", "method", "is", "not", "used", "directly", ...
def check_mandatory_components(model, *mandatory_model_components): for component_name in mandatory_model_components: obj = getattr(model, component_name) o_class = type(obj).__name__ if o_class == 'ScalarSet' or o_class == 'OrderedScalarSet': if len(obj) == 0: ra...
[ "def", "check_mandatory_components", "(", "model", ",", "*", "mandatory_model_components", ")", ":", "for", "component_name", "in", "mandatory_model_components", ":", "obj", "=", "getattr", "(", "model", ",", "component_name", ")", "o_class", "=", "type", "(", "ob...
Checks whether mandatory elements of a Pyomo model are populated, and returns a clear error message if they don't exist.
[ "Checks", "whether", "mandatory", "elements", "of", "a", "Pyomo", "model", "are", "populated", "and", "returns", "a", "clear", "error", "message", "if", "they", "don", "'", "t", "exist", "." ]
[ "\"\"\"\n Checks whether mandatory elements of a Pyomo model are populated,\n and returns a clear error message if they don't exist.\n\n Typically, this method is not used directly. Instead, the\n min_data_check() method will set up a BuildCheck that uses this\n function.\n\n If an argument is a s...
[ { "param": "model", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
load_aug
null
def load_aug(switch_data, optional=False, auto_select=False, optional_params=[], **kwds): """ This is a wrapper for the DataPortal object that accepts additional keywords. This currently supports a flag for the file being optional. The name load_aug() is not great and may be changed. ""...
This is a wrapper for the DataPortal object that accepts additional keywords. This currently supports a flag for the file being optional. The name load_aug() is not great and may be changed.
This is a wrapper for the DataPortal object that accepts additional keywords. This currently supports a flag for the file being optional. The name load_aug() is not great and may be changed.
[ "This", "is", "a", "wrapper", "for", "the", "DataPortal", "object", "that", "accepts", "additional", "keywords", ".", "This", "currently", "supports", "a", "flag", "for", "the", "file", "being", "optional", ".", "The", "name", "load_aug", "()", "is", "not", ...
def load_aug(switch_data, optional=False, auto_select=False, optional_params=[], **kwds): load_data(switch_data, optional, auto_select, optional_params, **kwds)
[ "def", "load_aug", "(", "switch_data", ",", "optional", "=", "False", ",", "auto_select", "=", "False", ",", "optional_params", "=", "[", "]", ",", "**", "kwds", ")", ":", "load_data", "(", "switch_data", ",", "optional", ",", "auto_select", ",", "optional...
This is a wrapper for the DataPortal object that accepts additional keywords.
[ "This", "is", "a", "wrapper", "for", "the", "DataPortal", "object", "that", "accepts", "additional", "keywords", "." ]
[ "\"\"\"\n This is a wrapper for the DataPortal object that accepts additional\n keywords. This currently supports a flag for the file being optional.\n The name load_aug() is not great and may be changed.\n \"\"\"" ]
[ { "param": "switch_data", "type": null }, { "param": "optional", "type": null }, { "param": "auto_select", "type": null }, { "param": "optional_params", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "switch_data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "optional", "type": null, "docstring": null, "docstring...
048a460a29719106110f90144f4463b7dece5183
staadecker/switch
switch_model/utilities/__init__.py
[ "ECL-2.0", "Apache-2.0" ]
Python
warn
null
def warn(message): """ Send warning message to sys.stderr. Unlike warnings.warn, this does not add the current line of code to the message. """ sys.stderr.write("WARNING: " + message + '\n')
Send warning message to sys.stderr. Unlike warnings.warn, this does not add the current line of code to the message.
Send warning message to sys.stderr. Unlike warnings.warn, this does not add the current line of code to the message.
[ "Send", "warning", "message", "to", "sys", ".", "stderr", ".", "Unlike", "warnings", ".", "warn", "this", "does", "not", "add", "the", "current", "line", "of", "code", "to", "the", "message", "." ]
def warn(message): sys.stderr.write("WARNING: " + message + '\n')
[ "def", "warn", "(", "message", ")", ":", "sys", ".", "stderr", ".", "write", "(", "\"WARNING: \"", "+", "message", "+", "'\\n'", ")" ]
Send warning message to sys.stderr.
[ "Send", "warning", "message", "to", "sys", ".", "stderr", "." ]
[ "\"\"\"\n Send warning message to sys.stderr.\n Unlike warnings.warn, this does not add the current line of code to the message.\n \"\"\"" ]
[ { "param": "message", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "message", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
32ec4ccd647a1091d48f8516b97bc19d57e8286a
staadecker/switch
switch_model/generators/core/dispatch.py
[ "ECL-2.0", "Apache-2.0" ]
Python
post_solve
<not_specific>
def post_solve(instance, outdir): """ Exported files: dispatch-wide.csv - Dispatch results timepoints in "wide" format with timepoints as rows, generation projects as columns, and dispatch level as values dispatch.csv - Dispatch results in normalized form where each row describes the dispa...
Exported files: dispatch-wide.csv - Dispatch results timepoints in "wide" format with timepoints as rows, generation projects as columns, and dispatch level as values dispatch.csv - Dispatch results in normalized form where each row describes the dispatch of a generation project in one timepo...
Exported files: dispatch-wide.csv - Dispatch results timepoints in "wide" format with timepoints as rows, generation projects as columns, and dispatch level as values dispatch.csv - Dispatch results in normalized form where each row describes the dispatch of a generation project in one timepoint. dispatch_annual_summ...
[ "Exported", "files", ":", "dispatch", "-", "wide", ".", "csv", "-", "Dispatch", "results", "timepoints", "in", "\"", "wide", "\"", "format", "with", "timepoints", "as", "rows", "generation", "projects", "as", "columns", "and", "dispatch", "level", "as", "val...
def post_solve(instance, outdir): sorted_gen = sorted_robust(instance.GENERATION_PROJECTS) write_table( instance, instance.TIMEPOINTS, output_file=os.path.join(outdir, "dispatch-wide.csv"), headings=("timestamp",) + tuple(sorted_gen), values=lambda m, t: (m.tp_timestamp[t],) + tu...
[ "def", "post_solve", "(", "instance", ",", "outdir", ")", ":", "sorted_gen", "=", "sorted_robust", "(", "instance", ".", "GENERATION_PROJECTS", ")", "write_table", "(", "instance", ",", "instance", ".", "TIMEPOINTS", ",", "output_file", "=", "os", ".", "path",...
Exported files: dispatch-wide.csv - Dispatch results timepoints in "wide" format with timepoints as rows, generation projects as columns, and dispatch level as values
[ "Exported", "files", ":", "dispatch", "-", "wide", ".", "csv", "-", "Dispatch", "results", "timepoints", "in", "\"", "wide", "\"", "format", "with", "timepoints", "as", "rows", "generation", "projects", "as", "columns", "and", "dispatch", "level", "as", "val...
[ "\"\"\"\n Exported files:\n\n dispatch-wide.csv - Dispatch results timepoints in \"wide\" format with\n timepoints as rows, generation projects as columns, and dispatch level\n as values\n\n dispatch.csv - Dispatch results in normalized form where each row\n describes the dispatch of a generation ...
[ { "param": "instance", "type": null }, { "param": "outdir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "instance", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outdir", "type": null, "docstring": null, "docstring_toke...
32ec4ccd647a1091d48f8516b97bc19d57e8286a
staadecker/switch
switch_model/generators/core/dispatch.py
[ "ECL-2.0", "Apache-2.0" ]
Python
graph_hourly_dispatch
null
def graph_hourly_dispatch(tools): """ Generates a matrix of hourly dispatch plots for each time region """ # Read dispatch.csv df = tools.get_dataframe('dispatch.csv') # Convert to GW df["DispatchGen_MW"] /= 1e3 # Plot Dispatch tools.graph_time_matrix( df, value_colum...
Generates a matrix of hourly dispatch plots for each time region
Generates a matrix of hourly dispatch plots for each time region
[ "Generates", "a", "matrix", "of", "hourly", "dispatch", "plots", "for", "each", "time", "region" ]
def graph_hourly_dispatch(tools): df = tools.get_dataframe('dispatch.csv') df["DispatchGen_MW"] /= 1e3 tools.graph_time_matrix( df, value_column="DispatchGen_MW", ylabel="Average daily dispatch (GW)", )
[ "def", "graph_hourly_dispatch", "(", "tools", ")", ":", "df", "=", "tools", ".", "get_dataframe", "(", "'dispatch.csv'", ")", "df", "[", "\"DispatchGen_MW\"", "]", "/=", "1e3", "tools", ".", "graph_time_matrix", "(", "df", ",", "value_column", "=", "\"Dispatch...
Generates a matrix of hourly dispatch plots for each time region
[ "Generates", "a", "matrix", "of", "hourly", "dispatch", "plots", "for", "each", "time", "region" ]
[ "\"\"\"\n Generates a matrix of hourly dispatch plots for each time region\n \"\"\"", "# Read dispatch.csv", "# Convert to GW", "# Plot Dispatch" ]
[ { "param": "tools", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tools", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
32ec4ccd647a1091d48f8516b97bc19d57e8286a
staadecker/switch
switch_model/generators/core/dispatch.py
[ "ECL-2.0", "Apache-2.0" ]
Python
graph_hourly_dispatch
null
def graph_hourly_dispatch(tools): """ Generates a matrix of hourly dispatch plots for each time region """ # Read dispatch.csv df = tools.get_dataframe('dispatch.csv') # Convert to GW df["DispatchGen_MW"] /= 1e3 # Plot Dispatch tools.graph_scenario_matrix( df, value_c...
Generates a matrix of hourly dispatch plots for each time region
Generates a matrix of hourly dispatch plots for each time region
[ "Generates", "a", "matrix", "of", "hourly", "dispatch", "plots", "for", "each", "time", "region" ]
def graph_hourly_dispatch(tools): df = tools.get_dataframe('dispatch.csv') df["DispatchGen_MW"] /= 1e3 tools.graph_scenario_matrix( df, value_column="DispatchGen_MW", ylabel="Average daily dispatch (GW)" )
[ "def", "graph_hourly_dispatch", "(", "tools", ")", ":", "df", "=", "tools", ".", "get_dataframe", "(", "'dispatch.csv'", ")", "df", "[", "\"DispatchGen_MW\"", "]", "/=", "1e3", "tools", ".", "graph_scenario_matrix", "(", "df", ",", "value_column", "=", "\"Disp...
Generates a matrix of hourly dispatch plots for each time region
[ "Generates", "a", "matrix", "of", "hourly", "dispatch", "plots", "for", "each", "time", "region" ]
[ "\"\"\"\n Generates a matrix of hourly dispatch plots for each time region\n \"\"\"", "# Read dispatch.csv", "# Convert to GW", "# Plot Dispatch" ]
[ { "param": "tools", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tools", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ebd8347eb8c6bdfa53402b66a0ed3df900fe62e0
staadecker/switch
switch_model/wecc/get_inputs/get_inputs.py
[ "ECL-2.0", "Apache-2.0" ]
Python
write_csv_from_query
null
def write_csv_from_query(cursor, fname: str, headers: List[str], query: str): """Create CSV file from cursor.""" print(f"\t{fname}.csv... ", flush=True, end="") cursor.execute(query) data = cursor.fetchall() write_csv(data, fname, headers, log=False) print(len(data)) if not data: war...
Create CSV file from cursor.
Create CSV file from cursor.
[ "Create", "CSV", "file", "from", "cursor", "." ]
def write_csv_from_query(cursor, fname: str, headers: List[str], query: str): print(f"\t{fname}.csv... ", flush=True, end="") cursor.execute(query) data = cursor.fetchall() write_csv(data, fname, headers, log=False) print(len(data)) if not data: warnings.warn(f"File {fname} is empty.")
[ "def", "write_csv_from_query", "(", "cursor", ",", "fname", ":", "str", ",", "headers", ":", "List", "[", "str", "]", ",", "query", ":", "str", ")", ":", "print", "(", "f\"\\t{fname}.csv... \"", ",", "flush", "=", "True", ",", "end", "=", "\"\"", ")", ...
Create CSV file from cursor.
[ "Create", "CSV", "file", "from", "cursor", "." ]
[ "\"\"\"Create CSV file from cursor.\"\"\"" ]
[ { "param": "cursor", "type": null }, { "param": "fname", "type": "str" }, { "param": "headers", "type": "List[str]" }, { "param": "query", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cursor", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fname", "type": "str", "docstring": null, "docstring_tokens...
ebd8347eb8c6bdfa53402b66a0ed3df900fe62e0
staadecker/switch
switch_model/wecc/get_inputs/get_inputs.py
[ "ECL-2.0", "Apache-2.0" ]
Python
write_csv
null
def write_csv(data: Iterable[List], fname, headers: List[str], log=True): """Create CSV file from Iterable.""" if log: print(f"\t{fname}.csv... ", flush=True, end="") with open(fname + ".csv", "w") as f: f.write(",".join(headers) + "\n") for row in data: # Replace None va...
Create CSV file from Iterable.
Create CSV file from Iterable.
[ "Create", "CSV", "file", "from", "Iterable", "." ]
def write_csv(data: Iterable[List], fname, headers: List[str], log=True): if log: print(f"\t{fname}.csv... ", flush=True, end="") with open(fname + ".csv", "w") as f: f.write(",".join(headers) + "\n") for row in data: row_as_clean_strings = [ "." if element is...
[ "def", "write_csv", "(", "data", ":", "Iterable", "[", "List", "]", ",", "fname", ",", "headers", ":", "List", "[", "str", "]", ",", "log", "=", "True", ")", ":", "if", "log", ":", "print", "(", "f\"\\t{fname}.csv... \"", ",", "flush", "=", "True", ...
Create CSV file from Iterable.
[ "Create", "CSV", "file", "from", "Iterable", "." ]
[ "\"\"\"Create CSV file from Iterable.\"\"\"", "# Replace None values with dots for Pyomo. Also turn all datatypes into strings", "# concatenates \"line\" separated by commas, and appends \\n" ]
[ { "param": "data", "type": "Iterable[List]" }, { "param": "fname", "type": null }, { "param": "headers", "type": "List[str]" }, { "param": "log", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "data", "type": "Iterable[List]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fname", "type": null, "docstring": null, "docstri...
1244b1b6bed86d7183ce86905c1bccc93ac804d4
staadecker/switch
switch_model/balancing/electric_vehicles/simple.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
null
def define_components(mod): """ Adds components to a Pyomo abstract model object to describe a virtual battery charging pattern. ev_charge_limit[z,t] is a parameter that describes the maximum instantaneous charge (power limit) in MW for a virtual battery in load zone z at timepoint t. ...
Adds components to a Pyomo abstract model object to describe a virtual battery charging pattern. ev_charge_limit[z,t] is a parameter that describes the maximum instantaneous charge (power limit) in MW for a virtual battery in load zone z at timepoint t. ev_cumulative_charge_upper_mwh[z,t] is...
Adds components to a Pyomo abstract model object to describe a virtual battery charging pattern. ev_charge_limit[z,t] is a parameter that describes the maximum instantaneous charge (power limit) in MW for a virtual battery in load zone z at timepoint t. ev_cumulative_charge_upper_mwh[z,t] is a parameter that describe...
[ "Adds", "components", "to", "a", "Pyomo", "abstract", "model", "object", "to", "describe", "a", "virtual", "battery", "charging", "pattern", ".", "ev_charge_limit", "[", "z", "t", "]", "is", "a", "parameter", "that", "describes", "the", "maximum", "instantaneo...
def define_components(mod): mod.ev_charge_limit_mw = Param( mod.LOAD_ZONES, mod.TIMEPOINTS, default = float('inf'), input_file="ev_limits.csv", within=NonNegativeReals) mod.ev_cumulative_charge_upper_mwh = Param( mod.LOAD_ZONES, mod.TIMEPOINTS, default = 0.0, ...
[ "def", "define_components", "(", "mod", ")", ":", "mod", ".", "ev_charge_limit_mw", "=", "Param", "(", "mod", ".", "LOAD_ZONES", ",", "mod", ".", "TIMEPOINTS", ",", "default", "=", "float", "(", "'inf'", ")", ",", "input_file", "=", "\"ev_limits.csv\"", ",...
Adds components to a Pyomo abstract model object to describe a virtual battery charging pattern.
[ "Adds", "components", "to", "a", "Pyomo", "abstract", "model", "object", "to", "describe", "a", "virtual", "battery", "charging", "pattern", "." ]
[ "\"\"\"\n Adds components to a Pyomo abstract model object to describe a virtual\n battery charging pattern.\n\n ev_charge_limit[z,t] is a parameter that describes the maximum \n instantaneous charge (power limit) in MW for a virtual battery in load\n zone z at timepoint t.\n\n ev_cumulative_charg...
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b2d7eaa9e0f4c4055f0a4c54af07fea4e260ff70
staadecker/switch
switch_model/policies/rps_unbundled.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
null
def define_components(mod): """ f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as elegible for RPS accounting or not. RPS_ENERGY_SOURCES is a set enumerating all energy sources that contribute to RPS accounting. It is built by union of all fuels that are RPS elegible...
f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as elegible for RPS accounting or not. RPS_ENERGY_SOURCES is a set enumerating all energy sources that contribute to RPS accounting. It is built by union of all fuels that are RPS elegible and the NON_FUEL_ENERGY_SOURCE...
f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as elegible for RPS accounting or not. RPS_ENERGY_SOURCES is a set enumerating all energy sources that contribute to RPS accounting. It is built by union of all fuels that are RPS elegible and the NON_FUEL_ENERGY_SOURCES set. RPS_PERIODS is a subse...
[ "f_rps_eligible", "[", "f", "in", "FUELS", "]", "is", "a", "binary", "parameter", "that", "flags", "each", "fuel", "as", "elegible", "for", "RPS", "accounting", "or", "not", ".", "RPS_ENERGY_SOURCES", "is", "a", "set", "enumerating", "all", "energy", "source...
def define_components(mod): mod.ZONE_PERIODS = Set( input_file='rps_targets.csv', dimen=2, within=mod.LOAD_ZONES * mod.PERIODS) mod.f_rps_eligible = Param( mod.FUELS, within=Boolean, input_file='fuels.csv', default=False) mod.RPS_ENERGY_SOURCES = Set( ...
[ "def", "define_components", "(", "mod", ")", ":", "mod", ".", "ZONE_PERIODS", "=", "Set", "(", "input_file", "=", "'rps_targets.csv'", ",", "dimen", "=", "2", ",", "within", "=", "mod", ".", "LOAD_ZONES", "*", "mod", ".", "PERIODS", ")", "mod", ".", "f...
f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as elegible for RPS accounting or not.
[ "f_rps_eligible", "[", "f", "in", "FUELS", "]", "is", "a", "binary", "parameter", "that", "flags", "each", "fuel", "as", "elegible", "for", "RPS", "accounting", "or", "not", "." ]
[ "\"\"\"\n \n f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as\n elegible for RPS accounting or not.\n \n RPS_ENERGY_SOURCES is a set enumerating all energy sources that contribute\n to RPS accounting. It is built by union of all fuels that are RPS elegible\n and the NON_...
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
09d6c94d34d973394eb34cb7ddfe8e59c22efb81
staadecker/switch
switch_model/policies/rps_by_load_zone.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
null
def define_components(mod): """ f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as elegible for RPS accounting or not. RPS_ENERGY_SOURCES is a set enumerating all energy sources that contribute to RPS accounting. It is built by union of all fuels that are RPS elegible...
f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as elegible for RPS accounting or not. RPS_ENERGY_SOURCES is a set enumerating all energy sources that contribute to RPS accounting. It is built by union of all fuels that are RPS elegible and the NON_FUEL_ENERGY_SOURCE...
f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as elegible for RPS accounting or not. RPS_ENERGY_SOURCES is a set enumerating all energy sources that contribute to RPS accounting. It is built by union of all fuels that are RPS elegible and the NON_FUEL_ENERGY_SOURCES set. RPS_PERIODS is a subse...
[ "f_rps_eligible", "[", "f", "in", "FUELS", "]", "is", "a", "binary", "parameter", "that", "flags", "each", "fuel", "as", "elegible", "for", "RPS", "accounting", "or", "not", ".", "RPS_ENERGY_SOURCES", "is", "a", "set", "enumerating", "all", "energy", "source...
def define_components(mod): mod.ZONE_PERIODS = Set( dimen=2, within=mod.LOAD_ZONES * mod.PERIODS) mod.f_rps_eligible = Param( mod.FUELS, within=Boolean, default=False) mod.RPS_ENERGY_SOURCES = Set( initialize=lambda m: set(m.NON_FUEL_ENERGY_SOURCES) | \ se...
[ "def", "define_components", "(", "mod", ")", ":", "mod", ".", "ZONE_PERIODS", "=", "Set", "(", "dimen", "=", "2", ",", "within", "=", "mod", ".", "LOAD_ZONES", "*", "mod", ".", "PERIODS", ")", "mod", ".", "f_rps_eligible", "=", "Param", "(", "mod", "...
f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as elegible for RPS accounting or not.
[ "f_rps_eligible", "[", "f", "in", "FUELS", "]", "is", "a", "binary", "parameter", "that", "flags", "each", "fuel", "as", "elegible", "for", "RPS", "accounting", "or", "not", "." ]
[ "\"\"\"\n \n f_rps_eligible[f in FUELS] is a binary parameter that flags each fuel as\n elegible for RPS accounting or not.\n \n RPS_ENERGY_SOURCES is a set enumerating all energy sources that contribute\n to RPS accounting. It is built by union of all fuels that are RPS elegible\n and the NON_...
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
09d6c94d34d973394eb34cb7ddfe8e59c22efb81
staadecker/switch
switch_model/policies/rps_by_load_zone.py
[ "ECL-2.0", "Apache-2.0" ]
Python
load_inputs
null
def load_inputs(mod, switch_data, inputs_dir): """ The RPS target goals input file is mandatory, to discourage people from loading the module if it is not going to be used. It is not necessary to specify targets for all periods. Mandatory input files: rps_targets.csv LOAD_ZO...
The RPS target goals input file is mandatory, to discourage people from loading the module if it is not going to be used. It is not necessary to specify targets for all periods. Mandatory input files: rps_targets.csv LOAD_ZONES PERIOD rps_target The optional parameter ...
The RPS target goals input file is mandatory, to discourage people from loading the module if it is not going to be used. It is not necessary to specify targets for all periods. The optional parameter to define fuels as RPS eligible can be inputted in the following file: fuels.csv fuel f_rps_eligible
[ "The", "RPS", "target", "goals", "input", "file", "is", "mandatory", "to", "discourage", "people", "from", "loading", "the", "module", "if", "it", "is", "not", "going", "to", "be", "used", ".", "It", "is", "not", "necessary", "to", "specify", "targets", ...
def load_inputs(mod, switch_data, inputs_dir): switch_data.load_aug( filename=os.path.join(inputs_dir, 'fuels.csv'), select=('fuel','f_rps_eligible'), optional_params=['f_rps_eligible'], param=(mod.f_rps_eligible,)) switch_data.load_aug( filename=os.path.join(inputs_dir, ...
[ "def", "load_inputs", "(", "mod", ",", "switch_data", ",", "inputs_dir", ")", ":", "switch_data", ".", "load_aug", "(", "filename", "=", "os", ".", "path", ".", "join", "(", "inputs_dir", ",", "'fuels.csv'", ")", ",", "select", "=", "(", "'fuel'", ",", ...
The RPS target goals input file is mandatory, to discourage people from loading the module if it is not going to be used.
[ "The", "RPS", "target", "goals", "input", "file", "is", "mandatory", "to", "discourage", "people", "from", "loading", "the", "module", "if", "it", "is", "not", "going", "to", "be", "used", "." ]
[ "\"\"\"\n The RPS target goals input file is mandatory, to discourage people from\n loading the module if it is not going to be used. It is not necessary to\n specify targets for all periods.\n \n Mandatory input files:\n rps_targets.csv\n LOAD_ZONES PERIOD rps_target\n \n The...
[ { "param": "mod", "type": null }, { "param": "switch_data", "type": null }, { "param": "inputs_dir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "switch_data", "type": null, "docstring": null, "docstring_toke...
76d3ded5fd82926f92a4c790ee1979d016b7db63
staadecker/switch
switch_model/policies/CA_policies.py
[ "ECL-2.0", "Apache-2.0" ]
Python
define_components
null
def define_components(mod): """ load_zone_state[z] is the two-letter state code of a load zone. Values are inferred from the prefix of the load_zone id. For example, "CA_PGE_BAY" gives a state code of "CA". Note that this method isn't perfect. For example, "CAN_ALB" gives a "state" code of "CAN"...
load_zone_state[z] is the two-letter state code of a load zone. Values are inferred from the prefix of the load_zone id. For example, "CA_PGE_BAY" gives a state code of "CA". Note that this method isn't perfect. For example, "CAN_ALB" gives a "state" code of "CAN". If the state value is "CA" th...
load_zone_state[z] is the two-letter state code of a load zone. Values are inferred from the prefix of the load_zone id. For example, "CA_PGE_BAY" gives a state code of "CA". Note that this method isn't perfect. carbon_cap_tco2_per_yr_CA[p] is the carbon cap for a given period on all CO2 emission generated in load zon...
[ "load_zone_state", "[", "z", "]", "is", "the", "two", "-", "letter", "state", "code", "of", "a", "load", "zone", ".", "Values", "are", "inferred", "from", "the", "prefix", "of", "the", "load_zone", "id", ".", "For", "example", "\"", "CA_PGE_BAY", "\"", ...
def define_components(mod): mod.load_zone_state = Param( mod.LOAD_ZONES, input_file="load_zones.csv", default=lambda m, z: z.partition("_")[0], within=Any, doc="Two-letter state code for each load zone inferred from the load zone id.") mod.CA_ZONES = Set(initialize=mod.LO...
[ "def", "define_components", "(", "mod", ")", ":", "mod", ".", "load_zone_state", "=", "Param", "(", "mod", ".", "LOAD_ZONES", ",", "input_file", "=", "\"load_zones.csv\"", ",", "default", "=", "lambda", "m", ",", "z", ":", "z", ".", "partition", "(", "\"...
load_zone_state[z] is the two-letter state code of a load zone.
[ "load_zone_state", "[", "z", "]", "is", "the", "two", "-", "letter", "state", "code", "of", "a", "load", "zone", "." ]
[ "\"\"\"\n load_zone_state[z] is the two-letter state code of a load zone.\n Values are inferred from the prefix of the load_zone id. For\n example, \"CA_PGE_BAY\" gives a state code of \"CA\". Note that\n this method isn't perfect. For example, \"CAN_ALB\" gives a \"state\"\n code of \"CAN\".\n If...
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
76d3ded5fd82926f92a4c790ee1979d016b7db63
staadecker/switch
switch_model/policies/CA_policies.py
[ "ECL-2.0", "Apache-2.0" ]
Python
post_solve
null
def post_solve(model, outdir): """ Export california's annual emissions and its carbon caps for each period. """ reporting.write_table( model, model.PERIODS, output_file=os.path.join(outdir, "ca_policies.csv"), headings=("PERIOD", "AnnualEmissions_tCO2_per_y...
Export california's annual emissions and its carbon caps for each period.
Export california's annual emissions and its carbon caps for each period.
[ "Export", "california", "'", "s", "annual", "emissions", "and", "its", "carbon", "caps", "for", "each", "period", "." ]
def post_solve(model, outdir): reporting.write_table( model, model.PERIODS, output_file=os.path.join(outdir, "ca_policies.csv"), headings=("PERIOD", "AnnualEmissions_tCO2_per_yr_CA", "carbon_cap_tco2_per_yr_CA", "CA_AnnualDispatch", "CA_AnnualDemand", "Dis...
[ "def", "post_solve", "(", "model", ",", "outdir", ")", ":", "reporting", ".", "write_table", "(", "model", ",", "model", ".", "PERIODS", ",", "output_file", "=", "os", ".", "path", ".", "join", "(", "outdir", ",", "\"ca_policies.csv\"", ")", ",", "headin...
Export california's annual emissions and its carbon caps for each period.
[ "Export", "california", "'", "s", "annual", "emissions", "and", "its", "carbon", "caps", "for", "each", "period", "." ]
[ "\"\"\"\n Export california's annual emissions and its carbon caps\n for each period.\n \"\"\"" ]
[ { "param": "model", "type": null }, { "param": "outdir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outdir", "type": null, "docstring": null, "docstring_tokens"...
c30751ae7e12f9ca0d7f991831c354356f3d81d3
jonasbb/jupytext
jupytext/combine.py
[ "MIT" ]
Python
black_invariant
<not_specific>
def black_invariant(text, chars=None): """Remove characters that may be changed when reformatting the text with black""" if chars is None: chars = [' ', '\t', '\n', ',', "'", '"', '(', ')', '\\'] for char in chars: text = text.replace(char, '') return text
Remove characters that may be changed when reformatting the text with black
Remove characters that may be changed when reformatting the text with black
[ "Remove", "characters", "that", "may", "be", "changed", "when", "reformatting", "the", "text", "with", "black" ]
def black_invariant(text, chars=None): if chars is None: chars = [' ', '\t', '\n', ',', "'", '"', '(', ')', '\\'] for char in chars: text = text.replace(char, '') return text
[ "def", "black_invariant", "(", "text", ",", "chars", "=", "None", ")", ":", "if", "chars", "is", "None", ":", "chars", "=", "[", "' '", ",", "'\\t'", ",", "'\\n'", ",", "','", ",", "\"'\"", ",", "'\"'", ",", "'('", ",", "')'", ",", "'\\\\'", "]",...
Remove characters that may be changed when reformatting the text with black
[ "Remove", "characters", "that", "may", "be", "changed", "when", "reformatting", "the", "text", "with", "black" ]
[ "\"\"\"Remove characters that may be changed when reformatting the text with black\"\"\"" ]
[ { "param": "text", "type": null }, { "param": "chars", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "chars", "type": null, "docstring": null, "docstring_tokens": ...
c30751ae7e12f9ca0d7f991831c354356f3d81d3
jonasbb/jupytext
jupytext/combine.py
[ "MIT" ]
Python
combine_inputs_with_outputs
<not_specific>
def combine_inputs_with_outputs(nb_source, nb_outputs, fmt=None): """Copy outputs and metadata of the second notebook into the first one, for cells that have matching inputs""" output_code_cells = [cell for cell in nb_outputs.cells if cell.cell_type == 'code'] output_other_cells = [cell for cell in nb_...
Copy outputs and metadata of the second notebook into the first one, for cells that have matching inputs
Copy outputs and metadata of the second notebook into the first one, for cells that have matching inputs
[ "Copy", "outputs", "and", "metadata", "of", "the", "second", "notebook", "into", "the", "first", "one", "for", "cells", "that", "have", "matching", "inputs" ]
def combine_inputs_with_outputs(nb_source, nb_outputs, fmt=None): output_code_cells = [cell for cell in nb_outputs.cells if cell.cell_type == 'code'] output_other_cells = [cell for cell in nb_outputs.cells if cell.cell_type != 'code'] assert nb_outputs.nbformat == nb_source.nbformat, \ "The notebook...
[ "def", "combine_inputs_with_outputs", "(", "nb_source", ",", "nb_outputs", ",", "fmt", "=", "None", ")", ":", "output_code_cells", "=", "[", "cell", "for", "cell", "in", "nb_outputs", ".", "cells", "if", "cell", ".", "cell_type", "==", "'code'", "]", "output...
Copy outputs and metadata of the second notebook into the first one, for cells that have matching inputs
[ "Copy", "outputs", "and", "metadata", "of", "the", "second", "notebook", "into", "the", "first", "one", "for", "cells", "that", "have", "matching", "inputs" ]
[ "\"\"\"Copy outputs and metadata of the second notebook into\n the first one, for cells that have matching inputs\"\"\"", "# nbformat version number taken from the notebook with outputs", "# Remove outputs to warranty that trust of returned notebook is that of second notebook", "# Fill outputs with that of...
[ { "param": "nb_source", "type": null }, { "param": "nb_outputs", "type": null }, { "param": "fmt", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "nb_source", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nb_outputs", "type": null, "docstring": null, "docstring...
50c70dfe3b12ca92c8311a1401811a977e0c3e46
braind3d/traffic-brain
classification/src/data_generator.py
[ "MIT" ]
Python
parse_annotations
<not_specific>
def parse_annotations(annotation_folder: str, image_dir: str, labels: list): ''' Extracts bounding box information from PASCAL VOC .xml annotation files. Parameters: ---------- annotation_folder : str Dataset annotations location. image_dir : str ...
Extracts bounding box information from PASCAL VOC .xml annotation files. Parameters: ---------- annotation_folder : str Dataset annotations location. image_dir : str Dataset images location. labels : list Objec...
Extracts bounding box information from PASCAL VOC .xml annotation files.
[ "Extracts", "bounding", "box", "information", "from", "PASCAL", "VOC", ".", "xml", "annotation", "files", "." ]
def parse_annotations(annotation_folder: str, image_dir: str, labels: list): max_annotations = 0 image_names = [] annotations = [] for annotation in sorted(os.listdir(annotation_folder)): annotation_count = 0 object_bboxes = [] for element in xml.etree...
[ "def", "parse_annotations", "(", "annotation_folder", ":", "str", ",", "image_dir", ":", "str", ",", "labels", ":", "list", ")", ":", "max_annotations", "=", "0", "image_names", "=", "[", "]", "annotations", "=", "[", "]", "for", "annotation", "in", "sorte...
Extracts bounding box information from PASCAL VOC .xml annotation files.
[ "Extracts", "bounding", "box", "information", "from", "PASCAL", "VOC", ".", "xml", "annotation", "files", "." ]
[ "'''\n Extracts bounding box information from PASCAL VOC .xml annotation files.\n\n Parameters:\n ----------\n annotation_folder : str\n Dataset annotations location.\n image_dir : str\n Dataset images location.\n labels : list\n ...
[ { "param": "annotation_folder", "type": "str" }, { "param": "image_dir", "type": "str" }, { "param": "labels", "type": "list" } ]
{ "returns": [ { "docstring": "A tuple containing:\nimage_names : nparray\nImages files paths (shape : image_count, 1)\nimage_annotations : nparray\nAnnotations every image (shape : image count, max annotation count, 5) with\nannotations in format xmin, ymin, xmax, ymax, class.", "docstring_tokens": [...
50c70dfe3b12ca92c8311a1401811a977e0c3e46
braind3d/traffic-brain
classification/src/data_generator.py
[ "MIT" ]
Python
generate_tf_dataset
<not_specific>
def generate_tf_dataset(annotation_folder: str, image_dir: str, labels: list, batch_size: int): ''' Creates a Tensorflow compatable dataset from YOLO images and annotations Parameters: ----------- annotation_folder : str Dataset annotations location. ...
Creates a Tensorflow compatable dataset from YOLO images and annotations Parameters: ----------- annotation_folder : str Dataset annotations location. image_dir : str Dataset images location. labels : list Obje...
Creates a Tensorflow compatable dataset from YOLO images and annotations
[ "Creates", "a", "Tensorflow", "compatable", "dataset", "from", "YOLO", "images", "and", "annotations" ]
def generate_tf_dataset(annotation_folder: str, image_dir: str, labels: list, batch_size: int): image_names, image_bboxes = DataGenerator.parse_annotations( annotation_folder, image_dir, labels) tf_dataset = tf.data.Dataset.from_tensor_slices( (image_names, image_bboxes)) ...
[ "def", "generate_tf_dataset", "(", "annotation_folder", ":", "str", ",", "image_dir", ":", "str", ",", "labels", ":", "list", ",", "batch_size", ":", "int", ")", ":", "image_names", ",", "image_bboxes", "=", "DataGenerator", ".", "parse_annotations", "(", "ann...
Creates a Tensorflow compatable dataset from YOLO images and annotations
[ "Creates", "a", "Tensorflow", "compatable", "dataset", "from", "YOLO", "images", "and", "annotations" ]
[ "'''\n Creates a Tensorflow compatable dataset from YOLO images and annotations\n\n Parameters:\n -----------\n annotation_folder : str\n Dataset annotations location.\n image_dir : str\n Dataset images location.\n labels : list\n ...
[ { "param": "annotation_folder", "type": "str" }, { "param": "image_dir", "type": "str" }, { "param": "labels", "type": "list" }, { "param": "batch_size", "type": "int" } ]
{ "returns": [ { "docstring": "A batched Tensorflow dataset.\nbatch : tuple\n(images, annotations)\nbatch[0] : images : tensor (shape : batch_size, IMAGE_W, IMAGE_H, 3)\nbatch[1] : annotations : tensor (shape : batch_size, max annot, 5)", "docstring_tokens": [ "A", "batched", "...
30fd426a634e986ffc26091a22696bdd6af7e62f
braind3d/traffic-brain
embedded/raspberry/server/traffic_light/views.py
[ "MIT" ]
Python
load_animation
null
def load_animation(name: str, color: LEDBoard): ''' Loads an animation from a given name Parameters: ----------- name : str Name of the animations to be loaded. color : LEDBoard The board on which the animation should be displayed. ''' with open('server/static/animation...
Loads an animation from a given name Parameters: ----------- name : str Name of the animations to be loaded. color : LEDBoard The board on which the animation should be displayed.
Loads an animation from a given name Parameters. name : str Name of the animations to be loaded. color : LEDBoard The board on which the animation should be displayed.
[ "Loads", "an", "animation", "from", "a", "given", "name", "Parameters", ".", "name", ":", "str", "Name", "of", "the", "animations", "to", "be", "loaded", ".", "color", ":", "LEDBoard", "The", "board", "on", "which", "the", "animation", "should", "be", "d...
def load_animation(name: str, color: LEDBoard): with open('server/static/animations/{}.json'.format(name)) as animation_file: animation = json.load(animation_file) light_controller.display_animation( animation['frames'], color, animation['fps'], animation['looped'], STOP_FLAG)
[ "def", "load_animation", "(", "name", ":", "str", ",", "color", ":", "LEDBoard", ")", ":", "with", "open", "(", "'server/static/animations/{}.json'", ".", "format", "(", "name", ")", ")", "as", "animation_file", ":", "animation", "=", "json", ".", "load", ...
Loads an animation from a given name Parameters:
[ "Loads", "an", "animation", "from", "a", "given", "name", "Parameters", ":" ]
[ "'''\n Loads an animation from a given name\n\n Parameters:\n -----------\n name : str\n Name of the animations to be loaded.\n\n color : LEDBoard\n The board on which the animation should be displayed.\n '''" ]
[ { "param": "name", "type": "str" }, { "param": "color", "type": "LEDBoard" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "color", "type": "LEDBoard", "docstring": null, "docstring_to...
30fd426a634e986ffc26091a22696bdd6af7e62f
braind3d/traffic-brain
embedded/raspberry/server/traffic_light/views.py
[ "MIT" ]
Python
animation
<not_specific>
def animation(): ''' POST /change_lights ------------------- Stores a new submitted animation json file. ''' data = request.json def compare(list1, list2): return collections.Counter(list1) == collections.Counter(list2) if not compare(['name', 'fps', 'looped', 'frames'], data.k...
POST /change_lights ------------------- Stores a new submitted animation json file.
POST /change_lights Stores a new submitted animation json file.
[ "POST", "/", "change_lights", "Stores", "a", "new", "submitted", "animation", "json", "file", "." ]
def animation(): data = request.json def compare(list1, list2): return collections.Counter(list1) == collections.Counter(list2) if not compare(['name', 'fps', 'looped', 'frames'], data.keys()): return 'Invalid animation JSON.', 400 with open('server/static/animations/{}.json'.format(data...
[ "def", "animation", "(", ")", ":", "data", "=", "request", ".", "json", "def", "compare", "(", "list1", ",", "list2", ")", ":", "return", "collections", ".", "Counter", "(", "list1", ")", "==", "collections", ".", "Counter", "(", "list2", ")", "if", ...
POST /change_lights Stores a new submitted animation json file.
[ "POST", "/", "change_lights", "Stores", "a", "new", "submitted", "animation", "json", "file", "." ]
[ "'''\n POST /change_lights\n -------------------\n Stores a new submitted animation json file.\n '''" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
30fd426a634e986ffc26091a22696bdd6af7e62f
braind3d/traffic-brain
embedded/raspberry/server/traffic_light/views.py
[ "MIT" ]
Python
change_lights
<not_specific>
def change_lights(): ''' POST /change_lights ------------------- Sets the traffic lights to display certain passed animations. ''' global STOP_FLAG STOP_FLAG = True STOP_FLAG = False available_animations = [x.split('.')[0] for x in os.listdir('server/sta...
POST /change_lights ------------------- Sets the traffic lights to display certain passed animations.
POST /change_lights Sets the traffic lights to display certain passed animations.
[ "POST", "/", "change_lights", "Sets", "the", "traffic", "lights", "to", "display", "certain", "passed", "animations", "." ]
def change_lights(): global STOP_FLAG STOP_FLAG = True STOP_FLAG = False available_animations = [x.split('.')[0] for x in os.listdir('server/static/animations/')] if not (request.args.get('red') and request.args.get('yellow') and request.args.get('green')): return...
[ "def", "change_lights", "(", ")", ":", "global", "STOP_FLAG", "STOP_FLAG", "=", "True", "STOP_FLAG", "=", "False", "available_animations", "=", "[", "x", ".", "split", "(", "'.'", ")", "[", "0", "]", "for", "x", "in", "os", ".", "listdir", "(", "'serve...
POST /change_lights Sets the traffic lights to display certain passed animations.
[ "POST", "/", "change_lights", "Sets", "the", "traffic", "lights", "to", "display", "certain", "passed", "animations", "." ]
[ "'''\n POST /change_lights\n -------------------\n Sets the traffic lights to display certain passed animations.\n '''" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
6beadea7f8be74d24e6acec459a6a77996abfe55
ShorensteinCenter/Benchmarks-Program
app/lists.py
[ "MIT" ]
Python
do_async_import
null
def do_async_import(coroutine): """Generic wrapper function to run async imports. Args: coroutine: the coroutine to be run asynchronously """ loop = asyncio.get_event_loop() future = asyncio.ensure_future(coroutine) loop.run_until_complete(future)
Generic wrapper function to run async imports. Args: coroutine: the coroutine to be run asynchronously
Generic wrapper function to run async imports.
[ "Generic", "wrapper", "function", "to", "run", "async", "imports", "." ]
def do_async_import(coroutine): loop = asyncio.get_event_loop() future = asyncio.ensure_future(coroutine) loop.run_until_complete(future)
[ "def", "do_async_import", "(", "coroutine", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "future", "=", "asyncio", ".", "ensure_future", "(", "coroutine", ")", "loop", ".", "run_until_complete", "(", "future", ")" ]
Generic wrapper function to run async imports.
[ "Generic", "wrapper", "function", "to", "run", "async", "imports", "." ]
[ "\"\"\"Generic wrapper function to run async imports.\r\n\r\n Args:\r\n coroutine: the coroutine to be run asynchronously\r\n \"\"\"" ]
[ { "param": "coroutine", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "coroutine", "type": null, "docstring": "the coroutine to be run asynchronously", "docstring_tokens": [ "the", "coroutine", "to", "be", "run", "asynchronously" ], "def...