code
stringlengths
1
18.2k
def set_branding(self, asset_ids): """Sets the branding. arg: asset_ids (osid.id.Id[]): the new assets raise: InvalidArgument - ``asset_ids`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``asset_ids`` is ``null`` *compliance: mandatory -- This method must be implemented.* """...
def get_license_metadata(self): """Gets the metadata for the license. return: (osid.Metadata) - metadata for the license *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._mdata['license']) metadata.update({'existing_string_values': self._my_map['license']}) return Metadata(**metadata...
def set_license(self, license_): """Sets the license. arg: license (string): the new license raise: InvalidArgument - ``license`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``license`` is ``null`` *compliance: mandatory -- This method must be implemented.* """ self._my_map[...
def clear_license(self): """Removes the license. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_license_metadata().is_read_only() or self.get_license_metadata().is_required()): raise errors.NoA...
def _init_metadata(self, **kwargs): """Initialize metadata for form""" self._mdata.update(default_mdata.get_osid_object_mdata()) OsidForm._init_metadata(self) if 'default_display_name' in kwargs: self._mdata['display_name']['default_string_values'][0]['text'] = kwargs['default_display_name'] update_display_text_default...
def _init_map(self, record_types=None): """Initialize map for form""" OsidForm._init_map(self) self._my_map['displayName'] = dict(self._display_name_default) self._my_map['description'] = dict(self._description_default) self._my_map['genusTypeId'] = self._genus_type_default OsidExtensibleForm._init_map(self, record_typ...
def get_display_name_metadata(self): """Gets the metadata for a display name. return: (osid.Metadata) - metadata for the display name *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._mdata['display_name']) metadata.update({'existing_string_values': self._my_map['displayName']['text'...
def set_display_name(self, display_name): """Sets a display name. A display name is required and if not set, will be set by the provider. arg: display_name (string): the new display name raise: InvalidArgument - ``display_name`` is invalid raise: NoAccess - ``Metadata.isReadonly()`` is ``true`` raise: NullArgument - ``...
def clear_display_name(self): """Clears the display name. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_display_name_metadata().is_read_only() or self.get_display_name_metadata().is_required()): raise err...
def get_description_metadata(self): """Gets the metadata for a description. return: (osid.Metadata) - metadata for the description *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._mdata['description']) metadata.update({'existing_string_values': self._my_map['description']['text']}) ...
def set_description(self, description): """Sets a description. arg: description (string): the new description raise: InvalidArgument - ``description`` is invalid raise: NoAccess - ``Metadata.isReadonly()`` is ``true`` raise: NullArgument - ``description`` is ``null`` *compliance: mandatory -- This method must be implem...
def clear_description(self): """Clears the description. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_description_metadata().is_read_only() or self.get_description_metadata().is_required()): raise errors....
def get_genus_type_metadata(self): """Gets the metadata for a genus type. return: (osid.Metadata) - metadata for the genus *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._mdata['genus_type']) metadata.update({'existing_string_values': self._my_map['genusTypeId']}) return Metadata(*...
def set_genus_type(self, genus_type): """Sets a genus. A genus cannot be cleared because all objects have at minimum a root genus. arg: genus_type (osid.type.Type): the new genus raise: InvalidArgument - ``genus_type`` is invalid raise: NoAccess - ``Metadata.isReadonly()`` is ``true`` raise: NullArgument - ``genus_type...
def clear_genus_type(self): """Clears the genus type. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_genus_type_metadata().is_read_only() or self.get_genus_type_metadata().is_required()): raise errors.NoAc...
def _get_next_n(self, object_class, number=None): """Gets the next set of "n" elements in this list. The specified amount must be less than or equal to the return from ``available()``. arg: n (cardinal): the number of ``Relationship`` elements requested which must be less than or equal to ``available()`` return: (osid....
try: next_list.append(next(self)) except Exception: # Need to specify exceptions here! raise errors.OperationFailed() counter += 1 return object_class(next_list)
def _get_next_object(self, object_class): """stub""" next_object = OsidList.next(self) if isinstance(next_object, dict): next_object = object_class(osid_object_map=next_object, runtime=self._runtime, proxy=self._proxy) elif is_string(next_object) and object_class == Id: next_object = Id(next_object) return next_object
def skip(self, n): """Skip the specified number of elements in the list. If the number skipped is greater than the number of elements in the list, hasNext() becomes false and available() returns zero as there are no more elements to retrieve. arg: n (cardinal): the number of elements to skip *compliance: mandatory -- T...
def get_parent_ids(self): """Gets the parents of this node. return: (osid.id.IdList) - the parents of this node *compliance: mandatory -- This method must be implemented.* """ id_list = [] from ..id.objects import IdList for parent_node in self._my_map['parentNodes']: id_list.append(str(parent_node.ident)) return IdLis...
def get_child_ids(self): """Gets the children of this node. return: (osid.id.IdList) - the children of this node *compliance: mandatory -- This method must be implemented.* """ id_list = [] from ..id.objects import IdList for child_node in self._my_map['childNodes']: id_list.append(str(child_node.ident)) return IdList(...
def get_family(self): """Gets the ``Family`` at this node. return: (osid.relationship.Family) - the family represented by this node *compliance: mandatory -- This method must be implemented.* """ if self._lookup_session is None: mgr = get_provider_manager('RELATIONSHIP', runtime=self._runtime, proxy=self._proxy) self._...
def get_parent_family_nodes(self): """Gets the parents of this family. return: (osid.relationship.FamilyNodeList) - the parents of the ``id`` *compliance: mandatory -- This method must be implemented.* """ parent_family_nodes = [] for node in self._my_map['parentNodes']: parent_family_nodes.append(FamilyNode( node._my_...
def set_display_config(cls, config): # pragma: no cover """ Set configuration for superficial aspects of display. :param DisplayConfig config: a configuration object """ cls.DISPLAY_CONFIG = DisplayConfig( show_approx_str=config.show_approx_str, base_config=config.base_config, digits_config=config.digits_config, strip_...
def cache_key(model, pk): "Generates a cache key for a model instance." app = model._meta.app_label name = model._meta.module_name return 'api:{0}:{1}:{2}'.format(app, name, pk)
def transcript_to_gpd_line(tx,transcript_name=None,gene_name=None,direction=None): """Get the genpred format string representation of the mapping :param transcript_name: :param gene_name: :param strand: :type transcript_name: string :type gene_name: string :type strand: string :return: GPD line :rtype: string """ tname...
str(','.join([str(x.start-1) for x in tx.exons]))+','+"\t" out += str(','.join([str(x.end) for x in tx.exons]))+',' return out
def transcript_to_fake_psl_line(self,ref): """Convert a mapping to a fake PSL line :param ref: reference genome dictionary :type ref: dict() :return: psl line :rtype: string """ self._initialize() e = self mylen = 0 matches = 0 qstartslist = [] for exon in self.exons: mylen = exon.rng.length() matches += mylen qstartsl...
# 15 oline += str(e.exons[0].rng.start-1)+"\t" # 16 oline += str(e.exons[-1].rng.end)+"\t" # 17 oline += str(len(e.exons))+"\t" # 18 oline += ','.join([str(e.exons[x].rng.end-(e.exons[x].rng.start-1)) for x in range(0,len(e.exons))])+','+"\t" # 19 oline += qstarts + "\t" # 20 oline += ','.join([str(x.rng.start-1) for x...
def invoke(self, ns, request_name, params, auth_token, simplify=False): """ Invokes zimbra soap request. """ ZimbraClientTransport.invoke(self, ns, request_name, params, auth_token, simplify) headers = SOAPpy.Types.headerType() if auth_token.token != None: data={sconstant.E_AUTH_TOKEN: auth_token.token, sconstant.E_SES...
def get_type_data(name): """Return dictionary representation of type. Can be used to initialize primordium.type.primitives.Type """ name = name.upper() if name in ISO_CURRENCY_TYPES: article = 'the ' type_name = ISO_CURRENCY_TYPES[name] elif name in ISO_CURRENCY_ELEMENT_TYPES: article = '' type_name = ISO_CURRENCY_ELEM...
def find_package_data( where='.', package='', exclude=standard_exclude, exclude_directories=standard_exclude_directories, only_in_packages=True, show_ignored=False, ): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. The dictionary looks like:: {'package': [files]} Where ``...
by Ian Bicking. """ out = {} stack = [(convert_path(where), '', package, only_in_packages)] while stack: where, prefix, package, only_in_packages = stack.pop(0) for name in os.listdir(where): fn = os.path.join(where, name) if os.path.isdir(fn): bad_name = False for pattern in exclude_directories: if (fnmatchcase(name, ...
( "File %s ignored by pattern %s" % (fn, pattern)) break if bad_name: continue out.setdefault(package, []).append(prefix + name) return out
def buttons(self, master): '''Add a standard button box. Override if you do not want the standard buttons ''' box = tk.Frame(master) ttk.Button( box, text="Next", width=10, command=self.next_day ).pack(side=tk.LEFT, padx=5, pady=5) ttk.Button( box, text="OK", width=10, command=self.ok, default=tk.ACTIVE ).pack(side=tk....
def close(self): """Set some objects to None to hopefully free up some memory.""" self._target_context_errors = None self._query_context_errors = None self._general_errors = None for ae in self._alignment_errors: ae.close() self._alignment_errors = None
def add_alignment_errors(self,ae): """If you alread have thealignment errors, add them for profile construction.""" self._target_context_errors = None self._query_context_errors = None self._alignment_errors.append(ae) self._general_errors.add_alignment_errors(ae)
def add_alignment(self,align): """Calculate alignment errors from the alignment and add it to the profile.""" self._target_context_errors = None self._query_context_errors = None ae = AlignmentErrors(align) self._alignment_errors.append(ae) self._general_errors.add_alignment_errors(ae)
def get_target_context_error_report(self): """Get a report on context-specific errors relative to what is expected on the target strand. :returns: Object with a 'header' and a 'data' where data describes context: before,after ,reference, query. A total is kept for each reference base, and individual errors are finally ...
def get_min_context_count(self,context_type): """Calculate out which context has the minum coverage thusfar. :param context_type: 'target' or 'query' :type context_type: string :returns: Minimum Coverage :rtype: int """ cnt = 10000000000 bases = ['A','C','G','T'] basesplus = ['A','C','G','T','-'] r = None if context_ty...
def write_context_error_report(self,file,context_type): """Write a context error report relative to the target or query into the specified filename :param file: The name of a file to write the report to :param context_type: They type of profile, target or query based :type file: string :type context_type: string """ if...
def get_query_context_error_report(self): """Get a report on context-specific errors relative to what is expected on the query strand. :returns: Object with a 'header' and a 'data' where data describes context: before,after ,reference, query. A total is kept for each reference base, and individual errors are finally ch...
def combine_context_errors(self): """Each alignment contributes some information to the error report. These reports for each alignment need to be gone through and combined into one report. :returns: Dictionary containing the error counts on context base :rtype: dict() """ r = {} if self._target_context_errors: r = self...
[x.get_context_query_errors() for x in self._alignment_errors]: for b in k: if b not in r: r[b] = {} for c in k[b]: if c not in r[b]: r[b][c] = {} for a in k[b][c]: if a not in r[b][c]: r[b][c][a] = {} r[b][c][a]['total'] = 0 r[b][c][a]['types'] = {} r[b][c][a]['total'] += k[b][c][a]['total'] for type in k[b][c][a]['ty...
def get_string(self): """Make a string reprentation of the error stats. :returns: error profile :rtype: string """ ostr = '' ostr += str(len(self._alignment_errors))+" Alignments\n" ostr += 'Target: '+"\n" totbases = sum([len(x.get_target_sequence()) for x in self._alignment_errors]) ostr += ' '+str(totbases)+" Target ...
def get_error_probability(self): """This means for the base we are talking about how many errors between 0 and 1 do we attribute to it? For the 'unobserved' errors, these can only count when one is adjacent to base :returns: error probability p(error_observed)+(1-p_error_observed)*error_unobserved :rtype: float """ a =...
def set_observable(self,tseq,qseq): """Set the observable sequence data :param tseq: target sequence (from the homopolymer) :param qseq: query sequence ( from the homopolymer) :type tseq: string :type qseq: string """ tnt = None qnt = None if len(tseq) > 0: tnt = tseq[0] if len(qseq) > 0: qnt = qseq[0] self._observable...
def set_unobserved_before(self,tlen,qlen,nt,p): """Set the unobservable sequence data before this base :param tlen: target homopolymer length :param qlen: query homopolymer length :param nt: nucleotide :param p: p is the probability of attributing this base to the unobserved error :type tlen: int :type qlen: int :type ...
def set_unobserved_after(self,tlen,qlen,nt,p): """Set the unobservable sequence data after this base :param tlen: target homopolymer length :param qlen: query homopolymer length :param nt: nucleotide :param p: p is the probability of attributing this base to the unobserved error :type tlen: int :type qlen: int :type nt...
def get_adjusted_error_count(self): """ Get the total error count associated with this single base. This would typically be one but sometimes it may be larger for instertions. :returns: error_count :rtype: float """ p1 = self._observable.get_attributable_length() p1 += self._unobservable.get_attributable_length() retur...
def get_base(self): """ Get the single base at this position. :returns: base :rtype: char """ if self._type == 'query': return self._observable.get_query_base() return self._observable.get_target_base()
def get_string(self): """ Get a string representation of this single base error. :returns: report :rtype: string """ ostr = '' ostr += 'BaseError for ['+self._type+'] base: '+self.get_base()+"\n" if self._observable.get_error_probability() > 0: ostr += ' Homopolymer set:'+"\n" ostr += ' '+str(self.get_homopolymer())+"\...
ostr
def get_context_target_errors(self): """A more straitfoward calculation of the context-specific errors relative to the target :returns: matrix of observed contexts and values :rtype: matrix of [before][after][reference]{types} with types being any base or a deletion. """ if self._context_target_errors: return self._con...
before = tunobs.get_before_type() bp = tunobs.get_before_probability() after = tunobs.get_after_type() ap = tunobs.get_after_probability() if otype[2][0][0] == 'N': continue if otype[2][1][0] == 'N': continue if before: if before[2][0][0] == 'N': continue if before[2][1][0] == 'N': continue if after: if after[2][0][0] ...
sure our insertion can't be bigger than 1 hp_insert_before = 0 hp_insert_after = 0 if otype[0] == 'insertion': tb = otype[2][0][0] qb = otype[2][1][0] r[tbefore][tb]['-']['types'][qb] += op/2 r[tb][tafter]['-']['types'][qb] += op/2 #homopolymer ... so we do have the correct base r[tbefore][tafter][t]['types'][qb] += 1 ...
def get_context_query_errors(self): """A more straitfoward calculation of the context-specific errors relative to the query :returns: matrix of observed contexts and values :rtype: matrix of [before][after][query]{types} with types being any base or a deletion. """ if self._context_query_errors: return self._context_qu...
before = tunobs.get_before_type() bp = tunobs.get_before_probability() after = tunobs.get_after_type() ap = tunobs.get_after_probability() if otype[2][0][0] == 'N': continue if otype[2][1][0] == 'N': continue if before: if before[2][0][0] == 'N': continue if before[2][1][0] == 'N': continue if after: if after[2][0][0] ...
sure our deletion can't be bigger than 1 hp_deletion_before = 0 hp_deletion_after = 0 if otype[0] == 'deletion': tb = otype[2][0][0] qb = otype[2][1][0] r[tbefore][tb]['-']['types'][tb] += op/2 r[tb][tafter]['-']['types'][tb] += op/2 #homopolymer ... so we do have the correct base r[tbefore][tafter][t]['types'][tb] += ...
def get_query_errors(self): """ Return a list of base-wise error observations for the query :returns: list of base-wise errors :rtype: list of HPA groups """ if self._query_errors: return self._query_errors v = [] for i in range(len(self._query_hpas)): v.append(self.get_query_error(i)) return v
def get_query_error(self,i): """Just get a single error characterization based on the index :param i: list index :type i: int :returns: base-wise error :rtype: HPA group description """ x = self._query_hpas[i] h = x['hpa'] pos = x['pos'] prob = 0 be = BaseError('query') be.set_observable(h.get_target(),h.get_query()) i...
def get_target_errors(self): """Just get a single error characterization based on the index relative to the target :param i: list index :type i: int :returns: list of base-wise errors :rtype: list of HPA groups """ if self._target_errors: return self._target_errors v = [] for i in range(len(self._target_hpas)): v.appen...
def get_target_error(self,i): """Just get a single error characterization based on the index relative to the target :param i: list index :type i: int :returns: base-wise error :rtype: HPA group description """ x = self._target_hpas[i] h = x['hpa'] pos = x['pos'] prob = 0 be = BaseError('target') be.set_observable(h.get...
def analyze_quality(self): """Go through HPAGroups and store the distro of ordinal values of quality scores""" res = {} for h in self._hpas: if h.type() not in res: res[h.type()]={} for c in h.get_quality(): if c not in res[h.type()]: res[h.type()][c] = 0 res[h.type()][c]+=1 self._quality_distro = res
def get_quality_report_string(self): """get a report on quality score distribution. currently prints to stdout""" if not self._quality_distro: self.analyze_quality() ostr = "" for type in sorted(self._quality_distro.keys()): total = sum([ord(x)*self._quality_distro[type][x] for x in self._quality_distro[type]]) cnt = s...
def _misalign_split(self,alns): """Requires alignment strings have been set so for each exon we have query, target and query_quality _has_quality will specify whether or not the quality is meaningful """ total = [] z = 0 for x in alns: z += 1 exon_num = z if self._alignment.strand == '-': exon_num = (len(alns)-z)+1 buf...
buffer['nt'] or tchar == buffer['nt']: # its a homopolymer match buffer['query'] += qchar buffer['target'] += tchar buffer['query_quality'] += qualchar #print 'homopoly' else: #print 'new thing' #print buffer total.append(buffer) buffer = {'query':qchar,'target':tchar,'query_quality':qualchar,'exon':exon_num} if qchar ...
def get_string(self): """make a string representation of the general error report""" ostr = '' errtotal = self.deletions['total']+self.insertions['total']+self.mismatches ostr += 'from '+str(self.alignment_length)+' bp of alignment'+"\n" ostr += ' '+str(float(errtotal)/float(self.alignment_length))+" error rate\n" ostr...
def get_stats(self): """Return a string describing the stats""" ostr = '' errtotal = self.deletions['total']+self.insertions['total']+self.mismatches ostr += "ALIGNMENT_COUNT\t"+str(self.alignment_count)+"\n" ostr += "ALIGNMENT_BASES\t"+str(self.alignment_length)+"\n" ostr += "ANY_ERROR\t"+str(errtotal)+"\n" ostr += "M...
def get_report(self): """Another report, but not context based""" ostr = '' ostr += "target\tquery\tcnt\ttotal\n" poss = ['-','A','C','G','T'] for target in poss: for query in poss: ostr += target+ "\t"+query+"\t"+str(self.matrix[target][query])+"\t"+str(self.alignment_length)+"\n" return ostr
def add_alignment_errors(self,ae): """Add alignment errors to the group :param ae: one set of alignment errors :param type: """ self.alignment_count += 1 for v in ae.get_HPAGroups(): self._add_HPAGroup(v)
def _set_catalog_view(self, session): """Sets the underlying catalog view to match current view""" if self._catalog_view == COMPARATIVE: try: session.use_comparative_catalog_view() except AttributeError: pass else: try: session.use_plenary_catalog_view() except AttributeError: pass
def use_comparative_catalog_view(self): """Pass through to provider CatalogLookupSession.use_comparative_catalog_view""" self._catalog_view = COMPARATIVE # self._get_provider_session('catalog_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_comparativ...
def use_plenary_catalog_view(self): """Pass through to provider CatalogLookupSession.use_plenary_catalog_view""" self._catalog_view = PLENARY # self._get_provider_session('catalog_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_plenary_catalog_view()...
def get_catalogs_by_ids(self, *args, **kwargs): """Pass through to provider CatalogLookupSession.get_catalogs_by_ids""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bins_by_ids catalogs = self._get_provider_session('catalog_lookup_session').get_catalogs_by_ids(*args, **kwargs) cat_list...
def get_catalogs(self): """Pass through to provider CatalogLookupSession.get_catalogs""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bins_template catalogs = self._get_provider_session('catalog_lookup_session').get_catalogs() cat_list = [] for cat in catalogs: cat_list.append(Catalog(...
def create_catalog(self, *args, **kwargs): """Pass through to provider CatalogAdminSession.create_catalog""" # Implemented from kitosid template for - # osid.resource.BinAdminSession.create_bin return Catalog( self._provider_manager, self._get_provider_session('catalog_admin_session').create_catalog(*args, **kwargs), s...
def get_catalog_form(self, *args, **kwargs): """Pass through to provider CatalogAdminSession.get_catalog_form_for_update""" # Implemented from kitosid template for - # osid.resource.BinAdminSession.get_bin_form_for_update_template # This method might be a bit sketchy. Time will tell. if isinstance(args[-1], list) or 'c...
def save_catalog(self, catalog_form, *args, **kwargs): """Pass through to provider CatalogAdminSession.update_catalog""" # Implemented from kitosid template for - # osid.resource.BinAdminSession.update_bin if catalog_form.is_for_update(): return self.update_catalog(catalog_form, *args, **kwargs) else: return self.creat...
def _set_catalog_view(self, session): """Sets the underlying catalog view to match current view""" if self._catalog_view == FEDERATED: try: session.use_federated_catalog_view() except AttributeError: pass else: try: session.use_isolated_catalog_view() except AttributeError: pass
def generate_n_and_k_counters(max_order, species, central_symbols_prefix="M_", raw_symbols_prefix="x_"): r""" Makes a counter for central moments (n_counter) and a counter for raw moment (k_counter). Each is a list of :class:`~means.approximation.ode_problem.Moment`s. Therefore, each :class:`~means.approximation.ode_pr...
and [0, 0, 1]) descriptors = [] for i in range(len(species)): row = [0]*len(species) row[i] = 1 descriptors.append(row) # We use species name as symbols for first order raw moment k_counter += [Moment(d, s) for d,s in zip(descriptors, species)] # Higher order raw moment descriptors k_counter_descriptors = [i for i in i...
[sp.Symbol(central_symbols_prefix + "_".join([str(s) for s in count])) for count in n_counter_descriptors] n_counter += [Moment(c, s) for c,s in zip(n_counter_descriptors, n_counter_symbols)] return n_counter, k_counter
def build_config(dataset, datasets_dir, phase, problem=None, output_dir='data/output'): """ root@d3m-example-pod:/# cat /input/185_baseball/test_config.json { "problem_schema": "/input/TEST/problem_TEST/problemDoc.json", "problem_root": "/input/TEST/problem_TEST", "dataset_schema": "/input/TEST/dataset_TEST/datasetDoc....
def run(self): """ Overrides the default _run() private method. Performs the complete analysis :return: A fully computed set of Ordinary Differential Equations that can be used for further simulation :rtype: :class:`~means.core.problems.ODEProblem` """ S = self.model.stoichiometry_matrix amat = self.model.propensities ...
y_k} = \mathfb{S_i} \frac{\partial \mathbf{a}}{\partial y_k}` A = sp.Matrix(len(ymat), len(ymat), lambda i, j: 0) for i in range(A.rows): for k in range(A.cols): A[i, k] = reduce(operator.add, [S[i, j] * sp.diff(amat[j], ymat[k]) for j in range(len(amat))]) # `diagA` is a matrix that has values sqrt(a[i]) on the diagon...
= sp.Matrix(cov_matrix) # Matrix of variances (diagonal) and covariances of species i and j differentiated wrt time. # I.e. if i=j, V_ij is the variance, and if i!=j, V_ij is the covariance between species i and species j dVdt = A * V + V * (A.T) + E * (E.T) # build ODEProblem object rhs_redundant = sp.Matrix([i for i ...
= [] for i in non_redundant_idx: rhs.append(rhs_redundant[i]) out_problem = ODEProblem("LNA", ode_terms, rhs, sp.Matrix(self.model.parameters)) return out_problem
def _get_learning_data_path(self): """ Returns the path of learningData.csv in a dataset """ for res in self.dsDoc['dataResources']: resPath = res['resPath'] resType = res['resType'] dirname = os.path.basename(os.path.normpath(os.path.dirname(resPath))) if resType == 'table' and dirname == 'tables': if 'learningData.cs...
def _get_learning_data_resource(self): """ Returns the path of learningData.csv in a dataset """ for res in self.dsDoc['dataResources']: resPath = res['resPath'] resType = res['resType'] if resType == 'table': if 'learningData.csv' in resPath: return res else: raise RuntimeError('could not find learningData.csv') # if ...
def get_data_modality(self): """Detect the data modality based on the resource_types. resource_types == ['table'] => 'single_table' resource_types == ['something_else'...] => 'something_else' # this is not likely resource_types == ['table', 'table'...] => 'multi_table' resource_types == ['table', 'something_else'...] =...
def _get_resources_by_type(self, resource_type): """ Returns the list of resources that are of the indicated type """ resources = [] for res in self.dsDoc['dataResources']: if res['resType'] == resource_type: resources.append(res) return resources
def get_text_path(self): """ Returns the path of the directory containing text if they exist in this dataset. """ for res in self.dsDoc['dataResources']: resPath = res['resPath'] resType = res['resType'] isCollection = res['isCollection'] if resType == 'text' and isCollection: return os.path.join(self.dsHome, resPath) ...
def _get_scope_with_mangled(self, name): """Return a scope containing passed mangled name.""" scope = self while True: parent = scope.get_enclosing_scope() if parent is None: return if name in parent.rev_mangled: return parent scope = parent
def _get_scope_with_symbol(self, name): """Return a scope containing passed name as a symbol name.""" scope = self while True: parent = scope.get_enclosing_scope() if parent is None: return if name in parent.symbols: return parent scope = parent
def get_next_mangled_name(self): """ 1. Do not shadow a mangled name from a parent scope if we reference the original name from that scope in this scope or any sub-scope. 2. Do not shadow an original name from a parent scope if it's not mangled and we reference it in this scope or any sub-scope. """ while True: mangled...
def generator( worker_id, sleep=lambda x: time.sleep(x/1000.0), now=lambda: int(time.time()*1000)): """ worker_id: a unique for your *entire* environment number between 0 and 255 to identify this generator. sleep(n): function to pause this worker for n milliseconds. you usually want to supply a custom method for this i...
log.warning("sequence overrun") sequence = -1 & sequence_mask sleep(1) continue else: sequence = 0 last_timestamp = timestamp yield ( ((timestamp-fitepoch) << timestamp_left_shift) | (worker_id << worker_id_shift) | sequence)
def _init_map(self): """stub""" QuestionTextFormRecord._init_map(self) self.my_osid_object_form._my_map['choices'] = \ self._choices_metadata['default_object_values'][0]
def _init_metadata(self): """stub""" QuestionTextFormRecord._init_metadata(self) self._choices_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'choices'), 'element_label': 'Choices', 'instructions': 'Enter as many choices as you wish', 'required': True, 'read_only...