repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.pool_versions | def pool_versions(self, updater_id=None, updater_name=None, pool_id=None):
"""Get list of pool versions.
Parameters:
updater_id (int):
updater_name (str):
pool_id (int):
"""
params = {
'search[updater_id]': updater_id,
'search[... | python | def pool_versions(self, updater_id=None, updater_name=None, pool_id=None):
"""Get list of pool versions.
Parameters:
updater_id (int):
updater_name (str):
pool_id (int):
"""
params = {
'search[updater_id]': updater_id,
'search[... | [
"def",
"pool_versions",
"(",
"self",
",",
"updater_id",
"=",
"None",
",",
"updater_name",
"=",
"None",
",",
"pool_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'search[updater_id]'",
":",
"updater_id",
",",
"'search[updater_name]'",
":",
"updater_name",
","... | Get list of pool versions.
Parameters:
updater_id (int):
updater_name (str):
pool_id (int): | [
"Get",
"list",
"of",
"pool",
"versions",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L975-L988 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.tag_aliases | def tag_aliases(self, name_matches=None, antecedent_name=None,
tag_id=None):
"""Get tags aliases.
Parameters:
name_matches (str): Match antecedent or consequent name.
antecedent_name (str): Match antecedent name (exact match).
tag_id (int): The ta... | python | def tag_aliases(self, name_matches=None, antecedent_name=None,
tag_id=None):
"""Get tags aliases.
Parameters:
name_matches (str): Match antecedent or consequent name.
antecedent_name (str): Match antecedent name (exact match).
tag_id (int): The ta... | [
"def",
"tag_aliases",
"(",
"self",
",",
"name_matches",
"=",
"None",
",",
"antecedent_name",
"=",
"None",
",",
"tag_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'search[name_matches]'",
":",
"name_matches",
",",
"'search[antecedent_name]'",
":",
"antecedent_... | Get tags aliases.
Parameters:
name_matches (str): Match antecedent or consequent name.
antecedent_name (str): Match antecedent name (exact match).
tag_id (int): The tag alias id. | [
"Get",
"tags",
"aliases",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L1039-L1053 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.tag_implications | def tag_implications(self, name_matches=None, antecedent_name=None,
tag_id=None):
"""Get tags implications.
Parameters:
name_matches (str): Match antecedent or consequent name.
antecedent_name (str): Match antecedent name (exact match).
tag_i... | python | def tag_implications(self, name_matches=None, antecedent_name=None,
tag_id=None):
"""Get tags implications.
Parameters:
name_matches (str): Match antecedent or consequent name.
antecedent_name (str): Match antecedent name (exact match).
tag_i... | [
"def",
"tag_implications",
"(",
"self",
",",
"name_matches",
"=",
"None",
",",
"antecedent_name",
"=",
"None",
",",
"tag_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'search[name_matches]'",
":",
"name_matches",
",",
"'search[antecedent_name]'",
":",
"antece... | Get tags implications.
Parameters:
name_matches (str): Match antecedent or consequent name.
antecedent_name (str): Match antecedent name (exact match).
tag_id (int): Tag implication id. | [
"Get",
"tags",
"implications",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L1055-L1069 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.tag_related | def tag_related(self, query, category=None):
"""Get related tags.
Parameters:
query (str): The tag to find the related tags for.
category (str): If specified, show only tags of a specific
category. Can be: General 0, Artist 1, Copyright
... | python | def tag_related(self, query, category=None):
"""Get related tags.
Parameters:
query (str): The tag to find the related tags for.
category (str): If specified, show only tags of a specific
category. Can be: General 0, Artist 1, Copyright
... | [
"def",
"tag_related",
"(",
"self",
",",
"query",
",",
"category",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'query'",
":",
"query",
",",
"'category'",
":",
"category",
"}",
"return",
"self",
".",
"_get",
"(",
"'related_tag.json'",
",",
"params",
")"
] | Get related tags.
Parameters:
query (str): The tag to find the related tags for.
category (str): If specified, show only tags of a specific
category. Can be: General 0, Artist 1, Copyright
3 and Character 4. | [
"Get",
"related",
"tags",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L1071-L1081 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.wiki_list | def wiki_list(self, title=None, creator_id=None, body_matches=None,
other_names_match=None, creator_name=None, hide_deleted=None,
other_names_present=None, order=None):
"""Function to retrieves a list of every wiki page.
Parameters:
title (str): Page titl... | python | def wiki_list(self, title=None, creator_id=None, body_matches=None,
other_names_match=None, creator_name=None, hide_deleted=None,
other_names_present=None, order=None):
"""Function to retrieves a list of every wiki page.
Parameters:
title (str): Page titl... | [
"def",
"wiki_list",
"(",
"self",
",",
"title",
"=",
"None",
",",
"creator_id",
"=",
"None",
",",
"body_matches",
"=",
"None",
",",
"other_names_match",
"=",
"None",
",",
"creator_name",
"=",
"None",
",",
"hide_deleted",
"=",
"None",
",",
"other_names_present... | Function to retrieves a list of every wiki page.
Parameters:
title (str): Page title.
creator_id (int): Creator id.
body_matches (str): Page content.
other_names_match (str): Other names.
creator_name (str): Creator name.
hide_deleted (str... | [
"Function",
"to",
"retrieves",
"a",
"list",
"of",
"every",
"wiki",
"page",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L1083-L1108 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.wiki_versions_list | def wiki_versions_list(self, page_id, updater_id):
"""Return a list of wiki page version.
Parameters:
page_id (int):
updater_id (int):
"""
params = {
'earch[updater_id]': updater_id,
'search[wiki_page_id]': page_id
}
re... | python | def wiki_versions_list(self, page_id, updater_id):
"""Return a list of wiki page version.
Parameters:
page_id (int):
updater_id (int):
"""
params = {
'earch[updater_id]': updater_id,
'search[wiki_page_id]': page_id
}
re... | [
"def",
"wiki_versions_list",
"(",
"self",
",",
"page_id",
",",
"updater_id",
")",
":",
"params",
"=",
"{",
"'earch[updater_id]'",
":",
"updater_id",
",",
"'search[wiki_page_id]'",
":",
"page_id",
"}",
"return",
"self",
".",
"_get",
"(",
"'wiki_page_versions.json'"... | Return a list of wiki page version.
Parameters:
page_id (int):
updater_id (int): | [
"Return",
"a",
"list",
"of",
"wiki",
"page",
"version",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L1172-L1183 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.forum_topic_list | def forum_topic_list(self, title_matches=None, title=None,
category_id=None):
"""Function to get forum topics.
Parameters:
title_matches (str): Search body for the given terms.
title (str): Exact title match.
category_id (int): Can be: 0, 1, ... | python | def forum_topic_list(self, title_matches=None, title=None,
category_id=None):
"""Function to get forum topics.
Parameters:
title_matches (str): Search body for the given terms.
title (str): Exact title match.
category_id (int): Can be: 0, 1, ... | [
"def",
"forum_topic_list",
"(",
"self",
",",
"title_matches",
"=",
"None",
",",
"title",
"=",
"None",
",",
"category_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'search[title_matches]'",
":",
"title_matches",
",",
"'search[title]'",
":",
"title",
",",
"... | Function to get forum topics.
Parameters:
title_matches (str): Search body for the given terms.
title (str): Exact title match.
category_id (int): Can be: 0, 1, 2 (General, Tags, Bugs & Features
respectively). | [
"Function",
"to",
"get",
"forum",
"topics",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L1193-L1208 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.forum_post_list | def forum_post_list(self, creator_id=None, creator_name=None,
topic_id=None, topic_title_matches=None,
topic_category_id=None, body_matches=None):
"""Return a list of forum posts.
Parameters:
creator_id (int):
creator_name (str):
... | python | def forum_post_list(self, creator_id=None, creator_name=None,
topic_id=None, topic_title_matches=None,
topic_category_id=None, body_matches=None):
"""Return a list of forum posts.
Parameters:
creator_id (int):
creator_name (str):
... | [
"def",
"forum_post_list",
"(",
"self",
",",
"creator_id",
"=",
"None",
",",
"creator_name",
"=",
"None",
",",
"topic_id",
"=",
"None",
",",
"topic_title_matches",
"=",
"None",
",",
"topic_category_id",
"=",
"None",
",",
"body_matches",
"=",
"None",
")",
":",... | Return a list of forum posts.
Parameters:
creator_id (int):
creator_name (str):
topic_id (int):
topic_title_matches (str):
topic_category_id (int): Can be: 0, 1, 2 (General, Tags, Bugs &
Features respectively).
... | [
"Return",
"a",
"list",
"of",
"forum",
"posts",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L1268-L1290 | train |
LuqueDaniel/pybooru | pybooru/pybooru.py | _Pybooru.site_name | def site_name(self, site_name):
"""Function that sets and checks the site name and set url.
Parameters:
site_name (str): The site name in 'SITE_LIST', default sites.
Raises:
PybooruError: When 'site_name' isn't valid.
"""
if site_name in SITE_LIST:
... | python | def site_name(self, site_name):
"""Function that sets and checks the site name and set url.
Parameters:
site_name (str): The site name in 'SITE_LIST', default sites.
Raises:
PybooruError: When 'site_name' isn't valid.
"""
if site_name in SITE_LIST:
... | [
"def",
"site_name",
"(",
"self",
",",
"site_name",
")",
":",
"if",
"site_name",
"in",
"SITE_LIST",
":",
"self",
".",
"__site_name",
"=",
"site_name",
"self",
".",
"__site_url",
"=",
"SITE_LIST",
"[",
"site_name",
"]",
"[",
"'url'",
"]",
"else",
":",
"rai... | Function that sets and checks the site name and set url.
Parameters:
site_name (str): The site name in 'SITE_LIST', default sites.
Raises:
PybooruError: When 'site_name' isn't valid. | [
"Function",
"that",
"sets",
"and",
"checks",
"the",
"site",
"name",
"and",
"set",
"url",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/pybooru.py#L79-L93 | train |
LuqueDaniel/pybooru | pybooru/pybooru.py | _Pybooru.site_url | def site_url(self, url):
"""URL setter and validator for site_url property.
Parameters:
url (str): URL of on Moebooru/Danbooru based sites.
Raises:
PybooruError: When URL scheme or URL are invalid.
"""
# Regular expression to URL validate
regex =... | python | def site_url(self, url):
"""URL setter and validator for site_url property.
Parameters:
url (str): URL of on Moebooru/Danbooru based sites.
Raises:
PybooruError: When URL scheme or URL are invalid.
"""
# Regular expression to URL validate
regex =... | [
"def",
"site_url",
"(",
"self",
",",
"url",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r'^(?:http|https)://'",
"r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?| \\ [A-Z0-9-]{2,}(?<!-)\\.?)|'",
"r'localhost|'",
"r'\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}... | URL setter and validator for site_url property.
Parameters:
url (str): URL of on Moebooru/Danbooru based sites.
Raises:
PybooruError: When URL scheme or URL are invalid. | [
"URL",
"setter",
"and",
"validator",
"for",
"site_url",
"property",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/pybooru.py#L106-L134 | train |
LuqueDaniel/pybooru | pybooru/pybooru.py | _Pybooru._request | def _request(self, url, api_call, request_args, method='GET'):
"""Function to request and returning JSON data.
Parameters:
url (str): Base url call.
api_call (str): API function to be called.
request_args (dict): All requests parameters.
method (str): (De... | python | def _request(self, url, api_call, request_args, method='GET'):
"""Function to request and returning JSON data.
Parameters:
url (str): Base url call.
api_call (str): API function to be called.
request_args (dict): All requests parameters.
method (str): (De... | [
"def",
"_request",
"(",
"self",
",",
"url",
",",
"api_call",
",",
"request_args",
",",
"method",
"=",
"'GET'",
")",
":",
"try",
":",
"if",
"method",
"!=",
"'GET'",
":",
"self",
".",
"client",
".",
"headers",
".",
"update",
"(",
"{",
"'content-type'",
... | Function to request and returning JSON data.
Parameters:
url (str): Base url call.
api_call (str): API function to be called.
request_args (dict): All requests parameters.
method (str): (Defauld: GET) HTTP method 'GET' or 'POST'
Raises:
Pyboo... | [
"Function",
"to",
"request",
"and",
"returning",
"JSON",
"data",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/pybooru.py#L149-L186 | train |
LuqueDaniel/pybooru | pybooru/api_moebooru.py | MoebooruApi_Mixin.post_update | def post_update(self, post_id, tags=None, file_=None, rating=None,
source=None, is_rating_locked=None, is_note_locked=None,
parent_id=None):
"""Update a specific post.
Only the 'post_id' parameter is required. Leave the other parameters
blank if you don't... | python | def post_update(self, post_id, tags=None, file_=None, rating=None,
source=None, is_rating_locked=None, is_note_locked=None,
parent_id=None):
"""Update a specific post.
Only the 'post_id' parameter is required. Leave the other parameters
blank if you don't... | [
"def",
"post_update",
"(",
"self",
",",
"post_id",
",",
"tags",
"=",
"None",
",",
"file_",
"=",
"None",
",",
"rating",
"=",
"None",
",",
"source",
"=",
"None",
",",
"is_rating_locked",
"=",
"None",
",",
"is_note_locked",
"=",
"None",
",",
"parent_id",
... | Update a specific post.
Only the 'post_id' parameter is required. Leave the other parameters
blank if you don't want to change them (Requires login).
Parameters:
post_id (int): The id number of the post to update.
tags (str): A space delimited list of tags. Specify prev... | [
"Update",
"a",
"specific",
"post",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_moebooru.py#L79-L113 | train |
LuqueDaniel/pybooru | pybooru/moebooru.py | Moebooru.site_name | def site_name(self, site_name):
"""Sets api_version and hash_string.
Parameters:
site_name (str): The site name in 'SITE_LIST', default sites.
Raises:
PybooruError: When 'site_name' isn't valid.
"""
# Set base class property site_name
_Pybooru.si... | python | def site_name(self, site_name):
"""Sets api_version and hash_string.
Parameters:
site_name (str): The site name in 'SITE_LIST', default sites.
Raises:
PybooruError: When 'site_name' isn't valid.
"""
# Set base class property site_name
_Pybooru.si... | [
"def",
"site_name",
"(",
"self",
",",
"site_name",
")",
":",
"_Pybooru",
".",
"site_name",
".",
"fset",
"(",
"self",
",",
"site_name",
")",
"if",
"(",
"'api_version'",
"and",
"'hashed_string'",
")",
"in",
"SITE_LIST",
"[",
"site_name",
"]",
":",
"self",
... | Sets api_version and hash_string.
Parameters:
site_name (str): The site name in 'SITE_LIST', default sites.
Raises:
PybooruError: When 'site_name' isn't valid. | [
"Sets",
"api_version",
"and",
"hash_string",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/moebooru.py#L74-L88 | train |
LuqueDaniel/pybooru | pybooru/moebooru.py | Moebooru._build_url | def _build_url(self, api_call):
"""Build request url.
Parameters:
api_call (str): Base API Call.
Returns:
Complete url (str).
"""
if self.api_version in ('1.13.0', '1.13.0+update.1', '1.13.0+update.2'):
if '/' not in api_call:
... | python | def _build_url(self, api_call):
"""Build request url.
Parameters:
api_call (str): Base API Call.
Returns:
Complete url (str).
"""
if self.api_version in ('1.13.0', '1.13.0+update.1', '1.13.0+update.2'):
if '/' not in api_call:
... | [
"def",
"_build_url",
"(",
"self",
",",
"api_call",
")",
":",
"if",
"self",
".",
"api_version",
"in",
"(",
"'1.13.0'",
",",
"'1.13.0+update.1'",
",",
"'1.13.0+update.2'",
")",
":",
"if",
"'/'",
"not",
"in",
"api_call",
":",
"return",
"\"{0}/{1}/index.json\"",
... | Build request url.
Parameters:
api_call (str): Base API Call.
Returns:
Complete url (str). | [
"Build",
"request",
"url",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/moebooru.py#L90-L102 | train |
LuqueDaniel/pybooru | pybooru/moebooru.py | Moebooru._build_hash_string | def _build_hash_string(self):
"""Function for build password hash string.
Raises:
PybooruError: When isn't provide hash string.
PybooruError: When aren't provide username or password.
PybooruError: When Pybooru can't add password to hash strring.
"""
... | python | def _build_hash_string(self):
"""Function for build password hash string.
Raises:
PybooruError: When isn't provide hash string.
PybooruError: When aren't provide username or password.
PybooruError: When Pybooru can't add password to hash strring.
"""
... | [
"def",
"_build_hash_string",
"(",
"self",
")",
":",
"if",
"self",
".",
"site_name",
"in",
"SITE_LIST",
"or",
"self",
".",
"hash_string",
":",
"if",
"self",
".",
"username",
"and",
"self",
".",
"password",
":",
"try",
":",
"hash_string",
"=",
"self",
".",... | Function for build password hash string.
Raises:
PybooruError: When isn't provide hash string.
PybooruError: When aren't provide username or password.
PybooruError: When Pybooru can't add password to hash strring. | [
"Function",
"for",
"build",
"password",
"hash",
"string",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/moebooru.py#L104-L131 | train |
bjodah/pyodesys | pyodesys/symbolic.py | _is_autonomous | def _is_autonomous(indep, exprs):
""" Whether the expressions for the dependent variables are autonomous.
Note that the system may still behave as an autonomous system on the interface
of :meth:`integrate` due to use of pre-/post-processors.
"""
if indep is None:
return True
for expr in... | python | def _is_autonomous(indep, exprs):
""" Whether the expressions for the dependent variables are autonomous.
Note that the system may still behave as an autonomous system on the interface
of :meth:`integrate` due to use of pre-/post-processors.
"""
if indep is None:
return True
for expr in... | [
"def",
"_is_autonomous",
"(",
"indep",
",",
"exprs",
")",
":",
"if",
"indep",
"is",
"None",
":",
"return",
"True",
"for",
"expr",
"in",
"exprs",
":",
"try",
":",
"in_there",
"=",
"indep",
"in",
"expr",
".",
"free_symbols",
"except",
":",
"in_there",
"=... | Whether the expressions for the dependent variables are autonomous.
Note that the system may still behave as an autonomous system on the interface
of :meth:`integrate` due to use of pre-/post-processors. | [
"Whether",
"the",
"expressions",
"for",
"the",
"dependent",
"variables",
"are",
"autonomous",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L81-L96 | train |
bjodah/pyodesys | pyodesys/symbolic.py | symmetricsys | def symmetricsys(dep_tr=None, indep_tr=None, SuperClass=TransformedSys, **kwargs):
""" A factory function for creating symmetrically transformed systems.
Creates a new subclass which applies the same transformation for each dependent variable.
Parameters
----------
dep_tr : pair of callables (defa... | python | def symmetricsys(dep_tr=None, indep_tr=None, SuperClass=TransformedSys, **kwargs):
""" A factory function for creating symmetrically transformed systems.
Creates a new subclass which applies the same transformation for each dependent variable.
Parameters
----------
dep_tr : pair of callables (defa... | [
"def",
"symmetricsys",
"(",
"dep_tr",
"=",
"None",
",",
"indep_tr",
"=",
"None",
",",
"SuperClass",
"=",
"TransformedSys",
",",
"**",
"kwargs",
")",
":",
"if",
"dep_tr",
"is",
"not",
"None",
":",
"if",
"not",
"callable",
"(",
"dep_tr",
"[",
"0",
"]",
... | A factory function for creating symmetrically transformed systems.
Creates a new subclass which applies the same transformation for each dependent variable.
Parameters
----------
dep_tr : pair of callables (default: None)
Forward and backward transformation callbacks to be applied to the
... | [
"A",
"factory",
"function",
"for",
"creating",
"symmetrically",
"transformed",
"systems",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L961-L1027 | train |
bjodah/pyodesys | pyodesys/symbolic.py | SymbolicSys.from_other | def from_other(cls, ori, **kwargs):
""" Creates a new instance with an existing one as a template.
Parameters
----------
ori : SymbolicSys instance
\\*\\*kwargs:
Keyword arguments used to create the new instance.
Returns
-------
A new instanc... | python | def from_other(cls, ori, **kwargs):
""" Creates a new instance with an existing one as a template.
Parameters
----------
ori : SymbolicSys instance
\\*\\*kwargs:
Keyword arguments used to create the new instance.
Returns
-------
A new instanc... | [
"def",
"from_other",
"(",
"cls",
",",
"ori",
",",
"**",
"kwargs",
")",
":",
"for",
"k",
"in",
"cls",
".",
"_attrs_to_copy",
"+",
"(",
"'params'",
",",
"'roots'",
",",
"'init_indep'",
",",
"'init_dep'",
")",
":",
"if",
"k",
"not",
"in",
"kwargs",
":",... | Creates a new instance with an existing one as a template.
Parameters
----------
ori : SymbolicSys instance
\\*\\*kwargs:
Keyword arguments used to create the new instance.
Returns
-------
A new instance of the class. | [
"Creates",
"a",
"new",
"instance",
"with",
"an",
"existing",
"one",
"as",
"a",
"template",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L466-L508 | train |
bjodah/pyodesys | pyodesys/symbolic.py | SymbolicSys.get_jac | def get_jac(self):
""" Derives the jacobian from ``self.exprs`` and ``self.dep``. """
if self._jac is True:
if self.sparse is True:
self._jac, self._colptrs, self._rowvals = self.be.sparse_jacobian_csc(self.exprs, self.dep)
elif self.band is not None: # Banded
... | python | def get_jac(self):
""" Derives the jacobian from ``self.exprs`` and ``self.dep``. """
if self._jac is True:
if self.sparse is True:
self._jac, self._colptrs, self._rowvals = self.be.sparse_jacobian_csc(self.exprs, self.dep)
elif self.band is not None: # Banded
... | [
"def",
"get_jac",
"(",
"self",
")",
":",
"if",
"self",
".",
"_jac",
"is",
"True",
":",
"if",
"self",
".",
"sparse",
"is",
"True",
":",
"self",
".",
"_jac",
",",
"self",
".",
"_colptrs",
",",
"self",
".",
"_rowvals",
"=",
"self",
".",
"be",
".",
... | Derives the jacobian from ``self.exprs`` and ``self.dep``. | [
"Derives",
"the",
"jacobian",
"from",
"self",
".",
"exprs",
"and",
"self",
".",
"dep",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L637-L650 | train |
bjodah/pyodesys | pyodesys/symbolic.py | SymbolicSys.get_jtimes | def get_jtimes(self):
""" Derive the jacobian-vector product from ``self.exprs`` and ``self.dep``"""
if self._jtimes is False:
return False
if self._jtimes is True:
r = self.be.Dummy('r')
v = tuple(self.be.Dummy('v_{0}'.format(i)) for i in range(self.ny))
... | python | def get_jtimes(self):
""" Derive the jacobian-vector product from ``self.exprs`` and ``self.dep``"""
if self._jtimes is False:
return False
if self._jtimes is True:
r = self.be.Dummy('r')
v = tuple(self.be.Dummy('v_{0}'.format(i)) for i in range(self.ny))
... | [
"def",
"get_jtimes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_jtimes",
"is",
"False",
":",
"return",
"False",
"if",
"self",
".",
"_jtimes",
"is",
"True",
":",
"r",
"=",
"self",
".",
"be",
".",
"Dummy",
"(",
"'r'",
")",
"v",
"=",
"tuple",
"(",
... | Derive the jacobian-vector product from ``self.exprs`` and ``self.dep`` | [
"Derive",
"the",
"jacobian",
"-",
"vector",
"product",
"from",
"self",
".",
"exprs",
"and",
"self",
".",
"dep"
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L652-L664 | train |
bjodah/pyodesys | pyodesys/symbolic.py | SymbolicSys.jacobian_singular | def jacobian_singular(self):
""" Returns True if Jacobian is singular, else False. """
cses, (jac_in_cses,) = self.be.cse(self.get_jac())
if jac_in_cses.nullspace():
return True
else:
return False | python | def jacobian_singular(self):
""" Returns True if Jacobian is singular, else False. """
cses, (jac_in_cses,) = self.be.cse(self.get_jac())
if jac_in_cses.nullspace():
return True
else:
return False | [
"def",
"jacobian_singular",
"(",
"self",
")",
":",
"cses",
",",
"(",
"jac_in_cses",
",",
")",
"=",
"self",
".",
"be",
".",
"cse",
"(",
"self",
".",
"get_jac",
"(",
")",
")",
"if",
"jac_in_cses",
".",
"nullspace",
"(",
")",
":",
"return",
"True",
"e... | Returns True if Jacobian is singular, else False. | [
"Returns",
"True",
"if",
"Jacobian",
"is",
"singular",
"else",
"False",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L666-L672 | train |
bjodah/pyodesys | pyodesys/symbolic.py | SymbolicSys.get_dfdx | def get_dfdx(self):
""" Calculates 2nd derivatives of ``self.exprs`` """
if self._dfdx is True:
if self.indep is None:
zero = 0*self.be.Dummy()**0
self._dfdx = self.be.Matrix(1, self.ny, [zero]*self.ny)
else:
self._dfdx = self.be.Ma... | python | def get_dfdx(self):
""" Calculates 2nd derivatives of ``self.exprs`` """
if self._dfdx is True:
if self.indep is None:
zero = 0*self.be.Dummy()**0
self._dfdx = self.be.Matrix(1, self.ny, [zero]*self.ny)
else:
self._dfdx = self.be.Ma... | [
"def",
"get_dfdx",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dfdx",
"is",
"True",
":",
"if",
"self",
".",
"indep",
"is",
"None",
":",
"zero",
"=",
"0",
"*",
"self",
".",
"be",
".",
"Dummy",
"(",
")",
"**",
"0",
"self",
".",
"_dfdx",
"=",
"s... | Calculates 2nd derivatives of ``self.exprs`` | [
"Calculates",
"2nd",
"derivatives",
"of",
"self",
".",
"exprs"
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L674-L684 | train |
bjodah/pyodesys | pyodesys/symbolic.py | SymbolicSys.get_f_ty_callback | def get_f_ty_callback(self):
""" Generates a callback for evaluating ``self.exprs``. """
cb = self._callback_factory(self.exprs)
lb = self.lower_bounds
ub = self.upper_bounds
if lb is not None or ub is not None:
def _bounds_wrapper(t, y, p=(), be=None):
... | python | def get_f_ty_callback(self):
""" Generates a callback for evaluating ``self.exprs``. """
cb = self._callback_factory(self.exprs)
lb = self.lower_bounds
ub = self.upper_bounds
if lb is not None or ub is not None:
def _bounds_wrapper(t, y, p=(), be=None):
... | [
"def",
"get_f_ty_callback",
"(",
"self",
")",
":",
"cb",
"=",
"self",
".",
"_callback_factory",
"(",
"self",
".",
"exprs",
")",
"lb",
"=",
"self",
".",
"lower_bounds",
"ub",
"=",
"self",
".",
"upper_bounds",
"if",
"lb",
"is",
"not",
"None",
"or",
"ub",... | Generates a callback for evaluating ``self.exprs``. | [
"Generates",
"a",
"callback",
"for",
"evaluating",
"self",
".",
"exprs",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L689-L709 | train |
bjodah/pyodesys | pyodesys/symbolic.py | SymbolicSys.get_j_ty_callback | def get_j_ty_callback(self):
""" Generates a callback for evaluating the jacobian. """
j_exprs = self.get_jac()
if j_exprs is False:
return None
cb = self._callback_factory(j_exprs)
if self.sparse:
from scipy.sparse import csc_matrix
def spars... | python | def get_j_ty_callback(self):
""" Generates a callback for evaluating the jacobian. """
j_exprs = self.get_jac()
if j_exprs is False:
return None
cb = self._callback_factory(j_exprs)
if self.sparse:
from scipy.sparse import csc_matrix
def spars... | [
"def",
"get_j_ty_callback",
"(",
"self",
")",
":",
"j_exprs",
"=",
"self",
".",
"get_jac",
"(",
")",
"if",
"j_exprs",
"is",
"False",
":",
"return",
"None",
"cb",
"=",
"self",
".",
"_callback_factory",
"(",
"j_exprs",
")",
"if",
"self",
".",
"sparse",
"... | Generates a callback for evaluating the jacobian. | [
"Generates",
"a",
"callback",
"for",
"evaluating",
"the",
"jacobian",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L711-L726 | train |
bjodah/pyodesys | pyodesys/symbolic.py | SymbolicSys.get_dfdx_callback | def get_dfdx_callback(self):
""" Generate a callback for evaluating derivative of ``self.exprs`` """
dfdx_exprs = self.get_dfdx()
if dfdx_exprs is False:
return None
return self._callback_factory(dfdx_exprs) | python | def get_dfdx_callback(self):
""" Generate a callback for evaluating derivative of ``self.exprs`` """
dfdx_exprs = self.get_dfdx()
if dfdx_exprs is False:
return None
return self._callback_factory(dfdx_exprs) | [
"def",
"get_dfdx_callback",
"(",
"self",
")",
":",
"dfdx_exprs",
"=",
"self",
".",
"get_dfdx",
"(",
")",
"if",
"dfdx_exprs",
"is",
"False",
":",
"return",
"None",
"return",
"self",
".",
"_callback_factory",
"(",
"dfdx_exprs",
")"
] | Generate a callback for evaluating derivative of ``self.exprs`` | [
"Generate",
"a",
"callback",
"for",
"evaluating",
"derivative",
"of",
"self",
".",
"exprs"
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L728-L733 | train |
bjodah/pyodesys | pyodesys/symbolic.py | SymbolicSys.get_jtimes_callback | def get_jtimes_callback(self):
""" Generate a callback fro evaluating the jacobian-vector product."""
jtimes = self.get_jtimes()
if jtimes is False:
return None
v, jtimes_exprs = jtimes
return _Callback(self.indep, tuple(self.dep) + tuple(v), self.params,
... | python | def get_jtimes_callback(self):
""" Generate a callback fro evaluating the jacobian-vector product."""
jtimes = self.get_jtimes()
if jtimes is False:
return None
v, jtimes_exprs = jtimes
return _Callback(self.indep, tuple(self.dep) + tuple(v), self.params,
... | [
"def",
"get_jtimes_callback",
"(",
"self",
")",
":",
"jtimes",
"=",
"self",
".",
"get_jtimes",
"(",
")",
"if",
"jtimes",
"is",
"False",
":",
"return",
"None",
"v",
",",
"jtimes_exprs",
"=",
"jtimes",
"return",
"_Callback",
"(",
"self",
".",
"indep",
",",... | Generate a callback fro evaluating the jacobian-vector product. | [
"Generate",
"a",
"callback",
"fro",
"evaluating",
"the",
"jacobian",
"-",
"vector",
"product",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L735-L742 | train |
bjodah/pyodesys | pyodesys/symbolic.py | PartiallySolvedSystem.from_linear_invariants | def from_linear_invariants(cls, ori_sys, preferred=None, **kwargs):
""" Reformulates the ODE system in fewer variables.
Given linear invariant equations one can always reduce the number
of dependent variables in the system by the rank of the matrix describing
this linear system.
... | python | def from_linear_invariants(cls, ori_sys, preferred=None, **kwargs):
""" Reformulates the ODE system in fewer variables.
Given linear invariant equations one can always reduce the number
of dependent variables in the system by the rank of the matrix describing
this linear system.
... | [
"def",
"from_linear_invariants",
"(",
"cls",
",",
"ori_sys",
",",
"preferred",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"_be",
"=",
"ori_sys",
".",
"be",
"A",
"=",
"_be",
".",
"Matrix",
"(",
"ori_sys",
".",
"linear_invariants",
")",
"rA",
",",
"pivo... | Reformulates the ODE system in fewer variables.
Given linear invariant equations one can always reduce the number
of dependent variables in the system by the rank of the matrix describing
this linear system.
Parameters
----------
ori_sys : :class:`SymbolicSys` instance
... | [
"Reformulates",
"the",
"ODE",
"system",
"in",
"fewer",
"variables",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L1275-L1335 | train |
bjodah/pyodesys | pyodesys/core.py | chained_parameter_variation | def chained_parameter_variation(subject, durations, y0, varied_params, default_params=None,
integrate_kwargs=None, x0=None, npoints=1, numpy=None):
""" Integrate an ODE-system for a serie of durations with some parameters changed in-between
Parameters
----------
subject ... | python | def chained_parameter_variation(subject, durations, y0, varied_params, default_params=None,
integrate_kwargs=None, x0=None, npoints=1, numpy=None):
""" Integrate an ODE-system for a serie of durations with some parameters changed in-between
Parameters
----------
subject ... | [
"def",
"chained_parameter_variation",
"(",
"subject",
",",
"durations",
",",
"y0",
",",
"varied_params",
",",
"default_params",
"=",
"None",
",",
"integrate_kwargs",
"=",
"None",
",",
"x0",
"=",
"None",
",",
"npoints",
"=",
"1",
",",
"numpy",
"=",
"None",
... | Integrate an ODE-system for a serie of durations with some parameters changed in-between
Parameters
----------
subject : function or ODESys instance
If a function: should have the signature of :meth:`pyodesys.ODESys.integrate`
(and resturn a :class:`pyodesys.results.Result` object).
... | [
"Integrate",
"an",
"ODE",
"-",
"system",
"for",
"a",
"serie",
"of",
"durations",
"with",
"some",
"parameters",
"changed",
"in",
"-",
"between"
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L917-L996 | train |
bjodah/pyodesys | pyodesys/core.py | ODESys.pre_process | def pre_process(self, xout, y0, params=()):
""" Transforms input to internal values, used internally. """
for pre_processor in self.pre_processors:
xout, y0, params = pre_processor(xout, y0, params)
return [self.numpy.atleast_1d(arr) for arr in (xout, y0, params)] | python | def pre_process(self, xout, y0, params=()):
""" Transforms input to internal values, used internally. """
for pre_processor in self.pre_processors:
xout, y0, params = pre_processor(xout, y0, params)
return [self.numpy.atleast_1d(arr) for arr in (xout, y0, params)] | [
"def",
"pre_process",
"(",
"self",
",",
"xout",
",",
"y0",
",",
"params",
"=",
"(",
")",
")",
":",
"for",
"pre_processor",
"in",
"self",
".",
"pre_processors",
":",
"xout",
",",
"y0",
",",
"params",
"=",
"pre_processor",
"(",
"xout",
",",
"y0",
",",
... | Transforms input to internal values, used internally. | [
"Transforms",
"input",
"to",
"internal",
"values",
"used",
"internally",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L286-L290 | train |
bjodah/pyodesys | pyodesys/core.py | ODESys.post_process | def post_process(self, xout, yout, params):
""" Transforms internal values to output, used internally. """
for post_processor in self.post_processors:
xout, yout, params = post_processor(xout, yout, params)
return xout, yout, params | python | def post_process(self, xout, yout, params):
""" Transforms internal values to output, used internally. """
for post_processor in self.post_processors:
xout, yout, params = post_processor(xout, yout, params)
return xout, yout, params | [
"def",
"post_process",
"(",
"self",
",",
"xout",
",",
"yout",
",",
"params",
")",
":",
"for",
"post_processor",
"in",
"self",
".",
"post_processors",
":",
"xout",
",",
"yout",
",",
"params",
"=",
"post_processor",
"(",
"xout",
",",
"yout",
",",
"params",... | Transforms internal values to output, used internally. | [
"Transforms",
"internal",
"values",
"to",
"output",
"used",
"internally",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L292-L296 | train |
bjodah/pyodesys | pyodesys/core.py | ODESys.adaptive | def adaptive(self, y0, x0, xend, params=(), **kwargs):
""" Integrate with integrator chosen output.
Parameters
----------
integrator : str
See :meth:`integrate`.
y0 : array_like
See :meth:`integrate`.
x0 : float
Initial value of the in... | python | def adaptive(self, y0, x0, xend, params=(), **kwargs):
""" Integrate with integrator chosen output.
Parameters
----------
integrator : str
See :meth:`integrate`.
y0 : array_like
See :meth:`integrate`.
x0 : float
Initial value of the in... | [
"def",
"adaptive",
"(",
"self",
",",
"y0",
",",
"x0",
",",
"xend",
",",
"params",
"=",
"(",
")",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"integrate",
"(",
"(",
"x0",
",",
"xend",
")",
",",
"y0",
",",
"params",
"=",
"params",
",",
... | Integrate with integrator chosen output.
Parameters
----------
integrator : str
See :meth:`integrate`.
y0 : array_like
See :meth:`integrate`.
x0 : float
Initial value of the independent variable.
xend : float
Final value of... | [
"Integrate",
"with",
"integrator",
"chosen",
"output",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L298-L321 | train |
bjodah/pyodesys | pyodesys/core.py | ODESys.predefined | def predefined(self, y0, xout, params=(), **kwargs):
""" Integrate with user chosen output.
Parameters
----------
integrator : str
See :meth:`integrate`.
y0 : array_like
See :meth:`integrate`.
xout : array_like
params : array_like
... | python | def predefined(self, y0, xout, params=(), **kwargs):
""" Integrate with user chosen output.
Parameters
----------
integrator : str
See :meth:`integrate`.
y0 : array_like
See :meth:`integrate`.
xout : array_like
params : array_like
... | [
"def",
"predefined",
"(",
"self",
",",
"y0",
",",
"xout",
",",
"params",
"=",
"(",
")",
",",
"**",
"kwargs",
")",
":",
"xout",
",",
"yout",
",",
"info",
"=",
"self",
".",
"integrate",
"(",
"xout",
",",
"y0",
",",
"params",
"=",
"params",
",",
"... | Integrate with user chosen output.
Parameters
----------
integrator : str
See :meth:`integrate`.
y0 : array_like
See :meth:`integrate`.
xout : array_like
params : array_like
See :meth:`integrate`.
\*\*kwargs:
See :m... | [
"Integrate",
"with",
"user",
"chosen",
"output",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L323-L345 | train |
bjodah/pyodesys | pyodesys/core.py | ODESys.integrate | def integrate(self, x, y0, params=(), atol=1e-8, rtol=1e-8, **kwargs):
""" Integrate the system of ordinary differential equations.
Solves the initial value problem (IVP).
Parameters
----------
x : array_like or pair (start and final time) or float
if float:
... | python | def integrate(self, x, y0, params=(), atol=1e-8, rtol=1e-8, **kwargs):
""" Integrate the system of ordinary differential equations.
Solves the initial value problem (IVP).
Parameters
----------
x : array_like or pair (start and final time) or float
if float:
... | [
"def",
"integrate",
"(",
"self",
",",
"x",
",",
"y0",
",",
"params",
"=",
"(",
")",
",",
"atol",
"=",
"1e-8",
",",
"rtol",
"=",
"1e-8",
",",
"**",
"kwargs",
")",
":",
"arrs",
"=",
"self",
".",
"to_arrays",
"(",
"x",
",",
"y0",
",",
"params",
... | Integrate the system of ordinary differential equations.
Solves the initial value problem (IVP).
Parameters
----------
x : array_like or pair (start and final time) or float
if float:
make it a pair: (0, x)
if pair or length-2 array:
... | [
"Integrate",
"the",
"system",
"of",
"ordinary",
"differential",
"equations",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L347-L449 | train |
bjodah/pyodesys | pyodesys/core.py | ODESys.plot_phase_plane | def plot_phase_plane(self, indices=None, **kwargs):
""" Plots a phase portrait from last integration.
This method will be deprecated. Please use :meth:`Result.plot_phase_plane`.
See :func:`pyodesys.plotting.plot_phase_plane`
"""
return self._plot(plot_phase_plane, indices=indice... | python | def plot_phase_plane(self, indices=None, **kwargs):
""" Plots a phase portrait from last integration.
This method will be deprecated. Please use :meth:`Result.plot_phase_plane`.
See :func:`pyodesys.plotting.plot_phase_plane`
"""
return self._plot(plot_phase_plane, indices=indice... | [
"def",
"plot_phase_plane",
"(",
"self",
",",
"indices",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"_plot",
"(",
"plot_phase_plane",
",",
"indices",
"=",
"indices",
",",
"**",
"kwargs",
")"
] | Plots a phase portrait from last integration.
This method will be deprecated. Please use :meth:`Result.plot_phase_plane`.
See :func:`pyodesys.plotting.plot_phase_plane` | [
"Plots",
"a",
"phase",
"portrait",
"from",
"last",
"integration",
"."
] | 0034a6165b550d8d9808baef58678dca5a493ab7 | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L756-L762 | train |
neon-jungle/wagtailnews | wagtailnews/permissions.py | user_can_edit_news | def user_can_edit_news(user):
"""
Check if the user has permission to edit any of the registered NewsItem
types.
"""
newsitem_models = [model.get_newsitem_model()
for model in NEWSINDEX_MODEL_CLASSES]
if user.is_active and user.is_superuser:
# admin can edit news ... | python | def user_can_edit_news(user):
"""
Check if the user has permission to edit any of the registered NewsItem
types.
"""
newsitem_models = [model.get_newsitem_model()
for model in NEWSINDEX_MODEL_CLASSES]
if user.is_active and user.is_superuser:
# admin can edit news ... | [
"def",
"user_can_edit_news",
"(",
"user",
")",
":",
"newsitem_models",
"=",
"[",
"model",
".",
"get_newsitem_model",
"(",
")",
"for",
"model",
"in",
"NEWSINDEX_MODEL_CLASSES",
"]",
"if",
"user",
".",
"is_active",
"and",
"user",
".",
"is_superuser",
":",
"retur... | Check if the user has permission to edit any of the registered NewsItem
types. | [
"Check",
"if",
"the",
"user",
"has",
"permission",
"to",
"edit",
"any",
"of",
"the",
"registered",
"NewsItem",
"types",
"."
] | 4cdec7013cca276dcfc658d3c986444ba6a42a84 | https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/permissions.py#L21-L38 | train |
neon-jungle/wagtailnews | wagtailnews/permissions.py | user_can_edit_newsitem | def user_can_edit_newsitem(user, NewsItem):
"""
Check if the user has permission to edit a particular NewsItem type.
"""
for perm in format_perms(NewsItem, ['add', 'change', 'delete']):
if user.has_perm(perm):
return True
return False | python | def user_can_edit_newsitem(user, NewsItem):
"""
Check if the user has permission to edit a particular NewsItem type.
"""
for perm in format_perms(NewsItem, ['add', 'change', 'delete']):
if user.has_perm(perm):
return True
return False | [
"def",
"user_can_edit_newsitem",
"(",
"user",
",",
"NewsItem",
")",
":",
"for",
"perm",
"in",
"format_perms",
"(",
"NewsItem",
",",
"[",
"'add'",
",",
"'change'",
",",
"'delete'",
"]",
")",
":",
"if",
"user",
".",
"has_perm",
"(",
"perm",
")",
":",
"re... | Check if the user has permission to edit a particular NewsItem type. | [
"Check",
"if",
"the",
"user",
"has",
"permission",
"to",
"edit",
"a",
"particular",
"NewsItem",
"type",
"."
] | 4cdec7013cca276dcfc658d3c986444ba6a42a84 | https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/permissions.py#L41-L49 | train |
neon-jungle/wagtailnews | wagtailnews/models.py | get_date_or_404 | def get_date_or_404(year, month, day):
"""Try to make a date from the given inputs, raising Http404 on error"""
try:
return datetime.date(int(year), int(month), int(day))
except ValueError:
raise Http404 | python | def get_date_or_404(year, month, day):
"""Try to make a date from the given inputs, raising Http404 on error"""
try:
return datetime.date(int(year), int(month), int(day))
except ValueError:
raise Http404 | [
"def",
"get_date_or_404",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"try",
":",
"return",
"datetime",
".",
"date",
"(",
"int",
"(",
"year",
")",
",",
"int",
"(",
"month",
")",
",",
"int",
"(",
"day",
")",
")",
"except",
"ValueError",
":",
... | Try to make a date from the given inputs, raising Http404 on error | [
"Try",
"to",
"make",
"a",
"date",
"from",
"the",
"given",
"inputs",
"raising",
"Http404",
"on",
"error"
] | 4cdec7013cca276dcfc658d3c986444ba6a42a84 | https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/models.py#L29-L34 | train |
neon-jungle/wagtailnews | wagtailnews/models.py | NewsIndexMixin.respond | def respond(self, request, view, newsitems, extra_context={}):
"""A helper that takes some news items and returns an HttpResponse"""
context = self.get_context(request, view=view)
context.update(self.paginate_newsitems(request, newsitems))
context.update(extra_context)
template =... | python | def respond(self, request, view, newsitems, extra_context={}):
"""A helper that takes some news items and returns an HttpResponse"""
context = self.get_context(request, view=view)
context.update(self.paginate_newsitems(request, newsitems))
context.update(extra_context)
template =... | [
"def",
"respond",
"(",
"self",
",",
"request",
",",
"view",
",",
"newsitems",
",",
"extra_context",
"=",
"{",
"}",
")",
":",
"context",
"=",
"self",
".",
"get_context",
"(",
"request",
",",
"view",
"=",
"view",
")",
"context",
".",
"update",
"(",
"se... | A helper that takes some news items and returns an HttpResponse | [
"A",
"helper",
"that",
"takes",
"some",
"news",
"items",
"and",
"returns",
"an",
"HttpResponse"
] | 4cdec7013cca276dcfc658d3c986444ba6a42a84 | https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/models.py#L80-L86 | train |
neon-jungle/wagtailnews | wagtailnews/views/chooser.py | get_newsitem_model | def get_newsitem_model(model_string):
"""
Get the NewsItem model from a model string. Raises ValueError if the model
string is invalid, or references a model that is not a NewsItem.
"""
try:
NewsItem = apps.get_model(model_string)
assert issubclass(NewsItem, AbstractNewsItem)
exc... | python | def get_newsitem_model(model_string):
"""
Get the NewsItem model from a model string. Raises ValueError if the model
string is invalid, or references a model that is not a NewsItem.
"""
try:
NewsItem = apps.get_model(model_string)
assert issubclass(NewsItem, AbstractNewsItem)
exc... | [
"def",
"get_newsitem_model",
"(",
"model_string",
")",
":",
"try",
":",
"NewsItem",
"=",
"apps",
".",
"get_model",
"(",
"model_string",
")",
"assert",
"issubclass",
"(",
"NewsItem",
",",
"AbstractNewsItem",
")",
"except",
"(",
"ValueError",
",",
"LookupError",
... | Get the NewsItem model from a model string. Raises ValueError if the model
string is invalid, or references a model that is not a NewsItem. | [
"Get",
"the",
"NewsItem",
"model",
"from",
"a",
"model",
"string",
".",
"Raises",
"ValueError",
"if",
"the",
"model",
"string",
"is",
"invalid",
"or",
"references",
"a",
"model",
"that",
"is",
"not",
"a",
"NewsItem",
"."
] | 4cdec7013cca276dcfc658d3c986444ba6a42a84 | https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/views/chooser.py#L119-L129 | train |
geometalab/pyGeoTile | pygeotile/tile.py | Tile.from_quad_tree | def from_quad_tree(cls, quad_tree):
"""Creates a tile from a Microsoft QuadTree"""
assert bool(re.match('^[0-3]*$', quad_tree)), 'QuadTree value can only consists of the digits 0, 1, 2 and 3.'
zoom = len(str(quad_tree))
offset = int(math.pow(2, zoom)) - 1
google_x, google_y = [re... | python | def from_quad_tree(cls, quad_tree):
"""Creates a tile from a Microsoft QuadTree"""
assert bool(re.match('^[0-3]*$', quad_tree)), 'QuadTree value can only consists of the digits 0, 1, 2 and 3.'
zoom = len(str(quad_tree))
offset = int(math.pow(2, zoom)) - 1
google_x, google_y = [re... | [
"def",
"from_quad_tree",
"(",
"cls",
",",
"quad_tree",
")",
":",
"assert",
"bool",
"(",
"re",
".",
"match",
"(",
"'^[0-3]*$'",
",",
"quad_tree",
")",
")",
",",
"'QuadTree value can only consists of the digits 0, 1, 2 and 3.'",
"zoom",
"=",
"len",
"(",
"str",
"("... | Creates a tile from a Microsoft QuadTree | [
"Creates",
"a",
"tile",
"from",
"a",
"Microsoft",
"QuadTree"
] | b1f44271698f5fc4d18c2add935797ed43254aa6 | https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L16-L24 | train |
geometalab/pyGeoTile | pygeotile/tile.py | Tile.from_google | def from_google(cls, google_x, google_y, zoom):
"""Creates a tile from Google format X Y and zoom"""
max_tile = (2 ** zoom) - 1
assert 0 <= google_x <= max_tile, 'Google X needs to be a value between 0 and (2^zoom) -1.'
assert 0 <= google_y <= max_tile, 'Google Y needs to be a value betw... | python | def from_google(cls, google_x, google_y, zoom):
"""Creates a tile from Google format X Y and zoom"""
max_tile = (2 ** zoom) - 1
assert 0 <= google_x <= max_tile, 'Google X needs to be a value between 0 and (2^zoom) -1.'
assert 0 <= google_y <= max_tile, 'Google Y needs to be a value betw... | [
"def",
"from_google",
"(",
"cls",
",",
"google_x",
",",
"google_y",
",",
"zoom",
")",
":",
"max_tile",
"=",
"(",
"2",
"**",
"zoom",
")",
"-",
"1",
"assert",
"0",
"<=",
"google_x",
"<=",
"max_tile",
",",
"'Google X needs to be a value between 0 and (2^zoom) -1.... | Creates a tile from Google format X Y and zoom | [
"Creates",
"a",
"tile",
"from",
"Google",
"format",
"X",
"Y",
"and",
"zoom"
] | b1f44271698f5fc4d18c2add935797ed43254aa6 | https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L35-L40 | train |
geometalab/pyGeoTile | pygeotile/tile.py | Tile.for_point | def for_point(cls, point, zoom):
"""Creates a tile for given point"""
latitude, longitude = point.latitude_longitude
return cls.for_latitude_longitude(latitude=latitude, longitude=longitude, zoom=zoom) | python | def for_point(cls, point, zoom):
"""Creates a tile for given point"""
latitude, longitude = point.latitude_longitude
return cls.for_latitude_longitude(latitude=latitude, longitude=longitude, zoom=zoom) | [
"def",
"for_point",
"(",
"cls",
",",
"point",
",",
"zoom",
")",
":",
"latitude",
",",
"longitude",
"=",
"point",
".",
"latitude_longitude",
"return",
"cls",
".",
"for_latitude_longitude",
"(",
"latitude",
"=",
"latitude",
",",
"longitude",
"=",
"longitude",
... | Creates a tile for given point | [
"Creates",
"a",
"tile",
"for",
"given",
"point"
] | b1f44271698f5fc4d18c2add935797ed43254aa6 | https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L43-L46 | train |
geometalab/pyGeoTile | pygeotile/tile.py | Tile.quad_tree | def quad_tree(self):
"""Gets the tile in the Microsoft QuadTree format, converted from TMS"""
value = ''
tms_x, tms_y = self.tms
tms_y = (2 ** self.zoom - 1) - tms_y
for i in range(self.zoom, 0, -1):
digit = 0
mask = 1 << (i - 1)
if (tms_x & ma... | python | def quad_tree(self):
"""Gets the tile in the Microsoft QuadTree format, converted from TMS"""
value = ''
tms_x, tms_y = self.tms
tms_y = (2 ** self.zoom - 1) - tms_y
for i in range(self.zoom, 0, -1):
digit = 0
mask = 1 << (i - 1)
if (tms_x & ma... | [
"def",
"quad_tree",
"(",
"self",
")",
":",
"value",
"=",
"''",
"tms_x",
",",
"tms_y",
"=",
"self",
".",
"tms",
"tms_y",
"=",
"(",
"2",
"**",
"self",
".",
"zoom",
"-",
"1",
")",
"-",
"tms_y",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"zoom",
... | Gets the tile in the Microsoft QuadTree format, converted from TMS | [
"Gets",
"the",
"tile",
"in",
"the",
"Microsoft",
"QuadTree",
"format",
"converted",
"from",
"TMS"
] | b1f44271698f5fc4d18c2add935797ed43254aa6 | https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L75-L88 | train |
geometalab/pyGeoTile | pygeotile/tile.py | Tile.google | def google(self):
"""Gets the tile in the Google format, converted from TMS"""
tms_x, tms_y = self.tms
return tms_x, (2 ** self.zoom - 1) - tms_y | python | def google(self):
"""Gets the tile in the Google format, converted from TMS"""
tms_x, tms_y = self.tms
return tms_x, (2 ** self.zoom - 1) - tms_y | [
"def",
"google",
"(",
"self",
")",
":",
"tms_x",
",",
"tms_y",
"=",
"self",
".",
"tms",
"return",
"tms_x",
",",
"(",
"2",
"**",
"self",
".",
"zoom",
"-",
"1",
")",
"-",
"tms_y"
] | Gets the tile in the Google format, converted from TMS | [
"Gets",
"the",
"tile",
"in",
"the",
"Google",
"format",
"converted",
"from",
"TMS"
] | b1f44271698f5fc4d18c2add935797ed43254aa6 | https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L91-L94 | train |
geometalab/pyGeoTile | pygeotile/tile.py | Tile.bounds | def bounds(self):
"""Gets the bounds of a tile represented as the most west and south point and the most east and north point"""
google_x, google_y = self.google
pixel_x_west, pixel_y_north = google_x * TILE_SIZE, google_y * TILE_SIZE
pixel_x_east, pixel_y_south = (google_x + 1) * TILE_S... | python | def bounds(self):
"""Gets the bounds of a tile represented as the most west and south point and the most east and north point"""
google_x, google_y = self.google
pixel_x_west, pixel_y_north = google_x * TILE_SIZE, google_y * TILE_SIZE
pixel_x_east, pixel_y_south = (google_x + 1) * TILE_S... | [
"def",
"bounds",
"(",
"self",
")",
":",
"google_x",
",",
"google_y",
"=",
"self",
".",
"google",
"pixel_x_west",
",",
"pixel_y_north",
"=",
"google_x",
"*",
"TILE_SIZE",
",",
"google_y",
"*",
"TILE_SIZE",
"pixel_x_east",
",",
"pixel_y_south",
"=",
"(",
"goog... | Gets the bounds of a tile represented as the most west and south point and the most east and north point | [
"Gets",
"the",
"bounds",
"of",
"a",
"tile",
"represented",
"as",
"the",
"most",
"west",
"and",
"south",
"point",
"and",
"the",
"most",
"east",
"and",
"north",
"point"
] | b1f44271698f5fc4d18c2add935797ed43254aa6 | https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L97-L105 | train |
IAMconsortium/pyam | pyam/read_ixmp.py | read_ix | def read_ix(ix, **kwargs):
"""Read timeseries data from an ixmp object
Parameters
----------
ix: ixmp.TimeSeries or ixmp.Scenario
this option requires the ixmp package as a dependency
kwargs: arguments passed to ixmp.TimeSeries.timeseries()
"""
if not isinstance(ix, ixmp.TimeSeries)... | python | def read_ix(ix, **kwargs):
"""Read timeseries data from an ixmp object
Parameters
----------
ix: ixmp.TimeSeries or ixmp.Scenario
this option requires the ixmp package as a dependency
kwargs: arguments passed to ixmp.TimeSeries.timeseries()
"""
if not isinstance(ix, ixmp.TimeSeries)... | [
"def",
"read_ix",
"(",
"ix",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"ix",
",",
"ixmp",
".",
"TimeSeries",
")",
":",
"error",
"=",
"'not recognized as valid ixmp class: {}'",
".",
"format",
"(",
"ix",
")",
"raise",
"ValueError",
"(",... | Read timeseries data from an ixmp object
Parameters
----------
ix: ixmp.TimeSeries or ixmp.Scenario
this option requires the ixmp package as a dependency
kwargs: arguments passed to ixmp.TimeSeries.timeseries() | [
"Read",
"timeseries",
"data",
"from",
"an",
"ixmp",
"object"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/read_ixmp.py#L8-L24 | train |
IAMconsortium/pyam | pyam/utils.py | requires_package | def requires_package(pkg, msg, error_type=ImportError):
"""Decorator when a function requires an optional dependency
Parameters
----------
pkg : imported package object
msg : string
Message to show to user with error_type
error_type : python error class
"""
def _requires_package... | python | def requires_package(pkg, msg, error_type=ImportError):
"""Decorator when a function requires an optional dependency
Parameters
----------
pkg : imported package object
msg : string
Message to show to user with error_type
error_type : python error class
"""
def _requires_package... | [
"def",
"requires_package",
"(",
"pkg",
",",
"msg",
",",
"error_type",
"=",
"ImportError",
")",
":",
"def",
"_requires_package",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"pkg",
"is",
"None",
":",
... | Decorator when a function requires an optional dependency
Parameters
----------
pkg : imported package object
msg : string
Message to show to user with error_type
error_type : python error class | [
"Decorator",
"when",
"a",
"function",
"requires",
"an",
"optional",
"dependency"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L36-L52 | train |
IAMconsortium/pyam | pyam/utils.py | write_sheet | def write_sheet(writer, name, df, index=False):
"""Write a pandas DataFrame to an ExcelWriter,
auto-formatting column width depending on maxwidth of data and colum header
Parameters
----------
writer: pandas.ExcelWriter
an instance of a pandas ExcelWriter
name: string
name of th... | python | def write_sheet(writer, name, df, index=False):
"""Write a pandas DataFrame to an ExcelWriter,
auto-formatting column width depending on maxwidth of data and colum header
Parameters
----------
writer: pandas.ExcelWriter
an instance of a pandas ExcelWriter
name: string
name of th... | [
"def",
"write_sheet",
"(",
"writer",
",",
"name",
",",
"df",
",",
"index",
"=",
"False",
")",
":",
"if",
"index",
":",
"df",
"=",
"df",
".",
"reset_index",
"(",
")",
"df",
".",
"to_excel",
"(",
"writer",
",",
"name",
",",
"index",
"=",
"False",
"... | Write a pandas DataFrame to an ExcelWriter,
auto-formatting column width depending on maxwidth of data and colum header
Parameters
----------
writer: pandas.ExcelWriter
an instance of a pandas ExcelWriter
name: string
name of the sheet to be written
df: pandas.DataFrame
... | [
"Write",
"a",
"pandas",
"DataFrame",
"to",
"an",
"ExcelWriter",
"auto",
"-",
"formatting",
"column",
"width",
"depending",
"on",
"maxwidth",
"of",
"data",
"and",
"colum",
"header"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L70-L96 | train |
IAMconsortium/pyam | pyam/utils.py | read_pandas | def read_pandas(fname, *args, **kwargs):
"""Read a file and return a pd.DataFrame"""
if not os.path.exists(fname):
raise ValueError('no data file `{}` found!'.format(fname))
if fname.endswith('csv'):
df = pd.read_csv(fname, *args, **kwargs)
else:
xl = pd.ExcelFile(fname)
... | python | def read_pandas(fname, *args, **kwargs):
"""Read a file and return a pd.DataFrame"""
if not os.path.exists(fname):
raise ValueError('no data file `{}` found!'.format(fname))
if fname.endswith('csv'):
df = pd.read_csv(fname, *args, **kwargs)
else:
xl = pd.ExcelFile(fname)
... | [
"def",
"read_pandas",
"(",
"fname",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fname",
")",
":",
"raise",
"ValueError",
"(",
"'no data file `{}` found!'",
".",
"format",
"(",
"fname",
")",
")",... | Read a file and return a pd.DataFrame | [
"Read",
"a",
"file",
"and",
"return",
"a",
"pd",
".",
"DataFrame"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L99-L110 | train |
IAMconsortium/pyam | pyam/utils.py | sort_data | def sort_data(data, cols):
"""Sort `data` rows and order columns"""
return data.sort_values(cols)[cols + ['value']].reset_index(drop=True) | python | def sort_data(data, cols):
"""Sort `data` rows and order columns"""
return data.sort_values(cols)[cols + ['value']].reset_index(drop=True) | [
"def",
"sort_data",
"(",
"data",
",",
"cols",
")",
":",
"return",
"data",
".",
"sort_values",
"(",
"cols",
")",
"[",
"cols",
"+",
"[",
"'value'",
"]",
"]",
".",
"reset_index",
"(",
"drop",
"=",
"True",
")"
] | Sort `data` rows and order columns | [
"Sort",
"data",
"rows",
"and",
"order",
"columns"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L258-L260 | train |
IAMconsortium/pyam | pyam/utils.py | _escape_regexp | def _escape_regexp(s):
"""escape characters with specific regexp use"""
return (
str(s)
.replace('|', '\\|')
.replace('.', '\.') # `.` has to be replaced before `*`
.replace('*', '.*')
.replace('+', '\+')
.replace('(', '\(')
.replace(')', '\)')
.r... | python | def _escape_regexp(s):
"""escape characters with specific regexp use"""
return (
str(s)
.replace('|', '\\|')
.replace('.', '\.') # `.` has to be replaced before `*`
.replace('*', '.*')
.replace('+', '\+')
.replace('(', '\(')
.replace(')', '\)')
.r... | [
"def",
"_escape_regexp",
"(",
"s",
")",
":",
"return",
"(",
"str",
"(",
"s",
")",
".",
"replace",
"(",
"'|'",
",",
"'\\\\|'",
")",
".",
"replace",
"(",
"'.'",
",",
"'\\.'",
")",
".",
"replace",
"(",
"'*'",
",",
"'.*'",
")",
".",
"replace",
"(",
... | escape characters with specific regexp use | [
"escape",
"characters",
"with",
"specific",
"regexp",
"use"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L332-L343 | train |
IAMconsortium/pyam | pyam/utils.py | years_match | def years_match(data, years):
"""
matching of year columns for data filtering
"""
years = [years] if isinstance(years, int) else years
dt = datetime.datetime
if isinstance(years, dt) or isinstance(years[0], dt):
error_msg = "`year` can only be filtered with ints or lists of ints"
... | python | def years_match(data, years):
"""
matching of year columns for data filtering
"""
years = [years] if isinstance(years, int) else years
dt = datetime.datetime
if isinstance(years, dt) or isinstance(years[0], dt):
error_msg = "`year` can only be filtered with ints or lists of ints"
... | [
"def",
"years_match",
"(",
"data",
",",
"years",
")",
":",
"years",
"=",
"[",
"years",
"]",
"if",
"isinstance",
"(",
"years",
",",
"int",
")",
"else",
"years",
"dt",
"=",
"datetime",
".",
"datetime",
"if",
"isinstance",
"(",
"years",
",",
"dt",
")",
... | matching of year columns for data filtering | [
"matching",
"of",
"year",
"columns",
"for",
"data",
"filtering"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L346-L355 | train |
IAMconsortium/pyam | pyam/utils.py | hour_match | def hour_match(data, hours):
"""
matching of days in time columns for data filtering
"""
hours = [hours] if isinstance(hours, int) else hours
return data.isin(hours) | python | def hour_match(data, hours):
"""
matching of days in time columns for data filtering
"""
hours = [hours] if isinstance(hours, int) else hours
return data.isin(hours) | [
"def",
"hour_match",
"(",
"data",
",",
"hours",
")",
":",
"hours",
"=",
"[",
"hours",
"]",
"if",
"isinstance",
"(",
"hours",
",",
"int",
")",
"else",
"hours",
"return",
"data",
".",
"isin",
"(",
"hours",
")"
] | matching of days in time columns for data filtering | [
"matching",
"of",
"days",
"in",
"time",
"columns",
"for",
"data",
"filtering"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L372-L377 | train |
IAMconsortium/pyam | pyam/utils.py | datetime_match | def datetime_match(data, dts):
"""
matching of datetimes in time columns for data filtering
"""
dts = dts if islistable(dts) else [dts]
if any([not isinstance(i, datetime.datetime) for i in dts]):
error_msg = (
"`time` can only be filtered by datetimes"
)
raise Ty... | python | def datetime_match(data, dts):
"""
matching of datetimes in time columns for data filtering
"""
dts = dts if islistable(dts) else [dts]
if any([not isinstance(i, datetime.datetime) for i in dts]):
error_msg = (
"`time` can only be filtered by datetimes"
)
raise Ty... | [
"def",
"datetime_match",
"(",
"data",
",",
"dts",
")",
":",
"dts",
"=",
"dts",
"if",
"islistable",
"(",
"dts",
")",
"else",
"[",
"dts",
"]",
"if",
"any",
"(",
"[",
"not",
"isinstance",
"(",
"i",
",",
"datetime",
".",
"datetime",
")",
"for",
"i",
... | matching of datetimes in time columns for data filtering | [
"matching",
"of",
"datetimes",
"in",
"time",
"columns",
"for",
"data",
"filtering"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L422-L432 | train |
IAMconsortium/pyam | pyam/utils.py | to_int | def to_int(x, index=False):
"""Formatting series or timeseries columns to int and checking validity.
If `index=False`, the function works on the `pd.Series x`; else,
the function casts the index of `x` to int and returns x with a new index.
"""
_x = x.index if index else x
cols = list(map(int, _... | python | def to_int(x, index=False):
"""Formatting series or timeseries columns to int and checking validity.
If `index=False`, the function works on the `pd.Series x`; else,
the function casts the index of `x` to int and returns x with a new index.
"""
_x = x.index if index else x
cols = list(map(int, _... | [
"def",
"to_int",
"(",
"x",
",",
"index",
"=",
"False",
")",
":",
"_x",
"=",
"x",
".",
"index",
"if",
"index",
"else",
"x",
"cols",
"=",
"list",
"(",
"map",
"(",
"int",
",",
"_x",
")",
")",
"error",
"=",
"_x",
"[",
"cols",
"!=",
"_x",
"]",
"... | Formatting series or timeseries columns to int and checking validity.
If `index=False`, the function works on the `pd.Series x`; else,
the function casts the index of `x` to int and returns x with a new index. | [
"Formatting",
"series",
"or",
"timeseries",
"columns",
"to",
"int",
"and",
"checking",
"validity",
".",
"If",
"index",
"=",
"False",
"the",
"function",
"works",
"on",
"the",
"pd",
".",
"Series",
"x",
";",
"else",
"the",
"function",
"casts",
"the",
"index",... | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L435-L449 | train |
IAMconsortium/pyam | pyam/utils.py | concat_with_pipe | def concat_with_pipe(x, cols=None):
"""Concatenate a `pd.Series` separated by `|`, drop `None` or `np.nan`"""
cols = cols or x.index
return '|'.join([x[i] for i in cols if x[i] not in [None, np.nan]]) | python | def concat_with_pipe(x, cols=None):
"""Concatenate a `pd.Series` separated by `|`, drop `None` or `np.nan`"""
cols = cols or x.index
return '|'.join([x[i] for i in cols if x[i] not in [None, np.nan]]) | [
"def",
"concat_with_pipe",
"(",
"x",
",",
"cols",
"=",
"None",
")",
":",
"cols",
"=",
"cols",
"or",
"x",
".",
"index",
"return",
"'|'",
".",
"join",
"(",
"[",
"x",
"[",
"i",
"]",
"for",
"i",
"in",
"cols",
"if",
"x",
"[",
"i",
"]",
"not",
"in"... | Concatenate a `pd.Series` separated by `|`, drop `None` or `np.nan` | [
"Concatenate",
"a",
"pd",
".",
"Series",
"separated",
"by",
"|",
"drop",
"None",
"or",
"np",
".",
"nan"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L452-L455 | train |
IAMconsortium/pyam | pyam/core.py | _make_index | def _make_index(df, cols=META_IDX):
"""Create an index from the columns of a dataframe"""
return pd.MultiIndex.from_tuples(
pd.unique(list(zip(*[df[col] for col in cols]))), names=tuple(cols)) | python | def _make_index(df, cols=META_IDX):
"""Create an index from the columns of a dataframe"""
return pd.MultiIndex.from_tuples(
pd.unique(list(zip(*[df[col] for col in cols]))), names=tuple(cols)) | [
"def",
"_make_index",
"(",
"df",
",",
"cols",
"=",
"META_IDX",
")",
":",
"return",
"pd",
".",
"MultiIndex",
".",
"from_tuples",
"(",
"pd",
".",
"unique",
"(",
"list",
"(",
"zip",
"(",
"*",
"[",
"df",
"[",
"col",
"]",
"for",
"col",
"in",
"cols",
"... | Create an index from the columns of a dataframe | [
"Create",
"an",
"index",
"from",
"the",
"columns",
"of",
"a",
"dataframe"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1400-L1403 | train |
IAMconsortium/pyam | pyam/core.py | check_aggregate | def check_aggregate(df, variable, components=None, exclude_on_fail=False,
multiplier=1, **kwargs):
"""Check whether the timeseries values match the aggregation
of sub-categories
Parameters
----------
df: IamDataFrame instance
args: see IamDataFrame.check_aggregate() for deta... | python | def check_aggregate(df, variable, components=None, exclude_on_fail=False,
multiplier=1, **kwargs):
"""Check whether the timeseries values match the aggregation
of sub-categories
Parameters
----------
df: IamDataFrame instance
args: see IamDataFrame.check_aggregate() for deta... | [
"def",
"check_aggregate",
"(",
"df",
",",
"variable",
",",
"components",
"=",
"None",
",",
"exclude_on_fail",
"=",
"False",
",",
"multiplier",
"=",
"1",
",",
"**",
"kwargs",
")",
":",
"fdf",
"=",
"df",
".",
"filter",
"(",
"**",
"kwargs",
")",
"if",
"... | Check whether the timeseries values match the aggregation
of sub-categories
Parameters
----------
df: IamDataFrame instance
args: see IamDataFrame.check_aggregate() for details
kwargs: passed to `df.filter()` | [
"Check",
"whether",
"the",
"timeseries",
"values",
"match",
"the",
"aggregation",
"of",
"sub",
"-",
"categories"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1462-L1479 | train |
IAMconsortium/pyam | pyam/core.py | filter_by_meta | def filter_by_meta(data, df, join_meta=False, **kwargs):
"""Filter by and join meta columns from an IamDataFrame to a pd.DataFrame
Parameters
----------
data: pd.DataFrame instance
DataFrame to which meta columns are to be joined,
index or columns must include `['model', 'scenario']`
... | python | def filter_by_meta(data, df, join_meta=False, **kwargs):
"""Filter by and join meta columns from an IamDataFrame to a pd.DataFrame
Parameters
----------
data: pd.DataFrame instance
DataFrame to which meta columns are to be joined,
index or columns must include `['model', 'scenario']`
... | [
"def",
"filter_by_meta",
"(",
"data",
",",
"df",
",",
"join_meta",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"set",
"(",
"META_IDX",
")",
".",
"issubset",
"(",
"data",
".",
"index",
".",
"names",
"+",
"list",
"(",
"data",
".",
"colu... | Filter by and join meta columns from an IamDataFrame to a pd.DataFrame
Parameters
----------
data: pd.DataFrame instance
DataFrame to which meta columns are to be joined,
index or columns must include `['model', 'scenario']`
df: IamDataFrame instance
IamDataFrame from which meta... | [
"Filter",
"by",
"and",
"join",
"meta",
"columns",
"from",
"an",
"IamDataFrame",
"to",
"a",
"pd",
".",
"DataFrame"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1482-L1534 | train |
IAMconsortium/pyam | pyam/core.py | compare | def compare(left, right, left_label='left', right_label='right',
drop_close=True, **kwargs):
"""Compare the data in two IamDataFrames and return a pd.DataFrame
Parameters
----------
left, right: IamDataFrames
the IamDataFrames to be compared
left_label, right_label: str, default... | python | def compare(left, right, left_label='left', right_label='right',
drop_close=True, **kwargs):
"""Compare the data in two IamDataFrames and return a pd.DataFrame
Parameters
----------
left, right: IamDataFrames
the IamDataFrames to be compared
left_label, right_label: str, default... | [
"def",
"compare",
"(",
"left",
",",
"right",
",",
"left_label",
"=",
"'left'",
",",
"right_label",
"=",
"'right'",
",",
"drop_close",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"ret",
"=",
"pd",
".",
"concat",
"(",
"{",
"right_label",
":",
"right",
... | Compare the data in two IamDataFrames and return a pd.DataFrame
Parameters
----------
left, right: IamDataFrames
the IamDataFrames to be compared
left_label, right_label: str, default `left`, `right`
column names of the returned dataframe
drop_close: bool, default True
remov... | [
"Compare",
"the",
"data",
"in",
"two",
"IamDataFrames",
"and",
"return",
"a",
"pd",
".",
"DataFrame"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1537-L1556 | train |
IAMconsortium/pyam | pyam/core.py | concat | def concat(dfs):
"""Concatenate a series of `pyam.IamDataFrame`-like objects together"""
if isstr(dfs) or not hasattr(dfs, '__iter__'):
msg = 'Argument must be a non-string iterable (e.g., list or tuple)'
raise TypeError(msg)
_df = None
for df in dfs:
df = df if isinstance(df, I... | python | def concat(dfs):
"""Concatenate a series of `pyam.IamDataFrame`-like objects together"""
if isstr(dfs) or not hasattr(dfs, '__iter__'):
msg = 'Argument must be a non-string iterable (e.g., list or tuple)'
raise TypeError(msg)
_df = None
for df in dfs:
df = df if isinstance(df, I... | [
"def",
"concat",
"(",
"dfs",
")",
":",
"if",
"isstr",
"(",
"dfs",
")",
"or",
"not",
"hasattr",
"(",
"dfs",
",",
"'__iter__'",
")",
":",
"msg",
"=",
"'Argument must be a non-string iterable (e.g., list or tuple)'",
"raise",
"TypeError",
"(",
"msg",
")",
"_df",
... | Concatenate a series of `pyam.IamDataFrame`-like objects together | [
"Concatenate",
"a",
"series",
"of",
"pyam",
".",
"IamDataFrame",
"-",
"like",
"objects",
"together"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1559-L1572 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.variables | def variables(self, include_units=False):
"""Get a list of variables
Parameters
----------
include_units: boolean, default False
include the units
"""
if include_units:
return self.data[['variable', 'unit']].drop_duplicates()\
.res... | python | def variables(self, include_units=False):
"""Get a list of variables
Parameters
----------
include_units: boolean, default False
include the units
"""
if include_units:
return self.data[['variable', 'unit']].drop_duplicates()\
.res... | [
"def",
"variables",
"(",
"self",
",",
"include_units",
"=",
"False",
")",
":",
"if",
"include_units",
":",
"return",
"self",
".",
"data",
"[",
"[",
"'variable'",
",",
"'unit'",
"]",
"]",
".",
"drop_duplicates",
"(",
")",
".",
"reset_index",
"(",
"drop",
... | Get a list of variables
Parameters
----------
include_units: boolean, default False
include the units | [
"Get",
"a",
"list",
"of",
"variables"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L161-L173 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.append | def append(self, other, ignore_meta_conflict=False, inplace=False,
**kwargs):
"""Append any castable object to this IamDataFrame.
Columns in `other.meta` that are not in `self.meta` are always merged,
duplicate region-variable-unit-year rows raise a ValueError.
Parameters... | python | def append(self, other, ignore_meta_conflict=False, inplace=False,
**kwargs):
"""Append any castable object to this IamDataFrame.
Columns in `other.meta` that are not in `self.meta` are always merged,
duplicate region-variable-unit-year rows raise a ValueError.
Parameters... | [
"def",
"append",
"(",
"self",
",",
"other",
",",
"ignore_meta_conflict",
"=",
"False",
",",
"inplace",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"IamDataFrame",
")",
":",
"other",
"=",
"IamDataFrame",
"(",... | Append any castable object to this IamDataFrame.
Columns in `other.meta` that are not in `self.meta` are always merged,
duplicate region-variable-unit-year rows raise a ValueError.
Parameters
----------
other: pyam.IamDataFrame, ixmp.TimeSeries, ixmp.Scenario,
pd.DataFra... | [
"Append",
"any",
"castable",
"object",
"to",
"this",
"IamDataFrame",
".",
"Columns",
"in",
"other",
".",
"meta",
"that",
"are",
"not",
"in",
"self",
".",
"meta",
"are",
"always",
"merged",
"duplicate",
"region",
"-",
"variable",
"-",
"unit",
"-",
"year",
... | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L175-L246 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.pivot_table | def pivot_table(self, index, columns, values='value',
aggfunc='count', fill_value=None, style=None):
"""Returns a pivot table
Parameters
----------
index: str or list of strings
rows for Pivot table
columns: str or list of strings
colu... | python | def pivot_table(self, index, columns, values='value',
aggfunc='count', fill_value=None, style=None):
"""Returns a pivot table
Parameters
----------
index: str or list of strings
rows for Pivot table
columns: str or list of strings
colu... | [
"def",
"pivot_table",
"(",
"self",
",",
"index",
",",
"columns",
",",
"values",
"=",
"'value'",
",",
"aggfunc",
"=",
"'count'",
",",
"fill_value",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"index",
"=",
"[",
"index",
"]",
"if",
"isstr",
"(",
... | Returns a pivot table
Parameters
----------
index: str or list of strings
rows for Pivot table
columns: str or list of strings
columns for Pivot table
values: str, default 'value'
dataframe column to aggregate or count
aggfunc: str or ... | [
"Returns",
"a",
"pivot",
"table"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L248-L290 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.as_pandas | def as_pandas(self, with_metadata=False):
"""Return this as a pd.DataFrame
Parameters
----------
with_metadata : bool, default False or dict
if True, join data with all meta columns; if a dict, discover
meaningful meta columns from values (in key-value)
"""... | python | def as_pandas(self, with_metadata=False):
"""Return this as a pd.DataFrame
Parameters
----------
with_metadata : bool, default False or dict
if True, join data with all meta columns; if a dict, discover
meaningful meta columns from values (in key-value)
"""... | [
"def",
"as_pandas",
"(",
"self",
",",
"with_metadata",
"=",
"False",
")",
":",
"if",
"with_metadata",
":",
"cols",
"=",
"self",
".",
"_discover_meta_cols",
"(",
"**",
"with_metadata",
")",
"if",
"isinstance",
"(",
"with_metadata",
",",
"dict",
")",
"else",
... | Return this as a pd.DataFrame
Parameters
----------
with_metadata : bool, default False or dict
if True, join data with all meta columns; if a dict, discover
meaningful meta columns from values (in key-value) | [
"Return",
"this",
"as",
"a",
"pd",
".",
"DataFrame"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L312-L331 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame._new_meta_column | def _new_meta_column(self, name):
"""Add a column to meta if it doesn't exist, set to value `np.nan`"""
if name is None:
raise ValueError('cannot add a meta column `{}`'.format(name))
if name not in self.meta:
self.meta[name] = np.nan | python | def _new_meta_column(self, name):
"""Add a column to meta if it doesn't exist, set to value `np.nan`"""
if name is None:
raise ValueError('cannot add a meta column `{}`'.format(name))
if name not in self.meta:
self.meta[name] = np.nan | [
"def",
"_new_meta_column",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'cannot add a meta column `{}`'",
".",
"format",
"(",
"name",
")",
")",
"if",
"name",
"not",
"in",
"self",
".",
"meta",
":",
"sel... | Add a column to meta if it doesn't exist, set to value `np.nan` | [
"Add",
"a",
"column",
"to",
"meta",
"if",
"it",
"doesn",
"t",
"exist",
"set",
"to",
"value",
"np",
".",
"nan"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L474-L479 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.convert_unit | def convert_unit(self, conversion_mapping, inplace=False):
"""Converts units based on provided unit conversion factors
Parameters
----------
conversion_mapping: dict
for each unit for which a conversion should be carried out,
provide current unit and target unit ... | python | def convert_unit(self, conversion_mapping, inplace=False):
"""Converts units based on provided unit conversion factors
Parameters
----------
conversion_mapping: dict
for each unit for which a conversion should be carried out,
provide current unit and target unit ... | [
"def",
"convert_unit",
"(",
"self",
",",
"conversion_mapping",
",",
"inplace",
"=",
"False",
")",
":",
"ret",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"if",
"not",
"inplace",
"else",
"self",
"for",
"current_unit",
",",
"(",
"new_unit",
",",
"facto... | Converts units based on provided unit conversion factors
Parameters
----------
conversion_mapping: dict
for each unit for which a conversion should be carried out,
provide current unit and target unit and conversion factor
{<current unit>: [<target unit>, <co... | [
"Converts",
"units",
"based",
"on",
"provided",
"unit",
"conversion",
"factors"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L635-L654 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.normalize | def normalize(self, inplace=False, **kwargs):
"""Normalize data to a given value. Currently only supports normalizing
to a specific time.
Parameters
----------
inplace: bool, default False
if True, do operation inplace and return None
kwargs: the values on wh... | python | def normalize(self, inplace=False, **kwargs):
"""Normalize data to a given value. Currently only supports normalizing
to a specific time.
Parameters
----------
inplace: bool, default False
if True, do operation inplace and return None
kwargs: the values on wh... | [
"def",
"normalize",
"(",
"self",
",",
"inplace",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"if",
"len",
"(",
"kwargs",
")",
">",
"1",
"or",
"self",
".",
"time_col",
"not",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"'Only time(year)-based normal... | Normalize data to a given value. Currently only supports normalizing
to a specific time.
Parameters
----------
inplace: bool, default False
if True, do operation inplace and return None
kwargs: the values on which to normalize (e.g., `year=2005`) | [
"Normalize",
"data",
"to",
"a",
"given",
"value",
".",
"Currently",
"only",
"supports",
"normalizing",
"to",
"a",
"specific",
"time",
"."
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L656-L677 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.aggregate | def aggregate(self, variable, components=None, append=False):
"""Compute the aggregate of timeseries components or sub-categories
Parameters
----------
variable: str
variable for which the aggregate should be computed
components: list of str, default None
... | python | def aggregate(self, variable, components=None, append=False):
"""Compute the aggregate of timeseries components or sub-categories
Parameters
----------
variable: str
variable for which the aggregate should be computed
components: list of str, default None
... | [
"def",
"aggregate",
"(",
"self",
",",
"variable",
",",
"components",
"=",
"None",
",",
"append",
"=",
"False",
")",
":",
"components",
"=",
"components",
"or",
"self",
".",
"_variable_components",
"(",
"variable",
")",
"if",
"not",
"len",
"(",
"components"... | Compute the aggregate of timeseries components or sub-categories
Parameters
----------
variable: str
variable for which the aggregate should be computed
components: list of str, default None
list of variables, defaults to all sub-categories of `variable`
... | [
"Compute",
"the",
"aggregate",
"of",
"timeseries",
"components",
"or",
"sub",
"-",
"categories"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L679-L707 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.check_aggregate | def check_aggregate(self, variable, components=None, exclude_on_fail=False,
multiplier=1, **kwargs):
"""Check whether a timeseries matches the aggregation of its components
Parameters
----------
variable: str
variable to be checked for matching aggreg... | python | def check_aggregate(self, variable, components=None, exclude_on_fail=False,
multiplier=1, **kwargs):
"""Check whether a timeseries matches the aggregation of its components
Parameters
----------
variable: str
variable to be checked for matching aggreg... | [
"def",
"check_aggregate",
"(",
"self",
",",
"variable",
",",
"components",
"=",
"None",
",",
"exclude_on_fail",
"=",
"False",
",",
"multiplier",
"=",
"1",
",",
"**",
"kwargs",
")",
":",
"df_components",
"=",
"self",
".",
"aggregate",
"(",
"variable",
",",
... | Check whether a timeseries matches the aggregation of its components
Parameters
----------
variable: str
variable to be checked for matching aggregation of sub-categories
components: list of str, default None
list of variables, defaults to all sub-categories of `... | [
"Check",
"whether",
"a",
"timeseries",
"matches",
"the",
"aggregation",
"of",
"its",
"components"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L709-L747 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.aggregate_region | def aggregate_region(self, variable, region='World', subregions=None,
components=None, append=False):
"""Compute the aggregate of timeseries over a number of regions
including variable components only defined at the `region` level
Parameters
----------
v... | python | def aggregate_region(self, variable, region='World', subregions=None,
components=None, append=False):
"""Compute the aggregate of timeseries over a number of regions
including variable components only defined at the `region` level
Parameters
----------
v... | [
"def",
"aggregate_region",
"(",
"self",
",",
"variable",
",",
"region",
"=",
"'World'",
",",
"subregions",
"=",
"None",
",",
"components",
"=",
"None",
",",
"append",
"=",
"False",
")",
":",
"if",
"subregions",
"is",
"None",
":",
"rows",
"=",
"self",
"... | Compute the aggregate of timeseries over a number of regions
including variable components only defined at the `region` level
Parameters
----------
variable: str
variable for which the aggregate should be computed
region: str, default 'World'
dimension
... | [
"Compute",
"the",
"aggregate",
"of",
"timeseries",
"over",
"a",
"number",
"of",
"regions",
"including",
"variable",
"components",
"only",
"defined",
"at",
"the",
"region",
"level"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L749-L801 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.check_aggregate_region | def check_aggregate_region(self, variable, region='World', subregions=None,
components=None, exclude_on_fail=False,
**kwargs):
"""Check whether the region timeseries data match the aggregation
of components
Parameters
-------... | python | def check_aggregate_region(self, variable, region='World', subregions=None,
components=None, exclude_on_fail=False,
**kwargs):
"""Check whether the region timeseries data match the aggregation
of components
Parameters
-------... | [
"def",
"check_aggregate_region",
"(",
"self",
",",
"variable",
",",
"region",
"=",
"'World'",
",",
"subregions",
"=",
"None",
",",
"components",
"=",
"None",
",",
"exclude_on_fail",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"df_subregions",
"=",
"self",
... | Check whether the region timeseries data match the aggregation
of components
Parameters
----------
variable: str
variable to be checked for matching aggregation of subregions
region: str, default 'World'
region to be checked for matching aggregation of su... | [
"Check",
"whether",
"the",
"region",
"timeseries",
"data",
"match",
"the",
"aggregation",
"of",
"components"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L803-L850 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.check_internal_consistency | def check_internal_consistency(self, **kwargs):
"""Check whether the database is internally consistent
We check that all variables are equal to the sum of their sectoral
components and that all the regions add up to the World total. If
the check is passed, None is returned, otherwise a ... | python | def check_internal_consistency(self, **kwargs):
"""Check whether the database is internally consistent
We check that all variables are equal to the sum of their sectoral
components and that all the regions add up to the World total. If
the check is passed, None is returned, otherwise a ... | [
"def",
"check_internal_consistency",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"inconsistent_vars",
"=",
"{",
"}",
"for",
"variable",
"in",
"self",
".",
"variables",
"(",
")",
":",
"diff_agg",
"=",
"self",
".",
"check_aggregate",
"(",
"variable",
",",
"*... | Check whether the database is internally consistent
We check that all variables are equal to the sum of their sectoral
components and that all the regions add up to the World total. If
the check is passed, None is returned, otherwise a dictionary of
inconsistent variables is returned.
... | [
"Check",
"whether",
"the",
"database",
"is",
"internally",
"consistent"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L860-L888 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame._apply_filters | def _apply_filters(self, **filters):
"""Determine rows to keep in data for given set of filters
Parameters
----------
filters: dict
dictionary of filters ({col: values}}); uses a pseudo-regexp syntax
by default, but accepts `regexp: True` to use regexp directly
... | python | def _apply_filters(self, **filters):
"""Determine rows to keep in data for given set of filters
Parameters
----------
filters: dict
dictionary of filters ({col: values}}); uses a pseudo-regexp syntax
by default, but accepts `regexp: True` to use regexp directly
... | [
"def",
"_apply_filters",
"(",
"self",
",",
"**",
"filters",
")",
":",
"regexp",
"=",
"filters",
".",
"pop",
"(",
"'regexp'",
",",
"False",
")",
"keep",
"=",
"np",
".",
"array",
"(",
"[",
"True",
"]",
"*",
"len",
"(",
"self",
".",
"data",
")",
")"... | Determine rows to keep in data for given set of filters
Parameters
----------
filters: dict
dictionary of filters ({col: values}}); uses a pseudo-regexp syntax
by default, but accepts `regexp: True` to use regexp directly | [
"Determine",
"rows",
"to",
"keep",
"in",
"data",
"for",
"given",
"set",
"of",
"filters"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L938-L1013 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.col_apply | def col_apply(self, col, func, *args, **kwargs):
"""Apply a function to a column
Parameters
----------
col: string
column in either data or metadata
func: functional
function to apply
"""
if col in self.data:
self.data[col] = s... | python | def col_apply(self, col, func, *args, **kwargs):
"""Apply a function to a column
Parameters
----------
col: string
column in either data or metadata
func: functional
function to apply
"""
if col in self.data:
self.data[col] = s... | [
"def",
"col_apply",
"(",
"self",
",",
"col",
",",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"col",
"in",
"self",
".",
"data",
":",
"self",
".",
"data",
"[",
"col",
"]",
"=",
"self",
".",
"data",
"[",
"col",
"]",
".",
"app... | Apply a function to a column
Parameters
----------
col: string
column in either data or metadata
func: functional
function to apply | [
"Apply",
"a",
"function",
"to",
"a",
"column"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1015-L1028 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame._to_file_format | def _to_file_format(self, iamc_index):
"""Return a dataframe suitable for writing to a file"""
df = self.timeseries(iamc_index=iamc_index).reset_index()
df = df.rename(columns={c: str(c).title() for c in df.columns})
return df | python | def _to_file_format(self, iamc_index):
"""Return a dataframe suitable for writing to a file"""
df = self.timeseries(iamc_index=iamc_index).reset_index()
df = df.rename(columns={c: str(c).title() for c in df.columns})
return df | [
"def",
"_to_file_format",
"(",
"self",
",",
"iamc_index",
")",
":",
"df",
"=",
"self",
".",
"timeseries",
"(",
"iamc_index",
"=",
"iamc_index",
")",
".",
"reset_index",
"(",
")",
"df",
"=",
"df",
".",
"rename",
"(",
"columns",
"=",
"{",
"c",
":",
"st... | Return a dataframe suitable for writing to a file | [
"Return",
"a",
"dataframe",
"suitable",
"for",
"writing",
"to",
"a",
"file"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1030-L1034 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.to_csv | def to_csv(self, path, iamc_index=False, **kwargs):
"""Write timeseries data to a csv file
Parameters
----------
path: string
file path
iamc_index: bool, default False
if True, use `['model', 'scenario', 'region', 'variable', 'unit']`;
else, u... | python | def to_csv(self, path, iamc_index=False, **kwargs):
"""Write timeseries data to a csv file
Parameters
----------
path: string
file path
iamc_index: bool, default False
if True, use `['model', 'scenario', 'region', 'variable', 'unit']`;
else, u... | [
"def",
"to_csv",
"(",
"self",
",",
"path",
",",
"iamc_index",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_to_file_format",
"(",
"iamc_index",
")",
".",
"to_csv",
"(",
"path",
",",
"index",
"=",
"False",
",",
"**",
"kwargs",
")"
] | Write timeseries data to a csv file
Parameters
----------
path: string
file path
iamc_index: bool, default False
if True, use `['model', 'scenario', 'region', 'variable', 'unit']`;
else, use all `data` columns | [
"Write",
"timeseries",
"data",
"to",
"a",
"csv",
"file"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1036-L1047 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.to_excel | def to_excel(self, excel_writer, sheet_name='data',
iamc_index=False, **kwargs):
"""Write timeseries data to Excel format
Parameters
----------
excel_writer: string or ExcelWriter object
file path or existing ExcelWriter
sheet_name: string, default '... | python | def to_excel(self, excel_writer, sheet_name='data',
iamc_index=False, **kwargs):
"""Write timeseries data to Excel format
Parameters
----------
excel_writer: string or ExcelWriter object
file path or existing ExcelWriter
sheet_name: string, default '... | [
"def",
"to_excel",
"(",
"self",
",",
"excel_writer",
",",
"sheet_name",
"=",
"'data'",
",",
"iamc_index",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"excel_writer",
",",
"pd",
".",
"ExcelWriter",
")",
":",
"close",
"=",
... | Write timeseries data to Excel format
Parameters
----------
excel_writer: string or ExcelWriter object
file path or existing ExcelWriter
sheet_name: string, default 'data'
name of sheet which will contain `IamDataFrame.timeseries()` data
iamc_index: bool,... | [
"Write",
"timeseries",
"data",
"to",
"Excel",
"format"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1049-L1070 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.export_metadata | def export_metadata(self, path):
"""Export metadata to Excel
Parameters
----------
path: string
path/filename for xlsx file of metadata export
"""
writer = pd.ExcelWriter(path)
write_sheet(writer, 'meta', self.meta, index=True)
writer.save() | python | def export_metadata(self, path):
"""Export metadata to Excel
Parameters
----------
path: string
path/filename for xlsx file of metadata export
"""
writer = pd.ExcelWriter(path)
write_sheet(writer, 'meta', self.meta, index=True)
writer.save() | [
"def",
"export_metadata",
"(",
"self",
",",
"path",
")",
":",
"writer",
"=",
"pd",
".",
"ExcelWriter",
"(",
"path",
")",
"write_sheet",
"(",
"writer",
",",
"'meta'",
",",
"self",
".",
"meta",
",",
"index",
"=",
"True",
")",
"writer",
".",
"save",
"("... | Export metadata to Excel
Parameters
----------
path: string
path/filename for xlsx file of metadata export | [
"Export",
"metadata",
"to",
"Excel"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1072-L1082 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.load_metadata | def load_metadata(self, path, *args, **kwargs):
"""Load metadata exported from `pyam.IamDataFrame` instance
Parameters
----------
path: string
xlsx file with metadata exported from `pyam.IamDataFrame` instance
"""
if not os.path.exists(path):
rais... | python | def load_metadata(self, path, *args, **kwargs):
"""Load metadata exported from `pyam.IamDataFrame` instance
Parameters
----------
path: string
xlsx file with metadata exported from `pyam.IamDataFrame` instance
"""
if not os.path.exists(path):
rais... | [
"def",
"load_metadata",
"(",
"self",
",",
"path",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"raise",
"ValueError",
"(",
"\"no metadata file '\"",
"+",
"path",
"+",
"\"' found!... | Load metadata exported from `pyam.IamDataFrame` instance
Parameters
----------
path: string
xlsx file with metadata exported from `pyam.IamDataFrame` instance | [
"Load",
"metadata",
"exported",
"from",
"pyam",
".",
"IamDataFrame",
"instance"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1084-L1131 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.line_plot | def line_plot(self, x='year', y='value', **kwargs):
"""Plot timeseries lines of existing data
see pyam.plotting.line_plot() for all available options
"""
df = self.as_pandas(with_metadata=kwargs)
# pivot data if asked for explicit variable name
variables = df['variable'... | python | def line_plot(self, x='year', y='value', **kwargs):
"""Plot timeseries lines of existing data
see pyam.plotting.line_plot() for all available options
"""
df = self.as_pandas(with_metadata=kwargs)
# pivot data if asked for explicit variable name
variables = df['variable'... | [
"def",
"line_plot",
"(",
"self",
",",
"x",
"=",
"'year'",
",",
"y",
"=",
"'value'",
",",
"**",
"kwargs",
")",
":",
"df",
"=",
"self",
".",
"as_pandas",
"(",
"with_metadata",
"=",
"kwargs",
")",
"variables",
"=",
"df",
"[",
"'variable'",
"]",
".",
"... | Plot timeseries lines of existing data
see pyam.plotting.line_plot() for all available options | [
"Plot",
"timeseries",
"lines",
"of",
"existing",
"data"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1133-L1160 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.stack_plot | def stack_plot(self, *args, **kwargs):
"""Plot timeseries stacks of existing data
see pyam.plotting.stack_plot() for all available options
"""
df = self.as_pandas(with_metadata=True)
ax = plotting.stack_plot(df, *args, **kwargs)
return ax | python | def stack_plot(self, *args, **kwargs):
"""Plot timeseries stacks of existing data
see pyam.plotting.stack_plot() for all available options
"""
df = self.as_pandas(with_metadata=True)
ax = plotting.stack_plot(df, *args, **kwargs)
return ax | [
"def",
"stack_plot",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"df",
"=",
"self",
".",
"as_pandas",
"(",
"with_metadata",
"=",
"True",
")",
"ax",
"=",
"plotting",
".",
"stack_plot",
"(",
"df",
",",
"*",
"args",
",",
"**",
"kwarg... | Plot timeseries stacks of existing data
see pyam.plotting.stack_plot() for all available options | [
"Plot",
"timeseries",
"stacks",
"of",
"existing",
"data"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1162-L1169 | train |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.scatter | def scatter(self, x, y, **kwargs):
"""Plot a scatter chart using metadata columns
see pyam.plotting.scatter() for all available options
"""
variables = self.data['variable'].unique()
xisvar = x in variables
yisvar = y in variables
if not xisvar and not yisvar:
... | python | def scatter(self, x, y, **kwargs):
"""Plot a scatter chart using metadata columns
see pyam.plotting.scatter() for all available options
"""
variables = self.data['variable'].unique()
xisvar = x in variables
yisvar = y in variables
if not xisvar and not yisvar:
... | [
"def",
"scatter",
"(",
"self",
",",
"x",
",",
"y",
",",
"**",
"kwargs",
")",
":",
"variables",
"=",
"self",
".",
"data",
"[",
"'variable'",
"]",
".",
"unique",
"(",
")",
"xisvar",
"=",
"x",
"in",
"variables",
"yisvar",
"=",
"y",
"in",
"variables",
... | Plot a scatter chart using metadata columns
see pyam.plotting.scatter() for all available options | [
"Plot",
"a",
"scatter",
"chart",
"using",
"metadata",
"columns"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1189-L1229 | train |
IAMconsortium/pyam | pyam/run_control.py | RunControl.update | def update(self, rc):
"""Add additional run control parameters
Parameters
----------
rc : string, file, dictionary, optional
a path to a YAML file, a file handle for a YAML file, or a
dictionary describing run control configuration
"""
rc = self._... | python | def update(self, rc):
"""Add additional run control parameters
Parameters
----------
rc : string, file, dictionary, optional
a path to a YAML file, a file handle for a YAML file, or a
dictionary describing run control configuration
"""
rc = self._... | [
"def",
"update",
"(",
"self",
",",
"rc",
")",
":",
"rc",
"=",
"self",
".",
"_load_yaml",
"(",
"rc",
")",
"self",
".",
"store",
"=",
"_recursive_update",
"(",
"self",
".",
"store",
",",
"rc",
")"
] | Add additional run control parameters
Parameters
----------
rc : string, file, dictionary, optional
a path to a YAML file, a file handle for a YAML file, or a
dictionary describing run control configuration | [
"Add",
"additional",
"run",
"control",
"parameters"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/run_control.py#L75-L85 | train |
IAMconsortium/pyam | pyam/run_control.py | RunControl.recursive_update | def recursive_update(self, k, d):
"""Recursively update a top-level option in the run control
Parameters
----------
k : string
the top-level key
d : dictionary or similar
the dictionary to use for updating
"""
u = self.__getitem__(k)
... | python | def recursive_update(self, k, d):
"""Recursively update a top-level option in the run control
Parameters
----------
k : string
the top-level key
d : dictionary or similar
the dictionary to use for updating
"""
u = self.__getitem__(k)
... | [
"def",
"recursive_update",
"(",
"self",
",",
"k",
",",
"d",
")",
":",
"u",
"=",
"self",
".",
"__getitem__",
"(",
"k",
")",
"self",
".",
"store",
"[",
"k",
"]",
"=",
"_recursive_update",
"(",
"u",
",",
"d",
")"
] | Recursively update a top-level option in the run control
Parameters
----------
k : string
the top-level key
d : dictionary or similar
the dictionary to use for updating | [
"Recursively",
"update",
"a",
"top",
"-",
"level",
"option",
"in",
"the",
"run",
"control"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/run_control.py#L125-L136 | train |
IAMconsortium/pyam | pyam/iiasa.py | Connection.available_metadata | def available_metadata(self):
"""
List all scenario metadata indicators available in the connected
data source
"""
url = self.base_url + 'metadata/types'
headers = {'Authorization': 'Bearer {}'.format(self.auth())}
r = requests.get(url, headers=headers)
re... | python | def available_metadata(self):
"""
List all scenario metadata indicators available in the connected
data source
"""
url = self.base_url + 'metadata/types'
headers = {'Authorization': 'Bearer {}'.format(self.auth())}
r = requests.get(url, headers=headers)
re... | [
"def",
"available_metadata",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"'metadata/types'",
"headers",
"=",
"{",
"'Authorization'",
":",
"'Bearer {}'",
".",
"format",
"(",
"self",
".",
"auth",
"(",
")",
")",
"}",
"r",
"=",
"requests... | List all scenario metadata indicators available in the connected
data source | [
"List",
"all",
"scenario",
"metadata",
"indicators",
"available",
"in",
"the",
"connected",
"data",
"source"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L87-L95 | train |
IAMconsortium/pyam | pyam/iiasa.py | Connection.metadata | def metadata(self, default=True):
"""
Metadata of scenarios in the connected data source
Parameter
---------
default : bool, optional, default True
Return *only* the default version of each Scenario.
Any (`model`, `scenario`) without a default version is ... | python | def metadata(self, default=True):
"""
Metadata of scenarios in the connected data source
Parameter
---------
default : bool, optional, default True
Return *only* the default version of each Scenario.
Any (`model`, `scenario`) without a default version is ... | [
"def",
"metadata",
"(",
"self",
",",
"default",
"=",
"True",
")",
":",
"default",
"=",
"'true'",
"if",
"default",
"else",
"'false'",
"add_url",
"=",
"'runs?getOnlyDefaultRuns={}&includeMetadata=true'",
"url",
"=",
"self",
".",
"base_url",
"+",
"add_url",
".",
... | Metadata of scenarios in the connected data source
Parameter
---------
default : bool, optional, default True
Return *only* the default version of each Scenario.
Any (`model`, `scenario`) without a default version is omitted.
If :obj:`False`, return all versi... | [
"Metadata",
"of",
"scenarios",
"in",
"the",
"connected",
"data",
"source"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L98-L128 | train |
IAMconsortium/pyam | pyam/iiasa.py | Connection.variables | def variables(self):
"""All variables in the connected data source"""
url = self.base_url + 'ts'
headers = {'Authorization': 'Bearer {}'.format(self.auth())}
r = requests.get(url, headers=headers)
df = pd.read_json(r.content, orient='records')
return pd.Series(df['variabl... | python | def variables(self):
"""All variables in the connected data source"""
url = self.base_url + 'ts'
headers = {'Authorization': 'Bearer {}'.format(self.auth())}
r = requests.get(url, headers=headers)
df = pd.read_json(r.content, orient='records')
return pd.Series(df['variabl... | [
"def",
"variables",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"'ts'",
"headers",
"=",
"{",
"'Authorization'",
":",
"'Bearer {}'",
".",
"format",
"(",
"self",
".",
"auth",
"(",
")",
")",
"}",
"r",
"=",
"requests",
".",
"get",
... | All variables in the connected data source | [
"All",
"variables",
"in",
"the",
"connected",
"data",
"source"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L141-L147 | train |
IAMconsortium/pyam | pyam/iiasa.py | Connection.query | def query(self, **kwargs):
"""
Query the data source, subselecting data. Available keyword arguments
include
- model
- scenario
- region
- variable
Example
-------
```
Connection.query(model='MESSAGE', scenario='SSP2*',
... | python | def query(self, **kwargs):
"""
Query the data source, subselecting data. Available keyword arguments
include
- model
- scenario
- region
- variable
Example
-------
```
Connection.query(model='MESSAGE', scenario='SSP2*',
... | [
"def",
"query",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"headers",
"=",
"{",
"'Authorization'",
":",
"'Bearer {}'",
".",
"format",
"(",
"self",
".",
"auth",
"(",
")",
")",
",",
"'Content-Type'",
":",
"'application/json'",
",",
"}",
"data",
"=",
"js... | Query the data source, subselecting data. Available keyword arguments
include
- model
- scenario
- region
- variable
Example
-------
```
Connection.query(model='MESSAGE', scenario='SSP2*',
variable=['Emissions|CO2', 'Pri... | [
"Query",
"the",
"data",
"source",
"subselecting",
"data",
".",
"Available",
"keyword",
"arguments",
"include"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L209-L253 | train |
IAMconsortium/pyam | pyam/statistics.py | Statistics.reindex | def reindex(self, copy=True):
"""Reindex the summary statistics dataframe"""
ret = deepcopy(self) if copy else self
ret.stats = ret.stats.reindex(index=ret._idx, level=0)
if ret.idx_depth == 2:
ret.stats = ret.stats.reindex(index=ret._sub_idx, level=1)
if ret.rows is... | python | def reindex(self, copy=True):
"""Reindex the summary statistics dataframe"""
ret = deepcopy(self) if copy else self
ret.stats = ret.stats.reindex(index=ret._idx, level=0)
if ret.idx_depth == 2:
ret.stats = ret.stats.reindex(index=ret._sub_idx, level=1)
if ret.rows is... | [
"def",
"reindex",
"(",
"self",
",",
"copy",
"=",
"True",
")",
":",
"ret",
"=",
"deepcopy",
"(",
"self",
")",
"if",
"copy",
"else",
"self",
"ret",
".",
"stats",
"=",
"ret",
".",
"stats",
".",
"reindex",
"(",
"index",
"=",
"ret",
".",
"_idx",
",",
... | Reindex the summary statistics dataframe | [
"Reindex",
"the",
"summary",
"statistics",
"dataframe"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/statistics.py#L198-L213 | train |
IAMconsortium/pyam | pyam/statistics.py | Statistics.summarize | def summarize(self, center='mean', fullrange=None, interquartile=None,
custom_format='{:.2f}'):
"""Format the compiled statistics to a concise string output
Parameter
---------
center : str, default `mean`
what to return as 'center' of the summary: `mean`, ... | python | def summarize(self, center='mean', fullrange=None, interquartile=None,
custom_format='{:.2f}'):
"""Format the compiled statistics to a concise string output
Parameter
---------
center : str, default `mean`
what to return as 'center' of the summary: `mean`, ... | [
"def",
"summarize",
"(",
"self",
",",
"center",
"=",
"'mean'",
",",
"fullrange",
"=",
"None",
",",
"interquartile",
"=",
"None",
",",
"custom_format",
"=",
"'{:.2f}'",
")",
":",
"self",
".",
"reindex",
"(",
"copy",
"=",
"False",
")",
"center",
"=",
"'m... | Format the compiled statistics to a concise string output
Parameter
---------
center : str, default `mean`
what to return as 'center' of the summary: `mean`, `50%`, `median`
fullrange : bool, default None
return full range of data if True or `fullrange`, `interqu... | [
"Format",
"the",
"compiled",
"statistics",
"to",
"a",
"concise",
"string",
"output"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/statistics.py#L215-L240 | train |
IAMconsortium/pyam | pyam/plotting.py | reset_default_props | def reset_default_props(**kwargs):
"""Reset properties to initial cycle point"""
global _DEFAULT_PROPS
pcycle = plt.rcParams['axes.prop_cycle']
_DEFAULT_PROPS = {
'color': itertools.cycle(_get_standard_colors(**kwargs))
if len(kwargs) > 0 else itertools.cycle([x['color'] for x in pcycle]... | python | def reset_default_props(**kwargs):
"""Reset properties to initial cycle point"""
global _DEFAULT_PROPS
pcycle = plt.rcParams['axes.prop_cycle']
_DEFAULT_PROPS = {
'color': itertools.cycle(_get_standard_colors(**kwargs))
if len(kwargs) > 0 else itertools.cycle([x['color'] for x in pcycle]... | [
"def",
"reset_default_props",
"(",
"**",
"kwargs",
")",
":",
"global",
"_DEFAULT_PROPS",
"pcycle",
"=",
"plt",
".",
"rcParams",
"[",
"'axes.prop_cycle'",
"]",
"_DEFAULT_PROPS",
"=",
"{",
"'color'",
":",
"itertools",
".",
"cycle",
"(",
"_get_standard_colors",
"("... | Reset properties to initial cycle point | [
"Reset",
"properties",
"to",
"initial",
"cycle",
"point"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L75-L84 | train |
IAMconsortium/pyam | pyam/plotting.py | default_props | def default_props(reset=False, **kwargs):
"""Return current default properties
Parameters
----------
reset : bool
if True, reset properties and return
default: False
"""
global _DEFAULT_PROPS
if _DEFAULT_PROPS is None or reset:
reset_default_props(**kwargs)
... | python | def default_props(reset=False, **kwargs):
"""Return current default properties
Parameters
----------
reset : bool
if True, reset properties and return
default: False
"""
global _DEFAULT_PROPS
if _DEFAULT_PROPS is None or reset:
reset_default_props(**kwargs)
... | [
"def",
"default_props",
"(",
"reset",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"global",
"_DEFAULT_PROPS",
"if",
"_DEFAULT_PROPS",
"is",
"None",
"or",
"reset",
":",
"reset_default_props",
"(",
"**",
"kwargs",
")",
"return",
"_DEFAULT_PROPS"
] | Return current default properties
Parameters
----------
reset : bool
if True, reset properties and return
default: False | [
"Return",
"current",
"default",
"properties"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L87-L99 | train |
IAMconsortium/pyam | pyam/plotting.py | assign_style_props | def assign_style_props(df, color=None, marker=None, linestyle=None,
cmap=None):
"""Assign the style properties for a plot
Parameters
----------
df : pd.DataFrame
data to be used for style properties
"""
if color is None and cmap is not None:
raise ValueErr... | python | def assign_style_props(df, color=None, marker=None, linestyle=None,
cmap=None):
"""Assign the style properties for a plot
Parameters
----------
df : pd.DataFrame
data to be used for style properties
"""
if color is None and cmap is not None:
raise ValueErr... | [
"def",
"assign_style_props",
"(",
"df",
",",
"color",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"linestyle",
"=",
"None",
",",
"cmap",
"=",
"None",
")",
":",
"if",
"color",
"is",
"None",
"and",
"cmap",
"is",
"not",
"None",
":",
"raise",
"ValueErr... | Assign the style properties for a plot
Parameters
----------
df : pd.DataFrame
data to be used for style properties | [
"Assign",
"the",
"style",
"properties",
"for",
"a",
"plot"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L102-L155 | train |
IAMconsortium/pyam | pyam/plotting.py | reshape_line_plot | def reshape_line_plot(df, x, y):
"""Reshape data from long form to "line plot form".
Line plot form has x value as the index with one column for each line.
Each column has data points as values and all metadata as column headers.
"""
idx = list(df.columns.drop(y))
if df.duplicated(idx).any():
... | python | def reshape_line_plot(df, x, y):
"""Reshape data from long form to "line plot form".
Line plot form has x value as the index with one column for each line.
Each column has data points as values and all metadata as column headers.
"""
idx = list(df.columns.drop(y))
if df.duplicated(idx).any():
... | [
"def",
"reshape_line_plot",
"(",
"df",
",",
"x",
",",
"y",
")",
":",
"idx",
"=",
"list",
"(",
"df",
".",
"columns",
".",
"drop",
"(",
"y",
")",
")",
"if",
"df",
".",
"duplicated",
"(",
"idx",
")",
".",
"any",
"(",
")",
":",
"warnings",
".",
"... | Reshape data from long form to "line plot form".
Line plot form has x value as the index with one column for each line.
Each column has data points as values and all metadata as column headers. | [
"Reshape",
"data",
"from",
"long",
"form",
"to",
"line",
"plot",
"form",
"."
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L158-L169 | train |
IAMconsortium/pyam | pyam/plotting.py | reshape_bar_plot | def reshape_bar_plot(df, x, y, bars):
"""Reshape data from long form to "bar plot form".
Bar plot form has x value as the index with one column for bar grouping.
Table values come from y values.
"""
idx = [bars, x]
if df.duplicated(idx).any():
warnings.warn('Duplicated index found.')
... | python | def reshape_bar_plot(df, x, y, bars):
"""Reshape data from long form to "bar plot form".
Bar plot form has x value as the index with one column for bar grouping.
Table values come from y values.
"""
idx = [bars, x]
if df.duplicated(idx).any():
warnings.warn('Duplicated index found.')
... | [
"def",
"reshape_bar_plot",
"(",
"df",
",",
"x",
",",
"y",
",",
"bars",
")",
":",
"idx",
"=",
"[",
"bars",
",",
"x",
"]",
"if",
"df",
".",
"duplicated",
"(",
"idx",
")",
".",
"any",
"(",
")",
":",
"warnings",
".",
"warn",
"(",
"'Duplicated index f... | Reshape data from long form to "bar plot form".
Bar plot form has x value as the index with one column for bar grouping.
Table values come from y values. | [
"Reshape",
"data",
"from",
"long",
"form",
"to",
"bar",
"plot",
"form",
"."
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L172-L183 | train |
IAMconsortium/pyam | pyam/plotting.py | read_shapefile | def read_shapefile(fname, region_col=None, **kwargs):
"""Read a shapefile for use in regional plots. Shapefiles must have a
column denoted as "region".
Parameters
----------
fname : string
path to shapefile to be read by geopandas
region_col : string, default None
if provided, r... | python | def read_shapefile(fname, region_col=None, **kwargs):
"""Read a shapefile for use in regional plots. Shapefiles must have a
column denoted as "region".
Parameters
----------
fname : string
path to shapefile to be read by geopandas
region_col : string, default None
if provided, r... | [
"def",
"read_shapefile",
"(",
"fname",
",",
"region_col",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"gdf",
"=",
"gpd",
".",
"read_file",
"(",
"fname",
",",
"**",
"kwargs",
")",
"if",
"region_col",
"is",
"not",
"None",
":",
"gdf",
"=",
"gdf",
".",
... | Read a shapefile for use in regional plots. Shapefiles must have a
column denoted as "region".
Parameters
----------
fname : string
path to shapefile to be read by geopandas
region_col : string, default None
if provided, rename a column in the shapefile to "region" | [
"Read",
"a",
"shapefile",
"for",
"use",
"in",
"regional",
"plots",
".",
"Shapefiles",
"must",
"have",
"a",
"column",
"denoted",
"as",
"region",
"."
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L188-L205 | train |
IAMconsortium/pyam | pyam/plotting.py | add_net_values_to_bar_plot | def add_net_values_to_bar_plot(axs, color='k'):
"""Add net values next to an existing vertical stacked bar chart
Parameters
----------
axs : matplotlib.Axes or list thereof
color : str, optional, default: black
the color of the bars to add
"""
axs = axs if isinstance(axs, Iterable) ... | python | def add_net_values_to_bar_plot(axs, color='k'):
"""Add net values next to an existing vertical stacked bar chart
Parameters
----------
axs : matplotlib.Axes or list thereof
color : str, optional, default: black
the color of the bars to add
"""
axs = axs if isinstance(axs, Iterable) ... | [
"def",
"add_net_values_to_bar_plot",
"(",
"axs",
",",
"color",
"=",
"'k'",
")",
":",
"axs",
"=",
"axs",
"if",
"isinstance",
"(",
"axs",
",",
"Iterable",
")",
"else",
"[",
"axs",
"]",
"for",
"ax",
"in",
"axs",
":",
"box_args",
"=",
"_get_boxes",
"(",
... | Add net values next to an existing vertical stacked bar chart
Parameters
----------
axs : matplotlib.Axes or list thereof
color : str, optional, default: black
the color of the bars to add | [
"Add",
"net",
"values",
"next",
"to",
"an",
"existing",
"vertical",
"stacked",
"bar",
"chart"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L650-L664 | train |
IAMconsortium/pyam | pyam/plotting.py | scatter | def scatter(df, x, y, ax=None, legend=None, title=None,
color=None, marker='o', linestyle=None, cmap=None,
groupby=['model', 'scenario'], with_lines=False, **kwargs):
"""Plot data as a scatter chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form dat... | python | def scatter(df, x, y, ax=None, legend=None, title=None,
color=None, marker='o', linestyle=None, cmap=None,
groupby=['model', 'scenario'], with_lines=False, **kwargs):
"""Plot data as a scatter chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form dat... | [
"def",
"scatter",
"(",
"df",
",",
"x",
",",
"y",
",",
"ax",
"=",
"None",
",",
"legend",
"=",
"None",
",",
"title",
"=",
"None",
",",
"color",
"=",
"None",
",",
"marker",
"=",
"'o'",
",",
"linestyle",
"=",
"None",
",",
"cmap",
"=",
"None",
",",
... | Plot data as a scatter chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
x : str
column to be plotted on the x-axis
y : str
column to be plotted on the y-axis
ax : matplotlib.Axes, optional
legend : bool, optional
Include a... | [
"Plot",
"data",
"as",
"a",
"scatter",
"chart",
"."
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L667-L760 | train |
IAMconsortium/pyam | pyam/logger.py | logger | def logger():
"""Access global logger"""
global _LOGGER
if _LOGGER is None:
logging.basicConfig()
_LOGGER = logging.getLogger()
_LOGGER.setLevel('INFO')
return _LOGGER | python | def logger():
"""Access global logger"""
global _LOGGER
if _LOGGER is None:
logging.basicConfig()
_LOGGER = logging.getLogger()
_LOGGER.setLevel('INFO')
return _LOGGER | [
"def",
"logger",
"(",
")",
":",
"global",
"_LOGGER",
"if",
"_LOGGER",
"is",
"None",
":",
"logging",
".",
"basicConfig",
"(",
")",
"_LOGGER",
"=",
"logging",
".",
"getLogger",
"(",
")",
"_LOGGER",
".",
"setLevel",
"(",
"'INFO'",
")",
"return",
"_LOGGER"
] | Access global logger | [
"Access",
"global",
"logger"
] | 4077929ca6e7be63a0e3ecf882c5f1da97b287bf | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/logger.py#L7-L14 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.