_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q48100
Grammar.is_contextfree
train
def is_contextfree(self): """Returns True iff the grammar is context-free.""" for lhs, rhs in self.rules: if len(lhs) != 1: return False if lhs[0] not in self.nonterminals: return False return True
python
{ "resource": "" }
q48101
Grammar.remove_useless
train
def remove_useless(self): """Returns a new grammar containing just useful rules.""" if not self.is_contextfree(): raise ValueError("grammar must be context-free") by_lhs = collections.defaultdict(list) by_rhs = collections.defaultdict(list) for [lhs], rhs in self.rule...
python
{ "resource": "" }
q48102
MergedOptionStringFormatter.special_format_field
train
def special_format_field(self, obj, format_spec): """Know about any special formats""" if format_spec == "env": return "${{{0}}}".format(obj) elif format_spec == "from_env": if obj not in os.environ: raise NoSuchEnvironmentVariable(wanted=obj) ...
python
{ "resource": "" }
q48103
BlackBird._create_threads
train
def _create_threads(self): """ This method creates job instances. """ creator = JobCreator( self.config, self.observers.jobs, self.logger ) self.jobs = creator.job_factory()
python
{ "resource": "" }
q48104
BlackBird.start
train
def start(self): """ main loop. """ def main_loop(): while True: threadnames = [thread.name for thread in threading.enumerate()] for job_name, concrete_job in self.jobs.items(): if job_name not in threadnames: ...
python
{ "resource": "" }
q48105
GradeSystemSearchSession.get_grade_systems_by_search
train
def get_grade_systems_by_search(self, grade_system_query, grade_system_search): """Pass through to provider GradeSystemSearchSession.get_grade_systems_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template if not self....
python
{ "resource": "" }
q48106
GradeEntrySearchSession.get_grade_entries_by_search
train
def get_grade_entries_by_search(self, grade_entry_query, grade_entry_search): """Pass through to provider GradeEntrySearchSession.get_grade_entries_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template if not self._ca...
python
{ "resource": "" }
q48107
GradebookColumnSearchSession.get_gradebook_columns_by_search
train
def get_gradebook_columns_by_search(self, gradebook_column_query, gradebook_column_search): """Pass through to provider GradebookColumnSearchSession.get_gradebook_columns_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template ...
python
{ "resource": "" }
q48108
Alignment.actual_query_range
train
def actual_query_range(self): """This is the actual query range for the positive strand :returns: Range of query positive strand covered :rtype: GenomicRange """ a = self.alignment_ranges #return GenomicRange(a[0][1].chr,a[0][1].start,a[-1][1].end,self.get_strand()) if self.get_strand() ==...
python
{ "resource": "" }
q48109
Alignment.set_reference
train
def set_reference(self,ref): """Set the reference sequence :param ref: reference sequence :type ref: string """ self._options = self._options._replace(reference = ref)
python
{ "resource": "" }
q48110
Alignment.get_alignment_strings
train
def get_alignment_strings(self,min_intron_size=68): """Process the alignment to get information like the alignment strings for each exon. These strings are used by the pretty print. :returns: String representation of the alignment in an easy to read format :rtype: string """ qseq = self.quer...
python
{ "resource": "" }
q48111
Alignment.get_PSL
train
def get_PSL(self,min_intron_size=68): """Get a PSL object representation of the alignment. :returns: PSL representation :rtype: PSL """ from seqtools.format.psl import PSL matches = sum([x[0].length for x in self.alignment_ranges]) # 1. Matches - Number of matching bases that aren't repeats ...
python
{ "resource": "" }
q48112
Alignment.get_SAM
train
def get_SAM(self,min_intron_size=68): """Get a SAM object representation of the alignment. :returns: SAM representation :rtype: SAM """ from seqtools.format.sam import SAM #ar is target then query qname = self.alignment_ranges[0][1].chr flag = 0 if self.strand == '-': flag = 16 ...
python
{ "resource": "" }
q48113
Alignment.construct_cigar
train
def construct_cigar(self,min_intron_size=68): """Create a CIGAR string from the alignment :returns: CIGAR string :rtype: string """ # goes target query ar = self.alignment_ranges cig = '' if ar[0][1].start > 1: # soft clipped cig += str(ar[0][1].start-1)+'S' for i in range(l...
python
{ "resource": "" }
q48114
Alignment.get_target_transcript
train
def get_target_transcript(self,min_intron=1): """Get the mapping of to the target strand :returns: Transcript mapped to target :rtype: Transcript """ if min_intron < 1: sys.stderr.write("ERROR minimum intron should be 1 base or longer\n") sys.exit() #tx = Transcript() rngs = [...
python
{ "resource": "" }
q48115
ProficiencyQuery.match_resource_id
train
def match_resource_id(self, resource_id, match): """Sets the resource ``Id`` for this query. arg: resource_id (osid.id.Id): a resource ``Id`` arg: match (boolean): ``true`` if a positive match, ``false`` for a negative match raise: NullArgument - ``resource_id`` i...
python
{ "resource": "" }
q48116
ProficiencyQuery.match_objective_id
train
def match_objective_id(self, objective_id, match): """Sets the objective ``Id`` for this query. arg: objective_id (osid.id.Id): an objective ``Id`` arg: match (boolean): ``true`` for a positive match, ``false`` for a negative match raise: NullArgument - ``objectiv...
python
{ "resource": "" }
q48117
ProficiencyQuery.match_completion
train
def match_completion(self, start, end, match): """Sets the completion for this query to match completion percentages between the given range inclusive. arg: start (decimal): start of range arg: end (decimal): end of range arg: match (boolean): ``true`` for a positive match, ...
python
{ "resource": "" }
q48118
ProficiencyQuery.match_level_id
train
def match_level_id(self, grade_id, match): """Sets the level grade ``Id`` for this query. arg: grade_id (osid.id.Id): a grade ``Id`` arg: match (boolean): ``true`` for a positive match, ``false`` for a negative match raise: NullArgument - ``grade_id`` is ``null`` ...
python
{ "resource": "" }
q48119
GenomicRangeFromString
train
def GenomicRangeFromString(range_string,payload=None,dir=None): """Constructor for a GenomicRange object that takes a string""" m = re.match('^(.+):(\d+)-(\d+)$',range_string) if not m: sys.stderr.write("ERROR bad genomic range string\n"+range_string+"\n") sys.exit() chr = m.group(1) start = int(m.g...
python
{ "resource": "" }
q48120
GenomicRange.copy
train
def copy(self): """Create a new copy of selfe. does not do a deep copy for payload :return: copied range :rtype: GenomicRange """ return type(self)(self.chr, self.start+self._start_offset, self.end, self.payload, ...
python
{ "resource": "" }
q48121
GenomicRange.get_bed_array
train
def get_bed_array(self): """Return a basic three meber bed array representation of this range :return: list of [chr,start (0-indexed), end (1-indexed] :rtype: list """ arr = [self.chr,self.start-1,self.end] if self.dir: arr.append(self.dir) return arr
python
{ "resource": "" }
q48122
GenomicRange.equals
train
def equals(self,gr): """ check for equality. does not consider direction :param gr: another genomic range :type gr: GenomicRange :return: true if they are the same, false if they are not :rtype: bool """ if self.chr == gr.chr and self.start == gr.start and self.end == gr.end: return T...
python
{ "resource": "" }
q48123
GenomicRange.get_range_string
train
def get_range_string(self): """ get the range string represetation. similar to the default input for UCSC genome browser :return: representation by string like chr2:801-900 :rtype: string """ return self.chr+":"+str(self.start)+"-"+str(self.end)
python
{ "resource": "" }
q48124
GenomicRange.adjacent
train
def adjacent(self,rng2): """ Test for adjacency. :param rng2: :param use_direction: false by default :param type: GenomicRange :param type: use_direction """ if self.chr != rng2.chr: return False if self.direction != rng2.direction and use_direction: return False if self.end == rn...
python
{ "resource": "" }
q48125
GenomicRange.overlaps
train
def overlaps(self,in_genomic_range,padding=0): """do the ranges overlap? :param in_genomic_range: range to compare to :param padding: add to the ends this many (default 0) :type in_genomic_range: GenomicRange :type padding: int :return: True if they overlap :rtype: bool """ if pad...
python
{ "resource": "" }
q48126
GenomicRange.overlap_size
train
def overlap_size(self,in_genomic_range): """ The size of the overlap :param in_genomic_range: the range to intersect :type in_genomic_range: GenomicRange :return: count of overlapping bases :rtype: int """ if self.chr != in_genomic_range.chr: return 0 if self.end < in_genomic_ran...
python
{ "resource": "" }
q48127
GenomicRange.merge
train
def merge(self,range2): """merge this bed with another bed to make a longer bed. Returns None if on different chromosomes. keeps the options of this class (not range2) :param range2: :type range2: GenomicRange :return: bigger range with both :rtype: GenomicRange """ if self.chr != ...
python
{ "resource": "" }
q48128
GenomicRange.intersect
train
def intersect(self,range2): """Return the chunk they overlap as a range. options is passed to result from this object :param range2: :type range2: GenomicRange :return: Range with the intersecting segement, or None if not overlapping :rtype: GenomicRange """ if not self.overlaps(rang...
python
{ "resource": "" }
q48129
GenomicRange.cmp
train
def cmp(self,range2,overlap_size=0): """the comparitor for ranges * return 1 if greater than range2 * return -1 if less than range2 * return 0 if overlapped :param range2: :param overlap_size: allow some padding for an 'equal' comparison (default 0) :type range2: GenomicRange :type ...
python
{ "resource": "" }
q48130
GenomicRange.subtract
train
def subtract(self,range2): """Take another range, and list of ranges after removing range2, keep options from self :param range2: :type range2: GenomicRange :return: List of Genomic Ranges :rtype: GenomicRange[] """ outranges = [] if self.chr != range2.chr: outranges.append(self....
python
{ "resource": "" }
q48131
GenomicRange.distance
train
def distance(self,rng): """The distance between two ranges. :param rng: another range :type rng: GenomicRange :returns: bases separting, 0 if overlapped or adjacent, -1 if on different chromsomes :rtype: int """ if self.chr != rng.chr: return -1 c = self.cmp(rng) if c == 0: return 0...
python
{ "resource": "" }
q48132
RelationshipSearchResults.get_relationships
train
def get_relationships(self): """Gets the relationship list resulting from a search. return: (osid.relationship.RelationshipList) - the relationship list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """...
python
{ "resource": "" }
q48133
FamilySearchResults.get_families
train
def get_families(self): """Gets the family list resulting from a search. return: (osid.relationship.FamilyList) - the family list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: ...
python
{ "resource": "" }
q48134
parse_log_entry
train
def parse_log_entry(text): """This function does all real job on log line parsing. it setup two cases for restart parsing if a line with wrong format was found. Restarts: - use_value: just retuns an object it was passed. This can be any value. - reparse: calls `parse_log_entry` again with...
python
{ "resource": "" }
q48135
log_analyzer
train
def log_analyzer(path): """This procedure replaces every line which can't be parsed with special object MalformedLogEntry. """ with handle(MalformedLogEntryError, lambda (c): invoke_restart('use_value', MalformedLogEntry(c.text...
python
{ "resource": "" }
q48136
log_analyzer2
train
def log_analyzer2(path): """This procedure considers every line which can't be parsed as a line with ERROR level. """ with handle(MalformedLogEntryError, lambda (c): invoke_restart('reparse', 'ERROR: ' + c.text)): for f...
python
{ "resource": "" }
q48137
init
train
def init(db_url, api_url): """ Initialize the database server. Sets some configuration parameters on the server, creates the necessary databases for this project, pushes design documents into those databases, and sets up replication with the cloud server if one has already been selected. """ ...
python
{ "resource": "" }
q48138
clear
train
def clear(): """ Clear all data on the local server. Useful for debugging purposed. """ utils.check_for_local_server() click.confirm( "Are you sure you want to do this? It will delete all of your data", abort=True ) server = Server(config["local_server"]["url"]) for db_na...
python
{ "resource": "" }
q48139
load_fixture
train
def load_fixture(fixture_file): """ Populate the database from a JSON file. Reads the JSON file FIXTURE_FILE and uses it to populate the database. Fuxture files should consist of a dictionary mapping database names to arrays of objects to store in those databases. """ utils.check_for_local_s...
python
{ "resource": "" }
q48140
update_module_types
train
def update_module_types(): """ Download the repositories for all of the firmware_module_type records and update them using the `module.json` files from the repositories themselves. Currently only works for git repositories. """ local_url = config["local_server"]["url"] server = Server(local_...
python
{ "resource": "" }
q48141
strip_comments
train
def strip_comments(code): '''Returns the headers with comments removed. ''' single_comment = compile('//.*') # single line comment multi_comment = compile('/\\*\\*.*?\\*/', re.DOTALL) # multiline comment code = sub(single_comment, '', code) code = sub(multi_comment, '', code) return...
python
{ "resource": "" }
q48142
parse_geometry
train
def parse_geometry(geometry): """Takes a geometry string, returns map of parameters.""" m = re.match("(\d+)x(\d+)([-+]\d+)([-+]\d+)", geometry) if not m: raise ValueError("failed to parse geometry string") return map(int, m.groups())
python
{ "resource": "" }
q48143
BetterDialog.buttons
train
def buttons(self, master): """Adds 'OK' and 'Cancel' buttons to standard button frame. Override if need for different configuration. """ subframe = tk.Frame(master) subframe.pack(side=tk.RIGHT) ttk.Button( subframe, text="OK", width=...
python
{ "resource": "" }
q48144
BetterDialog.ok
train
def ok(self, event=None): """Function called when OK-button is clicked. This method calls check_input(), and if that returns ok it calls execute(), and then destroys the dialog. """ if not self.check_input(): self.initial_focus.focus_set() return ...
python
{ "resource": "" }
q48145
BetterDialog.cancel
train
def cancel(self, event=None): """Function called when Cancel-button clicked. This method returns focus to parent, and destroys the dialog. """ if self.parent != None: self.parent.focus_set() self.destroy()
python
{ "resource": "" }
q48146
MappingGeneric.set_payload
train
def set_payload(self,val): """Set a payload for this object :param val: payload to be stored :type val: Anything that can be put in a list """ self._options = self._options._replace(payload = val)
python
{ "resource": "" }
q48147
MappingGeneric.avg_mutual_coverage
train
def avg_mutual_coverage(self,gpd): """get the coverage fraction of each transcript then return the geometric mean :param gpd: Another transcript :type gpd: Transcript :return: avg_coverage :rtype: float """ ov = self.overlap_size(gpd) if ov == 0: return 0 xfrac = float(ov) / float(s...
python
{ "resource": "" }
q48148
MappingGeneric.overlap_size
train
def overlap_size(self,tx2): """Return the number of overlapping base pairs between two transcripts :param tx2: Another transcript :type tx2: Transcript :return: overlap size in base pairs :rtype: int """ total = 0 for e1 in self.exons: for e2 in tx2.exons: total += e1.over...
python
{ "resource": "" }
q48149
MappingGeneric.overlaps
train
def overlaps(self,tx2): """Return True if overlapping """ total = 0 for e1 in self.exons: for e2 in tx2.exons: if e1.overlap_size(e2) > 0: return True return False
python
{ "resource": "" }
q48150
MappingGeneric.slice_target
train
def slice_target(self,chr,start,end): """Slice the mapping by the target coordinate First coordinate is 0-indexed start Second coordinate is 1-indexed finish """ # create a range that we are going to intersect with trng = Bed(chr,start,end) nrngs = [] for r in sel...
python
{ "resource": "" }
q48151
MappingGeneric.slice_sequence
train
def slice_sequence(self,start,end): """Slice the mapping by the position in the sequence First coordinate is 0-indexed start Second coordinate is 1-indexed finish """ #find the sequence length l = self.length indexstart = start indexend = end ns = [] tot...
python
{ "resource": "" }
q48152
MappingGeneric.sequence
train
def sequence(self): """A strcutre is defined so get, if the sequence is not already there, get the sequence from the reference Always is returned on the positive strand for the MappingGeneric :param ref_dict: reference dictionary (only necessary if sequence has not been set already) :type ref_dict...
python
{ "resource": "" }
q48153
MappingGeneric.get_sequence
train
def get_sequence(self,ref): """get a sequence given a reference""" strand = '+' if not self._options.direction: sys.stderr.write("WARNING: no strand information for the transcript\n") if self._options.direction: strand = self._options.direction seq = '' for e in [x.range for x in self.exon...
python
{ "resource": "" }
q48154
MappingGeneric.get_junctions_string
train
def get_junctions_string(self): """Get a string representation of the junctions. This is almost identical to a previous function. :return: string representation of junction :rtype: string """ self._initialize() return ';'.join([x.get_range_string() for x in self.junctions])
python
{ "resource": "" }
q48155
MappingGeneric.junction_overlap
train
def junction_overlap(self,tx,tolerance=0): """Calculate the junction overlap between two transcripts :param tx: Other transcript :type tx: Transcript :param tolerance: how close to consider two junctions as overlapped (default=0) :type tolerance: int :return: Junction Overlap Report :rtype:...
python
{ "resource": "" }
q48156
MappingGeneric.smooth_gaps
train
def smooth_gaps(self,min_intron): """any gaps smaller than min_intron are joined, andreturns a new mapping with gaps smoothed :param min_intron: the smallest an intron can be, smaller gaps will be sealed :type min_intron: int :return: a mapping with small gaps closed :rtype: MappingGeneric """ ...
python
{ "resource": "" }
q48157
aggregate_registry_timers
train
def aggregate_registry_timers(): """Returns a list of aggregate timing information for registered timers. Each element is a 3-tuple of - timer description - aggregate elapsed time - number of calls The list is sorted by the first start time of each aggregate timer. """ im...
python
{ "resource": "" }
q48158
read_sbml
train
def read_sbml(filename): """ Read the model from a SBML file. :param filename: SBML filename to read the model from :return: A tuple, consisting of :class:`~means.core.model.Model` instance, set of parameter values, and set of initial conditions variables. """ import libsbml i...
python
{ "resource": "" }
q48159
OrderedChoiceItemRecord.is_response_correct
train
def is_response_correct(self, response): """returns True if response evaluates to an Item Answer that is 100 percent correct""" for answer in self.my_osid_object.get_answers(): if self._is_match(response, answer): return True return False
python
{ "resource": "" }
q48160
Day.add_exercises
train
def add_exercises(self, *exercises): """Add the exercises to the day. The method will automatically infer whether a static or dynamic exercise is passed to it. Parameters ---------- *exercises An unpacked tuple of exercises. Examples ------- ...
python
{ "resource": "" }
q48161
parseSOAP
train
def parseSOAP(xml_str, rules = None): """ Replacement for SOAPpy._parseSOAP method to spoof SOAPParser. """ try: from cStringIO import StringIO except ImportError: from StringIO import StringIO parser = xml.sax.make_parser() t = ZimbraSOAPParser(rules = rules) parser.set...
python
{ "resource": "" }
q48162
SoapHttpTransport.build_opener
train
def build_opener(self): """ Builds url opener, initializing proxy. @return: OpenerDirector """ http_handler = urllib2.HTTPHandler() # debuglevel=self.transport.debug if util.empty(self.transport.proxy_url): return urllib2.build_opener(http_handler) p...
python
{ "resource": "" }
q48163
SoapHttpTransport.init_soap_exception
train
def init_soap_exception(self, exc): """ Initializes exception based on soap error response. @param exc: URLError @return: SoapException """ if not isinstance(exc, urllib2.HTTPError): return SoapException(unicode(exc), exc) if isinstance(exc, urllib2.H...
python
{ "resource": "" }
q48164
BaseOrthoQuestionFormRecord.set_ovs_view
train
def set_ovs_view(self, asset_data, view_name): """ view_name should be frontView, sideView, or topView """ if not isinstance(asset_data, DataInputStream): raise InvalidArgument('view file must be an ' + 'osid.transport.DataInputStream object'...
python
{ "resource": "" }
q48165
GradingManager._get_provider_session
train
def _get_provider_session(self, session_name, proxy=None): """Gets the session for the provider""" agent_key = self._get_agent_key(proxy) if session_name in self._provider_sessions[agent_key]: return self._provider_sessions[agent_key][session_name] else: session =...
python
{ "resource": "" }
q48166
GradingManager.use_comparative_gradebook_view
train
def use_comparative_gradebook_view(self): """Pass through to provider GradeSystemGradebookSession.use_comparative_gradebook_view""" self._gradebook_view = COMPARATIVE # self._get_provider_session('grade_system_gradebook_session') # To make sure the session is tracked for session in self....
python
{ "resource": "" }
q48167
GradingManager.use_plenary_gradebook_view
train
def use_plenary_gradebook_view(self): """Pass through to provider GradeSystemGradebookSession.use_plenary_gradebook_view""" self._gradebook_view = PLENARY # self._get_provider_session('grade_system_gradebook_session') # To make sure the session is tracked for session in self._get_provide...
python
{ "resource": "" }
q48168
GradingManager.get_gradebooks_by_parent_genus_type
train
def get_gradebooks_by_parent_genus_type(self, *args, **kwargs): """Pass through to provider GradebookLookupSession.get_gradebooks_by_parent_genus_type""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bins_by_parent_genus_type catalogs = self._get_provider...
python
{ "resource": "" }
q48169
GradingManager.get_gradebooks
train
def get_gradebooks(self): """Pass through to provider GradebookLookupSession.get_gradebooks""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bins_template catalogs = self._get_provider_session('gradebook_lookup_session').get_gradebooks() cat_list ...
python
{ "resource": "" }
q48170
GradingManager.get_gradebook_form
train
def get_gradebook_form(self, *args, **kwargs): """Pass through to provider GradebookAdminSession.get_gradebook_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 tel...
python
{ "resource": "" }
q48171
Gradebook.use_comparative_grade_system_view
train
def use_comparative_grade_system_view(self): """Pass through to provider GradeSystemLookupSession.use_comparative_grade_system_view""" self._object_views['grade_system'] = COMPARATIVE # self._get_provider_session('grade_system_lookup_session') # To make sure the session is tracked for se...
python
{ "resource": "" }
q48172
Gradebook.use_plenary_grade_system_view
train
def use_plenary_grade_system_view(self): """Pass through to provider GradeSystemLookupSession.use_plenary_grade_system_view""" self._object_views['grade_system'] = PLENARY # self._get_provider_session('grade_system_lookup_session') # To make sure the session is tracked for session in sel...
python
{ "resource": "" }
q48173
Gradebook.use_federated_gradebook_view
train
def use_federated_gradebook_view(self): """Pass through to provider GradeSystemLookupSession.use_federated_gradebook_view""" self._gradebook_view = FEDERATED # self._get_provider_session('grade_system_lookup_session') # To make sure the session is tracked for session in self._get_provide...
python
{ "resource": "" }
q48174
Gradebook.use_isolated_gradebook_view
train
def use_isolated_gradebook_view(self): """Pass through to provider GradeSystemLookupSession.use_isolated_gradebook_view""" self._gradebook_view = ISOLATED # self._get_provider_session('grade_system_lookup_session') # To make sure the session is tracked for session in self._get_provider_s...
python
{ "resource": "" }
q48175
Gradebook.get_grade_system_form
train
def get_grade_system_form(self, *args, **kwargs): """Pass through to provider GradeSystemAdminSession.get_grade_system_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time...
python
{ "resource": "" }
q48176
Gradebook.save_grade_system
train
def save_grade_system(self, grade_system_form, *args, **kwargs): """Pass through to provider GradeSystemAdminSession.update_grade_system""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if grade_system_form.is_for_update(): ret...
python
{ "resource": "" }
q48177
Gradebook.use_comparative_grade_entry_view
train
def use_comparative_grade_entry_view(self): """Pass through to provider GradeEntryLookupSession.use_comparative_grade_entry_view""" self._object_views['grade_entry'] = COMPARATIVE # self._get_provider_session('grade_entry_lookup_session') # To make sure the session is tracked for session...
python
{ "resource": "" }
q48178
Gradebook.use_plenary_grade_entry_view
train
def use_plenary_grade_entry_view(self): """Pass through to provider GradeEntryLookupSession.use_plenary_grade_entry_view""" self._object_views['grade_entry'] = PLENARY # self._get_provider_session('grade_entry_lookup_session') # To make sure the session is tracked for session in self._ge...
python
{ "resource": "" }
q48179
Gradebook.get_grade_entry_form
train
def get_grade_entry_form(self, *args, **kwargs): """Pass through to provider GradeEntryAdminSession.get_grade_entry_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time wi...
python
{ "resource": "" }
q48180
Gradebook.save_grade_entry
train
def save_grade_entry(self, grade_entry_form, *args, **kwargs): """Pass through to provider GradeEntryAdminSession.update_grade_entry""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if grade_entry_form.is_for_update(): return s...
python
{ "resource": "" }
q48181
Gradebook.use_comparative_gradebook_column_view
train
def use_comparative_gradebook_column_view(self): """Pass through to provider GradebookColumnLookupSession.use_comparative_gradebook_column_view""" self._object_views['gradebook_column'] = COMPARATIVE # self._get_provider_session('gradebook_column_lookup_session') # To make sure the session is tr...
python
{ "resource": "" }
q48182
Gradebook.use_plenary_gradebook_column_view
train
def use_plenary_gradebook_column_view(self): """Pass through to provider GradebookColumnLookupSession.use_plenary_gradebook_column_view""" self._object_views['gradebook_column'] = PLENARY # self._get_provider_session('gradebook_column_lookup_session') # To make sure the session is tracked ...
python
{ "resource": "" }
q48183
Gradebook.get_gradebook_column_form
train
def get_gradebook_column_form(self, *args, **kwargs): """Pass through to provider GradebookColumnAdminSession.get_gradebook_column_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit s...
python
{ "resource": "" }
q48184
Gradebook.save_gradebook_column
train
def save_gradebook_column(self, gradebook_column_form, *args, **kwargs): """Pass through to provider GradebookColumnAdminSession.update_gradebook_column""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if gradebook_column_form.is_for_updat...
python
{ "resource": "" }
q48185
memoize
train
def memoize(f): """Cache value returned by the function.""" @wraps(f) def w(*args, **kw): memoize.mem[f] = v = f(*args, **kw) return v return w
python
{ "resource": "" }
q48186
project2module
train
def project2module(project): """Convert project name into a module name.""" # Name unification in accordance with PEP 426. project = project.lower().replace("-", "_") if project.startswith("python_"): # Remove conventional "python-" prefix. project = project[7:] return project
python
{ "resource": "" }
q48187
Flake8Checker.add_options
train
def add_options(cls, manager): """Register plug-in specific options.""" kw = {} if flake8.__version__ >= '3.0.0': kw['parse_from_config'] = True manager.add_option( "--known-modules", action='store', default="", help=( ...
python
{ "resource": "" }
q48188
Flake8Checker.parse_options
train
def parse_options(cls, options): """Parse plug-in specific options.""" cls.known_modules = { project2module(k): v.split(",") for k, v in [ x.split(":[") for x in re.split(r"],?", options.known_modules)[:-1] ] }
python
{ "resource": "" }
q48189
Flake8Checker.get_setup
train
def get_setup(cls): """Get package setup.""" try: with open("setup.py") as f: return SetupVisitor(ast.parse(f.read())) except IOError as e: LOG.warning("Couldn't open setup file: %s", e) return SetupVisitor(ast.parse(""))
python
{ "resource": "" }
q48190
Flake8Checker.run
train
def run(self): """Run checker.""" def split(module): """Split module into submodules.""" return tuple(module.split(".")) def modcmp(lib=(), test=()): """Compare import modules.""" if len(lib) > len(test): return False ...
python
{ "resource": "" }
q48191
Image.as_html
train
def as_html(self): """ Returns the image of the Yahoo rss feed as an html string """ return '<a href="{0}"><img height="{1}" width="{2}" src="{3}" alt="{4}"></a>'.format( self.link, self.height, self.width, self.url, self.title)
python
{ "resource": "" }
q48192
ffprobe
train
def ffprobe(input_file, verbose=False): """Runs ffprobe on file and returns python dict with result""" if isinstance(input_file, FileObject): exists = input_file.exists path = input_file.path elif type(input_file) in string_types: exists = os.path.exists(input_file) path = in...
python
{ "resource": "" }
q48193
class_check_para
train
def class_check_para(**kw): """ force check accept and return, decorator, @class_check_para(accept=, returns=, mail=) :param kw: :return: """ try: def decorator(f): def new_f(*args): if "accepts" in kw: assert len(args) == len(kw["accep...
python
{ "resource": "" }
q48194
ExtendedSteps.pay_loan
train
def pay_loan(self, loan_name): """additional when step for loan payments""" loan_payments = { 'student': 600, 'car': 200 } payment_amount = loan_payments[loan_name] self.withdraw(payment_amount)
python
{ "resource": "" }
q48195
ExtendedSteps.withdraw
train
def withdraw(self, amount): """Extends withdraw method to make sure enough funds are in the account, then call withdraw from superclass""" if amount > self.balance: raise ValueError('Insufficient Funds') super().withdraw(amount)
python
{ "resource": "" }
q48196
ExtendedSteps.compare_balance
train
def compare_balance(self, operator, or_equals, amount): """Additional step using regex matcher to compare the current balance with some number""" amount = int(amount) if operator == 'less': if or_equals: self.assertLessEqual(self.balance, amount) else: ...
python
{ "resource": "" }
q48197
ClosureBase._set_mixed_moments_to_zero
train
def _set_mixed_moments_to_zero(self, closed_central_moments, n_counter): r""" In univariate case, set the cross-terms to 0. :param closed_central_moments: matrix of closed central moment :param n_counter: a list of :class:`~means.core.descriptors.Moment`\s representing central moments ...
python
{ "resource": "" }
q48198
read_tgf
train
def read_tgf(filename): """Reads a file in Trivial Graph Format.""" g = Graph() with open(filename) as file: states = {} # Nodes for line in file: line = line.strip() if line == "": continue elif line == "#": break...
python
{ "resource": "" }
q48199
Graph.only_path
train
def only_path(self): """Finds the only path from the start node. If there is more than one, raises ValueError.""" start = [v for v in self.nodes if self.nodes[v].get('start', False)] if len(start) != 1: raise ValueError("graph does not have exactly one start node") ...
python
{ "resource": "" }