Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def pool_list(self, name_matches=None, pool_ids=None, category=None,
description_matches=None, creator_name=None, creator_id=None,
is_deleted=None, is_active=None, order=None):
params = {
'search[name_matches]'... | [
"Get a list of pools.\n\n Parameters:\n name_matches (str):\n pool_ids (str): Can search for multiple ID's at once, separated by\n commas.\n description_matches (str):\n creator_name (str):\n creator_id (int):\n is_ac... |
Please provide a description of the function:def pool_create(self, name, description, category):
params = {
'pool[name]': name,
'pool[description]': description,
'pool[category]': category
}
return self._get('pools.json', params, method='POST', au... | [
"Function to create a pool (Requires login) (UNTESTED).\n\n Parameters:\n name (str): Pool name.\n description (str): Pool description.\n category (str): Can be: series, collection.\n "
] |
Please provide a description of the function:def pool_update(self, pool_id, name=None, description=None, post_ids=None,
is_active=None, category=None):
params = {
'pool[name]': name,
'pool[description]': description,
'pool[post_ids]': post_ids,
... | [
"Update a pool (Requires login) (UNTESTED).\n\n Parameters:\n pool_id (int): Where pool_id is the pool id.\n name (str):\n description (str):\n post_ids (str): List of space delimited post ids.\n is_active (int): Can be: 1, 0.\n category (str)... |
Please provide a description of the function:def pool_delete(self, pool_id):
return self._get('pools/{0}.json'.format(pool_id), method='DELETE',
auth=True) | [
"Delete a pool (Requires login) (UNTESTED) (Moderator+).\n\n Parameters:\n pool_id (int): Where pool_id is the pool id.\n "
] |
Please provide a description of the function:def pool_undelete(self, pool_id):
return self._get('pools/{0}/undelete.json'.format(pool_id),
method='POST', auth=True) | [
"Undelete a specific poool (Requires login) (UNTESTED) (Moderator+).\n\n Parameters:\n pool_id (int): Where pool_id is the pool id.\n "
] |
Please provide a description of the function:def pool_revert(self, pool_id, version_id):
return self._get('pools/{0}/revert.json'.format(pool_id),
{'version_id': version_id}, method='PUT', auth=True) | [
"Function to revert a specific pool (Requires login) (UNTESTED).\n\n Parameters:\n pool_id (int): Where pool_id is the pool id.\n version_id (int):\n "
] |
Please provide a description of the function:def pool_versions(self, updater_id=None, updater_name=None, pool_id=None):
params = {
'search[updater_id]': updater_id,
'search[updater_name]': updater_name,
'search[pool_id]': pool_id
}
return self._ge... | [
"Get list of pool versions.\n\n Parameters:\n updater_id (int):\n updater_name (str):\n pool_id (int):\n "
] |
Please provide a description of the function:def tag_list(self, name_matches=None, name=None, category=None,
hide_empty=None, has_wiki=None, has_artist=None, order=None):
params = {
'search[name_matches]': name_matches,
'search[name]': name,
'search[... | [
"Get a list of tags.\n\n Parameters:\n name_matches (str): Can be: part or full name.\n name (str): Allows searching for multiple tags with exact given\n names, separated by commas. e.g.\n search[name]=touhou,original,k-on! would return the\... |
Please provide a description of the function:def tag_update(self, tag_id, category):
param = {'tag[category]': category}
return self._get('pools/{0}.json'.format(tag_id), param, method='PUT',
auth=True) | [
"Lets you update a tag (Requires login) (UNTESTED).\n\n Parameters:\n tag_id (int):\n category (str): Can be: 0, 1, 3, 4 (general, artist, copyright,\n character respectively).\n "
] |
Please provide a description of the function:def tag_aliases(self, name_matches=None, antecedent_name=None,
tag_id=None):
params = {
'search[name_matches]': name_matches,
'search[antecedent_name]': antecedent_name,
'search[id]': tag_id
... | [
"Get tags aliases.\n\n Parameters:\n name_matches (str): Match antecedent or consequent name.\n antecedent_name (str): Match antecedent name (exact match).\n tag_id (int): The tag alias id.\n "
] |
Please provide a description of the function:def tag_implications(self, name_matches=None, antecedent_name=None,
tag_id=None):
params = {
'search[name_matches]': name_matches,
'search[antecedent_name]': antecedent_name,
'search[id]': tag_id
... | [
"Get tags implications.\n\n Parameters:\n name_matches (str): Match antecedent or consequent name.\n antecedent_name (str): Match antecedent name (exact match).\n tag_id (int): Tag implication id.\n "
] |
Please provide a description of the function:def tag_related(self, query, category=None):
params = {'query': query, 'category': category}
return self._get('related_tag.json', params) | [
"Get related tags.\n\n Parameters:\n query (str): The tag to find the related tags for.\n category (str): If specified, show only tags of a specific\n category. Can be: General 0, Artist 1, Copyright\n 3 and Character 4.\n "
] |
Please provide a description of the function: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):
params = {
'search[title]': title,
... | [
"Function to retrieves a list of every wiki page.\n\n Parameters:\n title (str): Page title.\n creator_id (int): Creator id.\n body_matches (str): Page content.\n other_names_match (str): Other names.\n creator_name (str): Creator name.\n hide... |
Please provide a description of the function:def wiki_create(self, title, body, other_names=None):
params = {
'wiki_page[title]': title,
'wiki_page[body]': body,
'wiki_page[other_names]': other_names
}
return self._get('wiki_pages.json', params, m... | [
"Action to lets you create a wiki page (Requires login) (UNTESTED).\n\n Parameters:\n title (str): Page title.\n body (str): Page content.\n other_names (str): Other names.\n "
] |
Please provide a description of the function:def wiki_update(self, page_id, title=None, body=None,
other_names=None, is_locked=None, is_deleted=None):
params = {
'wiki_page[title]': title,
'wiki_page[body]': body,
'wiki_page[other_names]': other_n... | [
"Action to lets you update a wiki page (Requires login) (UNTESTED).\n\n Parameters:\n page_id (int): Whre page_id is the wiki page id.\n title (str): Page title.\n body (str): Page content.\n other_names (str): Other names.\n is_locked (int): Can be: 0, ... |
Please provide a description of the function:def wiki_delete(self, page_id):
return self._get('wiki_pages/{0}.json'.format(page_id), auth=True,
method='DELETE') | [
"Delete a specific page wiki (Requires login) (UNTESTED) (Builder+).\n\n Parameters:\n page_id (int):\n "
] |
Please provide a description of the function:def wiki_revert(self, wiki_page_id, version_id):
return self._get('wiki_pages/{0}/revert.json'.format(wiki_page_id),
{'version_id': version_id}, method='PUT', auth=True) | [
"Revert page to a previeous version (Requires login) (UNTESTED).\n\n Parameters:\n wiki_page_id (int): Where page_id is the wiki page id.\n version_id (int):\n "
] |
Please provide a description of the function: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', params) | [
"Return a list of wiki page version.\n\n Parameters:\n page_id (int):\n updater_id (int):\n "
] |
Please provide a description of the function:def forum_topic_list(self, title_matches=None, title=None,
category_id=None):
params = {
'search[title_matches]': title_matches,
'search[title]': title,
'search[category_id]': category_id
... | [
"Function to get forum topics.\n\n Parameters:\n title_matches (str): Search body for the given terms.\n title (str): Exact title match.\n category_id (int): Can be: 0, 1, 2 (General, Tags, Bugs & Features\n respectively).\n "
] |
Please provide a description of the function:def forum_topic_create(self, title, body, category=None):
params = {
'forum_topic[title]': title,
'forum_topic[original_post_attributes][body]': body,
'forum_topic[category_id]': category
}
return self.... | [
"Function to create topic (Requires login) (UNTESTED).\n\n Parameters:\n title (str): topic title.\n body (str): Message of the initial post.\n category (str): Can be: 0, 1, 2 (General, Tags, Bugs & Features\n respectively).\n "
] |
Please provide a description of the function:def forum_topic_update(self, topic_id, title=None, category=None):
params = {
'forum_topic[title]': title,
'forum_topic[category_id]': category
}
return self._get('forum_topics/{0}.json'.format(topic_id), params,
... | [
"Update a specific topic (Login Requires) (UNTESTED).\n\n Parameters:\n topic_id (int): Where topic_id is the topic id.\n title (str): Topic title.\n category (str): Can be: 0, 1, 2 (General, Tags, Bugs & Features\n respectively).\n "
] |
Please provide a description of the function:def forum_topic_delete(self, topic_id):
return self._get('forum_topics/{0}.json'.format(topic_id),
method='DELETE', auth=True) | [
"Delete a topic (Login Requires) (Moderator+) (UNTESTED).\n\n Parameters:\n topic_id (int): Where topic_id is the topic id.\n "
] |
Please provide a description of the function:def forum_topic_undelete(self, topic_id):
return self._get('forum_topics/{0}/undelete.json'.format(topic_id),
method='POST', auth=True) | [
"Un delete a topic (Login requries) (Moderator+) (UNTESTED).\n\n Parameters:\n topic_id (int): Where topic_id is the topic id.\n "
] |
Please provide a description of the function: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):
params = {
'search[creator_id]': creator_id,
... | [
"Return a list of forum posts.\n\n Parameters:\n creator_id (int):\n creator_name (str):\n topic_id (int):\n topic_title_matches (str):\n topic_category_id (int): Can be: 0, 1, 2 (General, Tags, Bugs &\n Features respe... |
Please provide a description of the function:def forum_post_create(self, topic_id, body):
params = {'forum_post[topic_id]': topic_id, 'forum_post[body]': body}
return self._get('forum_posts.json', params, method='POST', auth=True) | [
"Create a forum post (Requires login).\n\n Parameters:\n topic_id (int):\n body (str): Post content.\n "
] |
Please provide a description of the function:def forum_post_update(self, topic_id, body):
params = {'forum_post[body]': body}
return self._get('forum_posts/{0}.json'.format(topic_id), params,
method='PUT', auth=True) | [
"Update a specific forum post (Requries login)(Moderator+)(UNTESTED).\n\n Parameters:\n post_id (int): Forum topic id.\n body (str): Post content.\n "
] |
Please provide a description of the function:def forum_post_delete(self, post_id):
return self._get('forum_posts/{0}.json'.format(post_id),
method='DELETE', auth=True) | [
"Delete a specific forum post (Requires login)(Moderator+)(UNTESTED).\n\n Parameters:\n post_id (int): Forum post id.\n "
] |
Please provide a description of the function:def forum_post_undelete(self, post_id):
return self._get('forum_posts/{0}/undelete.json'.format(post_id),
method='POST', auth=True) | [
"Undelete a specific forum post (Requires login)(Moderator+)(UNTESTED).\n\n Parameters:\n post_id (int): Forum post id.\n "
] |
Please provide a description of the function: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:
raise PybooruError(
"The 'site_name' is not valid, specify... | [
"Function that sets and checks the site name and set url.\n\n Parameters:\n site_name (str): The site name in 'SITE_LIST', default sites.\n\n Raises:\n PybooruError: When 'site_name' isn't valid.\n "
] |
Please provide a description of the function:def site_url(self, url):
# Regular expression to URL validate
regex = re.compile(
r'^(?:http|https)://' # Scheme only HTTP/HTTPS
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?| \
[A-Z0-9-]{2,}(?<... | [
"URL setter and validator for site_url property.\n\n Parameters:\n url (str): URL of on Moebooru/Danbooru based sites.\n\n Raises:\n PybooruError: When URL scheme or URL are invalid.\n "
] |
Please provide a description of the function:def _request(self, url, api_call, request_args, method='GET'):
try:
if method != 'GET':
# Reset content-type for data encoded as a multipart form
self.client.headers.update({'content-type': None})
resp... | [
"Function to request and returning JSON data.\n\n Parameters:\n url (str): Base url call.\n api_call (str): API function to be called.\n request_args (dict): All requests parameters.\n method (str): (Defauld: GET) HTTP method 'GET' or 'POST'\n\n Raises:\n ... |
Please provide a description of the function:def _get(self, api_call, params=None, method='GET', auth=False,
file_=None):
url = "{0}/{1}".format(self.site_url, api_call)
if method == 'GET':
request_args = {'params': params}
else:
request_args = {'da... | [
"Function to preapre API call.\n\n Parameters:\n api_call (str): API function to be called.\n params (str): API function parameters.\n method (str): (Defauld: GET) HTTP method (GET, POST, PUT or\n DELETE)\n file_ (file): File to upload (on... |
Please provide a description of the function:def post_create(self, tags, file_=None, rating=None, source=None,
rating_locked=None, note_locked=None, parent_id=None,
md5=None):
if file_ or source is not None:
params = {
'post[tags]': ta... | [
"Function to create a new post (Requires login).\n\n There are only two mandatory fields: you need to supply the\n 'tags', and you need to supply the 'file_', either through a\n multipart form or through a source URL (Requires login) (UNTESTED).\n\n Parameters:\n tags (str): A... |
Please provide a description of the function: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):
params = {
'id': post_id,
'post[tags]': tags,
... | [
"Update a specific post.\n\n Only the 'post_id' parameter is required. Leave the other parameters\n blank if you don't want to change them (Requires login).\n\n Parameters:\n post_id (int): The id number of the post to update.\n tags (str): A space delimited list of tags. ... |
Please provide a description of the function:def post_vote(self, post_id, score):
if score <= 3 and score >= 0:
params = {'id': post_id, 'score': score}
return self._get('post/vote', params, 'POST')
else:
raise PybooruAPIError("Value of 'score' only can be 0,... | [
"Action lets you vote for a post (Requires login).\n\n Parameters:\n post_id (int): The post id.\n score (int):\n * 0: No voted or Remove vote.\n * 1: Good.\n * 2: Great.\n * 3: Favorite, add post to favorites.\n\n Raise... |
Please provide a description of the function:def tag_update(self, name=None, tag_type=None, is_ambiguous=None):
params = {
'name': name,
'tag[tag_type]': tag_type,
'tag[is_ambiguous]': is_ambiguous
}
return self._get('tag/update', params, 'PUT') | [
"Action to lets you update tag (Requires login) (UNTESTED).\n\n Parameters:\n name (str): The name of the tag to update.\n tag_type (int):\n * General: 0.\n * artist: 1.\n * copyright: 3.\n * character: 4.\n is_ambig... |
Please provide a description of the function:def artist_create(self, name, urls=None, alias=None, group=None):
params = {
'artist[name]': name,
'artist[urls]': urls,
'artist[alias]': alias,
'artist[group]': group
}
return self._get('ar... | [
"Function to create an artist (Requires login) (UNTESTED).\n\n Parameters:\n name (str): The artist's name.\n urls (str): A list of URLs associated with the artist, whitespace\n delimited.\n alias (str): The artist that this artist is an alias for. Simp... |
Please provide a description of the function:def artist_update(self, artist_id, name=None, urls=None, alias=None,
group=None):
params = {
'id': artist_id,
'artist[name]': name,
'artist[urls]': urls,
'artist[alias]': alias,
... | [
"Function to update artists (Requires Login) (UNTESTED).\n\n Only the artist_id parameter is required. The other parameters are\n optional.\n\n Parameters:\n artist_id (int): The id of thr artist to update (Type: INT).\n name (str): The artist's name.\n urls (st... |
Please provide a description of the function:def comment_create(self, post_id, comment_body, anonymous=None):
params = {
'comment[post_id]': post_id,
'comment[body]': comment_body,
'comment[anonymous]': anonymous
}
return self._get('comment/create... | [
"Action to lets you create a comment (Requires login).\n\n Parameters:\n post_id (int): The post id number to which you are responding.\n comment_body (str): The body of the comment.\n anonymous (int): Set to 1 if you want to post this comment\n an... |
Please provide a description of the function:def wiki_create(self, title, body):
params = {'wiki_page[title]': title, 'wiki_page[body]': body}
return self._get('wiki/create', params, method='POST') | [
"Action to lets you create a wiki page (Requires login) (UNTESTED).\n\n Parameters:\n title (str): The title of the wiki page.\n body (str): The body of the wiki page.\n "
] |
Please provide a description of the function:def wiki_update(self, title, new_title=None, page_body=None):
params = {
'title': title,
'wiki_page[title]': new_title,
'wiki_page[body]': page_body
}
return self._get('wiki/update', params, method='PUT... | [
"Action to lets you update a wiki page (Requires login) (UNTESTED).\n\n Parameters:\n title (str): The title of the wiki page to update.\n new_title (str): The new title of the wiki page.\n page_body (str): The new body of the wiki page.\n "
] |
Please provide a description of the function:def note_revert(self, note_id, version):
params = {'id': note_id, 'version': version}
return self._get('note/revert', params, method='PUT') | [
"Function to revert a specific note (Requires login) (UNTESTED).\n\n Parameters:\n note_id (int): The note id to update.\n version (int): The version to revert to.\n "
] |
Please provide a description of the function:def pool_update(self, pool_id, name=None, is_public=None,
description=None):
params = {
'id': pool_id,
'pool[name]': name,
'pool[is_public]': is_public,
'pool[description]': description
... | [
"Function to update a pool (Requires login) (UNTESTED).\n\n Parameters:\n pool_id (int): The pool id number.\n name (str): The name.\n is_public (int): 1 or 0, whether or not the pool is public.\n description (str): A description of the pool.\n "
] |
Please provide a description of the function:def pool_create(self, name, description, is_public):
params = {'pool[name]': name, 'pool[description]': description,
'pool[is_public]': is_public}
return self._get('pool/create', params, method='POST') | [
"Function to create a pool (Require login) (UNTESTED).\n\n Parameters:\n name (str): The name.\n description (str): A description of the pool.\n is_public (int): 1 or 0, whether or not the pool is public.\n "
] |
Please provide a description of the function:def site_name(self, site_name):
# Set base class property site_name
_Pybooru.site_name.fset(self, site_name)
if ('api_version' and 'hashed_string') in SITE_LIST[site_name]:
self.api_version = SITE_LIST[site_name]['api_version']
... | [
"Sets api_version and hash_string.\n\n Parameters:\n site_name (str): The site name in 'SITE_LIST', default sites.\n\n Raises:\n PybooruError: When 'site_name' isn't valid.\n "
] |
Please provide a description of the function: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".format(self.site_url, api_call)
return "{0}/{1}.json".format(self... | [
"Build request url.\n\n Parameters:\n api_call (str): Base API Call.\n\n Returns:\n Complete url (str).\n "
] |
Please provide a description of the function:def _build_hash_string(self):
# Build AUTENTICATION hash_string
# Check if hash_string exists
if self.site_name in SITE_LIST or self.hash_string:
if self.username and self.password:
try:
hash_st... | [
"Function for build password hash string.\n\n Raises:\n PybooruError: When isn't provide hash string.\n PybooruError: When aren't provide username or password.\n PybooruError: When Pybooru can't add password to hash strring.\n "
] |
Please provide a description of the function:def _get(self, api_call, params, method='GET', file_=None):
url = self._build_url(api_call)
if method == 'GET':
request_args = {'params': params}
else:
if self.password_hash is None:
self._build_hash_s... | [
"Function to preapre API call.\n\n Parameters:\n api_call (str): API function to be called.\n params (dict): API function parameters.\n method (str): (Defauld: GET) HTTP method 'GET' or 'POST'\n file_ (file): File to upload.\n "
] |
Please provide a description of the function: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 = expr.has(indep)
if in_there:
return False
ret... | [
" Whether the expressions for the dependent variables are autonomous.\n\n Note that the system may still behave as an autonomous system on the interface\n of :meth:`integrate` due to use of pre-/post-processors.\n "
] |
Please provide a description of the function:def symmetricsys(dep_tr=None, indep_tr=None, SuperClass=TransformedSys, **kwargs):
if dep_tr is not None:
if not callable(dep_tr[0]) or not callable(dep_tr[1]):
raise ValueError("Exceptected dep_tr to be a pair of callables")
if indep_tr is n... | [
" A factory function for creating symmetrically transformed systems.\n\n Creates a new subclass which applies the same transformation for each dependent variable.\n\n Parameters\n ----------\n dep_tr : pair of callables (default: None)\n Forward and backward transformation callbacks to be applied... |
Please provide a description of the function:def get_logexp(a=1, b=0, a2=None, b2=None, backend=None):
if a2 is None:
a2 = a
if b2 is None:
b2 = b
if backend is None:
import sympy as backend
return (lambda x: backend.log(a*x + b),
lambda x: (backend.exp(x) - b2)/... | [
" Utility function for use with :func:symmetricsys.\n\n Creates a pair of callbacks for logarithmic transformation\n (including scaling and shifting): ``u = ln(a*x + b)``.\n\n Parameters\n ----------\n a : number\n Scaling (forward).\n b : number\n Shift (forward).\n a2 : number\n... |
Please provide a description of the function:def from_callback(cls, rhs, ny=None, nparams=None, first_step_factory=None,
roots_cb=None, indep_name=None, **kwargs):
ny, nparams = _get_ny_nparams_from_kw(ny, nparams, kwargs)
be = Backend(kwargs.pop('backend', None))
... | [
" Create an instance from a callback.\n\n Parameters\n ----------\n rhs : callbable\n Signature ``rhs(x, y[:], p[:], backend=math) -> f[:]``.\n ny : int\n Length of ``y`` in ``rhs``.\n nparams : int\n Length of ``p`` in ``rhs``.\n first_step... |
Please provide a description of the function:def from_other(cls, ori, **kwargs):
for k in cls._attrs_to_copy + ('params', 'roots', 'init_indep', 'init_dep'):
if k not in kwargs:
val = getattr(ori, k)
if val is not None:
kwargs[k] = val
... | [
" Creates a new instance with an existing one as a template.\n\n Parameters\n ----------\n ori : SymbolicSys instance\n \\\\*\\\\*kwargs:\n Keyword arguments used to create the new instance.\n\n Returns\n -------\n A new instance of the class.\n\n "... |
Please provide a description of the function:def from_other_new_params(cls, ori, par_subs, new_pars, new_par_names=None,
new_latex_par_names=None, **kwargs):
new_exprs = [expr.subs(par_subs) for expr in ori.exprs]
drop_idxs = [ori.params.index(par) for par in par_s... | [
" Creates a new instance with an existing one as a template (with new parameters)\n\n Calls ``.from_other`` but first it replaces some parameters according to ``par_subs``\n and (optionally) introduces new parameters given in ``new_pars``.\n\n Parameters\n ----------\n ori : Symbo... |
Please provide a description of the function:def from_other_new_params_by_name(cls, ori, par_subs, new_par_names=(), **kwargs):
if not ori.dep_by_name:
warnings.warn('dep_by_name is not True')
if not ori.par_by_name:
warnings.warn('par_by_name is not True')
dep =... | [
" Creates a new instance with an existing one as a template (with new parameters)\n\n Calls ``.from_other_new_params`` but first it creates the new instances from user provided\n callbacks generating the expressions the parameter substitutions.\n\n Parameters\n ----------\n ori : ... |
Please provide a description of the function:def get_jac(self):
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
self._j... | [
" Derives the jacobian from ``self.exprs`` and ``self.dep``. "
] |
Please provide a description of the function:def get_jtimes(self):
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))
f = self.be.Matrix(1, se... | [
" Derive the jacobian-vector product from ``self.exprs`` and ``self.dep``"
] |
Please provide a description of the function:def jacobian_singular(self):
cses, (jac_in_cses,) = self.be.cse(self.get_jac())
if jac_in_cses.nullspace():
return True
else:
return False | [
" Returns True if Jacobian is singular, else False. "
] |
Please provide a description of the function:def get_dfdx(self):
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.Matrix(1,... | [
" Calculates 2nd derivatives of ``self.exprs`` "
] |
Please provide a description of the function: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 is not None:
def _bounds_wrapper(t, y, p=(), be=None):
if lb is not... | [
" Generates a callback for evaluating ``self.exprs``. "
] |
Please provide a description of the function: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:
from scipy.sparse import csc_matrix
def sparse_cb(x, y, p... | [
" Generates a callback for evaluating the jacobian. "
] |
Please provide a description of the function: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`` "
] |
Please provide a description of the function:def get_jtimes_callback(self):
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,
jtimes_exprs... | [
" Generate a callback fro evaluating the jacobian-vector product."
] |
Please provide a description of the function:def from_callback(cls, cb, ny=None, nparams=None, dep_transf_cbs=None,
indep_transf_cbs=None, roots_cb=None, **kwargs):
ny, nparams = _get_ny_nparams_from_kw(ny, nparams, kwargs)
be = Backend(kwargs.pop('backend', None))
... | [
"\n Create an instance from a callback.\n\n Analogous to :func:`SymbolicSys.from_callback`.\n\n Parameters\n ----------\n cb : callable\n Signature ``rhs(x, y[:], p[:]) -> f[:]``\n ny : int\n length of y\n nparams : int\n length of p\... |
Please provide a description of the function:def from_callback(cls, cb, ny=None, nparams=None, dep_scaling=1, indep_scaling=1,
**kwargs):
return TransformedSys.from_callback(
cb, ny, nparams,
dep_transf_cbs=repeat(cls._scale_fw_bw(dep_scaling)),
... | [
"\n Create an instance from a callback.\n\n Analogous to :func:`SymbolicSys.from_callback`.\n\n Parameters\n ----------\n cb : callable\n Signature rhs(x, y[:], p[:]) -> f[:]\n ny : int\n length of y\n nparams : int\n length of p\n ... |
Please provide a description of the function:def from_linear_invariants(cls, ori_sys, preferred=None, **kwargs):
_be = ori_sys.be
A = _be.Matrix(ori_sys.linear_invariants)
rA, pivots = A.rref()
if len(pivots) < A.shape[0]:
# If the linear system contains rows which a... | [
" Reformulates the ODE system in fewer variables.\n\n Given linear invariant equations one can always reduce the number\n of dependent variables in the system by the rank of the matrix describing\n this linear system.\n\n Parameters\n ----------\n ori_sys : :class:`Symbolic... |
Please provide a description of the function:def integrate_auto_switch(odes, kw, x, y0, params=(), **kwargs):
x_arr = np.asarray(x)
if x_arr.shape[-1] > 2:
raise NotImplementedError("Only adaptive support return_on_error for now")
multimode = False if x_arr.ndim < 2 else x_arr.shape[0]
nfo_... | [
" Auto-switching between formulations of ODE system.\n\n In case one has a formulation of a system of ODEs which is preferential in\n the beginning of the integration, this function allows the user to run the\n integration with this system where it takes a user-specified maximum number\n of steps before... |
Please provide a description of the function:def chained_parameter_variation(subject, durations, y0, varied_params, default_params=None,
integrate_kwargs=None, x0=None, npoints=1, numpy=None):
assert len(durations) > 0, 'need at least 1 duration (preferably many)'
assert npo... | [
" Integrate an ODE-system for a serie of durations with some parameters changed in-between\n\n Parameters\n ----------\n subject : function or ODESys instance\n If a function: should have the signature of :meth:`pyodesys.ODESys.integrate`\n (and resturn a :class:`pyodesys.results.Result` obje... |
Please provide a description of the function:def pre_process(self, xout, y0, params=()):
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)] | [
" Transforms input to internal values, used internally. "
] |
Please provide a description of the function:def post_process(self, xout, yout, params):
for post_processor in self.post_processors:
xout, yout, params = post_processor(xout, yout, params)
return xout, yout, params | [
" Transforms internal values to output, used internally. "
] |
Please provide a description of the function:def adaptive(self, y0, x0, xend, params=(), **kwargs):
return self.integrate((x0, xend), y0,
params=params, **kwargs) | [
" Integrate with integrator chosen output.\n\n Parameters\n ----------\n integrator : str\n See :meth:`integrate`.\n y0 : array_like\n See :meth:`integrate`.\n x0 : float\n Initial value of the independent variable.\n xend : float\n ... |
Please provide a description of the function:def predefined(self, y0, xout, params=(), **kwargs):
xout, yout, info = self.integrate(xout, y0, params=params,
force_predefined=True, **kwargs)
return yout, info | [
" Integrate with user chosen output.\n\n Parameters\n ----------\n integrator : str\n See :meth:`integrate`.\n y0 : array_like\n See :meth:`integrate`.\n xout : array_like\n params : array_like\n See :meth:`integrate`.\n \\*\\*kwargs:... |
Please provide a description of the function:def integrate(self, x, y0, params=(), atol=1e-8, rtol=1e-8, **kwargs):
arrs = self.to_arrays(x, y0, params)
_x, _y, _p = _arrs = self.pre_process(*arrs)
ndims = [a.ndim for a in _arrs]
if ndims == [1, 1, 1]:
twodim = False... | [
" Integrate the system of ordinary differential equations.\n\n Solves the initial value problem (IVP).\n\n Parameters\n ----------\n x : array_like or pair (start and final time) or float\n if float:\n make it a pair: (0, x)\n if pair or length-2 arra... |
Please provide a description of the function:def _integrate_scipy(self, intern_xout, intern_y0, intern_p,
atol=1e-8, rtol=1e-8, first_step=None, with_jacobian=None,
force_predefined=False, name=None, **kwargs):
from scipy.integrate import ode
ny... | [
" Do not use directly (use ``integrate('scipy', ...)``).\n\n Uses `scipy.integrate.ode <http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.ode.html>`_\n\n Parameters\n ----------\n \\*args :\n See :meth:`integrate`.\n name : str (default: 'lsoda'/'dopri... |
Please provide a description of the function:def _integrate_gsl(self, *args, **kwargs):
import pygslodeiv2 # Python interface GSL's "odeiv2" integrators
kwargs['with_jacobian'] = kwargs.get(
'method', 'bsimp') in pygslodeiv2.requires_jac
return self._integrate(pygslodeiv2.i... | [
" Do not use directly (use ``integrate(..., integrator='gsl')``).\n\n Uses `GNU Scientific Library <http://www.gnu.org/software/gsl/>`_\n (via `pygslodeiv2 <https://pypi.python.org/pypi/pygslodeiv2>`_)\n to integrate the ODE system.\n\n Parameters\n ----------\n \\*args :\n... |
Please provide a description of the function:def _integrate_odeint(self, *args, **kwargs):
import pyodeint # Python interface to boost's odeint integrators
kwargs['with_jacobian'] = kwargs.get(
'method', 'rosenbrock4') in pyodeint.requires_jac
return self._integrate(pyodein... | [
" Do not use directly (use ``integrate(..., integrator='odeint')``).\n\n Uses `Boost.Numeric.Odeint <http://www.odeint.com>`_\n (via `pyodeint <https://pypi.python.org/pypi/pyodeint>`_) to integrate\n the ODE system.\n "
] |
Please provide a description of the function:def _integrate_cvode(self, *args, **kwargs):
import pycvodes # Python interface to SUNDIALS's cvodes integrators
kwargs['with_jacobian'] = kwargs.get('method', 'bdf') in pycvodes.requires_jac
if 'lband' in kwargs or 'uband' in kwargs or 'ban... | [
" Do not use directly (use ``integrate(..., integrator='cvode')``).\n\n Uses CVode from CVodes in\n `SUNDIALS <https://computation.llnl.gov/casc/sundials/>`_\n (via `pycvodes <https://pypi.python.org/pypi/pycvodes>`_)\n to integrate the ODE system. "
] |
Please provide a description of the function:def plot_phase_plane(self, indices=None, **kwargs):
return self._plot(plot_phase_plane, indices=indices, **kwargs) | [
" Plots a phase portrait from last integration.\n\n This method will be deprecated. Please use :meth:`Result.plot_phase_plane`.\n See :func:`pyodesys.plotting.plot_phase_plane`\n "
] |
Please provide a description of the function:def stiffness(self, xyp=None, eigenvals_cb=None):
if eigenvals_cb is None:
if self.band is not None:
raise NotImplementedError
eigenvals_cb = self._jac_eigenvals_svd
if xyp is None:
x, y, intern_p ... | [
" [DEPRECATED] Use :meth:`Result.stiffness`, stiffness ration\n\n Running stiffness ratio from last integration.\n Calculate sittness ratio, i.e. the ratio between the largest and\n smallest absolute eigenvalue of the jacobian matrix. The user may\n supply their own routine for calculati... |
Please provide a description of the function:def build_dummy_request(newsitem):
url = newsitem.full_url
if url:
url_info = urlparse(url)
hostname = url_info.hostname
path = url_info.path
port = url_info.port or 80
else:
# Cannot determine a URL to this page - cob... | [
"\n Construct a HttpRequest object that is, as far as possible,\n representative of ones that would receive this page as a response. Used\n for previewing / moderation and any other place where we want to\n display a view of this page in the admin interface without going\n through the regular page ro... |
Please provide a description of the function: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:
# admin can edit news iff any news types exist
return bool(newsitem... | [
"\n Check if the user has permission to edit any of the registered NewsItem\n types.\n "
] |
Please provide a description of the function:def user_can_edit_newsitem(user, NewsItem):
for perm in format_perms(NewsItem, ['add', 'change', 'delete']):
if user.has_perm(perm):
return True
return False | [
"\n Check if the user has permission to edit a particular NewsItem type.\n "
] |
Please provide a description of the function:def get_date_or_404(year, month, day):
try:
return datetime.date(int(year), int(month), int(day))
except ValueError:
raise Http404 | [
"Try to make a date from the given inputs, raising Http404 on error"
] |
Please provide a description of the function:def respond(self, request, view, newsitems, extra_context={}):
context = self.get_context(request, view=view)
context.update(self.paginate_newsitems(request, newsitems))
context.update(extra_context)
template = self.get_template(reque... | [
"A helper that takes some news items and returns an HttpResponse"
] |
Please provide a description of the function:def from_latitude_longitude(cls, latitude=0.0, longitude=0.0):
assert -180.0 <= longitude <= 180.0, 'Longitude needs to be a value between -180.0 and 180.0.'
assert -90.0 <= latitude <= 90.0, 'Latitude needs to be a value between -90.0 and 90.0.'
... | [
"Creates a point from lat/lon in WGS84"
] |
Please provide a description of the function:def from_pixel(cls, pixel_x=0, pixel_y=0, zoom=None):
max_pixel = (2 ** zoom) * TILE_SIZE
assert 0 <= pixel_x <= max_pixel, 'Point X needs to be a value between 0 and (2^zoom) * 256.'
assert 0 <= pixel_y <= max_pixel, 'Point Y needs to be a v... | [
"Creates a point from pixels X Y Z (zoom) in pyramid"
] |
Please provide a description of the function:def from_meters(cls, meter_x=0.0, meter_y=0.0):
assert -ORIGIN_SHIFT <= meter_x <= ORIGIN_SHIFT, \
'Meter X needs to be a value between -{0} and {0}.'.format(ORIGIN_SHIFT)
assert -ORIGIN_SHIFT <= meter_y <= ORIGIN_SHIFT, \
'Me... | [
"Creates a point from X Y Z (zoom) meters in Spherical Mercator EPSG:900913"
] |
Please provide a description of the function:def pixels(self, zoom=None):
meter_x, meter_y = self.meters
pixel_x = (meter_x + ORIGIN_SHIFT) / resolution(zoom=zoom)
pixel_y = (meter_y - ORIGIN_SHIFT) / resolution(zoom=zoom)
return abs(round(pixel_x)), abs(round(pixel_y)) | [
"Gets pixels of the EPSG:4326 pyramid by a specific zoom, converted from lat/lon in WGS84"
] |
Please provide a description of the function:def meters(self):
latitude, longitude = self.latitude_longitude
meter_x = longitude * ORIGIN_SHIFT / 180.0
meter_y = math.log(math.tan((90.0 + latitude) * math.pi / 360.0)) / (math.pi / 180.0)
meter_y = meter_y * ORIGIN_SHIFT / 180.0
... | [
"Gets the XY meters in Spherical Mercator EPSG:900913, converted from lat/lon in WGS84"
] |
Please provide a description of the function: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(quad_tree))
offset = int(math.pow(2, zoom)) - 1
google_x, google_y = [red... | [
"Creates a tile from a Microsoft QuadTree"
] |
Please provide a description of the function:def from_tms(cls, tms_x, tms_y, zoom):
max_tile = (2 ** zoom) - 1
assert 0 <= tms_x <= max_tile, 'TMS X needs to be a value between 0 and (2^zoom) -1.'
assert 0 <= tms_y <= max_tile, 'TMS Y needs to be a value between 0 and (2^zoom) -1.'
... | [
"Creates a tile from Tile Map Service (TMS) X Y and zoom"
] |
Please provide a description of the function: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.'
assert 0 <= google_y <= max_tile, 'Google Y needs to be a value between 0 a... | [
"Creates a tile from Google format X Y and zoom"
] |
Please provide a description of the function:def for_point(cls, point, zoom):
latitude, longitude = point.latitude_longitude
return cls.for_latitude_longitude(latitude=latitude, longitude=longitude, zoom=zoom) | [
"Creates a tile for given point"
] |
Please provide a description of the function:def for_pixels(cls, pixel_x, pixel_y, zoom):
tms_x = int(math.ceil(pixel_x / float(TILE_SIZE)) - 1)
tms_y = int(math.ceil(pixel_y / float(TILE_SIZE)) - 1)
return cls(tms_x=tms_x, tms_y=(2 ** zoom - 1) - tms_y, zoom=zoom) | [
"Creates a tile from pixels X Y Z (zoom) in pyramid"
] |
Please provide a description of the function:def for_meters(cls, meter_x, meter_y, zoom):
point = Point.from_meters(meter_x=meter_x, meter_y=meter_y)
pixel_x, pixel_y = point.pixels(zoom=zoom)
return cls.for_pixels(pixel_x=pixel_x, pixel_y=pixel_y, zoom=zoom) | [
"Creates a tile from X Y meters in Spherical Mercator EPSG:900913"
] |
Please provide a description of the function:def for_latitude_longitude(cls, latitude, longitude, zoom):
point = Point.from_latitude_longitude(latitude=latitude, longitude=longitude)
pixel_x, pixel_y = point.pixels(zoom=zoom)
return cls.for_pixels(pixel_x=pixel_x, pixel_y=pixel_y, zoom=... | [
"Creates a tile from lat/lon in WGS84"
] |
Please provide a description of the function: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, 0, -1):
digit = 0
mask = 1 << (i - 1)
if (tms_x & mask) != 0:
d... | [
"Gets the tile in the Microsoft QuadTree format, converted from TMS"
] |
Please provide a description of the function: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"
] |
Please provide a description of the function: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 = (google_x + 1) * TILE_SIZE, (google_y + 1) * TILE_SIZE
point_min = Point.from_p... | [
"Gets the bounds of a tile represented as the most west and south point and the most east and north point"
] |
Please provide a description of the function:def fit(self, X, C):
X, C = _check_fit_input(X, C)
self.nclasses = C.shape[1]
ncombs = int( self.nclasses * (self.nclasses - 1) / 2 )
self.classifiers = [ deepcopy(self.base_classifier) for c in range(ncombs) ]
self.classes_co... | [
"\n Fit one classifier comparing each pair of classes\n \n Parameters\n ----------\n X : array (n_samples, n_features)\n The data on which to fit a cost-sensitive classifier.\n C : array (n_samples, n_classes)\n The cost of predicting each label for ea... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.