_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q234500
get_stmts
train
def get_stmts(pmids_unread, cleanup=True, sparser_version=None): "Run sparser on the pmids in pmids_unread." if sparser_version is None: sparser_version = sparser.get_version() stmts = {} now = datetime.now() outbuf_fname = 'sparser_%s_%s.log' % ( now.strftime('%Y%m%d-%H%M%S'), ...
python
{ "resource": "" }
q234501
run_sparser
train
def run_sparser(pmid_list, tmp_dir, num_cores, start_index, end_index, force_read, force_fulltext, cleanup=True, verbose=True): 'Run the sparser reader on the pmids in pmid_list.' reader_version = sparser.get_version() _, _, _, pmids_read, pmids_unread, _ =\ get_content_to_read( ...
python
{ "resource": "" }
q234502
get_all_descendants
train
def get_all_descendants(parent): """Get all the descendants of a parent class, recursively.""" children = parent.__subclasses__() descendants = children[:] for child in children: descendants += get_all_descendants(child) return descendants
python
{ "resource": "" }
q234503
get_type_hierarchy
train
def get_type_hierarchy(s): """Get the sequence of parents from `s` to Statement. Parameters ---------- s : a class or instance of a child of Statement For example the statement `Phosphorylation(MEK(), ERK())` or just the class `Phosphorylation`. Returns ------- parent_list ...
python
{ "resource": "" }
q234504
get_statement_by_name
train
def get_statement_by_name(stmt_name): """Get a statement class given the name of the statement class.""" stmt_classes = get_all_descendants(Statement) for stmt_class in stmt_classes: if stmt_class.__name__.lower() == stmt_name.lower(): return stmt_class raise NotAStatementName('\"%s\...
python
{ "resource": "" }
q234505
get_unresolved_support_uuids
train
def get_unresolved_support_uuids(stmts): """Get uuids unresolved in support from stmts from stmts_from_json.""" return {s.uuid for stmt in stmts for s in stmt.supports + stmt.supported_by if isinstance(s, Unresolved)}
python
{ "resource": "" }
q234506
stmt_type
train
def stmt_type(obj, mk=True): """Return standardized, backwards compatible object type String. This is a temporary solution to make sure type comparisons and matches keys of Statements and related classes are backwards compatible. """ if isinstance(obj, Statement) and mk: return type(obj...
python
{ "resource": "" }
q234507
Statement.get_hash
train
def get_hash(self, shallow=True, refresh=False): """Get a hash for this Statement. There are two types of hash, "shallow" and "full". A shallow hash is as unique as the information carried by the statement, i.e. it is a hash of the `matches_key`. This means that differences in source, e...
python
{ "resource": "" }
q234508
Statement._tag_evidence
train
def _tag_evidence(self): """Set all the Evidence stmt_tag to my deep matches-key hash.""" h = self.get_hash(shallow=False) for ev in self.evidence: ev.stmt_tag = h return
python
{ "resource": "" }
q234509
Statement.agent_list
train
def agent_list(self, deep_sorted=False): """Get the canonicallized agent list.""" ag_list = [] for ag_name in self._agent_order: ag_attr = getattr(self, ag_name) if isinstance(ag_attr, Concept) or ag_attr is None: ag_list.append(ag_attr) elif i...
python
{ "resource": "" }
q234510
Statement.to_json
train
def to_json(self, use_sbo=False): """Return serialized Statement as a JSON dict. Parameters ---------- use_sbo : Optional[bool] If True, SBO annotations are added to each applicable element of the JSON. Default: False Returns ------- json...
python
{ "resource": "" }
q234511
Statement.to_graph
train
def to_graph(self): """Return Statement as a networkx graph.""" def json_node(graph, element, prefix): if not element: return None node_id = '|'.join(prefix) if isinstance(element, list): graph.add_node(node_id, label='') ...
python
{ "resource": "" }
q234512
Statement.make_generic_copy
train
def make_generic_copy(self, deeply=False): """Make a new matching Statement with no provenance. All agents and other attributes besides evidence, belief, supports, and supported_by will be copied over, and a new uuid will be assigned. Thus, the new Statement will satisfy `new_stmt.match...
python
{ "resource": "" }
q234513
load_lincs_csv
train
def load_lincs_csv(url): """Helper function to turn csv rows into dicts.""" resp = requests.get(url, params={'output_type': '.csv'}, timeout=120) resp.raise_for_status() if sys.version_info[0] < 3: csv_io = BytesIO(resp.content) else: csv_io = StringIO(resp.text) data_rows = list...
python
{ "resource": "" }
q234514
LincsClient.get_small_molecule_name
train
def get_small_molecule_name(self, hms_lincs_id): """Get the name of a small molecule from the LINCS sm metadata. Parameters ---------- hms_lincs_id : str The HMS LINCS ID of the small molecule. Returns ------- str The name of the small mo...
python
{ "resource": "" }
q234515
LincsClient.get_small_molecule_refs
train
def get_small_molecule_refs(self, hms_lincs_id): """Get the id refs of a small molecule from the LINCS sm metadata. Parameters ---------- hms_lincs_id : str The HMS LINCS ID of the small molecule. Returns ------- dict A dictionary of refe...
python
{ "resource": "" }
q234516
LincsClient.get_protein_refs
train
def get_protein_refs(self, hms_lincs_id): """Get the refs for a protein from the LINCs protein metadata. Parameters ---------- hms_lincs_id : str The HMS LINCS ID for the protein Returns ------- dict A dictionary of protein references. ...
python
{ "resource": "" }
q234517
GeneNetwork.get_bel_stmts
train
def get_bel_stmts(self, filter=False): """Get relevant statements from the BEL large corpus. Performs a series of neighborhood queries and then takes the union of all the statements. Because the query process can take a long time for large gene lists, the resulting list of statements ar...
python
{ "resource": "" }
q234518
GeneNetwork.get_biopax_stmts
train
def get_biopax_stmts(self, filter=False, query='pathsbetween', database_filter=None): """Get relevant statements from Pathway Commons. Performs a "paths between" query for the genes in :py:attr:`gene_list` and uses the results to build statements. This function caches t...
python
{ "resource": "" }
q234519
GeneNetwork.get_statements
train
def get_statements(self, filter=False): """Return the combined list of statements from BEL and Pathway Commons. Internally calls :py:meth:`get_biopax_stmts` and :py:meth:`get_bel_stmts`. Parameters ---------- filter : bool If True, includes only those statem...
python
{ "resource": "" }
q234520
GeneNetwork.run_preassembly
train
def run_preassembly(self, stmts, print_summary=True): """Run complete preassembly procedure on the given statements. Results are returned as a dict and stored in the attribute :py:attr:`results`. They are also saved in the pickle file `<basename>_results.pkl`. Parameters ...
python
{ "resource": "" }
q234521
_get_grounding
train
def _get_grounding(entity): """Return Hume grounding.""" db_refs = {'TEXT': entity['text']} groundings = entity.get('grounding') if not groundings: return db_refs def get_ont_concept(concept): """Strip slash, replace spaces and remove example leafs.""" # In the WM context, g...
python
{ "resource": "" }
q234522
HumeJsonLdProcessor._find_relations
train
def _find_relations(self): """Find all relevant relation elements and return them in a list.""" # Get all extractions extractions = \ list(self.tree.execute("$.extractions[(@.@type is 'Extraction')]")) # Get relations from extractions relations = [] for e in ...
python
{ "resource": "" }
q234523
HumeJsonLdProcessor._get_documents
train
def _get_documents(self): """Populate sentences attribute with a dict keyed by document id.""" documents = self.tree.execute("$.documents") for doc in documents: sentences = {s['@id']: s['text'] for s in doc.get('sentences', [])} self.document_dict[doc['@id']] = {'sentenc...
python
{ "resource": "" }
q234524
HumeJsonLdProcessor._make_context
train
def _make_context(self, entity): """Get place and time info from the json for this entity.""" loc_context = None time_context = None # Look for time and place contexts. for argument in entity["arguments"]: if argument["type"] == "place": entity_id = a...
python
{ "resource": "" }
q234525
HumeJsonLdProcessor._make_concept
train
def _make_concept(self, entity): """Return Concept from a Hume entity.""" # Use the canonical name as the name of the Concept by default name = self._sanitize(entity['canonicalName']) # But if there is a trigger head text, we prefer that since # it almost always results in a clea...
python
{ "resource": "" }
q234526
HumeJsonLdProcessor._get_event_and_context
train
def _get_event_and_context(self, event, arg_type): """Return an INDRA Event based on an event entry.""" eid = _choose_id(event, arg_type) ev = self.concept_dict[eid] concept, metadata = self._make_concept(ev) ev_delta = {'adjectives': [], 'states': get_states(...
python
{ "resource": "" }
q234527
HumeJsonLdProcessor._get_evidence
train
def _get_evidence(self, event, adjectives): """Return the Evidence object for the INDRA Statement.""" provenance = event.get('provenance') # First try looking up the full sentence through provenance doc_id = provenance[0]['document']['@id'] sent_id = provenance[0]['sentence'] ...
python
{ "resource": "" }
q234528
_is_statement_in_list
train
def _is_statement_in_list(new_stmt, old_stmt_list): """Return True of given statement is equivalent to on in a list Determines whether the statement is equivalent to any statement in the given list of statements, with equivalency determined by Statement's equals method. Parameters ---------- ...
python
{ "resource": "" }
q234529
normalize_medscan_name
train
def normalize_medscan_name(name): """Removes the "complex" and "complex complex" suffixes from a medscan agent name so that it better corresponds with the grounding map. Parameters ---------- name: str The Medscan agent name Returns ------- norm_name: str The Medscan ag...
python
{ "resource": "" }
q234530
_urn_to_db_refs
train
def _urn_to_db_refs(urn): """Converts a Medscan URN to an INDRA db_refs dictionary with grounding information. Parameters ---------- urn : str A Medscan URN Returns ------- db_refs : dict A dictionary with grounding information, mapping databases to database ide...
python
{ "resource": "" }
q234531
_untag_sentence
train
def _untag_sentence(tagged_sentence): """Removes all tags in the sentence, returning the original sentence without Medscan annotations. Parameters ---------- tagged_sentence : str The tagged sentence Returns ------- untagged_sentence : str Sentence with tags and annotat...
python
{ "resource": "" }
q234532
_extract_sentence_tags
train
def _extract_sentence_tags(tagged_sentence): """Given a tagged sentence, extracts a dictionary mapping tags to the words or phrases that they tag. Parameters ---------- tagged_sentence : str The sentence with Medscan annotations and tags Returns ------- tags : dict A di...
python
{ "resource": "" }
q234533
ProteinSiteInfo.get_sites
train
def get_sites(self): """Parse the site-text string and return a list of sites. Returns ------- sites : list[Site] A list of position-residue pairs corresponding to the site-text """ st = self.site_text suffixes = [' residue', ' residues', ',', '/'] ...
python
{ "resource": "" }
q234534
MedscanProcessor.process_csxml_file
train
def process_csxml_file(self, filename, interval=None, lazy=False): """Processes a filehandle to MedScan csxml input into INDRA statements. The CSXML format consists of a top-level `<batch>` root element containing a series of `<doc>` (document) elements, in turn containing `<sec...
python
{ "resource": "" }
q234535
get_parser
train
def get_parser(description, input_desc): """Get a parser that is generic to reading scripts. Parameters ---------- description : str A description of the tool, usually about one line long. input_desc: str A string describing the nature of the input file used by the reading t...
python
{ "resource": "" }
q234536
send_request
train
def send_request(endpoint, **kwargs): """Return the response to a query as JSON from the NewsAPI web service. The basic API is limited to 100 results which is chosen unless explicitly given as an argument. Beyond that, paging is supported through the "page" argument, if needed. Parameters ----...
python
{ "resource": "" }
q234537
process_cx_file
train
def process_cx_file(file_name, require_grounding=True): """Process a CX JSON file into Statements. Parameters ---------- file_name : str Path to file containing CX JSON. require_grounding: bool Whether network nodes lacking grounding information should be included among the ...
python
{ "resource": "" }
q234538
process_ndex_network
train
def process_ndex_network(network_id, username=None, password=None, require_grounding=True): """Process an NDEx network into Statements. Parameters ---------- network_id : str NDEx network ID. username : str NDEx username. password : str NDEx pass...
python
{ "resource": "" }
q234539
process_cx
train
def process_cx(cx_json, summary=None, require_grounding=True): """Process a CX JSON object into Statements. Parameters ---------- cx_json : list CX JSON object. summary : Optional[dict] The network summary object which can be obtained via get_network_summary through the web ...
python
{ "resource": "" }
q234540
read_files
train
def read_files(files, readers, **kwargs): """Read the files in `files` with the reader objects in `readers`. Parameters ---------- files : list [str] A list of file paths to be read by the readers. Supported files are limited to text and nxml files. readers : list [Reader instances]...
python
{ "resource": "" }
q234541
Expander.expand_families
train
def expand_families(self, stmts): """Generate statements by expanding members of families and complexes. """ new_stmts = [] for stmt in stmts: # Put together the lists of families, with their members. E.g., # for a statement involving RAF and MEK, should return a ...
python
{ "resource": "" }
q234542
update_ontology
train
def update_ontology(ont_url, rdf_path): """Load an ontology formatted like Eidos' from github.""" yaml_root = load_yaml_from_url(ont_url) G = rdf_graph_from_yaml(yaml_root) save_hierarchy(G, rdf_path)
python
{ "resource": "" }
q234543
rdf_graph_from_yaml
train
def rdf_graph_from_yaml(yaml_root): """Convert the YAML object into an RDF Graph object.""" G = Graph() for top_entry in yaml_root: assert len(top_entry) == 1 node = list(top_entry.keys())[0] build_relations(G, node, top_entry[node], None) return G
python
{ "resource": "" }
q234544
load_yaml_from_url
train
def load_yaml_from_url(ont_url): """Return a YAML object loaded from a YAML file URL.""" res = requests.get(ont_url) if res.status_code != 200: raise Exception('Could not load ontology from %s' % ont_url) root = yaml.load(res.content) return root
python
{ "resource": "" }
q234545
IsiPreprocessor.register_preprocessed_file
train
def register_preprocessed_file(self, infile, pmid, extra_annotations): """Set up already preprocessed text file for reading with ISI reader. This is essentially a mock function to "register" already preprocessed files and get an IsiPreprocessor object that can be passed to the IsiProces...
python
{ "resource": "" }
q234546
IsiPreprocessor.preprocess_plain_text_string
train
def preprocess_plain_text_string(self, text, pmid, extra_annotations): """Preprocess plain text string for use by ISI reader. Preprocessing is done by tokenizing into sentences and writing each sentence on its own line in a plain text file. All other preprocessing functions ultimately c...
python
{ "resource": "" }
q234547
IsiPreprocessor.preprocess_plain_text_file
train
def preprocess_plain_text_file(self, filename, pmid, extra_annotations): """Preprocess a plain text file for use with ISI reder. Preprocessing results in a new text file with one sentence per line. Parameters ---------- filename : str The name of the plain t...
python
{ "resource": "" }
q234548
IsiPreprocessor.preprocess_nxml_file
train
def preprocess_nxml_file(self, filename, pmid, extra_annotations): """Preprocess an NXML file for use with the ISI reader. Preprocessing is done by extracting plain text from NXML and then creating a text file with one sentence per line. Parameters ---------- filename :...
python
{ "resource": "" }
q234549
IsiPreprocessor.preprocess_abstract_list
train
def preprocess_abstract_list(self, abstract_list): """Preprocess abstracts in database pickle dump format for ISI reader. For each abstract, creates a plain text file with one sentence per line, and stores metadata to be included with each statement from that abstract. Paramete...
python
{ "resource": "" }
q234550
process_geneways_files
train
def process_geneways_files(input_folder=data_folder, get_evidence=True): """Reads in Geneways data and returns a list of statements. Parameters ---------- input_folder : Optional[str] A folder in which to search for Geneways data. Looks for these Geneways extraction data files: human_ac...
python
{ "resource": "" }
q234551
DanbooruApi_Mixin.post_flag_create
train
def post_flag_create(self, post_id, reason): """Function to flag a post. Parameters: post_id (int): The id of the flagged post. reason (str): The reason of the flagging. """ params = {'post_flag[post_id]': post_id, 'post_flag[reason]': reason} return self...
python
{ "resource": "" }
q234552
DanbooruApi_Mixin.post_versions_list
train
def post_versions_list(self, updater_name=None, updater_id=None, post_id=None, start_id=None): """Get list of post versions. Parameters: updater_name (str): updater_id (int): post_id (int): start_id (int): """ pa...
python
{ "resource": "" }
q234553
DanbooruApi_Mixin.artist_list
train
def artist_list(self, query=None, artist_id=None, creator_name=None, creator_id=None, is_active=None, is_banned=None, empty_only=None, order=None): """Get an artist of a list of artists. Parameters: query (str): This field has multiple...
python
{ "resource": "" }
q234554
DanbooruApi_Mixin.artist_commentary_list
train
def artist_commentary_list(self, text_matches=None, post_id=None, post_tags_match=None, original_present=None, translated_present=None): """list artist commentary. Parameters: text_matches (str): post_id (int): ...
python
{ "resource": "" }
q234555
DanbooruApi_Mixin.artist_commentary_versions
train
def artist_commentary_versions(self, post_id, updater_id): """Return list of artist commentary versions. Parameters: updater_id (int): post_id (int): """ params = {'search[updater_id]': updater_id, 'search[post_id]': post_id} return self._get('artist_comm...
python
{ "resource": "" }
q234556
DanbooruApi_Mixin.note_list
train
def note_list(self, body_matches=None, post_id=None, post_tags_match=None, creator_name=None, creator_id=None, is_active=None): """Return list of notes. Parameters: body_matches (str): The note's body matches the given terms. post_id (int): A specific post. ...
python
{ "resource": "" }
q234557
DanbooruApi_Mixin.note_versions
train
def note_versions(self, updater_id=None, post_id=None, note_id=None): """Get list of note versions. Parameters: updater_id (int): post_id (int): note_id (int): """ params = { 'search[updater_id]': updater_id, 'search[post_id]':...
python
{ "resource": "" }
q234558
DanbooruApi_Mixin.user_list
train
def user_list(self, name=None, name_matches=None, min_level=None, max_level=None, level=None, user_id=None, order=None): """Function to get a list of users or a specific user. Levels: Users have a number attribute called level representing their role. The curre...
python
{ "resource": "" }
q234559
DanbooruApi_Mixin.pool_list
train
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): """Get a list of pools. Parameters: name_matches (str): pool_ids (...
python
{ "resource": "" }
q234560
DanbooruApi_Mixin.pool_versions
train
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
{ "resource": "" }
q234561
DanbooruApi_Mixin.tag_aliases
train
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
{ "resource": "" }
q234562
DanbooruApi_Mixin.tag_implications
train
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
{ "resource": "" }
q234563
DanbooruApi_Mixin.tag_related
train
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
{ "resource": "" }
q234564
DanbooruApi_Mixin.wiki_list
train
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
{ "resource": "" }
q234565
DanbooruApi_Mixin.wiki_versions_list
train
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
{ "resource": "" }
q234566
DanbooruApi_Mixin.forum_topic_list
train
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
{ "resource": "" }
q234567
DanbooruApi_Mixin.forum_post_list
train
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
{ "resource": "" }
q234568
_Pybooru.site_name
train
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
{ "resource": "" }
q234569
_Pybooru.site_url
train
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
{ "resource": "" }
q234570
_Pybooru._request
train
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
{ "resource": "" }
q234571
MoebooruApi_Mixin.post_update
train
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
{ "resource": "" }
q234572
Moebooru.site_name
train
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
{ "resource": "" }
q234573
Moebooru._build_url
train
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
{ "resource": "" }
q234574
Moebooru._build_hash_string
train
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
{ "resource": "" }
q234575
_is_autonomous
train
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
{ "resource": "" }
q234576
symmetricsys
train
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
{ "resource": "" }
q234577
SymbolicSys.from_other
train
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
{ "resource": "" }
q234578
SymbolicSys.get_jac
train
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
{ "resource": "" }
q234579
SymbolicSys.get_jtimes
train
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
{ "resource": "" }
q234580
SymbolicSys.jacobian_singular
train
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
{ "resource": "" }
q234581
SymbolicSys.get_dfdx
train
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
{ "resource": "" }
q234582
SymbolicSys.get_f_ty_callback
train
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
{ "resource": "" }
q234583
SymbolicSys.get_j_ty_callback
train
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
{ "resource": "" }
q234584
SymbolicSys.get_dfdx_callback
train
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
{ "resource": "" }
q234585
SymbolicSys.get_jtimes_callback
train
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
{ "resource": "" }
q234586
PartiallySolvedSystem.from_linear_invariants
train
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
{ "resource": "" }
q234587
chained_parameter_variation
train
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
{ "resource": "" }
q234588
ODESys.pre_process
train
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
{ "resource": "" }
q234589
ODESys.post_process
train
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
{ "resource": "" }
q234590
ODESys.adaptive
train
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
{ "resource": "" }
q234591
ODESys.predefined
train
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
{ "resource": "" }
q234592
ODESys.integrate
train
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
{ "resource": "" }
q234593
ODESys.plot_phase_plane
train
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
{ "resource": "" }
q234594
user_can_edit_news
train
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
{ "resource": "" }
q234595
user_can_edit_newsitem
train
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
{ "resource": "" }
q234596
get_date_or_404
train
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
{ "resource": "" }
q234597
NewsIndexMixin.respond
train
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
{ "resource": "" }
q234598
get_newsitem_model
train
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
{ "resource": "" }
q234599
Tile.from_quad_tree
train
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
{ "resource": "" }