code stringlengths 1 18.2k |
|---|
def make_image(self, conf, images, chain=None, parent_chain=None, made=None, ignore_deps=False, ignore_parent=False, pushing=False): """Make us an image""" made = {} if made is None else made chain = [] if chain is None else chain parent_chain = [] if parent_chain is None else parent_chain if conf.name in made: return ... |
conf.name, conf.image_name) cached = self.build_image(conf, pushing=pushing) made[conf.name] = True return cached |
def build_image(self, conf, pushing=False): """Build this image""" with conf.make_context() as context: try: stream = BuildProgressStream(conf.harpoon.silent_build) with self.remove_replaced_images(conf) as info: cached = NormalBuilder().build(conf, context, stream) info['cached'] = cached except (KeyboardInterrupt, Ex... |
def layered(self, images, only_pushable=False): """Yield layers of images""" if only_pushable: operate_on = dict((image, instance) for image, instance in images.items() if instance.image_index) else: operate_on = images layers = Layers(operate_on, all_images=images) layers.add_all_to_layers() for layer in layers.layere... |
def _init_metadata(self): """stub""" self._shuffle_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'shuffle'), 'element_label': 'Shuffle', 'instructions': 'Shuffle parameters', 'required': True, 'read_only': False, 'linked': True, 'array': False, 'default_boolean_... |
def set_shuffle(self, shuffle): """stub""" if not self.my_osid_object_form._is_valid_boolean( shuffle): raise InvalidArgument('shuffle') self.my_osid_object_form._my_map['shuffle'] = shuffle |
def _is_match(self, response, answer): """For MC, can call through to MultiChoice Item Record?""" # TODO: this varies depending on question type if self._only_generic_right_feedback(): return str(answer.genus_type) == str(RIGHT_ANSWER_GENUS) elif self._is_multiple_choice(): return MultiChoiceItemRecord._is_match(self, ... |
def get_authorizations(self): """Gets the authorization list resulting from the search. return: (osid.authorization.AuthorizationList) - the authorization list raise: IllegalState - list has already been retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalSta... |
def get_vaults(self): """Gets the vault list resulting from the search. return: (osid.authorization.VaultList) - the vault list raise: IllegalState - list has already been retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List has already been retrie... |
def get_knowledge_category(self): """Gets the grade associated with the knowledge dimension. return: (osid.grading.Grade) - the grade raise: IllegalState - has_knowledge_category() is false raise: OperationFailed - unable to complete request compliance: mandatory - This method must be implemented. """ if not self.has_k... |
def get_cognitive_process(self): """Gets the grade associated with the cognitive process. return: (osid.grading.Grade) - the grade raise: IllegalState - has_cognitive_process() is false raise: OperationFailed - unable to complete request compliance: mandatory - This method must be implemented. """ if not self.has_cogni... |
def set_assessment(self, assessment_id=None): """Sets the assessment. arg: assessmentId (osid.id.Id): the new assessment raise: INVALID_ARGUMENT - assessmentId is invalid raise: NoAccess - assessmentId cannot be modified raise: NullArgument - assessmentId is null compliance: mandatory - This method must be implemented.... |
def set_cognitive_process(self, grade_id=None): """Sets the cognitive process. arg: gradeId (osid.id.Id): the new cognitive process raise: INVALID_ARGUMENT - gradeId is invalid raise: NoAccess - gradeId cannot be modified raise: NullArgument - gradeId is null compliance: mandatory - This method must be implemented. """... |
def get_next_objective(self): """Gets the next Objective in this list. return: (osid.learning.Objective) - the next Objective in this list. The has_next() method should be used to test that a next Objective is available before calling this method. raise: IllegalState - no more elements available in this list raise: Ope... |
def get_objective(self): """Gets the related objective. return: (osid.learning.Objective) - the related objective raise: OperationFailed - unable to complete request compliance: mandatory - This method must be implemented. """ # Note that this makes the generic objectives call to Handcar # without specifying the object... |
def get_asset_ids(self): """Gets the Ids of any assets associated with this activity. return: (osid.id.IdList) - list of asset Ids raise: IllegalState - is_asset_based_activity() is false compliance: mandatory - This method must be implemented. """ if not self.is_asset_based_activity(): raise IllegalState() else: ids =... |
def get_assets(self): """Gets any assets associated with this activity. return: (osid.repository.AssetList) - list of assets raise: IllegalState - is_asset_based_activity() is false raise: OperationFailed - unable to complete request compliance: mandatory - This method must be implemented. """ # This includes a kludge ... |
def get_assessment_ids(self): """Gets the Ids of any assessments associated with this activity. return: (osid.id.IdList) - list of assessment Ids raise: IllegalState - is_assessment_based_activity() is false compliance: mandatory - This method must be implemented. """ if not self.is_assessment_based_activity(): raise I... |
def set_assets(self, asset_ids=None): """Sets the assets. arg: assetIds (osid.id.Id): the asset Ids raise: INVALID_ARGUMENT - assetIds is invalid raise: NullArgument - assetIds is null raise: NoAccess - metadata.is_read_only() is true compliance: mandatory - This method must be implemented. """ if asset_ids is None: ra... |
def set_courses(self, course_ids=None): """Sets the courses. arg: courseIds (osid.id.Id): the course Ids raise: INVALID_ARGUMENT - courseIds is invalid raise: NullArgument - courseIds is null raise: NoAccess - metadata.is_read_only() is true compliance: mandatory - This method must be implemented. """ if course_ids is ... |
def set_assessments(self, assessment_ids=None): """Sets the assessments. arg: assessmentIds (osid.id.Id): the assessment Ids raise: INVALID_ARGUMENT - assessmentIds is invalid raise: NullArgument - assessmentIds is null raise: NoAccess - metadata.is_read_only() is true compliance: mandatory - This method must be implem... |
def get_next_activity(self): """Gets the next Activity in this list. return: (osid.learning.Activity) - the next Activity in this list. The has_next() method should be used to test that a next Activity is available before calling this method. raise: IllegalState - no more elements available in this list raise: Operatio... |
def get_next_objective_bank(self): """Gets the next ObjectiveBank in this list. return: (osid.learning.ObjectiveBank) - the next ObjectiveBank in this list. The has_next() method should be used to test that a next ObjectiveBank is available before calling this method. raise: IllegalState - no more elements available in... |
def get_next_objective_banks(self, n=None): """Gets the next set of ObjectiveBank elements in this list which must be less than or equal to the return from available(). arg: n (cardinal): the number of ObjectiveBank elements requested which must be less than or equal to available() return: (osid.learning.ObjectiveBank)... |
except Exception: # Need to specify exceptions here! raise OperationFailed() x = x + 1 return next_list |
def get_report(self): """ describe the graph :returns: report :rtype: string """ ostr = '' ostr += "Nodes: "+str(len(self.__nodes.keys()))+"\n" ostr += "Edges: "+str(len(self.__edges.keys()))+"\n" return ostr |
def get_node_edges(self,node,type="both"): """ given a node return the edges attached, by default get both incoming and outgoing :param node: :param type: :type node: Node :type type: string - default 'both' :returns: edge list :rtype: Edge[] edge list """ if type == "both": return [self.__edges[x] for x in self.__edge... |
def get_children(self,node): """ Find all the children of a node. must be a undirectional graph with no cycles :param node: :type node: Node :returns: list of nodes :rtype: Node[] """ if self.find_cycle() or self.__directionless: sys.stderr.write("ERROR: do cannot find a branch when there are cycles in the graph\n") sy... |
def get_roots(self): """get the roots of a graph. must be a directed graph :returns: root list of nodes :rtype: Node[] """ if self.__directionless: sys.stderr.write("ERROR: can't get roots of an undirected graph\n") sys.exit() outputids = self.__nodes.keys() #print outputids rootset = set(outputids) - set(self.__child_... |
def root_and_children_to_graph(self,root): """Take a root node and its children and make them into graphs""" g = Graph() g.add_node(root) edges = [] edges += self.get_node_edges(root,"outgoing") for c in self.get_children(root): g.add_node(c) edges += self.get_node_edges(c,"outgoing") for e in edges: g.add_edge(e) retu... |
def validate(self): """ Validates whether the particular model is created properly """ if self.stoichiometry_matrix.cols != self.propensities.rows: raise ValueError('There must be a column in stoichiometry matrix ' 'for each row in propensities matrix. ' 'S ({0.rows}x{0.cols}): {0!r} , ' 'propensities ({1.rows}x{1.cols... |
in free_symbols: if symbol not in both: raise ValueError('Propensity {0!r} ' 'contains a free symbol {1!r} ' 'that is not in listed in parameters or species lists ' 'Parameters: {2!r}; ' 'Species: {3!r}'.format(row, symbol, self.parameters, self.species)) seen_free_symbols.update(free_symbols) |
def get_id(self): """Gets the Id associated with this instance of this OSID object. Persisting any reference to this object is done by persisting the Id returned from this method. The Id returned may be different than the Id used to query this object. In this case, the new Id should be preferred over the old one for fu... |
obliterate the object or its ``Id`` but instead should update the properties of the object including the deactiavted status and the elimination of any unwanted pieces of data. As such, there is no means for updating an ``Id`` and providers should consider carefully the identification scheme to implement. ``Id`` assignm... |
namespace=self._namespace, authority=self._authority) |
def _get_record(self, record_type): """Get the record string type value given the record_type.""" if not self.has_record_type(record_type): raise errors.Unsupported() if str(record_type) not in self._records: raise errors.Unimplemented() return self._records[str(record_type)] |
def _init_records(self, record_types): """Initalize all records for this form.""" for record_type in record_types: # This conditional was inserted on 7/11/14. It may prove problematic: if str(record_type) not in self._my_map['recordTypeIds']: record_initialized = self._init_record(str(record_type)) if record_initialize... |
def _delete(self): """Override this method in inheriting objects to perform special clearing operations.""" try: for record in self._records: try: self._records[record]._delete() except AttributeError: pass except AttributeError: pass |
def _get_provider_manager(self, osid, local=False): """Gets the most appropriate provider manager depending on config.""" return get_provider_manager(osid, runtime=self._runtime, proxy=getattr(self, '_proxy', None), local=local) |
def get_record_types(self): """Gets the record types available in this object. A record ``Type`` explicitly indicates the specification of an interface to the record. A record may or may not inherit other record interfaces through interface inheritance in which case support of a record type may not be explicit in the r... |
def is_effective(self): """Tests if the current date is within the start end end dates inclusive. return: (boolean) - ``true`` if this is effective, ``false`` otherwise *compliance: mandatory -- This method must be implemented.* """ now = DateTime.utcnow() return self.get_start_date() <= now and self.get_end_date() >= ... |
def get_start_date(self): """Gets the start date. return: (osid.calendaring.DateTime) - the start date *compliance: mandatory -- This method must be implemented.* """ sdate = self._my_map['startDate'] return DateTime( sdate.year, sdate.month, sdate.day, sdate.hour, sdate.minute, sdate.second, sdate.microsecond) |
def get_provider_id(self): """Gets the ``Id`` of the provider. return: (osid.id.Id) - the provider ``Id`` *compliance: mandatory -- This method must be implemented.* """ if 'providerId' not in self._my_map or not self._my_map['providerId']: raise errors.IllegalState('this sourceable object has no provider set') return ... |
def get_provider(self): """Gets the ``Resource`` representing the provider. return: (osid.resource.Resource) - the provider raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ if 'providerId' not in self._my_map or not self._my_map['providerId']: raise err... |
def get_branding_ids(self): """Gets the branding asset ``Ids``. return: (osid.id.IdList) - a list of asset ``Ids`` *compliance: mandatory -- This method must be implemented.* """ from ..id.objects import IdList if 'brandingIds' not in self._my_map: return IdList([]) id_list = [] for idstr in self._my_map['brandingIds']... |
def get_license(self): """Gets the terms of usage. An empty license means the terms are unknown. return: (osid.locale.DisplayText) - the license *compliance: mandatory -- This method must be implemented.* """ if 'license' in self._my_map: license_text = self._my_map['license'] return DisplayText(display_text_map=licens... |
def rc(self): """Flip the direction""" ntx = self.copy() newstrand = '+' if ntx.strand == '+': newstrand = '-' ntx._options = ntx._options._replace(direction=newstrand) return ntx |
def slice_sequence(self,start,end,directionless=False): """Slice the mapping by the position in the sequence First coordinate is 0-indexed start Second coordinate is 1-indexed finish """ if end > self.length: end = self.length if start < 0: start = 0 if not directionless and self.direction == '-': newend = self.length-... |
def range(self): """Get the range from the leftmost exon to the rightmost :return: total range :rtype: GenomicRange """ return GenomicRange(self._rngs[0].chr,self._rngs[0].start,self._rngs[-1].end) |
def set_strand(self,dir): """Set the strand (direction) :param dir: direction + or - :type dir: char """ self._options = self._options._replace(direction = dir) |
def chr(self): """the reference chromosome. greedy return the first chromosome in exon array :return: chromosome :rtype: string """ if len(self.exons)==0: sys.stderr.write("WARNING can't return chromsome with nothing here\n") return None return self._rngs[0].chr |
def junctions(self): """Can be inferred from the exons, this is not implemented yet""" if len(self.exons) < 2: return [] junctions = [] for i in range(1,len(self.exons)): junctions.append(Junction(self.exons[i-1],self.exons[i])) return junctions |
def get_gpd_line(self,transcript_name=None,gene_name=None,direction=None): """Get the genpred format string representation of the mapping""" return transcript_to_gpd_line(self,transcript_name=transcript_name,gene_name=gene_name,direction=direction) |
def set_gene_name(self,name): """assign a gene name :param name: name :type name: string """ self._options = self._options._replace(gene_name = name) |
def set_transcript_name(self,name): """assign a transcript name :param name: name :type name: string """ self._options = self._options._replace(name = name) |
def exon_overlap(self,tx,multi_minover=10,multi_endfrac=0,multi_midfrac=0.8,single_minover=50,single_frac=0.5,multi_consec=True): """Get a report on how mucht the exons overlap :param tx: :param multi_minover: multi-exons need to overlap by at lest this much to be considered overlapped (default 10) :param multi_endfrac... |
def consecutive_exon_count(self1): """Best number of consecutive exons that overlap :return: matched consecutive exon count :rtype: int """ best = 1 consec = 1 for i in range(0,len(self1.dif1)): if self1.dif1[i] == 1 and self1.dif2[i] == 1: consec += 1 else: consec = 1 if consec > best: best = consec return best |
def is_subset(self1): """ Return value if tx_obj2 is a complete subset of tx_obj1 or tx_obj1 is a complete subset of tx_obj2 Values are: * Return 1: Full overlap (mutual subests) * Return 2: two is a subset of one * Return 3: one is a subset of two * Return False if neither is a subset of the other :return: subset valu... |
def is_full_overlap(self1): """true if they are a full overlap :return: is full overlap :rtype: bool """ if len(self1.overs) == 0: return False if len(self1.dif1) > 0: if max(self1.dif1) != 1 or max(self1.dif2) != 1: return False if self1.start1 and self1.end1 and self1.start2 and self1.end2: return True return False |
def analyze_overs(self1): """A helper function that prepares overlap and consecutive matches data""" #check for full overlap first self1.dif1 = [self1.overs[i][0]-self1.overs[i-1][0] for i in range(1,len(self1.overs))] self1.dif2 = [self1.overs[i][1]-self1.overs[i-1][1] for i in range(1,len(self1.overs))] #see if it st... |
def calculate_overlap(self1): """Create the array that describes how junctions overlap""" overs = [] if not self1.tx_obj1.range.overlaps(self1.tx_obj2.range): return # if they dont overlap wont find anything for i in range(0,len(self1.tx_obj1.exons)): for j in range(0,len(self1.tx_obj2.exons)): osize = self1.tx_obj1.ex... |
#print overs self1.overs = overs |
def is_subset(self): """Return value if tx_obj2 is a complete subset of tx_obj1 or tx_obj1 is a complete subset of tx_obj2 values: * Return 1: Full overlap (mutual subests) * Return 2: two is a subset of one * Return 3: one is a subset of two * Return False if neither is a subset of the other """ if len(self.overs) == ... |
if self.tx_obj1.get_exon_count() != self.tx_obj2.get_exon_count(): raise ValueError('how can be same with different exons'+"\n"+str(self.overs)+"\n"+str(self.dif1)+"\n"+str(self.dif2)+"\n"+str(len(self.j1))+"\n"+str(len(self.j2))+"\n"+str(self.tx_obj1.get_exon_count())+"\n"+str(self.tx_obj2.get_exon_count())) return 1 ... |
def analyze_overs(self): """A helper function to prepare values describing overlaps""" #check for full overlap first self.dif1 = [self.overs[i][0]-self.overs[i-1][0] for i in range(1,len(self.overs))] self.dif2 = [self.overs[i][1]-self.overs[i-1][1] for i in range(1,len(self.overs))] #see if it starts and ends on first... |
def calculate_overlap(self): """Create the array that describes how junctions overlap""" overs = [] if not self.tx_obj1.range.overlaps(self.tx_obj2.range): return [] # if they dont overlap wont find anything for i in range(0,len(self.j1)): for j in range(0,len(self.j2)): if self.j1[i].overlaps(self.j2[j],tolerance=self... |
def get_string(self): """A string representation of the junction :return: string represnetation :rtype: string """ return self.left.chr+':'+str(self.left.end)+'-'+self.right.chr+':'+str(self.right.start) |
def get_range_string(self): """Another string representation of the junction. these may be redundant.""" return self.left.chr+":"+str(self.left.end)+'/'+self.right.chr+":"+str(self.right.start) |
def equals(self,junc): """test equality with another junction""" if self.left.equals(junc.left): return False if self.right.equals(junc.right): return False return True |
def overlaps(self,junc,tolerance=0): """see if junction overlaps with tolerance""" if not self.left.overlaps(junc.left,padding=tolerance): return False if not self.right.overlaps(junc.right,padding=tolerance): return False return True |
def cmp(self,junc,tolerance=0): """ output comparison and allow for tolerance if desired * -1 if junc comes before self * 1 if junc comes after self * 0 if overlaps * 2 if else :param junc: :param tolerance: optional search space (default=0, no tolerance) :type junc: Junction :type tolerance: int :return: value of comp... |
def get_sequence(self,chr=None,start=None,end=None,dir=None,rng=None): """get a sequence :param chr: :param start: :param end: :param dir: charcter +/- :parma rng: :type chr: string :type start: int :type end: int :type dir: char :type rng: GenomicRange :return: sequence :rtype: string """ if rng: chr = rng.chr start =... |
def get_relationship_query_session(self): """Gets the ``OsidSession`` associated with the relationship query service. return: (osid.relationship.RelationshipQuerySession) - a ``RelationshipQuerySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_relationship_query()`` is ``fa... |
def get_relationship_query_session_for_family(self, family_id): """Gets the ``OsidSession`` associated with the relationship query service for the given family. arg: family_id (osid.id.Id): the ``Id`` of the family return: (osid.relationship.RelationshipQuerySession) - a ``RelationshipQuerySession`` raise: NotFound - n... |
def get_relationship_admin_session(self): """Gets the ``OsidSession`` associated with the relationship administration service. return: (osid.relationship.RelationshipAdminSession) - a ``RelationshipAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_relationship_admin()`... |
def get_relationship_admin_session_for_family(self, family_id): """Gets the ``OsidSession`` associated with the relationship administration service for the given family. arg: family_id (osid.id.Id): the ``Id`` of the ``Family`` return: (osid.relationship.RelationshipAdminSession) - a ``RelationshipAdminSession`` raise:... |
def get_relationship_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the relationship lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.RelationshipLookupSession) - a ``RelationshipLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed... |
def get_relationship_lookup_session_for_family(self, family_id, proxy): """Gets the ``OsidSession`` associated with the relationship lookup service for the given family. arg: family_id (osid.id.Id): the ``Id`` of the family arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.RelationshipLookupSession) - a... |
def get_family_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the family lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.FamilyLookupSession) - a ``FamilyLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete re... |
def get_family_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the family administrative service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.FamilyAdminSession) - a ``FamilyAdminSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to comple... |
def get_family_hierarchy_session(self, proxy): """Gets the ``OsidSession`` associated with the family hierarchy service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.FamilyHierarchySession) - a ``FamilyHierarchySession`` for families raise: NullArgument - ``proxy`` is ``null`` raise: OperationFaile... |
def get_family_hierarchy_design_session(self, proxy): """Gets the ``OsidSession`` associated with the family hierarchy design service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.FamilyHierarchyDesignSession) - a ``HierarchyDesignSession`` for families raise: NullArgument - ``proxy`` is ``null`` r... |
def _get_authz_session(self): """Gets the AuthorizationSession for the default (bootstrap) typed Vault Assumes only one vault of this Type, but it can have children depending on underlying impl. """ from ..utilities import BOOTSTRAP_VAULT_TYPE try: vaults = self._get_vault_lookup_session().get_vaults_by_genus_type(BOOT... |
def _get_override_lookup_session(self): """Gets the AuthorizationLookupSession for the override typed Vault Assumes only one """ from ..utilities import OVERRIDE_VAULT_TYPE try: override_vaults = self._get_vault_lookup_session().get_vaults_by_genus_type(OVERRIDE_VAULT_TYPE) except Unimplemented: return None if override... |
def _fetch_headers(self): """Needs ._fh handle to stream to be set by child""" self._header_text, self._n_ref = self._read_top_header() self._ref_lengths, self._ref_names = self._read_reference_information() self._header = SAMHeader(self._header_text) |
def _get_block(self): """Just read a single block from your current location in _fh""" b = self._fh.read(4) # get block size bytes #print self._fh.tell() if not b: raise StopIteration block_size = struct.unpack('<i',b)[0] return self._fh.read(block_size) |
def _read_reference_information(self): """Reads the reference names and lengths""" ref_lengths = {} ref_names = [] for n in range(self._n_ref): l_name = struct.unpack('<i',self._fh.read(4))[0] name = self._fh.read(l_name).rstrip('\0') l_ref = struct.unpack('<i',self._fh.read(4))[0] ref_lengths[name] = l_ref ref_names.a... |
def _read_top_header(self): """Read the header text and number of reference seqs""" magic = self._fh.read(4) l_text = struct.unpack('<i',self._fh.read(4))[0] header_text = self._fh.read(l_text).rstrip('\0') n_ref = struct.unpack('<i',self._fh.read(4))[0] return header_text, n_ref |
def fetch_by_coord(self,coord): """get a single entry by the coordinate location [blockStart, innerStart] .. warning:: creates a new instance of a BAMFile object when maybe the one we had would have worked """ #print coord #print self.path #b2 = BAMFile(self.path,blockStart=coord[0],innerStart=coord[1],index_obj=self.i... |
def fetch_starting_at_coord(self,coord): #b2 = BAMFile(self.path,blockStart=coord[0],innerStart=coord[1],index_obj=self.index,reference=self._reference) """starting at a certain coordinate was supposed to make output .. warning:: creates a new instance of a BAMFile object when maybe the one we had would have worked """... |
def get_agents(self): """Gets the agent list resulting from the search. return: (osid.authentication.AgentList) - the agent list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List has already been retrieved.') s... |
def parse_flag(exception_message): """ Parse the flag from the solver exception. e.g. >>> parse_flag("Exception: Dopri5 failed with flag -3") -3 :param exception_message: message from the exception :type exception_message: str :return: flag id :rtype: int """ import re match = re.match('.* failed with flag (-\d+)', exc... |
def simulate(self, timepoints): """ Simulate initialised solver for the specified timepoints :param timepoints: timepoints that will be returned from simulation :return: a list of trajectories for each of the equations in the problem. """ solver = self._solver last_timepoint = timepoints[-1] try: simulated_timepoints, ... |
def _results_to_trajectories(self, simulated_timepoints, simulated_values): """ Convert the resulting results into a list of trajectories :param simulated_timepoints: timepoints output from a solver :param simulated_values: values returned by the solver :return: """ descriptions = self._problem.left_hand_side_descripto... |
def get_blackbird(url, use_serial=True): """ Return synchronous version of Blackbird interface :param port_url: serial port, i.e. '/dev/ttyUSB0' :return: synchronous implementation of Blackbird interface """ lock = RLock() print(serial) def synchronized(func): @wraps(func) def wrapper(*args, **kwargs): with lock: retur... |
returned by blackbird """ _LOGGER.debug('Sending "%s"', request) if use_serial: # clear self._port.reset_output_buffer() self._port.reset_input_buffer() # send self._port.write(request) self._port.flush() # receive result = bytearray() while True: c = self._port.read(1) if c is None: break if not c: raise serial.Serial... |
# Set zone source self._process_request(_format_set_zone_source(zone, source)) @synchronized def set_all_zone_source(self, source: int): # Set all zones to one source self._process_request(_format_set_all_zone_source(source)) @synchronized def lock_front_buttons(self): # Lock front panel buttons self._process_request(_... |
def get_async_blackbird(port_url, loop): """ Return asynchronous version of Blackbird interface :param port_url: serial port, i.e. '/dev/ttyUSB0' :return: asynchronous implementation of Blackbird interface """ lock = asyncio.Lock() def locked_coro(coro): @asyncio.coroutine @wraps(coro) def wrapper(*args, **kwargs): wit... |
__init__(self, loop): super().__init__() self._loop = loop self._lock = asyncio.Lock() self._transport = None self._connected = asyncio.Event(loop=loop) self.q = asyncio.Queue(loop=loop) def connection_made(self, transport): self._transport = transport self._connected.set() _LOGGER.debug('port opened %s', self._transpo... |
def _set_log_view(self, session): """Sets the underlying log view to match current view""" if self._log_view == COMPARATIVE: try: session.use_comparative_log_view() except AttributeError: pass else: try: session.use_plenary_log_view() except AttributeError: pass |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.